From 7bf41e1faba75493d4a3605de5becca7553c0b2e Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Wed, 16 Jun 2010 21:08:22 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=B0=20trunk?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit +YUCHENG HU+ git-svn-id: https://svn.code.sf.net/p/hawebs/svn@344 a2543c7e-f6e9-4f8a-8bff-1ffc34733512 --- .../3c788c8140c244baa4de05cad390c937.spc | 8 +- .../components/com_admin/admin.admin.html.php | 670 +- .../components/com_admin/admin.admin.php | 94 +- .../com_admin/tmpl/sysinfo_config.php | 146 +- .../com_admin/toolbar.admin.html.php | 94 +- .../components/com_admin/toolbar.admin.php | 82 +- .../components/com_banners/admin.banners.php | 128 +- .../components/com_banners/banners.xml | 24 +- .../com_banners/controllers/banner.php | 898 +- .../com_banners/controllers/client.php | 427 +- .../com_banners/elements/bannerclient.php | 98 +- .../components/com_banners/helpers/banner.php | 160 +- .../components/com_banners/tables/banner.php | 262 +- .../com_banners/tables/bannerclient.php | 136 +- .../components/com_banners/views/banner.php | 946 +- .../components/com_banners/views/client.php | 514 +- .../components/com_cache/admin.cache.html.php | 306 +- .../components/com_cache/admin.cache.php | 232 +- .../components/com_cache/cache.class.php | 320 +- .../components/com_cache/cache.xml | 24 +- .../com_cache/toolbar.cache.html.php | 78 +- .../components/com_cache/toolbar.cache.php | 62 +- .../com_categories/admin.categories.html.php | 1160 +- .../com_categories/admin.categories.php | 2020 +- .../toolbar.categories.html.php | 168 +- .../com_categories/toolbar.categories.php | 86 +- .../components/com_checkin/admin.checkin.php | 212 +- .../com_checkin/toolbar.checkin.html.php | 60 +- .../com_checkin/toolbar.checkin.php | 46 +- .../components/com_config/admin.config.php | 88 +- .../components/com_config/config.xml | 24 +- .../components/com_config/controller.php | 56 +- .../com_config/controllers/application.php | 974 +- .../com_config/controllers/component.php | 230 +- .../com_config/models/component.php | 112 +- .../com_config/toolbar.config.html.php | 62 +- .../components/com_config/toolbar.config.php | 48 +- .../com_config/views/application/view.php | 270 +- .../com_config/views/component/view.php | 138 +- .../com_contact/admin.contact.html.php | 952 +- .../components/com_contact/admin.contact.php | 1011 +- .../components/com_contact/contact.xml | 24 +- .../components/com_contact/contact_items.xml | 202 +- .../com_contact/elements/contact.php | 86 +- .../components/com_contact/helpers/vcard.php | 186 +- .../components/com_contact/tables/contact.php | 238 +- .../com_contact/toolbar.contact.html.php | 116 +- .../com_contact/toolbar.contact.php | 64 +- .../com_content/admin.content.html.php | 1850 +- .../components/com_content/admin.content.php | 272 +- .../components/com_content/content.xml | 26 +- .../components/com_content/controller.php | 2944 +- .../com_content/elements/article.php | 120 +- .../com_content/elements/author.php | 74 +- .../components/com_content/helper.php | 244 +- .../components/com_content/helper/content.php | 142 +- .../components/com_content/models/element.php | 315 +- .../com_content/toolbar.content.html.php | 166 +- .../com_content/toolbar.content.php | 94 +- .../com_content/views/element/view.php | 411 +- .../com_cpanel/admin.cpanel.html.php | 94 +- .../components/com_cpanel/admin.cpanel.php | 52 +- .../components/com_cpanel/cpanel.xml | 24 +- .../com_cpanel/toolbar.cpanel.html.php | 54 +- .../components/com_cpanel/toolbar.cpanel.php | 48 +- .../com_frontpage/admin.frontpage.php | 739 +- .../components/com_frontpage/frontpage.xml | 22 +- .../com_frontpage/tables/frontpage.php | 68 +- .../com_frontpage/views/frontpage.php | 526 +- .../com_installer/admin.installer.php | 90 +- .../components/com_installer/controller.php | 380 +- .../components/com_installer/helper.php | 72 +- .../components/com_installer/installer.xml | 24 +- .../com_installer/models/components.php | 344 +- .../com_installer/models/extension.php | 282 +- .../com_installer/models/install.php | 470 +- .../com_installer/models/languages.php | 476 +- .../com_installer/models/modules.php | 234 +- .../com_installer/models/plugins.php | 262 +- .../com_installer/models/templates.php | 344 +- .../com_installer/views/components/view.php | 138 +- .../com_installer/views/default/view.php | 144 +- .../com_installer/views/install/view.php | 90 +- .../com_installer/views/languages/view.php | 146 +- .../com_installer/views/modules/view.php | 150 +- .../com_installer/views/plugins/view.php | 142 +- .../com_installer/views/templates/view.php | 146 +- .../com_languages/admin.languages.html.php | 312 +- .../com_languages/admin.languages.php | 306 +- .../components/com_languages/languages.xml | 24 +- .../com_languages/toolbar.languages.html.php | 58 +- .../com_languages/toolbar.languages.php | 48 +- .../components/com_login/admin.login.php | 170 +- .../com_massmail/admin.massmail.html.php | 278 +- .../com_massmail/admin.massmail.php | 308 +- .../components/com_massmail/massmail.xml | 24 +- .../com_massmail/toolbar.massmail.html.php | 68 +- .../com_massmail/toolbar.massmail.php | 48 +- .../com_media/assets/medialist-details.css | 78 +- .../com_media/assets/medialist-thumbs.css | 210 +- .../com_media/assets/mediamanager.css | 212 +- .../com_media/assets/mediamanager.js | 360 +- .../com_media/assets/popup-imagelist.css | 108 +- .../com_media/assets/popup-imagemanager.css | 228 +- .../com_media/assets/popup-imagemanager.js | 492 +- .../components/com_media/controller.php | 180 +- .../components/com_media/controllers/file.php | 376 +- .../com_media/controllers/folder.php | 260 +- .../components/com_media/helpers/media.php | 370 +- .../components/com_media/media.php | 154 +- .../components/com_media/media.xml | 24 +- .../components/com_media/models/list.php | 386 +- .../components/com_media/models/manager.php | 263 +- .../com_media/views/images/view.html.php | 122 +- .../com_media/views/imageslist/view.html.php | 146 +- .../com_media/views/media/view.html.php | 266 +- .../com_media/views/medialist/view.html.php | 180 +- .../components/com_menus/admin.menus.php | 46 +- .../components/com_menus/classes/ilink.php | 787 +- .../components/com_menus/controller.php | 1596 +- .../components/com_menus/helpers/helper.php | 342 +- .../components/com_menus/menus.xml | 24 +- .../components/com_menus/models/item.php | 1584 +- .../components/com_menus/models/list.php | 1501 +- .../components/com_menus/models/menutype.php | 560 +- .../com_menus/views/item/tmpl/form.php | 410 +- .../components/com_menus/views/item/view.php | 374 +- .../com_menus/views/list/tmpl/default.php | 258 +- .../components/com_menus/views/list/view.php | 379 +- .../components/com_menus/views/menus/view.php | 284 +- .../com_messages/admin.messages.html.php | 592 +- .../com_messages/admin.messages.php | 603 +- .../components/com_messages/messages.xml | 24 +- .../com_messages/tables/message.php | 374 +- .../com_messages/toolbar.messages.html.php | 108 +- .../com_messages/toolbar.messages.php | 76 +- .../com_modules/admin.modules.html.php | 1265 +- .../components/com_modules/admin.modules.php | 68 +- .../components/com_modules/controller.php | 1663 +- .../components/com_modules/helpers/xml.php | 90 +- .../components/com_modules/models/module.php | 340 +- .../components/com_modules/modules.xml | 24 +- .../com_modules/toolbar.modules.html.php | 146 +- .../com_modules/toolbar.modules.php | 70 +- .../com_newsfeeds/admin.newsfeeds.html.php | 702 +- .../com_newsfeeds/admin.newsfeeds.php | 931 +- .../com_newsfeeds/elements/newsfeed.php | 118 +- .../components/com_newsfeeds/newsfeeds.xml | 24 +- .../com_newsfeeds/tables/newsfeed.php | 158 +- .../com_newsfeeds/toolbar.newsfeeds.html.php | 106 +- .../com_newsfeeds/toolbar.newsfeeds.php | 62 +- .../components/com_plugins/controller.php | 562 +- .../components/com_plugins/plugins.php | 62 +- .../components/com_plugins/plugins.xml | 24 +- .../com_plugins/views/plugin/view.html.php | 232 +- .../views/plugins/tmpl/default.php | 280 +- .../com_plugins/views/plugins/view.html.php | 279 +- .../components/com_poll/controller.php | 444 +- .../components/com_poll/elements/poll.php | 86 +- .../components/com_poll/poll.php | 64 +- .../components/com_poll/poll.xml | 24 +- .../components/com_poll/tables/poll.php | 276 +- .../com_poll/views/poll/view.html.php | 164 +- .../com_poll/views/polls/tmpl/default.php | 252 +- .../com_poll/views/polls/view.html.php | 219 +- .../components/com_search/controller.php | 90 +- .../components/com_search/helpers/search.php | 408 +- .../components/com_search/helpers/site.php | 74 +- .../components/com_search/models/search.php | 245 +- .../components/com_search/search.php | 42 +- .../components/com_search/search.xml | 24 +- .../com_search/views/search/view.php | 130 +- .../com_sections/admin.sections.html.php | 870 +- .../com_sections/admin.sections.php | 1425 +- .../com_sections/toolbar.sections.html.php | 130 +- .../com_sections/toolbar.sections.php | 74 +- .../com_templates/admin.templates.html.php | 1240 +- .../com_templates/admin.templates.php | 200 +- .../components/com_templates/controller.php | 1000 +- .../com_templates/helpers/template.php | 238 +- .../components/com_templates/templates.xml | 24 +- .../com_templates/toolbar.templates.html.php | 152 +- .../com_templates/toolbar.templates.php | 94 +- .../components/com_trash/admin.trash.html.php | 722 +- .../components/com_trash/admin.trash.php | 794 +- .../com_trash/toolbar.trash.html.php | 94 +- .../components/com_trash/toolbar.trash.php | 64 +- .../components/com_trash/trash.xml | 22 +- .../components/com_users/controller.php | 929 +- .../components/com_users/users.class.php | 60 +- .../components/com_users/users.php | 66 +- .../components/com_users/users.xml | 24 +- .../com_users/views/user/view.html.php | 282 +- .../com_users/views/users/tmpl/default.php | 274 +- .../com_users/views/users/view.html.php | 331 +- .../components/com_weblinks/controller.php | 408 +- .../com_weblinks/models/weblink.php | 776 +- .../com_weblinks/models/weblinks.php | 383 +- .../com_weblinks/tables/weblink.php | 380 +- .../com_weblinks/views/weblink/view.html.php | 222 +- .../views/weblinks/tmpl/default.php | 282 +- .../com_weblinks/views/weblinks/view.html.php | 141 +- .../components/com_weblinks/weblinks.php | 64 +- .../components/com_weblinks/weblinks.xml | 24 +- .../help/en-GB/joomla.credits.html | 26 +- .../help/en-GB/joomla.glossary.html | 26 +- .../help/en-GB/joomla.support.html | 26 +- .../help/en-GB/joomla.whatsnew10.html | 2 +- .../help/en-GB/joomla.whatsnew15.html | 108 +- .../en-GB/screen.banner.categories.edit.html | 2 +- .../help/en-GB/screen.banner.categories.html | 2 +- .../en-GB/screen.banners.client.edit.html | 2 +- .../help/en-GB/screen.banners.client.html | 2 +- .../help/en-GB/screen.banners.edit.html | 2 +- .../help/en-GB/screen.banners.html | 6 +- .../help/en-GB/screen.cache.html | 2 +- .../help/en-GB/screen.categories.edit.html | 2 +- .../help/en-GB/screen.categories.html | 6 +- .../help/en-GB/screen.checkin.html | 6 +- .../help/en-GB/screen.config.html | 6 +- ...creen.contact_details.categories.edit.html | 2 +- .../screen.contact_details.categories.html | 2 +- .../en-GB/screen.contactmanager.edit.html | 2 +- .../help/en-GB/screen.contactmanager.html | 4 +- .../en-GB/screen.content.categories.edit.html | 2 +- .../help/en-GB/screen.content.categories.html | 2 +- .../help/en-GB/screen.content.edit.html | 2 +- .../help/en-GB/screen.content.html | 6 +- .../help/en-GB/screen.cpanel.html | 6 +- .../help/en-GB/screen.frontpage.html | 6 +- .../help/en-GB/screen.installer.html | 2 +- .../help/en-GB/screen.languages.html | 6 +- .../help/en-GB/screen.mediamanager.html | 6 +- .../help/en-GB/screen.menumanager.html | 6 +- .../help/en-GB/screen.menumanager.new.html | 2 +- .../help/en-GB/screen.menus.edit.html | 2 +- .../help/en-GB/screen.menus.html | 2 +- .../help/en-GB/screen.messages.edit.html | 2 +- .../help/en-GB/screen.messages.inbox.html | 2 +- .../help/en-GB/screen.messages.read.html | 2 +- .../help/en-GB/screen.modules.edit.html | 4 +- .../help/en-GB/screen.modules.html | 4 +- .../help/en-GB/screen.modules.new.html | 4 +- .../screen.modulesadministrator.edit.html | 2 +- .../help/en-GB/screen.modulessite.edit.html | 2 +- .../screen.newsfeeds.categories.edit.html | 2 +- .../en-GB/screen.newsfeeds.categories.html | 2 +- .../help/en-GB/screen.newsfeeds.edit.html | 2 +- .../help/en-GB/screen.newsfeeds.html | 6 +- .../help/en-GB/screen.plugins.edit.html | 2 +- .../help/en-GB/screen.plugins.html | 4 +- .../help/en-GB/screen.polls.edit.html | 2 +- .../help/en-GB/screen.polls.html | 6 +- .../help/en-GB/screen.sections.edit.html | 2 +- .../help/en-GB/screen.sections.html | 6 +- .../help/en-GB/screen.stats.searches.html | 6 +- .../help/en-GB/screen.system.info.html | 6 +- .../help/en-GB/screen.templates.html | 6 +- .../help/en-GB/screen.trashmanager.html | 6 +- .../help/en-GB/screen.users.edit.html | 6 +- .../help/en-GB/screen.users.html | 2 +- .../help/en-GB/screen.users.massmail.html | 6 +- .../help/en-GB/screen.weblink.edit.html | 6 +- .../help/en-GB/screen.weblink.html | 6 +- .../screen.weblinks.categories.edit.html | 2 +- .../en-GB/screen.weblinks.categories.html | 2 +- .../trunk/administrator/help/helpsites-15.xml | 6 +- .../administrator/includes/application.php | 586 +- .../trunk/administrator/includes/defines.php | 64 +- .../administrator/includes/framework.php | 162 +- .../trunk/administrator/includes/helper.php | 102 +- .../trunk/administrator/includes/router.php | 98 +- .../trunk/administrator/includes/toolbar.php | 1010 +- oss/joomla/trunk/administrator/index.php | 174 +- oss/joomla/trunk/administrator/index2.php | 28 +- oss/joomla/trunk/administrator/index3.php | 30 +- .../language/en-GB/en-GB.com_admin.ini | 4 +- .../language/en-GB/en-GB.com_banners.ini | 4 +- .../language/en-GB/en-GB.com_banners.menu.ini | 4 +- .../language/en-GB/en-GB.com_cache.ini | 4 +- .../language/en-GB/en-GB.com_categories.ini | 4 +- .../language/en-GB/en-GB.com_checkin.ini | 4 +- .../language/en-GB/en-GB.com_config.ini | 4 +- .../language/en-GB/en-GB.com_contact.ini | 4 +- .../language/en-GB/en-GB.com_contact.menu.ini | 4 +- .../language/en-GB/en-GB.com_content.ini | 5 +- .../language/en-GB/en-GB.com_cpanel.ini | 2 +- .../language/en-GB/en-GB.com_frontpage.ini | 4 +- .../language/en-GB/en-GB.com_installer.ini | 4 +- .../language/en-GB/en-GB.com_languages.ini | 4 +- .../language/en-GB/en-GB.com_login.ini | 4 +- .../language/en-GB/en-GB.com_massmail.ini | 4 +- .../language/en-GB/en-GB.com_media.ini | 6 +- .../language/en-GB/en-GB.com_menus.ini | 4 +- .../language/en-GB/en-GB.com_menus.menu.ini | 2 +- .../language/en-GB/en-GB.com_messages.ini | 4 +- .../language/en-GB/en-GB.com_modules.ini | 6 +- .../language/en-GB/en-GB.com_newsfeeds.ini | 4 +- .../en-GB/en-GB.com_newsfeeds.menu.ini | 4 +- .../language/en-GB/en-GB.com_plugins.ini | 4 +- .../language/en-GB/en-GB.com_poll.ini | 4 +- .../language/en-GB/en-GB.com_poll.menu.ini | 4 +- .../language/en-GB/en-GB.com_search.ini | 4 +- .../language/en-GB/en-GB.com_search.menu.ini | 4 +- .../language/en-GB/en-GB.com_sections.ini | 4 +- .../language/en-GB/en-GB.com_templates.ini | 4 +- .../language/en-GB/en-GB.com_trash.ini | 4 +- .../language/en-GB/en-GB.com_user.ini | 2 +- .../language/en-GB/en-GB.com_users.ini | 4 +- .../language/en-GB/en-GB.com_weblinks.ini | 4 +- .../en-GB/en-GB.com_weblinks.menu.ini | 4 +- .../language/en-GB/en-GB.com_wrapper.ini | 4 +- .../administrator/language/en-GB/en-GB.ini | 11 +- .../language/en-GB/en-GB.mod_components.ini | 4 +- .../language/en-GB/en-GB.mod_custom.ini | 4 +- .../language/en-GB/en-GB.mod_feed.ini | 4 +- .../language/en-GB/en-GB.mod_footer.ini | 4 +- .../language/en-GB/en-GB.mod_latest.ini | 4 +- .../language/en-GB/en-GB.mod_logged.ini | 4 +- .../language/en-GB/en-GB.mod_login.ini | 4 +- .../language/en-GB/en-GB.mod_menu.ini | 4 +- .../language/en-GB/en-GB.mod_online.ini | 4 +- .../language/en-GB/en-GB.mod_popular.ini | 4 +- .../language/en-GB/en-GB.mod_quickicon.ini | 4 +- .../language/en-GB/en-GB.mod_stats.ini | 4 +- .../language/en-GB/en-GB.mod_status.ini | 4 +- .../language/en-GB/en-GB.mod_submenu.ini | 4 +- .../language/en-GB/en-GB.mod_title.ini | 4 +- .../language/en-GB/en-GB.mod_toolbar.ini | 4 +- .../language/en-GB/en-GB.mod_unread.ini | 4 +- .../en-GB.plg_authentication_example.ini | 4 +- .../en-GB/en-GB.plg_authentication_gmail.ini | 4 +- .../en-GB/en-GB.plg_authentication_joomla.ini | 4 +- .../en-GB/en-GB.plg_authentication_ldap.ini | 4 +- .../en-GB/en-GB.plg_authentication_openid.ini | 2 +- .../language/en-GB/en-GB.plg_content_code.ini | 4 +- .../en-GB/en-GB.plg_content_emailcloak.ini | 4 +- .../en-GB/en-GB.plg_content_geshi.ini | 4 +- .../en-GB/en-GB.plg_content_image.ini | 4 +- .../en-GB/en-GB.plg_content_loadmodule.ini | 4 +- .../en-GB/en-GB.plg_content_pagebreak.ini | 4 +- .../en-GB.plg_content_pagenavigation.ini | 4 +- .../language/en-GB/en-GB.plg_content_vote.ini | 4 +- .../en-GB/en-GB.plg_editors-xtd_image.ini | 4 +- .../en-GB/en-GB.plg_editors-xtd_pagebreak.ini | 4 +- .../en-GB/en-GB.plg_editors-xtd_readmore.ini | 4 +- .../language/en-GB/en-GB.plg_editors_none.ini | 4 +- .../en-GB/en-GB.plg_editors_tinymce.ini | 16 +- .../en-GB/en-GB.plg_editors_xstandard.ini | 4 +- .../en-GB/en-GB.plg_search_categories.ini | 4 +- .../en-GB/en-GB.plg_search_contacts.ini | 4 +- .../en-GB/en-GB.plg_search_content.ini | 4 +- .../en-GB/en-GB.plg_search_newsfeeds.ini | 4 +- .../en-GB/en-GB.plg_search_sections.ini | 4 +- .../en-GB/en-GB.plg_search_weblinks.ini | 4 +- .../en-GB/en-GB.plg_system_backlink.ini | 2 +- .../language/en-GB/en-GB.plg_system_cache.ini | 2 +- .../language/en-GB/en-GB.plg_system_debug.ini | 4 +- .../en-GB/en-GB.plg_system_legacy.ini | 2 +- .../language/en-GB/en-GB.plg_system_sef.ini | 4 +- .../language/en-GB/en-GB.plg_user_joomla.ini | 4 +- .../en-GB/en-GB.plg_xmlrpc_blogger.ini | 4 +- .../en-GB/en-GB.plg_xmlrpc_joomla.ini | 4 +- .../language/en-GB/en-GB.tpl_beez.ini | 2 +- .../language/en-GB/en-GB.tpl_ja_purity.ini | 4 +- .../language/en-GB/en-GB.tpl_khepri.ini | 2 +- .../en-GB/en-GB.tpl_rhuk_milkyway.ini | 4 +- .../administrator/language/en-GB/en-GB.xml | 8 +- .../language/zh-CN/zh-CN.com_admin.ini | 29 +- .../language/zh-CN/zh-CN.com_apoll.ini | 36 +- .../language/zh-CN/zh-CN.com_apoll.menu.ini | 34 +- .../language/zh-CN/zh-CN.com_cache.ini | 9 +- .../language/zh-CN/zh-CN.mod_feed.ini | 60 +- .../language/zh-CN/zh-CN.mod_menu.ini | 3 +- .../language/zh-CN/zh-CN.mod_quickicon.ini | 30 +- .../language/zh-CN/zh-CN.mod_stats.ini | 31 +- .../language/zh-CN/zh-CN.mod_status.ini | 30 +- .../language/zh-CN/zh-CN.mod_submenu.ini | 30 +- .../language/zh-CN/zh-CN.mod_title.ini | 30 +- .../language/zh-CN/zh-CN.mod_toolbar.ini | 30 +- .../language/zh-CN/zh-CN.mod_unread.ini | 30 +- .../zh-CN.plg_authentication_example.ini | 29 +- .../zh-CN/zh-CN.plg_authentication_gmail.ini | 30 +- .../zh-CN/zh-CN.plg_authentication_joomla.ini | 29 +- .../zh-CN/zh-CN.plg_authentication_ldap.ini | 27 +- .../zh-CN/zh-CN.plg_authentication_openid.ini | 28 +- .../language/zh-CN/zh-CN.plg_content_code.ini | 30 +- .../zh-CN/zh-CN.plg_content_emailcloak.ini | 30 +- .../zh-CN/zh-CN.plg_content_geshi.ini | 30 +- .../zh-CN/zh-CN.plg_content_image.ini | 29 +- .../zh-CN/zh-CN.plg_content_loadmodule.ini | 29 +- .../zh-CN/zh-CN.plg_content_pagebreak.ini | 30 +- .../zh-CN.plg_content_pagenavigation.ini | 30 +- .../language/zh-CN/zh-CN.plg_content_vote.ini | 29 +- .../zh-CN/zh-CN.plg_editors-xtd_image.ini | 30 +- .../zh-CN/zh-CN.plg_editors-xtd_pagebreak.ini | 29 +- .../zh-CN/zh-CN.plg_editors-xtd_readmore.ini | 32 +- .../language/zh-CN/zh-CN.plg_editors_none.ini | 30 +- .../zh-CN/zh-CN.plg_editors_tinymce.ini | 80 +- .../zh-CN/zh-CN.plg_editors_xstandard.ini | 30 +- .../zh-CN/zh-CN.plg_search_categories.ini | 29 +- .../zh-CN/zh-CN.plg_search_contacts.ini | 29 +- .../zh-CN/zh-CN.plg_search_newsfeeds.ini | 35 +- .../zh-CN/zh-CN.plg_search_sections.ini | 30 +- .../zh-CN/zh-CN.plg_search_weblinks.ini | 29 +- .../zh-CN/zh-CN.plg_system_backlink.ini | 42 +- .../language/zh-CN/zh-CN.plg_system_cache.ini | 32 +- .../language/zh-CN/zh-CN.plg_system_debug.ini | 37 +- .../zh-CN/zh-CN.plg_system_legacy.ini | 34 +- .../language/zh-CN/zh-CN.plg_system_sef.ini | 31 +- .../language/zh-CN/zh-CN.plg_user_joomla.ini | 34 +- .../zh-CN/zh-CN.plg_xmlrpc_blogger.ini | 62 +- .../zh-CN/zh-CN.plg_xmlrpc_joomla.ini | 32 +- .../trunk/administrator/modules/index.html | 1 + .../modules/mod_custom/index.html | 1 + .../modules/mod_custom/mod_custom.xml | 15 + .../administrator/modules/mod_feed/helper.php | 168 + .../administrator/modules/mod_feed/index.html | 1 + .../modules/mod_feed/mod_feed.php | 42 + .../modules/mod_feed/mod_feed.xml | 48 + .../modules/mod_feed/tmpl/default.php | 5 + .../modules/mod_feed/tmpl/index.html | 1 + .../modules/mod_footer/index.html | 1 + .../modules/mod_footer/mod_footer.php | 30 + .../modules/mod_footer/mod_footer.xml | 21 + .../modules/mod_latest/index.html | 1 + .../modules/mod_latest/mod_latest.php | 127 + .../modules/mod_latest/mod_latest.xml | 29 + .../modules/mod_logged/index.html | 1 + .../modules/mod_logged/mod_logged.php | 60 + .../modules/mod_logged/mod_logged.xml | 21 + .../modules/mod_logged/tmpl/default.php | 77 + .../modules/mod_logged/tmpl/index.html | 1 + .../modules/mod_login/index.html | 1 + .../modules/mod_login/mod_login.php | 74 + .../modules/mod_login/mod_login.xml | 24 + .../administrator/modules/mod_menu/helper.php | 304 + .../administrator/modules/mod_menu/index.html | 1 + .../administrator/modules/mod_menu/menu.php | 222 + .../modules/mod_menu/mod_menu.php | 27 + .../modules/mod_menu/mod_menu.xml | 24 + .../modules/mod_online/index.html | 1 + .../modules/mod_online/mod_online.php | 30 + .../modules/mod_online/mod_online.xml | 20 + .../modules/mod_popular/index.html | 1 + .../modules/mod_popular/mod_popular.php | 60 + .../modules/mod_popular/mod_popular.xml | 20 + .../modules/mod_quickicon/index.html | 1 + .../modules/mod_quickicon/mod_quickicon.php | 84 + .../modules/mod_quickicon/mod_quickicon.xml | 21 + .../modules/mod_stats/index.html | 1 + .../modules/mod_stats/mod_stats.php | 52 + .../modules/mod_stats/mod_stats.xml | 21 + .../modules/mod_status/index.html | 1 + .../modules/mod_status/mod_status.php | 85 + .../modules/mod_status/mod_status.xml | 20 + .../modules/mod_submenu/index.html | 1 + .../modules/mod_submenu/mod_submenu.php | 139 + .../modules/mod_submenu/mod_submenu.xml | 20 + .../modules/mod_title/index.html | 1 + .../modules/mod_title/mod_title.php | 23 + .../modules/mod_title/mod_title.xml | 20 + .../modules/mod_toolbar/index.html | 1 + .../modules/mod_toolbar/mod_toolbar.php | 24 + .../modules/mod_toolbar/mod_toolbar.xml | 20 + .../modules/mod_unread/index.html | 1 + .../modules/mod_unread/mod_unread.php | 32 + .../modules/mod_unread/mod_unread.xml | 20 + .../hawebs_administrator/css/general.css | 1781 +- .../hawebs_administrator/css/menu.css | 5 +- .../templates/khepri/component.php | 64 +- .../administrator/templates/khepri/cpanel.php | 216 +- .../templates/khepri/css/component.css | 140 +- .../templates/khepri/css/general.css | 1190 +- .../templates/khepri/css/general_rtl.css | 442 +- .../templates/khepri/css/ie7.css | 29 +- .../templates/khepri/css/login.css | 188 +- .../templates/khepri/css/login_rtl.css | 88 +- .../templates/khepri/css/menu.css | 226 +- .../templates/khepri/css/menu_rtl.css | 122 +- .../templates/khepri/css/norounded.css | 140 +- .../templates/khepri/css/template.css | 54 +- .../templates/khepri/css/template_rtl.css | 46 +- .../templates/khepri/html/modules.php | 114 +- .../templates/khepri/html/pagination.php | 264 +- .../administrator/templates/khepri/index.php | 244 +- .../templates/khepri/js/index.js | 62 +- .../administrator/templates/khepri/js/menu.js | 114 +- .../administrator/templates/khepri/login.php | 194 +- .../templates/system/component.php | 46 +- .../templates/system/css/error.css | 106 +- .../templates/system/css/system.css | 52 +- .../administrator/templates/system/error.php | 78 +- .../templates/system/html/modules.php | 158 +- oss/joomla/trunk/build.xml | 20 +- .../trunk/components/com_banners/banners.php | 54 +- .../components/com_banners/controller.php | 76 +- .../components/com_banners/models/banner.php | 402 +- .../trunk/components/com_banners/router.php | 144 +- .../trunk/components/com_contact/contact.php | 56 +- .../components/com_contact/controller.php | 814 +- .../com_contact/models/category.php | 316 +- .../components/com_contact/models/contact.php | 148 +- .../trunk/components/com_contact/router.php | 472 +- .../views/category/tmpl/default.php | 208 +- .../com_contact/views/category/view.feed.php | 178 +- .../com_contact/views/category/view.html.php | 302 +- .../com_contact/views/contact/view.html.php | 370 +- .../trunk/components/com_content/content.php | 72 +- .../components/com_content/controller.php | 741 +- .../components/com_content/helpers/icon.php | 336 +- .../components/com_content/helpers/query.php | 248 +- .../components/com_content/helpers/route.php | 244 +- .../components/com_content/models/archive.php | 424 +- .../components/com_content/models/article.php | 1257 +- .../com_content/models/category.php | 1022 +- .../com_content/models/frontpage.php | 416 +- .../components/com_content/models/section.php | 1116 +- .../trunk/components/com_content/router.php | 382 +- .../views/archive/tmpl/default.php | 45 +- .../com_content/views/archive/view.html.php | 252 +- .../com_content/views/article/view.html.php | 786 +- .../com_content/views/article/view.pdf.php | 248 +- .../views/category/tmpl/default.php | 62 +- .../views/category/tmpl/default_items.php | 269 +- .../com_content/views/category/view.feed.php | 156 +- .../com_content/views/category/view.html.php | 568 +- .../com_content/views/frontpage/view.feed.php | 154 +- .../com_content/views/frontpage/view.html.php | 328 +- .../views/section/tmpl/default.php | 98 +- .../com_content/views/section/view.feed.php | 160 +- .../com_content/views/section/view.html.php | 368 +- .../components/com_mailto/controller.php | 324 +- .../trunk/components/com_mailto/mailto.php | 50 +- .../trunk/components/com_mailto/mailto.xml | 34 +- .../com_mailto/views/mailto/view.html.php | 136 +- .../com_mailto/views/sent/metadata.xml | 22 +- .../com_mailto/views/sent/view.html.php | 52 +- .../com_media/assets/popup-imagelist.css | 86 +- .../com_media/assets/popup-imagemanager.css | 148 +- .../com_media/assets/popup-imagemanager.js | 492 +- .../trunk/components/com_media/controller.php | 160 +- .../components/com_media/helpers/media.php | 265 +- .../trunk/components/com_media/media.php | 146 +- .../components/com_newsfeeds/controller.php | 92 +- .../com_newsfeeds/models/categories.php | 224 +- .../com_newsfeeds/models/category.php | 428 +- .../com_newsfeeds/models/newsfeed.php | 262 +- .../components/com_newsfeeds/newsfeeds.php | 62 +- .../trunk/components/com_newsfeeds/router.php | 488 +- .../views/categories/view.html.php | 164 +- .../views/category/view.html.php | 204 +- .../views/newsfeed/view.html.php | 268 +- .../trunk/components/com_poll/controller.php | 190 +- .../trunk/components/com_poll/models/poll.php | 124 +- oss/joomla/trunk/components/com_poll/poll.php | 90 +- .../trunk/components/com_poll/router.php | 268 +- .../com_poll/views/poll/view.html.php | 384 +- .../components/com_search/controller.php | 179 +- .../components/com_search/models/search.php | 430 +- .../trunk/components/com_search/router.php | 92 +- .../trunk/components/com_search/search.php | 54 +- .../com_search/views/search/view.html.php | 356 +- .../trunk/components/com_user/controller.php | 1074 +- .../components/com_user/models/remind.php | 216 +- .../components/com_user/models/reset.php | 512 +- .../trunk/components/com_user/models/user.php | 284 +- .../trunk/components/com_user/router.php | 96 +- oss/joomla/trunk/components/com_user/user.php | 56 +- oss/joomla/trunk/components/com_user/user.xml | 24 +- .../com_user/views/login/view.html.php | 232 +- .../com_user/views/register/view.html.php | 140 +- .../com_user/views/remind/view.html.php | 152 +- .../com_user/views/reset/tmpl/confirm.php | 60 +- .../com_user/views/reset/view.html.php | 180 +- .../com_user/views/user/view.html.php | 230 +- .../components/com_weblinks/controller.php | 110 +- .../com_weblinks/controllers/weblink.php | 274 +- .../components/com_weblinks/helpers/route.php | 162 +- .../com_weblinks/models/categories.php | 222 +- .../com_weblinks/models/category.php | 466 +- .../com_weblinks/models/weblink.php | 586 +- .../trunk/components/com_weblinks/router.php | 534 +- .../views/categories/view.html.php | 182 +- .../views/category/tmpl/default_items.php | 145 +- .../com_weblinks/views/category/view.feed.php | 148 +- .../com_weblinks/views/category/view.html.php | 336 +- .../com_weblinks/views/weblink/view.html.php | 340 +- .../components/com_weblinks/weblinks.php | 78 +- .../trunk/components/com_wrapper/router.php | 78 +- .../com_wrapper/views/wrapper/view.php | 104 +- .../trunk/components/com_wrapper/wrapper.php | 170 +- .../trunk/components/com_wrapper/wrapper.xml | 24 +- oss/joomla/trunk/includes/application.php | 754 +- oss/joomla/trunk/includes/defines.php | 70 +- oss/joomla/trunk/includes/footer.php | 52 +- oss/joomla/trunk/includes/framework.php | 170 +- .../trunk/includes/js/joomla.javascript.js | 1184 +- .../trunk/includes/js/mambojavascript.js | 1084 +- oss/joomla/trunk/includes/menu.php | 178 +- oss/joomla/trunk/includes/pathway.php | 132 +- oss/joomla/trunk/includes/router.php | 908 +- .../language/en-GB/en-GB.com_banners.ini | 8 +- .../language/en-GB/en-GB.com_contact.ini | 34 +- .../language/en-GB/en-GB.com_content.ini | 2 +- .../language/en-GB/en-GB.com_frontpage.ini | 2 +- .../trunk/language/en-GB/en-GB.com_mailto.ini | 2 +- .../trunk/language/en-GB/en-GB.com_media.ini | 2 +- .../language/en-GB/en-GB.com_messages.ini | 2 +- .../language/en-GB/en-GB.com_newsfeeds.ini | 2 +- .../trunk/language/en-GB/en-GB.com_poll.ini | 2 +- .../trunk/language/en-GB/en-GB.com_search.ini | 2 +- .../trunk/language/en-GB/en-GB.com_user.ini | 2 +- .../language/en-GB/en-GB.com_weblinks.ini | 2 +- .../language/en-GB/en-GB.com_wrapper.ini | 2 +- .../trunk/language/en-GB/en-GB.ignore.php | 32 +- oss/joomla/trunk/language/en-GB/en-GB.ini | 10 +- .../language/en-GB/en-GB.mod_archive.ini | 2 +- .../language/en-GB/en-GB.mod_banners.ini | 2 +- .../language/en-GB/en-GB.mod_breadcrumbs.ini | 2 +- .../trunk/language/en-GB/en-GB.mod_custom.ini | 2 +- .../trunk/language/en-GB/en-GB.mod_feed.ini | 2 +- .../trunk/language/en-GB/en-GB.mod_footer.ini | 2 +- .../language/en-GB/en-GB.mod_latestnews.ini | 4 +- .../trunk/language/en-GB/en-GB.mod_login.ini | 2 +- .../language/en-GB/en-GB.mod_mainmenu.ini | 2 +- .../language/en-GB/en-GB.mod_mostread.ini | 2 +- .../language/en-GB/en-GB.mod_newsflash.ini | 2 +- .../trunk/language/en-GB/en-GB.mod_online.ini | 2 +- .../trunk/language/en-GB/en-GB.mod_poll.ini | 2 +- .../language/en-GB/en-GB.mod_random_image.ini | 2 +- .../en-GB/en-GB.mod_related_items.ini | 2 +- .../trunk/language/en-GB/en-GB.mod_search.ini | 3 +- .../language/en-GB/en-GB.mod_sections.ini | 2 +- .../trunk/language/en-GB/en-GB.mod_stats.ini | 2 +- .../language/en-GB/en-GB.mod_syndicate.ini | 2 +- .../language/en-GB/en-GB.mod_whosonline.ini | 4 +- .../language/en-GB/en-GB.mod_wrapper.ini | 2 +- .../en-GB/en-GB.plg_content_pagebreak.ini | 2 +- .../language/en-GB/en-GB.plg_content_vote.ini | 2 +- .../en-GB/en-GB.plg_search_categories.ini | 2 +- .../en-GB/en-GB.plg_search_contacts.ini | 2 +- .../en-GB/en-GB.plg_search_content.ini | 2 +- .../en-GB/en-GB.plg_search_newsfeeds.ini | 2 +- .../en-GB/en-GB.plg_search_sections.ini | 2 +- .../en-GB/en-GB.plg_search_weblinks.ini | 2 +- .../language/en-GB/en-GB.plg_system_debug.ini | 2 +- .../trunk/language/en-GB/en-GB.tpl_beez.ini | 2 +- .../language/en-GB/en-GB.tpl_ja_purity.ini | 2 +- .../en-GB/en-GB.tpl_rhuk_milkyway.ini | 2 +- oss/joomla/trunk/language/en-GB/en-GB.xml | 48 +- oss/joomla/trunk/language/zh-CN/zh-CN.xml | 14 +- .../libraries/domit/xml_domit_lite_parser.php | 3784 +-- .../libraries/domit/xml_domit_parser.php | 7358 ++--- .../joomla/application/application.php | 2224 +- .../application/component/controller.php | 1440 +- .../joomla/application/component/helper.php | 422 +- .../joomla/application/component/model.php | 704 +- .../joomla/application/component/view.php | 1376 +- .../libraries/joomla/application/helper.php | 674 +- .../libraries/joomla/application/menu.php | 572 +- .../joomla/application/module/helper.php | 614 +- .../libraries/joomla/application/pathway.php | 432 +- .../libraries/joomla/application/router.php | 832 +- .../trunk/libraries/joomla/base/object.php | 454 +- .../libraries/joomla/base/observable.php | 252 +- .../trunk/libraries/joomla/base/observer.php | 116 +- .../trunk/libraries/joomla/base/tree.php | 222 +- .../trunk/libraries/joomla/cache/cache.php | 632 +- .../joomla/cache/handler/callback.php | 266 +- .../libraries/joomla/cache/handler/output.php | 154 +- .../libraries/joomla/cache/handler/page.php | 272 +- .../libraries/joomla/cache/handler/view.php | 300 +- .../trunk/libraries/joomla/cache/storage.php | 346 +- .../libraries/joomla/cache/storage/apc.php | 312 +- .../joomla/cache/storage/eaccelerator.php | 344 +- .../libraries/joomla/cache/storage/file.php | 528 +- .../joomla/cache/storage/memcache.php | 430 +- .../libraries/joomla/cache/storage/xcache.php | 284 +- .../trunk/libraries/joomla/client/ftp.php | 2934 +- .../trunk/libraries/joomla/client/helper.php | 480 +- .../trunk/libraries/joomla/client/ldap.php | 974 +- .../libraries/joomla/database/database.php | 2180 +- .../joomla/database/database/mysql.php | 1384 +- .../joomla/database/database/mysqli.php | 1418 +- .../libraries/joomla/database/recordset.php | 208 +- .../trunk/libraries/joomla/database/table.php | 1724 +- .../libraries/joomla/database/table/aro.php | 86 +- .../joomla/database/table/arogroup.php | 86 +- .../joomla/database/table/category.php | 214 +- .../joomla/database/table/component.php | 228 +- .../joomla/database/table/content.php | 392 +- .../libraries/joomla/database/table/menu.php | 246 +- .../joomla/database/table/menutypes.php | 181 +- .../joomla/database/table/module.php | 230 +- .../joomla/database/table/plugin.php | 270 +- .../joomla/database/table/section.php | 248 +- .../joomla/database/table/session.php | 426 +- .../libraries/joomla/database/table/user.php | 682 +- .../libraries/joomla/document/document.php | 1564 +- .../libraries/joomla/document/error/error.php | 348 +- .../libraries/joomla/document/feed/feed.php | 1002 +- .../joomla/document/feed/renderer/atom.php | 236 +- .../joomla/document/feed/renderer/rss.php | 362 +- .../libraries/joomla/document/html/html.php | 788 +- .../document/html/renderer/component.php | 78 +- .../joomla/document/html/renderer/head.php | 316 +- .../joomla/document/html/renderer/message.php | 158 +- .../joomla/document/html/renderer/module.php | 178 +- .../joomla/document/html/renderer/modules.php | 88 +- .../libraries/joomla/document/pdf/pdf.php | 492 +- .../libraries/joomla/document/raw/raw.php | 118 +- .../libraries/joomla/document/renderer.php | 154 +- .../libraries/joomla/environment/browser.php | 1704 +- .../libraries/joomla/environment/request.php | 1192 +- .../libraries/joomla/environment/response.php | 563 +- .../libraries/joomla/environment/uri.php | 1551 +- .../trunk/libraries/joomla/error/error.php | 1157 +- .../libraries/joomla/error/exception.php | 502 +- .../trunk/libraries/joomla/error/log.php | 462 +- .../trunk/libraries/joomla/error/profiler.php | 338 +- .../libraries/joomla/event/dispatcher.php | 388 +- .../trunk/libraries/joomla/event/event.php | 144 +- oss/joomla/trunk/libraries/joomla/factory.php | 1435 +- .../libraries/joomla/filesystem/archive.php | 376 +- .../joomla/filesystem/archive/bzip2.php | 178 +- .../joomla/filesystem/archive/gzip.php | 268 +- .../joomla/filesystem/archive/tar.php | 376 +- .../joomla/filesystem/archive/zip.php | 1032 +- .../libraries/joomla/filesystem/file.php | 770 +- .../libraries/joomla/filesystem/folder.php | 1140 +- .../libraries/joomla/filesystem/path.php | 524 +- .../libraries/joomla/filter/filterinput.php | 1012 +- .../libraries/joomla/filter/filteroutput.php | 296 +- .../trunk/libraries/joomla/html/editor.php | 631 +- .../trunk/libraries/joomla/html/html.php | 660 +- .../libraries/joomla/html/html/behavior.php | 788 +- .../libraries/joomla/html/html/content.php | 112 +- .../libraries/joomla/html/html/email.php | 211 +- .../trunk/libraries/joomla/html/html/form.php | 74 +- .../trunk/libraries/joomla/html/html/grid.php | 346 +- .../libraries/joomla/html/html/image.php | 304 +- .../trunk/libraries/joomla/html/html/list.php | 472 +- .../trunk/libraries/joomla/html/html/menu.php | 306 +- .../libraries/joomla/html/html/select.php | 550 +- .../libraries/joomla/html/pagination.php | 1098 +- .../trunk/libraries/joomla/html/pane.php | 612 +- .../trunk/libraries/joomla/html/parameter.php | 906 +- .../joomla/html/parameter/element.php | 202 +- .../html/parameter/element/calendar.php | 92 +- .../html/parameter/element/category.php | 148 +- .../joomla/html/parameter/element/editors.php | 120 +- .../html/parameter/element/filelist.php | 162 +- .../html/parameter/element/folderlist.php | 136 +- .../html/parameter/element/helpsites.php | 90 +- .../joomla/html/parameter/element/hidden.php | 92 +- .../html/parameter/element/imagelist.php | 90 +- .../html/parameter/element/languages.php | 112 +- .../joomla/html/parameter/element/list.php | 100 +- .../joomla/html/parameter/element/menu.php | 100 +- .../html/parameter/element/menuitem.php | 266 +- .../html/parameter/element/password.php | 86 +- .../joomla/html/parameter/element/radio.php | 96 +- .../joomla/html/parameter/element/section.php | 94 +- .../joomla/html/parameter/element/spacer.php | 96 +- .../joomla/html/parameter/element/sql.php | 88 +- .../joomla/html/parameter/element/text.php | 96 +- .../html/parameter/element/textarea.php | 92 +- .../html/parameter/element/timezones.php | 176 +- .../html/parameter/element/usergroup.php | 122 +- .../trunk/libraries/joomla/html/toolbar.php | 518 +- .../libraries/joomla/html/toolbar/button.php | 264 +- .../joomla/html/toolbar/button/confirm.php | 184 +- .../joomla/html/toolbar/button/custom.php | 102 +- .../joomla/html/toolbar/button/help.php | 166 +- .../joomla/html/toolbar/button/link.php | 144 +- .../joomla/html/toolbar/button/popup.php | 166 +- .../joomla/html/toolbar/button/separator.php | 102 +- .../joomla/html/toolbar/button/standard.php | 176 +- oss/joomla/trunk/libraries/joomla/import.php | 116 +- .../joomla/installer/adapters/component.php | 1510 +- .../joomla/installer/adapters/language.php | 444 +- .../joomla/installer/adapters/module.php | 791 +- .../joomla/installer/adapters/plugin.php | 642 +- .../joomla/installer/adapters/template.php | 400 +- .../libraries/joomla/installer/helper.php | 554 +- .../libraries/joomla/installer/installer.php | 2344 +- .../trunk/libraries/joomla/language/help.php | 290 +- .../libraries/joomla/language/helper.php | 190 +- .../libraries/joomla/language/language.php | 1562 +- .../trunk/libraries/joomla/mail/helper.php | 334 +- .../trunk/libraries/joomla/mail/mail.php | 642 +- oss/joomla/trunk/libraries/joomla/methods.php | 324 +- .../trunk/libraries/joomla/plugin/helper.php | 410 +- .../trunk/libraries/joomla/plugin/plugin.php | 236 +- .../libraries/joomla/registry/format.php | 176 +- .../libraries/joomla/registry/format/ini.php | 562 +- .../libraries/joomla/registry/format/php.php | 172 +- .../libraries/joomla/registry/format/xml.php | 194 +- .../libraries/joomla/registry/registry.php | 1022 +- .../libraries/joomla/session/session.php | 1534 +- .../libraries/joomla/session/storage.php | 380 +- .../libraries/joomla/session/storage/apc.php | 262 +- .../joomla/session/storage/database.php | 278 +- .../joomla/session/storage/eaccelerator.php | 264 +- .../joomla/session/storage/memcache.php | 430 +- .../libraries/joomla/session/storage/none.php | 76 +- .../joomla/session/storage/xcache.php | 282 +- .../joomla/template/module/function/Sef.php | 104 +- .../template/module/function/Translate.php | 120 +- .../joomla/template/module/modifier/SEF.php | 74 +- .../template/module/modifier/Translate.php | 74 +- .../libraries/joomla/template/template.php | 416 +- .../joomla/template/tmpl/adminfilters.html | 68 +- .../joomla/template/tmpl/adminlists.html | 220 +- .../joomla/template/tmpl/breadcrumbs.html | 4 +- .../joomla/template/tmpl/calendar.html | 80 +- .../libraries/joomla/template/tmpl/dtree.html | 52 +- .../libraries/joomla/template/tmpl/forms.html | 38 +- .../libraries/joomla/template/tmpl/help.html | 72 +- .../libraries/joomla/template/tmpl/page.html | 40 +- .../libraries/joomla/template/tmpl/tabs.html | 92 +- .../libraries/joomla/user/authentication.php | 548 +- .../libraries/joomla/user/authorization.php | 1076 +- .../trunk/libraries/joomla/user/helper.php | 682 +- .../trunk/libraries/joomla/user/user.php | 1228 +- .../joomla/utilities/arrayhelper.php | 572 +- .../libraries/joomla/utilities/buffer.php | 230 +- .../joomla/utilities/compat/compat.php | 64 +- .../joomla/utilities/compat/php50x.php | 234 +- .../joomla/utilities/compat/php51x.php | 60 +- .../trunk/libraries/joomla/utilities/date.php | 606 +- .../joomla/utilities/simplecrypt.php | 408 +- .../libraries/joomla/utilities/simplexml.php | 1336 +- .../libraries/joomla/utilities/string.php | 890 +- .../libraries/joomla/utilities/utility.php | 362 +- oss/joomla/trunk/libraries/joomla/version.php | 180 +- oss/joomla/trunk/libraries/loader.php | 374 +- .../trunk/libraries/pattemplate/patError.php | 594 +- .../libraries/pattemplate/patErrorManager.php | 1420 +- .../libraries/pattemplate/patTemplate.php | 5340 ++-- .../libraries/phpinputfilter/inputfilter.php | 1102 +- .../trunk/libraries/phpmailer/phpmailer.php | 3818 +-- .../trunk/libraries/phputf8/utils/ascii.php | 432 +- .../trunk/libraries/simplepie/simplepie.php | 25842 +++++++++------- oss/joomla/trunk/media/system/js/caption.js | 133 +- oss/joomla/trunk/media/system/js/combobox.js | 232 +- .../media/system/js/mootools-uncompressed.js | 14204 ++++----- oss/joomla/trunk/media/system/js/mootools.js | 198 +- oss/joomla/trunk/media/system/js/openid.js | 286 +- oss/joomla/trunk/media/system/js/switcher.js | 200 +- oss/joomla/trunk/media/system/js/tabs.js | 140 +- oss/joomla/trunk/media/system/js/validate.js | 330 +- .../trunk/modules/mod_archive/helper.php | 106 +- .../trunk/modules/mod_archive/mod_archive.php | 44 +- .../trunk/modules/mod_archive/mod_archive.xml | 2 +- .../trunk/modules/mod_banners/helper.php | 256 +- .../trunk/modules/mod_banners/mod_banners.php | 48 +- .../trunk/modules/mod_banners/mod_banners.xml | 2 +- .../trunk/modules/mod_breadcrumbs/helper.php | 148 +- .../mod_breadcrumbs/mod_breadcrumbs.php | 52 +- .../mod_breadcrumbs/mod_breadcrumbs.xml | 66 +- .../trunk/modules/mod_custom/mod_custom.xml | 2 +- oss/joomla/trunk/modules/mod_feed/helper.php | 118 +- .../trunk/modules/mod_feed/mod_feed.php | 86 +- .../trunk/modules/mod_feed/mod_feed.xml | 98 +- .../trunk/modules/mod_footer/mod_footer.php | 70 +- .../trunk/modules/mod_footer/mod_footer.xml | 2 +- .../trunk/modules/mod_latestnews/helper.php | 238 +- .../modules/mod_latestnews/mod_latestnews.php | 40 +- .../modules/mod_latestnews/mod_latestnews.xml | 4 +- oss/joomla/trunk/modules/mod_login/helper.php | 94 +- .../trunk/modules/mod_login/mod_login.php | 52 +- .../trunk/modules/mod_login/mod_login.xml | 6 +- .../trunk/modules/mod_mainmenu/helper.php | 836 +- .../trunk/modules/mod_mainmenu/legacy.php | 854 +- .../modules/mod_mainmenu/mod_mainmenu.php | 82 +- .../modules/mod_mainmenu/mod_mainmenu.xml | 184 +- .../trunk/modules/mod_mostread/helper.php | 178 +- .../modules/mod_mostread/mod_mostread.php | 40 +- .../modules/mod_mostread/mod_mostread.xml | 2 +- .../trunk/modules/mod_newsflash/helper.php | 207 +- .../modules/mod_newsflash/mod_newsflash.php | 90 +- .../modules/mod_newsflash/mod_newsflash.xml | 106 +- oss/joomla/trunk/modules/mod_poll/helper.php | 118 +- .../trunk/modules/mod_poll/mod_poll.php | 66 +- .../trunk/modules/mod_poll/mod_poll.xml | 2 +- .../trunk/modules/mod_random_image/helper.php | 232 +- .../mod_random_image/mod_random_image.php | 62 +- .../mod_random_image/mod_random_image.xml | 2 +- .../modules/mod_related_items/helper.php | 230 +- .../mod_related_items/mod_related_items.php | 56 +- .../mod_related_items/mod_related_items.xml | 4 +- .../trunk/modules/mod_search/helper.php | 42 +- .../trunk/modules/mod_search/mod_search.php | 67 +- .../trunk/modules/mod_search/mod_search.xml | 90 +- .../trunk/modules/mod_search/tmpl/default.php | 83 +- .../trunk/modules/mod_sections/helper.php | 108 +- .../modules/mod_sections/mod_sections.php | 52 +- .../modules/mod_sections/mod_sections.xml | 4 +- oss/joomla/trunk/modules/mod_stats/helper.php | 228 +- .../trunk/modules/mod_stats/mod_stats.php | 48 +- .../trunk/modules/mod_stats/mod_stats.xml | 2 +- .../trunk/modules/mod_syndicate/helper.php | 62 +- .../modules/mod_syndicate/mod_syndicate.php | 58 +- .../modules/mod_syndicate/mod_syndicate.xml | 2 +- .../trunk/modules/mod_whosonline/helper.php | 150 +- .../modules/mod_whosonline/mod_whosonline.php | 60 +- .../modules/mod_whosonline/mod_whosonline.xml | 2 +- .../trunk/modules/mod_wrapper/helper.php | 118 +- .../trunk/modules/mod_wrapper/mod_wrapper.php | 60 +- .../trunk/modules/mod_wrapper/mod_wrapper.xml | 2 +- 912 files changed, 138002 insertions(+), 130235 deletions(-) create mode 100644 oss/joomla/trunk/administrator/modules/index.html create mode 100644 oss/joomla/trunk/administrator/modules/mod_custom/index.html create mode 100644 oss/joomla/trunk/administrator/modules/mod_custom/mod_custom.xml create mode 100644 oss/joomla/trunk/administrator/modules/mod_feed/helper.php create mode 100644 oss/joomla/trunk/administrator/modules/mod_feed/index.html create mode 100644 oss/joomla/trunk/administrator/modules/mod_feed/mod_feed.php create mode 100644 oss/joomla/trunk/administrator/modules/mod_feed/mod_feed.xml create mode 100644 oss/joomla/trunk/administrator/modules/mod_feed/tmpl/default.php create mode 100644 oss/joomla/trunk/administrator/modules/mod_feed/tmpl/index.html create mode 100644 oss/joomla/trunk/administrator/modules/mod_footer/index.html create mode 100644 oss/joomla/trunk/administrator/modules/mod_footer/mod_footer.php create mode 100644 oss/joomla/trunk/administrator/modules/mod_footer/mod_footer.xml create mode 100644 oss/joomla/trunk/administrator/modules/mod_latest/index.html create mode 100644 oss/joomla/trunk/administrator/modules/mod_latest/mod_latest.php create mode 100644 oss/joomla/trunk/administrator/modules/mod_latest/mod_latest.xml create mode 100644 oss/joomla/trunk/administrator/modules/mod_logged/index.html create mode 100644 oss/joomla/trunk/administrator/modules/mod_logged/mod_logged.php create mode 100644 oss/joomla/trunk/administrator/modules/mod_logged/mod_logged.xml create mode 100644 oss/joomla/trunk/administrator/modules/mod_logged/tmpl/default.php create mode 100644 oss/joomla/trunk/administrator/modules/mod_logged/tmpl/index.html create mode 100644 oss/joomla/trunk/administrator/modules/mod_login/index.html create mode 100644 oss/joomla/trunk/administrator/modules/mod_login/mod_login.php create mode 100644 oss/joomla/trunk/administrator/modules/mod_login/mod_login.xml create mode 100644 oss/joomla/trunk/administrator/modules/mod_menu/helper.php create mode 100644 oss/joomla/trunk/administrator/modules/mod_menu/index.html create mode 100644 oss/joomla/trunk/administrator/modules/mod_menu/menu.php create mode 100644 oss/joomla/trunk/administrator/modules/mod_menu/mod_menu.php create mode 100644 oss/joomla/trunk/administrator/modules/mod_menu/mod_menu.xml create mode 100644 oss/joomla/trunk/administrator/modules/mod_online/index.html create mode 100644 oss/joomla/trunk/administrator/modules/mod_online/mod_online.php create mode 100644 oss/joomla/trunk/administrator/modules/mod_online/mod_online.xml create mode 100644 oss/joomla/trunk/administrator/modules/mod_popular/index.html create mode 100644 oss/joomla/trunk/administrator/modules/mod_popular/mod_popular.php create mode 100644 oss/joomla/trunk/administrator/modules/mod_popular/mod_popular.xml create mode 100644 oss/joomla/trunk/administrator/modules/mod_quickicon/index.html create mode 100644 oss/joomla/trunk/administrator/modules/mod_quickicon/mod_quickicon.php create mode 100644 oss/joomla/trunk/administrator/modules/mod_quickicon/mod_quickicon.xml create mode 100644 oss/joomla/trunk/administrator/modules/mod_stats/index.html create mode 100644 oss/joomla/trunk/administrator/modules/mod_stats/mod_stats.php create mode 100644 oss/joomla/trunk/administrator/modules/mod_stats/mod_stats.xml create mode 100644 oss/joomla/trunk/administrator/modules/mod_status/index.html create mode 100644 oss/joomla/trunk/administrator/modules/mod_status/mod_status.php create mode 100644 oss/joomla/trunk/administrator/modules/mod_status/mod_status.xml create mode 100644 oss/joomla/trunk/administrator/modules/mod_submenu/index.html create mode 100644 oss/joomla/trunk/administrator/modules/mod_submenu/mod_submenu.php create mode 100644 oss/joomla/trunk/administrator/modules/mod_submenu/mod_submenu.xml create mode 100644 oss/joomla/trunk/administrator/modules/mod_title/index.html create mode 100644 oss/joomla/trunk/administrator/modules/mod_title/mod_title.php create mode 100644 oss/joomla/trunk/administrator/modules/mod_title/mod_title.xml create mode 100644 oss/joomla/trunk/administrator/modules/mod_toolbar/index.html create mode 100644 oss/joomla/trunk/administrator/modules/mod_toolbar/mod_toolbar.php create mode 100644 oss/joomla/trunk/administrator/modules/mod_toolbar/mod_toolbar.xml create mode 100644 oss/joomla/trunk/administrator/modules/mod_unread/index.html create mode 100644 oss/joomla/trunk/administrator/modules/mod_unread/mod_unread.php create mode 100644 oss/joomla/trunk/administrator/modules/mod_unread/mod_unread.xml diff --git a/oss/joomla/trunk/administrator/cache/3c788c8140c244baa4de05cad390c937.spc b/oss/joomla/trunk/administrator/cache/3c788c8140c244baa4de05cad390c937.spc index 520f1ac7..6744cfe6 100644 --- a/oss/joomla/trunk/administrator/cache/3c788c8140c244baa4de05cad390c937.spc +++ b/oss/joomla/trunk/administrator/cache/3c788c8140c244baa4de05cad390c937.spc @@ -1,4 +1,6 @@ -a:3:{s:5:"child";a:1:{s:0:"";a:1:{s:3:"rss";a:1:{i:0;a:6:{s:4:"data";s:0:"";s:7:"attribs";a:1:{s:0:"";a:1:{s:7:"version";s:3:"2.0";}}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";s:5:"child";a:1:{s:0:"";a:1:{s:7:"channel";a:1:{i:0;a:6:{s:4:"data";s:50:" +a:4:{s:5:"child";a:1:{s:0:"";a:1:{s:3:"rss";a:1:{i:0;a:6:{s:4:"data";s:3:" + +";s:7:"attribs";a:1:{s:0:"";a:1:{s:7:"version";s:3:"2.0";}}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";s:5:"child";a:1:{s:0:"";a:1:{s:7:"channel";a:1:{i:0;a:6:{s:4:"data";s:50:" @@ -15,7 +17,7 @@ a:3:{s:5:"child";a:1:{s:0:"";a:1:{s:3:"rss";a:1:{i:0;a:6:{s:4:"data";s:0:"";s:7: - ";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";s:5:"child";a:3:{s:0:"";a:7:{s:5:"title";a:1:{i:0;a:5:{s:4:"data";s:38:"Joomla! Developer - Vulnerability News";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:11:"description";a:1:{i:0;a:5:{s:4:"data";s:274:"Not only is Joomla! easy to use, but it is easy to add extra functionality through a flexible and powerful developer framework. The Joomla! Framework allows you to build exceptional extensions for Joomla! including components, modules, plugins, templates and language packs.";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:4:"link";a:1:{i:0;a:5:{s:4:"data";s:46:"http://developer.joomla.org/security/news.html";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:13:"lastBuildDate";a:1:{i:0;a:5:{s:4:"data";s:31:"Sat, 05 Jun 2010 16:48:57 +0000";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:9:"generator";a:1:{i:0;a:5:{s:4:"data";s:44:"Joomla! 1.5 - Open Source Content Management";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:8:"language";a:1:{i:0;a:5:{s:4:"data";s:5:"en-gb";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:4:"item";a:10:{i:0;a:6:{s:4:"data";s:31:" + ";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";s:5:"child";a:3:{s:0:"";a:7:{s:5:"title";a:1:{i:0;a:5:{s:4:"data";s:38:"Joomla! Developer - Vulnerability News";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:11:"description";a:1:{i:0;a:5:{s:4:"data";s:274:"Not only is Joomla! easy to use, but it is easy to add extra functionality through a flexible and powerful developer framework. The Joomla! Framework allows you to build exceptional extensions for Joomla! including components, modules, plugins, templates and language packs.";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:4:"link";a:1:{i:0;a:5:{s:4:"data";s:46:"http://developer.joomla.org/security/news.html";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:13:"lastBuildDate";a:1:{i:0;a:5:{s:4:"data";s:31:"Tue, 15 Jun 2010 03:48:58 +0000";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:9:"generator";a:1:{i:0;a:5:{s:4:"data";s:44:"Joomla! 1.5 - Open Source Content Management";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:8:"language";a:1:{i:0;a:5:{s:4:"data";s:5:"en-gb";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:4:"item";a:10:{i:0;a:6:{s:4:"data";s:31:" @@ -287,4 +289,4 @@ a:3:{s:5:"child";a:1:{s:0:"";a:1:{s:3:"rss";a:1:{i:0;a:6:{s:4:"data";s:0:"";s:7:

Contact

The JSST at the Joomla! Security Center.

-
";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:6:"author";a:1:{i:0;a:5:{s:4:"data";s:36:"dextercowley@gmail.com (Mark Dexter)";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:8:"category";a:1:{i:0;a:5:{s:4:"data";s:13:"Core Security";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:7:"pubDate";a:1:{i:0;a:5:{s:4:"data";s:31:"Wed, 22 Jul 2009 23:17:38 +0000";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}}s:42:"http://rssnamespace.org/feedburner/ext/1.0";a:1:{s:8:"origLink";a:1:{i:0;a:5:{s:4:"data";s:76:"http://developer.joomla.org/security/news/301-20090722-core-file-upload.html";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}}}}}}s:27:"http://www.w3.org/2005/Atom";a:1:{s:4:"link";a:2:{i:0;a:5:{s:4:"data";s:0:"";s:7:"attribs";a:1:{s:0:"";a:3:{s:3:"rel";s:4:"self";s:4:"type";s:19:"application/rss+xml";s:4:"href";s:42:"http://feeds.joomla.org/JoomlaSecurityNews";}}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}i:1;a:5:{s:4:"data";s:0:"";s:7:"attribs";a:1:{s:0:"";a:2:{s:3:"rel";s:3:"hub";s:4:"href";s:32:"http://pubsubhubbub.appspot.com/";}}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}}s:42:"http://rssnamespace.org/feedburner/ext/1.0";a:3:{s:4:"info";a:1:{i:0;a:5:{s:4:"data";s:0:"";s:7:"attribs";a:1:{s:0:"";a:1:{s:3:"uri";s:18:"joomlasecuritynews";}}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:14:"emailServiceId";a:1:{i:0;a:5:{s:4:"data";s:18:"JoomlaSecurityNews";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:18:"feedburnerHostname";a:1:{i:0;a:5:{s:4:"data";s:28:"http://feedburner.google.com";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}}}}}}}}}}}s:7:"headers";a:10:{s:12:"content-type";s:23:"text/xml; charset=UTF-8";s:4:"etag";s:27:"mEQ8f6dW7LwZ3ZwUdK5jBO0NiXI";s:13:"last-modified";s:29:"Sat, 05 Jun 2010 16:49:18 GMT";s:17:"transfer-encoding";s:7:"chunked";s:4:"date";s:29:"Sat, 05 Jun 2010 16:53:11 GMT";s:7:"expires";s:29:"Sat, 05 Jun 2010 16:53:11 GMT";s:13:"cache-control";s:18:"private, max-age=0";s:22:"x-content-type-options";s:7:"nosniff";s:16:"x-xss-protection";s:1:"0";s:6:"server";s:3:"GSE";}s:5:"build";d:20070719221955;} \ No newline at end of file +";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:6:"author";a:1:{i:0;a:5:{s:4:"data";s:36:"dextercowley@gmail.com (Mark Dexter)";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:8:"category";a:1:{i:0;a:5:{s:4:"data";s:13:"Core Security";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:7:"pubDate";a:1:{i:0;a:5:{s:4:"data";s:31:"Wed, 22 Jul 2009 23:17:38 +0000";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}}s:42:"http://rssnamespace.org/feedburner/ext/1.0";a:1:{s:8:"origLink";a:1:{i:0;a:5:{s:4:"data";s:76:"http://developer.joomla.org/security/news/301-20090722-core-file-upload.html";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}}}}}}s:27:"http://www.w3.org/2005/Atom";a:1:{s:4:"link";a:2:{i:0;a:5:{s:4:"data";s:0:"";s:7:"attribs";a:1:{s:0:"";a:3:{s:3:"rel";s:4:"self";s:4:"type";s:19:"application/rss+xml";s:4:"href";s:42:"http://feeds.joomla.org/JoomlaSecurityNews";}}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}i:1;a:5:{s:4:"data";s:0:"";s:7:"attribs";a:1:{s:0:"";a:2:{s:3:"rel";s:3:"hub";s:4:"href";s:32:"http://pubsubhubbub.appspot.com/";}}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}}s:42:"http://rssnamespace.org/feedburner/ext/1.0";a:3:{s:4:"info";a:1:{i:0;a:5:{s:4:"data";s:0:"";s:7:"attribs";a:1:{s:0:"";a:1:{s:3:"uri";s:18:"joomlasecuritynews";}}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:14:"emailServiceId";a:1:{i:0;a:5:{s:4:"data";s:18:"JoomlaSecurityNews";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:18:"feedburnerHostname";a:1:{i:0;a:5:{s:4:"data";s:28:"http://feedburner.google.com";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}}}}}}}}}}}s:4:"type";i:128;s:7:"headers";a:10:{s:12:"content-type";s:23:"text/xml; charset=UTF-8";s:4:"etag";s:27:"RtB/SHBsUAt78r/1WSugWsjBdbA";s:13:"last-modified";s:29:"Tue, 15 Jun 2010 03:49:02 GMT";s:17:"transfer-encoding";s:7:"chunked";s:4:"date";s:29:"Tue, 15 Jun 2010 03:49:12 GMT";s:7:"expires";s:29:"Tue, 15 Jun 2010 03:49:12 GMT";s:13:"cache-control";s:18:"private, max-age=0";s:22:"x-content-type-options";s:7:"nosniff";s:16:"x-xss-protection";s:1:"0";s:6:"server";s:3:"GSE";}s:5:"build";s:14:"20090627192103";} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_admin/admin.admin.html.php b/oss/joomla/trunk/administrator/components/com_admin/admin.admin.html.php index 336ac332..d9c67352 100644 --- a/oss/joomla/trunk/administrator/components/com_admin/admin.admin.html.php +++ b/oss/joomla/trunk/administrator/components/com_admin/admin.admin.html.php @@ -1,335 +1,335 @@ -setBuffer($contents, 'modules', 'submenu'); - ?> -
- -
-
- - - - -
- -
-
- -
- - - - -
- -
-
- -
- - - - -
- -
-
- -
- - - - -
- -
-
- -
- - - - -
- -
-
-
- -
- - * In case of the remote server it is assumed that this server provide one specific - * help set of files in one particular language. - */ - function help() - { - global $mainframe; - jimport( 'joomla.filesystem.folder' ); - jimport( 'joomla.language.help' ); - - // Get Help URL - an empty helpurl is interpreted as local help files! - $helpurl = $mainframe->getCfg('helpurl'); - if ( $helpurl == 'http://help.mamboserver.com' ) { - $helpurl = 'http://help.joomla.org'; - } - $fullhelpurl = $helpurl . '/index2.php?option=com_content&task=findkey&pop=1&keyref='; - - $helpsearch = JRequest::getString('helpsearch'); - $page = JRequest::getCmd('page', 'joomla.whatsnew15.html'); - $toc = getHelpToc( $helpsearch ); - $lang =& JFactory::getLanguage(); - $langTag = $lang->getTag(); - if( !JFolder::exists( JPATH_BASE.DS.'help'.DS.$langTag ) ) { - $langTag = 'en-GB'; // use english as fallback - } - - if (!eregi( '\.html$', $page )) { - $page .= '.xml'; - } - ?> - - - - - - -
- - - - - -
- : - - - - - - - 'helpFrame')) ?> - | - 'helpFrame')) ?> - | - 'helpFrame')) ?> - - 'helpFrame')) ?> | - 'helpFrame')) ?> | - 'helpFrame')) ?> - - | - 'helpFrame')) ?> - | - 'helpFrame')) ?> - | - 'helpFrame')) ?> - | - 'helpFrame')) ?> -
-
- -
-
- - - - -
-
    - $v) { - if ($helpurl) { - echo '
  • '; - echo JHTML::_('link', JHelp::createUrl( $k ), $v, array('target' => 'helpFrame')); - echo '
  • '; - } else { - echo '
  • '; - echo JHTML::_('link', JURI::base() .'help/'.$langTag.'/'.$k, $v, array('target' => 'helpFrame')); - echo '
  • '; - } - } - ?> -
-
-
-
- -
-
- - - - - - - - -
-
- - -
- -
-			/','',$changelog);
-
-			// Convert all other HTML entities
-			echo htmlentities($changelog);
-			?>
-		
- '. JText::_( 'Writable' ) .''; - $unwriteable = ''. JText::_( 'Unwritable' ) .''; - - echo ''; - echo ''; - echo $text; - if ( $visible ) { - echo $folder . '/'; - } - echo ''; - echo ''; - if ( $relative ) { - echo is_writable( "../$folder" ) ? $writeable : $unwriteable; - } else { - echo is_writable( "$folder" ) ? $writeable : $unwriteable; - } - echo ''; - echo ''; -} - -/** - * Compiles the help table of contents - * @param string A specific keyword on which to filter the resulting list - */ -function getHelpTOC( $helpsearch ) -{ - global $mainframe; - - $lang =& JFactory::getLanguage(); - jimport( 'joomla.filesystem.folder' ); - - $helpurl = $mainframe->getCfg('helpurl'); - - // Check for files in the actual language - $langTag = $lang->getTag(); - if( !JFolder::exists( JPATH_BASE.DS.'help'.DS.$langTag ) ) { - $langTag = 'en-GB'; // use english as fallback - } - $files = JFolder::files( JPATH_BASE.DS.'help'.DS.$langTag, '\.xml$|\.html$' ); - - $toc = array(); - foreach ($files as $file) { - $buffer = file_get_contents( JPATH_BASE.DS.'help'.DS.$langTag.DS.$file ); - if (preg_match( '#(.*?)#', $buffer, $m )) { - $title = trim( $m[1] ); - if ($title) { - if ($helpurl) { - // strip the extension - $file = preg_replace( '#\.xml$|\.html$#', '', $file ); - } - if ($helpsearch) { - if (JString::strpos( strip_tags( $buffer ), $helpsearch ) !== false) { - $toc[$file] = $title; - } - } else { - $toc[$file] = $title; - } - } - } - } - asort( $toc ); - return $toc; -} +setBuffer($contents, 'modules', 'submenu'); + ?> +
+ +
+
+ + + + +
+ +
+
+ +
+ + + + +
+ +
+
+ +
+ + + + +
+ +
+
+ +
+ + + + +
+ +
+
+ +
+ + + + +
+ +
+
+
+ +
+ + * In case of the remote server it is assumed that this server provide one specific + * help set of files in one particular language. + */ + function help() + { + global $mainframe; + jimport( 'joomla.filesystem.folder' ); + jimport( 'joomla.language.help' ); + + // Get Help URL - an empty helpurl is interpreted as local help files! + $helpurl = $mainframe->getCfg('helpurl'); + if ( $helpurl == 'http://help.mamboserver.com' ) { + $helpurl = 'http://help.joomla.org'; + } + $fullhelpurl = $helpurl . '/index2.php?option=com_content&task=findkey&pop=1&keyref='; + + $helpsearch = JRequest::getString('helpsearch'); + $page = JRequest::getCmd('page', 'joomla.whatsnew15.html'); + $toc = getHelpToc( $helpsearch ); + $lang =& JFactory::getLanguage(); + $langTag = $lang->getTag(); + if( !JFolder::exists( JPATH_BASE.DS.'help'.DS.$langTag ) ) { + $langTag = 'en-GB'; // use english as fallback + } + + if (!preg_match( '#\.html$#i', $page )) { + $page .= '.xml'; + } + ?> + + + + + + +
+ + + + + +
+ : + + + + + + + 'helpFrame')) ?> + | + 'helpFrame')) ?> + | + 'helpFrame')) ?> + + 'helpFrame')) ?> | + 'helpFrame')) ?> | + 'helpFrame')) ?> + + | + 'helpFrame')) ?> + | + 'helpFrame')) ?> + | + 'helpFrame')) ?> + | + 'helpFrame')) ?> +
+
+ +
+
+ + + + +
+
    + $v) { + if ($helpurl) { + echo '
  • '; + echo JHTML::_('link', JHelp::createUrl( $k ), $v, array('target' => 'helpFrame')); + echo '
  • '; + } else { + echo '
  • '; + echo JHTML::_('link', JURI::base() .'help/'.$langTag.'/'.$k, $v, array('target' => 'helpFrame')); + echo '
  • '; + } + } + ?> +
+
+
+
+ +
+
+ + + + + + + + +
+
+ + +
+ +
+			/','',$changelog);
+
+			// Convert all other HTML entities
+			echo htmlentities($changelog);
+			?>
+		
+ '. JText::_( 'Writable' ) .''; + $unwriteable = ''. JText::_( 'Unwritable' ) .''; + + echo ''; + echo ''; + echo $text; + if ( $visible ) { + echo $folder . '/'; + } + echo ''; + echo ''; + if ( $relative ) { + echo is_writable( "../$folder" ) ? $writeable : $unwriteable; + } else { + echo is_writable( "$folder" ) ? $writeable : $unwriteable; + } + echo ''; + echo ''; +} + +/** + * Compiles the help table of contents + * @param string A specific keyword on which to filter the resulting list + */ +function getHelpTOC( $helpsearch ) +{ + global $mainframe; + + $lang =& JFactory::getLanguage(); + jimport( 'joomla.filesystem.folder' ); + + $helpurl = $mainframe->getCfg('helpurl'); + + // Check for files in the actual language + $langTag = $lang->getTag(); + if( !JFolder::exists( JPATH_BASE.DS.'help'.DS.$langTag ) ) { + $langTag = 'en-GB'; // use english as fallback + } + $files = JFolder::files( JPATH_BASE.DS.'help'.DS.$langTag, '\.xml$|\.html$' ); + + $toc = array(); + foreach ($files as $file) { + $buffer = file_get_contents( JPATH_BASE.DS.'help'.DS.$langTag.DS.$file ); + if (preg_match( '#(.*?)#', $buffer, $m )) { + $title = trim( $m[1] ); + if ($title) { + if ($helpurl) { + // strip the extension + $file = preg_replace( '#\.xml$|\.html$#', '', $file ); + } + if ($helpsearch) { + if (JString::strpos( strip_tags( $buffer ), $helpsearch ) !== false) { + $toc[$file] = $title; + } + } else { + $toc[$file] = $title; + } + } + } + } + asort( $toc ); + return $toc; +} diff --git a/oss/joomla/trunk/administrator/components/com_admin/admin.admin.php b/oss/joomla/trunk/administrator/components/com_admin/admin.admin.php index eae282ec..9280649b 100644 --- a/oss/joomla/trunk/administrator/components/com_admin/admin.admin.php +++ b/oss/joomla/trunk/administrator/components/com_admin/admin.admin.php @@ -1,48 +1,48 @@ - -
- - - - - - - - - - - - - - - - $v) { - if (eregi( 'var \$host', $v)) { - $cf[$k] = 'var $host = \'xxxxxx\''; - } else if (eregi( 'var \$user', $v)) { - $cf[$k] = 'var $user = \'xxxxxx\''; - } else if (eregi( 'var \$password', $v)) { - $cf[$k] = 'var $password = \'xxxxxx\''; - } else if (eregi( 'var \$db ', $v)) { - $cf[$k] = 'var $db = \'xxxxxx\''; - } else if (eregi( 'var \$ftp_user ', $v)) { - $cf[$k] = 'var $ftp_user = \'xxxxxx\''; - } else if (eregi( 'var \$ftp_pass ', $v)) { - $cf[$k] = 'var $ftp_pass = \'xxxxxx\''; - } else if (eregi( 'var \$smtpuser ', $v)) { - $cf[$k] = 'var $smtpuser = \'xxxxxx\''; - } else if (eregi( 'var \$smtppass ', $v)) { - $cf[$k] = 'var $smtppass = \'xxxxxx\''; - } else if (eregi( '', $v)) { - $cf[$k] = ''; - } else if (eregi( '}', $v)) { - $cf[$k] = ''; - } else if (eregi( 'class JConfig {', $v)) { - $cf[$k] = ''; - } - $cf[$k] = str_replace('var ','',$cf[$k]); - $cf[$k] = str_replace(';','',$cf[$k]); - $cf[$k] = str_replace(' = ',''; - if ($cf[$k] != '') { - $config_output[] = $cf[$k]; - } - } - echo implode( '', $config_output ); - ?> - - -
- - - -
-   -
',$cf[$k]); - $cf[$k] = ''. $cf[$k] .'
-
+ +
+ + + + + + + + + + + + + + + + $v) { + if (preg_match( '#var \$host#i', $v)) { + $cf[$k] = 'var $host = \'xxxxxx\''; + } else if (preg_match( '#var \$user#i', $v)) { + $cf[$k] = 'var $user = \'xxxxxx\''; + } else if (preg_match( '#var \$password#i', $v)) { + $cf[$k] = 'var $password = \'xxxxxx\''; + } else if (preg_match( '#var \$db#i', $v)) { + $cf[$k] = 'var $db = \'xxxxxx\''; + } else if (preg_match( '#var \$ftp_user#i', $v)) { + $cf[$k] = 'var $ftp_user = \'xxxxxx\''; + } else if (preg_match( '#var \$ftp_pass#i', $v)) { + $cf[$k] = 'var $ftp_pass = \'xxxxxx\''; + } else if (preg_match( '#var \$smtpuser#i', $v)) { + $cf[$k] = 'var $smtpuser = \'xxxxxx\''; + } else if (preg_match( '#var \$smtppass#i', $v)) { + $cf[$k] = 'var $smtppass = \'xxxxxx\''; + } else if (preg_match( '#<\?php#i', $v)) { + $cf[$k] = ''; + } else if (preg_match( '#\?>#i', $v)) { + $cf[$k] = ''; + } else if (preg_match( '#\}#i', $v)) { + $cf[$k] = ''; + } else if (preg_match( '#class JConfig \{#i', $v)) { + $cf[$k] = ''; + } + $cf[$k] = str_replace('var ','',$cf[$k]); + $cf[$k] = str_replace(';','',$cf[$k]); + $cf[$k] = str_replace(' = ',''; + if ($cf[$k] != '') { + $config_output[] = $cf[$k]; + } + } + echo implode( '', $config_output ); + ?> + + +
+ + + +
+   +
',$cf[$k]); + $cf[$k] = ''. $cf[$k] .'
+
diff --git a/oss/joomla/trunk/administrator/components/com_admin/toolbar.admin.html.php b/oss/joomla/trunk/administrator/components/com_admin/toolbar.admin.html.php index 0854b425..6e3bf4f7 100644 --- a/oss/joomla/trunk/administrator/components/com_admin/toolbar.admin.html.php +++ b/oss/joomla/trunk/administrator/components/com_admin/toolbar.admin.html.php @@ -1,48 +1,48 @@ -authorize( 'com_banners', 'manage' )) { - $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); -} - -// Set the table directory -JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_banners'.DS.'tables'); - -$controllerName = JRequest::getCmd( 'c', 'banner' ); - -if($controllerName == 'client') { - JSubMenuHelper::addEntry(JText::_('Banners'), 'index.php?option=com_banners'); - JSubMenuHelper::addEntry(JText::_('Clients'), 'index.php?option=com_banners&c=client', true ); - JSubMenuHelper::addEntry(JText::_('Categories'), 'index.php?option=com_categories§ion=com_banner'); -} else { - JSubMenuHelper::addEntry(JText::_('Banners'), 'index.php?option=com_banners', true ); - JSubMenuHelper::addEntry(JText::_('Clients'), 'index.php?option=com_banners&c=client'); - JSubMenuHelper::addEntry(JText::_('Categories'), 'index.php?option=com_categories§ion=com_banner'); -} - -switch ($controllerName) -{ - default: - $controllerName = 'banner'; - // allow fall through - - case 'banner' : - case 'client': - // Temporary interceptor - $task = JRequest::getCmd('task'); - if ($task == 'listclients') { - $controllerName = 'client'; - } - - require_once( JPATH_COMPONENT.DS.'controllers'.DS.$controllerName.'.php' ); - $controllerName = 'BannerController'.$controllerName; - - // Create the controller - $controller = new $controllerName(); - - // Perform the Request task - $controller->execute( JRequest::getCmd('task') ); - - // Redirect if set by the controller - $controller->redirect(); - break; +authorize( 'com_banners', 'manage' )) { + $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); +} + +// Set the table directory +JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_banners'.DS.'tables'); + +$controllerName = JRequest::getCmd( 'c', 'banner' ); + +if($controllerName == 'client') { + JSubMenuHelper::addEntry(JText::_('Banners'), 'index.php?option=com_banners'); + JSubMenuHelper::addEntry(JText::_('Clients'), 'index.php?option=com_banners&c=client', true ); + JSubMenuHelper::addEntry(JText::_('Categories'), 'index.php?option=com_categories§ion=com_banner'); +} else { + JSubMenuHelper::addEntry(JText::_('Banners'), 'index.php?option=com_banners', true ); + JSubMenuHelper::addEntry(JText::_('Clients'), 'index.php?option=com_banners&c=client'); + JSubMenuHelper::addEntry(JText::_('Categories'), 'index.php?option=com_categories§ion=com_banner'); +} + +switch ($controllerName) +{ + default: + $controllerName = 'banner'; + // allow fall through + + case 'banner' : + case 'client': + // Temporary interceptor + $task = JRequest::getCmd('task'); + if ($task == 'listclients') { + $controllerName = 'client'; + } + + require_once( JPATH_COMPONENT.DS.'controllers'.DS.$controllerName.'.php' ); + $controllerName = 'BannerController'.$controllerName; + + // Create the controller + $controller = new $controllerName(); + + // Perform the Request task + $controller->execute( JRequest::getCmd('task') ); + + // Redirect if set by the controller + $controller->redirect(); + break; } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_banners/banners.xml b/oss/joomla/trunk/administrator/components/com_banners/banners.xml index ee860619..479bde55 100644 --- a/oss/joomla/trunk/administrator/components/com_banners/banners.xml +++ b/oss/joomla/trunk/administrator/components/com_banners/banners.xml @@ -1,12 +1,12 @@ - - - Banners - Joomla! Project - April 2006 - Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - admin@joomla.org - www.joomla.org - 1.5.0 - This component manages banners and banner clients - + + + Banners + Joomla! Project + April 2006 + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + This component manages banners and banner clients + diff --git a/oss/joomla/trunk/administrator/components/com_banners/controllers/banner.php b/oss/joomla/trunk/administrator/components/com_banners/controllers/banner.php index cbb6bd11..3160ddd0 100644 --- a/oss/joomla/trunk/administrator/components/com_banners/controllers/banner.php +++ b/oss/joomla/trunk/administrator/components/com_banners/controllers/banner.php @@ -1,447 +1,451 @@ -registerTask( 'add', 'edit' ); - $this->registerTask( 'apply', 'save' ); - $this->registerTask( 'resethits', 'save' ); - $this->registerTask( 'unpublish', 'publish' ); - } - - /** - * Display the list of banners - */ - function display() - { - global $mainframe; - - $db =& JFactory::getDBO(); - - $context = 'com_banners.banner.list.'; - $filter_order = $mainframe->getUserStateFromRequest( $context.'filter_order', 'filter_order', 'cc.title', 'cmd' ); - $filter_order_Dir = $mainframe->getUserStateFromRequest( $context.'filter_order_Dir', 'filter_order_Dir', '', 'word' ); - $filter_catid = $mainframe->getUserStateFromRequest( $context.'filter_catid', 'filter_catid', '', 'int' ); - $filter_state = $mainframe->getUserStateFromRequest( $context.'filter_state', 'filter_state', '', 'word' ); - $search = $mainframe->getUserStateFromRequest( $context.'search', 'search', '', 'string' ); - - $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); - $limitstart = $mainframe->getUserStateFromRequest( $context.'limitstart', 'limitstart', 0, 'int' ); - - $where = array(); - - if ( $filter_state ) - { - if ( $filter_state == 'P' ) { - $where[] = 'b.showBanner = 1'; - } - else if ($filter_state == 'U' ) { - $where[] = 'b.showBanner = 0'; - } - } - if ($filter_catid) { - $where[] = 'cc.id = ' . (int) $filter_catid; - } - if ($search) { - $where[] = 'LOWER(b.name) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); - } - - $where = count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : ''; - $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', b.ordering'; - - // get the total number of records - $query = 'SELECT COUNT(*)' - . ' FROM #__banner AS b' - . ' LEFT JOIN #__categories AS cc ON cc.id = b.catid' - . $where - ; - $db->setQuery( $query ); - $total = $db->loadResult(); - - jimport('joomla.html.pagination'); - $pageNav = new JPagination( $total, $limitstart, $limit ); - - $query = 'SELECT b.*, c.name AS client_name, cc.title AS category_name, u.name AS editor' - . ' FROM #__banner AS b' - . ' INNER JOIN #__bannerclient AS c ON c.cid = b.cid' - . ' LEFT JOIN #__categories AS cc ON cc.id = b.catid' - . ' LEFT JOIN #__users AS u ON u.id = b.checked_out' - . $where - . $orderby - ; - $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); - $rows = $db->loadObjectList(); - - // build list of categories - $javascript = 'onchange="document.adminForm.submit();"'; - $lists['catid'] = JHTML::_('list.category', 'filter_catid', 'com_banner', (int) $filter_catid, $javascript ); - - // state filter - $lists['state'] = JHTML::_('grid.state', $filter_state ); - - // table ordering - $lists['order_Dir'] = $filter_order_Dir; - $lists['order'] = $filter_order; - - // search filter - $lists['search']= $search; - - require_once(JPATH_COMPONENT.DS.'views'.DS.'banner.php'); - BannersViewBanner::banners( $rows, $pageNav, $lists ); - } - - function edit() - { - $db =& JFactory::getDBO(); - $user =& JFactory::getUser(); - - if ($this->_task == 'edit') { - $cid = JRequest::getVar('cid', array(0), 'method', 'array'); - $cid = array((int) $cid[0]); - } else { - $cid = array( 0 ); - } - - $option = JRequest::getCmd('option'); - - $lists = array(); - - $row =& JTable::getInstance('banner', 'Table'); - $row->load( $cid[0] ); - - if ($cid[0]) { - $row->checkout( $user->get('id') ); - } else { - $row->showBanner = 1; - } - - // Build Client select list - $sql = 'SELECT cid, name' - . ' FROM #__bannerclient' - ; - $db->setQuery($sql); - if (!$db->query()) - { - $this->setRedirect( 'index.php?option=com_banners' ); - return JError::raiseWarning( 500, $db->getErrorMsg() ); - } - - $banner_params = new JParameter( $row->params ); - $lists['width'] = $banner_params->get( 'width'); - $lists['height'] = $banner_params->get( 'height'); - - $clientlist[] = JHTML::_('select.option', '0', JText::_( 'Select Client' ), 'cid', 'name' ); - $clientlist = array_merge( $clientlist, $db->loadObjectList() ); - $lists['cid'] = JHTML::_('select.genericlist', $clientlist, 'cid', 'class="inputbox" size="1"','cid', 'name', $row->cid ); - - // Imagelist - $javascript = 'onchange="changeDisplayImage();"'; - $directory = '/images/banners'; - $lists['imageurl'] = JHTML::_('list.images', 'imageurl', $row->imageurl, $javascript, $directory, "bmp|gif|jpg|png|swf" ); - - // build list of categories - $lists['catid'] = JHTML::_('list.category', 'catid', 'com_banner', intval( $row->catid ) ); - - // sticky - $lists['sticky'] = JHTML::_('select.booleanlist', 'sticky', 'class="inputbox"', $row->sticky ); - - // published - $lists['showBanner'] = JHTML::_('select.booleanlist', 'showBanner', '', $row->showBanner ); - - require_once(JPATH_COMPONENT.DS.'views'.DS.'banner.php'); - BannersViewBanner::banner( $row, $lists ); - } - - /** - * Save method - */ - function save() - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $this->setRedirect( 'index.php?option=com_banners' ); - - // Initialize variables - $db =& JFactory::getDBO(); - - $post = JRequest::get( 'post' ); - // fix up special html fields - $post['custombannercode'] = JRequest::getVar( 'custombannercode', '', 'post', 'string', JREQUEST_ALLOWRAW ); - - $row =& JTable::getInstance('banner', 'Table'); - - // Save params temp fix - $temp1 = array(); - $temp2 = array(); - $temp1['width'] = (int) $post['width']; - $temp1['height'] = (int) $post['height']; - foreach ($temp1 as $k => $v) - { - if ( $k && strlen($v) ) - { - $temp2[] = $k.'='.$v; - } - } - $row->params = implode( "\n", $temp2 ); - - if (!$row->bind( $post )) { - return JError::raiseWarning( 500, $row->getError() ); - } - - // Resets clicks when `Reset Clicks` button is used instead of `Save` button - $task = JRequest::getCmd( 'task' ); - if ( $task == 'resethits' ) - { - $row->clicks = 0; - $msg = JText::_( 'Reset Banner clicks' ); - } - - // Sets impressions to unlimited when `unlimited` checkbox ticked - $unlimited = JRequest::getBool('unlimited'); - if ($unlimited) { - $row->imptotal = 0; - } - - if (!$row->check()) { - return JError::raiseWarning( 500, $row->getError() ); - } - - // if new item order last in appropriate group - if (!$row->bid) - { - $where = 'catid = '.(int) $row->catid; - $row->ordering = $row->getNextOrder( $where ); - } - - if (!$row->store()) { - return JError::raiseWarning( 500, $row->getError() ); - } - $row->checkin(); - - switch ($task) - { - case 'apply': - $link = 'index.php?option=com_banners&task=edit&cid[]='. $row->bid ; - break; - - case 'save': - default: - $link = 'index.php?option=com_banners'; - break; - } - - $this->setRedirect( $link, JText::_( 'Item Saved' ) ); - } - - function cancel() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $this->setRedirect( 'index.php?option=com_banners' ); - - // Initialize variables - $db =& JFactory::getDBO(); - $post = JRequest::get( 'post' ); - $row =& JTable::getInstance('banner', 'Table'); - $row->bind( $post ); - $row->checkin(); - } - - /** - * Copies one or more banners - */ - function copy() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $this->setRedirect( 'index.php?option=com_banners' ); - - $cid = JRequest::getVar( 'cid', null, 'post', 'array' ); - $db =& JFactory::getDBO(); - $table =& JTable::getInstance('banner', 'Table'); - $user = &JFactory::getUser(); - $n = count( $cid ); - - if ($n > 0) - { - foreach ($cid as $id) - { - if ($table->load( (int)$id )) - { - $table->bid = 0; - $table->name = 'Copy of ' . $table->name; - $table->impmade = 0; - $table->clicks = 0; - $table->showBanner = 0; - $table->date = $db->getNullDate(); - - if (!$table->store()) { - return JError::raiseWarning( $table->getError() ); - } - } - else { - return JError::raiseWarning( 500, $table->getError() ); - } - } - } - else { - return JError::raiseWarning( 500, JText::_( 'No items selected' ) ); - } - $this->setMessage( JText::sprintf( 'Items copied', $n ) ); - } - - function publish() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $this->setRedirect( 'index.php?option=com_banners' ); - - // Initialize variables - $db =& JFactory::getDBO(); - $user =& JFactory::getUser(); - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - $task = JRequest::getCmd( 'task' ); - $publish = ($task == 'publish'); - $n = count( $cid ); - - if (empty( $cid )) { - return JError::raiseWarning( 500, JText::_( 'No items selected' ) ); - } - - JArrayHelper::toInteger( $cid ); - $cids = implode( ',', $cid ); - - $query = 'UPDATE #__banner' - . ' SET showBanner = ' . (int) $publish - . ' WHERE bid IN ( '. $cids.' )' - . ' AND ( checked_out = 0 OR ( checked_out = ' .(int) $user->get('id'). ' ) )' - ; - $db->setQuery( $query ); - if (!$db->query()) { - return JError::raiseWarning( 500, $db->getError() ); - } - $this->setMessage( JText::sprintf( $publish ? 'Items published' : 'Items unpublished', $n ) ); - } - - function remove() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $this->setRedirect( 'index.php?option=com_banners' ); - - // Initialize variables - $db =& JFactory::getDBO(); - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - $n = count( $cid ); - JArrayHelper::toInteger( $cid ); - - if ($n) - { - $query = 'DELETE FROM #__banner' - . ' WHERE bid = ' . implode( ' OR bid = ', $cid ) - ; - $db->setQuery( $query ); - if (!$db->query()) { - JError::raiseWarning( 500, $db->getError() ); - } - } - - $this->setMessage( JText::sprintf( 'Items removed', $n ) ); - } - - /** - * Save the new order given by user - */ - function saveOrder() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $this->setRedirect( 'index.php?option=com_banners' ); - - // Initialize variables - $db =& JFactory::getDBO(); - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - $order = JRequest::getVar( 'order', array(), 'post', 'array' ); - $row =& JTable::getInstance('banner', 'Table'); - $total = count( $cid ); - $conditions = array(); - - if (empty( $cid )) { - return JError::raiseWarning( 500, JText::_( 'No items selected' ) ); - } - - // update ordering values - for ($i = 0; $i < $total; $i++) - { - $row->load( (int) $cid[$i] ); - if ($row->ordering != $order[$i]) - { - $row->ordering = $order[$i]; - if (!$row->store()) { - return JError::raiseError( 500, $db->getErrorMsg() ); - } - // remember to reorder this category - $condition = 'catid = '.(int) $row->catid; - $found = false; - foreach ($conditions as $cond) { - if ($cond[1] == $condition) - { - $found = true; - break; - } - } - if (!$found) { - $conditions[] = array ( $row->bid, $condition ); - } - } - } - - // execute reorder for each category - foreach ($conditions as $cond) - { - $row->load( $cond[0] ); - $row->reorder( $cond[1] ); - } - - // Clear the component's cache - $cache =& JFactory::getCache('com_banners'); - $cache->clean(); - - $this->setMessage( JText::_('New ordering saved') ); - } -} +registerTask( 'add', 'edit' ); + $this->registerTask( 'apply', 'save' ); + $this->registerTask( 'resethits', 'save' ); + $this->registerTask( 'unpublish', 'publish' ); + } + + /** + * Display the list of banners + */ + function display() + { + global $mainframe; + + $db =& JFactory::getDBO(); + + $context = 'com_banners.banner.list.'; + $filter_order = $mainframe->getUserStateFromRequest( $context.'filter_order', 'filter_order', 'cc.title', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( $context.'filter_order_Dir', 'filter_order_Dir', '', 'word' ); + $filter_catid = $mainframe->getUserStateFromRequest( $context.'filter_catid', 'filter_catid', '', 'int' ); + $filter_state = $mainframe->getUserStateFromRequest( $context.'filter_state', 'filter_state', '', 'word' ); + $search = $mainframe->getUserStateFromRequest( $context.'search', 'search', '', 'string' ); + if (strpos($search, '"') !== false) { + $search = str_replace(array('=', '<'), '', $search); + } + $search = JString::strtolower($search); + + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( $context.'limitstart', 'limitstart', 0, 'int' ); + + $where = array(); + + if ( $filter_state ) + { + if ( $filter_state == 'P' ) { + $where[] = 'b.showBanner = 1'; + } + else if ($filter_state == 'U' ) { + $where[] = 'b.showBanner = 0'; + } + } + if ($filter_catid) { + $where[] = 'cc.id = ' . (int) $filter_catid; + } + if ($search) { + $where[] = 'LOWER(b.name) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + + $where = count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : ''; + $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', b.ordering'; + + // get the total number of records + $query = 'SELECT COUNT(*)' + . ' FROM #__banner AS b' + . ' LEFT JOIN #__categories AS cc ON cc.id = b.catid' + . $where + ; + $db->setQuery( $query ); + $total = $db->loadResult(); + + jimport('joomla.html.pagination'); + $pageNav = new JPagination( $total, $limitstart, $limit ); + + $query = 'SELECT b.*, c.name AS client_name, cc.title AS category_name, u.name AS editor' + . ' FROM #__banner AS b' + . ' INNER JOIN #__bannerclient AS c ON c.cid = b.cid' + . ' LEFT JOIN #__categories AS cc ON cc.id = b.catid' + . ' LEFT JOIN #__users AS u ON u.id = b.checked_out' + . $where + . $orderby + ; + $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); + $rows = $db->loadObjectList(); + + // build list of categories + $javascript = 'onchange="document.adminForm.submit();"'; + $lists['catid'] = JHTML::_('list.category', 'filter_catid', 'com_banner', (int) $filter_catid, $javascript ); + + // state filter + $lists['state'] = JHTML::_('grid.state', $filter_state ); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search']= $search; + + require_once(JPATH_COMPONENT.DS.'views'.DS.'banner.php'); + BannersViewBanner::banners( $rows, $pageNav, $lists ); + } + + function edit() + { + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + + if ($this->_task == 'edit') { + $cid = JRequest::getVar('cid', array(0), 'method', 'array'); + $cid = array((int) $cid[0]); + } else { + $cid = array( 0 ); + } + + $option = JRequest::getCmd('option'); + + $lists = array(); + + $row =& JTable::getInstance('banner', 'Table'); + $row->load( $cid[0] ); + + if ($cid[0]) { + $row->checkout( $user->get('id') ); + } else { + $row->showBanner = 1; + } + + // Build Client select list + $sql = 'SELECT cid, name' + . ' FROM #__bannerclient' + ; + $db->setQuery($sql); + if (!$db->query()) + { + $this->setRedirect( 'index.php?option=com_banners' ); + return JError::raiseWarning( 500, $db->getErrorMsg() ); + } + + $banner_params = new JParameter( $row->params ); + $lists['width'] = $banner_params->get( 'width'); + $lists['height'] = $banner_params->get( 'height'); + + $clientlist[] = JHTML::_('select.option', '0', JText::_( 'Select Client' ), 'cid', 'name' ); + $clientlist = array_merge( $clientlist, $db->loadObjectList() ); + $lists['cid'] = JHTML::_('select.genericlist', $clientlist, 'cid', 'class="inputbox" size="1"','cid', 'name', $row->cid ); + + // Imagelist + $javascript = 'onchange="changeDisplayImage();"'; + $directory = '/images/banners'; + $lists['imageurl'] = JHTML::_('list.images', 'imageurl', $row->imageurl, $javascript, $directory, "bmp|gif|jpg|png|swf" ); + + // build list of categories + $lists['catid'] = JHTML::_('list.category', 'catid', 'com_banner', intval( $row->catid ) ); + + // sticky + $lists['sticky'] = JHTML::_('select.booleanlist', 'sticky', 'class="inputbox"', $row->sticky ); + + // published + $lists['showBanner'] = JHTML::_('select.booleanlist', 'showBanner', '', $row->showBanner ); + + require_once(JPATH_COMPONENT.DS.'views'.DS.'banner.php'); + BannersViewBanner::banner( $row, $lists ); + } + + /** + * Save method + */ + function save() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $this->setRedirect( 'index.php?option=com_banners' ); + + // Initialize variables + $db =& JFactory::getDBO(); + + $post = JRequest::get( 'post' ); + // fix up special html fields + $post['custombannercode'] = JRequest::getVar( 'custombannercode', '', 'post', 'string', JREQUEST_ALLOWRAW ); + + $row =& JTable::getInstance('banner', 'Table'); + + // Save params temp fix + $temp1 = array(); + $temp2 = array(); + $temp1['width'] = (int) $post['width']; + $temp1['height'] = (int) $post['height']; + foreach ($temp1 as $k => $v) + { + if ( $k && strlen($v) ) + { + $temp2[] = $k.'='.$v; + } + } + $row->params = implode( "\n", $temp2 ); + + if (!$row->bind( $post )) { + return JError::raiseWarning( 500, $row->getError() ); + } + + // Resets clicks when `Reset Clicks` button is used instead of `Save` button + $task = JRequest::getCmd( 'task' ); + if ( $task == 'resethits' ) + { + $row->clicks = 0; + $msg = JText::_( 'Reset Banner clicks' ); + } + + // Sets impressions to unlimited when `unlimited` checkbox ticked + $unlimited = JRequest::getBool('unlimited'); + if ($unlimited) { + $row->imptotal = 0; + } + + if (!$row->check()) { + return JError::raiseWarning( 500, $row->getError() ); + } + + // if new item order last in appropriate group + if (!$row->bid) + { + $where = 'catid = '.(int) $row->catid; + $row->ordering = $row->getNextOrder( $where ); + } + + if (!$row->store()) { + return JError::raiseWarning( 500, $row->getError() ); + } + $row->checkin(); + + switch ($task) + { + case 'apply': + $link = 'index.php?option=com_banners&task=edit&cid[]='. $row->bid ; + break; + + case 'save': + default: + $link = 'index.php?option=com_banners'; + break; + } + + $this->setRedirect( $link, JText::_( 'Item Saved' ) ); + } + + function cancel() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $this->setRedirect( 'index.php?option=com_banners' ); + + // Initialize variables + $db =& JFactory::getDBO(); + $post = JRequest::get( 'post' ); + $row =& JTable::getInstance('banner', 'Table'); + $row->bind( $post ); + $row->checkin(); + } + + /** + * Copies one or more banners + */ + function copy() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $this->setRedirect( 'index.php?option=com_banners' ); + + $cid = JRequest::getVar( 'cid', null, 'post', 'array' ); + $db =& JFactory::getDBO(); + $table =& JTable::getInstance('banner', 'Table'); + $user = &JFactory::getUser(); + $n = count( $cid ); + + if ($n > 0) + { + foreach ($cid as $id) + { + if ($table->load( (int)$id )) + { + $table->bid = 0; + $table->name = 'Copy of ' . $table->name; + $table->impmade = 0; + $table->clicks = 0; + $table->showBanner = 0; + $table->date = $db->getNullDate(); + + if (!$table->store()) { + return JError::raiseWarning( $table->getError() ); + } + } + else { + return JError::raiseWarning( 500, $table->getError() ); + } + } + } + else { + return JError::raiseWarning( 500, JText::_( 'No items selected' ) ); + } + $this->setMessage( JText::sprintf( 'Items copied', $n ) ); + } + + function publish() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $this->setRedirect( 'index.php?option=com_banners' ); + + // Initialize variables + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + $task = JRequest::getCmd( 'task' ); + $publish = ($task == 'publish'); + $n = count( $cid ); + + if (empty( $cid )) { + return JError::raiseWarning( 500, JText::_( 'No items selected' ) ); + } + + JArrayHelper::toInteger( $cid ); + $cids = implode( ',', $cid ); + + $query = 'UPDATE #__banner' + . ' SET showBanner = ' . (int) $publish + . ' WHERE bid IN ( '. $cids.' )' + . ' AND ( checked_out = 0 OR ( checked_out = ' .(int) $user->get('id'). ' ) )' + ; + $db->setQuery( $query ); + if (!$db->query()) { + return JError::raiseWarning( 500, $db->getError() ); + } + $this->setMessage( JText::sprintf( $publish ? 'Items published' : 'Items unpublished', $n ) ); + } + + function remove() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $this->setRedirect( 'index.php?option=com_banners' ); + + // Initialize variables + $db =& JFactory::getDBO(); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + $n = count( $cid ); + JArrayHelper::toInteger( $cid ); + + if ($n) + { + $query = 'DELETE FROM #__banner' + . ' WHERE bid = ' . implode( ' OR bid = ', $cid ) + ; + $db->setQuery( $query ); + if (!$db->query()) { + JError::raiseWarning( 500, $db->getError() ); + } + } + + $this->setMessage( JText::sprintf( 'Items removed', $n ) ); + } + + /** + * Save the new order given by user + */ + function saveOrder() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $this->setRedirect( 'index.php?option=com_banners' ); + + // Initialize variables + $db =& JFactory::getDBO(); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + $order = JRequest::getVar( 'order', array(), 'post', 'array' ); + $row =& JTable::getInstance('banner', 'Table'); + $total = count( $cid ); + $conditions = array(); + + if (empty( $cid )) { + return JError::raiseWarning( 500, JText::_( 'No items selected' ) ); + } + + // update ordering values + for ($i = 0; $i < $total; $i++) + { + $row->load( (int) $cid[$i] ); + if ($row->ordering != $order[$i]) + { + $row->ordering = $order[$i]; + if (!$row->store()) { + return JError::raiseError( 500, $db->getErrorMsg() ); + } + // remember to reorder this category + $condition = 'catid = '.(int) $row->catid; + $found = false; + foreach ($conditions as $cond) { + if ($cond[1] == $condition) + { + $found = true; + break; + } + } + if (!$found) { + $conditions[] = array ( $row->bid, $condition ); + } + } + } + + // execute reorder for each category + foreach ($conditions as $cond) + { + $row->load( $cond[0] ); + $row->reorder( $cond[1] ); + } + + // Clear the component's cache + $cache =& JFactory::getCache('com_banners'); + $cache->clean(); + + $this->setMessage( JText::_('New ordering saved') ); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_banners/controllers/client.php b/oss/joomla/trunk/administrator/components/com_banners/controllers/client.php index 70229d6d..07f302b3 100644 --- a/oss/joomla/trunk/administrator/components/com_banners/controllers/client.php +++ b/oss/joomla/trunk/administrator/components/com_banners/controllers/client.php @@ -1,213 +1,216 @@ -registerTask( 'add', 'edit' ); - $this->registerTask( 'apply', 'save' ); - } - - function display() - { - global $mainframe; - - $db =& JFactory::getDBO(); - $user =& JFactory::getUser(); - $context = 'com_banners.bannerclient.list.'; - $filter_order = $mainframe->getUserStateFromRequest( $context.'filter_order', 'filter_order', 'a.name', 'cmd' ); - $filter_order_Dir = $mainframe->getUserStateFromRequest( $context.'filter_order_Dir', 'filter_order_Dir', '', 'word' ); - $search = $mainframe->getUserStateFromRequest( $context.'search', 'search', '', 'string' ); - $search = JString::strtolower( $search ); - - $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); - $limitstart = $mainframe->getUserStateFromRequest( $context.'limitstart', 'limitstart', 0, 'int' ); - - $where = array(); - - if ($search) { - $where[] = 'LOWER(a.name) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); - } - - $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); - $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', a.cid'; - - // get the total number of records - $query = 'SELECT a.*, count(b.bid) AS nbanners, u.name AS editor' - . ' FROM #__bannerclient AS a' - . ' LEFT JOIN #__banner AS b ON a.cid = b.cid' - . ' LEFT JOIN #__users AS u ON u.id = a.checked_out' - . $where - . ' GROUP BY a.cid' - . $orderby - ; - - $db->setQuery( $query ); - $db->query(); - $total = $db->getNumRows(); - - jimport('joomla.html.pagination'); - $pageNav = new JPagination( $total, $limitstart, $limit ); - - $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); - $rows = $db->loadObjectList(); - - // table ordering - $lists['order_Dir'] = $filter_order_Dir; - $lists['order'] = $filter_order; - - // search filter - $lists['search']= $search; - - require_once(JPATH_COMPONENT.DS.'views'.DS.'client.php'); - BannersViewClients::clients( $rows, $pageNav, $lists ); - } - - /** - * Edit a banner client record - */ - function edit() - { - // Initialize variables - $db =& JFactory::getDBO(); - $user =& JFactory::getUser(); - - $userId = $user->get ( 'id' ); - - if ($this->_task == 'edit') { - $cid = JRequest::getVar('cid', array(0), 'method', 'array'); - } else { - $cid = array( 0 ); - } - - $row =& JTable::getInstance('bannerclient', 'Table'); - $row->load( (int) $cid[0] ); - - // fail if checked out not by 'me' - if ($row->isCheckedOut( $userId )) { - $this->setRedirect( 'index.php?option=com_banners&c=client' ); - return JError::raiseWarning( JText::sprintf( 'WARNEDITEDBYPERSON', $row->name ) ); - } - - if ($row->cid) { - // do stuff for existing record - $row->checkout( $userId ); - } else { - // do stuff for new record - $row->published = 0; - $row->approved = 0; - } - - require_once(JPATH_COMPONENT.DS.'views'.DS.'client.php'); - BannersViewClients::client( $row ); - } - - function save() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $this->setRedirect( 'index.php?option=com_banners&c=client' ); - - // Initialize variables - $db =& JFactory::getDBO(); - $table =& JTable::getInstance('bannerclient', 'Table'); - - if (!$table->bind( JRequest::get( 'post' ) )) { - return JError::raiseWarning( 500, $table->getError() ); - } - if (!$table->check()) { - return JError::raiseWarning( 500, $table->getError() ); - } - if (!$table->store()) { - return JError::raiseWarning( 500, $table->getError() ); - } - $table->checkin(); - - switch (JRequest::getCmd( 'task' )) - { - case 'apply': - $this->setRedirect( 'index.php?option=com_banners&c=client&task=edit&cid[]='. $table->cid ); - break; - } - - $this->setMessage( JText::_( 'Item Saved' ) ); - } - - function cancel() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $this->setRedirect( 'index.php?option=com_banners&c=client' ); - - // Initialize variables - $db =& JFactory::getDBO(); - $table =& JTable::getInstance('bannerclient', 'Table'); - $table->cid = JRequest::getVar( 'cid', 0, 'post', 'int' ); - $table->checkin(); - } - - function remove() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $this->setRedirect( 'index.php?option=com_banners&c=client' ); - - // Initialize variables - $db =& JFactory::getDBO(); - $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); - $table =& JTable::getInstance('bannerclient', 'Table'); - $n = count( $cid ); - - for ($i = 0; $i < $n; $i++) - { - $query = 'SELECT COUNT( bid )' - . ' FROM #__banner' - . ' WHERE cid = '. (int) $cid[$i] - ; - $db->setQuery($query); - $count = $db->loadResult(); - if ($count === null) { - return JError::raiseWarning( 500, $db->getErrorMsg() ); - } - else if ($count > 0) { - return JError::raiseWarning( 500, JText::_( 'WARNCANNOTDELCLIENTBANNER' ) ); - } - else { - if (!$table->delete( (int) $cid[$i] )) { - return JError::raiseWarning( 500, $table->getError() ); - } - } - } - - $this->setMessage( JText::sprintf( 'Items removed', $n ) ); - } +registerTask( 'add', 'edit' ); + $this->registerTask( 'apply', 'save' ); + } + + function display() + { + global $mainframe; + + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + $context = 'com_banners.bannerclient.list.'; + $filter_order = $mainframe->getUserStateFromRequest( $context.'filter_order', 'filter_order', 'a.name', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( $context.'filter_order_Dir', 'filter_order_Dir', '', 'word' ); + $search = $mainframe->getUserStateFromRequest( $context.'search', 'search', '', 'string' ); + if (strpos($search, '"') !== false) { + $search = str_replace(array('=', '<'), '', $search); + } + $search = JString::strtolower($search); + + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( $context.'limitstart', 'limitstart', 0, 'int' ); + + $where = array(); + + if ($search) { + $where[] = 'LOWER(a.name) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + + $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); + $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', a.cid'; + + // get the total number of records + $query = 'SELECT a.*, count(b.bid) AS nbanners, u.name AS editor' + . ' FROM #__bannerclient AS a' + . ' LEFT JOIN #__banner AS b ON a.cid = b.cid' + . ' LEFT JOIN #__users AS u ON u.id = a.checked_out' + . $where + . ' GROUP BY a.cid' + . $orderby + ; + + $db->setQuery( $query ); + $db->query(); + $total = $db->getNumRows(); + + jimport('joomla.html.pagination'); + $pageNav = new JPagination( $total, $limitstart, $limit ); + + $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); + $rows = $db->loadObjectList(); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search']= $search; + + require_once(JPATH_COMPONENT.DS.'views'.DS.'client.php'); + BannersViewClients::clients( $rows, $pageNav, $lists ); + } + + /** + * Edit a banner client record + */ + function edit() + { + // Initialize variables + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + + $userId = $user->get ( 'id' ); + + if ($this->_task == 'edit') { + $cid = JRequest::getVar('cid', array(0), 'method', 'array'); + } else { + $cid = array( 0 ); + } + + $row =& JTable::getInstance('bannerclient', 'Table'); + $row->load( (int) $cid[0] ); + + // fail if checked out not by 'me' + if ($row->isCheckedOut( $userId )) { + $this->setRedirect( 'index.php?option=com_banners&c=client' ); + return JError::raiseWarning( JText::sprintf( 'WARNEDITEDBYPERSON', $row->name ) ); + } + + if ($row->cid) { + // do stuff for existing record + $row->checkout( $userId ); + } else { + // do stuff for new record + $row->published = 0; + $row->approved = 0; + } + + require_once(JPATH_COMPONENT.DS.'views'.DS.'client.php'); + BannersViewClients::client( $row ); + } + + function save() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $this->setRedirect( 'index.php?option=com_banners&c=client' ); + + // Initialize variables + $db =& JFactory::getDBO(); + $table =& JTable::getInstance('bannerclient', 'Table'); + + if (!$table->bind( JRequest::get( 'post' ) )) { + return JError::raiseWarning( 500, $table->getError() ); + } + if (!$table->check()) { + return JError::raiseWarning( 500, $table->getError() ); + } + if (!$table->store()) { + return JError::raiseWarning( 500, $table->getError() ); + } + $table->checkin(); + + switch (JRequest::getCmd( 'task' )) + { + case 'apply': + $this->setRedirect( 'index.php?option=com_banners&c=client&task=edit&cid[]='. $table->cid ); + break; + } + + $this->setMessage( JText::_( 'Item Saved' ) ); + } + + function cancel() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $this->setRedirect( 'index.php?option=com_banners&c=client' ); + + // Initialize variables + $db =& JFactory::getDBO(); + $table =& JTable::getInstance('bannerclient', 'Table'); + $table->cid = JRequest::getVar( 'cid', 0, 'post', 'int' ); + $table->checkin(); + } + + function remove() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $this->setRedirect( 'index.php?option=com_banners&c=client' ); + + // Initialize variables + $db =& JFactory::getDBO(); + $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); + $table =& JTable::getInstance('bannerclient', 'Table'); + $n = count( $cid ); + + for ($i = 0; $i < $n; $i++) + { + $query = 'SELECT COUNT( bid )' + . ' FROM #__banner' + . ' WHERE cid = '. (int) $cid[$i] + ; + $db->setQuery($query); + $count = $db->loadResult(); + if ($count === null) { + return JError::raiseWarning( 500, $db->getErrorMsg() ); + } + else if ($count > 0) { + return JError::raiseWarning( 500, JText::_( 'WARNCANNOTDELCLIENTBANNER' ) ); + } + else { + if (!$table->delete( (int) $cid[$i] )) { + return JError::raiseWarning( 500, $table->getError() ); + } + } + } + + $this->setMessage( JText::sprintf( 'Items removed', $n ) ); + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_banners/elements/bannerclient.php b/oss/joomla/trunk/administrator/components/com_banners/elements/bannerclient.php index 8662a2de..5488733e 100644 --- a/oss/joomla/trunk/administrator/components/com_banners/elements/bannerclient.php +++ b/oss/joomla/trunk/administrator/components/com_banners/elements/bannerclient.php @@ -1,49 +1,49 @@ -setQuery($query); - $options = $db->loadObjectList(); - array_unshift($options, JHTML::_('select.option', '0', '- '.JText::_('Select Client').' -', 'cid', 'name')); - - return JHTML::_('select.genericlist', $options, ''.$control_name.'['.$name.']', 'class="inputbox"', 'cid', 'name', $value, $control_name.$name ); - } -} +setQuery($query); + $options = $db->loadObjectList(); + array_unshift($options, JHTML::_('select.option', '0', '- '.JText::_('Select Client').' -', 'cid', 'name')); + + return JHTML::_('select.genericlist', $options, ''.$control_name.'['.$name.']', 'class="inputbox"', 'cid', 'name', $value, $control_name.$name ); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_banners/helpers/banner.php b/oss/joomla/trunk/administrator/components/com_banners/helpers/banner.php index af5dfc5a..7b3ac3de 100644 --- a/oss/joomla/trunk/administrator/components/com_banners/helpers/banner.php +++ b/oss/joomla/trunk/administrator/components/com_banners/helpers/banner.php @@ -1,81 +1,81 @@ -get( 'tag_prefix' ); - - $instance = array(); - - if (!is_array( $keywords )) - { - $keywords = explode( ',', $keywords ); - } - - foreach ($keywords as $keyword) - { - $keyword = trim( $keyword ); - $regex = '#^' . $prefix . '#'; - if (preg_match( $regex, $keyword )) - { - $instance[] = $keyword; - } - } - } - return $instance; - } - - /** - * Checks if a URL is an image - * - * @param string - * @return URL - */ - function isImage( $url ) - { - $result = preg_match( '#(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$#i', $url ); - return $result; - } - - /** - * Checks if a URL is a Flash file - * - * @param string - * @return URL - */ - function isFlash( $url ) - { - $result = preg_match( '#\.swf$#i', $url ); - return $result; - } -} +get( 'tag_prefix' ); + + $instance = array(); + + if (!is_array( $keywords )) + { + $keywords = explode( ',', $keywords ); + } + + foreach ($keywords as $keyword) + { + $keyword = trim( $keyword ); + $regex = '#^' . $prefix . '#'; + if (preg_match( $regex, $keyword )) + { + $instance[] = $keyword; + } + } + } + return $instance; + } + + /** + * Checks if a URL is an image + * + * @param string + * @return URL + */ + function isImage( $url ) + { + $result = preg_match( '#(\.bmp|\.gif|\.jpg|\.jpeg|\.png)$#i', $url ); + return $result; + } + + /** + * Checks if a URL is a Flash file + * + * @param string + * @return URL + */ + function isFlash( $url ) + { + $result = preg_match( '#\.swf$#i', $url ); + return $result; + } +} ?> \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_banners/tables/banner.php b/oss/joomla/trunk/administrator/components/com_banners/tables/banner.php index c9e90eec..8b54db20 100644 --- a/oss/joomla/trunk/administrator/components/com_banners/tables/banner.php +++ b/oss/joomla/trunk/administrator/components/com_banners/tables/banner.php @@ -1,131 +1,131 @@ -set( 'date', $now->toMySQL() ); - } - - function clicks() - { - $query = 'UPDATE #__banner' - . ' SET clicks = ( clicks + 1 )' - . ' WHERE bid = ' . (int) $this->bid - ; - $this->_db->setQuery( $query ); - $this->_db->query(); - } - - /** - * Overloaded check function - * - * @access public - * @return boolean - * @see JTable::check - * @since 1.5 - */ - function check() - { - // check for valid client id - if (is_null($this->cid) || $this->cid == 0) { - $this->setError(JText::_( 'BNR_CLIENT' )); - return false; - } - - // check for valid name - if(trim($this->name) == '') { - $this->setError(JText::_( 'BNR_NAME' )); - return false; - } - - if(empty($this->alias)) { - $this->alias = $this->name; - } - $this->alias = JFilterOutput::stringURLSafe($this->alias); - - /*if(trim($this->imageurl) == '') { - $this->setError(JText::_( 'BNR_IMAGE' )); - return false; - } - if(trim($this->clickurl) == '' && trim($this->custombannercode) == '') { - $this->setError(JText::_( 'BNR_URL' )); - return false; - }*/ - - return true; - } -} -?> +set( 'date', $now->toMySQL() ); + } + + function clicks() + { + $query = 'UPDATE #__banner' + . ' SET clicks = ( clicks + 1 )' + . ' WHERE bid = ' . (int) $this->bid + ; + $this->_db->setQuery( $query ); + $this->_db->query(); + } + + /** + * Overloaded check function + * + * @access public + * @return boolean + * @see JTable::check + * @since 1.5 + */ + function check() + { + // check for valid client id + if (is_null($this->cid) || $this->cid == 0) { + $this->setError(JText::_( 'BNR_CLIENT' )); + return false; + } + + // check for valid name + if(trim($this->name) == '') { + $this->setError(JText::_( 'BNR_NAME' )); + return false; + } + + if(empty($this->alias)) { + $this->alias = $this->name; + } + $this->alias = JFilterOutput::stringURLSafe($this->alias); + + /*if(trim($this->imageurl) == '') { + $this->setError(JText::_( 'BNR_IMAGE' )); + return false; + } + if(trim($this->clickurl) == '' && trim($this->custombannercode) == '') { + $this->setError(JText::_( 'BNR_URL' )); + return false; + }*/ + + return true; + } +} +?> diff --git a/oss/joomla/trunk/administrator/components/com_banners/tables/bannerclient.php b/oss/joomla/trunk/administrator/components/com_banners/tables/bannerclient.php index 3c28a11e..033471bd 100644 --- a/oss/joomla/trunk/administrator/components/com_banners/tables/bannerclient.php +++ b/oss/joomla/trunk/administrator/components/com_banners/tables/bannerclient.php @@ -1,68 +1,68 @@ -name == '')) { - $this->setError(JText::_( 'BNR_CLIENT_NAME' )); - return false; - } - - // check for valid client contact - if (trim($this->contact == '')) { - $this->setError(JText::_( 'BNR_CONTACT' )); - return false; - } - - // check for valid client email - jimport( 'joomla.mail.helper' ); - if (!JMailHelper::isEmailAddress( $this->email )) { - $this->setError(JText::_( 'BNR_VALID_EMAIL' )); - return false; - } - - return true; - } -} +name == '')) { + $this->setError(JText::_( 'BNR_CLIENT_NAME' )); + return false; + } + + // check for valid client contact + if (trim($this->contact == '')) { + $this->setError(JText::_( 'BNR_CONTACT' )); + return false; + } + + // check for valid client email + jimport( 'joomla.mail.helper' ); + if (!JMailHelper::isEmailAddress( $this->email )) { + $this->setError(JText::_( 'BNR_VALID_EMAIL' )); + return false; + } + + return true; + } +} diff --git a/oss/joomla/trunk/administrator/components/com_banners/views/banner.php b/oss/joomla/trunk/administrator/components/com_banners/views/banner.php index 04dcf050..00d7d2ca 100644 --- a/oss/joomla/trunk/administrator/components/com_banners/views/banner.php +++ b/oss/joomla/trunk/administrator/components/com_banners/views/banner.php @@ -1,473 +1,473 @@ - -
- - - - - -
- : - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - id = $row->bid; - $link = JRoute::_( 'index.php?option=com_banners&task=edit&cid[]='. $row->id ); - - if( $row->imptotal <= 0 ) { - $row->imptotal = JText::_('unlimited'); - } - - if ( $row->impmade != 0 ) { - $percentClicks = 100 * $row->clicks/$row->impmade; - } else { - $percentClicks = 0; - } - - $row->published = $row->showBanner; - $published = JHTML::_('grid.published', $row, $i ); - $checked = JHTML::_('grid.checkedout', $row, $i ); - ?> - "> - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- getListFooter(); ?> -
- getRowOffset($i); ?> - - - - - get ('id'), $row->checked_out ) ) { - echo $row->name; - } else { - ?> - - - name; ?> - - - - client_name;?> - - category_name;?> - - - - - class="text_area" style="text-align: center" /> - - sticky ? JText::_( 'Yes' ) : JText::_( 'No' );?> - - impmade.' '.JText::_('of').' '.$row->imptotal?> - - clicks;?> - - - - tags; ?> - - id; ?> -
- - - - - - - - -
- [ '. JText::_( 'New' ) .' ]' : JText::_( 'Banner' ) . ': [ '. JText::_( 'Edit' ) .' ]', 'generic.png' ); - JToolBarHelper::save( 'save' ); - JToolBarHelper::apply('apply'); - JToolBarHelper::cancel( 'cancel' ); - JToolBarHelper::help( 'screen.banners.edit' ); - } - - function banner( &$row, &$lists ) - { - BannersViewBanner::setBannerToolbar(); - JRequest::setVar( 'hidemainmenu', 1 ); - JFilterOutput::objectHTMLSafe( $row, ENT_QUOTES, 'custombannercode' ); - ?> - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - imptotal == 0) { - $unlimited = 'checked="checked"'; - $row->imptotal = ''; - } - ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
- - - -
- : - - -
- : - - -
- - - -
- - - -
- - - -
- - - -      - - /> -
- - - -
- : - - clicks;?> -      - -
- - - -
- - - -
-
- - - -
- - - -
- - - -
- : - - imageurl)) { - ?> - - - - imageurl)) { - ?> - - - - -
- - - -
-
-
-
- - - - - - - - -
- +
+ + + + + +
+ : + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + id = $row->bid; + $link = JRoute::_( 'index.php?option=com_banners&task=edit&cid[]='. $row->id ); + + if( $row->imptotal <= 0 ) { + $row->imptotal = JText::_('unlimited'); + } + + if ( $row->impmade != 0 ) { + $percentClicks = 100 * $row->clicks/$row->impmade; + } else { + $percentClicks = 0; + } + + $row->published = $row->showBanner; + $published = JHTML::_('grid.published', $row, $i ); + $checked = JHTML::_('grid.checkedout', $row, $i ); + ?> + "> + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
+ getListFooter(); ?> +
+ getRowOffset($i); ?> + + + + + get ('id'), $row->checked_out ) ) { + echo $row->name; + } else { + ?> + + + name; ?> + + + + client_name;?> + + category_name;?> + + + + + class="text_area" style="text-align: center" /> + + sticky ? JText::_( 'Yes' ) : JText::_( 'No' );?> + + impmade.' '.JText::_('of').' '.$row->imptotal?> + + clicks;?> - + + + tags; ?> + + id; ?> +
+ + + + + + + + +
+ [ '. JText::_( 'New' ) .' ]' : JText::_( 'Banner' ) . ': [ '. JText::_( 'Edit' ) .' ]', 'generic.png' ); + JToolBarHelper::save( 'save' ); + JToolBarHelper::apply('apply'); + JToolBarHelper::cancel( 'cancel' ); + JToolBarHelper::help( 'screen.banners.edit' ); + } + + function banner( &$row, &$lists ) + { + BannersViewBanner::setBannerToolbar(); + JRequest::setVar( 'hidemainmenu', 1 ); + JFilterOutput::objectHTMLSafe( $row, ENT_QUOTES, 'custombannercode' ); + ?> + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + imptotal == 0) { + $unlimited = 'checked="checked"'; + $row->imptotal = ''; + } + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ : + + +
+ : + + +
+ + + +
+ + + +
+ + + +
+ + + +      + + /> +
+ + + +
+ : + + clicks;?> +      + +
+ + + +
+ + + +
+
+ + + +
+ + + +
+ + + +
+ : + + imageurl)) { + ?> + + + + imageurl)) { + ?> + + + + +
+ + + +
+
+
+
+ + + + + + + + +
+ -
- - - - - - -
- : - - - - -
- - - - - - - - - - - - - - - - - - - id = $row->cid; - $link = JRoute::_( 'index.php?option=com_banners&c=client&task=edit&cid[]='. $row->id ); - - $checked = JHTML::_('grid.checkedout', $row, $i ); - ?> - "> - - - - - - - - - -
- - - - - - - - - - - -
- getListFooter(); ?> -
- getRowOffset( $i ); ?> - - - - get ('id'), $row->checked_out ) ) { - echo $row->name; - } else { - ?> - - - name; ?> - - - - contact; ?> - - nbanners;?> - - cid; ?> -
- - - - - - - - -
- [ '. JText::_( 'New' ) .' ]' : JText::_( 'Banner Client' ) . ': [ '. JText::_( 'Edit' ) .' ]', 'generic.png' ); - JToolBarHelper::save( 'save' ); - JToolBarHelper::apply('apply'); - JToolBarHelper::cancel( 'cancel' ); - JToolBarHelper::help( 'screen.banners.client.edit' ); - } - - function client( &$row ) - { - BannersViewClients::setClientToolbar(); - JRequest::setVar( 'hidemainmenu', 1 ); - JFilterOutput::objectHTMLSafe( $row, ENT_QUOTES, 'extrainfo' ); - ?> - - -
- -
-
- - - - - - - - - - - - - - - -
- - - -
- - - -
- - - -
-
-
- -
-
- - - - - - -
- -
-
-
-
- - - - - - - -
- +
+ + + + + + +
+ : + + + + +
+ + + + + + + + + + + + + + + + + + + id = $row->cid; + $link = JRoute::_( 'index.php?option=com_banners&c=client&task=edit&cid[]='. $row->id ); + + $checked = JHTML::_('grid.checkedout', $row, $i ); + ?> + "> + + + + + + + + + +
+ + + + + + + + + + + +
+ getListFooter(); ?> +
+ getRowOffset( $i ); ?> + + + + get ('id'), $row->checked_out ) ) { + echo $row->name; + } else { + ?> + + + name; ?> + + + + contact; ?> + + nbanners;?> + + cid; ?> +
+ + + + + + + + +
+ [ '. JText::_( 'New' ) .' ]' : JText::_( 'Banner Client' ) . ': [ '. JText::_( 'Edit' ) .' ]', 'generic.png' ); + JToolBarHelper::save( 'save' ); + JToolBarHelper::apply('apply'); + JToolBarHelper::cancel( 'cancel' ); + JToolBarHelper::help( 'screen.banners.client.edit' ); + } + + function client( &$row ) + { + BannersViewClients::setClientToolbar(); + JRequest::setVar( 'hidemainmenu', 1 ); + JFilterOutput::objectHTMLSafe( $row, ENT_QUOTES, 'extrainfo' ); + ?> + + +
+ +
+
+ + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + +
+
+
+ +
+
+ + + + + + +
+ +
+
+
+
+ + + + + + + +
+ -
- - - - - - - - - - - - - - - - - - " > - - - - - - - - -
- - - - - - - - - -
- getListFooter(); ?> -
- getRowOffset( $i ); ?> - - - - - group; ?> - - - count; ?> - - size ?> -
- - - - - - -
- -
- - - - - - - - - -
- -
-
- -
- - - -
- -
- - - - - - - - - -
- -
- -
- - - -
- +
+ + + + + + + + + + + + + + + + + + " > + + + + + + + + +
+ + + + + + + + + +
+ getListFooter(); ?> +
+ getRowOffset( $i ); ?> + + + + + group; ?> + + + count; ?> + + size ?> +
+ + + + + + +
+ +
+ + + + + + + + + +
+ +
+
+ +
+ + + +
+ +
+ + + + + + + + + +
+ +
+ +
+ + + +
+ authorize( 'com_cache', 'manage' )) { - $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); -} - -// Load the html output class and the model class -require_once (JApplicationHelper::getPath('admin_html')); -require_once (JApplicationHelper::getPath('class')); - -$cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); - -/* - * This is our main control structure for the component - * - * Each view is determined by the $task variable - */ -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; -} - -/** - * Static class to hold controller functions for the Cache component - * - * @static - * @package Joomla - * @subpackage Weblinks - * @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(); - } -} +authorize( 'com_cache', 'manage' )) { + $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); +} + +// Load the html output class and the model class +require_once (JApplicationHelper::getPath('admin_html')); +require_once (JApplicationHelper::getPath('class')); + +$cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); + +/* + * This is our main control structure for the component + * + * Each view is determined by the $task variable + */ +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; +} + +/** + * Static class to hold controller functions for the Cache component + * + * @static + * @package Joomla + * @subpackage Weblinks + * @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(); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_cache/cache.class.php b/oss/joomla/trunk/administrator/components/com_cache/cache.class.php index 324edd3c..564dd9da 100644 --- a/oss/joomla/trunk/administrator/components/com_cache/cache.class.php +++ b/oss/joomla/trunk/administrator/components/com_cache/cache.class.php @@ -1,161 +1,161 @@ -_path = $path; - $this->_parse(); - } - - /** - * Parse $path for cache file groups. Any files identifided as cache are logged - * in a group and stored in $this->items. - * - * @access private - * @param String $path - */ - function _parse() - { - jimport('joomla.filesystem.folder'); - jimport('joomla.filesystem.file'); - $folders = JFolder::folders($this->_path); - - foreach ($folders as $folder) - { - $files = array(); - $files = JFolder::files($this->_path.DS.$folder); - $this->_items[$folder] = new CacheItem( $folder ); - - foreach ($files as $file) - { - $this->_items[$folder]->updateSize( filesize( $this->_path.DS.$folder.DS.$file )/ 1024 ); - } - } - } - - /** - * Get the number of current Cache Groups - * - * @access public - * @return int - */ - function getGroupCount() - { - return count($this->_items); - } - - /** - * Retrun an Array containing a sub set of the total - * number of Cache Groups as defined by the params. - * - * @access public - * @param Int $start - * @param Int $limit - * @return Array - */ - function getRows( $start, $limit ) - { - $i = 0; - $rows = array(); - if (!is_array($this->_items)) { - return null; - } - - foreach ($this->_items as $item) - { - if ( (($i >= $start) && ($i < $start+$limit)) || ($limit == 0) ) { - $rows[] = $item; - } - $i++; - } - return $rows; - } - - /** - * Clean out a cache group as named by param. - * If no param is passed clean all cache groups. - * - * @param String $group - */ - function cleanCache( $group='' ) - { - $cache =& JFactory::getCache('', 'callback', 'file'); - $cache->clean( $group ); - } - - function cleanCacheList( $array ) - { - foreach ($array as $group) { - $this->cleanCache( $group ); - } - } -} - - /** - * This Class is used by CacheData to store group cache data. - * - * @package Joomla - * @subpackage Cache - * @since 1.5 - */ -class CacheItem -{ - var $group = ""; - var $size = 0; - var $count = 0; - - function CacheItem ( $group ) - { - $this->group = $group; - } - - function updateSize( $size ) - { - $this->size = number_format( $this->size + $size, 2 ); - $this->count++; - } +_path = $path; + $this->_parse(); + } + + /** + * Parse $path for cache file groups. Any files identifided as cache are logged + * in a group and stored in $this->items. + * + * @access private + * @param String $path + */ + function _parse() + { + jimport('joomla.filesystem.folder'); + jimport('joomla.filesystem.file'); + $folders = JFolder::folders($this->_path); + + foreach ($folders as $folder) + { + $files = array(); + $files = JFolder::files($this->_path.DS.$folder); + $this->_items[$folder] = new CacheItem( $folder ); + + foreach ($files as $file) + { + $this->_items[$folder]->updateSize( filesize( $this->_path.DS.$folder.DS.$file )/ 1024 ); + } + } + } + + /** + * Get the number of current Cache Groups + * + * @access public + * @return int + */ + function getGroupCount() + { + return count($this->_items); + } + + /** + * Retrun an Array containing a sub set of the total + * number of Cache Groups as defined by the params. + * + * @access public + * @param Int $start + * @param Int $limit + * @return Array + */ + function getRows( $start, $limit ) + { + $i = 0; + $rows = array(); + if (!is_array($this->_items)) { + return null; + } + + foreach ($this->_items as $item) + { + if ( (($i >= $start) && ($i < $start+$limit)) || ($limit == 0) ) { + $rows[] = $item; + } + $i++; + } + return $rows; + } + + /** + * Clean out a cache group as named by param. + * If no param is passed clean all cache groups. + * + * @param String $group + */ + function cleanCache( $group='' ) + { + $cache =& JFactory::getCache('', 'callback', 'file'); + $cache->clean( $group ); + } + + function cleanCacheList( $array ) + { + foreach ($array as $group) { + $this->cleanCache( $group ); + } + } +} + + /** + * This Class is used by CacheData to store group cache data. + * + * @package Joomla + * @subpackage Cache + * @since 1.5 + */ +class CacheItem +{ + var $group = ""; + var $size = 0; + var $count = 0; + + function CacheItem ( $group ) + { + $this->group = $group; + } + + function updateSize( $size ) + { + $this->size = number_format( $this->size + $size, 2 ); + $this->count++; + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_cache/cache.xml b/oss/joomla/trunk/administrator/components/com_cache/cache.xml index d40334be..86be6563 100644 --- a/oss/joomla/trunk/administrator/components/com_cache/cache.xml +++ b/oss/joomla/trunk/administrator/components/com_cache/cache.xml @@ -1,12 +1,12 @@ - - - Cache Manager - Joomla! Project - 2006 - Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - admin@joomla.org - www.joomla.org - 1.5.0 - Cache Manager - + + + Cache Manager + Joomla! Project + 2006 + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + Cache Manager + diff --git a/oss/joomla/trunk/administrator/components/com_cache/toolbar.cache.html.php b/oss/joomla/trunk/administrator/components/com_cache/toolbar.cache.html.php index 44925b8e..d45988ea 100644 --- a/oss/joomla/trunk/administrator/components/com_cache/toolbar.cache.html.php +++ b/oss/joomla/trunk/administrator/components/com_cache/toolbar.cache.html.php @@ -1,40 +1,40 @@ - -
- - - - - - -
- : - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - sect_link = JRoute::_( 'index.php?option=com_sections&task=edit&cid[]='. $row->section ); - - $link = 'index.php?option=com_categories§ion='. $section .'&task=edit&cid[]='. $row->id .'&type='.$type; - - $access = JHTML::_('grid.access', $row, $i ); - $checked = JHTML::_('grid.checkedout', $row, $i ); - $published = JHTML::_('grid.published', $row, $i ); - ?> - "> - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - -
- getListFooter(); ?> -
- getRowOffset( $i ); ?> - - - - - get ('id'), $row->checked_out ) ) { - echo $row->title; - } else { - ?> - - title; ?> - - - - - orderUpIcon( $i, ($row->section == @$rows[$i-1]->section), 'orderup', 'Move Up', $ordering ); ?> - orderDownIcon( $i, $n, ($row->section == @$rows[$i+1]->section), 'orderdown', 'Move Down', $ordering ); ?> - - class="text_area" style="text-align: center" /> - - - - - section_name; ?> - - active; ?> - - trash; ?> - - id; ?> -
- - - - - - - - - - - -
- image == '') { - $row->image = 'blank.png'; - } - - if ( $redirect == 'content' ) { - $component = 'Content'; - } else { - $component = ucfirst( substr( $redirect, 4 ) ); - if ( $redirect == 'com_contact_details' ) { - $component = 'Contact'; - } - } - - JFilterOutput::objectHTMLSafe( $row, ENT_QUOTES, 'description' ); - $cparams = JComponentHelper::getParams ('com_media'); - ?> - - -
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
- - - -
- : - - -
- - - -
- - - -
- - - -
- - - -
- - - -
  - -
-
- -
- - - - - - -
- display( 'description', htmlspecialchars($row->description, ENT_QUOTES), '550', '300', '60', '20', array('pagebreak', 'readmore') ) ; - ?> -
-
-
-
- - - - - - - - -
- - - -
- -
- - - - - - - . - -
- : -
- -

-
- : -
- "; - foreach ( $items as $item ) { - echo "
  • ". $item->title ."
  • "; - } - echo ""; - ?> -
    - : -
    - "; - foreach ( $contents as $content ) { - echo "
  • ". $content->title ."
  • "; - } - echo ""; - ?> -
    - -
    - -
    - . -
    -

    - - - - - - - "; - } - ?> - -
    - - - -
    - -
    - - - - - - - . - -
    - : -
    - -

    -
    - : -
    - "; - foreach ( $items as $item ) { - echo "
  • ". $item->title ."
  • "; - } - echo ""; - ?> -
    - : -
    - "; - foreach ( $contents as $content ) { - echo "
  • ". $content->title ."
  • "; - echo "\n id\" />"; - } - echo ""; - ?> -
    - -
    - -
    - -
    - . -
    -

    - - - - - - - "; - } - ?> - -
    - +
    + + + + + + +
    + : + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + sect_link = JRoute::_( 'index.php?option=com_sections&task=edit&cid[]='. $row->section ); + + $link = 'index.php?option=com_categories§ion='. $section .'&task=edit&cid[]='. $row->id .'&type='.$type; + + $access = JHTML::_('grid.access', $row, $i ); + $checked = JHTML::_('grid.checkedout', $row, $i ); + $published = JHTML::_('grid.published', $row, $i ); + ?> + "> + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + +
    + getListFooter(); ?> +
    + getRowOffset( $i ); ?> + + + + + get ('id'), $row->checked_out ) ) { + echo $row->title; + } else { + ?> + + title; ?> + + + + + orderUpIcon( $i, ($row->section == @$rows[$i-1]->section), 'orderup', 'Move Up', $ordering ); ?> + orderDownIcon( $i, $n, ($row->section == @$rows[$i+1]->section), 'orderdown', 'Move Down', $ordering ); ?> + + class="text_area" style="text-align: center" /> + + + + + section_name; ?> + + active; ?> + + trash; ?> + + id; ?> +
    + + + + + + + + + + + +
    + image == '') { + $row->image = 'blank.png'; + } + + if ( $redirect == 'content' ) { + $component = 'Content'; + } else { + $component = ucfirst( substr( $redirect, 4 ) ); + if ( $redirect == 'com_contact_details' ) { + $component = 'Contact'; + } + } + + JFilterOutput::objectHTMLSafe( $row, ENT_QUOTES, 'description' ); + $cparams = JComponentHelper::getParams ('com_media'); + ?> + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + +
    + + + +
    + : + + +
    + + + +
    + + + +
    + + + +
    + + + +
    + + + +
      + +
    +
    + +
    + + + + + + +
    + display( 'description', htmlspecialchars($row->description, ENT_QUOTES), '550', '300', '60', '20', array('pagebreak', 'readmore') ) ; + ?> +
    +
    +
    +
    + + + + + + + + +
    + + + +
    + +
    + + + + + + + . + +
    + : +
    + +

    +
    + : +
    + "; + foreach ( $items as $item ) { + echo "
  • ". $item->title ."
  • "; + } + echo ""; + ?> +
    + : +
    + "; + foreach ( $contents as $content ) { + echo "
  • ". $content->title ."
  • "; + } + echo ""; + ?> +
    + +
    + +
    + . +
    +

    + + + + + + + "; + } + ?> + +
    + + + +
    + +
    + + + + + + + . + +
    + : +
    + +

    +
    + : +
    + "; + foreach ( $items as $item ) { + echo "
  • ". $item->title ."
  • "; + } + echo ""; + ?> +
    + : +
    + "; + foreach ( $contents as $content ) { + echo "
  • ". $content->title ."
  • "; + echo "\n id\" />"; + } + echo ""; + ?> +
    + +
    + +
    + +
    + . +
    +

    + + + + + + + "; + } + ?> + +
    + getUserStateFromRequest( $option.'.filter_order', 'filter_order', 'c.ordering', 'cmd' ); - $filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'.filter_order_Dir', 'filter_order_Dir', '', 'word' ); - $filter_state = $mainframe->getUserStateFromRequest( $option.'.'.$section.'.filter_state', 'filter_state', '', 'word' ); - $sectionid = $mainframe->getUserStateFromRequest( $option.'.'.$section.'.sectionid', 'sectionid', 0, 'int' ); - $search = $mainframe->getUserStateFromRequest( $option.'.search', 'search', '', 'string' ); - $search = JString::strtolower( $search ); - - $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); - $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); - - $section_name = ''; - $content_add = ''; - $content_join = ''; - $order = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', c.ordering'; - if (intval( $section ) > 0) { - $table = 'content'; - - $query = 'SELECT title' - . ' FROM #__sections' - . ' WHERE id = '.(int) $section; - $db->setQuery( $query ); - $section_name = $db->loadResult(); - $section_name = JText::sprintf( 'Content:', JText::_( $section_name ) ); - $where = ' WHERE c.section = '.$db->Quote($section); - $type = 'content'; - } else if (strpos( $section, 'com_' ) === 0) { - $table = substr( $section, 4 ); - - $query = 'SELECT name' - . ' FROM #__components' - . ' WHERE link = '.$db->Quote('option='.$section); - ; - $db->setQuery( $query ); - $section_name = $db->loadResult(); - $where = ' WHERE c.section = '.$db->Quote($section); - $type = 'other'; - // special handling for contact component - if ( $section == 'com_contact_details' ) { - $section_name = JText::_( 'Contact' ); - } - $section_name = JText::sprintf( 'Component:', $section_name ); - } else { - $table = $section; - $where = ' WHERE c.section = '.$db->Quote($section); - $type = 'other'; - } - - // get the total number of records - $query = 'SELECT COUNT(*)' - . ' FROM #__categories' - ; - if ($section == 'com_content') - { - if($sectionid > 0) - { - $query .= ' WHERE section = '.(int) $sectionid; - } else { - $query .= ' WHERE section > 0'; - } - } else { - $query .= ' WHERE section = '.$db->quote($section); - } - if ( $filter_state ) { - if ( $filter_state == 'P' ) { - $query .= ' AND published = 1'; - } else if ($filter_state == 'U' ) { - $query .= ' AND published = 0'; - } - } - $db->setQuery( $query ); - $total = $db->loadResult(); - - // allows for viweing of all content categories - if ( $section == 'com_content' ) { - $table = 'content'; - $content_add = ' , z.title AS section_name'; - $content_join = ' LEFT JOIN #__sections AS z ON z.id = c.section'; - $where = ' WHERE c.section NOT LIKE "%com_%"'; - if ($filter_order == 'c.ordering'){ - $order = ' ORDER BY z.title, c.ordering '. $filter_order_Dir; - } else { - $order = ' ORDER BY '.$filter_order.' '. $filter_order_Dir.', z.title, c.ordering'; - } - - $section_name = JText::_( 'All Content:' ); - - $type = 'content'; - } - - // used by filter - if ( $sectionid > 0 ) { - $filter = ' AND c.section = '.$db->Quote($sectionid); - } else { - $filter = ''; - } - if ( $filter_state ) { - if ( $filter_state == 'P' ) { - $filter .= ' AND c.published = 1'; - } else if ($filter_state == 'U' ) { - $filter .= ' AND c.published = 0'; - } - } - if ($search) { - $filter .= ' AND LOWER(c.title) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); - } - - jimport('joomla.html.pagination'); - $pageNav = new JPagination( $total, $limitstart, $limit ); - - $tablesAllowed = $db->getTableList(); - if (!in_array($db->getPrefix().$table, $tablesAllowed)) { - $table = 'content'; - } - - $query = 'SELECT c.*, c.checked_out as checked_out_contact_category, g.name AS groupname, u.name AS editor, COUNT( DISTINCT s2.checked_out ) AS checked_out_count' - . $content_add - . ' FROM #__categories AS c' - . ' LEFT JOIN #__users AS u ON u.id = c.checked_out' - . ' LEFT JOIN #__groups AS g ON g.id = c.access' - . ' LEFT JOIN #__'.$table.' AS s2 ON s2.catid = c.id AND s2.checked_out > 0' - . $content_join - . $where - . $filter - . ' AND c.published != -2' - . ' GROUP BY c.id' - . $order - ; - $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); - $rows = $db->loadObjectList(); - if ($db->getErrorNum()) { - echo $db->stderr(); - return; - } - - $count = count( $rows ); - // number of Active Items - for ( $i = 0; $i < $count; $i++ ) { - $query = 'SELECT COUNT( a.id )' - . ' FROM #__content AS a' - . ' WHERE a.catid = '. (int) $rows[$i]->id - . ' AND a.state <> -2' - ; - $db->setQuery( $query ); - $active = $db->loadResult(); - $rows[$i]->active = $active; - } - // number of Trashed Items - for ( $i = 0; $i < $count; $i++ ) { - $query = 'SELECT COUNT( a.id )' - . ' FROM #__content AS a' - . ' WHERE a.catid = '. (int) $rows[$i]->id - . ' AND a.state = -2' - ; - $db->setQuery( $query ); - $trash = $db->loadResult(); - $rows[$i]->trash = $trash; - } - - // get list of sections for dropdown filter - $javascript = 'onchange="document.adminForm.submit();"'; - $lists['sectionid'] = JHTML::_('list.section', 'sectionid', $sectionid, $javascript, 'ordering', false ); - - // state filter - $lists['state'] = JHTML::_('grid.state', $filter_state ); - - // table ordering - $lists['order_Dir'] = $filter_order_Dir; - $lists['order'] = $filter_order; - - // search filter - $lists['search']= $search; - - categories_html::show( $rows, $section, $section_name, $pageNav, $lists, $type ); -} - -/** -* Compiles information to add or edit a category -* @param string The name of the category section -* @param integer The unique id of the category to edit (0 if new) -* @param string The name of the current user -*/ -function editCategory($edit ) -{ - global $mainframe; - - // Initialize variables - $db =& JFactory::getDBO(); - $user =& JFactory::getUser(); - $uid = $user->get('id'); - - $type = JRequest::getCmd( 'type' ); - $redirect = JRequest::getCmd( 'section', 'com_content' ); - $section = JRequest::getCmd( 'section', 'com_content' ); - $cid = JRequest::getVar( 'cid', array(0), '', 'array' ); - - JArrayHelper::toInteger($cid, array(0)); - - // check for existance of any sections - $query = 'SELECT COUNT( id )' - . ' FROM #__sections' - . ' WHERE scope = "content"' - ; - $db->setQuery( $query ); - $sections = $db->loadResult(); - if (!$sections && $type != 'other' - && $section != 'com_weblinks' - && $section != 'com_newsfeeds' - && $section != 'com_contact_details' - && $section != 'com_banner') { - $mainframe->redirect( 'index.php?option=com_categories§ion='. $section, JText::_( 'WARNSECTION', true ) ); - } - - $row =& JTable::getInstance('category'); - // load the row from the db table - if ($edit) - $row->load( $cid[0] ); - - // fail if checked out not by 'me' - if ( JTable::isCheckedOut($user->get ('id'), $row->checked_out )) { - $msg = JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The category' ), $row->title ); - $mainframe->redirect( 'index.php?option=com_categories§ion='. $row->section, $msg ); - } - - if ( $edit ) { - $row->checkout( $user->get('id')); - } else { - $row->published = 1; - } - - - // make order list - $order = array(); - $query = 'SELECT COUNT(*)' - . ' FROM #__categories' - . ' WHERE section = '.$db->Quote($row->section) - ; - $db->setQuery( $query ); - $max = intval( $db->loadResult() ) + 1; - - for ($i=1; $i < $max; $i++) { - $order[] = JHTML::_('select.option', $i ); - } - - // build the html select list for sections - if ( $section == 'com_content' ) { - - if (!$row->section && JRequest::getInt('sectionid')) { - $row->section = JRequest::getInt('sectionid'); - } - - $query = 'SELECT s.id AS value, s.title AS text' - . ' FROM #__sections AS s' - . ' ORDER BY s.ordering' - ; - $db->setQuery( $query ); - $sections = $db->loadObjectList(); - $lists['section'] = JHTML::_('select.genericlist', $sections, 'section', 'class="inputbox" size="1"', 'value', 'text', $row->section ); - } else { - if ( $type == 'other' ) { - $section_name = JText::_( 'N/A' ); - } else { - $temp =& JTable::getInstance('section'); - $temp->load( $row->section ); - $section_name = $temp->name; - } - if(!$section_name) $section_name = JText::_( 'N/A' ); - $row->section = $section; - $lists['section'] = ''. $section_name; - } - - // build the html select list for ordering - $query = 'SELECT ordering AS value, title AS text' - . ' FROM #__categories' - . ' WHERE section = '.$db->Quote($row->section) - . ' ORDER BY ordering' - ; - if ($edit) { - $lists['ordering'] = JHTML::_('list.specificordering', $row, $cid[0], $query ); - } - else { - $lists['ordering'] = JHTML::_('list.specificordering', $row, '', $query ); - } - // build the select list for the image positions - $active = ( $row->image_position ? $row->image_position : 'left' ); - $lists['image_position'] = JHTML::_('list.positions', 'image_position', $active, NULL, 0, 0 ); - // Imagelist - $lists['image'] = JHTML::_('list.images', 'image', $row->image ); - // build the html select list for the group access - $lists['access'] = JHTML::_('list.accesslevel', $row ); - // build the html radio buttons for published - $published = ($row->id) ? $row->published : 1; - $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $published ); - - categories_html::edit( $row, $lists, $redirect ); -} - -/** -* Saves the catefory after an edit form submit -* @param string The name of the category section -*/ -function saveCategory() -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db =& JFactory::getDBO(); - $menu = JRequest::getCmd( 'menu', 'mainmenu', 'post' ); - $menuid = JRequest::getVar( 'menuid', 0, 'post', 'int' ); - $redirect = JRequest::getCmd( 'redirect', '', 'post' ); - $oldtitle = JRequest::getString( 'oldtitle', '', 'post' ); - $post = JRequest::get( 'post' ); - - // fix up special html fields - $post['description'] = JRequest::getVar( 'description', '', 'post', 'string', JREQUEST_ALLOWRAW ); - - $row =& JTable::getInstance('category'); - if (!$row->bind( $post )) { - JError::raiseError(500, $row->getError() ); - } - if (!$row->check()) { - JError::raiseError(500, $row->getError() ); - } - // if new item order last in appropriate group - if (!$row->id) { - $where = "section = " . $db->Quote($row->section); - $row->ordering = $row->getNextOrder( $where ); - } - - if (!$row->store()) { - JError::raiseError(500, $row->getError() ); - } - $row->checkin(); - - if ($row->section > 0) { - $query = 'UPDATE #__content' - .' SET sectionid = '.$row->section - .' WHERE catid = '.$row->id - ; - $db->setQuery( $query ); - $db->query(); - } - - if ( $oldtitle ) { - if ($oldtitle != $row->title) { - $query = 'UPDATE #__menu' - . ' SET name = '.$db->Quote($row->title) - . ' WHERE name = '.$db->Quote($oldtitle) - . ' AND type = "content_category"' - ; - $db->setQuery( $query ); - $db->query(); - } - } - - // Update Section Count - if ($row->section != 'com_contact_details' && - $row->section != 'com_newsfeeds' && - $row->section != 'com_weblinks') { - $query = 'UPDATE #__sections SET count=count+1' - . ' WHERE id = '.$db->Quote($row->section) - ; - $db->setQuery( $query ); - } - - if (!$db->query()) { - JError::raiseError(500, $db->getErrorMsg() ); - } - - switch ( JRequest::getCmd('task') ) - { - case 'go2menu': - $mainframe->redirect( 'index.php?option=com_menus&menutype='. $menu ); - break; - - case 'go2menuitem': - $mainframe->redirect( 'index.php?option=com_menus&menutype='. $menu .'&task=edit&id='. $menuid ); - break; - - case 'apply': - $msg = JText::_( 'Changes to Category saved' ); - $mainframe->redirect( 'index.php?option=com_categories§ion='. $redirect .'&task=edit&cid[]='. $row->id, $msg ); - break; - - case 'save': - default: - $msg = JText::_( 'Category saved' ); - $mainframe->redirect( 'index.php?option=com_categories§ion='. $redirect, $msg ); - break; - } -} - -/** -* Deletes one or more categories from the categories table -* @param string The name of the category section -* @param array An array of unique category id numbers -*/ -function removeCategories( $section, $cid ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db =& JFactory::getDBO(); - - JArrayHelper::toInteger($cid); - - if (count( $cid ) < 1) { - JError::raiseError(500, JText::_( 'Select a category to delete', true )); - } - - $cids = implode( ',', $cid ); - - if (intval( $section ) > 0) { - $table = 'content'; - } else if (strpos( $section, 'com_' ) === 0) { - $table = substr( $section, 4 ); - } else { - $table = $section; - } - - $tablesAllowed = $db->getTableList(); - if (!in_array($db->getPrefix().$table, $tablesAllowed)) { - $table = 'content'; - } - - $query = 'SELECT c.id, c.name, c.title, COUNT( s.catid ) AS numcat' - . ' FROM #__categories AS c' - . ' LEFT JOIN #__'.$table.' AS s ON s.catid = c.id' - . ' WHERE c.id IN ( '.$cids.' )' - . ' GROUP BY c.id' - ; - $db->setQuery( $query ); - - if (!($rows = $db->loadObjectList())) { - JError::raiseError( 500, $db->stderr() ); - return false; - } - - $err = array(); - $cid = array(); - foreach ($rows as $row) { - if ($row->numcat == 0) { - $cid[] = (int) $row->id; - } else { - $err[] = $row->title; - } - } - - if (count( $cid )) { - $cids = implode( ',', $cid ); - $query = 'DELETE FROM #__categories' - . ' WHERE id IN ( '.$cids.' )' - ; - $db->setQuery( $query ); - if (!$db->query()) { - JError::raiseError( 500, $db->stderr() ); - return false; - } - } - - if (count( $err )) { - $cids = implode( ", ", $err ); - $msg = JText::sprintf( 'WARNNOTREMOVEDRECORDS', $cids ); - $mainframe->redirect( 'index.php?option=com_categories§ion='. $section, $msg ); - } - - $mainframe->redirect( 'index.php?option=com_categories§ion='. $section ); -} - -/** -* Publishes or Unpublishes one or more categories -* @param string The name of the category section -* @param integer A unique category id (passed from an edit form) -* @param array An array of unique category id numbers -* @param integer 0 if unpublishing, 1 if publishing -* @param string The name of the current user -*/ -function publishCategories( $section, $cid=null, $publish=1 ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db =& JFactory::getDBO(); - $user =& JFactory::getUser(); - $uid = $user->get('id'); - - JArrayHelper::toInteger($cid); - - if (count( $cid ) < 1) { - $action = $publish ? 'publish' : 'unpublish'; - JError::raiseError(500, JText::_( 'Select a category to '.$action, true ) ); - } - - $cids = implode( ',', $cid ); - - $query = 'UPDATE #__categories' - . ' SET published = ' . (int) $publish - . ' WHERE id IN ( '.$cids.' )' - . ' AND ( checked_out = 0 OR ( checked_out = '.(int) $uid.' ) )' - ; - $db->setQuery( $query ); - if (!$db->query()) { - JError::raiseError(500, $db->getErrorMsg() ); - } - - if (count( $cid ) == 1) { - $row =& JTable::getInstance('category'); - $row->checkin( $cid[0] ); - } - - $mainframe->redirect( 'index.php?option=com_categories§ion='. $section ); -} - -/** -* Cancels an edit operation -* @param string The name of the category section -* @param integer A unique category id -*/ -function cancelCategory() -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db =& JFactory::getDBO(); - - $redirect = JRequest::getCmd( 'redirect', '', 'post' ); - - $row =& JTable::getInstance('category'); - $row->bind( JRequest::get( 'post' )); - $row->checkin(); - - $mainframe->redirect( 'index.php?option=com_categories§ion='. $redirect ); -} - -/** -* Moves the order of a record -* @param integer The increment to reorder by -*/ -function orderCategory( $uid, $inc ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db =& JFactory::getDBO(); - $row =& JTable::getInstance('category' ); - $row->load( $uid ); - $row->move( $inc, 'section = '.$db->Quote($row->section) ); - $section = JRequest::getCmd('section'); - if($section) { - $section = '§ion='. $section; - } - $mainframe->redirect( 'index.php?option=com_categories'. $section ); -} - -/** -* Form for moving item(s) to a specific menu -*/ -function moveCategorySelect( $option, $cid, $sectionOld ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $redirect = JRequest::getCmd( 'section', 'com_content', 'post' ); - - JArrayHelper::toInteger($cid); - - if (count( $cid ) < 1) { - JError::raiseError(500, JText::_( 'Select an item to move', true )); - } - - ## query to list selected categories - $cids = implode( ',', $cid ); - $query = 'SELECT a.title, a.section' - . ' FROM #__categories AS a' - . ' WHERE a.id IN ( '.$cids.' )' - ; - $db->setQuery( $query ); - $items = $db->loadObjectList(); - - ## query to list items from categories - $query = 'SELECT a.title' - . ' FROM #__content AS a' - . ' WHERE a.catid IN ( '.$cids.' )' - . ' ORDER BY a.catid, a.title' - ; - $db->setQuery( $query ); - $contents = $db->loadObjectList(); - - ## query to choose section to move to - $query = 'SELECT a.title AS text, a.id AS value' - . ' FROM #__sections AS a' - . ' WHERE a.published = 1' - . ' ORDER BY a.title' - ; - $db->setQuery( $query ); - $sections = $db->loadObjectList(); - - // build the html select list - $SectionList = JHTML::_('select.genericlist', $sections, 'sectionmove', 'class="inputbox" size="10"', 'value', 'text', null ); - - categories_html::moveCategorySelect( $option, $cid, $SectionList, $items, $sectionOld, $contents, $redirect ); -} - - -/** -* Save the item(s) to the menu selected -*/ -function moveCategorySave( $cid, $sectionOld ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $sectionMove = JRequest::getCmd( 'sectionmove' ); - - //Check to see of a section was selected to copy the items too - if (!$sectionMove) - { - $msg = JText::_('Please select a section from the list'); - moveCategorySelect( 'com_categories', $cid, $sectionOld ); - JError::raiseWarning(500, $msg); - return; - } - - JArrayHelper::toInteger($cid, array(0)); - - $sectionNew =& JTable::getInstance('section'); - $sectionNew->load( $sectionMove ); - - //Remove the categories was in destination section - $cids = implode( ',', $cid ); - - $query = 'SELECT id, title' - . ' FROM #__categories' - . ' WHERE id IN ( '.$cids.' )' - . ' AND section = '.$db->Quote($sectionMove) - ; - $db->setQuery( $query ); - - $scid = $db->loadResultArray(0); - $title = $db->loadResultArray(1); - - $cid = array_diff($cid, $scid); - - // - if ( !empty($cid) ) { - $cids = implode( ',', $cid ); - $total = count( $cid ); - - $query = 'UPDATE #__categories' - . ' SET section = '.$db->Quote($sectionMove) - . ' WHERE id IN ( '.$cids.' )' - ; - $db->setQuery( $query ); - if ( !$db->query() ) { - JError::raiseError(500, $db->getErrorMsg() ); - } - $query = 'UPDATE #__content' - . ' SET sectionid = '.$db->Quote($sectionMove) - . ' WHERE catid IN ( '.$cids.' )' - ; - $db->setQuery( $query ); - if ( !$db->query() ) { - JError::raiseError(500, $db->getErrorMsg()); - } - - $msg = JText::sprintf( 'Categories moved to', $sectionNew->title ); - $mainframe->enqueueMessage($msg); - } - if ( !empty($title) && is_array($title) ) { - if ( count($title) == 1 ) { - $msg = JText::sprintf( 'Category already in', implode( ', ', $title ), $sectionNew->title ); - } else { - $msg = JText::sprintf( 'Categories already in', implode( ', ', $title ), $sectionNew->title ); - } - $mainframe->enqueueMessage($msg); - } - - $mainframe->redirect( 'index.php?option=com_categories§ion='. $sectionOld ); -} - -/** -* Form for copying item(s) to a specific menu -*/ -function copyCategorySelect( $option, $cid, $sectionOld ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $redirect = JRequest::getCmd( 'section', 'com_content', 'post' ); - - JArrayHelper::toInteger($cid); - - if (count( $cid ) < 1) { - JError::raiseError(500, JText::_( 'Select an item to move', true )); - } - - ## query to list selected categories - $cids = implode( ',', $cid ); - $query = 'SELECT a.title, a.section' - . ' FROM #__categories AS a' - . ' WHERE a.id IN ( '.$cids.' )' - ; - $db->setQuery( $query ); - $items = $db->loadObjectList(); - - ## query to list items from categories - $query = 'SELECT a.title, a.id' - . ' FROM #__content AS a' - . ' WHERE a.catid IN ( '.$cids.' )' - . ' ORDER BY a.catid, a.title' - ; - $db->setQuery( $query ); - $contents = $db->loadObjectList(); - - ## query to choose section to move to - $query = 'SELECT a.title AS `text`, a.id AS `value`' - . ' FROM #__sections AS a' - . ' WHERE a.published = 1' - . ' ORDER BY a.name' - ; - $db->setQuery( $query ); - $sections = $db->loadObjectList(); - - // build the html select list - $SectionList = JHTML::_('select.genericlist', $sections, 'sectionmove', 'class="inputbox" size="10"', 'value', 'text', null ); - - categories_html::copyCategorySelect( $option, $cid, $SectionList, $items, $sectionOld, $contents, $redirect ); -} - - -/** -* Save the item(s) to the menu selected -*/ -function copyCategorySave( $cid, $sectionOld ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db =& JFactory::getDBO(); - - $sectionMove = JRequest::getInt( 'sectionmove' ); - - //Check to see of a section was selected to copy the items too - if (!$sectionMove) - { - $msg = JText::_('Please select a section from the list'); - copyCategorySelect( 'com_categories', $cid, $sectionOld ); - JError::raiseWarning(500, $msg); - return; - } - - $contentid = JRequest::getVar( 'item', null, '', 'array' ); - JArrayHelper::toInteger($contentid); - - $category =& JTable::getInstance('category'); - - foreach( $cid as $id ) - { - $category->load( $id ); - $category->id = NULL; - $category->title = JText::sprintf( 'Copy of', $category->title ); - $category->name = JText::sprintf( 'Copy of', $category->name ); - $category->section = $sectionMove; - if (!$category->check()) { - JError::raiseError(500, $category->getError()); - } - - if (!$category->store()) { - JError::raiseError(500, $category->getError()); - } - $category->checkin(); - // stores original catid - $newcatids[]["old"] = $id; - // pulls new catid - $newcatids[]["new"] = $category->id; - } - - $content =& JTable::getInstance('content'); - foreach( $contentid as $id) { - $content->load( $id ); - $content->id = NULL; - $content->sectionid = $sectionMove; - $content->hits = 0; - foreach( $newcatids as $newcatid ) { - if ( $content->catid == $newcatid["old"] ) { - $content->catid = $newcatid["new"]; - } - } - if (!$content->check()) { - JError::raiseError(500, $content->getError()); - } - - if (!$content->store()) { - JError::raiseError(500, $content->getError()); - } - $content->checkin(); - } - - $sectionNew =& JTable::getInstance('section'); - $sectionNew->load( $sectionMove ); - - $msg = JText::sprintf( 'Categories copied to', count($cid), $sectionNew->title ); - $mainframe->redirect( 'index.php?option=com_categories§ion='. $sectionOld, $msg ); -} - -/** -* changes the access level of a record -* @param integer The increment to reorder by -*/ -function accessMenu( $uid, $access, $section ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db =& JFactory::getDBO(); - - $row =& JTable::getInstance('category'); - $row->load( $uid ); - $row->access = $access; - - if ( !$row->check() ) { - return $row->getError(); - } - if ( !$row->store() ) { - return $row->getError(); - } - - $mainframe->redirect( 'index.php?option=com_categories§ion='. $section ); -} - -function saveOrder( &$cid, $section ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db =& JFactory::getDBO(); - - $total = count( $cid ); - $order = JRequest::getVar( 'order', array(0), 'post', 'array' ); - JArrayHelper::toInteger($order, array(0)); - $row =& JTable::getInstance('category'); - $groupings = array(); - - // update ordering values - for( $i=0; $i < $total; $i++ ) { - $row->load( (int) $cid[$i] ); - // track sections - $groupings[] = $row->section; - if ($row->ordering != $order[$i]) { - $row->ordering = $order[$i]; - if (!$row->store()) { - JError::raiseError(500, $db->getErrorMsg()); - } - } - } - - // execute updateOrder for each parent group - $groupings = array_unique( $groupings ); - foreach ($groupings as $group){ - $row->reorder('section = '.$db->Quote($group)); - } - - $msg = JText::_( 'New ordering saved' ); - $mainframe->redirect( 'index.php?option=com_categories§ion='. $section, $msg ); +getUserStateFromRequest( $option.'.filter_order', 'filter_order', 'c.ordering', 'cmd' ); + if ($filter_order == 'section_name' && ($section == 'com_newsfeeds' || $section == 'com_banner' || $section == 'com_weblinks' || $section == 'com_contact_details')){ + $filter_order = 'c.ordering'; + } + $filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'.filter_order_Dir', 'filter_order_Dir', '', 'word' ); + $filter_state = $mainframe->getUserStateFromRequest( $option.'.'.$section.'.filter_state', 'filter_state', '', 'word' ); + $sectionid = $mainframe->getUserStateFromRequest( $option.'.'.$section.'.sectionid', 'sectionid', 0, 'int' ); + $search = $mainframe->getUserStateFromRequest( $option.'.search', 'search', '', 'string' ); + if (strpos($search, '"') !== false) { + $search = str_replace(array('=', '<'), '', $search); + } + $search = JString::strtolower($search); + + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); + + $section_name = ''; + $content_add = ''; + $content_join = ''; + $order = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', c.ordering'; + if (intval( $section ) > 0) { + $table = 'content'; + + $query = 'SELECT title' + . ' FROM #__sections' + . ' WHERE id = '.(int) $section; + $db->setQuery( $query ); + $section_name = $db->loadResult(); + $section_name = JText::sprintf( 'Content:', JText::_( $section_name ) ); + $where = ' WHERE c.section = '.$db->Quote($section); + $type = 'content'; + } else if (strpos( $section, 'com_' ) === 0) { + $table = substr( $section, 4 ); + + $query = 'SELECT name' + . ' FROM #__components' + . ' WHERE link = '.$db->Quote('option='.$section); + ; + $db->setQuery( $query ); + $section_name = $db->loadResult(); + $where = ' WHERE c.section = '.$db->Quote($section); + $type = 'other'; + // special handling for contact component + if ( $section == 'com_contact_details' ) { + $section_name = JText::_( 'Contact' ); + } + $section_name = JText::sprintf( 'Component:', $section_name ); + } else { + $table = $section; + $where = ' WHERE c.section = '.$db->Quote($section); + $type = 'other'; + } + + // get the total number of records + $query = 'SELECT COUNT(*)' + . ' FROM #__categories' + ; + if ($section == 'com_content') + { + if($sectionid > 0) + { + $query .= ' WHERE section = '.(int) $sectionid; + } else { + $query .= ' WHERE section > 0'; + } + } else { + $query .= ' WHERE section = '.$db->quote($section); + } + if ( $filter_state ) { + if ( $filter_state == 'P' ) { + $query .= ' AND published = 1'; + } else if ($filter_state == 'U' ) { + $query .= ' AND published = 0'; + } + } + $db->setQuery( $query ); + $total = $db->loadResult(); + + // allows for viweing of all content categories + if ( $section == 'com_content' ) { + $table = 'content'; + $content_add = ' , z.title AS section_name'; + $content_join = ' LEFT JOIN #__sections AS z ON z.id = c.section'; + $where = ' WHERE c.section NOT LIKE "%com_%"'; + if ($filter_order == 'c.ordering'){ + $order = ' ORDER BY z.title, c.ordering '. $filter_order_Dir; + } else { + $order = ' ORDER BY '.$filter_order.' '. $filter_order_Dir.', z.title, c.ordering'; + } + + $section_name = JText::_( 'All Content:' ); + + $type = 'content'; + } + + // used by filter + if ( $sectionid > 0 ) { + $filter = ' AND c.section = '.$db->Quote($sectionid); + } else { + $filter = ''; + } + if ( $filter_state ) { + if ( $filter_state == 'P' ) { + $filter .= ' AND c.published = 1'; + } else if ($filter_state == 'U' ) { + $filter .= ' AND c.published = 0'; + } + } + if ($search) { + $filter .= ' AND LOWER(c.title) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + + jimport('joomla.html.pagination'); + $pageNav = new JPagination( $total, $limitstart, $limit ); + + $tablesAllowed = $db->getTableList(); + if (!in_array($db->getPrefix().$table, $tablesAllowed)) { + $table = 'content'; + } + + $query = 'SELECT c.*, c.checked_out as checked_out_contact_category, g.name AS groupname, u.name AS editor, COUNT( DISTINCT s2.checked_out ) AS checked_out_count' + . $content_add + . ' FROM #__categories AS c' + . ' LEFT JOIN #__users AS u ON u.id = c.checked_out' + . ' LEFT JOIN #__groups AS g ON g.id = c.access' + . ' LEFT JOIN #__'.$table.' AS s2 ON s2.catid = c.id AND s2.checked_out > 0' + . $content_join + . $where + . $filter + . ' AND c.published != -2' + . ' GROUP BY c.id' + . $order + ; + $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); + $rows = $db->loadObjectList(); + if ($db->getErrorNum()) { + echo $db->stderr(); + return; + } + + $count = count( $rows ); + // number of Active Items + for ( $i = 0; $i < $count; $i++ ) { + $query = 'SELECT COUNT( a.id )' + . ' FROM #__content AS a' + . ' WHERE a.catid = '. (int) $rows[$i]->id + . ' AND a.state <> -2' + ; + $db->setQuery( $query ); + $active = $db->loadResult(); + $rows[$i]->active = $active; + } + // number of Trashed Items + for ( $i = 0; $i < $count; $i++ ) { + $query = 'SELECT COUNT( a.id )' + . ' FROM #__content AS a' + . ' WHERE a.catid = '. (int) $rows[$i]->id + . ' AND a.state = -2' + ; + $db->setQuery( $query ); + $trash = $db->loadResult(); + $rows[$i]->trash = $trash; + } + + // get list of sections for dropdown filter + $javascript = 'onchange="document.adminForm.submit();"'; + $lists['sectionid'] = JHTML::_('list.section', 'sectionid', $sectionid, $javascript, 'ordering', false ); + + // state filter + $lists['state'] = JHTML::_('grid.state', $filter_state ); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search']= $search; + + categories_html::show( $rows, $section, $section_name, $pageNav, $lists, $type ); +} + +/** +* Compiles information to add or edit a category +* @param string The name of the category section +* @param integer The unique id of the category to edit (0 if new) +* @param string The name of the current user +*/ +function editCategory($edit ) +{ + global $mainframe; + + // Initialize variables + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + $uid = $user->get('id'); + + $type = JRequest::getCmd( 'type' ); + $redirect = JRequest::getCmd( 'section', 'com_content' ); + $section = JRequest::getCmd( 'section', 'com_content' ); + $cid = JRequest::getVar( 'cid', array(0), '', 'array' ); + + JArrayHelper::toInteger($cid, array(0)); + + // check for existance of any sections + $query = 'SELECT COUNT( id )' + . ' FROM #__sections' + . ' WHERE scope = "content"' + ; + $db->setQuery( $query ); + $sections = $db->loadResult(); + if (!$sections && $type != 'other' + && $section != 'com_weblinks' + && $section != 'com_newsfeeds' + && $section != 'com_contact_details' + && $section != 'com_banner') { + $mainframe->redirect( 'index.php?option=com_categories§ion='. $section, JText::_( 'WARNSECTION', true ) ); + } + + $row =& JTable::getInstance('category'); + // load the row from the db table + if ($edit) + $row->load( $cid[0] ); + + // fail if checked out not by 'me' + if ( JTable::isCheckedOut($user->get ('id'), $row->checked_out )) { + $msg = JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The category' ), $row->title ); + $mainframe->redirect( 'index.php?option=com_categories§ion='. $row->section, $msg ); + } + + if ( $edit ) { + $row->checkout( $user->get('id')); + } else { + $row->published = 1; + } + + + // make order list + $order = array(); + $query = 'SELECT COUNT(*)' + . ' FROM #__categories' + . ' WHERE section = '.$db->Quote($row->section) + ; + $db->setQuery( $query ); + $max = intval( $db->loadResult() ) + 1; + + for ($i=1; $i < $max; $i++) { + $order[] = JHTML::_('select.option', $i ); + } + + // build the html select list for sections + if ( $section == 'com_content' ) { + + if (!$row->section && JRequest::getInt('sectionid')) { + $row->section = JRequest::getInt('sectionid'); + } + + $query = 'SELECT s.id AS value, s.title AS text' + . ' FROM #__sections AS s' + . ' ORDER BY s.ordering' + ; + $db->setQuery( $query ); + $sections = $db->loadObjectList(); + $lists['section'] = JHTML::_('select.genericlist', $sections, 'section', 'class="inputbox" size="1"', 'value', 'text', $row->section ); + } else { + if ( $type == 'other' ) { + $section_name = JText::_( 'N/A' ); + } else { + $temp =& JTable::getInstance('section'); + $temp->load( $row->section ); + $section_name = $temp->name; + } + if(!$section_name) $section_name = JText::_( 'N/A' ); + $row->section = $section; + $lists['section'] = ''. $section_name; + } + + // build the html select list for ordering + $query = 'SELECT ordering AS value, title AS text' + . ' FROM #__categories' + . ' WHERE section = '.$db->Quote($row->section) + . ' ORDER BY ordering' + ; + if ($edit) { + $lists['ordering'] = JHTML::_('list.specificordering', $row, $cid[0], $query ); + } + else { + $lists['ordering'] = JHTML::_('list.specificordering', $row, '', $query ); + } + // build the select list for the image positions + $active = ( $row->image_position ? $row->image_position : 'left' ); + $lists['image_position'] = JHTML::_('list.positions', 'image_position', $active, NULL, 0, 0 ); + // Imagelist + $lists['image'] = JHTML::_('list.images', 'image', $row->image ); + // build the html select list for the group access + $lists['access'] = JHTML::_('list.accesslevel', $row ); + // build the html radio buttons for published + $published = ($row->id) ? $row->published : 1; + $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $published ); + + categories_html::edit( $row, $lists, $redirect ); +} + +/** +* Saves the catefory after an edit form submit +* @param string The name of the category section +*/ +function saveCategory() +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db =& JFactory::getDBO(); + $menu = JRequest::getCmd( 'menu', 'mainmenu', 'post' ); + $menuid = JRequest::getVar( 'menuid', 0, 'post', 'int' ); + $redirect = JRequest::getCmd( 'redirect', '', 'post' ); + $oldtitle = JRequest::getString( 'oldtitle', '', 'post' ); + $post = JRequest::get( 'post' ); + + // fix up special html fields + $post['description'] = JRequest::getVar( 'description', '', 'post', 'string', JREQUEST_ALLOWRAW ); + + $row =& JTable::getInstance('category'); + if (!$row->bind( $post )) { + JError::raiseError(500, $row->getError() ); + } + if (!$row->check()) { + JError::raiseError(500, $row->getError() ); + } + // if new item order last in appropriate group + if (!$row->id) { + $where = "section = " . $db->Quote($row->section); + $row->ordering = $row->getNextOrder( $where ); + } + + if (!$row->store()) { + JError::raiseError(500, $row->getError() ); + } + $row->checkin(); + + if ($row->section > 0) { + $query = 'UPDATE #__content' + .' SET sectionid = '.$row->section + .' WHERE catid = '.$row->id + ; + $db->setQuery( $query ); + $db->query(); + } + + if ( $oldtitle ) { + if ($oldtitle != $row->title) { + $query = 'UPDATE #__menu' + . ' SET name = '.$db->Quote($row->title) + . ' WHERE name = '.$db->Quote($oldtitle) + . ' AND type = "content_category"' + ; + $db->setQuery( $query ); + $db->query(); + } + } + + // Update Section Count + if ($row->section != 'com_contact_details' && + $row->section != 'com_newsfeeds' && + $row->section != 'com_weblinks') { + $query = 'UPDATE #__sections SET count=count+1' + . ' WHERE id = '.$db->Quote($row->section) + ; + $db->setQuery( $query ); + } + + if (!$db->query()) { + JError::raiseError(500, $db->getErrorMsg() ); + } + + switch ( JRequest::getCmd('task') ) + { + case 'go2menu': + $mainframe->redirect( 'index.php?option=com_menus&menutype='. $menu ); + break; + + case 'go2menuitem': + $mainframe->redirect( 'index.php?option=com_menus&menutype='. $menu .'&task=edit&id='. $menuid ); + break; + + case 'apply': + $msg = JText::_( 'Changes to Category saved' ); + $mainframe->redirect( 'index.php?option=com_categories§ion='. $redirect .'&task=edit&cid[]='. $row->id, $msg ); + break; + + case 'save': + default: + $msg = JText::_( 'Category saved' ); + $mainframe->redirect( 'index.php?option=com_categories§ion='. $redirect, $msg ); + break; + } +} + +/** +* Deletes one or more categories from the categories table +* @param string The name of the category section +* @param array An array of unique category id numbers +*/ +function removeCategories( $section, $cid ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db =& JFactory::getDBO(); + + JArrayHelper::toInteger($cid); + + if (count( $cid ) < 1) { + JError::raiseError(500, JText::_( 'Select a category to delete', true )); + } + + $cids = implode( ',', $cid ); + + if (intval( $section ) > 0) { + $table = 'content'; + } else if (strpos( $section, 'com_' ) === 0) { + $table = substr( $section, 4 ); + } else { + $table = $section; + } + + $tablesAllowed = $db->getTableList(); + if (!in_array($db->getPrefix().$table, $tablesAllowed)) { + $table = 'content'; + } + + $query = 'SELECT c.id, c.name, c.title, COUNT( s.catid ) AS numcat' + . ' FROM #__categories AS c' + . ' LEFT JOIN #__'.$table.' AS s ON s.catid = c.id' + . ' WHERE c.id IN ( '.$cids.' )' + . ' GROUP BY c.id' + ; + $db->setQuery( $query ); + + if (!($rows = $db->loadObjectList())) { + JError::raiseError( 500, $db->stderr() ); + return false; + } + + $err = array(); + $cid = array(); + foreach ($rows as $row) { + if ($row->numcat == 0) { + $cid[] = (int) $row->id; + } else { + $err[] = $row->title; + } + } + + if (count( $cid )) { + $cids = implode( ',', $cid ); + $query = 'DELETE FROM #__categories' + . ' WHERE id IN ( '.$cids.' )' + ; + $db->setQuery( $query ); + if (!$db->query()) { + JError::raiseError( 500, $db->stderr() ); + return false; + } + } + + if (count( $err )) { + $cids = implode( ", ", $err ); + $msg = JText::sprintf( 'WARNNOTREMOVEDRECORDS', $cids ); + $mainframe->redirect( 'index.php?option=com_categories§ion='. $section, $msg ); + } + + $mainframe->redirect( 'index.php?option=com_categories§ion='. $section ); +} + +/** +* Publishes or Unpublishes one or more categories +* @param string The name of the category section +* @param integer A unique category id (passed from an edit form) +* @param array An array of unique category id numbers +* @param integer 0 if unpublishing, 1 if publishing +* @param string The name of the current user +*/ +function publishCategories( $section, $cid=null, $publish=1 ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + $uid = $user->get('id'); + + JArrayHelper::toInteger($cid); + + if (count( $cid ) < 1) { + $action = $publish ? 'publish' : 'unpublish'; + JError::raiseError(500, JText::_( 'Select a category to '.$action, true ) ); + } + + $cids = implode( ',', $cid ); + + $query = 'UPDATE #__categories' + . ' SET published = ' . (int) $publish + . ' WHERE id IN ( '.$cids.' )' + . ' AND ( checked_out = 0 OR ( checked_out = '.(int) $uid.' ) )' + ; + $db->setQuery( $query ); + if (!$db->query()) { + JError::raiseError(500, $db->getErrorMsg() ); + } + + if (count( $cid ) == 1) { + $row =& JTable::getInstance('category'); + $row->checkin( $cid[0] ); + } + + $mainframe->redirect( 'index.php?option=com_categories§ion='. $section ); +} + +/** +* Cancels an edit operation +* @param string The name of the category section +* @param integer A unique category id +*/ +function cancelCategory() +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db =& JFactory::getDBO(); + + $redirect = JRequest::getCmd( 'redirect', '', 'post' ); + + $row =& JTable::getInstance('category'); + $row->bind( JRequest::get( 'post' )); + $row->checkin(); + + $mainframe->redirect( 'index.php?option=com_categories§ion='. $redirect ); +} + +/** +* Moves the order of a record +* @param integer The increment to reorder by +*/ +function orderCategory( $uid, $inc ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db =& JFactory::getDBO(); + $row =& JTable::getInstance('category' ); + $row->load( $uid ); + $row->move( $inc, 'section = '.$db->Quote($row->section) ); + $section = JRequest::getCmd('section'); + if($section) { + $section = '§ion='. $section; + } + $mainframe->redirect( 'index.php?option=com_categories'. $section ); +} + +/** +* Form for moving item(s) to a specific menu +*/ +function moveCategorySelect( $option, $cid, $sectionOld ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $redirect = JRequest::getCmd( 'section', 'com_content', 'post' ); + + JArrayHelper::toInteger($cid); + + if (count( $cid ) < 1) { + JError::raiseError(500, JText::_( 'Select an item to move', true )); + } + + ## query to list selected categories + $cids = implode( ',', $cid ); + $query = 'SELECT a.title, a.section' + . ' FROM #__categories AS a' + . ' WHERE a.id IN ( '.$cids.' )' + ; + $db->setQuery( $query ); + $items = $db->loadObjectList(); + + ## query to list items from categories + $query = 'SELECT a.title' + . ' FROM #__content AS a' + . ' WHERE a.catid IN ( '.$cids.' )' + . ' ORDER BY a.catid, a.title' + ; + $db->setQuery( $query ); + $contents = $db->loadObjectList(); + + ## query to choose section to move to + $query = 'SELECT a.title AS text, a.id AS value' + . ' FROM #__sections AS a' + . ' WHERE a.published = 1' + . ' ORDER BY a.title' + ; + $db->setQuery( $query ); + $sections = $db->loadObjectList(); + + // build the html select list + $SectionList = JHTML::_('select.genericlist', $sections, 'sectionmove', 'class="inputbox" size="10"', 'value', 'text', null ); + + categories_html::moveCategorySelect( $option, $cid, $SectionList, $items, $sectionOld, $contents, $redirect ); +} + + +/** +* Save the item(s) to the menu selected +*/ +function moveCategorySave( $cid, $sectionOld ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $sectionMove = JRequest::getCmd( 'sectionmove' ); + + //Check to see of a section was selected to copy the items too + if (!$sectionMove) + { + $msg = JText::_('Please select a section from the list'); + moveCategorySelect( 'com_categories', $cid, $sectionOld ); + JError::raiseWarning(500, $msg); + return; + } + + JArrayHelper::toInteger($cid, array(0)); + + $sectionNew =& JTable::getInstance('section'); + $sectionNew->load( $sectionMove ); + + //Remove the categories was in destination section + $cids = implode( ',', $cid ); + + $query = 'SELECT id, title' + . ' FROM #__categories' + . ' WHERE id IN ( '.$cids.' )' + . ' AND section = '.$db->Quote($sectionMove) + ; + $db->setQuery( $query ); + + $scid = $db->loadResultArray(0); + $title = $db->loadResultArray(1); + + $cid = array_diff($cid, $scid); + + // + if ( !empty($cid) ) { + $cids = implode( ',', $cid ); + $total = count( $cid ); + + $query = 'UPDATE #__categories' + . ' SET section = '.$db->Quote($sectionMove) + . ' WHERE id IN ( '.$cids.' )' + ; + $db->setQuery( $query ); + if ( !$db->query() ) { + JError::raiseError(500, $db->getErrorMsg() ); + } + $query = 'UPDATE #__content' + . ' SET sectionid = '.$db->Quote($sectionMove) + . ' WHERE catid IN ( '.$cids.' )' + ; + $db->setQuery( $query ); + if ( !$db->query() ) { + JError::raiseError(500, $db->getErrorMsg()); + } + + $msg = JText::sprintf( 'Categories moved to', $sectionNew->title ); + $mainframe->enqueueMessage($msg); + } + if ( !empty($title) && is_array($title) ) { + if ( count($title) == 1 ) { + $msg = JText::sprintf( 'Category already in', implode( ', ', $title ), $sectionNew->title ); + } else { + $msg = JText::sprintf( 'Categories already in', implode( ', ', $title ), $sectionNew->title ); + } + $mainframe->enqueueMessage($msg); + } + + $mainframe->redirect( 'index.php?option=com_categories§ion='. $sectionOld ); +} + +/** +* Form for copying item(s) to a specific menu +*/ +function copyCategorySelect( $option, $cid, $sectionOld ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $redirect = JRequest::getCmd( 'section', 'com_content', 'post' ); + + JArrayHelper::toInteger($cid); + + if (count( $cid ) < 1) { + JError::raiseError(500, JText::_( 'Select an item to move', true )); + } + + ## query to list selected categories + $cids = implode( ',', $cid ); + $query = 'SELECT a.title, a.section' + . ' FROM #__categories AS a' + . ' WHERE a.id IN ( '.$cids.' )' + ; + $db->setQuery( $query ); + $items = $db->loadObjectList(); + + ## query to list items from categories + $query = 'SELECT a.title, a.id' + . ' FROM #__content AS a' + . ' WHERE a.catid IN ( '.$cids.' )' + . ' ORDER BY a.catid, a.title' + ; + $db->setQuery( $query ); + $contents = $db->loadObjectList(); + + ## query to choose section to move to + $query = 'SELECT a.title AS `text`, a.id AS `value`' + . ' FROM #__sections AS a' + . ' WHERE a.published = 1' + . ' ORDER BY a.name' + ; + $db->setQuery( $query ); + $sections = $db->loadObjectList(); + + // build the html select list + $SectionList = JHTML::_('select.genericlist', $sections, 'sectionmove', 'class="inputbox" size="10"', 'value', 'text', null ); + + categories_html::copyCategorySelect( $option, $cid, $SectionList, $items, $sectionOld, $contents, $redirect ); +} + + +/** +* Save the item(s) to the menu selected +*/ +function copyCategorySave( $cid, $sectionOld ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db =& JFactory::getDBO(); + + $sectionMove = JRequest::getInt( 'sectionmove' ); + + //Check to see of a section was selected to copy the items too + if (!$sectionMove) + { + $msg = JText::_('Please select a section from the list'); + copyCategorySelect( 'com_categories', $cid, $sectionOld ); + JError::raiseWarning(500, $msg); + return; + } + + $contentid = JRequest::getVar( 'item', null, '', 'array' ); + JArrayHelper::toInteger($contentid); + + $category =& JTable::getInstance('category'); + + foreach( $cid as $id ) + { + $category->load( $id ); + $category->id = NULL; + $category->title = JText::sprintf( 'Copy of', $category->title ); + $category->name = JText::sprintf( 'Copy of', $category->name ); + $category->section = $sectionMove; + if (!$category->check()) { + JError::raiseError(500, $category->getError()); + } + + if (!$category->store()) { + JError::raiseError(500, $category->getError()); + } + $category->checkin(); + // stores original catid + $newcatids[]["old"] = $id; + // pulls new catid + $newcatids[]["new"] = $category->id; + } + + $content =& JTable::getInstance('content'); + foreach( $contentid as $id) { + $content->load( $id ); + $content->id = NULL; + $content->sectionid = $sectionMove; + $content->hits = 0; + foreach( $newcatids as $newcatid ) { + if ( $content->catid == $newcatid["old"] ) { + $content->catid = $newcatid["new"]; + } + } + if (!$content->check()) { + JError::raiseError(500, $content->getError()); + } + + if (!$content->store()) { + JError::raiseError(500, $content->getError()); + } + $content->checkin(); + } + + $sectionNew =& JTable::getInstance('section'); + $sectionNew->load( $sectionMove ); + + $msg = JText::sprintf( 'Categories copied to', count($cid), $sectionNew->title ); + $mainframe->redirect( 'index.php?option=com_categories§ion='. $sectionOld, $msg ); +} + +/** +* changes the access level of a record +* @param integer The increment to reorder by +*/ +function accessMenu( $uid, $access, $section ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db =& JFactory::getDBO(); + + $row =& JTable::getInstance('category'); + $row->load( $uid ); + $row->access = $access; + + if ( !$row->check() ) { + return $row->getError(); + } + if ( !$row->store() ) { + return $row->getError(); + } + + $mainframe->redirect( 'index.php?option=com_categories§ion='. $section ); +} + +function saveOrder( &$cid, $section ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db =& JFactory::getDBO(); + + $total = count( $cid ); + $order = JRequest::getVar( 'order', array(0), 'post', 'array' ); + JArrayHelper::toInteger($order, array(0)); + $row =& JTable::getInstance('category'); + $groupings = array(); + + // update ordering values + for( $i=0; $i < $total; $i++ ) { + $row->load( (int) $cid[$i] ); + // track sections + $groupings[] = $row->section; + if ($row->ordering != $order[$i]) { + $row->ordering = $order[$i]; + if (!$row->store()) { + JError::raiseError(500, $db->getErrorMsg()); + } + } + } + + // execute updateOrder for each parent group + $groupings = array_unique( $groupings ); + foreach ($groupings as $group){ + $row->reorder('section = '.$db->Quote($group)); + } + + $msg = JText::_( 'New ordering saved' ); + $mainframe->redirect( 'index.php?option=com_categories§ion='. $section, $msg ); } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_categories/toolbar.categories.html.php b/oss/joomla/trunk/administrator/components/com_categories/toolbar.categories.html.php index 26d6ea54..5e40b753 100644 --- a/oss/joomla/trunk/administrator/components/com_categories/toolbar.categories.html.php +++ b/oss/joomla/trunk/administrator/components/com_categories/toolbar.categories.html.php @@ -1,85 +1,85 @@ -[ '. $text.' ]', 'categories.png' ); - JToolBarHelper::save(); - JToolBarHelper::apply(); - if ($edit) { - // for existing articles the button is renamed `close` - JToolBarHelper::cancel( 'cancel', 'Close' ); - } else { - JToolBarHelper::cancel(); - } - JToolBarHelper::help( 'screen.' . substr( $section, 4 ) . '.categories.edit' ); - } - - /** - * Draws the menu for Moving existing categories - * @param int The published state (to display the inverse button) - */ - function _MOVE() { - - JToolBarHelper::title( JText::_( 'Category' ) .': [ '. JText::_( 'Move' ).' ]', 'categories.png' ); - JToolBarHelper::save( 'movesave' ); - JToolBarHelper::cancel(); - } - - /** - * Draws the menu for Copying existing categories - * @param int The published state (to display the inverse button) - */ - function _COPY() { - JToolBarHelper::title( JText::_( 'Category' ) .': [ '. JText::_( 'Copy' ).' ]', 'categories.png' ); - - JToolBarHelper::save( 'copysave' ); - JToolBarHelper::cancel(); - } - - /** - * Draws the menu for Editing an existing category - */ - function _DEFAULT() - { - $section = JRequest::getCmd( 'section' ); - - JToolBarHelper::title( JText::_( 'Category Manager' ) .': [ '. JText::_(JString::substr($section, 4)).' ]', 'categories.png' ); - JToolBarHelper::publishList(); - JToolBarHelper::unpublishList(); - - if ( $section == 'com_content' || ( $section > 0 ) ) { - JToolBarHelper::customX( 'moveselect', 'move.png', 'move_f2.png', 'Move', true ); - JToolBarHelper::customX( 'copyselect', 'copy.png', 'copy_f2.png', 'Copy', true ); - } - JToolBarHelper::deleteList(); - JToolBarHelper::editListX(); - JToolBarHelper::addNewX(); - JToolBarHelper::help( 'screen.' . substr( $section, 4 ) . '.categories' ); - } +[ '. $text.' ]', 'categories.png' ); + JToolBarHelper::save(); + JToolBarHelper::apply(); + if ($edit) { + // for existing articles the button is renamed `close` + JToolBarHelper::cancel( 'cancel', 'Close' ); + } else { + JToolBarHelper::cancel(); + } + JToolBarHelper::help( 'screen.' . substr( $section, 4 ) . '.categories.edit' ); + } + + /** + * Draws the menu for Moving existing categories + * @param int The published state (to display the inverse button) + */ + function _MOVE() { + + JToolBarHelper::title( JText::_( 'Category' ) .': [ '. JText::_( 'Move' ).' ]', 'categories.png' ); + JToolBarHelper::save( 'movesave' ); + JToolBarHelper::cancel(); + } + + /** + * Draws the menu for Copying existing categories + * @param int The published state (to display the inverse button) + */ + function _COPY() { + JToolBarHelper::title( JText::_( 'Category' ) .': [ '. JText::_( 'Copy' ).' ]', 'categories.png' ); + + JToolBarHelper::save( 'copysave' ); + JToolBarHelper::cancel(); + } + + /** + * Draws the menu for Editing an existing category + */ + function _DEFAULT() + { + $section = JRequest::getCmd( 'section' ); + + JToolBarHelper::title( JText::_( 'Category Manager' ) .': [ '. JText::_(JString::substr($section, 4)).' ]', 'categories.png' ); + JToolBarHelper::publishList(); + JToolBarHelper::unpublishList(); + + if ( $section == 'com_content' || ( $section > 0 ) ) { + JToolBarHelper::customX( 'moveselect', 'move.png', 'move_f2.png', 'Move', true ); + JToolBarHelper::customX( 'copyselect', 'copy.png', 'copy_f2.png', 'Copy', true ); + } + JToolBarHelper::deleteList(); + JToolBarHelper::editListX(); + JToolBarHelper::addNewX(); + JToolBarHelper::help( 'screen.' . substr( $section, 4 ) . '.categories' ); + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_categories/toolbar.categories.php b/oss/joomla/trunk/administrator/components/com_categories/toolbar.categories.php index ba6c1238..533f6ec5 100644 --- a/oss/joomla/trunk/administrator/components/com_categories/toolbar.categories.php +++ b/oss/joomla/trunk/administrator/components/com_categories/toolbar.categories.php @@ -1,44 +1,44 @@ -authorize( 'com_checkin', 'manage' )) { - $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); -} -$db =& JFactory::getDBO(); -$nullDate = $db->getNullDate(); -?> -
    - - - - - - - - getTableList(); - $k = 0; - foreach ($tables as $tn) { - // make sure we get the right tables based on prefix - if (!preg_match( "/^".$mainframe->getCfg('dbprefix')."/i", $tn )) { - continue; - } - $fields = $db->getTableFields( array( $tn ) ); - - $foundCO = false; - $foundCOT = false; - $foundE = false; - - $foundCO = isset( $fields[$tn]['checked_out'] ); - $foundCOT = isset( $fields[$tn]['checked_out_time'] ); - $foundE = isset( $fields[$tn]['editor'] ); - - if ($foundCO && $foundCOT) { - if ($foundE) { - $query = 'SELECT checked_out, editor FROM '.$tn.' WHERE checked_out > 0'; - } else { - $query = 'SELECT checked_out FROM '.$tn.' WHERE checked_out > 0'; - } - $db->setQuery( $query ); - $res = $db->query(); - $num = $db->getNumRows( $res ); - - if ($foundE) { - $query = 'UPDATE '.$tn.' SET checked_out = 0, checked_out_time = '.$db->Quote($nullDate).', editor = NULL WHERE checked_out > 0'; - } else { - $query = 'UPDATE '.$tn.' SET checked_out = 0, checked_out_time = '.$db->Quote($nullDate).' WHERE checked_out > 0'; - } - $db->setQuery( $query ); - $res = $db->query(); - - if ($res == 1) { - if ($num > 0) { - echo ""; - echo "\n "; - echo "\n "; - echo "\n "; - echo "\n "; - echo "\n"; - } else { - echo ""; - echo "\n "; - echo "\n "; - echo "\n "; - echo "\n "; - echo "\n"; - } - $k = 1 - $k; - } - } - } - ?> - - - -
    - - - - - - -
    ". JText::_( 'Checking table' ) ." - ". $tn ."". JText::_( 'Checked-In' ) ." ". $num ." ". JText::_( 'items' ) ."\"". 
    ". JText::_( 'Checking table' ) ." - ". $tn ."". JText::_( 'Checked-In' ) ." ". $num ." ". JText::_( 'items' ) ."  
    - - - -
    +authorize( 'com_checkin', 'manage' )) { + $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); +} +$db =& JFactory::getDBO(); +$nullDate = $db->getNullDate(); +?> +
    + + + + + + + + getTableList(); + $k = 0; + foreach ($tables as $tn) { + // make sure we get the right tables based on prefix + if (!preg_match( "/^".$mainframe->getCfg('dbprefix')."/i", $tn )) { + continue; + } + $fields = $db->getTableFields( array( $tn ) ); + + $foundCO = false; + $foundCOT = false; + $foundE = false; + + $foundCO = isset( $fields[$tn]['checked_out'] ); + $foundCOT = isset( $fields[$tn]['checked_out_time'] ); + $foundE = isset( $fields[$tn]['editor'] ); + + if ($foundCO && $foundCOT) { + if ($foundE) { + $query = 'SELECT checked_out, editor FROM '.$tn.' WHERE checked_out > 0'; + } else { + $query = 'SELECT checked_out FROM '.$tn.' WHERE checked_out > 0'; + } + $db->setQuery( $query ); + $res = $db->query(); + $num = $db->getNumRows( $res ); + + if ($foundE) { + $query = 'UPDATE '.$tn.' SET checked_out = 0, checked_out_time = '.$db->Quote($nullDate).', editor = NULL WHERE checked_out > 0'; + } else { + $query = 'UPDATE '.$tn.' SET checked_out = 0, checked_out_time = '.$db->Quote($nullDate).' WHERE checked_out > 0'; + } + $db->setQuery( $query ); + $res = $db->query(); + + if ($res == 1) { + if ($num > 0) { + echo ""; + echo "\n "; + echo "\n "; + echo "\n "; + echo "\n "; + echo "\n"; + } else { + echo ""; + echo "\n "; + echo "\n "; + echo "\n "; + echo "\n "; + echo "\n"; + } + $k = 1 - $k; + } + } + } + ?> + + + +
    + + + + + + +
    ". JText::_( 'Checking table' ) ." - ". $tn ."". JText::_( 'Checked-In' ) ." ". $num ." ". JText::_( 'items' ) ."\"". 
    ". JText::_( 'Checking table' ) ." - ". $tn ."". JText::_( 'Checked-In' ) ." ". $num ." ". JText::_( 'items' ) ."  
    + + + +
    \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_checkin/toolbar.checkin.html.php b/oss/joomla/trunk/administrator/components/com_checkin/toolbar.checkin.html.php index dafbd4f5..b260e5be 100644 --- a/oss/joomla/trunk/administrator/components/com_checkin/toolbar.checkin.html.php +++ b/oss/joomla/trunk/administrator/components/com_checkin/toolbar.checkin.html.php @@ -1,31 +1,31 @@ -authorize( 'com_config', 'manage' )) { - $mainframe->redirect('index.php', JText::_('ALERTNOTAUTH')); -} - -// Require the base controller -require_once (JPATH_COMPONENT.DS.'controller.php'); - -// Require specific controller if requested -if($controller = JRequest::getWord('controller', 'application')) { - $path = JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php'; - if (file_exists($path)) { - require_once $path; - } else { - $controller = ''; - } -} - -// Create the controller -$classname = 'ConfigController'.ucfirst($controller); -$controller = new $classname( ); - -JResponse::setHeader( 'Expires', 'Mon, 26 Jul 1997 05:00:00 GMT', true ); - -// Perform the Request task -$controller->execute( JRequest::getCmd( 'task' ) ); +authorize( 'com_config', 'manage' )) { + $mainframe->redirect('index.php', JText::_('ALERTNOTAUTH')); +} + +// Require the base controller +require_once (JPATH_COMPONENT.DS.'controller.php'); + +// Require specific controller if requested +if($controller = JRequest::getWord('controller', 'application')) { + $path = JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php'; + if (file_exists($path)) { + require_once $path; + } else { + $controller = ''; + } +} + +// Create the controller +$classname = 'ConfigController'.ucfirst($controller); +$controller = new $classname( ); + +JResponse::setHeader( 'Expires', 'Mon, 26 Jul 1997 05:00:00 GMT', true ); + +// Perform the Request task +$controller->execute( JRequest::getCmd( 'task' ) ); $controller->redirect(); \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_config/config.xml b/oss/joomla/trunk/administrator/components/com_config/config.xml index 5371d229..556d4ad5 100644 --- a/oss/joomla/trunk/administrator/components/com_config/config.xml +++ b/oss/joomla/trunk/administrator/components/com_config/config.xml @@ -1,12 +1,12 @@ - - - Configuration Manager - Joomla! Project - 2006 - Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - admin@joomla.org - www.joomla.org - 1.5.0 - Configuration Manager - + + + Configuration Manager + Joomla! Project + 2006 + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + Configuration Manager + diff --git a/oss/joomla/trunk/administrator/components/com_config/controller.php b/oss/joomla/trunk/administrator/components/com_config/controller.php index fb7e5f90..62ce27e6 100644 --- a/oss/joomla/trunk/administrator/components/com_config/controller.php +++ b/oss/joomla/trunk/administrator/components/com_config/controller.php @@ -1,29 +1,29 @@ -registerTask( 'apply', 'save' ); - } - - /** - * Show the configuration edit form - * @param string The URL option - */ - function showConfig() - { - // Initialize some variables - $db =& JFactory::getDBO(); - $row = new JConfig(); - - // compile list of the languages - $langs = array (); - $menuitems = array (); - $lists = array (); - - // PRE-PROCESS SOME LIST - - // -- Editors -- - - // compile list of the editors - $query = 'SELECT element AS value, name AS text' - .' FROM #__plugins' - .' WHERE folder = "editors"' - .' AND published = 1' - .' ORDER BY ordering, name' - ; - $db->setQuery($query); - $edits = $db->loadObjectList(); - - // -- Show/Hide -- - - $show_hide = array (JHTML::_('select.option', 1, JText::_('Hide')), JHTML::_('select.option', 0, JText::_('Show')),); - - $show_hide_r = array (JHTML::_('select.option', 0, JText::_('Hide')), JHTML::_('select.option', 1, JText::_('Show')),); - - // -- menu items -- - - $query = 'SELECT id AS value, name AS text FROM #__menu' - .' WHERE ( type="content_section" OR type="components" OR type="content_typed" )' - .' AND published = 1' - .' AND access = 0' - .' ORDER BY name' - ; - $db->setQuery($query); - $menuitems = array_merge($menuitems, $db->loadObjectList()); - - // SITE SETTINGS - $lists['offline'] = JHTML::_('select.booleanlist', 'offline', 'class="inputbox"', $row->offline); - if (!$row->editor) { - $row->editor = ''; - } - // build the html select list - $lists['editor'] = JHTML::_('select.genericlist', $edits, 'editor', 'class="inputbox" size="1"', 'value', 'text', $row->editor); - $listLimit = array (JHTML::_('select.option', 5, 5), JHTML::_('select.option', 10, 10), JHTML::_('select.option', 15, 15), JHTML::_('select.option', 20, 20), JHTML::_('select.option', 25, 25), JHTML::_('select.option', 30, 30), JHTML::_('select.option', 50, 50), JHTML::_('select.option', 100, 100),); - $lists['list_limit'] = JHTML::_('select.genericlist', $listLimit, 'list_limit', 'class="inputbox" size="1"', 'value', 'text', ($row->list_limit ? $row->list_limit : 50)); - - jimport('joomla.language.help'); - $helpsites = array (); - $helpsites = JHelp::createSiteList(JPATH_BASE.DS.'help'.DS.'helpsites-15.xml', $row->helpurl); - array_unshift($helpsites, JHTML::_('select.option', '', JText::_('local'))); - $lists['helpsites'] = JHTML::_('select.genericlist', $helpsites, 'helpurl', ' class="inputbox"', 'value', 'text', $row->helpurl); - - // DEBUG - $lists['debug'] = JHTML::_('select.booleanlist', 'debug', 'class="inputbox"', $row->debug); - $lists['debug_lang'] = JHTML::_('select.booleanlist', 'debug_lang', 'class="inputbox"', $row->debug_lang); - - // DATABASE SETTINGS - - // SERVER SETTINGS - $lists['gzip'] = JHTML::_('select.booleanlist', 'gzip', 'class="inputbox"', $row->gzip); - $errors = array (JHTML::_('select.option', -1, JText::_('System Default')), JHTML::_('select.option', 0, JText::_('None')), JHTML::_('select.option', E_ERROR | E_WARNING | E_PARSE, JText::_('Simple')), JHTML::_('select.option', E_ALL, JText::_('Maximum'))); - $lists['xmlrpc_server'] = JHTML::_('select.booleanlist', 'xmlrpc_server', 'class="inputbox"', $row->xmlrpc_server); - $lists['error_reporting'] = JHTML::_('select.genericlist', $errors, 'error_reporting', 'class="inputbox" size="1"', 'value', 'text', $row->error_reporting); - $lists['enable_ftp'] = JHTML::_('select.booleanlist', 'ftp_enable', 'class="inputbox"', intval($row->ftp_enable)); - - $forceSSL = array( - JHTML::_('select.option', 0, JText::_('None')), - JHTML::_('select.option', 1, JText::_('Administrator Only')), - JHTML::_('select.option', 2, JText::_('Entire Site')), - ); - $lists['force_ssl'] = JHTML::_('select.genericlist', $forceSSL, 'force_ssl', 'class="inputbox" size="1"', 'value', 'text', @$row->force_ssl); - - // LOCALE SETTINGS - $timeoffset = array ( - JHTML::_('select.option', -12, JText::_('(UTC -12:00) International Date Line West')), - JHTML::_('select.option', -11, JText::_('(UTC -11:00) Midway Island, Samoa')), - JHTML::_('select.option', -10, JText::_('(UTC -10:00) Hawaii')), - JHTML::_('select.option', -9.5, JText::_('(UTC -09:30) Taiohae, Marquesas Islands')), - JHTML::_('select.option', -9, JText::_('(UTC -09:00) Alaska')), - JHTML::_('select.option', -8, JText::_('(UTC -08:00) Pacific Time (US & Canada)')), - JHTML::_('select.option', -7, JText::_('(UTC -07:00) Mountain Time (US & Canada)')), - JHTML::_('select.option', -6, JText::_('(UTC -06:00) Central Time (US & Canada), Mexico City')), - JHTML::_('select.option', -5, JText::_('(UTC -05:00) Eastern Time (US & Canada), Bogota, Lima')), - JHTML::_('select.option', -4.5, JText::_('(UTC -04:30) Venezuela')), - JHTML::_('select.option', -4, JText::_('(UTC -04:00) Atlantic Time (Canada), Caracas, La Paz')), - JHTML::_('select.option', -3.5, JText::_('(UTC -03:30) St. John\'s, Newfoundland, Labrador')), - JHTML::_('select.option', -3, JText::_('(UTC -03:00) Brazil, Buenos Aires, Georgetown')), - JHTML::_('select.option', -2, JText::_('(UTC -02:00) Mid-Atlantic')), - JHTML::_('select.option', -1, JText::_('(UTC -01:00) Azores, Cape Verde Islands')), - JHTML::_('select.option', 0, JText::_('(UTC 00:00) Western Europe Time, London, Lisbon, Casablanca')), - JHTML::_('select.option', 1, JText::_('(UTC +01:00) Amsterdam, Berlin, Brussels, Copenhagen, Madrid, Paris')), - JHTML::_('select.option', 2, JText::_('(UTC +02:00) Istanbul, Jerusalem, Kaliningrad, South Africa')), - JHTML::_('select.option', 3, JText::_('(UTC +03:00) Baghdad, Riyadh, Moscow, St. Petersburg')), - JHTML::_('select.option', 3.5, JText::_('(UTC +03:30) Tehran')), - JHTML::_('select.option', 4, JText::_('(UTC +04:00) Abu Dhabi, Muscat, Baku, Tbilisi')), - JHTML::_('select.option', 4.5, JText::_('(UTC +04:30) Kabul')), - JHTML::_('select.option', 5, JText::_('(UTC +05:00) Ekaterinburg, Islamabad, Karachi, Tashkent')), - JHTML::_('select.option', 5.5, JText::_('(UTC +05:30) Bombay, Calcutta, Madras, New Delhi, Colombo')), - JHTML::_('select.option', 5.75, JText::_('(UTC +05:45) Kathmandu')), - JHTML::_('select.option', 6, JText::_('(UTC +06:00) Almaty, Dhaka')), - JHTML::_('select.option', 6.30, JText::_('(UTC +06:30) Yagoon')), - JHTML::_('select.option', 7, JText::_('(UTC +07:00) Bangkok, Hanoi, Jakarta')), - JHTML::_('select.option', 8, JText::_('(UTC +08:00) Beijing, Perth, Singapore, Hong Kong')), - JHTML::_('select.option', 8.75, JText::_('(UTC +08:00) Western Australia')), - JHTML::_('select.option', 9, JText::_('(UTC +09:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk')), - JHTML::_('select.option', 9.5, JText::_('(UTC +09:30) Adelaide, Darwin, Yakutsk')), - JHTML::_('select.option', 10, JText::_('(UTC +10:00) Eastern Australia, Guam, Vladivostok')), - JHTML::_('select.option', 10.5, JText::_('(UTC +10:30) Lord Howe Island (Australia)')), - JHTML::_('select.option', 11, JText::_('(UTC +11:00) Magadan, Solomon Islands, New Caledonia')), - JHTML::_('select.option', 11.30, JText::_('(UTC +11:30) Norfolk Island')), - JHTML::_('select.option', 12, JText::_('(UTC +12:00) Auckland, Wellington, Fiji, Kamchatka')), - JHTML::_('select.option', 12.75, JText::_('(UTC +12:45) Chatham Island')), - JHTML::_('select.option', 13, JText::_('(UTC +13:00) Tonga')), - JHTML::_('select.option', 14, JText::_('(UTC +14:00) Kiribati')),); - $lists['offset'] = JHTML::_('select.genericlist', $timeoffset, 'offset', 'class="inputbox" size="1"', 'value', 'text', $row->offset); - - // MAIL SETTINGS - $mailer = array ( - JHTML::_('select.option', 'mail', JText::_('PHP mail function')), - JHTML::_('select.option', 'sendmail', JText::_('Sendmail')), - JHTML::_('select.option', 'smtp', JText::_('SMTP Server'))); - $lists['mailer'] = JHTML::_('select.genericlist', $mailer, 'mailer', 'class="inputbox" size="1"', 'value', 'text', $row->mailer); - $smtpsecure = array ( - JHTML::_('select.option', 'none', JText::_('None')), - JHTML::_('select.option', 'ssl', 'SSL'), - JHTML::_('select.option', 'tls', 'TLS')); - $lists['smtpsecure'] = JHTML::_('select.genericlist', $smtpsecure, 'smtpsecure', 'class="inputbox" size="1"', 'value', 'text', (isset($row->smtpsecure) ? $row->smtpsecure : '')); - $lists['smtpauth'] = JHTML::_('select.booleanlist', 'smtpauth', 'class="inputbox"', $row->smtpauth); - - // CACHE SETTINGS - $lists['caching'] = JHTML::_('select.booleanlist', 'caching', 'class="inputbox"', $row->caching); - jimport('joomla.cache.cache'); - $stores = JCache::getStores(); - $options = array(); - foreach($stores as $store) { - $options[] = JHTML::_('select.option', $store, JText::_(ucfirst($store)) ); - } - $lists['cache_handlers'] = JHTML::_('select.genericlist', $options, 'cache_handler', 'class="inputbox" size="1"', 'value', 'text', $row->cache_handler); - - // MEMCACHE SETTINGS - if (!empty($row->memcache_settings) && !is_array($row->memcache_settings)) { - $row->memcache_settings = unserialize(stripslashes($row->memcache_settings)); - } - $lists['memcache_persist'] = JHTML::_('select.booleanlist', 'memcache_settings[persistent]', 'class="inputbox"', @$row->memcache_settings['persistent']); - $lists['memcache_compress'] = JHTML::_('select.booleanlist', 'memcache_settings[compression]', 'class="inputbox"', @$row->memcache_settings['compression']); - - // META SETTINGS - $lists['MetaAuthor'] = JHTML::_('select.booleanlist', 'MetaAuthor', 'class="inputbox"', $row->MetaAuthor); - $lists['MetaTitle'] = JHTML::_('select.booleanlist', 'MetaTitle', 'class="inputbox"', $row->MetaTitle); - - // SEO SETTINGS - $lists['sef'] = JHTML::_('select.booleanlist', 'sef', 'class="inputbox"', $row->sef); - $lists['sef_rewrite'] = JHTML::_('select.booleanlist', 'sef_rewrite', 'class="inputbox"', $row->sef_rewrite); - $lists['sef_suffix'] = JHTML::_('select.booleanlist', 'sef_suffix', 'class="inputbox"', $row->sef_suffix); - - // FEED SETTINGS - $formats = array (JHTML::_('select.option', 'RSS2.0', JText::_('RSS')), JHTML::_('select.option', 'Atom', JText::_('Atom'))); - $summary = array (JHTML::_('select.option', 1, JText::_('Full Text')), JHTML::_('select.option', 0, JText::_('Intro Text')),); - $lists['feed_limit'] = JHTML::_('select.genericlist', $listLimit, 'feed_limit', 'class="inputbox" size="1"', 'value', 'text', ($row->feed_limit ? $row->feed_limit : 10)); - $emailOptions = array ( JHTML::_('select.option', 'author', JText::_('Author Email')), - JHTML::_('select.option', 'site', JText::_('Site Email'))); - $lists['feed_email'] = JHTML::_('select.genericlist', $emailOptions, 'feed_email', 'class="inputbox" size="1"', 'value', 'text', (@$row->feed_email) ? $row->feed_email : 'author'); - - // SESSION SETTINGS - $stores = JSession::getStores(); - $options = array(); - foreach($stores as $store) { - $options[] = JHTML::_('select.option', $store, JText::_(ucfirst($store)) ); - } - $lists['session_handlers'] = JHTML::_('select.genericlist', $options, 'session_handler', 'class="inputbox" size="1"', 'value', 'text', $row->session_handler); - - // SHOW EDIT FORM - ConfigApplicationView::showConfig($row, $lists); - } - - /** - * Save the configuration - */ - function save() - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Set FTP credentials, if given - jimport('joomla.client.helper'); - JClientHelper::setCredentialsFromRequest('ftp'); - $ftp = JClientHelper::getCredentials('ftp'); - - //Save user and media manager settings - $table =& JTable::getInstance('component'); - - $userpost['params'] = JRequest::getVar('userparams', array(), 'post', 'array'); - $userpost['option'] = 'com_users'; - $table->loadByOption( 'com_users' ); - $table->bind( $userpost ); - - // pre-save checks - if (!$table->check()) { - JError::raiseWarning( 500, $table->getError() ); - return false; - } - - // save the changes - if (!$table->store()) { - JError::raiseWarning( 500, $table->getError() ); - return false; - } - - $mediapost['params'] = JRequest::getVar('mediaparams', array(), 'post', 'array'); - $mediapost['option'] = 'com_media'; - //Sanitize $file_path and $image_path - $file_path = $mediapost['params']['file_path']; - $image_path = $mediapost['params']['image_path']; - if(strpos($file_path, '/') === 0 || strpos($file_path, '\\') === 0) { - //Leading slash. Kill it and default to /media - $file_path = 'images'; - } - if(strpos($image_path, '/') === 0 || strpos($image_path, '\\') === 0) { - //Leading slash. Kill it and default to /media - $image_path = 'images/stories'; - } - if(strpos($file_path, '..') !== false) { - //downward directories. Kill it and default to images/ - $file_path = 'images'; - } - if(strpos($image_path, '..') !== false) { - //downward directories Kill it and default to images/stories - $image_path = 'images/stories'; - } - $mediapost['params']['file_path'] = $file_path; - $mediapost['params']['image_path'] = $image_path; - - $table->loadByOption( 'com_media' ); - $table->bind( $mediapost ); - - // pre-save checks - if (!$table->check()) { - JError::raiseWarning( 500, $table->getError() ); - return false; - } - - // save the changes - if (!$table->store()) { - JError::raiseWarning( 500, $table->getError() ); - return false; - } - - $config = new JRegistry('config'); - $config_array = array(); - - // SITE SETTINGS - $config_array['offline'] = JRequest::getVar('offline', 0, 'post', 'int'); - $config_array['editor'] = JRequest::getVar('editor', 'tinymce', 'post', 'cmd'); - $config_array['list_limit'] = JRequest::getVar('list_limit', 20, 'post', 'int'); - $config_array['helpurl'] = JRequest::getVar('helpurl', 'http://help.joomla.org', 'post', 'string'); - - // DEBUG - $config_array['debug'] = JRequest::getVar('debug', 0, 'post', 'int'); - $config_array['debug_lang'] = JRequest::getVar('debug_lang', 0, 'post', 'int'); - - // SEO SETTINGS - $config_array['sef'] = JRequest::getVar('sef', 0, 'post', 'int'); - $config_array['sef_rewrite'] = JRequest::getVar('sef_rewrite', 0, 'post', 'int'); - $config_array['sef_suffix'] = JRequest::getVar('sef_suffix', 0, 'post', 'int'); - - // FEED SETTINGS - $config_array['feed_limit'] = JRequest::getVar('feed_limit', 10, 'post', 'int'); - $config_array['feed_email'] = JRequest::getVar('feed_email', 'author', 'post', 'word'); - - // SERVER SETTINGS - $config_array['secret'] = JRequest::getVar('secret', 0, 'post', 'string'); - $config_array['gzip'] = JRequest::getVar('gzip', 0, 'post', 'int'); - $config_array['error_reporting'] = JRequest::getVar('error_reporting', -1, 'post', 'int'); - $config_array['xmlrpc_server'] = JRequest::getVar('xmlrpc_server', 0, 'post', 'int'); - $config_array['log_path'] = JRequest::getVar('log_path', JPATH_ROOT.DS.'logs', 'post', 'string'); - $config_array['tmp_path'] = JRequest::getVar('tmp_path', JPATH_ROOT.DS.'tmp', 'post', 'string'); - $config_array['live_site'] = rtrim(JRequest::getVar('live_site','','post','string'), '/\\'); - $config_array['force_ssl'] = JRequest::getVar('force_ssl', 0, 'post', 'int'); - - // LOCALE SETTINGS - $config_array['offset'] = JRequest::getVar('offset', 0, 'post', 'float'); - - // CACHE SETTINGS - $config_array['caching'] = JRequest::getVar('caching', 0, 'post', 'int'); - $config_array['cachetime'] = JRequest::getVar('cachetime', 900, 'post', 'int'); - $config_array['cache_handler'] = JRequest::getVar('cache_handler', 'file', 'post', 'word'); - $config_array['memcache_settings'] = JRequest::getVar('memcache_settings', array(), 'post'); - - // FTP SETTINGS - $config_array['ftp_enable'] = JRequest::getVar('ftp_enable', 0, 'post', 'int'); - $config_array['ftp_host'] = JRequest::getVar('ftp_host', '', 'post', 'string'); - $config_array['ftp_port'] = JRequest::getVar('ftp_port', '', 'post', 'int'); - $config_array['ftp_user'] = JRequest::getVar('ftp_user', '', 'post', 'string'); - $config_array['ftp_pass'] = JRequest::getVar('ftp_pass', '', 'post', 'string', JREQUEST_ALLOWRAW); - $config_array['ftp_root'] = JRequest::getVar('ftp_root', '', 'post', 'string'); - - // DATABASE SETTINGS - $config_array['dbtype'] = JRequest::getVar('dbtype', 'mysql', 'post', 'word'); - $config_array['host'] = JRequest::getVar('host', 'localhost', 'post', 'string'); - $config_array['user'] = JRequest::getVar('user', '', 'post', 'string'); - $config_array['db'] = JRequest::getVar('db', '', 'post', 'string'); - $config_array['dbprefix'] = JRequest::getVar('dbprefix', 'jos_', 'post', 'string'); - - // MAIL SETTINGS - $config_array['mailer'] = JRequest::getVar('mailer', 'mail', 'post', 'word'); - $config_array['mailfrom'] = JRequest::getVar('mailfrom', '', 'post', 'string'); - $config_array['fromname'] = JRequest::getVar('fromname', 'Joomla 1.5', 'post', 'string'); - $config_array['sendmail'] = JRequest::getVar('sendmail', '/usr/sbin/sendmail', 'post', 'string'); - $config_array['smtpauth'] = JRequest::getVar('smtpauth', 0, 'post', 'int'); - $config_array['smtpsecure'] = JRequest::getVar('smtpsecure', 'none', 'post', 'word'); - $smtpport = JRequest::getVar('smtpport', '', 'post', 'int'); - $config_array['smtpport'] = $smtpport ? $smtpport : '25'; - $config_array['smtpuser'] = JRequest::getVar('smtpuser', '', 'post', 'string'); - $config_array['smtppass'] = JRequest::getVar('smtppass', '', 'post', 'string', JREQUEST_ALLOWRAW); - $config_array['smtphost'] = JRequest::getVar('smtphost', '', 'post', 'string'); - - // META SETTINGS - $config_array['MetaAuthor'] = JRequest::getVar('MetaAuthor', 1, 'post', 'int'); - $config_array['MetaTitle'] = JRequest::getVar('MetaTitle', 1, 'post', 'int'); - - // SESSION SETTINGS - $config_array['lifetime'] = JRequest::getVar('lifetime', 0, 'post', 'int'); - $config_array['session_handler'] = JRequest::getVar('session_handler', 'none', 'post', 'word'); - - //LANGUAGE SETTINGS - //$config_array['lang'] = JRequest::getVar('lang', 'none', 'english', 'cmd'); - //$config_array['language'] = JRequest::getVar('language', 'en-GB', 'post', 'cmd'); - - $config->loadArray($config_array); - - //override any possible database password change - $config->setValue('config.password', $mainframe->getCfg('password')); - - // handling of special characters - $sitename = htmlspecialchars( JRequest::getVar( 'sitename', '', 'post', 'string' ), ENT_COMPAT, 'UTF-8' ); - $config->setValue('config.sitename', $sitename); - - $MetaDesc = htmlspecialchars( JRequest::getVar( 'MetaDesc', '', 'post', 'string' ), ENT_COMPAT, 'UTF-8' ); - $config->setValue('config.MetaDesc', $MetaDesc); - - $MetaKeys = htmlspecialchars( JRequest::getVar( 'MetaKeys', '', 'post', 'string' ), ENT_COMPAT, 'UTF-8' ); - $config->setValue('config.MetaKeys', $MetaKeys); - - // handling of quotes (double and single) and amp characters - // htmlspecialchars not used to preserve ability to insert other html characters - $offline_message = JRequest::getVar( 'offline_message', '', 'post', 'string' ); - $offline_message = JFilterOutput::ampReplace( $offline_message ); - $offline_message = str_replace( '"', '"', $offline_message ); - $offline_message = str_replace( "'", ''', $offline_message ); - $config->setValue('config.offline_message', $offline_message); - - //purge the database session table (only if we are changing to a db session store) - if($mainframe->getCfg('session_handler') != 'database' && $config->getValue('session_handler') == 'database') - { - $table =& JTable::getInstance('session'); - $table->purge(-1); - } - - // Get the path of the configuration file - $fname = JPATH_CONFIGURATION.DS.'configuration.php'; - - // Update the credentials with the new settings - $oldconfig =& JFactory::getConfig(); - $oldconfig->setValue('config.ftp_enable', $config_array['ftp_enable']); - $oldconfig->setValue('config.ftp_host', $config_array['ftp_host']); - $oldconfig->setValue('config.ftp_port', $config_array['ftp_port']); - $oldconfig->setValue('config.ftp_user', $config_array['ftp_user']); - $oldconfig->setValue('config.ftp_pass', $config_array['ftp_pass']); - $oldconfig->setValue('config.ftp_root', $config_array['ftp_root']); - JClientHelper::getCredentials('ftp', true); - - if(!$config->get('caching') && $oldconfig->get('caching')) { - $cache = JFactory::getCache(); - $cache->clean(); - } - - // Try to make configuration.php writeable - jimport('joomla.filesystem.path'); - if (!$ftp['enabled'] && JPath::isOwner($fname) && !JPath::setPermissions($fname, '0644')) { - JError::raiseNotice('SOME_ERROR_CODE', 'Could not make configuration.php writable'); - } - - // Get the config registry in PHP class format and write it to configuation.php - jimport('joomla.filesystem.file'); - if (JFile::write($fname, $config->toString('PHP', 'config', array('class' => 'JConfig')))) { - $msg = JText::_('The Configuration Details have been updated'); - } else { - $msg = JText::_('ERRORCONFIGFILE'); - } - - // Redirect appropriately - $task = $this->getTask(); - switch ($task) { - case 'apply' : - $this->setRedirect('index.php?option=com_config', $msg); - break; - - case 'save' : - default : - $this->setRedirect('index.php', $msg); - break; - } - - // Try to make configuration.php unwriteable - //if (!$ftp['enabled'] && JPath::isOwner($fname) && !JPath::setPermissions($fname, '0444')) { - if ($config_array['ftp_enable']==0 && !$ftp['enabled'] && JPath::isOwner($fname) && !JPath::setPermissions($fname, '0444')) { - JError::raiseNotice('SOME_ERROR_CODE', 'Could not make configuration.php unwritable'); - } - } - - /** - * Cancel operation - */ - function cancel() - { - // Set FTP credentials, if given - jimport('joomla.client.helper'); - JClientHelper::setCredentialsFromRequest('ftp'); - - $this->setRedirect( 'index.php' ); - } - - function refreshHelp() - { - jimport('joomla.filesystem.file'); - - // Set FTP credentials, if given - jimport('joomla.client.helper'); - JClientHelper::setCredentialsFromRequest('ftp'); - - if (($data = file_get_contents('http://help.joomla.org/helpsites-15.xml')) === false ) { - $this->setRedirect('index.php?option=com_config', JText::_('HELPREFRESH ERROR FETCH'), 'error'); - } else if (!JFile::write(JPATH_BASE.DS.'help'.DS.'helpsites-15.xml', $data)) { - $this->setRedirect('index.php?option=com_config', JText::_('HELPREFRESH ERROR STORE'), 'error'); - } else { - $this->setRedirect('index.php?option=com_config', JText::_('HELPREFRESH SUCCESS')); - } - } -} +registerTask( 'apply', 'save' ); + } + + /** + * Show the configuration edit form + * @param string The URL option + */ + function showConfig() + { + // Initialize some variables + $db =& JFactory::getDBO(); + $row = new JConfig(); + + // compile list of the languages + $langs = array (); + $menuitems = array (); + $lists = array (); + + // PRE-PROCESS SOME LIST + + // -- Editors -- + + // compile list of the editors + $query = 'SELECT element AS value, name AS text' + .' FROM #__plugins' + .' WHERE folder = "editors"' + .' AND published = 1' + .' ORDER BY ordering, name' + ; + $db->setQuery($query); + $edits = $db->loadObjectList(); + + // -- Show/Hide -- + + $show_hide = array (JHTML::_('select.option', 1, JText::_('Hide')), JHTML::_('select.option', 0, JText::_('Show')),); + + $show_hide_r = array (JHTML::_('select.option', 0, JText::_('Hide')), JHTML::_('select.option', 1, JText::_('Show')),); + + // -- menu items -- + + $query = 'SELECT id AS value, name AS text FROM #__menu' + .' WHERE ( type="content_section" OR type="components" OR type="content_typed" )' + .' AND published = 1' + .' AND access = 0' + .' ORDER BY name' + ; + $db->setQuery($query); + $menuitems = array_merge($menuitems, $db->loadObjectList()); + + // SITE SETTINGS + $lists['offline'] = JHTML::_('select.booleanlist', 'offline', 'class="inputbox"', $row->offline); + if (!$row->editor) { + $row->editor = ''; + } + // build the html select list + $lists['editor'] = JHTML::_('select.genericlist', $edits, 'editor', 'class="inputbox" size="1"', 'value', 'text', $row->editor); + $listLimit = array (JHTML::_('select.option', 5, 5), JHTML::_('select.option', 10, 10), JHTML::_('select.option', 15, 15), JHTML::_('select.option', 20, 20), JHTML::_('select.option', 25, 25), JHTML::_('select.option', 30, 30), JHTML::_('select.option', 50, 50), JHTML::_('select.option', 100, 100),); + $lists['list_limit'] = JHTML::_('select.genericlist', $listLimit, 'list_limit', 'class="inputbox" size="1"', 'value', 'text', ($row->list_limit ? $row->list_limit : 50)); + + jimport('joomla.language.help'); + $helpsites = array (); + $helpsites = JHelp::createSiteList(JPATH_BASE.DS.'help'.DS.'helpsites-15.xml', $row->helpurl); + array_unshift($helpsites, JHTML::_('select.option', '', JText::_('local'))); + $lists['helpsites'] = JHTML::_('select.genericlist', $helpsites, 'helpurl', ' class="inputbox"', 'value', 'text', $row->helpurl); + + // DEBUG + $lists['debug'] = JHTML::_('select.booleanlist', 'debug', 'class="inputbox"', $row->debug); + $lists['debug_lang'] = JHTML::_('select.booleanlist', 'debug_lang', 'class="inputbox"', $row->debug_lang); + + // DATABASE SETTINGS + + // SERVER SETTINGS + $lists['gzip'] = JHTML::_('select.booleanlist', 'gzip', 'class="inputbox"', $row->gzip); + $errors = array (JHTML::_('select.option', -1, JText::_('System Default')), JHTML::_('select.option', 0, JText::_('None')), JHTML::_('select.option', E_ERROR | E_WARNING | E_PARSE, JText::_('Simple')), JHTML::_('select.option', E_ALL, JText::_('Maximum'))); + $lists['xmlrpc_server'] = JHTML::_('select.booleanlist', 'xmlrpc_server', 'class="inputbox"', $row->xmlrpc_server); + $lists['error_reporting'] = JHTML::_('select.genericlist', $errors, 'error_reporting', 'class="inputbox" size="1"', 'value', 'text', $row->error_reporting); + $lists['enable_ftp'] = JHTML::_('select.booleanlist', 'ftp_enable', 'class="inputbox"', intval($row->ftp_enable)); + + $forceSSL = array( + JHTML::_('select.option', 0, JText::_('None')), + JHTML::_('select.option', 1, JText::_('Administrator Only')), + JHTML::_('select.option', 2, JText::_('Entire Site')), + ); + $lists['force_ssl'] = JHTML::_('select.genericlist', $forceSSL, 'force_ssl', 'class="inputbox" size="1"', 'value', 'text', @$row->force_ssl); + + // LOCALE SETTINGS + $timeoffset = array ( + JHTML::_('select.option', -12, JText::_('(UTC -12:00) International Date Line West')), + JHTML::_('select.option', -11, JText::_('(UTC -11:00) Midway Island, Samoa')), + JHTML::_('select.option', -10, JText::_('(UTC -10:00) Hawaii')), + JHTML::_('select.option', -9.5, JText::_('(UTC -09:30) Taiohae, Marquesas Islands')), + JHTML::_('select.option', -9, JText::_('(UTC -09:00) Alaska')), + JHTML::_('select.option', -8, JText::_('(UTC -08:00) Pacific Time (US & Canada)')), + JHTML::_('select.option', -7, JText::_('(UTC -07:00) Mountain Time (US & Canada)')), + JHTML::_('select.option', -6, JText::_('(UTC -06:00) Central Time (US & Canada), Mexico City')), + JHTML::_('select.option', -5, JText::_('(UTC -05:00) Eastern Time (US & Canada), Bogota, Lima')), + JHTML::_('select.option', -4.5, JText::_('(UTC -04:30) Venezuela')), + JHTML::_('select.option', -4, JText::_('(UTC -04:00) Atlantic Time (Canada), Caracas, La Paz')), + JHTML::_('select.option', -3.5, JText::_('(UTC -03:30) St. John\'s, Newfoundland, Labrador')), + JHTML::_('select.option', -3, JText::_('(UTC -03:00) Brazil, Buenos Aires, Georgetown')), + JHTML::_('select.option', -2, JText::_('(UTC -02:00) Mid-Atlantic')), + JHTML::_('select.option', -1, JText::_('(UTC -01:00) Azores, Cape Verde Islands')), + JHTML::_('select.option', 0, JText::_('(UTC 00:00) Western Europe Time, London, Lisbon, Casablanca')), + JHTML::_('select.option', 1, JText::_('(UTC +01:00) Amsterdam, Berlin, Brussels, Copenhagen, Madrid, Paris')), + JHTML::_('select.option', 2, JText::_('(UTC +02:00) Istanbul, Jerusalem, Kaliningrad, South Africa')), + JHTML::_('select.option', 3, JText::_('(UTC +03:00) Baghdad, Riyadh, Moscow, St. Petersburg')), + JHTML::_('select.option', 3.5, JText::_('(UTC +03:30) Tehran')), + JHTML::_('select.option', 4, JText::_('(UTC +04:00) Abu Dhabi, Muscat, Baku, Tbilisi')), + JHTML::_('select.option', 4.5, JText::_('(UTC +04:30) Kabul')), + JHTML::_('select.option', 5, JText::_('(UTC +05:00) Ekaterinburg, Islamabad, Karachi, Tashkent')), + JHTML::_('select.option', 5.5, JText::_('(UTC +05:30) Bombay, Calcutta, Madras, New Delhi, Colombo')), + JHTML::_('select.option', 5.75, JText::_('(UTC +05:45) Kathmandu')), + JHTML::_('select.option', 6, JText::_('(UTC +06:00) Almaty, Dhaka')), + JHTML::_('select.option', 6.5, JText::_('(UTC +06:30) Yagoon')), + JHTML::_('select.option', 7, JText::_('(UTC +07:00) Bangkok, Hanoi, Jakarta')), + JHTML::_('select.option', 8, JText::_('(UTC +08:00) Beijing, Perth, Singapore, Hong Kong')), + JHTML::_('select.option', 8.75, JText::_('(UTC +08:00) Ulaanbaatar, Western Australia')), + JHTML::_('select.option', 9, JText::_('(UTC +09:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk')), + JHTML::_('select.option', 9.5, JText::_('(UTC +09:30) Adelaide, Darwin, Yakutsk')), + JHTML::_('select.option', 10, JText::_('(UTC +10:00) Eastern Australia, Guam, Vladivostok')), + JHTML::_('select.option', 10.5, JText::_('(UTC +10:30) Lord Howe Island (Australia)')), + JHTML::_('select.option', 11, JText::_('(UTC +11:00) Magadan, Solomon Islands, New Caledonia')), + JHTML::_('select.option', 11.5, JText::_('(UTC +11:30) Norfolk Island')), + JHTML::_('select.option', 12, JText::_('(UTC +12:00) Auckland, Wellington, Fiji, Kamchatka')), + JHTML::_('select.option', 12.75, JText::_('(UTC +12:45) Chatham Island')), + JHTML::_('select.option', 13, JText::_('(UTC +13:00) Tonga')), + JHTML::_('select.option', 14, JText::_('(UTC +14:00) Kiribati')),); + $lists['offset'] = JHTML::_('select.genericlist', $timeoffset, 'offset', 'class="inputbox" size="1"', 'value', 'text', $row->offset); + + // MAIL SETTINGS + $mailer = array ( + JHTML::_('select.option', 'mail', JText::_('PHP mail function')), + JHTML::_('select.option', 'sendmail', JText::_('Sendmail')), + JHTML::_('select.option', 'smtp', JText::_('SMTP Server'))); + $lists['mailer'] = JHTML::_('select.genericlist', $mailer, 'mailer', 'class="inputbox" size="1"', 'value', 'text', $row->mailer); + $smtpsecure = array ( + JHTML::_('select.option', 'none', JText::_('None')), + JHTML::_('select.option', 'ssl', 'SSL'), + JHTML::_('select.option', 'tls', 'TLS')); + $lists['smtpsecure'] = JHTML::_('select.genericlist', $smtpsecure, 'smtpsecure', 'class="inputbox" size="1"', 'value', 'text', (isset($row->smtpsecure) ? $row->smtpsecure : '')); + $lists['smtpauth'] = JHTML::_('select.booleanlist', 'smtpauth', 'class="inputbox"', $row->smtpauth); + + // CACHE SETTINGS + $lists['caching'] = JHTML::_('select.booleanlist', 'caching', 'class="inputbox"', $row->caching); + jimport('joomla.cache.cache'); + $stores = JCache::getStores(); + $options = array(); + foreach($stores as $store) { + $options[] = JHTML::_('select.option', $store, JText::_(ucfirst($store)) ); + } + $lists['cache_handlers'] = JHTML::_('select.genericlist', $options, 'cache_handler', 'class="inputbox" size="1"', 'value', 'text', $row->cache_handler); + + // MEMCACHE SETTINGS + if (!empty($row->memcache_settings) && !is_array($row->memcache_settings)) { + $row->memcache_settings = unserialize(stripslashes($row->memcache_settings)); + } + $lists['memcache_persist'] = JHTML::_('select.booleanlist', 'memcache_settings[persistent]', 'class="inputbox"', @$row->memcache_settings['persistent']); + $lists['memcache_compress'] = JHTML::_('select.booleanlist', 'memcache_settings[compression]', 'class="inputbox"', @$row->memcache_settings['compression']); + + // META SETTINGS + $lists['MetaAuthor'] = JHTML::_('select.booleanlist', 'MetaAuthor', 'class="inputbox"', $row->MetaAuthor); + $lists['MetaTitle'] = JHTML::_('select.booleanlist', 'MetaTitle', 'class="inputbox"', $row->MetaTitle); + + // SEO SETTINGS + $lists['sef'] = JHTML::_('select.booleanlist', 'sef', 'class="inputbox"', $row->sef); + $lists['sef_rewrite'] = JHTML::_('select.booleanlist', 'sef_rewrite', 'class="inputbox"', $row->sef_rewrite); + $lists['sef_suffix'] = JHTML::_('select.booleanlist', 'sef_suffix', 'class="inputbox"', $row->sef_suffix); + + // FEED SETTINGS + $formats = array (JHTML::_('select.option', 'RSS2.0', JText::_('RSS')), JHTML::_('select.option', 'Atom', JText::_('Atom'))); + $summary = array (JHTML::_('select.option', 1, JText::_('Full Text')), JHTML::_('select.option', 0, JText::_('Intro Text')),); + $lists['feed_limit'] = JHTML::_('select.genericlist', $listLimit, 'feed_limit', 'class="inputbox" size="1"', 'value', 'text', ($row->feed_limit ? $row->feed_limit : 10)); + $emailOptions = array ( JHTML::_('select.option', 'author', JText::_('Author Email')), + JHTML::_('select.option', 'site', JText::_('Site Email'))); + $lists['feed_email'] = JHTML::_('select.genericlist', $emailOptions, 'feed_email', 'class="inputbox" size="1"', 'value', 'text', (@$row->feed_email) ? $row->feed_email : 'author'); + + // SESSION SETTINGS + $stores = JSession::getStores(); + $options = array(); + foreach($stores as $store) { + $options[] = JHTML::_('select.option', $store, JText::_(ucfirst($store)) ); + } + $lists['session_handlers'] = JHTML::_('select.genericlist', $options, 'session_handler', 'class="inputbox" size="1"', 'value', 'text', $row->session_handler); + + // SHOW EDIT FORM + ConfigApplicationView::showConfig($row, $lists); + } + + /** + * Save the configuration + */ + function save() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Set FTP credentials, if given + jimport('joomla.client.helper'); + JClientHelper::setCredentialsFromRequest('ftp'); + $ftp = JClientHelper::getCredentials('ftp'); + + //Save user and media manager settings + $table =& JTable::getInstance('component'); + + $userpost['params'] = JRequest::getVar('userparams', array(), 'post', 'array'); + $userpost['option'] = 'com_users'; + $table->loadByOption( 'com_users' ); + $table->bind( $userpost ); + + // pre-save checks + if (!$table->check()) { + JError::raiseWarning( 500, $table->getError() ); + return false; + } + + // save the changes + if (!$table->store()) { + JError::raiseWarning( 500, $table->getError() ); + return false; + } + + $mediapost['params'] = JRequest::getVar('mediaparams', array(), 'post', 'array'); + $mediapost['option'] = 'com_media'; + //Sanitize $file_path and $image_path + $file_path = $mediapost['params']['file_path']; + $image_path = $mediapost['params']['image_path']; + if(strpos($file_path, '/') === 0 || strpos($file_path, '\\') === 0) { + //Leading slash. Kill it and default to /media + $file_path = 'images'; + } + if(strpos($image_path, '/') === 0 || strpos($image_path, '\\') === 0) { + //Leading slash. Kill it and default to /media + $image_path = 'images/stories'; + } + if(strpos($file_path, '..') !== false) { + //downward directories. Kill it and default to images/ + $file_path = 'images'; + } + if(strpos($image_path, '..') !== false) { + //downward directories Kill it and default to images/stories + $image_path = 'images/stories'; + } + $mediapost['params']['file_path'] = $file_path; + $mediapost['params']['image_path'] = $image_path; + + $table->loadByOption( 'com_media' ); + $table->bind( $mediapost ); + + // pre-save checks + if (!$table->check()) { + JError::raiseWarning( 500, $table->getError() ); + return false; + } + + // save the changes + if (!$table->store()) { + JError::raiseWarning( 500, $table->getError() ); + return false; + } + + $config = new JRegistry('config'); + $config_array = array(); + + // SITE SETTINGS + $config_array['offline'] = JRequest::getVar('offline', 0, 'post', 'int'); + $config_array['editor'] = JRequest::getVar('editor', 'tinymce', 'post', 'cmd'); + $config_array['list_limit'] = JRequest::getVar('list_limit', 20, 'post', 'int'); + $config_array['helpurl'] = JRequest::getVar('helpurl', 'http://help.joomla.org', 'post', 'string'); + + // DEBUG + $config_array['debug'] = JRequest::getVar('debug', 0, 'post', 'int'); + $config_array['debug_lang'] = JRequest::getVar('debug_lang', 0, 'post', 'int'); + + // SEO SETTINGS + $config_array['sef'] = JRequest::getVar('sef', 0, 'post', 'int'); + $config_array['sef_rewrite'] = JRequest::getVar('sef_rewrite', 0, 'post', 'int'); + $config_array['sef_suffix'] = JRequest::getVar('sef_suffix', 0, 'post', 'int'); + + // FEED SETTINGS + $config_array['feed_limit'] = JRequest::getVar('feed_limit', 10, 'post', 'int'); + $config_array['feed_email'] = JRequest::getVar('feed_email', 'author', 'post', 'word'); + + // SERVER SETTINGS + $config_array['secret'] = JRequest::getVar('secret', 0, 'post', 'string'); + $config_array['gzip'] = JRequest::getVar('gzip', 0, 'post', 'int'); + $config_array['error_reporting'] = JRequest::getVar('error_reporting', -1, 'post', 'int'); + $config_array['xmlrpc_server'] = JRequest::getVar('xmlrpc_server', 0, 'post', 'int'); + $config_array['log_path'] = JRequest::getVar('log_path', JPATH_ROOT.DS.'logs', 'post', 'string'); + $config_array['tmp_path'] = JRequest::getVar('tmp_path', JPATH_ROOT.DS.'tmp', 'post', 'string'); + $config_array['live_site'] = rtrim(JRequest::getVar('live_site','','post','string'), '/\\'); + $config_array['force_ssl'] = JRequest::getVar('force_ssl', 0, 'post', 'int'); + + // LOCALE SETTINGS + $config_array['offset'] = JRequest::getVar('offset', 0, 'post', 'float'); + + // CACHE SETTINGS + $config_array['caching'] = JRequest::getVar('caching', 0, 'post', 'int'); + $config_array['cachetime'] = JRequest::getVar('cachetime', 900, 'post', 'int'); + $config_array['cache_handler'] = JRequest::getVar('cache_handler', 'file', 'post', 'word'); + $config_array['memcache_settings'] = JRequest::getVar('memcache_settings', array(), 'post'); + + // FTP SETTINGS + $config_array['ftp_enable'] = JRequest::getVar('ftp_enable', 0, 'post', 'int'); + $config_array['ftp_host'] = JRequest::getVar('ftp_host', '', 'post', 'string'); + $config_array['ftp_port'] = JRequest::getVar('ftp_port', '', 'post', 'int'); + $config_array['ftp_user'] = JRequest::getVar('ftp_user', '', 'post', 'string'); + $config_array['ftp_pass'] = JRequest::getVar('ftp_pass', '', 'post', 'string', JREQUEST_ALLOWRAW); + $config_array['ftp_root'] = JRequest::getVar('ftp_root', '', 'post', 'string'); + + // DATABASE SETTINGS + $config_array['dbtype'] = JRequest::getVar('dbtype', 'mysql', 'post', 'word'); + $config_array['host'] = JRequest::getVar('host', 'localhost', 'post', 'string'); + $config_array['user'] = JRequest::getVar('user', '', 'post', 'string'); + $config_array['db'] = JRequest::getVar('db', '', 'post', 'string'); + $config_array['dbprefix'] = JRequest::getVar('dbprefix', 'jos_', 'post', 'string'); + + // MAIL SETTINGS + $config_array['mailer'] = JRequest::getVar('mailer', 'mail', 'post', 'word'); + $config_array['mailfrom'] = JRequest::getVar('mailfrom', '', 'post', 'string'); + $config_array['fromname'] = JRequest::getVar('fromname', 'Joomla 1.5', 'post', 'string'); + $config_array['sendmail'] = JRequest::getVar('sendmail', '/usr/sbin/sendmail', 'post', 'string'); + $config_array['smtpauth'] = JRequest::getVar('smtpauth', 0, 'post', 'int'); + $config_array['smtpsecure'] = JRequest::getVar('smtpsecure', 'none', 'post', 'word'); + $smtpport = JRequest::getVar('smtpport', '', 'post', 'int'); + $config_array['smtpport'] = $smtpport ? $smtpport : '25'; + $config_array['smtpuser'] = JRequest::getVar('smtpuser', '', 'post', 'string'); + $config_array['smtppass'] = JRequest::getVar('smtppass', '', 'post', 'string', JREQUEST_ALLOWRAW); + $config_array['smtphost'] = JRequest::getVar('smtphost', '', 'post', 'string'); + + // META SETTINGS + $config_array['MetaAuthor'] = JRequest::getVar('MetaAuthor', 1, 'post', 'int'); + $config_array['MetaTitle'] = JRequest::getVar('MetaTitle', 1, 'post', 'int'); + + // SESSION SETTINGS + $config_array['lifetime'] = JRequest::getVar('lifetime', 0, 'post', 'int'); + $config_array['session_handler'] = JRequest::getVar('session_handler', 'none', 'post', 'word'); + + //LANGUAGE SETTINGS + //$config_array['lang'] = JRequest::getVar('lang', 'none', 'english', 'cmd'); + //$config_array['language'] = JRequest::getVar('language', 'en-GB', 'post', 'cmd'); + + $config->loadArray($config_array); + + //override any possible database password change + $config->setValue('config.password', $mainframe->getCfg('password')); + + // handling of special characters + $sitename = htmlspecialchars( JRequest::getVar( 'sitename', '', 'post', 'string' ), ENT_COMPAT, 'UTF-8' ); + $config->setValue('config.sitename', $sitename); + + $MetaDesc = htmlspecialchars( JRequest::getVar( 'MetaDesc', '', 'post', 'string' ), ENT_COMPAT, 'UTF-8' ); + $config->setValue('config.MetaDesc', $MetaDesc); + + $MetaKeys = htmlspecialchars( JRequest::getVar( 'MetaKeys', '', 'post', 'string' ), ENT_COMPAT, 'UTF-8' ); + $config->setValue('config.MetaKeys', $MetaKeys); + + // handling of quotes (double and single) and amp characters + // htmlspecialchars not used to preserve ability to insert other html characters + $offline_message = JRequest::getVar( 'offline_message', '', 'post', 'string' ); + $offline_message = JFilterOutput::ampReplace( $offline_message ); + $offline_message = str_replace( '"', '"', $offline_message ); + $offline_message = str_replace( "'", ''', $offline_message ); + $config->setValue('config.offline_message', $offline_message); + + //purge the database session table (only if we are changing to a db session store) + if($mainframe->getCfg('session_handler') != 'database' && $config->getValue('session_handler') == 'database') + { + $table =& JTable::getInstance('session'); + $table->purge(-1); + } + + // Get the path of the configuration file + $fname = JPATH_CONFIGURATION.DS.'configuration.php'; + + // Update the credentials with the new settings + $oldconfig =& JFactory::getConfig(); + $oldconfig->setValue('config.ftp_enable', $config_array['ftp_enable']); + $oldconfig->setValue('config.ftp_host', $config_array['ftp_host']); + $oldconfig->setValue('config.ftp_port', $config_array['ftp_port']); + $oldconfig->setValue('config.ftp_user', $config_array['ftp_user']); + $oldconfig->setValue('config.ftp_pass', $config_array['ftp_pass']); + $oldconfig->setValue('config.ftp_root', $config_array['ftp_root']); + JClientHelper::getCredentials('ftp', true); + + if(!$config->get('caching') && $oldconfig->get('caching')) { + $cache = JFactory::getCache(); + $cache->clean(); + } + + // Try to make configuration.php writeable + jimport('joomla.filesystem.path'); + if (!$ftp['enabled'] && JPath::isOwner($fname) && !JPath::setPermissions($fname, '0644')) { + JError::raiseNotice('SOME_ERROR_CODE', 'Could not make configuration.php writable'); + } + + // Get the config registry in PHP class format and write it to configuation.php + jimport('joomla.filesystem.file'); + if (JFile::write($fname, $config->toString('PHP', 'config', array('class' => 'JConfig')))) { + $msg = JText::_('The Configuration Details have been updated'); + } else { + $msg = JText::_('ERRORCONFIGFILE'); + } + + // Redirect appropriately + $task = $this->getTask(); + switch ($task) { + case 'apply' : + $this->setRedirect('index.php?option=com_config', $msg); + break; + + case 'save' : + default : + $this->setRedirect('index.php', $msg); + break; + } + + // Try to make configuration.php unwriteable + //if (!$ftp['enabled'] && JPath::isOwner($fname) && !JPath::setPermissions($fname, '0444')) { + if ($config_array['ftp_enable']==0 && !$ftp['enabled'] && JPath::isOwner($fname) && !JPath::setPermissions($fname, '0444')) { + JError::raiseNotice('SOME_ERROR_CODE', 'Could not make configuration.php unwritable'); + } + } + + /** + * Cancel operation + */ + function cancel() + { + // Set FTP credentials, if given + jimport('joomla.client.helper'); + JClientHelper::setCredentialsFromRequest('ftp'); + + $this->setRedirect( 'index.php' ); + } + + function refreshHelp() + { + jimport('joomla.filesystem.file'); + + // Set FTP credentials, if given + jimport('joomla.client.helper'); + JClientHelper::setCredentialsFromRequest('ftp'); + + if (($data = file_get_contents('http://help.joomla.org/helpsites-15.xml')) === false ) { + $this->setRedirect('index.php?option=com_config', JText::_('HELPREFRESH ERROR FETCH'), 'error'); + } else if (!JFile::write(JPATH_BASE.DS.'help'.DS.'helpsites-15.xml', $data)) { + $this->setRedirect('index.php?option=com_config', JText::_('HELPREFRESH ERROR STORE'), 'error'); + } else { + $this->setRedirect('index.php?option=com_config', JText::_('HELPREFRESH SUCCESS')); + } + } +} diff --git a/oss/joomla/trunk/administrator/components/com_config/controllers/component.php b/oss/joomla/trunk/administrator/components/com_config/controllers/component.php index ecf2bada..879addc1 100644 --- a/oss/joomla/trunk/administrator/components/com_config/controllers/component.php +++ b/oss/joomla/trunk/administrator/components/com_config/controllers/component.php @@ -1,116 +1,116 @@ -registerTask( 'apply', 'save' ); - } - - /** - * Show the configuration edit form - * @param string The URL option - */ - function edit() - { - JRequest::setVar('tmpl', 'component'); //force the component template - $component = JRequest::getCmd( 'component' ); - - if (empty( $component )) - { - JError::raiseWarning( 500, 'Not a valid component' ); - return false; - } - - // load the component's language file - $lang = & JFactory::getLanguage(); - $lang->load( $component ); - - $model = $this->getModel('Component' ); - $table =& JTable::getInstance('component'); - - if (!$table->loadByOption( $component )) - { - JError::raiseWarning( 500, 'Not a valid component' ); - return false; - } - - $view = new ConfigViewComponent( ); - $view->assignRef('component', $table); - $view->setModel( $model, true ); - $view->display(); - } - - /** - * Save the configuration - */ - function save() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $component = JRequest::getCmd( 'component' ); - - $table =& JTable::getInstance('component'); - if (!$table->loadByOption( $component )) - { - JError::raiseWarning( 500, 'Not a valid component' ); - return false; - } - - $post = JRequest::get( 'post' ); - $post['option'] = $component; - $table->bind( $post ); - - // pre-save checks - if (!$table->check()) { - JError::raiseWarning( 500, $table->getError() ); - return false; - } - - // save the changes - if (!$table->store()) { - JError::raiseWarning( 500, $table->getError() ); - return false; - } - - //$this->setRedirect( 'index.php?option=com_config', $msg ); - $this->edit(); - } - - /** - * Cancel operation - */ - function cancel() - { - $this->setRedirect( 'index.php' ); - } +registerTask( 'apply', 'save' ); + } + + /** + * Show the configuration edit form + * @param string The URL option + */ + function edit() + { + JRequest::setVar('tmpl', 'component'); //force the component template + $component = JRequest::getCmd( 'component' ); + + if (empty( $component )) + { + JError::raiseWarning( 500, 'Not a valid component' ); + return false; + } + + // load the component's language file + $lang = & JFactory::getLanguage(); + $lang->load( $component ); + + $model = $this->getModel('Component' ); + $table =& JTable::getInstance('component'); + + if (!$table->loadByOption( $component )) + { + JError::raiseWarning( 500, 'Not a valid component' ); + return false; + } + + $view = new ConfigViewComponent( ); + $view->assignRef('component', $table); + $view->setModel( $model, true ); + $view->display(); + } + + /** + * Save the configuration + */ + function save() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $component = JRequest::getCmd( 'component' ); + + $table =& JTable::getInstance('component'); + if (!$table->loadByOption( $component )) + { + JError::raiseWarning( 500, 'Not a valid component' ); + return false; + } + + $post = JRequest::get( 'post' ); + $post['option'] = $component; + $table->bind( $post ); + + // pre-save checks + if (!$table->check()) { + JError::raiseWarning( 500, $table->getError() ); + return false; + } + + // save the changes + if (!$table->store()) { + JError::raiseWarning( 500, $table->getError() ); + return false; + } + + //$this->setRedirect( 'index.php?option=com_config', $msg ); + $this->edit(); + } + + /** + * Cancel operation + */ + function cancel() + { + $this->setRedirect( 'index.php' ); + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_config/models/component.php b/oss/joomla/trunk/administrator/components/com_config/models/component.php index 8a788b7a..57873696 100644 --- a/oss/joomla/trunk/administrator/components/com_config/models/component.php +++ b/oss/joomla/trunk/administrator/components/com_config/models/component.php @@ -1,57 +1,57 @@ -loadByOption( $component ); - - // work out file path - if ($path = JRequest::getString( 'path' )) { - $path = JPath::clean( JPATH_SITE.DS.$path ); - JPath::check( $path ); - } else { - $option = preg_replace( '#\W#', '', $table->option ); - $path = JPATH_ADMINISTRATOR.DS.'components'.DS.$option.DS.'config.xml'; - } - - if (file_exists( $path )) { - $instance = new JParameter( $table->params, $path ); - } else { - $instance = new JParameter( $table->params ); - } - } - return $instance; - } +loadByOption( $component ); + + // work out file path + if ($path = JRequest::getString( 'path' )) { + $path = JPath::clean( JPATH_SITE.DS.$path ); + JPath::check( $path ); + } else { + $option = preg_replace( '#\W#', '', $table->option ); + $path = JPATH_ADMINISTRATOR.DS.'components'.DS.$option.DS.'config.xml'; + } + + if (file_exists( $path )) { + $instance = new JParameter( $table->params, $path ); + } else { + $instance = new JParameter( $table->params ); + } + } + return $instance; + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_config/toolbar.config.html.php b/oss/joomla/trunk/administrator/components/com_config/toolbar.config.html.php index ab10a629..d1df897a 100644 --- a/oss/joomla/trunk/administrator/components/com_config/toolbar.config.html.php +++ b/oss/joomla/trunk/administrator/components/com_config/toolbar.config.html.php @@ -1,32 +1,32 @@ -loadByOption( 'com_users' ); - $userparams = new JParameter( $table->params, JPATH_ADMINISTRATOR.DS.'components'.DS.'com_users'.DS.'config.xml' ); - $table->loadByOption( 'com_media' ); - $mediaparams = new JParameter( $table->params, JPATH_ADMINISTRATOR.DS.'components'.DS.'com_media'.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'); ?> -
    -
    - - - - - - render('mediaparams'); ?> -
    -
    - - - -
    -
    -
    - - - - - -
    - - - - - - -
    -
    -
    -
    - - - - - - - -
    - '; - - return $tip; - } -} +loadByOption( 'com_users' ); + $userparams = new JParameter( $table->params, JPATH_ADMINISTRATOR.DS.'components'.DS.'com_users'.DS.'config.xml' ); + $table->loadByOption( 'com_media' ); + $mediaparams = new JParameter( $table->params, JPATH_ADMINISTRATOR.DS.'components'.DS.'com_media'.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'); ?> +
    +
    + + + + + + render('mediaparams'); ?> +
    +
    + + + +
    +
    +
    + + + + + +
    + + + + + + +
    +
    +
    +
    + + + + + + + +
    + '; + + return $tip; + } +} diff --git a/oss/joomla/trunk/administrator/components/com_config/views/component/view.php b/oss/joomla/trunk/administrator/components/com_config/views/component/view.php index 3a7f280e..5bc680ac 100644 --- a/oss/joomla/trunk/administrator/components/com_config/views/component/view.php +++ b/oss/joomla/trunk/administrator/components/com_config/views/component/view.php @@ -1,70 +1,70 @@ -getModel(); - $params = &$model->getParams(); - $component = JComponentHelper::getComponent(JRequest::getCmd( 'component' )); - - $document = & JFactory::getDocument(); - $document->setTitle( JText::_('Edit Preferences') ); - JHTML::_('behavior.tooltip'); -?> -
    -
    -
    - - -
    -
    - component->name) ?> -
    -
    - -
    - - - - render();?> -
    - - - - - - - - - -
    -getModel(); + $params = &$model->getParams(); + $component = JComponentHelper::getComponent(JRequest::getCmd( 'component' )); + + $document = & JFactory::getDocument(); + $document->setTitle( JText::_('Edit Preferences') ); + JHTML::_('behavior.tooltip'); +?> +
    +
    +
    + + +
    +
    + component->name) ?> +
    +
    + +
    + + + + render();?> +
    + + + + + + + + + +
    + -
    - - - - - - -
    - : - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - id ); - - $checked = JHTML::_('grid.checkedout', $row, $i ); - $access = JHTML::_('grid.access', $row, $i ); - $published = JHTML::_('grid.published', $row, $i ); - - $row->cat_link = JRoute::_( 'index.php?option=com_categories§ion=com_contact_details&task=edit&type=other&cid[]='. $row->catid ); - $row->user_link = JRoute::_( 'index.php?option=com_users&task=editA&cid[]='. $row->user_id ); - ?> - "> - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - -
    - getListFooter(); ?> -
    - getRowOffset( $i ); ?> - - - - get ('id'), $row->checked_out )) : - echo $row->name; - else : - ?> - - - name; ?> - - - - - orderUpIcon( $i, ( $row->catid == @$rows[$i-1]->catid ), 'orderup', 'Move Up', $ordering ); ?> - orderDownIcon( $i, $n, ( $row->catid == @$rows[$i+1]->catid ), 'orderdown', 'Move Down', $ordering ); ?> - - class="text_area" style="text-align: center" /> - - - - - category; ?> - - - user; ?> - - id; ?> -
    - - - - - - - -
    - image == '') { - $row->image = 'blank.png'; - } - - JHTML::_('behavior.tooltip'); - 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)); - - JFilterOutput::objectHTMLSafe( $row, ENT_QUOTES, 'misc' ); - $cparams = JComponentHelper::getParams ('com_media'); - ?> - - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - id) { - ?> - - - - - -
    - - - -
    - - - -
    - : - - -
    - - - -
    - - - -
    - - - -
    - - - -
    - - - id;?> -
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - -
    - - - -
    - - - -
    - - - -
    - - - -
    - - - -
    - - - -
    - - - -
    - - - -
    - - - -
    - - - -
    - - - -
    - - - -
    - -
    -
    -
    - -
    -
    - - - startPane("menu-pane"); - echo $pane->startPanel(JText :: _('Contact Parameters'), "param-page"); - echo $params->render(); - echo $pane->endPanel(); - echo $pane->startPanel(JText :: _('Advanced Parameters'), "param-page"); - echo $params->render('params', 'advanced'); - echo $pane->endPanel(); - echo $pane->startPanel(JText :: _('E-mail Parameters'), "param-page"); - echo $params->render('params', 'email'); - echo $pane->endPanel(); - echo $pane->endPane(); - ?>
    -
    -
    - - - - - - -
    - +
    + + + + + + +
    + : + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + id ); + + $checked = JHTML::_('grid.checkedout', $row, $i ); + $access = JHTML::_('grid.access', $row, $i ); + $published = JHTML::_('grid.published', $row, $i ); + + $row->cat_link = JRoute::_( 'index.php?option=com_categories§ion=com_contact_details&task=edit&type=other&cid[]='. $row->catid ); + $row->user_link = JRoute::_( 'index.php?option=com_users&task=editA&cid[]='. $row->user_id ); + ?> + "> + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + +
    + getListFooter(); ?> +
    + getRowOffset( $i ); ?> + + + + get ('id'), $row->checked_out )) : + echo $row->name; + else : + ?> + + + name; ?> + + + + + orderUpIcon( $i, ( $row->catid == @$rows[$i-1]->catid ), 'orderup', 'Move Up', $ordering ); ?> + orderDownIcon( $i, $n, ( $row->catid == @$rows[$i+1]->catid ), 'orderdown', 'Move Down', $ordering ); ?> + + class="text_area" style="text-align: center" /> + + + + + category; ?> + + + user; ?> + + id; ?> +
    + + + + + + + +
    + image == '') { + $row->image = 'blank.png'; + } + + JHTML::_('behavior.tooltip'); + 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)); + + JFilterOutput::objectHTMLSafe( $row, ENT_QUOTES, 'misc' ); + $cparams = JComponentHelper::getParams ('com_media'); + ?> + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id) { + ?> + + + + + +
    + + + +
    + + + +
    + : + + +
    + + + +
    + + + +
    + + + +
    + + + +
    + + + id;?> +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + +
    + + + +
    + + + +
    + + + +
    + + + +
    + + + +
    + + + +
    + + + +
    + + + +
    + + + +
    + + + +
    + + + +
    + + + +
    + +
    +
    +
    + +
    +
    + + + startPane("menu-pane"); + echo $pane->startPanel(JText :: _('Contact Parameters'), "param-page"); + echo $params->render(); + echo $pane->endPanel(); + echo $pane->startPanel(JText :: _('Advanced Parameters'), "param-page"); + echo $params->render('params', 'advanced'); + echo $pane->endPanel(); + echo $pane->startPanel(JText :: _('E-mail Parameters'), "param-page"); + echo $params->render('params', 'email'); + echo $pane->endPanel(); + echo $pane->endPane(); + ?>
    +
    +
    + + + + + + +
    + authorize( 'com_contact', 'manage' )) { - $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); -} - -require_once( JApplicationHelper::getPath( 'admin_html' ) ); -// Set the table directory -JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_contact'.DS.'tables'); - -$task = JRequest::getCmd('task'); -$id = JRequest::getVar('id', 0, 'get', 'int'); -$cid = JRequest::getVar('cid', array(0), 'post', 'array'); -JArrayHelper::toInteger($cid, array(0)); - -switch ($task) -{ - case 'add' : - editContact(false ); - break; - case 'edit': - editContact(true); - break; - - case 'apply': - case 'save': - case 'save2new': - case 'save2copy': - saveContact( $task ); - break; - - case 'remove': - removeContacts( $cid ); - break; - - case 'publish': - changeContact( $cid, 1 ); - break; - - case 'unpublish': - changeContact( $cid, 0 ); - break; - - case 'orderup': - orderContacts( $cid[0], -1 ); - break; - - case 'orderdown': - orderContacts( $cid[0], 1 ); - break; - - case 'accesspublic': - changeAccess( $cid[0], 0 ); - break; - - case 'accessregistered': - changeAccess( $cid[0], 1 ); - break; - - case 'accessspecial': - changeAccess( $cid[0], 2 ); - break; - - case 'saveorder': - saveOrder( $cid ); - break; - - case 'cancel': - cancelContact(); - break; - - default: - showContacts( $option ); - break; -} - -/** -* List the records -* @param string The current GET/POST option -*/ -function showContacts( $option ) -{ - global $mainframe; - - $db =& JFactory::getDBO(); - $filter_order = $mainframe->getUserStateFromRequest( $option.'filter_order', 'filter_order', 'cd.ordering', 'cmd' ); - $filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'filter_order_Dir', 'filter_order_Dir', '', 'word' ); - $filter_state = $mainframe->getUserStateFromRequest( $option.'filter_state', 'filter_state', '', 'word' ); - $filter_catid = $mainframe->getUserStateFromRequest( $option.'filter_catid', 'filter_catid', 0, 'int' ); - $search = $mainframe->getUserStateFromRequest( $option.'search', 'search', '', 'string' ); - $search = JString::strtolower( $search ); - - $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); - $limitstart = $mainframe->getUserStateFromRequest($option.'.limitstart', 'limitstart', 0, 'int'); - - $where = array(); - - if ( $search ) { - $where[] = 'cd.name LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); - } - if ( $filter_catid ) { - $where[] = 'cd.catid = '.(int) $filter_catid; - } - if ( $filter_state ) { - if ( $filter_state == 'P' ) { - $where[] = 'cd.published = 1'; - } else if ($filter_state == 'U' ) { - $where[] = 'cd.published = 0'; - } - } - - $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); - if ($filter_order == 'cd.ordering'){ - $orderby = ' ORDER BY category, cd.ordering'; - } else { - $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', category, cd.ordering'; - } - - // get the total number of records - $query = 'SELECT COUNT(*)' - . ' FROM #__contact_details AS cd' - . $where - ; - $db->setQuery( $query ); - $total = $db->loadResult(); - - jimport('joomla.html.pagination'); - $pageNav = new JPagination( $total, $limitstart, $limit ); - - // get the subset (based on limits) of required records - $query = 'SELECT cd.*, cc.title AS category, u.name AS user, v.name as editor, g.name AS groupname' - . ' FROM #__contact_details AS cd' - . ' LEFT JOIN #__groups AS g ON g.id = cd.access' - . ' LEFT JOIN #__categories AS cc ON cc.id = cd.catid' - . ' LEFT JOIN #__users AS u ON u.id = cd.user_id' - . ' LEFT JOIN #__users AS v ON v.id = cd.checked_out' - . $where - . $orderby - ; - $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); - $rows = $db->loadObjectList(); - - // build list of categories - $javascript = 'onchange="document.adminForm.submit();"'; - $lists['catid'] = JHTML::_('list.category', 'filter_catid', 'com_contact_details', intval( $filter_catid ), $javascript ); - - // state filter - $lists['state'] = JHTML::_('grid.state', $filter_state ); - - // table ordering - $lists['order_Dir'] = $filter_order_Dir; - $lists['order'] = $filter_order; - - // search filter - $lists['search']= $search; - - HTML_contact::showcontacts( $rows, $pageNav, $option, $lists ); -} - -/** -* Creates a new or edits and existing user record -* @param int The id of the record, 0 if a new entry -* @param string The current GET/POST option -*/ -function editContact($edit ) -{ - $db =& JFactory::getDBO(); - $user =& JFactory::getUser(); - - $cid = JRequest::getVar('cid', array(0), '', 'array'); - $option = JRequest::getCmd('option'); - - JArrayHelper::toInteger($cid, array(0)); - - $row =& JTable::getInstance('contact', 'Table'); - // load the row from the db table - if($edit) - $row->load( $cid[0] ); - - if ($edit) { - // do stuff for existing records - $row->checkout($user->get('id')); - } else { - // do stuff for new records - $row->imagepos = 'top'; - $row->ordering = 0; - $row->published = 1; - } - $lists = array(); - - // build the html select list for ordering - $query = 'SELECT ordering AS value, name AS text' - . ' FROM #__contact_details' - . ' WHERE published >= 0' - . ' AND catid = '.(int) $row->catid - . ' ORDER BY ordering' - ; - if($edit) - $lists['ordering'] = JHTML::_('list.specificordering', $row, $cid[0], $query ); - else - $lists['ordering'] = JHTML::_('list.specificordering', $row, '', $query ); - - // build list of users - $lists['user_id'] = JHTML::_('list.users', 'user_id', $row->user_id, 1, NULL, 'name', 0 ); - // build list of categories - $lists['catid'] = JHTML::_('list.category', 'catid', 'com_contact_details', intval( $row->catid ) ); - // build the html select list for images - $lists['image'] = JHTML::_('list.images', 'image', $row->image ); - // build the html select list for the group access - $lists['access'] = JHTML::_('list.accesslevel', $row ); - // build the html radio buttons for published - $lists['published'] = JHTML::_('select.booleanlist', 'published', '', $row->published ); - // build the html radio buttons for default - $lists['default_con'] = JHTML::_('select.booleanlist', 'default_con', '', $row->default_con ); - - // get params definitions - $file = JPATH_ADMINISTRATOR .'/components/com_contact/contact_items.xml'; - $params = new JParameter( $row->params, $file, 'component' ); - - HTML_contact::editcontact( $row, $lists, $option, $params ); -} - -/** -* Saves the record from an edit form submit -* @param string The current GET/POST option -*/ -function saveContact( $task ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db =& JFactory::getDBO(); - $row =& JTable::getInstance('contact', 'Table'); - $post = JRequest::get( 'post' ); - $post['misc'] = JRequest::getVar('misc', '', 'POST', 'string', JREQUEST_ALLOWHTML); - if (!$row->bind( $post )) { - JError::raiseError(500, $row->getError() ); - } - // save params - $params = JRequest::getVar( 'params', array(), 'post', 'array' ); - if (is_array( $params )) { - $txt = array(); - foreach ( $params as $k=>$v) { - $txt[] = "$k=$v"; - } - $row->params = implode( "\n", $txt ); - } - - // save to a copy, reset the primary key - if ($task == 'save2copy') { - $row->id = 0; - } - - // pre-save checks - if (!$row->check()) { - JError::raiseError(500, $row->getError() ); - } - - // if new item, order last in appropriate group - if (!$row->id) { - $where = "catid = " . (int) $row->catid; - $row->ordering = $row->getNextOrder( $where ); - } - - // save the changes - if (!$row->store()) { - JError::raiseError(500, $row->getError() ); - } - $row->checkin(); - if ($row->default_con) { - $query = 'UPDATE #__contact_details' - . ' SET default_con = 0' - . ' WHERE id <> '. (int) $row->id - . ' AND default_con = 1' - ; - $db->setQuery( $query ); - $db->query(); - } - - switch ($task) - { - case 'apply': - case 'save2copy': - $msg = JText::sprintf( 'Changes to X saved', JText::_('Contact') ); - $link = 'index.php?option=com_contact&task=edit&cid[]='. $row->id .''; - break; - - case 'save2new': - $msg = JText::sprintf( 'Changes to X saved', JText::_('Contact') ); - $link = 'index.php?option=com_contact&task=edit'; - break; - - case 'save': - default: - $msg = JText::_( 'Contact saved' ); - $link = 'index.php?option=com_contact'; - break; - } - - $mainframe->redirect( $link, $msg ); -} - -/** -* Removes records -* @param array An array of id keys to remove -* @param string The current GET/POST option -*/ -function removeContacts( &$cid ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db =& JFactory::getDBO(); - JArrayHelper::toInteger($cid); - - if (count( $cid )) { - $cids = implode( ',', $cid ); - $query = 'DELETE FROM #__contact_details' - . ' WHERE id IN ( '. $cids .' )' - ; - $db->setQuery( $query ); - if (!$db->query()) { - echo "\n"; - } - } - - $mainframe->redirect( "index.php?option=com_contact" ); -} - -/** -* Changes the state of one or more content pages -* @param array An array of unique category id numbers -* @param integer 0 if unpublishing, 1 if publishing -* @param string The current option -*/ -function changeContact( $cid=null, $state=0 ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db =& JFactory::getDBO(); - $user =& JFactory::getUser(); - JArrayHelper::toInteger($cid); - - if (count( $cid ) < 1) { - $action = $state ? 'publish' : 'unpublish'; - JError::raiseError(500, JText::_( 'Select an item to' .$action, true ) ); - } - - $cids = implode( ',', $cid ); - - $query = 'UPDATE #__contact_details' - . ' SET published = ' . (int) $state - . ' WHERE id IN ( '. $cids .' )' - . ' AND ( checked_out = 0 OR ( checked_out = '. (int) $user->get('id') .' ) )' - ; - $db->setQuery( $query ); - if (!$db->query()) { - JError::raiseError(500, $db->getErrorMsg() ); - } - - if (count( $cid ) == 1) { - $row =& JTable::getInstance('contact', 'Table'); - $row->checkin( intval( $cid[0] ) ); - } - - $mainframe->redirect( 'index.php?option=com_contact' ); -} - -/** JJC -* Moves the order of a record -* @param integer The increment to reorder by -*/ -function orderContacts( $uid, $inc ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db =& JFactory::getDBO(); - - $row =& JTable::getInstance('contact', 'Table'); - $row->load( $uid ); - $row->move( $inc, 'catid = '. (int) $row->catid .' AND published != 0' ); - - $mainframe->redirect( 'index.php?option=com_contact' ); -} - -/** PT -* Cancels editing and checks in the record -*/ -function cancelContact() -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db =& JFactory::getDBO(); - $row =& JTable::getInstance('contact', 'Table'); - $row->bind( JRequest::get( 'post' )); - $row->checkin(); - - $mainframe->redirect('index.php?option=com_contact'); -} - -/** -* changes the access level of a record -* @param integer The increment to reorder by -*/ -function changeAccess( $id, $access ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db =& JFactory::getDBO(); - - $row =& JTable::getInstance('contact', 'Table'); - $row->load( $id ); - $row->access = $access; - - if ( !$row->check() ) { - return $row->getError(); - } - if ( !$row->store() ) { - return $row->getError(); - } - - $mainframe->redirect( 'index.php?option=com_contact' ); -} - -function saveOrder( &$cid ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db =& JFactory::getDBO(); - $total = count( $cid ); - $order = JRequest::getVar( 'order', array(0), 'post', 'array' ); - JArrayHelper::toInteger($order, array(0)); - - $row =& JTable::getInstance('contact', 'Table'); - $groupings = array(); - - // update ordering values - for( $i=0; $i < $total; $i++ ) { - $row->load( (int) $cid[$i] ); - // track categories - $groupings[] = $row->catid; - - if ($row->ordering != $order[$i]) { - $row->ordering = $order[$i]; - if (!$row->store()) { - JError::raiseError(500, $db->getErrorMsg() ); - } - } - } - - // execute updateOrder for each parent group - $groupings = array_unique( $groupings ); - foreach ($groupings as $group){ - $row->reorder('catid = '.(int) $group); - } - - $msg = 'New ordering saved'; - $mainframe->redirect( 'index.php?option=com_contact', $msg ); -} +authorize( 'com_contact', 'manage' )) { + $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); +} + +require_once( JApplicationHelper::getPath( 'admin_html' ) ); +// Set the table directory +JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_contact'.DS.'tables'); + +$task = JRequest::getCmd('task'); +$id = JRequest::getVar('id', 0, 'get', 'int'); +$cid = JRequest::getVar('cid', array(0), 'post', 'array'); +JArrayHelper::toInteger($cid, array(0)); + +switch ($task) +{ + case 'add' : + editContact(false ); + break; + case 'edit': + editContact(true); + break; + + case 'apply': + case 'save': + case 'save2new': + case 'save2copy': + saveContact( $task ); + break; + + case 'remove': + removeContacts( $cid ); + break; + + case 'publish': + changeContact( $cid, 1 ); + break; + + case 'unpublish': + changeContact( $cid, 0 ); + break; + + case 'orderup': + orderContacts( $cid[0], -1 ); + break; + + case 'orderdown': + orderContacts( $cid[0], 1 ); + break; + + case 'accesspublic': + changeAccess( $cid[0], 0 ); + break; + + case 'accessregistered': + changeAccess( $cid[0], 1 ); + break; + + case 'accessspecial': + changeAccess( $cid[0], 2 ); + break; + + case 'saveorder': + saveOrder( $cid ); + break; + + case 'cancel': + cancelContact(); + break; + + default: + showContacts( $option ); + break; +} + +/** +* List the records +* @param string The current GET/POST option +*/ +function showContacts( $option ) +{ + global $mainframe; + + $db =& JFactory::getDBO(); + $filter_order = $mainframe->getUserStateFromRequest( $option.'filter_order', 'filter_order', 'cd.ordering', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'filter_order_Dir', 'filter_order_Dir', '', 'word' ); + $filter_state = $mainframe->getUserStateFromRequest( $option.'filter_state', 'filter_state', '', 'word' ); + $filter_catid = $mainframe->getUserStateFromRequest( $option.'filter_catid', 'filter_catid', 0, 'int' ); + $search = $mainframe->getUserStateFromRequest( $option.'search', 'search', '', 'string' ); + if (strpos($search, '"') !== false) { + $search = str_replace(array('=', '<'), '', $search); + } + $search = JString::strtolower($search); + + $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); + $limitstart = $mainframe->getUserStateFromRequest($option.'.limitstart', 'limitstart', 0, 'int'); + + $where = array(); + + if ( $search ) { + $where[] = 'cd.name LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + if ( $filter_catid ) { + $where[] = 'cd.catid = '.(int) $filter_catid; + } + if ( $filter_state ) { + if ( $filter_state == 'P' ) { + $where[] = 'cd.published = 1'; + } else if ($filter_state == 'U' ) { + $where[] = 'cd.published = 0'; + } + } + + $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); + if ($filter_order == 'cd.ordering'){ + $orderby = ' ORDER BY category, cd.ordering'; + } else { + $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', category, cd.ordering'; + } + + // get the total number of records + $query = 'SELECT COUNT(*)' + . ' FROM #__contact_details AS cd' + . $where + ; + $db->setQuery( $query ); + $total = $db->loadResult(); + + jimport('joomla.html.pagination'); + $pageNav = new JPagination( $total, $limitstart, $limit ); + + // get the subset (based on limits) of required records + $query = 'SELECT cd.*, cc.title AS category, u.name AS user, v.name as editor, g.name AS groupname' + . ' FROM #__contact_details AS cd' + . ' LEFT JOIN #__groups AS g ON g.id = cd.access' + . ' LEFT JOIN #__categories AS cc ON cc.id = cd.catid' + . ' LEFT JOIN #__users AS u ON u.id = cd.user_id' + . ' LEFT JOIN #__users AS v ON v.id = cd.checked_out' + . $where + . $orderby + ; + $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); + $rows = $db->loadObjectList(); + + // build list of categories + $javascript = 'onchange="document.adminForm.submit();"'; + $lists['catid'] = JHTML::_('list.category', 'filter_catid', 'com_contact_details', intval( $filter_catid ), $javascript ); + + // state filter + $lists['state'] = JHTML::_('grid.state', $filter_state ); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search']= $search; + + HTML_contact::showcontacts( $rows, $pageNav, $option, $lists ); +} + +/** +* Creates a new or edits and existing user record +* @param int The id of the record, 0 if a new entry +* @param string The current GET/POST option +*/ +function editContact($edit ) +{ + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + + $cid = JRequest::getVar('cid', array(0), '', 'array'); + $option = JRequest::getCmd('option'); + + JArrayHelper::toInteger($cid, array(0)); + + $row =& JTable::getInstance('contact', 'Table'); + // load the row from the db table + if($edit) + $row->load( $cid[0] ); + + if ($edit) { + // do stuff for existing records + $row->checkout($user->get('id')); + } else { + // do stuff for new records + $row->imagepos = 'top'; + $row->ordering = 0; + $row->published = 1; + } + $lists = array(); + + // build the html select list for ordering + $query = 'SELECT ordering AS value, name AS text' + . ' FROM #__contact_details' + . ' WHERE published >= 0' + . ' AND catid = '.(int) $row->catid + . ' ORDER BY ordering' + ; + if($edit) + $lists['ordering'] = JHTML::_('list.specificordering', $row, $cid[0], $query ); + else + $lists['ordering'] = JHTML::_('list.specificordering', $row, '', $query ); + + // build list of users + $lists['user_id'] = JHTML::_('list.users', 'user_id', $row->user_id, 1, NULL, 'name', 0 ); + // build list of categories + $lists['catid'] = JHTML::_('list.category', 'catid', 'com_contact_details', intval( $row->catid ) ); + // build the html select list for images + $lists['image'] = JHTML::_('list.images', 'image', $row->image ); + // build the html select list for the group access + $lists['access'] = JHTML::_('list.accesslevel', $row ); + // build the html radio buttons for published + $lists['published'] = JHTML::_('select.booleanlist', 'published', '', $row->published ); + // build the html radio buttons for default + $lists['default_con'] = JHTML::_('select.booleanlist', 'default_con', '', $row->default_con ); + + // get params definitions + $file = JPATH_ADMINISTRATOR .'/components/com_contact/contact_items.xml'; + $params = new JParameter( $row->params, $file, 'component' ); + + HTML_contact::editcontact( $row, $lists, $option, $params ); +} + +/** +* Saves the record from an edit form submit +* @param string The current GET/POST option +*/ +function saveContact( $task ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db =& JFactory::getDBO(); + $row =& JTable::getInstance('contact', 'Table'); + $post = JRequest::get( 'post' ); + $post['misc'] = JRequest::getVar('misc', '', 'POST', 'string', JREQUEST_ALLOWHTML); + if (!$row->bind( $post )) { + JError::raiseError(500, $row->getError() ); + } + // save params + $params = JRequest::getVar( 'params', array(), 'post', 'array' ); + if (is_array( $params )) { + $txt = array(); + foreach ( $params as $k=>$v) { + $txt[] = "$k=$v"; + } + $row->params = implode( "\n", $txt ); + } + + // save to a copy, reset the primary key + if ($task == 'save2copy') { + $row->id = 0; + } + + // pre-save checks + if (!$row->check()) { + JError::raiseError(500, $row->getError() ); + } + + // if new item, order last in appropriate group + if (!$row->id) { + $where = "catid = " . (int) $row->catid; + $row->ordering = $row->getNextOrder( $where ); + } + + // save the changes + if (!$row->store()) { + JError::raiseError(500, $row->getError() ); + } + $row->checkin(); + if ($row->default_con) { + $query = 'UPDATE #__contact_details' + . ' SET default_con = 0' + . ' WHERE id <> '. (int) $row->id + . ' AND default_con = 1' + ; + $db->setQuery( $query ); + $db->query(); + } + + switch ($task) + { + case 'apply': + case 'save2copy': + $msg = JText::sprintf( 'Changes to X saved', JText::_('Contact') ); + $link = 'index.php?option=com_contact&task=edit&cid[]='. $row->id .''; + break; + + case 'save2new': + $msg = JText::sprintf( 'Changes to X saved', JText::_('Contact') ); + $link = 'index.php?option=com_contact&task=edit'; + break; + + case 'save': + default: + $msg = JText::_( 'Contact saved' ); + $link = 'index.php?option=com_contact'; + break; + } + + $mainframe->redirect( $link, $msg ); +} + +/** +* Removes records +* @param array An array of id keys to remove +* @param string The current GET/POST option +*/ +function removeContacts( &$cid ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db =& JFactory::getDBO(); + JArrayHelper::toInteger($cid); + + if (count( $cid )) { + $cids = implode( ',', $cid ); + $query = 'DELETE FROM #__contact_details' + . ' WHERE id IN ( '. $cids .' )' + ; + $db->setQuery( $query ); + if (!$db->query()) { + echo "\n"; + } + } + + $mainframe->redirect( "index.php?option=com_contact" ); +} + +/** +* Changes the state of one or more content pages +* @param array An array of unique category id numbers +* @param integer 0 if unpublishing, 1 if publishing +* @param string The current option +*/ +function changeContact( $cid=null, $state=0 ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + JArrayHelper::toInteger($cid); + + if (count( $cid ) < 1) { + $action = $state ? 'publish' : 'unpublish'; + JError::raiseError(500, JText::_( 'Select an item to' .$action, true ) ); + } + + $cids = implode( ',', $cid ); + + $query = 'UPDATE #__contact_details' + . ' SET published = ' . (int) $state + . ' WHERE id IN ( '. $cids .' )' + . ' AND ( checked_out = 0 OR ( checked_out = '. (int) $user->get('id') .' ) )' + ; + $db->setQuery( $query ); + if (!$db->query()) { + JError::raiseError(500, $db->getErrorMsg() ); + } + + if (count( $cid ) == 1) { + $row =& JTable::getInstance('contact', 'Table'); + $row->checkin( intval( $cid[0] ) ); + } + + $mainframe->redirect( 'index.php?option=com_contact' ); +} + +/** JJC +* Moves the order of a record +* @param integer The increment to reorder by +*/ +function orderContacts( $uid, $inc ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db =& JFactory::getDBO(); + + $row =& JTable::getInstance('contact', 'Table'); + $row->load( $uid ); + $row->move( $inc, 'catid = '. (int) $row->catid .' AND published != 0' ); + + $mainframe->redirect( 'index.php?option=com_contact' ); +} + +/** PT +* Cancels editing and checks in the record +*/ +function cancelContact() +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db =& JFactory::getDBO(); + $row =& JTable::getInstance('contact', 'Table'); + $row->bind( JRequest::get( 'post' )); + $row->checkin(); + + $mainframe->redirect('index.php?option=com_contact'); +} + +/** +* changes the access level of a record +* @param integer The increment to reorder by +*/ +function changeAccess( $id, $access ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db =& JFactory::getDBO(); + + $row =& JTable::getInstance('contact', 'Table'); + $row->load( $id ); + $row->access = $access; + + if ( !$row->check() ) { + return $row->getError(); + } + if ( !$row->store() ) { + return $row->getError(); + } + + $mainframe->redirect( 'index.php?option=com_contact' ); +} + +function saveOrder( &$cid ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db =& JFactory::getDBO(); + $total = count( $cid ); + $order = JRequest::getVar( 'order', array(0), 'post', 'array' ); + JArrayHelper::toInteger($order, array(0)); + + $row =& JTable::getInstance('contact', 'Table'); + $groupings = array(); + + // update ordering values + for( $i=0; $i < $total; $i++ ) { + $row->load( (int) $cid[$i] ); + // track categories + $groupings[] = $row->catid; + + if ($row->ordering != $order[$i]) { + $row->ordering = $order[$i]; + if (!$row->store()) { + JError::raiseError(500, $db->getErrorMsg() ); + } + } + } + + // execute updateOrder for each parent group + $groupings = array_unique( $groupings ); + foreach ($groupings as $group){ + $row->reorder('catid = '.(int) $group); + } + + $msg = 'New ordering saved'; + $mainframe->redirect( 'index.php?option=com_contact', $msg ); +} diff --git a/oss/joomla/trunk/administrator/components/com_contact/contact.xml b/oss/joomla/trunk/administrator/components/com_contact/contact.xml index f0222d1e..9f068049 100644 --- a/oss/joomla/trunk/administrator/components/com_contact/contact.xml +++ b/oss/joomla/trunk/administrator/components/com_contact/contact.xml @@ -1,12 +1,12 @@ - - - Contact - Joomla! Project - Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. - April 2006 - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - admin@joomla.org - www.joomla.org - 1.5.0 - This component shows a listing of Contact Information - + + + Contact + Joomla! Project + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + April 2006 + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + This component shows a listing of Contact Information + diff --git a/oss/joomla/trunk/administrator/components/com_contact/contact_items.xml b/oss/joomla/trunk/administrator/components/com_contact/contact_items.xml index ff9d5b44..c222a966 100644 --- a/oss/joomla/trunk/administrator/components/com_contact/contact_items.xml +++ b/oss/joomla/trunk/administrator/components/com_contact/contact_items.xml @@ -1,101 +1,101 @@ - - - Contact Items - Joomla! Project - 2006 - Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - admin@joomla.org - www.joomla.org - 1.0.0 - Parameters for individual Contact Items - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + Contact Items + Joomla! Project + 2006 + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.0.0 + Parameters for individual Contact Items + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/oss/joomla/trunk/administrator/components/com_contact/elements/contact.php b/oss/joomla/trunk/administrator/components/com_contact/elements/contact.php index 70111727..ad823bfe 100644 --- a/oss/joomla/trunk/administrator/components/com_contact/elements/contact.php +++ b/oss/joomla/trunk/administrator/components/com_contact/elements/contact.php @@ -1,43 +1,43 @@ -setQuery( $query ); - $options = $db->loadObjectList( ); - - return JHTML::_('select.genericlist', $options, ''.$control_name.'['.$name.']', 'class="inputbox"', 'id', 'text', $value, $control_name.$name ); - } -} +setQuery( $query ); + $options = $db->loadObjectList( ); + + return JHTML::_('select.genericlist', $options, ''.$control_name.'['.$name.']', 'class="inputbox"', 'id', 'text', $value, $control_name.$name ); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_contact/helpers/vcard.php b/oss/joomla/trunk/administrator/components/com_contact/helpers/vcard.php index a97c29bf..cb56515b 100644 --- a/oss/joomla/trunk/administrator/components/com_contact/helpers/vcard.php +++ b/oss/joomla/trunk/administrator/components/com_contact/helpers/vcard.php @@ -1,94 +1,94 @@ -properties["N"] = "$family;$first;$additional;$prefix;$suffix"; - $this->setFormattedName( trim( "$prefix $first $additional $family $suffix" ) ); - } - - // needed to fix bug in vcard class - function setAddress( $postoffice='', $extended='', $street='', $city='', $region='', $zip='', $country='', $type='HOME;POSTAL' ) { - // $type may be DOM | INTL | POSTAL | PARCEL | HOME | WORK or any combination of these: e.g. "WORK;PARCEL;POSTAL" - $separator = ';'; - - $key = 'ADR'; - if ( $type != '' ) { - $key .= $separator . $type; - } - $key.= ';ENCODING=QUOTED-PRINTABLE'; - - $return = encode( $postoffice ); - $return .= $separator . encode( $extended ); - $return .= $separator . encode( $street ); - $return .= $separator . encode( $city ); - $return .= $separator . encode( $region); - $return .= $separator . encode( $zip ); - $return .= $separator . encode( $country ); - - $this->properties[$key] = $return; - } - - // added ability to set filename - function setFilename( $filename ) { - $this->filename = $filename .'.vcf'; - } - - // added ability to set position/title - function setTitle( $title ) { - $title = trim( $title ); - - $this->properties['TITLE'] = $title; - } - - // added ability to set organisation/company - function setOrg( $org ) { - $org = trim( $org ); - - $this->properties['ORG'] = $org; - } - - function getVCard( $sitename ) { - $text = 'BEGIN:VCARD'; - $text .= "\r\n"; - $text .= 'VERSION:2.1'; - $text .= "\r\n"; - - foreach( $this->properties as $key => $value ) { - $text .= "$key:$value"; - $text .= "\r\n"; - } - $text .= 'REV:'. date( 'Y-m-d' ) .'T'. date( 'H:i:s' ). 'Z'; - $text .= "\r\n"; - $text .= 'MAILER: Joomla! vCard for '. $sitename; - $text .= "\r\n"; - $text .= 'END:VCARD'; - $text .= "\r\n"; - - return $text; - } +properties["N"] = "$family;$first;$additional;$prefix;$suffix"; + $this->setFormattedName( trim( "$prefix $first $additional $family $suffix" ) ); + } + + // needed to fix bug in vcard class + function setAddress( $postoffice='', $extended='', $street='', $city='', $region='', $zip='', $country='', $type='HOME;POSTAL' ) { + // $type may be DOM | INTL | POSTAL | PARCEL | HOME | WORK or any combination of these: e.g. "WORK;PARCEL;POSTAL" + $separator = ';'; + + $key = 'ADR'; + if ( $type != '' ) { + $key .= $separator . $type; + } + $key.= ';ENCODING=QUOTED-PRINTABLE'; + + $return = encode( $postoffice ); + $return .= $separator . encode( $extended ); + $return .= $separator . encode( $street ); + $return .= $separator . encode( $city ); + $return .= $separator . encode( $region); + $return .= $separator . encode( $zip ); + $return .= $separator . encode( $country ); + + $this->properties[$key] = $return; + } + + // added ability to set filename + function setFilename( $filename ) { + $this->filename = $filename .'.vcf'; + } + + // added ability to set position/title + function setTitle( $title ) { + $title = trim( $title ); + + $this->properties['TITLE'] = $title; + } + + // added ability to set organisation/company + function setOrg( $org ) { + $org = trim( $org ); + + $this->properties['ORG'] = $org; + } + + function getVCard( $sitename ) { + $text = 'BEGIN:VCARD'; + $text .= "\r\n"; + $text .= 'VERSION:2.1'; + $text .= "\r\n"; + + foreach( $this->properties as $key => $value ) { + $text .= "$key:$value"; + $text .= "\r\n"; + } + $text .= 'REV:'. date( 'Y-m-d' ) .'T'. date( 'H:i:s' ). 'Z'; + $text .= "\r\n"; + $text .= 'MAILER: Joomla! vCard for '. $sitename; + $text .= "\r\n"; + $text .= 'END:VCARD'; + $text .= "\r\n"; + + return $text; + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_contact/tables/contact.php b/oss/joomla/trunk/administrator/components/com_contact/tables/contact.php index 5cd873b0..46abcebf 100644 --- a/oss/joomla/trunk/administrator/components/com_contact/tables/contact.php +++ b/oss/joomla/trunk/administrator/components/com_contact/tables/contact.php @@ -1,119 +1,119 @@ -default_con = intval( $this->default_con ); - - if (JFilterInput::checkAttribute(array ('href', $this->webpage))) { - $this->setError(JText::_('Please provide a valid URL')); - return false; - } - - // check for http on webpage - if (strlen($this->webpage) > 0 && (!(eregi('http://', $this->webpage) || (eregi('https://', $this->webpage)) || (eregi('ftp://', $this->webpage))))) { - $this->webpage = 'http://'.$this->webpage; - } - - if(empty($this->alias)) { - $this->alias = $this->name; - } - $this->alias = JFilterOutput::stringURLSafe($this->alias); - if(trim(str_replace('-','',$this->alias)) == '') { - $datenow =& JFactory::getDate(); - $this->alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S"); - } - - return true; - } -} +default_con = intval( $this->default_con ); + + if (JFilterInput::checkAttribute(array ('href', $this->webpage))) { + $this->setError(JText::_('Please provide a valid URL')); + return false; + } + + // check for http on webpage + if (strlen($this->webpage) > 0 && (!(preg_match('#http://#i', $this->webpage) || (preg_match('#https://#i', $this->webpage)) || (preg_match('#ftp://#i', $this->webpage))))) { + $this->webpage = 'http://'.$this->webpage; + } + + if(empty($this->alias)) { + $this->alias = $this->name; + } + $this->alias = JFilterOutput::stringURLSafe($this->alias); + if(trim(str_replace('-','',$this->alias)) == '') { + $datenow =& JFactory::getDate(); + $this->alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S"); + } + + return true; + } +} diff --git a/oss/joomla/trunk/administrator/components/com_contact/toolbar.contact.html.php b/oss/joomla/trunk/administrator/components/com_contact/toolbar.contact.html.php index 89e4728e..6bb362e3 100644 --- a/oss/joomla/trunk/administrator/components/com_contact/toolbar.contact.html.php +++ b/oss/joomla/trunk/administrator/components/com_contact/toolbar.contact.html.php @@ -1,59 +1,59 @@ -[ '. $text .' ]', 'generic.png' ); - - //JToolBarHelper::custom( 'save2new', 'new.png', 'new_f2.png', 'Save & New', false, false ); - //JToolBarHelper::custom( 'save2copy', 'copy.png', 'copy_f2.png', 'Save To Copy', false, false ); - JToolBarHelper::save(); - JToolBarHelper::apply(); - if ( $edit ) { - // for existing items the button is renamed `close` - JToolBarHelper::cancel( 'cancel', 'Close' ); - } else { - JToolBarHelper::cancel(); - } - JToolBarHelper::help( 'screen.contactmanager.edit' ); - } - - function _DEFAULT() { - - JToolBarHelper::title( JText::_( 'Contact Manager' ), 'generic.png' ); - JToolBarHelper::publishList(); - JToolBarHelper::unpublishList(); - JToolBarHelper::deleteList(); - JToolBarHelper::editListX(); - JToolBarHelper::addNewX(); - JToolBarHelper::preferences('com_contact', '500'); - - JToolBarHelper::help( 'screen.contactmanager' ); - } +[ '. $text .' ]', 'generic.png' ); + + //JToolBarHelper::custom( 'save2new', 'new.png', 'new_f2.png', 'Save & New', false, false ); + //JToolBarHelper::custom( 'save2copy', 'copy.png', 'copy_f2.png', 'Save To Copy', false, false ); + JToolBarHelper::save(); + JToolBarHelper::apply(); + if ( $edit ) { + // for existing items the button is renamed `close` + JToolBarHelper::cancel( 'cancel', 'Close' ); + } else { + JToolBarHelper::cancel(); + } + JToolBarHelper::help( 'screen.contactmanager.edit' ); + } + + function _DEFAULT() { + + JToolBarHelper::title( JText::_( 'Contact Manager' ), 'generic.png' ); + JToolBarHelper::publishList(); + JToolBarHelper::unpublishList(); + JToolBarHelper::deleteList(); + JToolBarHelper::editListX(); + JToolBarHelper::addNewX(); + JToolBarHelper::preferences('com_contact', '500'); + + JToolBarHelper::help( 'screen.contactmanager' ); + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_contact/toolbar.contact.php b/oss/joomla/trunk/administrator/components/com_contact/toolbar.contact.php index 7b37ab8b..bcdf65be 100644 --- a/oss/joomla/trunk/administrator/components/com_contact/toolbar.contact.php +++ b/oss/joomla/trunk/administrator/components/com_contact/toolbar.contact.php @@ -1,33 +1,33 @@ - -
    - - - - - - -
    - : - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - getNullDate(); - for ($i=0, $n=count( $rows ); $i < $n; $i++) - { - $row = &$rows[$i]; - - $link = 'index.php?option=com_content§ionid='. $redirect .'&task=edit&cid[]='. $row->id; - - $row->sect_link = JRoute::_( 'index.php?option=com_sections&task=edit&cid[]='. $row->sectionid ); - $row->cat_link = JRoute::_( 'index.php?option=com_categories&task=edit&cid[]='. $row->catid ); - - $publish_up =& JFactory::getDate($row->publish_up); - $publish_down =& JFactory::getDate($row->publish_down); - $publish_up->setOffset($config->getValue('config.offset')); - $publish_down->setOffset($config->getValue('config.offset')); - if ( $now->toUnix() <= $publish_up->toUnix() && $row->state == 1 ) { - $img = 'publish_y.png'; - $alt = JText::_( 'Published' ); - } else if ( ( $now->toUnix() <= $publish_down->toUnix() || $row->publish_down == $nullDate ) && $row->state == 1 ) { - $img = 'publish_g.png'; - $alt = JText::_( 'Published' ); - } else if ( $now->toUnix() > $publish_down->toUnix() && $row->state == 1 ) { - $img = 'publish_r.png'; - $alt = JText::_( 'Expired' ); - } else if ( $row->state == 0 ) { - $img = 'publish_x.png'; - $alt = JText::_( 'Unpublished' ); - } else if ( $row->state == -1 ) { - $img = 'disabled.png'; - $alt = JText::_( 'Archived' ); - } - $times = ''; - if (isset($row->publish_up)) { - if ($row->publish_up == $nullDate) { - $times .= JText::_( 'Start: Always' ); - } else { - $times .= JText::_( 'Start' ) .": ". $publish_up->toFormat(); - } - } - if (isset($row->publish_down)) { - if ($row->publish_down == $nullDate) { - $times .= "
    ". JText::_( 'Finish: No Expiry' ); - } else { - $times .= "
    ". JText::_( 'Finish' ) .": ". $publish_down->toFormat(); - } - } - - if ( $user->authorize( 'com_users', 'manage' ) ) { - if ( $row->created_by_alias ) { - $author = $row->created_by_alias; - } else { - $linkA = 'index.php?option=com_users&task=edit&cid[]='. $row->created_by; - $author = ''. $row->author .''; - } - } else { - if ( $row->created_by_alias ) { - $author = $row->created_by_alias; - } else { - $author = $row->author; - } - } - - $access = JHTML::_('grid.access', $row, $i, $row->state ); - $checked = JHTML::_('grid.checkedout', $row, $i ); - ?> - "> - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - getListFooter(); ?> -
    - getRowOffset( $i ); ?> - - - - get ('id'), $row->checked_out ) ) { - echo $row->title; - } else if ($row->state == -1) { - echo htmlspecialchars($row->title, ENT_QUOTES, 'UTF-8'); - echo ' [ '. JText::_( 'Archived' ) .' ]'; - } else { - ?> - - title, ENT_QUOTES); ?> - - - - <?php echo $alt; ?> - - - <?php echo ( $row->frontpage ) ? JText::_( 'Yes' ) : JText::_( 'No' );?> - - orderUpIcon( $i, ($row->catid == @$rows[$i-1]->catid), 'orderup', 'Move Up', $ordering); ?> - orderDownIcon( $i, $n, ($row->catid == @$rows[$i+1]->catid), 'orderdown', 'Move Down', $ordering ); ?> - - class="text_area" style="text-align: center" /> - - - - - section_name; ?> - - - name; ?> - - - - created, JText::_('DATE_FORMAT_LC4') ); ?> - - hits ?> - - id; ?> -
    - - - - - - - - - -
    - - -
    - - - - - - -
    - : - - - - - -
    - -
    - - - - - - - - - - - - - - - - - - - - cat_link = JRoute::_( 'index.php?option=com_categories&task=edit&cid[]='. $row->catid ); - $row->sec_link = JRoute::_( 'index.php?option=com_sections&task=edit&cid[]='. $row->sectionid ); - - if ( $user->authorize( 'com_users', 'manage' ) ) { - if ( $row->created_by_alias ) { - $author = $row->created_by_alias; - } else { - $linkA = JRoute::_( 'index.php?option=com_users&task=edit&cid[]='. $row->created_by ); - $author = ''. $row->author .''; - } - } else { - if ( $row->created_by_alias ) { - $author = $row->created_by_alias; - } else { - $author = $row->author; - } - } - - ?> - "> - - - - - - - - - - - -
    - - - - - - - - - - - - - - - -
    - getListFooter(); ?> -
    - getRowOffset( $i ); ?> - - id ); ?> - - title; ?> - - id; ?> - - - sectname; ?> - - - name; ?> - - - - created, JText::_( 'DATE_FORMAT_LC4' ) ); ?> -
    -
    - - - - - - - - - - -
    - $row is passed with the id - * property set to 0. - * @param JTableContent The category object - * @param string The html for the groups select list - */ - function editContent( &$row, $section, &$lists, &$sectioncategories, $option, &$form ) - { - JRequest::setVar( 'hidemainmenu', 1 ); - - jimport('joomla.html.pane'); - JFilterOutput::objectHTMLSafe( $row ); - - $db = &JFactory::getDBO(); - $editor = &JFactory::getEditor(); - // TODO: allowAllClose should default true in J!1.6, so remove the array when it does. - $pane = &JPane::getInstance('sliders', array('allowAllClose' => true)); - - JHTML::_('behavior.tooltip'); - ?> - - -
    - - - - - - -
    - - - - - -
    - display( 'text', $row->text , '100%', '550', '75', '20' ) ; - ?> -
    -
    - startPane("content-pane"); - echo $pane->startPanel( $title, "detail-page" ); - echo $form->render('details'); - - $title = JText::_( 'Parameters - Advanced' ); - echo $pane->endPanel(); - echo $pane->startPanel( $title, "params-page" ); - echo $form->render('params', 'advanced'); - - $title = JText::_( 'Metadata Information' ); - echo $pane->endPanel(); - echo $pane->startPanel( $title, "metadata-page" ); - echo $form->render('meta', 'metadata'); - - echo $pane->endPanel(); - echo $pane->endPane(); - ?> -
    - - - - - - - - -
    - - - -
    - - - - - - -
    - : -
    - -

    -
    - : -
    - "; - foreach ( $items as $item ) { - echo "
  • ". $item->title ."
  • "; - } - echo ""; - ?> -
    -

    - - - - - "; - } - ?> - -
    - - -
    - - - - - - -
    - : -
    - -

    -
    - : -
    - "; - foreach ( $items as $item ) { - echo "
  • ". $item->title ."
  • "; - } - echo ""; - ?> -
    -

    - - - - - "; - } - ?> - -
    - setLink(JURI::root()); - - JHTML::_('behavior.caption'); - - ?> - - - - - - - - - -
    - - - -
    - - - - - - - - - -
    - - - -
    - - - -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - -
    - - - - - - - -
    - - - - - - - -
    - getNullDate(); - - // used to hide "Reset Hits" when hits = 0 - if ( !$row->hits ) { - $visibility = 'style="display: none; visibility: hidden;"'; - } else { - $visibility = ''; - } - - ?> - - id ) { - ?> - - - - - - - - - - - - - - - - - - - - - - - - - -
    - : - - id; ?> -
    - - - state > 0 ? JText::_( 'Published' ) : ($row->state < 0 ? JText::_( 'Archived' ) : JText::_( 'Draft Unpublished' ) );?> -
    - - - hits;?> - > - - -
    - - - version;?> -
    - - - created == $nullDate ) { - echo JText::_( 'New document' ); - } else { - echo JHTML::_('date', $row->created, JText::_('DATE_FORMAT_LC2') ); - } - ?> -
    - - - modified == $nullDate ) { - echo JText::_( 'Not modified' ); - } else { - echo JHTML::_('date', $row->modified, JText::_('DATE_FORMAT_LC2')); - } - ?> -
    - +
    + + + + + + +
    + : + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + getNullDate(); + for ($i=0, $n=count( $rows ); $i < $n; $i++) + { + $row = &$rows[$i]; + + $link = 'index.php?option=com_content§ionid='. $redirect .'&task=edit&cid[]='. $row->id; + + $row->sect_link = JRoute::_( 'index.php?option=com_sections&task=edit&cid[]='. $row->sectionid ); + $row->cat_link = JRoute::_( 'index.php?option=com_categories&task=edit&cid[]='. $row->catid ); + + $publish_up =& JFactory::getDate($row->publish_up); + $publish_down =& JFactory::getDate($row->publish_down); + $publish_up->setOffset($config->getValue('config.offset')); + $publish_down->setOffset($config->getValue('config.offset')); + if ( $now->toUnix() <= $publish_up->toUnix() && $row->state == 1 ) { + $img = 'publish_y.png'; + $alt = JText::_( 'Published' ); + } else if ( ( $now->toUnix() <= $publish_down->toUnix() || $row->publish_down == $nullDate ) && $row->state == 1 ) { + $img = 'publish_g.png'; + $alt = JText::_( 'Published' ); + } else if ( $now->toUnix() > $publish_down->toUnix() && $row->state == 1 ) { + $img = 'publish_r.png'; + $alt = JText::_( 'Expired' ); + } else if ( $row->state == 0 ) { + $img = 'publish_x.png'; + $alt = JText::_( 'Unpublished' ); + } else if ( $row->state == -1 ) { + $img = 'disabled.png'; + $alt = JText::_( 'Archived' ); + } + $times = ''; + if (isset($row->publish_up)) { + if ($row->publish_up == $nullDate) { + $times .= JText::_( 'Start: Always' ); + } else { + $times .= JText::_( 'Start' ) .": ". $publish_up->toFormat(); + } + } + if (isset($row->publish_down)) { + if ($row->publish_down == $nullDate) { + $times .= "
    ". JText::_( 'Finish: No Expiry' ); + } else { + $times .= "
    ". JText::_( 'Finish' ) .": ". $publish_down->toFormat(); + } + } + + if ( $user->authorize( 'com_users', 'manage' ) ) { + if ( $row->created_by_alias ) { + $author = $row->created_by_alias; + } else { + $linkA = 'index.php?option=com_users&task=edit&cid[]='. $row->created_by; + $author = ''. $row->author .''; + } + } else { + if ( $row->created_by_alias ) { + $author = $row->created_by_alias; + } else { + $author = $row->author; + } + } + + $access = JHTML::_('grid.access', $row, $i, $row->state ); + $checked = JHTML::_('grid.checkedout', $row, $i ); + ?> + "> + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + getListFooter(); ?> +
    + getRowOffset( $i ); ?> + + + + get ('id'), $row->checked_out ) ) { + echo $row->title; + } else if ($row->state == -1) { + echo htmlspecialchars($row->title, ENT_QUOTES, 'UTF-8'); + echo ' [ '. JText::_( 'Archived' ) .' ]'; + } else { + ?> + + title, ENT_QUOTES); ?> + + + + <?php echo $alt; ?> + + + <?php echo ( $row->frontpage ) ? JText::_( 'Yes' ) : JText::_( 'No' );?> + + orderUpIcon( $i, ($row->catid == @$rows[$i-1]->catid), 'orderup', 'Move Up', $ordering); ?> + orderDownIcon( $i, $n, ($row->catid == @$rows[$i+1]->catid), 'orderdown', 'Move Down', $ordering ); ?> + + class="text_area" style="text-align: center" /> + + + + + section_name; ?> + + + name; ?> + + + + created, JText::_('DATE_FORMAT_LC4') ); ?> + + hits ?> + + id; ?> +
    + + + + + + + + + +
    + + +
    + + + + + + +
    + : + + + + + +
    + +
    + + + + + + + + + + + + + + + + + + + + cat_link = JRoute::_( 'index.php?option=com_categories&task=edit&cid[]='. $row->catid ); + $row->sec_link = JRoute::_( 'index.php?option=com_sections&task=edit&cid[]='. $row->sectionid ); + + if ( $user->authorize( 'com_users', 'manage' ) ) { + if ( $row->created_by_alias ) { + $author = $row->created_by_alias; + } else { + $linkA = JRoute::_( 'index.php?option=com_users&task=edit&cid[]='. $row->created_by ); + $author = ''. $row->author .''; + } + } else { + if ( $row->created_by_alias ) { + $author = $row->created_by_alias; + } else { + $author = $row->author; + } + } + + ?> + "> + + + + + + + + + + + +
    + + + + + + + + + + + + + + + +
    + getListFooter(); ?> +
    + getRowOffset( $i ); ?> + + id ); ?> + + title; ?> + + id; ?> + + + sectname; ?> + + + name; ?> + + + + created, JText::_( 'DATE_FORMAT_LC4' ) ); ?> +
    +
    + + + + + + + + + + +
    + $row is passed with the id + * property set to 0. + * @param JTableContent The category object + * @param string The html for the groups select list + */ + function editContent( &$row, $section, &$lists, &$sectioncategories, $option, &$form ) + { + JRequest::setVar( 'hidemainmenu', 1 ); + + jimport('joomla.html.pane'); + JFilterOutput::objectHTMLSafe( $row ); + + $db = &JFactory::getDBO(); + $editor = &JFactory::getEditor(); + // TODO: allowAllClose should default true in J!1.6, so remove the array when it does. + $pane = &JPane::getInstance('sliders', array('allowAllClose' => true)); + + JHTML::_('behavior.tooltip'); + ?> + + +
    + + + + + + +
    + + + + + +
    + display( 'text', $row->text , '100%', '550', '75', '20' ) ; + ?> +
    +
    + startPane("content-pane"); + echo $pane->startPanel( $title, "detail-page" ); + echo $form->render('details'); + + $title = JText::_( 'Parameters - Advanced' ); + echo $pane->endPanel(); + echo $pane->startPanel( $title, "params-page" ); + echo $form->render('params', 'advanced'); + + $title = JText::_( 'Metadata Information' ); + echo $pane->endPanel(); + echo $pane->startPanel( $title, "metadata-page" ); + echo $form->render('meta', 'metadata'); + + echo $pane->endPanel(); + echo $pane->endPane(); + ?> +
    + + + + + + + + +
    + + + +
    + + + + + + +
    + : +
    + +

    +
    + : +
    + "; + foreach ( $items as $item ) { + echo "
  • ". $item->title ."
  • "; + } + echo ""; + ?> +
    +

    + + + + + "; + } + ?> + +
    + + +
    + + + + + + +
    + : +
    + +

    +
    + : +
    + "; + foreach ( $items as $item ) { + echo "
  • ". $item->title ."
  • "; + } + echo ""; + ?> +
    +

    + + + + + "; + } + ?> + +
    + setLink(JURI::root()); + + JHTML::_('behavior.caption'); + + ?> + + + + + + + + + +
    + + + +
    + + + + + + + + + +
    + + + +
    + + + +
    +
    + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + +
    + + + + + + + +
    + + + + + + + +
    + getNullDate(); + + // used to hide "Reset Hits" when hits = 0 + if ( !$row->hits ) { + $visibility = 'style="display: none; visibility: hidden;"'; + } else { + $visibility = ''; + } + + ?> + + id ) { + ?> + + + + + + + + + + + + + + + + + + + + + + + + + +
    + : + + id; ?> +
    + + + state > 0 ? JText::_( 'Published' ) : ($row->state < 0 ? JText::_( 'Archived' ) : JText::_( 'Draft Unpublished' ) );?> +
    + + + hits;?> + > + + +
    + + + version;?> +
    + + + created == $nullDate ) { + echo JText::_( 'New document' ); + } else { + echo JHTML::_('date', $row->created, JText::_('DATE_FORMAT_LC2') ); + } + ?> +
    + + + modified == $nullDate ) { + echo JText::_( 'Not modified' ); + } else { + echo JHTML::_('date', $row->modified, JText::_('DATE_FORMAT_LC2')); + } + ?> +
    + execute( $task ); - $controller->redirect(); - break; - - case 'add' : - case 'new' : - ContentController::editContent(false); - break; - - case 'edit' : - ContentController::editContent(true); - break; - - case 'go2menu' : - case 'go2menuitem' : - case 'resethits' : - case 'menulink' : - case 'apply' : - case 'save' : - ContentController::saveContent(); - break; - - case 'remove' : - ContentController::removeContent(); - break; - - case 'publish' : - ContentController::changeContent(1); - break; - - case 'unpublish' : - ContentController::changeContent(0); - break; - - case 'toggle_frontpage' : - ContentController::toggleFrontPage(); - break; - - case 'archive' : - ContentController::changeContent(-1); - break; - - case 'unarchive' : - ContentController::changeContent(0); - break; - - case 'cancel' : - ContentController::cancelContent(); - break; - - case 'orderup' : - ContentController::orderContent(-1); - break; - - case 'orderdown' : - ContentController::orderContent(1); - break; - - //case 'showarchive' : - // JContentController::viewArchive(); - // break; - - case 'movesect' : - ContentController::moveSection(); - break; - - case 'movesectsave' : - ContentController::moveSectionSave(); - break; - - case 'copy' : - ContentController::copyItem(); - break; - - case 'copysave' : - ContentController::copyItemSave(); - break; - - case 'accesspublic' : - ContentController::accessMenu(0); - break; - - case 'accessregistered' : - ContentController::accessMenu(1); - break; - - case 'accessspecial' : - ContentController::accessMenu(2); - break; - - case 'saveorder' : - ContentController::saveOrder(); - break; - - case 'preview' : - ContentController::previewContent(); - break; - - case 'ins_pagebreak' : - ContentController::insertPagebreak(); - break; - - default : - ContentController::viewContent(); - break; +execute( $task ); + $controller->redirect(); + break; + + case 'add' : + case 'new' : + ContentController::editContent(false); + break; + + case 'edit' : + ContentController::editContent(true); + break; + + case 'go2menu' : + case 'go2menuitem' : + case 'resethits' : + case 'menulink' : + case 'apply' : + case 'save' : + ContentController::saveContent(); + break; + + case 'remove' : + ContentController::removeContent(); + break; + + case 'publish' : + ContentController::changeContent(1); + break; + + case 'unpublish' : + ContentController::changeContent(0); + break; + + case 'toggle_frontpage' : + ContentController::toggleFrontPage(); + break; + + case 'archive' : + ContentController::changeContent(-1); + break; + + case 'unarchive' : + ContentController::changeContent(0); + break; + + case 'cancel' : + ContentController::cancelContent(); + break; + + case 'orderup' : + ContentController::orderContent(-1); + break; + + case 'orderdown' : + ContentController::orderContent(1); + break; + + //case 'showarchive' : + // JContentController::viewArchive(); + // break; + + case 'movesect' : + ContentController::moveSection(); + break; + + case 'movesectsave' : + ContentController::moveSectionSave(); + break; + + case 'copy' : + ContentController::copyItem(); + break; + + case 'copysave' : + ContentController::copyItemSave(); + break; + + case 'accesspublic' : + ContentController::accessMenu(0); + break; + + case 'accessregistered' : + ContentController::accessMenu(1); + break; + + case 'accessspecial' : + ContentController::accessMenu(2); + break; + + case 'saveorder' : + ContentController::saveOrder(); + break; + + case 'preview' : + ContentController::previewContent(); + break; + + case 'ins_pagebreak' : + ContentController::insertPagebreak(); + break; + + default : + ContentController::viewContent(); + break; } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_content/content.xml b/oss/joomla/trunk/administrator/components/com_content/content.xml index bdee0dd0..464215d7 100644 --- a/oss/joomla/trunk/administrator/components/com_content/content.xml +++ b/oss/joomla/trunk/administrator/components/com_content/content.xml @@ -1,14 +1,14 @@ - - - Content Page - Joomla! Project - April 2006 - - Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. - - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - admin@joomla.org - www.joomla.org - 1.5.0 - DESCCONTENT + + + Content Page + Joomla! Project + April 2006 + + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + DESCCONTENT \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_content/controller.php b/oss/joomla/trunk/administrator/components/com_content/controller.php index cc75668c..59113b3a 100644 --- a/oss/joomla/trunk/administrator/components/com_content/controller.php +++ b/oss/joomla/trunk/administrator/components/com_content/controller.php @@ -1,1469 +1,1475 @@ -getModel( 'element' ); - $view = &$this->getView( 'element'); - $view->setModel( $model, true ); - $view->display(); - } - - /** - * Compiles a list of installed or defined modules - * @param database A database connector object - */ - function viewContent() - { - global $mainframe; - - // Initialize variables - $db =& JFactory::getDBO(); - $filter = null; - - // Get some variables from the request - $sectionid = JRequest::getVar( 'sectionid', -1, '', 'int' ); - $redirect = $sectionid; - $option = JRequest::getCmd( 'option' ); - $context = 'com_content.viewcontent'; - $filter_order = $mainframe->getUserStateFromRequest( $context.'filter_order', 'filter_order', '', 'cmd' ); - $filter_order_Dir = $mainframe->getUserStateFromRequest( $context.'filter_order_Dir', 'filter_order_Dir', '', 'word' ); - $filter_state = $mainframe->getUserStateFromRequest( $context.'filter_state', 'filter_state', '', 'word' ); - $catid = $mainframe->getUserStateFromRequest( $context.'catid', 'catid', 0, 'int' ); - $filter_authorid = $mainframe->getUserStateFromRequest( $context.'filter_authorid', 'filter_authorid', 0, 'int' ); - $filter_sectionid = $mainframe->getUserStateFromRequest( $context.'filter_sectionid', 'filter_sectionid', -1, 'int' ); - $search = $mainframe->getUserStateFromRequest( $context.'search', 'search', '', 'string' ); - $search = JString::strtolower($search); - - $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); - $limitstart = $mainframe->getUserStateFromRequest($context.'limitstart', 'limitstart', 0, 'int'); - - // In case limit has been changed, adjust limitstart accordingly - $limitstart = ( $limit != 0 ? (floor($limitstart / $limit) * $limit) : 0 ); - - //$where[] = "c.state >= 0"; - $where[] = 'c.state != -2'; - - if (!$filter_order) { - $filter_order = 'section_name'; - } - if ($filter_order == 'c.ordering') { - $order = ' ORDER BY section_name, cc.title, c.ordering '. $filter_order_Dir; - } else { - $order = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', section_name, cc.title, c.ordering'; - } - $all = 1; - - if ($filter_sectionid >= 0) { - $filter = ' WHERE cc.section = '. (int) $filter_sectionid; - } - $section->title = 'All Articles'; - $section->id = 0; - - /* - * Add the filter specific information to the where clause - */ - // Section filter - if ($filter_sectionid >= 0) { - $where[] = 'c.sectionid = ' . (int) $filter_sectionid; - } - // Category filter - if ($catid > 0) { - $where[] = 'c.catid = ' . (int) $catid; - } - // Author filter - if ($filter_authorid > 0) { - $where[] = 'c.created_by = ' . (int) $filter_authorid; - } - // Content state filter - if ($filter_state) { - if ($filter_state == 'P') { - $where[] = 'c.state = 1'; - } else { - if ($filter_state == 'U') { - $where[] = 'c.state = 0'; - } else if ($filter_state == 'A') { - $where[] = 'c.state = -1'; - } else { - $where[] = 'c.state != -2'; - } - } - } - // Keyword filter - if ($search) { - $where[] = '(LOWER( c.title ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ) . - ' OR c.id = ' . (int) $search . ')'; - } - - // Build the where clause of the content record query - $where = (count($where) ? ' WHERE '.implode(' AND ', $where) : ''); - - // Get the total number of records - $query = 'SELECT COUNT(*)' . - ' FROM #__content AS c' . - ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' . - ' LEFT JOIN #__sections AS s ON s.id = c.sectionid' . - $where; - $db->setQuery($query); - $total = $db->loadResult(); - - - // Create the pagination object - jimport('joomla.html.pagination'); - $pagination = new JPagination($total, $limitstart, $limit); - - // Get the articles - $query = 'SELECT c.*, g.name AS groupname, cc.title AS name, u.name AS editor, f.content_id AS frontpage, s.title AS section_name, v.name AS author' . - ' FROM #__content AS c' . - ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' . - ' LEFT JOIN #__sections AS s ON s.id = c.sectionid' . - ' LEFT JOIN #__groups AS g ON g.id = c.access' . - ' LEFT JOIN #__users AS u ON u.id = c.checked_out' . - ' LEFT JOIN #__users AS v ON v.id = c.created_by' . - ' LEFT JOIN #__content_frontpage AS f ON f.content_id = c.id' . - $where . - $order; - $db->setQuery($query, $pagination->limitstart, $pagination->limit); - $rows = $db->loadObjectList(); - - // If there is a database query error, throw a HTTP 500 and exit - if ($db->getErrorNum()) { - JError::raiseError( 500, $db->stderr() ); - return false; - } - - // get list of categories for dropdown filter - $query = 'SELECT cc.id AS value, cc.title AS text, section' . - ' FROM #__categories AS cc' . - ' INNER JOIN #__sections AS s ON s.id = cc.section ' . - $filter . - ' ORDER BY s.ordering, cc.ordering'; - $lists['catid'] = ContentHelper::filterCategory($query, $catid); - - // get list of sections for dropdown filter - $javascript = 'onchange="document.adminForm.submit();"'; - $lists['sectionid'] = JHTML::_('list.section', 'filter_sectionid', $filter_sectionid, $javascript); - - // get list of Authors for dropdown filter - $query = 'SELECT c.created_by, u.name' . - ' FROM #__content AS c' . - ' INNER JOIN #__sections AS s ON s.id = c.sectionid' . - ' LEFT JOIN #__users AS u ON u.id = c.created_by' . - ' WHERE c.state <> -1' . - ' AND c.state <> -2' . - ' GROUP BY u.name' . - ' ORDER BY u.name'; - $authors[] = JHTML::_('select.option', '0', '- '.JText::_('Select Author').' -', 'created_by', 'name'); - $db->setQuery($query); - $authors = array_merge($authors, $db->loadObjectList()); - $lists['authorid'] = JHTML::_('select.genericlist', $authors, 'filter_authorid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'created_by', 'name', $filter_authorid); - - // state filter - $lists['state'] = JHTML::_('grid.state', $filter_state, 'Published', 'Unpublished', 'Archived'); - - // table ordering - $lists['order_Dir'] = $filter_order_Dir; - $lists['order'] = $filter_order; - - // search filter - $lists['search'] = $search; - - ContentView::showContent($rows, $lists, $pagination, $redirect); - } - - /** - * Shows a list of archived articles - * @param int The section id - */ - function viewArchive() - { - global $mainframe; - - // Initialize variables - $db =& JFactory::getDBO(); - - $sectionid = JRequest::getVar( 'sectionid', 0, '', 'int' ); - $option = JRequest::getCmd( 'option' ); - - $filter_order = $mainframe->getUserStateFromRequest("$option.$sectionid.viewarchive.filter_order", 'filter_order', 'sectname', 'cmd'); - $filter_order_Dir = $mainframe->getUserStateFromRequest("$option.$sectionid.viewarchive.filter_order_Dir", 'filter_order_Dir', '', 'word'); - $catid = $mainframe->getUserStateFromRequest("$option.$sectionid.viewarchive.catid", 'catid', 0, 'int'); - $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); - $limitstart = $mainframe->getUserStateFromRequest("$option.$sectionid.viewarchive.limitstart", 'limitstart', 0, 'int'); - $filter_authorid = $mainframe->getUserStateFromRequest("$option.$sectionid.viewarchive.filter_authorid", 'filter_authorid', 0, 'int'); - $filter_sectionid = $mainframe->getUserStateFromRequest("$option.$sectionid.viewarchive.filter_sectionid", 'filter_sectionid', 0, 'int'); - $search = $mainframe->getUserStateFromRequest("$option.$sectionid.viewarchive.search", 'search', '', 'string'); - $search = JString::strtolower($search); - $redirect = $sectionid; - - // A section id of zero means view all articles [all sections] - if ($sectionid == 0) - { - $where = array ('c.state = -1', 'c.catid = cc.id', 'cc.section = s.id', 's.scope = "content"'); - $filter = ' , #__sections AS s WHERE s.id = c.section'; - $all = 1; - } - else - { - //We are viewing a specific section - $where = array ('c.state = -1', 'c.catid = cc.id', 'cc.section = s.id', 's.scope = "content"', 'c.sectionid= '.(int) $sectionid); - $filter = ' WHERE section = '.$db->Quote($sectionid); - $all = NULL; - } - - // Section filter - if ($filter_sectionid > 0) - { - $where[] = 'c.sectionid = ' . (int) $filter_sectionid; - } - // Author filter - if ($filter_authorid > 0) - { - $where[] = 'c.created_by = ' . (int) $filter_authorid; - } - // Category filter - if ($catid > 0) - { - $where[] = 'c.catid = ' . (int) $catid; - } - // Keyword filter - if ($search) - { - $where[] = 'LOWER( c.title ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); - } - - // TODO: Sanitise $filter_order - $filter_order_Dir = ($filter_order_Dir == 'ASC' ? 'ASC' : 'DESC'); - $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', sectname, cc.name, c.ordering'; - $where = (count($where) ? ' WHERE '.implode(' AND ', $where) : ''); - - // get the total number of records - $query = 'SELECT COUNT(*)' . - ' FROM #__content AS c' . - ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' . - ' LEFT JOIN #__sections AS s ON s.id = c.sectionid' . - $where; - $db->setQuery($query); - $total = $db->loadResult(); - - jimport('joomla.html.pagination'); - $pagination = new JPagination($total, $limitstart, $limit); - - $query = 'SELECT c.*, g.name AS groupname, cc.name, v.name AS author, s.title AS sectname' . - ' FROM #__content AS c' . - ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' . - ' LEFT JOIN #__sections AS s ON s.id = c.sectionid' . - ' LEFT JOIN #__groups AS g ON g.id = c.access' . - ' LEFT JOIN #__users AS v ON v.id = c.created_by' . - $where . - $orderby; - $db->setQuery($query, $pagination->limitstart, $pagination->limit); - $rows = $db->loadObjectList(); - - // If there is a database query error, throw a HTTP 500 and exit - if ($db->getErrorNum()) - { - JError::raiseError( 500, $db->stderr() ); - return false; - } - - // get list of categories for dropdown filter - $query = 'SELECT c.id AS value, c.title AS text' . - ' FROM #__categories AS c' . - $filter . - ' ORDER BY c.ordering'; - $lists['catid'] = ContentHelper::filterCategory($query, $catid); - - // get list of sections for dropdown filter - $javascript = 'onchange="document.adminForm.submit();"'; - $lists['sectionid'] = JAdminMenus::SelectSection('filter_sectionid', $filter_sectionid, $javascript); - - $section = & JTable::getInstance('section'); - $section->load($sectionid); - - // get list of Authors for dropdown filter - $query = 'SELECT c.created_by, u.name' . - ' FROM #__content AS c' . - ' INNER JOIN #__sections AS s ON s.id = c.sectionid' . - ' LEFT JOIN #__users AS u ON u.id = c.created_by' . - ' WHERE c.state = -1' . - ' GROUP BY u.name' . - ' ORDER BY u.name'; - $db->setQuery($query); - $authors[] = JHTML::_('select.option', '0', '- '.JText::_('Select Author').' -', 'created_by', 'name'); - $authors = array_merge($authors, $db->loadObjectList()); - $lists['authorid'] = JHTML::_('select.genericlist', $authors, 'filter_authorid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'created_by', 'name', $filter_authorid); - - // table ordering - $lists['order_Dir'] = $filter_order_Dir; - $lists['order'] = $filter_order; - - // search filter - $lists['search'] = $search; - - ContentView::showArchive($rows, $section, $lists, $pagination, $option, $all, $redirect); - } - - /** - * Compiles information to add or edit the record - * - * @param database A database connector object - * @param integer The unique id of the record to edit (0 if new) - * @param integer The id of the content section - */ - function editContent($edit) - { - global $mainframe; - - // Initialize variables - $db = & JFactory::getDBO(); - $user = & JFactory::getUser(); - - $cid = JRequest::getVar( 'cid', array(0), '', 'array' ); - JArrayHelper::toInteger($cid, array(0)); - $id = JRequest::getVar( 'id', $cid[0], '', 'int' ); - $option = JRequest::getCmd( 'option' ); - $nullDate = $db->getNullDate(); - $contentSection = ''; - $sectionid = 0; - - // Create and load the content table row - $row = & JTable::getInstance('content'); - if($edit) - $row->load($id); - - if ($id) { - $sectionid = $row->sectionid; - if ($row->state < 0) { - $mainframe->redirect('index.php?option=com_content', JText::_('You cannot edit an archived item')); - } - } - - // A sectionid of zero means grab from all sections - if ($sectionid == 0) { - $where = ' WHERE section NOT LIKE "%com_%"'; - } else { - // Grab from the specific section - $where = ' WHERE section = '. $db->Quote( $sectionid ); - } - - /* - * If the item is checked out we cannot edit it... unless it was checked - * out by the current user. - */ - if ( JTable::isCheckedOut($user->get ('id'), $row->checked_out )) - { - $msg = JText::sprintf('DESCBEINGEDITTED', JText::_('The item'), $row->title); - $mainframe->redirect('index.php?option=com_content', $msg); - } - - if ($id) - { - $row->checkout($user->get('id')); - - if (trim($row->images)) { - $row->images = explode("\n", $row->images); - } else { - $row->images = array (); - } - - $query = 'SELECT name' . - ' FROM #__users'. - ' WHERE id = '. (int) $row->created_by; - $db->setQuery($query); - $row->creator = $db->loadResult(); - - // test to reduce unneeded query - if ($row->created_by == $row->modified_by) { - $row->modifier = $row->creator; - } else { - $query = 'SELECT name' . - ' FROM #__users' . - ' WHERE id = '. (int) $row->modified_by; - $db->setQuery($query); - $row->modifier = $db->loadResult(); - } - - $query = 'SELECT COUNT(content_id)' . - ' FROM #__content_frontpage' . - ' WHERE content_id = '. (int) $row->id; - $db->setQuery($query); - $row->frontpage = $db->loadResult(); - if (!$row->frontpage) { - $row->frontpage = 0; - } - } - else - { - if (!$sectionid && JRequest::getInt('filter_sectionid')) { - $sectionid =JRequest::getInt('filter_sectionid'); - } - - if (JRequest::getInt('catid')) - { - $row->catid = JRequest::getInt('catid'); - $category = & JTable::getInstance('category'); - $category->load($row->catid); - $sectionid = $category->section; - } else { - $row->catid = NULL; - } - $createdate =& JFactory::getDate(); - $row->sectionid = $sectionid; - $row->version = 0; - $row->state = 1; - $row->ordering = 0; - $row->images = array (); - $row->publish_up = $createdate->toUnix(); - $row->publish_down = JText::_('Never'); - $row->creator = ''; - $row->created = $createdate->toUnix(); - $row->modified = $nullDate; - $row->modifier = ''; - $row->frontpage = 0; - - } - - $javascript = "onchange=\"changeDynaList( 'catid', sectioncategories, document.adminForm.sectionid.options[document.adminForm.sectionid.selectedIndex].value, 0, 0);\""; - - $query = 'SELECT s.id, s.title' . - ' FROM #__sections AS s' . - ' ORDER BY s.ordering'; - $db->setQuery($query); - - $sections[] = JHTML::_('select.option', '-1', '- '.JText::_('Select Section').' -', 'id', 'title'); - $sections[] = JHTML::_('select.option', '0', JText::_('Uncategorized'), 'id', 'title'); - $sections = array_merge($sections, $db->loadObjectList()); - $lists['sectionid'] = JHTML::_('select.genericlist', $sections, 'sectionid', 'class="inputbox" size="1" '.$javascript, 'id', 'title', intval($row->sectionid)); - - foreach ($sections as $section) - { - $section_list[] = (int) $section->id; - // get the type name - which is a special category - if ($row->sectionid) { - if ($section->id == $row->sectionid) { - $contentSection = $section->title; - } - } else { - if ($section->id == $sectionid) { - $contentSection = $section->title; - } - } - } - - $sectioncategories = array (); - $sectioncategories[-1] = array (); - $sectioncategories[-1][] = JHTML::_('select.option', '-1', JText::_( 'Select Category' ), 'id', 'title'); - $section_list = implode('\', \'', $section_list); - - $query = 'SELECT id, title, section' . - ' FROM #__categories' . - ' WHERE section IN ( \''.$section_list.'\' )' . - ' ORDER BY ordering'; - $db->setQuery($query); - $cat_list = $db->loadObjectList(); - - // Uncategorized category mapped to uncategorized section - $uncat = new stdClass(); - $uncat->id = 0; - $uncat->title = JText::_('Uncategorized'); - $uncat->section = 0; - $cat_list[] = $uncat; - foreach ($sections as $section) - { - $sectioncategories[$section->id] = array (); - $rows2 = array (); - foreach ($cat_list as $cat) - { - if ($cat->section == $section->id) { - $rows2[] = $cat; - } - } - foreach ($rows2 as $row2) { - $sectioncategories[$section->id][] = JHTML::_('select.option', $row2->id, $row2->title, 'id', 'title'); - } - } - $sectioncategories['-1'][] = JHTML::_('select.option', '-1', JText::_( 'Select Category' ), 'id', 'title'); - $categories = array(); - foreach ($cat_list as $cat) { - if($cat->section == $row->sectionid) - $categories[] = $cat; - } - - $categories[] = JHTML::_('select.option', '-1', JText::_( 'Select Category' ), 'id', 'title'); - $lists['catid'] = JHTML::_('select.genericlist', $categories, 'catid', 'class="inputbox" size="1"', 'id', 'title', intval($row->catid)); - - // build the html select list for ordering - $query = 'SELECT ordering AS value, title AS text' . - ' FROM #__content' . - ' WHERE catid = ' . (int) $row->catid . - ' AND state >= 0' . - ' ORDER BY ordering'; - if($edit) - $lists['ordering'] = JHTML::_('list.specificordering', $row, $id, $query, 1); - else - $lists['ordering'] = JHTML::_('list.specificordering', $row, '', $query, 1); - - // build the html radio buttons for frontpage - $lists['frontpage'] = JHTML::_('select.booleanlist', 'frontpage', '', $row->frontpage); - - // build the html radio buttons for published - $lists['state'] = JHTML::_('select.booleanlist', 'state', '', $row->state); - - /* - * We need to unify the introtext and fulltext fields and have the - * fields separated by the {readmore} tag, so lets do that now. - */ - if (JString::strlen($row->fulltext) > 1) { - $row->text = $row->introtext . "
    " . $row->fulltext; - } else { - $row->text = $row->introtext; - } - - // Create the form - $form = new JParameter('', JPATH_COMPONENT.DS.'models'.DS.'article.xml'); - - // Details Group - $active = (intval($row->created_by) ? intval($row->created_by) : $user->get('id')); - $form->set('created_by', $active); - $form->set('access', $row->access); - $form->set('created_by_alias', $row->created_by_alias); - - $form->set('created', JHTML::_('date', $row->created, '%Y-%m-%d %H:%M:%S')); - $form->set('publish_up', JHTML::_('date', $row->publish_up, '%Y-%m-%d %H:%M:%S')); - if (JHTML::_('date', $row->publish_down, '%Y') <= 1969 || $row->publish_down == $db->getNullDate()) { - $form->set('publish_down', JText::_('Never')); - } else { - $form->set('publish_down', JHTML::_('date', $row->publish_down, '%Y-%m-%d %H:%M:%S')); - } - - // Advanced Group - $form->loadINI($row->attribs); - - // Metadata Group - $form->set('description', $row->metadesc); - $form->set('keywords', $row->metakey); - $form->loadINI($row->metadata); - - ContentView::editContent($row, $contentSection, $lists, $sectioncategories, $option, $form); - } - - /** - * Saves the article an edit form submit - * @param database A database connector object - */ - function saveContent() - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db = & JFactory::getDBO(); - $user = & JFactory::getUser(); - $dispatcher = & JDispatcher::getInstance(); - JPluginHelper::importPlugin('content'); - - $details = JRequest::getVar( 'details', array(), 'post', 'array'); - $option = JRequest::getCmd( 'option' ); - $task = JRequest::getCmd( 'task' ); - $sectionid = JRequest::getVar( 'sectionid', 0, '', 'int' ); - $redirect = JRequest::getVar( 'redirect', $sectionid, 'post', 'int' ); - $menu = JRequest::getVar( 'menu', 'mainmenu', 'post', 'cmd' ); - $menuid = JRequest::getVar( 'menuid', 0, 'post', 'int' ); - $nullDate = $db->getNullDate(); - - $row = & JTable::getInstance('content'); - if (!$row->bind(JRequest::get('post'))) { - JError::raiseError( 500, $db->stderr() ); - return false; - } - $row->bind($details); - - // sanitise id field - $row->id = (int) $row->id; - - $isNew = true; - // Are we saving from an item edit? - if ($row->id) { - $isNew = false; - $datenow =& JFactory::getDate(); - $row->modified = $datenow->toMySQL(); - $row->modified_by = $user->get('id'); - } - - $row->created_by = $row->created_by ? $row->created_by : $user->get('id'); - - if ($row->created && strlen(trim( $row->created )) <= 10) { - $row->created .= ' 00:00:00'; - } - - $config =& JFactory::getConfig(); - $tzoffset = $config->getValue('config.offset'); - $date =& JFactory::getDate($row->created, $tzoffset); - $row->created = $date->toMySQL(); - - // Append time if not added to publish date - if (strlen(trim($row->publish_up)) <= 10) { - $row->publish_up .= ' 00:00:00'; - } - - $date =& JFactory::getDate($row->publish_up, $tzoffset); - $row->publish_up = $date->toMySQL(); - - // Handle never unpublish date - if (trim($row->publish_down) == JText::_('Never') || trim( $row->publish_down ) == '') - { - $row->publish_down = $nullDate; - } - else - { - if (strlen(trim( $row->publish_down )) <= 10) { - $row->publish_down .= ' 00:00:00'; - } - $date =& JFactory::getDate($row->publish_down, $tzoffset); - $row->publish_down = $date->toMySQL(); - } - - // Get a state and parameter variables from the request - $row->state = JRequest::getVar( 'state', 0, '', 'int' ); - $params = JRequest::getVar( 'params', null, 'post', 'array' ); - - // Build parameter INI string - if (is_array($params)) - { - $txt = array (); - foreach ($params as $k => $v) { - $txt[] = "$k=$v"; - } - $row->attribs = implode("\n", $txt); - } - - // Get metadata string - $metadata = JRequest::getVar( 'meta', null, 'post', 'array'); - if (is_array($metadata)) - { - $txt = array(); - foreach ($metadata as $k => $v) { - if ($k == 'description') { - $row->metadesc = $v; - } elseif ($k == 'keywords') { - $row->metakey = $v; - } else { - $txt[] = "$k=$v"; - } - } - $row->metadata = implode("\n", $txt); - } - - // Prepare the content for saving to the database - ContentHelper::saveContentPrep( $row ); - - // Make sure the data is valid - if (!$row->check()) { - JError::raiseError( 500, $db->stderr() ); - return false; - } - - // Increment the content version number - $row->version++; - - $result = $dispatcher->trigger('onBeforeContentSave', array(&$row, $isNew)); - if(in_array(false, $result, true)) { - JError::raiseError(500, $row->getError()); - return false; - } - - // Store the content to the database - if (!$row->store()) { - JError::raiseError( 500, $db->stderr() ); - return false; - } - - // Check the article and update item order - $row->checkin(); - $row->reorder('catid = '.(int) $row->catid.' AND state >= 0'); - - /* - * We need to update frontpage status for the article. - * - * First we include the frontpage table and instantiate an instance of it. - */ - require_once (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_frontpage'.DS.'tables'.DS.'frontpage.php'); - $fp = new TableFrontPage($db); - - // Is the article viewable on the frontpage? - if (JRequest::getVar( 'frontpage', 0, '', 'int' )) - { - // Is the item already viewable on the frontpage? - if (!$fp->load($row->id)) - { - // Insert the new entry - $query = 'INSERT INTO #__content_frontpage' . - ' VALUES ( '. (int) $row->id .', 1 )'; - $db->setQuery($query); - if (!$db->query()) - { - JError::raiseError( 500, $db->stderr() ); - return false; - } - $fp->ordering = 1; - } - } - else - { - // Delete the item from frontpage if it exists - if (!$fp->delete($row->id)) { - $msg .= $fp->stderr(); - } - $fp->ordering = 0; - } - $fp->reorder(); - - $cache = & JFactory::getCache('com_content'); - $cache->clean(); - - $dispatcher->trigger('onAfterContentSave', array(&$row, $isNew)); - - switch ($task) - { - case 'go2menu' : - $mainframe->redirect('index.php?option=com_menus&menutype='.$menu); - break; - - case 'go2menuitem' : - $mainframe->redirect('index.php?option=com_menus&menutype='.$menu.'&task=edit&id='.$menuid); - break; - - case 'menulink' : - ContentHelper::menuLink($redirect, $row->id); - break; - - case 'resethits' : - ContentHelper::resetHits($redirect, $row->id); - break; - - case 'apply' : - $msg = JText::sprintf('SUCCESSFULLY SAVED CHANGES TO ARTICLE', $row->title); - $mainframe->redirect('index.php?option=com_content§ionid='.$redirect.'&task=edit&cid[]='.$row->id, $msg); - break; - - case 'save' : - default : - $msg = JText::sprintf('Successfully Saved Article', $row->title); - $mainframe->redirect('index.php?option=com_content§ionid='.$redirect, $msg); - break; - } - } - - /** - * Changes the state of one or more content pages - * - * @param string The name of the category section - * @param integer A unique category id (passed from an edit form) - * @param array An array of unique category id numbers - * @param integer 0 if unpublishing, 1 if publishing - * @param string The name of the current user - */ - function changeContent( $state = 0 ) - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db = & JFactory::getDBO(); - $user = & JFactory::getUser(); - - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - JArrayHelper::toInteger($cid); - $option = JRequest::getCmd( 'option' ); - $task = JRequest::getCmd( 'task' ); - $rtask = JRequest::getCmd( 'returntask', '', 'post' ); - if ($rtask) { - $rtask = '&task='.$rtask; - } - - if (count($cid) < 1) { - $redirect = JRequest::getVar( 'redirect', '', 'post', 'int' ); - $action = ($state == 1) ? 'publish' : ($state == -1 ? 'archive' : 'unpublish'); - $msg = JText::_('Select an item to') . ' ' . JText::_($action); - $mainframe->redirect('index.php?option='.$option.$rtask.'§ionid='.$redirect, $msg, 'error'); - } - - // Get some variables for the query - $uid = $user->get('id'); - $total = count($cid); - $cids = implode(',', $cid); - - $query = 'UPDATE #__content' . - ' SET state = '. (int) $state . - ' WHERE id IN ( '. $cids .' ) AND ( checked_out = 0 OR (checked_out = '. (int) $uid .' ) )'; - $db->setQuery($query); - if (!$db->query()) { - JError::raiseError( 500, $db->getErrorMsg() ); - return false; - } - - if (count($cid) == 1) { - $row = & JTable::getInstance('content'); - $row->checkin($cid[0]); - } - - switch ($state) - { - case -1 : - $msg = JText::sprintf('Item(s) successfully Archived', $total); - break; - - case 1 : - $msg = JText::sprintf('Item(s) successfully Published', $total); - break; - - case 0 : - default : - if ($task == 'unarchive') { - $msg = JText::sprintf('Item(s) successfully Unarchived', $total); - } else { - $msg = JText::sprintf('Item(s) successfully Unpublished', $total); - } - break; - } - - $cache = & JFactory::getCache('com_content'); - $cache->clean(); - - // Get some return/redirect information from the request - $redirect = JRequest::getVar( 'redirect', $row->sectionid, 'post', 'int' ); - - $mainframe->redirect('index.php?option='.$option.$rtask.'§ionid='.$redirect, $msg); - } - - /** - * Changes the frontpage state of one or more articles - * - */ - function toggleFrontPage() - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db =& JFactory::getDBO(); - - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - $option = JRequest::getCmd( 'option' ); - $msg = null; - - JArrayHelper::toInteger($cid); - - if (count($cid) < 1) { - $msg = JText::_('Select an item to toggle'); - $mainframe->redirect('index.php?option='.$option, $msg, 'error'); - } - - /* - * We need to update frontpage status for the articles. - * - * First we include the frontpage table and instantiate an instance of - * it. - */ - require_once (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_frontpage'.DS.'tables'.DS.'frontpage.php'); - $fp = new TableFrontPage($db); - - foreach ($cid as $id) - { - // toggles go to first place - if ($fp->load($id)) { - if (!$fp->delete($id)) { - $msg .= $fp->stderr(); - } - $fp->ordering = 0; - } else { - // new entry - $query = 'INSERT INTO #__content_frontpage' . - ' VALUES ( '. (int) $id .', 0 )'; - $db->setQuery($query); - if (!$db->query()) { - JError::raiseError( 500, $db->stderr() ); - return false; - } - $fp->ordering = 0; - } - $fp->reorder(); - } - - $cache = & JFactory::getCache('com_content'); - $cache->clean(); - - $mainframe->redirect('index.php?option='.$option, $msg); - } - - function removeContent() - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db = & JFactory::getDBO(); - - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - $option = JRequest::getCmd( 'option' ); - $return = JRequest::getCmd( 'returntask', '', 'post' ); - $nullDate = $db->getNullDate(); - - JArrayHelper::toInteger($cid); - - if (count($cid) < 1) { - $msg = JText::_('Select an item to delete'); - $mainframe->redirect('index.php?option='.$option, $msg, 'error'); - } - - // Removed content gets put in the trash [state = -2] and ordering is always set to 0 - $state = '-2'; - $ordering = '0'; - - // Get the list of content id numbers to send to trash. - $cids = implode(',', $cid); - - // Update articles in the database - $query = 'UPDATE #__content' . - ' SET state = '.(int) $state . - ', ordering = '.(int) $ordering . - ', checked_out = 0, checked_out_time = '.$db->Quote($nullDate). - ' WHERE id IN ( '. $cids. ' )'; - $db->setQuery($query); - if (!$db->query()) - { - JError::raiseError( 500, $db->getErrorMsg() ); - return false; - } - - $cache = & JFactory::getCache('com_content'); - $cache->clean(); - - $msg = JText::sprintf('Item(s) sent to the Trash', count($cid)); - $mainframe->redirect('index.php?option='.$option.'&task='.$return, $msg); - } - - /** - * Cancels an edit operation - */ - function cancelContent() - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db = & JFactory::getDBO(); - - // Check the article in if checked out - $row = & JTable::getInstance('content'); - $row->bind(JRequest::get('post')); - $row->checkin(); - - $mainframe->redirect('index.php?option=com_content'); - } - - /** - * Moves the order of a record - * @param integer The increment to reorder by - */ - function orderContent($direction) - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db = & JFactory::getDBO(); - - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - - if (isset( $cid[0] )) - { - $row = & JTable::getInstance('content'); - $row->load( (int) $cid[0] ); - $row->move($direction, 'catid = ' . (int) $row->catid . ' AND state >= 0' ); - - $cache = & JFactory::getCache('com_content'); - $cache->clean(); - } - - $mainframe->redirect('index.php?option=com_content'); - } - - /** - * Form for moving item(s) to a different section and category - */ - function moveSection() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db =& JFactory::getDBO(); - - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - $sectionid = JRequest::getVar( 'sectionid', 0, '', 'int' ); - - JArrayHelper::toInteger($cid); - - if (count($cid) < 1) { - $msg = JText::_('Select an item to move'); - $mainframe->redirect('index.php?option=com_content', $msg, 'error'); - } - - //seperate contentids - $cids = implode(',', $cid); - // Articles query - $query = 'SELECT a.title' . - ' FROM #__content AS a' . - ' WHERE ( a.id IN ( '. $cids .' ) )' . - ' ORDER BY a.title'; - $db->setQuery($query); - $items = $db->loadObjectList(); - - $query = 'SELECT CONCAT_WS( ", ", s.id, c.id ) AS `value`, CONCAT_WS( " / ", s.title, c.title ) AS `text`' . - ' FROM #__sections AS s' . - ' INNER JOIN #__categories AS c ON c.section = s.id' . - ' WHERE s.scope = "content"' . - ' ORDER BY s.title, c.title'; - $db->setQuery($query); - $rows[] = JHTML::_('select.option', "0, 0", JText::_('UNCATEGORIZED')); - $rows = array_merge($rows, $db->loadObjectList()); - // build the html select list - $sectCatList = JHTML::_('select.genericlist', $rows, 'sectcat', 'class="inputbox" size="8"', 'value', 'text', null); - - ContentView::moveSection($cid, $sectCatList, 'com_content', $sectionid, $items); - } - - /** - * Save the changes to move item(s) to a different section and category - */ - function moveSectionSave() - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db = & JFactory::getDBO(); - $user = & JFactory::getUser(); - - $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); - $sectionid = JRequest::getVar( 'sectionid', 0, '', 'int' ); - $option = JRequest::getCmd( 'option' ); - - JArrayHelper::toInteger($cid, array(0)); - - $sectcat = JRequest::getVar( 'sectcat', '', 'post', 'string' ); - $sectcat = explode(',', $sectcat); - $newsect = (int) @$sectcat[0]; - $newcat = (int) @$sectcat[1]; - - if ((!$newsect || !$newcat) && ($sectcat !== array('0', ' 0'))) { - $mainframe->redirect("index.php?option=com_content§ionid=$sectionid", JText::_('An error has occurred')); - } - - // find section name - $query = 'SELECT a.title' . - ' FROM #__sections AS a' . - ' WHERE a.id = '. (int) $newsect; - $db->setQuery($query); - $section = $db->loadResult(); - - // find category name - $query = 'SELECT a.title' . - ' FROM #__categories AS a' . - ' WHERE a.id = '. (int) $newcat; - $db->setQuery($query); - $category = $db->loadResult(); - - $total = count($cid); - $cids = implode(',', $cid); - $uid = $user->get('id'); - - $row = & JTable::getInstance('content'); - // update old orders - put existing items in last place - foreach ($cid as $id) - { - $row->load(intval($id)); - $row->ordering = 0; - $row->store(); - $row->reorder('catid = '.(int) $row->catid.' AND state >= 0'); - } - - $query = 'UPDATE #__content SET sectionid = '.(int) $newsect.', catid = '.(int) $newcat. - ' WHERE id IN ( '.$cids.' )' . - ' AND ( checked_out = 0 OR ( checked_out = '.(int) $uid.' ) )'; - $db->setQuery($query); - if (!$db->query()) - { - JError::raiseError( 500, $db->getErrorMsg() ); - return false; - } - - // update new orders - put items in last place - foreach ($cid as $id) - { - $row->load(intval($id)); - $row->ordering = 0; - $row->store(); - $row->reorder('catid = '.(int) $row->catid.' AND state >= 0'); - } - - if ($section && $category) { - $msg = JText::sprintf('Item(s) successfully moved to Section', $total, $section, $category); - } else { - $msg = JText::sprintf('ITEM(S) SUCCESSFULLY MOVED TO UNCATEGORIZED', $total); - } - - $mainframe->redirect('index.php?option='.$option.'§ionid='.$sectionid, $msg); - } - - /** - * Form for copying item(s) - **/ - function copyItem() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db = & JFactory::getDBO(); - - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - $sectionid = JRequest::getVar( 'sectionid', 0, '', 'int' ); - $option = JRequest::getCmd( 'option' ); - - JArrayHelper::toInteger($cid); - - if (count($cid) < 1) { - $msg = JText::_('Select an item to move'); - $mainframe->redirect('index.php?option='.$option, $msg, 'error'); - } - - //seperate contentids - $cids = implode(',', $cid); - ## Articles query - $query = 'SELECT a.title' . - ' FROM #__content AS a' . - ' WHERE ( a.id IN ( '. $cids .' ) )' . - ' ORDER BY a.title'; - $db->setQuery($query); - $items = $db->loadObjectList(); - - ## Section & Category query - $query = 'SELECT CONCAT_WS(",",s.id,c.id) AS `value`, CONCAT_WS(" / ", s.title, c.title) AS `text`' . - ' FROM #__sections AS s' . - ' INNER JOIN #__categories AS c ON c.section = s.id' . - ' WHERE s.scope = "content"' . - ' ORDER BY s.title, c.title'; - $db->setQuery($query); - - // Add a row for uncategorized content - $uncat = JHTML::_('select.option', '0,0', JText::_('UNCATEGORIZED')); - $rows = $db->loadObjectList(); - array_unshift($rows, $uncat); - // build the html select list - $sectCatList = JHTML::_('select.genericlist', $rows, 'sectcat', 'class="inputbox" size="10"', 'value', 'text', NULL); - - ContentView::copySection($option, $cid, $sectCatList, $sectionid, $items); - } - - /** - * saves Copies of items - **/ - function copyItemSave() - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db = & JFactory::getDBO(); - - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - $sectionid = JRequest::getVar( 'sectionid', 0, '', 'int' ); - $option = JRequest::getCmd( 'option' ); - - JArrayHelper::toInteger($cid); - - $item = null; - $sectcat = JRequest::getVar( 'sectcat', '-1,-1', 'post', 'string' ); - //seperate sections and categories from selection - $sectcat = explode(',', $sectcat); - $newsect = (int) @$sectcat[0]; - $newcat = (int) @$sectcat[1]; - - if (($newsect == -1) || ($newcat == -1)) { - $mainframe->redirect('index.php?option=com_content§ionid='.$sectionid, JText::_('An error has occurred')); - } - - // find section name - $query = 'SELECT a.title' . - ' FROM #__sections AS a' . - ' WHERE a.id = '. (int) $newsect; - $db->setQuery($query); - $section = $db->loadResult(); - - // find category name - $query = 'SELECT a.title' . - ' FROM #__categories AS a' . - ' WHERE a.id = '. (int) $newcat; - $db->setQuery($query); - $category = $db->loadResult(); - - if (($newsect == 0) && ($newcat == 0)) - { - $section = JText::_('UNCATEGORIZED'); - $category = JText::_('UNCATEGORIZED'); - } - - $total = count($cid); - for ($i = 0; $i < $total; $i ++) - { - $row = & JTable::getInstance('content'); - - // main query - $query = 'SELECT a.*' . - ' FROM #__content AS a' . - ' WHERE a.id = '.(int) $cid[$i]; - $db->setQuery($query, 0, 1); - $item = $db->loadObject(); - - // values loaded into array set for store - $row->id = NULL; - $row->sectionid = $newsect; - $row->catid = $newcat; - $row->hits = '0'; - $row->ordering = '0'; - $row->title = $item->title; - $row->alias = $item->alias; - $row->title_alias = $item->title_alias; - $row->introtext = $item->introtext; - $row->fulltext = $item->fulltext; - $row->state = $item->state; - $row->mask = $item->mask; - $row->created = $item->created; - $row->created_by = $item->created_by; - $row->created_by_alias = $item->created_by_alias; - $row->modified = $item->modified; - $row->modified_by = $item->modified_by; - $row->checked_out = $item->checked_out; - $row->checked_out_time = $item->checked_out_time; - $row->publish_up = $item->publish_up; - $row->publish_down = $item->publish_down; - $row->images = $item->images; - $row->attribs = $item->attribs; - $row->version = $item->parentid; - $row->parentid = $item->parentid; - $row->metakey = $item->metakey; - $row->metadesc = $item->metadesc; - $row->access = $item->access; - $row->metadata = $item->metadata; - - if (!$row->check()) { - JError::raiseError( 500, $row->getError() ); - return false; - } - - if (!$row->store()) { - JError::raiseError( 500, $row->getError() ); - return false; - } - $row->reorder('catid='.(int) $row->catid.' AND state >= 0'); - } - - $msg = JText::sprintf('Item(s) successfully copied to Section', $total, $section, $category); - $mainframe->redirect('index.php?option='.$option.'§ionid='.$sectionid, $msg); - } - - /** - * @param integer The id of the article - * @param integer The new access level - * @param string The URL option - */ - function accessMenu($access) - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db = & JFactory::getDBO(); - - $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); - $option = JRequest::getCmd( 'option' ); - $cid = $cid[0]; - - // Create and load the article table object - $row = & JTable::getInstance('content'); - $row->load($cid); - $row->access = $access; - - // Ensure the article object is valid - if (!$row->check()) { - JError::raiseError( 500, $row->getError() ); - return false; - } - - // Store the changes - if (!$row->store()) { - JError::raiseError( 500, $row->getError() ); - return false; - } - - $cache = & JFactory::getCache('com_content'); - $cache->clean(); - - $mainframe->redirect('index.php?option='.$option); - } - - function saveOrder() - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize variables - $db = & JFactory::getDBO(); - - $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); - $order = JRequest::getVar( 'order', array (0), 'post', 'array' ); - $redirect = JRequest::getVar( 'redirect', 0, 'post', 'int' ); - $rettask = JRequest::getVar( 'returntask', '', 'post', 'cmd' ); - $total = count($cid); - $conditions = array (); - - JArrayHelper::toInteger($cid, array(0)); - JArrayHelper::toInteger($order, array(0)); - - // Instantiate an article table object - $row = & JTable::getInstance('content'); - - // Update the ordering for items in the cid array - for ($i = 0; $i < $total; $i ++) - { - $row->load( (int) $cid[$i] ); - if ($row->ordering != $order[$i]) { - $row->ordering = $order[$i]; - if (!$row->store()) { - JError::raiseError( 500, $db->getErrorMsg() ); - return false; - } - // remember to updateOrder this group - $condition = 'catid = '.(int) $row->catid.' AND state >= 0'; - $found = false; - foreach ($conditions as $cond) - if ($cond[1] == $condition) { - $found = true; - break; - } - if (!$found) - $conditions[] = array ($row->id, $condition); - } - } - - // execute updateOrder for each group - foreach ($conditions as $cond) - { - $row->load($cond[0]); - $row->reorder($cond[1]); - } - - $cache = & JFactory::getCache('com_content'); - $cache->clean(); - - $msg = JText::_('New ordering saved'); - switch ($rettask) - { - case 'showarchive' : - $mainframe->redirect('index.php?option=com_content&task=showarchive§ionid='.$redirect, $msg); - break; - - default : - $mainframe->redirect('index.php?option=com_content§ionid='.$redirect, $msg); - break; - } - } - - function previewContent() - { - // Initialize variables - $document =& JFactory::getDocument(); - $db =& JFactory::getDBO(); - $id = JRequest::getVar( 'id', 0, '', 'int' ); - $option = JRequest::getCmd( 'option' ); - - // Get the current default template - $query = 'SELECT template' . - ' FROM #__templates_menu' . - ' WHERE client_id = 0' . - ' AND menuid = 0'; - $db->setQuery($query); - $template = $db->loadResult(); - - // check if template editor stylesheet exists - if (!file_exists( JPATH_SITE.DS.'templates'.DS.$template.DS.'css'.DS.'editor.css' )) { - $template = 'system'; - } - - // Set page title - $document->setTitle(JText::_('Article Preview')); - $document->addStyleSheet(JURI::root() . 'templates/'.$template.'/css/editor.css'); - $document->setBase(JUri::root()); - - // Render article preview - ContentView::previewContent(); - } - - function insertPagebreak() - { - $document =& JFactory::getDocument(); - $document->setTitle(JText::_('PGB ARTICLE PAGEBRK')); - ContentView::insertPagebreak(); - } -} +getModel( 'element' ); + $view = &$this->getView( 'element'); + $view->setModel( $model, true ); + $view->display(); + } + + /** + * Compiles a list of installed or defined modules + * @param database A database connector object + */ + function viewContent() + { + global $mainframe; + + // Initialize variables + $db =& JFactory::getDBO(); + $filter = null; + + // Get some variables from the request + $sectionid = JRequest::getVar( 'sectionid', -1, '', 'int' ); + $redirect = $sectionid; + $option = JRequest::getCmd( 'option' ); + $context = 'com_content.viewcontent'; + $filter_order = $mainframe->getUserStateFromRequest( $context.'filter_order', 'filter_order', '', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( $context.'filter_order_Dir', 'filter_order_Dir', '', 'word' ); + $filter_state = $mainframe->getUserStateFromRequest( $context.'filter_state', 'filter_state', '', 'word' ); + $catid = $mainframe->getUserStateFromRequest( $context.'catid', 'catid', 0, 'int' ); + $filter_authorid = $mainframe->getUserStateFromRequest( $context.'filter_authorid', 'filter_authorid', 0, 'int' ); + $filter_sectionid = $mainframe->getUserStateFromRequest( $context.'filter_sectionid', 'filter_sectionid', -1, 'int' ); + $search = $mainframe->getUserStateFromRequest( $context.'search', 'search', '', 'string' ); + if (strpos($search, '"') !== false) { + $search = str_replace(array('=', '<'), '', $search); + } + $search = JString::strtolower($search); + + $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); + $limitstart = $mainframe->getUserStateFromRequest($context.'limitstart', 'limitstart', 0, 'int'); + + // In case limit has been changed, adjust limitstart accordingly + $limitstart = ( $limit != 0 ? (floor($limitstart / $limit) * $limit) : 0 ); + + //$where[] = "c.state >= 0"; + $where[] = 'c.state != -2'; + + if (!$filter_order) { + $filter_order = 'section_name'; + } + if ($filter_order == 'c.ordering') { + $order = ' ORDER BY section_name, cc.title, c.ordering '. $filter_order_Dir; + } else { + $order = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', section_name, cc.title, c.ordering'; + } + $all = 1; + + if ($filter_sectionid >= 0) { + $filter = ' WHERE cc.section = '. (int) $filter_sectionid; + } + $section->title = 'All Articles'; + $section->id = 0; + + /* + * Add the filter specific information to the where clause + */ + // Section filter + if ($filter_sectionid >= 0) { + $where[] = 'c.sectionid = ' . (int) $filter_sectionid; + } + // Category filter + if ($catid > 0) { + $where[] = 'c.catid = ' . (int) $catid; + } + // Author filter + if ($filter_authorid > 0) { + $where[] = 'c.created_by = ' . (int) $filter_authorid; + } + // Content state filter + if ($filter_state) { + if ($filter_state == 'P') { + $where[] = 'c.state = 1'; + } else { + if ($filter_state == 'U') { + $where[] = 'c.state = 0'; + } else if ($filter_state == 'A') { + $where[] = 'c.state = -1'; + } else { + $where[] = 'c.state != -2'; + } + } + } + // Keyword filter + if ($search) { + $where[] = '(LOWER( c.title ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ) . + ' OR c.id = ' . (int) $search . ')'; + } + + // Build the where clause of the content record query + $where = (count($where) ? ' WHERE '.implode(' AND ', $where) : ''); + + // Get the total number of records + $query = 'SELECT COUNT(*)' . + ' FROM #__content AS c' . + ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' . + ' LEFT JOIN #__sections AS s ON s.id = c.sectionid' . + $where; + $db->setQuery($query); + $total = $db->loadResult(); + + + // Create the pagination object + jimport('joomla.html.pagination'); + $pagination = new JPagination($total, $limitstart, $limit); + + // Get the articles + $query = 'SELECT c.*, g.name AS groupname, cc.title AS name, u.name AS editor, f.content_id AS frontpage, s.title AS section_name, v.name AS author' . + ' FROM #__content AS c' . + ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' . + ' LEFT JOIN #__sections AS s ON s.id = c.sectionid' . + ' LEFT JOIN #__groups AS g ON g.id = c.access' . + ' LEFT JOIN #__users AS u ON u.id = c.checked_out' . + ' LEFT JOIN #__users AS v ON v.id = c.created_by' . + ' LEFT JOIN #__content_frontpage AS f ON f.content_id = c.id' . + $where . + $order; + $db->setQuery($query, $pagination->limitstart, $pagination->limit); + $rows = $db->loadObjectList(); + + // If there is a database query error, throw a HTTP 500 and exit + if ($db->getErrorNum()) { + JError::raiseError( 500, $db->stderr() ); + return false; + } + + // get list of categories for dropdown filter + $query = 'SELECT cc.id AS value, cc.title AS text, section' . + ' FROM #__categories AS cc' . + ' INNER JOIN #__sections AS s ON s.id = cc.section ' . + $filter . + ' ORDER BY s.ordering, cc.ordering'; + $lists['catid'] = ContentHelper::filterCategory($query, $catid); + + // get list of sections for dropdown filter + $javascript = 'onchange="document.adminForm.submit();"'; + $lists['sectionid'] = JHTML::_('list.section', 'filter_sectionid', $filter_sectionid, $javascript); + + // get list of Authors for dropdown filter + $query = 'SELECT c.created_by, u.name' . + ' FROM #__content AS c' . + ' INNER JOIN #__sections AS s ON s.id = c.sectionid' . + ' LEFT JOIN #__users AS u ON u.id = c.created_by' . + ' WHERE c.state <> -1' . + ' AND c.state <> -2' . + ' GROUP BY u.name' . + ' ORDER BY u.name'; + $authors[] = JHTML::_('select.option', '0', '- '.JText::_('Select Author').' -', 'created_by', 'name'); + $db->setQuery($query); + $authors = array_merge($authors, $db->loadObjectList()); + $lists['authorid'] = JHTML::_('select.genericlist', $authors, 'filter_authorid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'created_by', 'name', $filter_authorid); + + // state filter + $lists['state'] = JHTML::_('grid.state', $filter_state, 'Published', 'Unpublished', 'Archived'); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search'] = $search; + + ContentView::showContent($rows, $lists, $pagination, $redirect); + } + + /** + * Shows a list of archived articles + * @param int The section id + */ + function viewArchive() + { + global $mainframe; + + // Initialize variables + $db =& JFactory::getDBO(); + + $sectionid = JRequest::getVar( 'sectionid', 0, '', 'int' ); + $option = JRequest::getCmd( 'option' ); + + $filter_order = $mainframe->getUserStateFromRequest("$option.$sectionid.viewarchive.filter_order", 'filter_order', 'sectname', 'cmd'); + $filter_order_Dir = $mainframe->getUserStateFromRequest("$option.$sectionid.viewarchive.filter_order_Dir", 'filter_order_Dir', '', 'word'); + $catid = $mainframe->getUserStateFromRequest("$option.$sectionid.viewarchive.catid", 'catid', 0, 'int'); + $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); + $limitstart = $mainframe->getUserStateFromRequest("$option.$sectionid.viewarchive.limitstart", 'limitstart', 0, 'int'); + $filter_authorid = $mainframe->getUserStateFromRequest("$option.$sectionid.viewarchive.filter_authorid", 'filter_authorid', 0, 'int'); + $filter_sectionid = $mainframe->getUserStateFromRequest("$option.$sectionid.viewarchive.filter_sectionid", 'filter_sectionid', 0, 'int'); + $search = $mainframe->getUserStateFromRequest("$option.$sectionid.viewarchive.search", 'search', '', 'string'); + if (strpos($search, '"') !== false) { + $search = str_replace(array('=', '<'), '', $search); + } + $search = JString::strtolower($search); + $redirect = $sectionid; + + // A section id of zero means view all articles [all sections] + if ($sectionid == 0) + { + $where = array ('c.state = -1', 'c.catid = cc.id', 'cc.section = s.id', 's.scope = "content"'); + $filter = ' , #__sections AS s WHERE s.id = c.section'; + $all = 1; + } + else + { + //We are viewing a specific section + $where = array ('c.state = -1', 'c.catid = cc.id', 'cc.section = s.id', 's.scope = "content"', 'c.sectionid= '.(int) $sectionid); + $filter = ' WHERE section = '.$db->Quote($sectionid); + $all = NULL; + } + + // Section filter + if ($filter_sectionid > 0) + { + $where[] = 'c.sectionid = ' . (int) $filter_sectionid; + } + // Author filter + if ($filter_authorid > 0) + { + $where[] = 'c.created_by = ' . (int) $filter_authorid; + } + // Category filter + if ($catid > 0) + { + $where[] = 'c.catid = ' . (int) $catid; + } + // Keyword filter + if ($search) + { + $where[] = 'LOWER( c.title ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + + // TODO: Sanitise $filter_order + $filter_order_Dir = ($filter_order_Dir == 'ASC' ? 'ASC' : 'DESC'); + $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', sectname, cc.name, c.ordering'; + $where = (count($where) ? ' WHERE '.implode(' AND ', $where) : ''); + + // get the total number of records + $query = 'SELECT COUNT(*)' . + ' FROM #__content AS c' . + ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' . + ' LEFT JOIN #__sections AS s ON s.id = c.sectionid' . + $where; + $db->setQuery($query); + $total = $db->loadResult(); + + jimport('joomla.html.pagination'); + $pagination = new JPagination($total, $limitstart, $limit); + + $query = 'SELECT c.*, g.name AS groupname, cc.name, v.name AS author, s.title AS sectname' . + ' FROM #__content AS c' . + ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' . + ' LEFT JOIN #__sections AS s ON s.id = c.sectionid' . + ' LEFT JOIN #__groups AS g ON g.id = c.access' . + ' LEFT JOIN #__users AS v ON v.id = c.created_by' . + $where . + $orderby; + $db->setQuery($query, $pagination->limitstart, $pagination->limit); + $rows = $db->loadObjectList(); + + // If there is a database query error, throw a HTTP 500 and exit + if ($db->getErrorNum()) + { + JError::raiseError( 500, $db->stderr() ); + return false; + } + + // get list of categories for dropdown filter + $query = 'SELECT c.id AS value, c.title AS text' . + ' FROM #__categories AS c' . + $filter . + ' ORDER BY c.ordering'; + $lists['catid'] = ContentHelper::filterCategory($query, $catid); + + // get list of sections for dropdown filter + $javascript = 'onchange="document.adminForm.submit();"'; + $lists['sectionid'] = JAdminMenus::SelectSection('filter_sectionid', $filter_sectionid, $javascript); + + $section = & JTable::getInstance('section'); + $section->load($sectionid); + + // get list of Authors for dropdown filter + $query = 'SELECT c.created_by, u.name' . + ' FROM #__content AS c' . + ' INNER JOIN #__sections AS s ON s.id = c.sectionid' . + ' LEFT JOIN #__users AS u ON u.id = c.created_by' . + ' WHERE c.state = -1' . + ' GROUP BY u.name' . + ' ORDER BY u.name'; + $db->setQuery($query); + $authors[] = JHTML::_('select.option', '0', '- '.JText::_('Select Author').' -', 'created_by', 'name'); + $authors = array_merge($authors, $db->loadObjectList()); + $lists['authorid'] = JHTML::_('select.genericlist', $authors, 'filter_authorid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'created_by', 'name', $filter_authorid); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search'] = $search; + + ContentView::showArchive($rows, $section, $lists, $pagination, $option, $all, $redirect); + } + + /** + * Compiles information to add or edit the record + * + * @param database A database connector object + * @param integer The unique id of the record to edit (0 if new) + * @param integer The id of the content section + */ + function editContent($edit) + { + global $mainframe; + + // Initialize variables + $db = & JFactory::getDBO(); + $user = & JFactory::getUser(); + + $cid = JRequest::getVar( 'cid', array(0), '', 'array' ); + JArrayHelper::toInteger($cid, array(0)); + $id = JRequest::getVar( 'id', $cid[0], '', 'int' ); + $option = JRequest::getCmd( 'option' ); + $nullDate = $db->getNullDate(); + $contentSection = ''; + $sectionid = 0; + + // Create and load the content table row + $row = & JTable::getInstance('content'); + if($edit) + $row->load($id); + + if ($id) { + $sectionid = $row->sectionid; + if ($row->state < 0) { + $mainframe->redirect('index.php?option=com_content', JText::_('You cannot edit an archived item')); + } + } + + // A sectionid of zero means grab from all sections + if ($sectionid == 0) { + $where = ' WHERE section NOT LIKE "%com_%"'; + } else { + // Grab from the specific section + $where = ' WHERE section = '. $db->Quote( $sectionid ); + } + + /* + * If the item is checked out we cannot edit it... unless it was checked + * out by the current user. + */ + if ( JTable::isCheckedOut($user->get ('id'), $row->checked_out )) + { + $msg = JText::sprintf('DESCBEINGEDITTED', JText::_('The item'), $row->title); + $mainframe->redirect('index.php?option=com_content', $msg); + } + + if ($id) + { + $row->checkout($user->get('id')); + + if (trim($row->images)) { + $row->images = explode("\n", $row->images); + } else { + $row->images = array (); + } + + $query = 'SELECT name' . + ' FROM #__users'. + ' WHERE id = '. (int) $row->created_by; + $db->setQuery($query); + $row->creator = $db->loadResult(); + + // test to reduce unneeded query + if ($row->created_by == $row->modified_by) { + $row->modifier = $row->creator; + } else { + $query = 'SELECT name' . + ' FROM #__users' . + ' WHERE id = '. (int) $row->modified_by; + $db->setQuery($query); + $row->modifier = $db->loadResult(); + } + + $query = 'SELECT COUNT(content_id)' . + ' FROM #__content_frontpage' . + ' WHERE content_id = '. (int) $row->id; + $db->setQuery($query); + $row->frontpage = $db->loadResult(); + if (!$row->frontpage) { + $row->frontpage = 0; + } + } + else + { + if (!$sectionid && JRequest::getInt('filter_sectionid')) { + $sectionid =JRequest::getInt('filter_sectionid'); + } + + if (JRequest::getInt('catid')) + { + $row->catid = JRequest::getInt('catid'); + $category = & JTable::getInstance('category'); + $category->load($row->catid); + $sectionid = $category->section; + } else { + $row->catid = NULL; + } + $createdate =& JFactory::getDate(); + $row->sectionid = $sectionid; + $row->version = 0; + $row->state = 1; + $row->ordering = 0; + $row->images = array (); + $row->publish_up = $createdate->toUnix(); + $row->publish_down = JText::_('Never'); + $row->creator = ''; + $row->created = $createdate->toUnix(); + $row->modified = $nullDate; + $row->modifier = ''; + $row->frontpage = 0; + + } + + $javascript = "onchange=\"changeDynaList( 'catid', sectioncategories, document.adminForm.sectionid.options[document.adminForm.sectionid.selectedIndex].value, 0, 0);\""; + + $query = 'SELECT s.id, s.title' . + ' FROM #__sections AS s' . + ' ORDER BY s.ordering'; + $db->setQuery($query); + + $sections[] = JHTML::_('select.option', '-1', '- '.JText::_('Select Section').' -', 'id', 'title'); + $sections[] = JHTML::_('select.option', '0', JText::_('Uncategorized'), 'id', 'title'); + $sections = array_merge($sections, $db->loadObjectList()); + $lists['sectionid'] = JHTML::_('select.genericlist', $sections, 'sectionid', 'class="inputbox" size="1" '.$javascript, 'id', 'title', intval($row->sectionid)); + + foreach ($sections as $section) + { + $section_list[] = (int) $section->id; + // get the type name - which is a special category + if ($row->sectionid) { + if ($section->id == $row->sectionid) { + $contentSection = $section->title; + } + } else { + if ($section->id == $sectionid) { + $contentSection = $section->title; + } + } + } + + $sectioncategories = array (); + $sectioncategories[-1] = array (); + $sectioncategories[-1][] = JHTML::_('select.option', '-1', JText::_( 'Select Category' ), 'id', 'title'); + $section_list = implode('\', \'', $section_list); + + $query = 'SELECT id, title, section' . + ' FROM #__categories' . + ' WHERE section IN ( \''.$section_list.'\' )' . + ' ORDER BY ordering'; + $db->setQuery($query); + $cat_list = $db->loadObjectList(); + + // Uncategorized category mapped to uncategorized section + $uncat = new stdClass(); + $uncat->id = 0; + $uncat->title = JText::_('Uncategorized'); + $uncat->section = 0; + $cat_list[] = $uncat; + foreach ($sections as $section) + { + $sectioncategories[$section->id] = array (); + $rows2 = array (); + foreach ($cat_list as $cat) + { + if ($cat->section == $section->id) { + $rows2[] = $cat; + } + } + foreach ($rows2 as $row2) { + $sectioncategories[$section->id][] = JHTML::_('select.option', $row2->id, $row2->title, 'id', 'title'); + } + } + $sectioncategories['-1'][] = JHTML::_('select.option', '-1', JText::_( 'Select Category' ), 'id', 'title'); + $categories = array(); + foreach ($cat_list as $cat) { + if($cat->section == $row->sectionid) + $categories[] = $cat; + } + + $categories[] = JHTML::_('select.option', '-1', JText::_( 'Select Category' ), 'id', 'title'); + $lists['catid'] = JHTML::_('select.genericlist', $categories, 'catid', 'class="inputbox" size="1"', 'id', 'title', intval($row->catid)); + + // build the html select list for ordering + $query = 'SELECT ordering AS value, title AS text' . + ' FROM #__content' . + ' WHERE catid = ' . (int) $row->catid . + ' AND state >= 0' . + ' ORDER BY ordering'; + if($edit) + $lists['ordering'] = JHTML::_('list.specificordering', $row, $id, $query, 1); + else + $lists['ordering'] = JHTML::_('list.specificordering', $row, '', $query, 1); + + // build the html radio buttons for frontpage + $lists['frontpage'] = JHTML::_('select.booleanlist', 'frontpage', '', $row->frontpage); + + // build the html radio buttons for published + $lists['state'] = JHTML::_('select.booleanlist', 'state', '', $row->state); + + /* + * We need to unify the introtext and fulltext fields and have the + * fields separated by the {readmore} tag, so lets do that now. + */ + if (JString::strlen($row->fulltext) > 1) { + $row->text = $row->introtext . "
    " . $row->fulltext; + } else { + $row->text = $row->introtext; + } + + // Create the form + $form = new JParameter('', JPATH_COMPONENT.DS.'models'.DS.'article.xml'); + + // Details Group + $active = (intval($row->created_by) ? intval($row->created_by) : $user->get('id')); + $form->set('created_by', $active); + $form->set('access', $row->access); + $form->set('created_by_alias', $row->created_by_alias); + + $form->set('created', JHTML::_('date', $row->created, '%Y-%m-%d %H:%M:%S')); + $form->set('publish_up', JHTML::_('date', $row->publish_up, '%Y-%m-%d %H:%M:%S')); + if (JHTML::_('date', $row->publish_down, '%Y') <= 1969 || $row->publish_down == $db->getNullDate()) { + $form->set('publish_down', JText::_('Never')); + } else { + $form->set('publish_down', JHTML::_('date', $row->publish_down, '%Y-%m-%d %H:%M:%S')); + } + + // Advanced Group + $form->loadINI($row->attribs); + + // Metadata Group + $form->set('description', $row->metadesc); + $form->set('keywords', $row->metakey); + $form->loadINI($row->metadata); + + ContentView::editContent($row, $contentSection, $lists, $sectioncategories, $option, $form); + } + + /** + * Saves the article an edit form submit + * @param database A database connector object + */ + function saveContent() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db = & JFactory::getDBO(); + $user = & JFactory::getUser(); + $dispatcher = & JDispatcher::getInstance(); + JPluginHelper::importPlugin('content'); + + $details = JRequest::getVar( 'details', array(), 'post', 'array'); + $option = JRequest::getCmd( 'option' ); + $task = JRequest::getCmd( 'task' ); + $sectionid = JRequest::getVar( 'sectionid', 0, '', 'int' ); + $redirect = JRequest::getVar( 'redirect', $sectionid, 'post', 'int' ); + $menu = JRequest::getVar( 'menu', 'mainmenu', 'post', 'cmd' ); + $menuid = JRequest::getVar( 'menuid', 0, 'post', 'int' ); + $nullDate = $db->getNullDate(); + + $row = & JTable::getInstance('content'); + if (!$row->bind(JRequest::get('post'))) { + JError::raiseError( 500, $db->stderr() ); + return false; + } + $row->bind($details); + + // sanitise id field + $row->id = (int) $row->id; + + $isNew = true; + // Are we saving from an item edit? + if ($row->id) { + $isNew = false; + $datenow =& JFactory::getDate(); + $row->modified = $datenow->toMySQL(); + $row->modified_by = $user->get('id'); + } + + $row->created_by = $row->created_by ? $row->created_by : $user->get('id'); + + if ($row->created && strlen(trim( $row->created )) <= 10) { + $row->created .= ' 00:00:00'; + } + + $config =& JFactory::getConfig(); + $tzoffset = $config->getValue('config.offset'); + $date =& JFactory::getDate($row->created, $tzoffset); + $row->created = $date->toMySQL(); + + // Append time if not added to publish date + if (strlen(trim($row->publish_up)) <= 10) { + $row->publish_up .= ' 00:00:00'; + } + + $date =& JFactory::getDate($row->publish_up, $tzoffset); + $row->publish_up = $date->toMySQL(); + + // Handle never unpublish date + if (trim($row->publish_down) == JText::_('Never') || trim( $row->publish_down ) == '') + { + $row->publish_down = $nullDate; + } + else + { + if (strlen(trim( $row->publish_down )) <= 10) { + $row->publish_down .= ' 00:00:00'; + } + $date =& JFactory::getDate($row->publish_down, $tzoffset); + $row->publish_down = $date->toMySQL(); + } + + // Get a state and parameter variables from the request + $row->state = JRequest::getVar( 'state', 0, '', 'int' ); + $params = JRequest::getVar( 'params', null, 'post', 'array' ); + + // Build parameter INI string + if (is_array($params)) + { + $txt = array (); + foreach ($params as $k => $v) { + $txt[] = "$k=$v"; + } + $row->attribs = implode("\n", $txt); + } + + // Get metadata string + $metadata = JRequest::getVar( 'meta', null, 'post', 'array'); + if (is_array($metadata)) + { + $txt = array(); + foreach ($metadata as $k => $v) { + if ($k == 'description') { + $row->metadesc = $v; + } elseif ($k == 'keywords') { + $row->metakey = $v; + } else { + $txt[] = "$k=$v"; + } + } + $row->metadata = implode("\n", $txt); + } + + // Prepare the content for saving to the database + ContentHelper::saveContentPrep( $row ); + + // Make sure the data is valid + if (!$row->check()) { + JError::raiseError( 500, $db->stderr() ); + return false; + } + + // Increment the content version number + $row->version++; + + $result = $dispatcher->trigger('onBeforeContentSave', array(&$row, $isNew)); + if(in_array(false, $result, true)) { + JError::raiseError(500, $row->getError()); + return false; + } + + // Store the content to the database + if (!$row->store()) { + JError::raiseError( 500, $db->stderr() ); + return false; + } + + // Check the article and update item order + $row->checkin(); + $row->reorder('catid = '.(int) $row->catid.' AND state >= 0'); + + /* + * We need to update frontpage status for the article. + * + * First we include the frontpage table and instantiate an instance of it. + */ + require_once (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_frontpage'.DS.'tables'.DS.'frontpage.php'); + $fp = new TableFrontPage($db); + + // Is the article viewable on the frontpage? + if (JRequest::getVar( 'frontpage', 0, '', 'int' )) + { + // Is the item already viewable on the frontpage? + if (!$fp->load($row->id)) + { + // Insert the new entry + $query = 'INSERT INTO #__content_frontpage' . + ' VALUES ( '. (int) $row->id .', 1 )'; + $db->setQuery($query); + if (!$db->query()) + { + JError::raiseError( 500, $db->stderr() ); + return false; + } + $fp->ordering = 1; + } + } + else + { + // Delete the item from frontpage if it exists + if (!$fp->delete($row->id)) { + $msg .= $fp->stderr(); + } + $fp->ordering = 0; + } + $fp->reorder(); + + $cache = & JFactory::getCache('com_content'); + $cache->clean(); + + $dispatcher->trigger('onAfterContentSave', array(&$row, $isNew)); + + switch ($task) + { + case 'go2menu' : + $mainframe->redirect('index.php?option=com_menus&menutype='.$menu); + break; + + case 'go2menuitem' : + $mainframe->redirect('index.php?option=com_menus&menutype='.$menu.'&task=edit&id='.$menuid); + break; + + case 'menulink' : + ContentHelper::menuLink($redirect, $row->id); + break; + + case 'resethits' : + ContentHelper::resetHits($redirect, $row->id); + break; + + case 'apply' : + $msg = JText::sprintf('SUCCESSFULLY SAVED CHANGES TO ARTICLE', $row->title); + $mainframe->redirect('index.php?option=com_content§ionid='.$redirect.'&task=edit&cid[]='.$row->id, $msg); + break; + + case 'save' : + default : + $msg = JText::sprintf('Successfully Saved Article', $row->title); + $mainframe->redirect('index.php?option=com_content§ionid='.$redirect, $msg); + break; + } + } + + /** + * Changes the state of one or more content pages + * + * @param string The name of the category section + * @param integer A unique category id (passed from an edit form) + * @param array An array of unique category id numbers + * @param integer 0 if unpublishing, 1 if publishing + * @param string The name of the current user + */ + function changeContent( $state = 0 ) + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db = & JFactory::getDBO(); + $user = & JFactory::getUser(); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + $option = JRequest::getCmd( 'option' ); + $task = JRequest::getCmd( 'task' ); + $rtask = JRequest::getCmd( 'returntask', '', 'post' ); + if ($rtask) { + $rtask = '&task='.$rtask; + } + + if (count($cid) < 1) { + $redirect = JRequest::getVar( 'redirect', '', 'post', 'int' ); + $action = ($state == 1) ? 'publish' : ($state == -1 ? 'archive' : 'unpublish'); + $msg = JText::_('Select an item to') . ' ' . JText::_($action); + $mainframe->redirect('index.php?option='.$option.$rtask.'§ionid='.$redirect, $msg, 'error'); + } + + // Get some variables for the query + $uid = $user->get('id'); + $total = count($cid); + $cids = implode(',', $cid); + + $query = 'UPDATE #__content' . + ' SET state = '. (int) $state . + ' WHERE id IN ( '. $cids .' ) AND ( checked_out = 0 OR (checked_out = '. (int) $uid .' ) )'; + $db->setQuery($query); + if (!$db->query()) { + JError::raiseError( 500, $db->getErrorMsg() ); + return false; + } + + if (count($cid) == 1) { + $row = & JTable::getInstance('content'); + $row->checkin($cid[0]); + } + + switch ($state) + { + case -1 : + $msg = JText::sprintf('Item(s) successfully Archived', $total); + break; + + case 1 : + $msg = JText::sprintf('Item(s) successfully Published', $total); + break; + + case 0 : + default : + if ($task == 'unarchive') { + $msg = JText::sprintf('Item(s) successfully Unarchived', $total); + } else { + $msg = JText::sprintf('Item(s) successfully Unpublished', $total); + } + break; + } + + $cache = & JFactory::getCache('com_content'); + $cache->clean(); + + // Get some return/redirect information from the request + $redirect = JRequest::getVar( 'redirect', $row->sectionid, 'post', 'int' ); + + $mainframe->redirect('index.php?option='.$option.$rtask.'§ionid='.$redirect, $msg); + } + + /** + * Changes the frontpage state of one or more articles + * + */ + function toggleFrontPage() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db =& JFactory::getDBO(); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + $option = JRequest::getCmd( 'option' ); + $msg = null; + + JArrayHelper::toInteger($cid); + + if (count($cid) < 1) { + $msg = JText::_('Select an item to toggle'); + $mainframe->redirect('index.php?option='.$option, $msg, 'error'); + } + + /* + * We need to update frontpage status for the articles. + * + * First we include the frontpage table and instantiate an instance of + * it. + */ + require_once (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_frontpage'.DS.'tables'.DS.'frontpage.php'); + $fp = new TableFrontPage($db); + + foreach ($cid as $id) + { + // toggles go to first place + if ($fp->load($id)) { + if (!$fp->delete($id)) { + $msg .= $fp->stderr(); + } + $fp->ordering = 0; + } else { + // new entry + $query = 'INSERT INTO #__content_frontpage' . + ' VALUES ( '. (int) $id .', 0 )'; + $db->setQuery($query); + if (!$db->query()) { + JError::raiseError( 500, $db->stderr() ); + return false; + } + $fp->ordering = 0; + } + $fp->reorder(); + } + + $cache = & JFactory::getCache('com_content'); + $cache->clean(); + + $mainframe->redirect('index.php?option='.$option, $msg); + } + + function removeContent() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db = & JFactory::getDBO(); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + $option = JRequest::getCmd( 'option' ); + $return = JRequest::getCmd( 'returntask', '', 'post' ); + $nullDate = $db->getNullDate(); + + JArrayHelper::toInteger($cid); + + if (count($cid) < 1) { + $msg = JText::_('Select an item to delete'); + $mainframe->redirect('index.php?option='.$option, $msg, 'error'); + } + + // Removed content gets put in the trash [state = -2] and ordering is always set to 0 + $state = '-2'; + $ordering = '0'; + + // Get the list of content id numbers to send to trash. + $cids = implode(',', $cid); + + // Update articles in the database + $query = 'UPDATE #__content' . + ' SET state = '.(int) $state . + ', ordering = '.(int) $ordering . + ', checked_out = 0, checked_out_time = '.$db->Quote($nullDate). + ' WHERE id IN ( '. $cids. ' )'; + $db->setQuery($query); + if (!$db->query()) + { + JError::raiseError( 500, $db->getErrorMsg() ); + return false; + } + + $cache = & JFactory::getCache('com_content'); + $cache->clean(); + + $msg = JText::sprintf('Item(s) sent to the Trash', count($cid)); + $mainframe->redirect('index.php?option='.$option.'&task='.$return, $msg); + } + + /** + * Cancels an edit operation + */ + function cancelContent() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db = & JFactory::getDBO(); + + // Check the article in if checked out + $row = & JTable::getInstance('content'); + $row->bind(JRequest::get('post')); + $row->checkin(); + + $mainframe->redirect('index.php?option=com_content'); + } + + /** + * Moves the order of a record + * @param integer The increment to reorder by + */ + function orderContent($direction) + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db = & JFactory::getDBO(); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + + if (isset( $cid[0] )) + { + $row = & JTable::getInstance('content'); + $row->load( (int) $cid[0] ); + $row->move($direction, 'catid = ' . (int) $row->catid . ' AND state >= 0' ); + + $cache = & JFactory::getCache('com_content'); + $cache->clean(); + } + + $mainframe->redirect('index.php?option=com_content'); + } + + /** + * Form for moving item(s) to a different section and category + */ + function moveSection() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db =& JFactory::getDBO(); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + $sectionid = JRequest::getVar( 'sectionid', 0, '', 'int' ); + + JArrayHelper::toInteger($cid); + + if (count($cid) < 1) { + $msg = JText::_('Select an item to move'); + $mainframe->redirect('index.php?option=com_content', $msg, 'error'); + } + + //seperate contentids + $cids = implode(',', $cid); + // Articles query + $query = 'SELECT a.title' . + ' FROM #__content AS a' . + ' WHERE ( a.id IN ( '. $cids .' ) )' . + ' ORDER BY a.title'; + $db->setQuery($query); + $items = $db->loadObjectList(); + + $query = 'SELECT CONCAT_WS( ", ", s.id, c.id ) AS `value`, CONCAT_WS( " / ", s.title, c.title ) AS `text`' . + ' FROM #__sections AS s' . + ' INNER JOIN #__categories AS c ON c.section = s.id' . + ' WHERE s.scope = "content"' . + ' ORDER BY s.title, c.title'; + $db->setQuery($query); + $rows[] = JHTML::_('select.option', "0, 0", JText::_('UNCATEGORIZED')); + $rows = array_merge($rows, $db->loadObjectList()); + // build the html select list + $sectCatList = JHTML::_('select.genericlist', $rows, 'sectcat', 'class="inputbox" size="8"', 'value', 'text', null); + + ContentView::moveSection($cid, $sectCatList, 'com_content', $sectionid, $items); + } + + /** + * Save the changes to move item(s) to a different section and category + */ + function moveSectionSave() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db = & JFactory::getDBO(); + $user = & JFactory::getUser(); + + $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); + $sectionid = JRequest::getVar( 'sectionid', 0, '', 'int' ); + $option = JRequest::getCmd( 'option' ); + + JArrayHelper::toInteger($cid, array(0)); + + $sectcat = JRequest::getVar( 'sectcat', '', 'post', 'string' ); + $sectcat = explode(',', $sectcat); + $newsect = (int) @$sectcat[0]; + $newcat = (int) @$sectcat[1]; + + if ((!$newsect || !$newcat) && ($sectcat !== array('0', ' 0'))) { + $mainframe->redirect("index.php?option=com_content§ionid=$sectionid", JText::_('An error has occurred')); + } + + // find section name + $query = 'SELECT a.title' . + ' FROM #__sections AS a' . + ' WHERE a.id = '. (int) $newsect; + $db->setQuery($query); + $section = $db->loadResult(); + + // find category name + $query = 'SELECT a.title' . + ' FROM #__categories AS a' . + ' WHERE a.id = '. (int) $newcat; + $db->setQuery($query); + $category = $db->loadResult(); + + $total = count($cid); + $cids = implode(',', $cid); + $uid = $user->get('id'); + + $row = & JTable::getInstance('content'); + // update old orders - put existing items in last place + foreach ($cid as $id) + { + $row->load(intval($id)); + $row->ordering = 0; + $row->store(); + $row->reorder('catid = '.(int) $row->catid.' AND state >= 0'); + } + + $query = 'UPDATE #__content SET sectionid = '.(int) $newsect.', catid = '.(int) $newcat. + ' WHERE id IN ( '.$cids.' )' . + ' AND ( checked_out = 0 OR ( checked_out = '.(int) $uid.' ) )'; + $db->setQuery($query); + if (!$db->query()) + { + JError::raiseError( 500, $db->getErrorMsg() ); + return false; + } + + // update new orders - put items in last place + foreach ($cid as $id) + { + $row->load(intval($id)); + $row->ordering = 0; + $row->store(); + $row->reorder('catid = '.(int) $row->catid.' AND state >= 0'); + } + + if ($section && $category) { + $msg = JText::sprintf('Item(s) successfully moved to Section', $total, $section, $category); + } else { + $msg = JText::sprintf('ITEM(S) SUCCESSFULLY MOVED TO UNCATEGORIZED', $total); + } + + $mainframe->redirect('index.php?option='.$option.'§ionid='.$sectionid, $msg); + } + + /** + * Form for copying item(s) + **/ + function copyItem() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db = & JFactory::getDBO(); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + $sectionid = JRequest::getVar( 'sectionid', 0, '', 'int' ); + $option = JRequest::getCmd( 'option' ); + + JArrayHelper::toInteger($cid); + + if (count($cid) < 1) { + $msg = JText::_('Select an item to move'); + $mainframe->redirect('index.php?option='.$option, $msg, 'error'); + } + + //seperate contentids + $cids = implode(',', $cid); + ## Articles query + $query = 'SELECT a.title' . + ' FROM #__content AS a' . + ' WHERE ( a.id IN ( '. $cids .' ) )' . + ' ORDER BY a.title'; + $db->setQuery($query); + $items = $db->loadObjectList(); + + ## Section & Category query + $query = 'SELECT CONCAT_WS(",",s.id,c.id) AS `value`, CONCAT_WS(" / ", s.title, c.title) AS `text`' . + ' FROM #__sections AS s' . + ' INNER JOIN #__categories AS c ON c.section = s.id' . + ' WHERE s.scope = "content"' . + ' ORDER BY s.title, c.title'; + $db->setQuery($query); + + // Add a row for uncategorized content + $uncat = JHTML::_('select.option', '0,0', JText::_('UNCATEGORIZED')); + $rows = $db->loadObjectList(); + array_unshift($rows, $uncat); + // build the html select list + $sectCatList = JHTML::_('select.genericlist', $rows, 'sectcat', 'class="inputbox" size="10"', 'value', 'text', NULL); + + ContentView::copySection($option, $cid, $sectCatList, $sectionid, $items); + } + + /** + * saves Copies of items + **/ + function copyItemSave() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db = & JFactory::getDBO(); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + $sectionid = JRequest::getVar( 'sectionid', 0, '', 'int' ); + $option = JRequest::getCmd( 'option' ); + + JArrayHelper::toInteger($cid); + + $item = null; + $sectcat = JRequest::getVar( 'sectcat', '-1,-1', 'post', 'string' ); + //seperate sections and categories from selection + $sectcat = explode(',', $sectcat); + $newsect = (int) @$sectcat[0]; + $newcat = (int) @$sectcat[1]; + + if (($newsect == -1) || ($newcat == -1)) { + $mainframe->redirect('index.php?option=com_content§ionid='.$sectionid, JText::_('An error has occurred')); + } + + // find section name + $query = 'SELECT a.title' . + ' FROM #__sections AS a' . + ' WHERE a.id = '. (int) $newsect; + $db->setQuery($query); + $section = $db->loadResult(); + + // find category name + $query = 'SELECT a.title' . + ' FROM #__categories AS a' . + ' WHERE a.id = '. (int) $newcat; + $db->setQuery($query); + $category = $db->loadResult(); + + if (($newsect == 0) && ($newcat == 0)) + { + $section = JText::_('UNCATEGORIZED'); + $category = JText::_('UNCATEGORIZED'); + } + + $total = count($cid); + for ($i = 0; $i < $total; $i ++) + { + $row = & JTable::getInstance('content'); + + // main query + $query = 'SELECT a.*' . + ' FROM #__content AS a' . + ' WHERE a.id = '.(int) $cid[$i]; + $db->setQuery($query, 0, 1); + $item = $db->loadObject(); + + // values loaded into array set for store + $row->id = NULL; + $row->sectionid = $newsect; + $row->catid = $newcat; + $row->hits = '0'; + $row->ordering = '0'; + $row->title = $item->title; + $row->alias = $item->alias; + $row->title_alias = $item->title_alias; + $row->introtext = $item->introtext; + $row->fulltext = $item->fulltext; + $row->state = $item->state; + $row->mask = $item->mask; + $row->created = $item->created; + $row->created_by = $item->created_by; + $row->created_by_alias = $item->created_by_alias; + $row->modified = $item->modified; + $row->modified_by = $item->modified_by; + $row->checked_out = $item->checked_out; + $row->checked_out_time = $item->checked_out_time; + $row->publish_up = $item->publish_up; + $row->publish_down = $item->publish_down; + $row->images = $item->images; + $row->attribs = $item->attribs; + $row->version = $item->parentid; + $row->parentid = $item->parentid; + $row->metakey = $item->metakey; + $row->metadesc = $item->metadesc; + $row->access = $item->access; + $row->metadata = $item->metadata; + + if (!$row->check()) { + JError::raiseError( 500, $row->getError() ); + return false; + } + + if (!$row->store()) { + JError::raiseError( 500, $row->getError() ); + return false; + } + $row->reorder('catid='.(int) $row->catid.' AND state >= 0'); + } + + $msg = JText::sprintf('Item(s) successfully copied to Section', $total, $section, $category); + $mainframe->redirect('index.php?option='.$option.'§ionid='.$sectionid, $msg); + } + + /** + * @param integer The id of the article + * @param integer The new access level + * @param string The URL option + */ + function accessMenu($access) + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db = & JFactory::getDBO(); + + $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); + $option = JRequest::getCmd( 'option' ); + $cid = $cid[0]; + + // Create and load the article table object + $row = & JTable::getInstance('content'); + $row->load($cid); + $row->access = $access; + + // Ensure the article object is valid + if (!$row->check()) { + JError::raiseError( 500, $row->getError() ); + return false; + } + + // Store the changes + if (!$row->store()) { + JError::raiseError( 500, $row->getError() ); + return false; + } + + $cache = & JFactory::getCache('com_content'); + $cache->clean(); + + $mainframe->redirect('index.php?option='.$option); + } + + function saveOrder() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize variables + $db = & JFactory::getDBO(); + + $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); + $order = JRequest::getVar( 'order', array (0), 'post', 'array' ); + $redirect = JRequest::getVar( 'redirect', 0, 'post', 'int' ); + $rettask = JRequest::getVar( 'returntask', '', 'post', 'cmd' ); + $total = count($cid); + $conditions = array (); + + JArrayHelper::toInteger($cid, array(0)); + JArrayHelper::toInteger($order, array(0)); + + // Instantiate an article table object + $row = & JTable::getInstance('content'); + + // Update the ordering for items in the cid array + for ($i = 0; $i < $total; $i ++) + { + $row->load( (int) $cid[$i] ); + if ($row->ordering != $order[$i]) { + $row->ordering = $order[$i]; + if (!$row->store()) { + JError::raiseError( 500, $db->getErrorMsg() ); + return false; + } + // remember to updateOrder this group + $condition = 'catid = '.(int) $row->catid.' AND state >= 0'; + $found = false; + foreach ($conditions as $cond) + if ($cond[1] == $condition) { + $found = true; + break; + } + if (!$found) + $conditions[] = array ($row->id, $condition); + } + } + + // execute updateOrder for each group + foreach ($conditions as $cond) + { + $row->load($cond[0]); + $row->reorder($cond[1]); + } + + $cache = & JFactory::getCache('com_content'); + $cache->clean(); + + $msg = JText::_('New ordering saved'); + switch ($rettask) + { + case 'showarchive' : + $mainframe->redirect('index.php?option=com_content&task=showarchive§ionid='.$redirect, $msg); + break; + + default : + $mainframe->redirect('index.php?option=com_content§ionid='.$redirect, $msg); + break; + } + } + + function previewContent() + { + // Initialize variables + $document =& JFactory::getDocument(); + $db =& JFactory::getDBO(); + $id = JRequest::getVar( 'id', 0, '', 'int' ); + $option = JRequest::getCmd( 'option' ); + + // Get the current default template + $query = 'SELECT template' . + ' FROM #__templates_menu' . + ' WHERE client_id = 0' . + ' AND menuid = 0'; + $db->setQuery($query); + $template = $db->loadResult(); + + // check if template editor stylesheet exists + if (!file_exists( JPATH_SITE.DS.'templates'.DS.$template.DS.'css'.DS.'editor.css' )) { + $template = 'system'; + } + + // Set page title + $document->setTitle(JText::_('Article Preview')); + $document->addStyleSheet(JURI::root() . 'templates/'.$template.'/css/editor.css'); + $document->setBase(JUri::root()); + + // Render article preview + ContentView::previewContent(); + } + + function insertPagebreak() + { + $document =& JFactory::getDocument(); + $document->setTitle(JText::_('PGB ARTICLE PAGEBRK')); + ContentView::insertPagebreak(); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_content/elements/article.php b/oss/joomla/trunk/administrator/components/com_content/elements/article.php index 0e8853b4..1ed703e1 100644 --- a/oss/joomla/trunk/administrator/components/com_content/elements/article.php +++ b/oss/joomla/trunk/administrator/components/com_content/elements/article.php @@ -1,60 +1,60 @@ -getTemplate(); - $fieldName = $control_name.'['.$name.']'; - $article =& JTable::getInstance('content'); - if ($value) { - $article->load($value); - } else { - $article->title = JText::_('Select an Article'); - } - - $js = " - function jSelectArticle(id, title, object) { - document.getElementById(object + '_id').value = id; - document.getElementById(object + '_name').value = title; - document.getElementById('sbox-window').close(); - }"; - $doc->addScriptDeclaration($js); - - $link = 'index.php?option=com_content&task=element&tmpl=component&object='.$name; - - JHTML::_('behavior.modal', 'a.modal'); - $html = "\n".'
    '; -// $html .= "\n   "; - $html .= ''."\n"; - $html .= "\n".''; - - return $html; - } -} +getTemplate(); + $fieldName = $control_name.'['.$name.']'; + $article =& JTable::getInstance('content'); + if ($value) { + $article->load($value); + } else { + $article->title = JText::_('Select an Article'); + } + + $js = " + function jSelectArticle(id, title, object) { + document.getElementById(object + '_id').value = id; + document.getElementById(object + '_name').value = title; + document.getElementById('sbox-window').close(); + }"; + $doc->addScriptDeclaration($js); + + $link = 'index.php?option=com_content&task=element&tmpl=component&object='.$name; + + JHTML::_('behavior.modal', 'a.modal'); + $html = "\n".'
    '; +// $html .= "\n   "; + $html .= ''."\n"; + $html .= "\n".''; + + return $html; + } +} diff --git a/oss/joomla/trunk/administrator/components/com_content/elements/author.php b/oss/joomla/trunk/administrator/components/com_content/elements/author.php index 61fd0f34..e9c0f3e4 100644 --- a/oss/joomla/trunk/administrator/components/com_content/elements/author.php +++ b/oss/joomla/trunk/administrator/components/com_content/elements/author.php @@ -1,38 +1,38 @@ -', '
    ', $text ); - - // Search for the {readmore} tag and split the text up accordingly. - $pattern = '##i'; - $tagPos = preg_match($pattern, $text); - - if ( $tagPos == 0 ) - { - $row->introtext = $text; - } else - { - list($row->introtext, $row->fulltext) = preg_split($pattern, $text, 2); - } - - // Filter settings - jimport( 'joomla.application.component.helper' ); - $config = JComponentHelper::getParams( 'com_content' ); - $user = &JFactory::getUser(); - $gid = $user->get( 'gid' ); - - $filterGroups = $config->get( 'filter_groups' ); - - // convert to array if one group selected - if ( (!is_array($filterGroups) && (int) $filterGroups > 0) ) { - $filterGroups = array($filterGroups); - } - - if (is_array($filterGroups) && in_array( $gid, $filterGroups )) - { - $filterType = $config->get( 'filter_type' ); - $filterTags = preg_split( '#[,\s]+#', trim( $config->get( 'filter_tags' ) ) ); - $filterAttrs = preg_split( '#[,\s]+#', trim( $config->get( 'filter_attritbutes' ) ) ); - switch ($filterType) - { - case 'NH': - $filter = new JFilterInput(); - break; - case 'WL': - $filter = new JFilterInput( $filterTags, $filterAttrs, 0, 0, 0); // turn off xss auto clean - break; - case 'BL': - default: - $filter = new JFilterInput( $filterTags, $filterAttrs, 1, 1 ); - break; - } - $row->introtext = $filter->clean( $row->introtext ); - $row->fulltext = $filter->clean( $row->fulltext ); - } elseif(empty($filterGroups) && $gid != '25') { // no default filtering for super admin (gid=25) - $filter = new JFilterInput( array(), array(), 1, 1 ); - $row->introtext = $filter->clean( $row->introtext ); - $row->fulltext = $filter->clean( $row->fulltext ); - } - return true; - } - - /** - * Function to reset Hit count of an article - * - */ - function resetHits($redirect, $id) - { - global $mainframe; - - // Initialize variables - $db = & JFactory::getDBO(); - - // Instantiate and load an article table - $row = & JTable::getInstance('content'); - $row->Load($id); - $row->hits = 0; - $row->store(); - $row->checkin(); - - $msg = JText::_('Successfully Reset Hit count'); - $mainframe->redirect('index.php?option=com_content§ionid='.$redirect.'&task=edit&id='.$id, $msg); - } - - function filterCategory($query, $active = NULL) - { - // Initialize variables - $db = & JFactory::getDBO(); - - $categories[] = JHTML::_('select.option', '0', '- '.JText::_('Select Category').' -'); - $db->setQuery($query); - $categories = array_merge($categories, $db->loadObjectList()); - - $category = JHTML::_('select.genericlist', $categories, 'catid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $active); - - return $category; - } - -} +', '
    ', $text ); + + // Search for the {readmore} tag and split the text up accordingly. + $pattern = '##i'; + $tagPos = preg_match($pattern, $text); + + if ( $tagPos == 0 ) + { + $row->introtext = $text; + } else + { + list($row->introtext, $row->fulltext) = preg_split($pattern, $text, 2); + } + + // Filter settings + jimport( 'joomla.application.component.helper' ); + $config = JComponentHelper::getParams( 'com_content' ); + $user = &JFactory::getUser(); + $gid = $user->get( 'gid' ); + + $filterGroups = $config->get( 'filter_groups' ); + + // convert to array if one group selected + if ( (!is_array($filterGroups) && (int) $filterGroups > 0) ) { + $filterGroups = array($filterGroups); + } + + if (is_array($filterGroups) && in_array( $gid, $filterGroups )) + { + $filterType = $config->get( 'filter_type' ); + $filterTags = preg_split( '#[,\s]+#', trim( $config->get( 'filter_tags' ) ) ); + $filterAttrs = preg_split( '#[,\s]+#', trim( $config->get( 'filter_attritbutes' ) ) ); + switch ($filterType) + { + case 'NH': + $filter = new JFilterInput(); + break; + case 'WL': + $filter = new JFilterInput( $filterTags, $filterAttrs, 0, 0, 0); // turn off xss auto clean + break; + case 'BL': + default: + $filter = new JFilterInput( $filterTags, $filterAttrs, 1, 1 ); + break; + } + $row->introtext = $filter->clean( $row->introtext ); + $row->fulltext = $filter->clean( $row->fulltext ); + } elseif(empty($filterGroups) && $gid != '25') { // no default filtering for super admin (gid=25) + $filter = new JFilterInput( array(), array(), 1, 1 ); + $row->introtext = $filter->clean( $row->introtext ); + $row->fulltext = $filter->clean( $row->fulltext ); + } + return true; + } + + /** + * Function to reset Hit count of an article + * + */ + function resetHits($redirect, $id) + { + global $mainframe; + + // Initialize variables + $db = & JFactory::getDBO(); + + // Instantiate and load an article table + $row = & JTable::getInstance('content'); + $row->Load($id); + $row->hits = 0; + $row->store(); + $row->checkin(); + + $msg = JText::_('Successfully Reset Hit count'); + $mainframe->redirect('index.php?option=com_content§ionid='.$redirect.'&task=edit&id='.$id, $msg); + } + + function filterCategory($query, $active = NULL) + { + // Initialize variables + $db = & JFactory::getDBO(); + + $categories[] = JHTML::_('select.option', '0', '- '.JText::_('Select Category').' -'); + $db->setQuery($query); + $categories = array_merge($categories, $db->loadObjectList()); + + $category = JHTML::_('select.genericlist', $categories, 'catid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $active); + + return $category; + } + +} diff --git a/oss/joomla/trunk/administrator/components/com_content/helper/content.php b/oss/joomla/trunk/administrator/components/com_content/helper/content.php index 4ad556a9..029e95a3 100644 --- a/oss/joomla/trunk/administrator/components/com_content/helper/content.php +++ b/oss/joomla/trunk/administrator/components/com_content/helper/content.php @@ -1,72 +1,72 @@ - - - - - - - - - - - - - - - - - -
    - <?php echo JText::_( 'Pending' ); ?> - - | - - <?php echo JText::_( 'Visible' ); ?> - - | - - <?php echo JText::_( 'Finished' ); ?> - - | - - <?php echo JText::_( 'Finished' ); ?> - - | - - <?php echo JText::_( 'Archived' ); ?> - - -
    - -
    - + + + + + + + + + + + + + + + + +
    + <?php echo JText::_( 'Pending' ); ?> + + | + + <?php echo JText::_( 'Visible' ); ?> + + | + + <?php echo JText::_( 'Finished' ); ?> + + | + + <?php echo JText::_( 'Finished' ); ?> + + | + + <?php echo JText::_( 'Archived' ); ?> + + +
    + +
    + _list)) { - return $this->_list; - } - - // Initialize variables - $db =& $this->getDBO(); - $filter = null; - - // Get some variables from the request - $sectionid = JRequest::getVar( 'sectionid', -1, '', 'int' ); - $redirect = $sectionid; - $option = JRequest::getCmd( 'option' ); - $filter_order = $mainframe->getUserStateFromRequest('articleelement.filter_order', 'filter_order', '', 'cmd'); - $filter_order_Dir = $mainframe->getUserStateFromRequest('articleelement.filter_order_Dir', 'filter_order_Dir', '', 'word'); - $catid = $mainframe->getUserStateFromRequest('articleelement.catid', 'catid', 0, 'int'); - $filter_authorid = $mainframe->getUserStateFromRequest('articleelement.filter_authorid', 'filter_authorid', 0, 'int'); - $filter_sectionid = $mainframe->getUserStateFromRequest('articleelement.filter_sectionid', 'filter_sectionid', -1, 'int'); - $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); - $limitstart = $mainframe->getUserStateFromRequest('articleelement.limitstart', 'limitstart', 0, 'int'); - $search = $mainframe->getUserStateFromRequest('articleelement.search', 'search', '', 'string'); - $search = JString::strtolower($search); - - //$where[] = "c.state >= 0"; - $where[] = "c.state != -2"; - - if (!$filter_order) { - $filter_order = 'section_name'; - } - $order = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', section_name, cc.name, c.ordering'; - $all = 1; - - if ($filter_sectionid >= 0) { - $filter = ' WHERE cc.section = '.$db->Quote($filter_sectionid); - } - $section->title = 'All Articles'; - $section->id = 0; - - /* - * Add the filter specific information to the where clause - */ - // Section filter - if ($filter_sectionid >= 0) { - $where[] = 'c.sectionid = '.(int) $filter_sectionid; - } - // Category filter - if ($catid > 0) { - $where[] = 'c.catid = '.(int) $catid; - } - // Author filter - if ($filter_authorid > 0) { - $where[] = 'c.created_by = '.(int) $filter_authorid; - } - - // Only published articles - $where[] = 'c.state = 1'; - - // Keyword filter - if ($search) { - $where[] = 'LOWER( c.title ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); - } - - // Build the where clause of the content record query - $where = (count($where) ? ' WHERE '.implode(' AND ', $where) : ''); - - // Get the total number of records - $query = 'SELECT COUNT(*)' . - ' FROM #__content AS c' . - ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' . - ' LEFT JOIN #__sections AS s ON s.id = c.sectionid' . - $where; - $db->setQuery($query); - $total = $db->loadResult(); - - // Create the pagination object - jimport('joomla.html.pagination'); - $this->_page = new JPagination($total, $limitstart, $limit); - - // Get the articles - $query = 'SELECT c.*, g.name AS groupname, cc.title as cctitle, u.name AS editor, f.content_id AS frontpage, s.title AS section_name, v.name AS author' . - ' FROM #__content AS c' . - ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' . - ' LEFT JOIN #__sections AS s ON s.id = c.sectionid' . - ' LEFT JOIN #__groups AS g ON g.id = c.access' . - ' LEFT JOIN #__users AS u ON u.id = c.checked_out' . - ' LEFT JOIN #__users AS v ON v.id = c.created_by' . - ' LEFT JOIN #__content_frontpage AS f ON f.content_id = c.id' . - $where . - $order; - $db->setQuery($query, $this->_page->limitstart, $this->_page->limit); - $this->_list = $db->loadObjectList(); - - // If there is a db query error, throw a HTTP 500 and exit - if ($db->getErrorNum()) { - JError::raiseError( 500, $db->stderr() ); - return false; - } - - return $this->_list; - } - - function getPagination() - { - if (is_null($this->_list) || is_null($this->_page)) { - $this->getList(); - } - return $this->_page; - } -} -?> +_list)) { + return $this->_list; + } + + // Initialize variables + $db =& $this->getDBO(); + $filter = null; + + // Get some variables from the request + $sectionid = JRequest::getVar( 'sectionid', -1, '', 'int' ); + $redirect = $sectionid; + $option = JRequest::getCmd( 'option' ); + $filter_order = $mainframe->getUserStateFromRequest('articleelement.filter_order', 'filter_order', '', 'cmd'); + $filter_order_Dir = $mainframe->getUserStateFromRequest('articleelement.filter_order_Dir', 'filter_order_Dir', '', 'word'); + $catid = $mainframe->getUserStateFromRequest('articleelement.catid', 'catid', 0, 'int'); + $filter_authorid = $mainframe->getUserStateFromRequest('articleelement.filter_authorid', 'filter_authorid', 0, 'int'); + $filter_sectionid = $mainframe->getUserStateFromRequest('articleelement.filter_sectionid', 'filter_sectionid', -1, 'int'); + $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); + $limitstart = $mainframe->getUserStateFromRequest('articleelement.limitstart', 'limitstart', 0, 'int'); + $search = $mainframe->getUserStateFromRequest('articleelement.search', 'search', '', 'string'); + if (strpos($search, '"') !== false) { + $search = str_replace(array('=', '<'), '', $search); + } + $search = JString::strtolower($search); + + //$where[] = "c.state >= 0"; + $where[] = "c.state != -2"; + + if (!$filter_order) { + $filter_order = 'section_name'; + } + $order = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', section_name, cc.name, c.ordering'; + $all = 1; + + if ($filter_sectionid >= 0) { + $filter = ' WHERE cc.section = '.$db->Quote($filter_sectionid); + } + $section->title = 'All Articles'; + $section->id = 0; + + /* + * Add the filter specific information to the where clause + */ + // Section filter + if ($filter_sectionid >= 0) { + $where[] = 'c.sectionid = '.(int) $filter_sectionid; + } + // Category filter + if ($catid > 0) { + $where[] = 'c.catid = '.(int) $catid; + } + // Author filter + if ($filter_authorid > 0) { + $where[] = 'c.created_by = '.(int) $filter_authorid; + } + + // Only published articles + $where[] = 'c.state = 1'; + + // Keyword filter + if ($search) { + $where[] = 'LOWER( c.title ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + + // Build the where clause of the content record query + $where = (count($where) ? ' WHERE '.implode(' AND ', $where) : ''); + + // Get the total number of records + $query = 'SELECT COUNT(*)' . + ' FROM #__content AS c' . + ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' . + ' LEFT JOIN #__sections AS s ON s.id = c.sectionid' . + $where; + $db->setQuery($query); + $total = $db->loadResult(); + + // Create the pagination object + jimport('joomla.html.pagination'); + $this->_page = new JPagination($total, $limitstart, $limit); + + // Get the articles + $query = 'SELECT c.*, g.name AS groupname, cc.title as cctitle, u.name AS editor, f.content_id AS frontpage, s.title AS section_name, v.name AS author' . + ' FROM #__content AS c' . + ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' . + ' LEFT JOIN #__sections AS s ON s.id = c.sectionid' . + ' LEFT JOIN #__groups AS g ON g.id = c.access' . + ' LEFT JOIN #__users AS u ON u.id = c.checked_out' . + ' LEFT JOIN #__users AS v ON v.id = c.created_by' . + ' LEFT JOIN #__content_frontpage AS f ON f.content_id = c.id' . + $where . + $order; + $db->setQuery($query, $this->_page->limitstart, $this->_page->limit); + $this->_list = $db->loadObjectList(); + + // If there is a db query error, throw a HTTP 500 and exit + if ($db->getErrorNum()) { + JError::raiseError( 500, $db->stderr() ); + return false; + } + + return $this->_list; + } + + function getPagination() + { + if (is_null($this->_list) || is_null($this->_page)) { + $this->getList(); + } + return $this->_page; + } +} +?> diff --git a/oss/joomla/trunk/administrator/components/com_content/toolbar.content.html.php b/oss/joomla/trunk/administrator/components/com_content/toolbar.content.html.php index e6b2111c..cb97ec59 100644 --- a/oss/joomla/trunk/administrator/components/com_content/toolbar.content.html.php +++ b/oss/joomla/trunk/administrator/components/com_content/toolbar.content.html.php @@ -1,84 +1,84 @@ -[ '. $text.' ]', 'addedit.png' ); - JToolBarHelper::preview( 'index.php?option=com_content&id='.$cid.'&tmpl=component', true ); - JToolBarHelper::save(); - JToolBarHelper::apply(); - if ( $edit ) { - // for existing articles the button is renamed `close` - JToolBarHelper::cancel( 'cancel', 'Close' ); - } else { - JToolBarHelper::cancel(); - } - JToolBarHelper::help( 'screen.content.edit' ); - } -/* - function _ARCHIVE() - { - JToolBarHelper::title( JText::_( 'Archive Manager' ), 'addedit.png' ); - JToolBarHelper::unarchiveList(); - JToolBarHelper::custom( 'remove', 'delete.png', 'delete_f2.png', 'Trash', false ); - JToolBarHelper::help( 'screen.content.archive' ); - } -*/ - function _MOVE() - { - JToolBarHelper::title( JText::_( 'Move Articles' ), 'move_f2.png' ); - JToolBarHelper::custom( 'movesectsave', 'save.png', 'save_f2.png', 'Save', false ); - JToolBarHelper::cancel(); - } - - function _COPY() - { - JToolBarHelper::title( JText::_( 'Copy Articles' ), 'copy_f2.png' ); - JToolBarHelper::custom( 'copysave', 'save.png', 'save_f2.png', 'Save', false ); - JToolBarHelper::cancel(); - } - - function _DEFAULT() - { - global $filter_state; - - JToolBarHelper::title( JText::_( 'Article Manager' ), 'article.png' ); - if ($filter_state == 'A' || $filter_state == NULL) { - JToolBarHelper::unarchiveList(); - } - if ($filter_state != 'A') { - JToolBarHelper::archiveList(); - } - JToolBarHelper::publishList(); - JToolBarHelper::unpublishList(); - JToolBarHelper::customX( 'movesect', 'move.png', 'move_f2.png', 'Move' ); - JToolBarHelper::customX( 'copy', 'copy.png', 'copy_f2.png', 'Copy' ); - JToolBarHelper::trash(); - JToolBarHelper::editListX(); - JToolBarHelper::addNewX(); - JToolBarHelper::preferences('com_content', '550'); - JToolBarHelper::help( 'screen.content' ); - } +[ '. $text.' ]', 'addedit.png' ); + JToolBarHelper::preview( 'index.php?option=com_content&id='.$cid.'&tmpl=component', true ); + JToolBarHelper::save(); + JToolBarHelper::apply(); + if ( $edit ) { + // for existing articles the button is renamed `close` + JToolBarHelper::cancel( 'cancel', 'Close' ); + } else { + JToolBarHelper::cancel(); + } + JToolBarHelper::help( 'screen.content.edit' ); + } +/* + function _ARCHIVE() + { + JToolBarHelper::title( JText::_( 'Archive Manager' ), 'addedit.png' ); + JToolBarHelper::unarchiveList(); + JToolBarHelper::custom( 'remove', 'delete.png', 'delete_f2.png', 'Trash', false ); + JToolBarHelper::help( 'screen.content.archive' ); + } +*/ + function _MOVE() + { + JToolBarHelper::title( JText::_( 'Move Articles' ), 'move_f2.png' ); + JToolBarHelper::custom( 'movesectsave', 'save.png', 'save_f2.png', 'Save', false ); + JToolBarHelper::cancel(); + } + + function _COPY() + { + JToolBarHelper::title( JText::_( 'Copy Articles' ), 'copy_f2.png' ); + JToolBarHelper::custom( 'copysave', 'save.png', 'save_f2.png', 'Save', false ); + JToolBarHelper::cancel(); + } + + function _DEFAULT() + { + global $filter_state; + + JToolBarHelper::title( JText::_( 'Article Manager' ), 'article.png' ); + if ($filter_state == 'A' || $filter_state == NULL) { + JToolBarHelper::unarchiveList(); + } + if ($filter_state != 'A') { + JToolBarHelper::archiveList(); + } + JToolBarHelper::publishList(); + JToolBarHelper::unpublishList(); + JToolBarHelper::customX( 'movesect', 'move.png', 'move_f2.png', 'Move' ); + JToolBarHelper::customX( 'copy', 'copy.png', 'copy_f2.png', 'Copy' ); + JToolBarHelper::trash(); + JToolBarHelper::editListX(); + JToolBarHelper::addNewX(); + JToolBarHelper::preferences('com_content', '550'); + JToolBarHelper::help( 'screen.content' ); + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_content/toolbar.content.php b/oss/joomla/trunk/administrator/components/com_content/toolbar.content.php index b150f85e..22423c1e 100644 --- a/oss/joomla/trunk/administrator/components/com_content/toolbar.content.php +++ b/oss/joomla/trunk/administrator/components/com_content/toolbar.content.php @@ -1,48 +1,48 @@ -getNullDate(); - - $document = & JFactory::getDocument(); - $document->setTitle(JText::_('Article Selection')); - - JHTML::_('behavior.modal'); - - $template = $mainframe->getTemplate(); - $document->addStyleSheet("templates/$template/css/general.css"); - - $limitstart = JRequest::getVar('limitstart', '0', '', 'int'); - - $lists = $this->_getLists(); - - //Ordering allowed ? - $ordering = ($lists['order'] == 'section_name' && $lists['order_Dir'] == 'ASC'); - - $rows = &$this->get('List'); - $page = &$this->get('Pagination'); - JHTML::_('behavior.tooltip'); - ?> -
    - - - - - - -
    - : - - - - - -
    - - - - - - - - - - - - - - - - - - - - created, JText::_('DATE_FORMAT_LC4') ); - $access = JHTML::_('grid.access', $row, $i, $row->state ); - ?> - "> - - - - - - - - - - -
    - - - - - - - - - - - - - -
    - getListFooter(); ?> -
    - getRowOffset( $i ); ?> - - title); ?>', '');"> - title, ENT_QUOTES, 'UTF-8'); ?> - - groupname;?> - - id; ?> - - section_name; ?> - - cctitle; ?> - - -
    - - - - -
    - getUserStateFromRequest('articleelement.filter_order', 'filter_order', '', 'cmd'); - $filter_order_Dir = $mainframe->getUserStateFromRequest('articleelement.filter_order_Dir', 'filter_order_Dir', '', 'word'); - $filter_state = $mainframe->getUserStateFromRequest('articleelement.filter_state', 'filter_state', '', 'word'); - $catid = $mainframe->getUserStateFromRequest('articleelement.catid', 'catid', 0, 'int'); - $filter_authorid = $mainframe->getUserStateFromRequest('articleelement.filter_authorid', 'filter_authorid', 0, 'int'); - $filter_sectionid = $mainframe->getUserStateFromRequest('articleelement.filter_sectionid', 'filter_sectionid', -1, 'int'); - $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); - $limitstart = $mainframe->getUserStateFromRequest('articleelement.limitstart', 'limitstart', 0, 'int'); - $search = $mainframe->getUserStateFromRequest('articleelement.search', 'search', '', 'string'); - $search = JString::strtolower($search); - - // get list of categories for dropdown filter - $filter = ($filter_sectionid >= 0) ? ' WHERE cc.section = '.$db->Quote($filter_sectionid) : ''; - - // get list of categories for dropdown filter - $query = 'SELECT cc.id AS value, cc.title AS text, section' . - ' FROM #__categories AS cc' . - ' INNER JOIN #__sections AS s ON s.id = cc.section' . - $filter . - ' ORDER BY s.ordering, cc.ordering'; - - $lists['catid'] = ContentHelper::filterCategory($query, $catid); - - // get list of sections for dropdown filter - $javascript = 'onchange="document.adminForm.submit();"'; - $lists['sectionid'] = JHTML::_('list.section', 'filter_sectionid', $filter_sectionid, $javascript); - - // table ordering - $lists['order_Dir'] = $filter_order_Dir; - $lists['order'] = $filter_order; - - // search filter - $lists['search'] = $search; - - return $lists; - } -} +getNullDate(); + + $document = & JFactory::getDocument(); + $document->setTitle(JText::_('Article Selection')); + + JHTML::_('behavior.modal'); + + $template = $mainframe->getTemplate(); + $document->addStyleSheet("templates/$template/css/general.css"); + + $limitstart = JRequest::getVar('limitstart', '0', '', 'int'); + + $lists = $this->_getLists(); + + //Ordering allowed ? + $ordering = ($lists['order'] == 'section_name' && $lists['order_Dir'] == 'ASC'); + + $rows = &$this->get('List'); + $page = &$this->get('Pagination'); + JHTML::_('behavior.tooltip'); + ?> +
    + + + + + + +
    + : + + + + + +
    + + + + + + + + + + + + + + + + + + + + created, JText::_('DATE_FORMAT_LC4') ); + $access = JHTML::_('grid.access', $row, $i, $row->state ); + ?> + "> + + + + + + + + + + +
    + + + + + + + + + + + + + +
    + getListFooter(); ?> +
    + getRowOffset( $i ); ?> + + title); ?>', '');"> + title, ENT_QUOTES, 'UTF-8'); ?> + + groupname;?> + + id; ?> + + section_name; ?> + + cctitle; ?> + + +
    + + + + +
    + getUserStateFromRequest('articleelement.filter_order', 'filter_order', '', 'cmd'); + $filter_order_Dir = $mainframe->getUserStateFromRequest('articleelement.filter_order_Dir', 'filter_order_Dir', '', 'word'); + $filter_state = $mainframe->getUserStateFromRequest('articleelement.filter_state', 'filter_state', '', 'word'); + $catid = $mainframe->getUserStateFromRequest('articleelement.catid', 'catid', 0, 'int'); + $filter_authorid = $mainframe->getUserStateFromRequest('articleelement.filter_authorid', 'filter_authorid', 0, 'int'); + $filter_sectionid = $mainframe->getUserStateFromRequest('articleelement.filter_sectionid', 'filter_sectionid', -1, 'int'); + $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); + $limitstart = $mainframe->getUserStateFromRequest('articleelement.limitstart', 'limitstart', 0, 'int'); + $search = $mainframe->getUserStateFromRequest('articleelement.search', 'search', '', 'string'); + if (strpos($search, '"') !== false) { + $search = str_replace(array('=', '<'), '', $search); + } + $search = JString::strtolower($search); + + // get list of categories for dropdown filter + $filter = ($filter_sectionid >= 0) ? ' WHERE cc.section = '.$db->Quote($filter_sectionid) : ''; + + // get list of categories for dropdown filter + $query = 'SELECT cc.id AS value, cc.title AS text, section' . + ' FROM #__categories AS cc' . + ' INNER JOIN #__sections AS s ON s.id = cc.section' . + $filter . + ' ORDER BY s.ordering, cc.ordering'; + + $lists['catid'] = ContentHelper::filterCategory($query, $catid); + + // get list of sections for dropdown filter + $javascript = 'onchange="document.adminForm.submit();"'; + $lists['sectionid'] = JHTML::_('list.section', 'filter_sectionid', $filter_sectionid, $javascript); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search'] = $search; + + return $lists; + } +} diff --git a/oss/joomla/trunk/administrator/components/com_cpanel/admin.cpanel.html.php b/oss/joomla/trunk/administrator/components/com_cpanel/admin.cpanel.html.php index 331de200..d130adcd 100644 --- a/oss/joomla/trunk/administrator/components/com_cpanel/admin.cpanel.html.php +++ b/oss/joomla/trunk/administrator/components/com_cpanel/admin.cpanel.html.php @@ -1,48 +1,48 @@ - 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(); - } + 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 diff --git a/oss/joomla/trunk/administrator/components/com_cpanel/admin.cpanel.php b/oss/joomla/trunk/administrator/components/com_cpanel/admin.cpanel.php index d0c69cff..2ea58144 100644 --- a/oss/joomla/trunk/administrator/components/com_cpanel/admin.cpanel.php +++ b/oss/joomla/trunk/administrator/components/com_cpanel/admin.cpanel.php @@ -1,27 +1,27 @@ - - - Control Panel - Joomla! Project - 2006 - Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - admin@joomla.org - www.joomla.org - 1.5.0 - The Control Panel is the Home Page of the Joomla! Administrator Back-end - + + + Control Panel + Joomla! Project + 2006 + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + The Control Panel is the Home Page of the Joomla! Administrator Back-end + diff --git a/oss/joomla/trunk/administrator/components/com_cpanel/toolbar.cpanel.html.php b/oss/joomla/trunk/administrator/components/com_cpanel/toolbar.cpanel.html.php index c4f16973..e3b203ab 100644 --- a/oss/joomla/trunk/administrator/components/com_cpanel/toolbar.cpanel.html.php +++ b/oss/joomla/trunk/administrator/components/com_cpanel/toolbar.cpanel.html.php @@ -1,28 +1,28 @@ -authorize( 'com_frontpage', 'manage' )) { - $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); -} - -// Set the table directory -JTable::addIncludePath(JPATH_COMPONENT.DS.DS.'tables'); - -// Set the helper directory -JHTML::addIncludePath( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_content'.DS.'helper' ); - -$cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); -JArrayHelper::toInteger($cid, array(0)); - -switch ( JRequest::getCmd( 'task' ) ) -{ - case 'publish': - changeFrontPage( $cid, 1, $option ); - break; - - case 'unpublish': - changeFrontPage( $cid, 0, $option ); - break; - - case 'archive': - changeFrontPage( $cid, -1, $option ); - break; - - case 'remove': - removeFrontPage( $cid, $option ); - break; - - case 'orderup': - orderFrontPage( $cid[0], -1, $option ); - break; - - case 'orderdown': - orderFrontPage( $cid[0], 1, $option ); - break; - - case 'saveorder': - saveOrder( $cid ); - break; - - case 'accesspublic': - accessMenu( $cid[0], 0 ); - break; - - case 'accessregistered': - accessMenu( $cid[0], 1 ); - break; - - case 'accessspecial': - accessMenu( $cid[0], 2 ); - break; - - default: - viewFrontPage( $option ); - break; -} - - -/** -* Compiles a list of frontpage items -*/ -function viewFrontPage( $option ) -{ - global $mainframe; - - $db =& JFactory::getDBO(); - $filter_order = $mainframe->getUserStateFromRequest( $option.'.filter_order', 'filter_order', 'fpordering', 'cmd' ); - $filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'.filter_order_Dir', 'filter_order_Dir', '', 'word' ); - $filter_state = $mainframe->getUserStateFromRequest( $option.'.filter_state', 'filter_state', '', 'word' ); - $catid = $mainframe->getUserStateFromRequest( $option.'.catid', 'catid', 0, 'int' ); - $filter_authorid = $mainframe->getUserStateFromRequest( $option.'.filter_authorid', 'filter_authorid', 0, 'int' ); - $filter_sectionid = $mainframe->getUserStateFromRequest( $option.'.filter_sectionid', 'filter_sectionid', -1, 'int' ); - $search = $mainframe->getUserStateFromRequest( $option.'.search', 'search', '', 'string' ); - $search = JString::strtolower( $search ); - - $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); - $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); - - JToolBarHelper::title( JText::_( 'Frontpage Manager' ), 'frontpage.png' ); - JToolBarHelper::archiveList(); - JToolBarHelper::publishList(); - JToolBarHelper::unpublishList(); - JToolBarHelper::custom('remove','delete.png','delete_f2.png','Remove', true); - JToolBarHelper::help( 'screen.frontpage' ); - - $where = array( - "c.state >= 0" - ); - - // used by filter - if ( $filter_sectionid >= 0 ) { - $where[] = 'c.sectionid = '.(int) $filter_sectionid; - } - if ( $catid > 0 ) { - $where[] = 'c.catid = '.(int) $catid; - } - if ( $filter_authorid > 0 ) { - $where[] = 'c.created_by = '. (int) $filter_authorid; - } - if ( $filter_state ) { - if ( $filter_state == 'P' ) { - $where[] = 'c.state = 1'; - } else if ($filter_state == 'U' ) { - $where[] = 'c.state = 0'; - } - } - - if ($search) { - $where[] = 'LOWER( c.title ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); - } - - $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); - $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', fpordering'; - - // get the total number of records - $query = 'SELECT count(*)' - . ' FROM #__content AS c' - . ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' - . ' LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope="content"' - . ' INNER JOIN #__content_frontpage AS f ON f.content_id = c.id' - . $where - ; - $db->setQuery( $query ); - $total = $db->loadResult(); - - jimport('joomla.html.pagination'); - $pageNav = new JPagination( $total, $limitstart, $limit ); - - $query = 'SELECT c.*, g.name AS groupname, cc.title as name, s.title AS sect_name, u.name AS editor, f.ordering AS fpordering, v.name AS author' - . ' FROM #__content AS c' - . ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' - . ' LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope="content"' - . ' INNER JOIN #__content_frontpage AS f ON f.content_id = c.id' - . ' INNER JOIN #__groups AS g ON g.id = c.access' - . ' LEFT JOIN #__users AS u ON u.id = c.checked_out' - . ' LEFT JOIN #__users AS v ON v.id = c.created_by' - . $where - . $orderby - ; - $db->setQuery( $query, $pageNav->limitstart,$pageNav->limit ); - $rows = $db->loadObjectList(); - if ($db->getErrorNum()) { - echo $db->stderr(); - return false; - } - - // get list of categories for dropdown filter - $query = 'SELECT cc.id AS value, cc.title AS text, section' - . ' FROM #__categories AS cc' - . ' INNER JOIN #__sections AS s ON s.id = cc.section ' - . ' ORDER BY s.ordering, cc.ordering' - ; - $db->setQuery( $query ); - $categories[] = JHTML::_('select.option', '-1', '- '. JText::_( 'Select Category' ) .' -' ); - $categories = array_merge( $categories, $db->loadObjectList() ); - $lists['catid'] = JHTML::_('select.genericlist', $categories, 'catid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $catid ); - - // get list of sections for dropdown filter - $javascript = 'onchange="document.adminForm.submit();"'; - $lists['sectionid'] = JHTML::_('list.section', 'filter_sectionid', $filter_sectionid, $javascript ); - - // get list of Authors for dropdown filter - $query = 'SELECT c.created_by, u.name' - . ' FROM #__content AS c' - . ' INNER JOIN #__sections AS s ON s.id = c.sectionid' - . ' LEFT JOIN #__users AS u ON u.id = c.created_by' - . ' WHERE c.state <> -1' - . ' AND c.state <> -2' - . ' GROUP BY u.name' - . ' ORDER BY u.name' - ; - $db->setQuery( $query ); - $authors[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select Author' ) .' -', 'created_by', 'name' ); - $authors = array_merge( $authors, $db->loadObjectList() ); - $lists['authorid'] = JHTML::_('select.genericlist', $authors, 'filter_authorid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'created_by', 'name', $filter_authorid ); - - // state filter - $lists['state'] = JHTML::_('grid.state', $filter_state ); - - // table ordering - $lists['order_Dir'] = $filter_order_Dir; - $lists['order'] = $filter_order; - - // search filter - $lists['search']= $search; - - require_once(JPATH_COMPONENT.DS.'views'.DS.'frontpage.php'); - FrontpageView::showList( $rows, $pageNav, $option, $lists ); -} - -/** -* Changes the state of one or more content pages -* @param array An array of unique category id numbers -* @param integer 0 if unpublishing, 1 if publishing -*/ -function changeFrontPage( $cid=null, $state=0, $option ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $user =& JFactory::getUser(); - - JArrayHelper::toInteger($cid); - - if (count( $cid ) < 1) { - $action = $state == 1 ? 'publish' : ($state == -1 ? 'archive' : 'unpublish'); - JError::raiseError(500, JText::_( 'Select an item to' .$action, true ) ); - } - - $cids = implode( ',', $cid ); - - $query = 'UPDATE #__content' - . ' SET state = '.(int) $state - . ' WHERE id IN ( '. $cids .' )' - . ' AND ( checked_out = 0 OR ( checked_out = ' .(int) $user->get('id'). ' ) )' - ; - $db->setQuery( $query ); - if (!$db->query()) { - JError::raiseError(500, $db->getErrorMsg() ); - } - - if (count( $cid ) == 1) { - $row =& JTable::getInstance('content'); - $row->checkin( $cid[0] ); - } - - $cache = & JFactory::getCache('com_content'); - $cache->clean(); - - $mainframe->redirect( 'index.php?option='.$option ); -} - -function removeFrontPage( &$cid, $option ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - if (!is_array( $cid ) || count( $cid ) < 1) { - JError::raiseError(500, JText::_( 'Select an item to delete', true ) ); - } - $fp =& JTable::getInstance('frontpage', 'Table'); - foreach ($cid as $id) { - if (!$fp->delete( $id )) { - JError::raiseError(500, $fp->getError() ); - } - $obj =& JTable::getInstance('content'); - $obj->load( $id ); - $obj->mask = 0; - if (!$obj->store()) { - JError::raiseError(500, $fp->getError() ); - } - } - $fp->reorder(); - - $cache = & JFactory::getCache('com_content'); - $cache->clean(); - - $mainframe->redirect( 'index.php?option='.$option ); -} - -/** -* Moves the order of a record -* @param integer The increment to reorder by -*/ -function orderFrontPage( $uid, $inc, $option ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - - $fp =& JTable::getInstance('frontpage','Table'); - $fp->load( $uid ); - $fp->move( $inc ); - - $cache = & JFactory::getCache('com_content'); - $cache->clean(); - - $mainframe->redirect( 'index.php?option='.$option ); -} - -/** -* @param integer The id of the article -* @param integer The new access level -* @param string The URL option -*/ -function accessMenu( $uid, $access ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db = & JFactory::getDBO(); - $row =& JTable::getInstance('content'); - $row->load( $uid ); - $row->access = $access; - - if ( !$row->check() ) { - return $row->getError(); - } - if ( !$row->store() ) { - return $row->getError(); - } - - $cache = & JFactory::getCache('com_content'); - $cache->clean(); - - $mainframe->redirect( 'index.php?option=com_frontpage' ); -} - -function saveOrder( &$cid ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $total = count( $cid ); - $order = JRequest::getVar( 'order', array(0), 'post', 'array' ); - - for( $i=0; $i < $total; $i++ ) - { - $query = 'UPDATE #__content_frontpage' - . ' SET ordering = ' . (int) $order[$i] - . ' WHERE content_id = ' . (int) $cid[$i]; - $db->setQuery( $query ); - if (!$db->query()) { - JError::raiseError(500, $db->getErrorMsg() ); - } - } - - $cache = & JFactory::getCache('com_content'); - $cache->clean(); - - $msg = JText::_( 'New ordering saved' ); - $mainframe->redirect( 'index.php?option=com_frontpage', $msg ); +authorize( 'com_frontpage', 'manage' )) { + $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); +} + +// Set the table directory +JTable::addIncludePath(JPATH_COMPONENT.DS.DS.'tables'); + +// Set the helper directory +JHTML::addIncludePath( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_content'.DS.'helper' ); + +$cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); +JArrayHelper::toInteger($cid, array(0)); + +switch ( JRequest::getCmd( 'task' ) ) +{ + case 'publish': + changeFrontPage( $cid, 1, $option ); + break; + + case 'unpublish': + changeFrontPage( $cid, 0, $option ); + break; + + case 'archive': + changeFrontPage( $cid, -1, $option ); + break; + + case 'remove': + removeFrontPage( $cid, $option ); + break; + + case 'orderup': + orderFrontPage( $cid[0], -1, $option ); + break; + + case 'orderdown': + orderFrontPage( $cid[0], 1, $option ); + break; + + case 'saveorder': + saveOrder( $cid ); + break; + + case 'accesspublic': + accessMenu( $cid[0], 0 ); + break; + + case 'accessregistered': + accessMenu( $cid[0], 1 ); + break; + + case 'accessspecial': + accessMenu( $cid[0], 2 ); + break; + + default: + viewFrontPage( $option ); + break; +} + + +/** +* Compiles a list of frontpage items +*/ +function viewFrontPage( $option ) +{ + global $mainframe; + + $db =& JFactory::getDBO(); + $filter_order = $mainframe->getUserStateFromRequest( $option.'.filter_order', 'filter_order', 'fpordering', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'.filter_order_Dir', 'filter_order_Dir', '', 'word' ); + $filter_state = $mainframe->getUserStateFromRequest( $option.'.filter_state', 'filter_state', '', 'word' ); + $catid = $mainframe->getUserStateFromRequest( $option.'.catid', 'catid', 0, 'int' ); + $filter_authorid = $mainframe->getUserStateFromRequest( $option.'.filter_authorid', 'filter_authorid', 0, 'int' ); + $filter_sectionid = $mainframe->getUserStateFromRequest( $option.'.filter_sectionid', 'filter_sectionid', -1, 'int' ); + $search = $mainframe->getUserStateFromRequest( $option.'.search', 'search', '', 'string' ); + if (strpos($search, '"') !== false) { + $search = str_replace(array('=', '<'), '', $search); + } + $search = JString::strtolower($search); + + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); + + JToolBarHelper::title( JText::_( 'Frontpage Manager' ), 'frontpage.png' ); + JToolBarHelper::archiveList(); + JToolBarHelper::publishList(); + JToolBarHelper::unpublishList(); + JToolBarHelper::custom('remove','delete.png','delete_f2.png','Remove', true); + JToolBarHelper::help( 'screen.frontpage' ); + + $where = array( + "c.state >= 0" + ); + + // used by filter + if ( $filter_sectionid >= 0 ) { + $where[] = 'c.sectionid = '.(int) $filter_sectionid; + } + if ( $catid > 0 ) { + $where[] = 'c.catid = '.(int) $catid; + } + if ( $filter_authorid > 0 ) { + $where[] = 'c.created_by = '. (int) $filter_authorid; + } + if ( $filter_state ) { + if ( $filter_state == 'P' ) { + $where[] = 'c.state = 1'; + } else if ($filter_state == 'U' ) { + $where[] = 'c.state = 0'; + } + } + + if ($search) { + $where[] = 'LOWER( c.title ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + + $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); + $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', fpordering'; + + // get the total number of records + $query = 'SELECT count(*)' + . ' FROM #__content AS c' + . ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' + . ' LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope="content"' + . ' INNER JOIN #__content_frontpage AS f ON f.content_id = c.id' + . $where + ; + $db->setQuery( $query ); + $total = $db->loadResult(); + + jimport('joomla.html.pagination'); + $pageNav = new JPagination( $total, $limitstart, $limit ); + + $query = 'SELECT c.*, g.name AS groupname, cc.title as name, s.title AS sect_name, u.name AS editor, f.ordering AS fpordering, v.name AS author' + . ' FROM #__content AS c' + . ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' + . ' LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope="content"' + . ' INNER JOIN #__content_frontpage AS f ON f.content_id = c.id' + . ' INNER JOIN #__groups AS g ON g.id = c.access' + . ' LEFT JOIN #__users AS u ON u.id = c.checked_out' + . ' LEFT JOIN #__users AS v ON v.id = c.created_by' + . $where + . $orderby + ; + $db->setQuery( $query, $pageNav->limitstart,$pageNav->limit ); + $rows = $db->loadObjectList(); + if ($db->getErrorNum()) { + echo $db->stderr(); + return false; + } + + // get list of categories for dropdown filter + $query = 'SELECT cc.id AS value, cc.title AS text, section' + . ' FROM #__categories AS cc' + . ' INNER JOIN #__sections AS s ON s.id = cc.section ' + . ' ORDER BY s.ordering, cc.ordering' + ; + $db->setQuery( $query ); + $categories[] = JHTML::_('select.option', '-1', '- '. JText::_( 'Select Category' ) .' -' ); + $categories = array_merge( $categories, $db->loadObjectList() ); + $lists['catid'] = JHTML::_('select.genericlist', $categories, 'catid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $catid ); + + // get list of sections for dropdown filter + $javascript = 'onchange="document.adminForm.submit();"'; + $lists['sectionid'] = JHTML::_('list.section', 'filter_sectionid', $filter_sectionid, $javascript ); + + // get list of Authors for dropdown filter + $query = 'SELECT c.created_by, u.name' + . ' FROM #__content AS c' + . ' INNER JOIN #__sections AS s ON s.id = c.sectionid' + . ' LEFT JOIN #__users AS u ON u.id = c.created_by' + . ' WHERE c.state <> -1' + . ' AND c.state <> -2' + . ' GROUP BY u.name' + . ' ORDER BY u.name' + ; + $db->setQuery( $query ); + $authors[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select Author' ) .' -', 'created_by', 'name' ); + $authors = array_merge( $authors, $db->loadObjectList() ); + $lists['authorid'] = JHTML::_('select.genericlist', $authors, 'filter_authorid', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'created_by', 'name', $filter_authorid ); + + // state filter + $lists['state'] = JHTML::_('grid.state', $filter_state ); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search']= $search; + + require_once(JPATH_COMPONENT.DS.'views'.DS.'frontpage.php'); + FrontpageView::showList( $rows, $pageNav, $option, $lists ); +} + +/** +* Changes the state of one or more content pages +* @param array An array of unique category id numbers +* @param integer 0 if unpublishing, 1 if publishing +*/ +function changeFrontPage( $cid=null, $state=0, $option ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + + JArrayHelper::toInteger($cid); + + if (count( $cid ) < 1) { + $action = $state == 1 ? 'publish' : ($state == -1 ? 'archive' : 'unpublish'); + JError::raiseError(500, JText::_( 'Select an item to' .$action, true ) ); + } + + $cids = implode( ',', $cid ); + + $query = 'UPDATE #__content' + . ' SET state = '.(int) $state + . ' WHERE id IN ( '. $cids .' )' + . ' AND ( checked_out = 0 OR ( checked_out = ' .(int) $user->get('id'). ' ) )' + ; + $db->setQuery( $query ); + if (!$db->query()) { + JError::raiseError(500, $db->getErrorMsg() ); + } + + if (count( $cid ) == 1) { + $row =& JTable::getInstance('content'); + $row->checkin( $cid[0] ); + } + + $cache = & JFactory::getCache('com_content'); + $cache->clean(); + + $mainframe->redirect( 'index.php?option='.$option ); +} + +function removeFrontPage( &$cid, $option ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + if (!is_array( $cid ) || count( $cid ) < 1) { + JError::raiseError(500, JText::_( 'Select an item to delete', true ) ); + } + $fp =& JTable::getInstance('frontpage', 'Table'); + foreach ($cid as $id) { + if (!$fp->delete( $id )) { + JError::raiseError(500, $fp->getError() ); + } + $obj =& JTable::getInstance('content'); + $obj->load( $id ); + $obj->mask = 0; + if (!$obj->store()) { + JError::raiseError(500, $fp->getError() ); + } + } + $fp->reorder(); + + $cache = & JFactory::getCache('com_content'); + $cache->clean(); + + $mainframe->redirect( 'index.php?option='.$option ); +} + +/** +* Moves the order of a record +* @param integer The increment to reorder by +*/ +function orderFrontPage( $uid, $inc, $option ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + + $fp =& JTable::getInstance('frontpage','Table'); + $fp->load( $uid ); + $fp->move( $inc ); + + $cache = & JFactory::getCache('com_content'); + $cache->clean(); + + $mainframe->redirect( 'index.php?option='.$option ); +} + +/** +* @param integer The id of the article +* @param integer The new access level +* @param string The URL option +*/ +function accessMenu( $uid, $access ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db = & JFactory::getDBO(); + $row =& JTable::getInstance('content'); + $row->load( $uid ); + $row->access = $access; + + if ( !$row->check() ) { + return $row->getError(); + } + if ( !$row->store() ) { + return $row->getError(); + } + + $cache = & JFactory::getCache('com_content'); + $cache->clean(); + + $mainframe->redirect( 'index.php?option=com_frontpage' ); +} + +function saveOrder( &$cid ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $total = count( $cid ); + $order = JRequest::getVar( 'order', array(0), 'post', 'array' ); + + for( $i=0; $i < $total; $i++ ) + { + $query = 'UPDATE #__content_frontpage' + . ' SET ordering = ' . (int) $order[$i] + . ' WHERE content_id = ' . (int) $cid[$i]; + $db->setQuery( $query ); + if (!$db->query()) { + JError::raiseError(500, $db->getErrorMsg() ); + } + } + + $cache = & JFactory::getCache('com_content'); + $cache->clean(); + + $msg = JText::_( 'New ordering saved' ); + $mainframe->redirect( 'index.php?option=com_frontpage', $msg ); } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_frontpage/frontpage.xml b/oss/joomla/trunk/administrator/components/com_frontpage/frontpage.xml index 0274818b..e7aa9501 100644 --- a/oss/joomla/trunk/administrator/components/com_frontpage/frontpage.xml +++ b/oss/joomla/trunk/administrator/components/com_frontpage/frontpage.xml @@ -1,11 +1,11 @@ - - - Frontpage - Joomla! Project - (C) 2005 - 2008 Open Source Matters. All rights reserved. - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - admin@joomla.org - www.joomla.org - 1.5.0 - This Component shows all the published Articles from your site marked Show on Front Page. - + + + Frontpage + Joomla! Project + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + This Component shows all the published Articles from your site marked Show on Front Page. + diff --git a/oss/joomla/trunk/administrator/components/com_frontpage/tables/frontpage.php b/oss/joomla/trunk/administrator/components/com_frontpage/tables/frontpage.php index bf4e665e..91f0a3d2 100644 --- a/oss/joomla/trunk/administrator/components/com_frontpage/tables/frontpage.php +++ b/oss/joomla/trunk/administrator/components/com_frontpage/tables/frontpage.php @@ -1,35 +1,35 @@ -getNullDate(); - $config =& JFactory::getConfig(); - $now =& JFactory::getDate(); - - //Ordering allowed ? - $ordering = (($lists['order'] == 'fpordering')); - - JHTML::_('behavior.tooltip'); - ?> -
    - - - - - - -
    - : - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - id ); - - $publish_up =& JFactory::getDate($row->publish_up); - $publish_down =& JFactory::getDate($row->publish_down); - $publish_up->setOffset($config->getValue('config.offset')); - $publish_down->setOffset($config->getValue('config.offset')); - if ( $now->toUnix() <= $publish_up->toUnix() && $row->state == 1 ) { - $img = 'publish_y.png'; - $alt = JText::_( 'Published' ); - } else if ( ( $now->toUnix() <= $publish_down->toUnix() || $row->publish_down == $nullDate ) && $row->state == 1 ) { - $img = 'publish_g.png'; - $alt = JText::_( 'Published' ); - } else if ( $now->toUnix() > $publish_down->toUnix() && $row->state == 1 ) { - $img = 'publish_r.png'; - $alt = JText::_( 'Expired' ); - } else if ( $row->state == 0 ) { - $img = 'publish_x.png'; - $alt = JText::_( 'Unpublished' ); - } else if ( $row->state == -1 ) { - $img = 'disabled.png'; - $alt = JText::_( 'Archived' ); - } - $times = ''; - if (isset($row->publish_up)) { - if ($row->publish_up == $nullDate) { - $times .= JText::_( 'Start: Always' ); - } else { - $times .= JText::_( 'Start' ) .": ". $publish_up->toFormat(); - } - } - if (isset($row->publish_down)) { - if ($row->publish_down == $nullDate) { - $times .= "
    ". JText::_( 'Finish: No Expiry' ); - } else { - $times .= "
    ". JText::_( 'Finish' ) .": ". $publish_down->toFormat(); - } - } - - $access = JHTML::_('grid.access', $row, $i ); - $checked = JHTML::_('grid.checkedout', $row, $i ); - - if ( $user->authorize( 'com_users', 'manage' ) ) { - if ( $row->created_by_alias ) { - $author = $row->created_by_alias; - } else { - $linkA = JRoute::_( 'index.php?option=com_users&task=edit&cid[]='. $row->created_by ); - $author='' . - ''. $row->author .''; - } - } else { - if ( $row->created_by_alias ) { - $author = $row->created_by_alias; - } else { - $author = $row->author; - } - } - - // section handling - if ($row->sectionid) { - $row->sect_link = JRoute::_( 'index.php?option=com_sections&task=edit&cid[]='. $row->sectionid ); - $title_sec = JText::_( 'Edit Section' ); - } - - // category handling - if ($row->catid) { - $row->cat_link = JRoute::_( 'index.php?option=com_categories&task=edit&cid[]='. $row->catid ); - $title_cat = JText::_( 'Edit Category' ); - } - ?> - "> - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - -
    - getListFooter(); ?> -
    - getRowOffset( $i ); ?> - - - - get ('id'), $row->checked_out ) ) { - echo $row->title; - } else { - ?> - - - title; ?> - - - - - <?php echo $alt;?> - - orderUpIcon( $i, true, 'orderup', 'Move Up', $ordering ); ?> - orderDownIcon( $i, $n, true, 'orderdown', 'Move Down', $ordering ); ?> - - class="text_area" style="text-align: center" /> - - - - id;?> - - sectionid) : ?> - - - sect_name; ?> - - - catid) : ?> - - - name; ?> - - - -
    - - - - - - - - -
    - getNullDate(); + $config =& JFactory::getConfig(); + $now =& JFactory::getDate(); + + //Ordering allowed ? + $ordering = (($lists['order'] == 'fpordering')); + + JHTML::_('behavior.tooltip'); + ?> +
    + + + + + + +
    + : + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + id ); + + $publish_up =& JFactory::getDate($row->publish_up); + $publish_down =& JFactory::getDate($row->publish_down); + $publish_up->setOffset($config->getValue('config.offset')); + $publish_down->setOffset($config->getValue('config.offset')); + if ( $now->toUnix() <= $publish_up->toUnix() && $row->state == 1 ) { + $img = 'publish_y.png'; + $alt = JText::_( 'Published' ); + } else if ( ( $now->toUnix() <= $publish_down->toUnix() || $row->publish_down == $nullDate ) && $row->state == 1 ) { + $img = 'publish_g.png'; + $alt = JText::_( 'Published' ); + } else if ( $now->toUnix() > $publish_down->toUnix() && $row->state == 1 ) { + $img = 'publish_r.png'; + $alt = JText::_( 'Expired' ); + } else if ( $row->state == 0 ) { + $img = 'publish_x.png'; + $alt = JText::_( 'Unpublished' ); + } else if ( $row->state == -1 ) { + $img = 'disabled.png'; + $alt = JText::_( 'Archived' ); + } + $times = ''; + if (isset($row->publish_up)) { + if ($row->publish_up == $nullDate) { + $times .= JText::_( 'Start: Always' ); + } else { + $times .= JText::_( 'Start' ) .": ". $publish_up->toFormat(); + } + } + if (isset($row->publish_down)) { + if ($row->publish_down == $nullDate) { + $times .= "
    ". JText::_( 'Finish: No Expiry' ); + } else { + $times .= "
    ". JText::_( 'Finish' ) .": ". $publish_down->toFormat(); + } + } + + $access = JHTML::_('grid.access', $row, $i ); + $checked = JHTML::_('grid.checkedout', $row, $i ); + + if ( $user->authorize( 'com_users', 'manage' ) ) { + if ( $row->created_by_alias ) { + $author = $row->created_by_alias; + } else { + $linkA = JRoute::_( 'index.php?option=com_users&task=edit&cid[]='. $row->created_by ); + $author='' . + ''. $row->author .''; + } + } else { + if ( $row->created_by_alias ) { + $author = $row->created_by_alias; + } else { + $author = $row->author; + } + } + + // section handling + if ($row->sectionid) { + $row->sect_link = JRoute::_( 'index.php?option=com_sections&task=edit&cid[]='. $row->sectionid ); + $title_sec = JText::_( 'Edit Section' ); + } + + // category handling + if ($row->catid) { + $row->cat_link = JRoute::_( 'index.php?option=com_categories&task=edit&cid[]='. $row->catid ); + $title_cat = JText::_( 'Edit Category' ); + } + ?> + "> + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + +
    + getListFooter(); ?> +
    + getRowOffset( $i ); ?> + + + + get ('id'), $row->checked_out ) ) { + echo $row->title; + } else { + ?> + + + title; ?> + + + + + <?php echo $alt;?> + + orderUpIcon( $i, true, 'orderup', 'Move Up', $ordering ); ?> + orderDownIcon( $i, $n, true, 'orderdown', 'Move Down', $ordering ); ?> + + class="text_area" style="text-align: center" /> + + + + id;?> + + sectionid) : ?> + + + sect_name; ?> + + + catid) : ?> + + + name; ?> + + + +
    + + + + + + + + +
    + authorize('com_installer', 'installer')) { - $mainframe->redirect('index.php', JText::_('ALERTNOTAUTH')); -} - -$ext = JRequest::getWord('type'); - -$subMenus = array( - 'Components' => 'components', - 'Modules' => 'modules', - 'Plugins' => 'plugins', - 'Languages' => 'languages', - 'Templates' => 'templates'); - -JSubMenuHelper::addEntry(JText::_( 'Install' ), '#" onclick="javascript:document.adminForm.type.value=\'\';submitbutton(\'installer\');', !in_array( $ext, $subMenus)); -foreach ($subMenus as $name => $extension) { - JSubMenuHelper::addEntry(JText::_( $name ), '#" onclick="javascript:document.adminForm.type.value=\''.$extension.'\';submitbutton(\'manage\');', ($extension == $ext)); -} - -require_once( JPATH_COMPONENT.DS.'controller.php' ); - -$controller = new InstallerController( array('default_task' => 'installform') ); -//die(JRequest::getCmd('task')); -$controller->execute( JRequest::getCmd('task') ); -$controller->redirect(); +authorize('com_installer', 'installer')) { + $mainframe->redirect('index.php', JText::_('ALERTNOTAUTH')); +} + +$ext = JRequest::getWord('type'); + +$subMenus = array( + 'Components' => 'components', + 'Modules' => 'modules', + 'Plugins' => 'plugins', + 'Languages' => 'languages', + 'Templates' => 'templates'); + +JSubMenuHelper::addEntry(JText::_( 'Install' ), '#" onclick="javascript:document.adminForm.type.value=\'\';submitbutton(\'installer\');', !in_array( $ext, $subMenus)); +foreach ($subMenus as $name => $extension) { + JSubMenuHelper::addEntry(JText::_( $name ), '#" onclick="javascript:document.adminForm.type.value=\''.$extension.'\';submitbutton(\'manage\');', ($extension == $ext)); +} + +require_once( JPATH_COMPONENT.DS.'controller.php' ); + +$controller = new InstallerController( array('default_task' => 'installform') ); +//die(JRequest::getCmd('task')); +$controller->execute( JRequest::getCmd('task') ); +$controller->redirect(); diff --git a/oss/joomla/trunk/administrator/components/com_installer/controller.php b/oss/joomla/trunk/administrator/components/com_installer/controller.php index 266a90f8..e889c444 100644 --- a/oss/joomla/trunk/administrator/components/com_installer/controller.php +++ b/oss/joomla/trunk/administrator/components/com_installer/controller.php @@ -1,191 +1,191 @@ -getModel( 'Install' ); - $model->setState( 'install.directory', $mainframe->getCfg( 'config.tmp_path' )); - - $view = &$this->getView( 'Install'); - - $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); - $view->assignRef('ftp', $ftp); - - $view->setModel( $model, true ); - $view->display(); - } - - /** - * Install an extension - * - * @access public - * @return void - * @since 1.5 - */ - function doInstall() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $model = &$this->getModel( 'Install' ); - $view = &$this->getView( 'Install' ); - - $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); - $view->assignRef('ftp', $ftp); - - if ($model->install()) { - $cache = &JFactory::getCache('mod_menu'); - $cache->clean(); - } - - $view->setModel( $model, true ); - $view->display(); - } - - /** - * Manage an extension type (List extensions of a given type) - * - * @access public - * @return void - * @since 1.5 - */ - function manage() - { - $type = JRequest::getWord('type', 'components'); - $model = &$this->getModel( $type ); - $view = &$this->getView( $type ); - - $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); - $view->assignRef('ftp', $ftp); - - $view->setModel( $model, true ); - $view->display(); - } - - /** - * Enable an extension (If supported) - * - * @access public - * @return void - * @since 1.5 - */ - function enable() - { - // Check for request forgeries - JRequest::checkToken( 'request' ) or jexit( 'Invalid Token' ); - - $type = JRequest::getWord('type', 'components'); - $model = &$this->getModel( $type ); - $view = &$this->getView( $type ); - - $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); - $view->assignRef('ftp', $ftp); - - if (method_exists($model, 'enable')) { - $eid = JRequest::getVar('eid', array(), '', 'array'); - JArrayHelper::toInteger($eid, array()); - $model->enable($eid); - } - - $view->setModel( $model, true ); - $view->display(); - } - - /** - * Disable an extension (If supported) - * - * @access public - * @return void - * @since 1.5 - */ - function disable() - { - // Check for request forgeries - JRequest::checkToken( 'request' ) or jexit( 'Invalid Token' ); - - $type = JRequest::getWord('type', 'components'); - $model = &$this->getModel( $type ); - $view = &$this->getView( $type ); - - $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); - $view->assignRef('ftp', $ftp); - - if (method_exists($model, 'disable')) { - $eid = JRequest::getVar('eid', array(), '', 'array'); - JArrayHelper::toInteger($eid, array()); - $model->disable($eid); - } - - $view->setModel( $model, true ); - $view->display(); - } - - /** - * Remove an extension (Uninstall) - * - * @access public - * @return void - * @since 1.5 - */ - function remove() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $type = JRequest::getWord('type', 'components'); - $model = &$this->getModel( $type ); - $view = &$this->getView( $type ); - - $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); - $view->assignRef('ftp', $ftp); - - $eid = JRequest::getVar('eid', array(), '', 'array'); - - // Update to handle components radio box - // Checks there is only one extensions, we're uninstalling components - // and then checks that the zero numbered item is set (shouldn't be a zero - // if the eid is set to the proper format) - if((count($eid) == 1) && ($type == 'components') && (isset($eid[0]))) $eid = array($eid[0] => 0); - - JArrayHelper::toInteger($eid, array()); - $result = $model->remove($eid); - - $view->setModel( $model, true ); - $view->display(); - } +getModel( 'Install' ); + $model->setState( 'install.directory', $mainframe->getCfg( 'config.tmp_path' )); + + $view = &$this->getView( 'Install'); + + $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); + $view->assignRef('ftp', $ftp); + + $view->setModel( $model, true ); + $view->display(); + } + + /** + * Install an extension + * + * @access public + * @return void + * @since 1.5 + */ + function doInstall() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $model = &$this->getModel( 'Install' ); + $view = &$this->getView( 'Install' ); + + $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); + $view->assignRef('ftp', $ftp); + + if ($model->install()) { + $cache = &JFactory::getCache('mod_menu'); + $cache->clean(); + } + + $view->setModel( $model, true ); + $view->display(); + } + + /** + * Manage an extension type (List extensions of a given type) + * + * @access public + * @return void + * @since 1.5 + */ + function manage() + { + $type = JRequest::getWord('type', 'components'); + $model = &$this->getModel( $type ); + $view = &$this->getView( $type ); + + $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); + $view->assignRef('ftp', $ftp); + + $view->setModel( $model, true ); + $view->display(); + } + + /** + * Enable an extension (If supported) + * + * @access public + * @return void + * @since 1.5 + */ + function enable() + { + // Check for request forgeries + JRequest::checkToken( 'request' ) or jexit( 'Invalid Token' ); + + $type = JRequest::getWord('type', 'components'); + $model = &$this->getModel( $type ); + $view = &$this->getView( $type ); + + $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); + $view->assignRef('ftp', $ftp); + + if (method_exists($model, 'enable')) { + $eid = JRequest::getVar('eid', array(), '', 'array'); + JArrayHelper::toInteger($eid, array()); + $model->enable($eid); + } + + $view->setModel( $model, true ); + $view->display(); + } + + /** + * Disable an extension (If supported) + * + * @access public + * @return void + * @since 1.5 + */ + function disable() + { + // Check for request forgeries + JRequest::checkToken( 'request' ) or jexit( 'Invalid Token' ); + + $type = JRequest::getWord('type', 'components'); + $model = &$this->getModel( $type ); + $view = &$this->getView( $type ); + + $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); + $view->assignRef('ftp', $ftp); + + if (method_exists($model, 'disable')) { + $eid = JRequest::getVar('eid', array(), '', 'array'); + JArrayHelper::toInteger($eid, array()); + $model->disable($eid); + } + + $view->setModel( $model, true ); + $view->display(); + } + + /** + * Remove an extension (Uninstall) + * + * @access public + * @return void + * @since 1.5 + */ + function remove() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $type = JRequest::getWord('type', 'components'); + $model = &$this->getModel( $type ); + $view = &$this->getView( $type ); + + $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); + $view->assignRef('ftp', $ftp); + + $eid = JRequest::getVar('eid', array(), '', 'array'); + + // Update to handle components radio box + // Checks there is only one extensions, we're uninstalling components + // and then checks that the zero numbered item is set (shouldn't be a zero + // if the eid is set to the proper format) + if((count($eid) == 1) && ($type == 'components') && (isset($eid[0]))) $eid = array($eid[0] => 0); + + JArrayHelper::toInteger($eid, array()); + $result = $model->remove($eid); + + $view->setModel( $model, true ); + $view->display(); + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_installer/helper.php b/oss/joomla/trunk/administrator/components/com_installer/helper.php index 457ab5d9..042d186d 100644 --- a/oss/joomla/trunk/administrator/components/com_installer/helper.php +++ b/oss/joomla/trunk/administrator/components/com_installer/helper.php @@ -1,37 +1,37 @@ -'.JText::_( 'Writable' ).'' - : ''.JText::_( 'Unwritable' ).''; - } +'.JText::_( 'Writable' ).'' + : ''.JText::_( 'Unwritable' ).''; + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_installer/installer.xml b/oss/joomla/trunk/administrator/components/com_installer/installer.xml index f21951d7..2ce38bb5 100644 --- a/oss/joomla/trunk/administrator/components/com_installer/installer.xml +++ b/oss/joomla/trunk/administrator/components/com_installer/installer.xml @@ -1,12 +1,12 @@ - - - Installation Manager - Joomla! Project - 2006 - Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - admin@joomla.org - www.joomla.org - 1.5.0 - Installation Manager - + + + Installation Manager + Joomla! Project + 2006 + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + Installation Manager + diff --git a/oss/joomla/trunk/administrator/components/com_installer/models/components.php b/oss/joomla/trunk/administrator/components/com_installer/models/components.php index 0f7ab13f..8c13cf74 100644 --- a/oss/joomla/trunk/administrator/components/com_installer/models/components.php +++ b/oss/joomla/trunk/administrator/components/com_installer/models/components.php @@ -1,173 +1,173 @@ -_type); - - // Enable the extension in the table and store it in the database - foreach ($eid as $id) - { - $table->load($id); - $table->enabled = '1'; - $result |= $table->store(); - } - - return $result; - } - - /** - * Disable a component - * - * @return boolean True on success - * @since 1.5 - */ - function disable($eid=array()) - { - // Initialize variables - $result = false; - - /* - * Ensure eid is an array of extension ids - * TODO: If it isn't an array do we want to set an error and fail? - */ - if (!is_array($eid)) { - $eid = array ($eid); - } - - // Get a database connector - $db =& JFactory::getDBO(); - - // Get a table object for the extension type - $table = & JTable::getInstance($this->_type); - - // Disable the extension in the table and store it in the database - foreach ($eid as $id) - { - $table->load($id); - $table->enabled = '0'; - $result |= $table->store(); - } - - return $result; - } - - function _loadItems() - { - global $mainframe, $option; - - jimport('joomla.filesystem.folder'); - - /* Get a database connector */ - $db =& JFactory::getDBO(); - - $query = 'SELECT *' . - ' FROM #__components' . - ' WHERE parent = 0' . - ' ORDER BY iscore, name'; - $db->setQuery($query); - $rows = $db->loadObjectList(); - - /* Get the component base directory */ - $adminDir = JPATH_ADMINISTRATOR .DS. 'components'; - $siteDir = JPATH_SITE .DS. 'components'; - - $numRows = count($rows); - for($i=0;$i < $numRows; $i++) - { - $row =& $rows[$i]; - - /* Get the component folder and list of xml files in folder */ - $folder = $adminDir.DS.$row->option; - if (JFolder::exists($folder)) { - $xmlFilesInDir = JFolder::files($folder, '.xml$'); - } else { - $folder = $siteDir.DS.$row->option; - if (JFolder::exists($folder)) { - $xmlFilesInDir = JFolder::files($folder, '.xml$'); - } else { - $xmlFilesInDir = null; - } - } - - if (count($xmlFilesInDir)) - { - foreach ($xmlFilesInDir as $xmlfile) - { - if ($data = JApplicationHelper::parseXMLInstallFile($folder.DS.$xmlfile)) { - foreach($data as $key => $value) { - $row->$key = $value; - } - } - $row->jname = JString::strtolower(str_replace(" ", "_", $row->name)); - } - } - } - $this->setState('pagination.total', $numRows); - - // if the offset is greater than the total, then can the offset - if($this->_state->get('pagination.offset') > $this->_state->get('pagination.total')) { - $this->setState('pagination.offset',0); - } - - if($this->_state->get('pagination.limit') > 0) { - $this->_items = array_slice( $rows, $this->_state->get('pagination.offset'), $this->_state->get('pagination.limit') ); - } else { - $this->_items = $rows; - } - } +_type); + + // Enable the extension in the table and store it in the database + foreach ($eid as $id) + { + $table->load($id); + $table->enabled = '1'; + $result |= $table->store(); + } + + return $result; + } + + /** + * Disable a component + * + * @return boolean True on success + * @since 1.5 + */ + function disable($eid=array()) + { + // Initialize variables + $result = false; + + /* + * Ensure eid is an array of extension ids + * TODO: If it isn't an array do we want to set an error and fail? + */ + if (!is_array($eid)) { + $eid = array ($eid); + } + + // Get a database connector + $db =& JFactory::getDBO(); + + // Get a table object for the extension type + $table = & JTable::getInstance($this->_type); + + // Disable the extension in the table and store it in the database + foreach ($eid as $id) + { + $table->load($id); + $table->enabled = '0'; + $result |= $table->store(); + } + + return $result; + } + + function _loadItems() + { + global $mainframe, $option; + + jimport('joomla.filesystem.folder'); + + /* Get a database connector */ + $db =& JFactory::getDBO(); + + $query = 'SELECT *' . + ' FROM #__components' . + ' WHERE parent = 0' . + ' ORDER BY iscore, name'; + $db->setQuery($query); + $rows = $db->loadObjectList(); + + /* Get the component base directory */ + $adminDir = JPATH_ADMINISTRATOR .DS. 'components'; + $siteDir = JPATH_SITE .DS. 'components'; + + $numRows = count($rows); + for($i=0;$i < $numRows; $i++) + { + $row =& $rows[$i]; + + /* Get the component folder and list of xml files in folder */ + $folder = $adminDir.DS.$row->option; + if (JFolder::exists($folder)) { + $xmlFilesInDir = JFolder::files($folder, '.xml$'); + } else { + $folder = $siteDir.DS.$row->option; + if (JFolder::exists($folder)) { + $xmlFilesInDir = JFolder::files($folder, '.xml$'); + } else { + $xmlFilesInDir = null; + } + } + + if (count($xmlFilesInDir)) + { + foreach ($xmlFilesInDir as $xmlfile) + { + if ($data = JApplicationHelper::parseXMLInstallFile($folder.DS.$xmlfile)) { + foreach($data as $key => $value) { + $row->$key = $value; + } + } + $row->jname = JString::strtolower(str_replace(" ", "_", $row->name)); + } + } + } + $this->setState('pagination.total', $numRows); + + // if the offset is greater than the total, then can the offset + if($this->_state->get('pagination.offset') > $this->_state->get('pagination.total')) { + $this->setState('pagination.offset',0); + } + + if($this->_state->get('pagination.limit') > 0) { + $this->_items = array_slice( $rows, $this->_state->get('pagination.offset'), $this->_state->get('pagination.limit') ); + } else { + $this->_items = $rows; + } + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_installer/models/extension.php b/oss/joomla/trunk/administrator/components/com_installer/models/extension.php index 1da0df63..da42c9bd 100644 --- a/oss/joomla/trunk/administrator/components/com_installer/models/extension.php +++ b/oss/joomla/trunk/administrator/components/com_installer/models/extension.php @@ -1,142 +1,142 @@ -setState('pagination.limit', $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int')); - $this->setState('pagination.offset',$mainframe->getUserStateFromRequest('com_installer.limitstart.'.$this->_type, 'limitstart', 0, 'int')); - $this->setState('pagination.total', 0); - } - - function &getItems() - { - if (empty($this->_items)) { - // Load the items - $this->_loadItems(); - } - return $this->_items; - } - - function &getPagination() - { - if (empty($this->_pagination)) { - // Make sure items are loaded for a proper total - if (empty($this->_items)) { - // Load the items - $this->_loadItems(); - } - // Load the pagination object - jimport('joomla.html.pagination'); - $this->_pagination = new JPagination($this->_state->get('pagination.total'), $this->_state->get('pagination.offset'), $this->_state->get('pagination.limit')); - } - return $this->_pagination; - } - - /** - * Remove (uninstall) an extension - * - * @static - * @param array An array of identifiers - * @return boolean True on success - * @since 1.0 - */ - function remove($eid=array()) - { - global $mainframe; - - // Initialize variables - $failed = array (); - - /* - * Ensure eid is an array of extension ids in the form id => client_id - * TODO: If it isn't an array do we want to set an error and fail? - */ - if (!is_array($eid)) { - $eid = array($eid => 0); - } - - // Get a database connector - $db =& JFactory::getDBO(); - - // Get an installer object for the extension type - jimport('joomla.installer.installer'); - $installer = & JInstaller::getInstance(); - - // Uninstall the chosen extensions - foreach ($eid as $id => $clientId) - { - $id = trim( $id ); - $result = $installer->uninstall($this->_type, $id, $clientId ); - - // Build an array of extensions that failed to uninstall - if ($result === false) { - $failed[] = $id; - } - } - - if (count($failed)) { - // There was an error in uninstalling the package - $msg = JText::sprintf('UNINSTALLEXT', JText::_($this->_type), JText::_('Error')); - $result = false; - } else { - // Package uninstalled sucessfully - $msg = JText::sprintf('UNINSTALLEXT', JText::_($this->_type), JText::_('Success')); - $result = true; - } - - $mainframe->enqueueMessage($msg); - $this->setState('action', 'remove'); - $this->setState('name', $installer->get('name')); - $this->setState('message', $installer->message); - $this->setState('extension.message', $installer->get('extension.message')); - - return $result; - } - - function _loadItems() - { - return JError::raiseError( 500, JText::_('Method Not Implemented')); - } +setState('pagination.limit', $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int')); + $this->setState('pagination.offset',$mainframe->getUserStateFromRequest('com_installer.limitstart.'.$this->_type, 'limitstart', 0, 'int')); + $this->setState('pagination.total', 0); + } + + function &getItems() + { + if (empty($this->_items)) { + // Load the items + $this->_loadItems(); + } + return $this->_items; + } + + function &getPagination() + { + if (empty($this->_pagination)) { + // Make sure items are loaded for a proper total + if (empty($this->_items)) { + // Load the items + $this->_loadItems(); + } + // Load the pagination object + jimport('joomla.html.pagination'); + $this->_pagination = new JPagination($this->_state->get('pagination.total'), $this->_state->get('pagination.offset'), $this->_state->get('pagination.limit')); + } + return $this->_pagination; + } + + /** + * Remove (uninstall) an extension + * + * @static + * @param array An array of identifiers + * @return boolean True on success + * @since 1.0 + */ + function remove($eid=array()) + { + global $mainframe; + + // Initialize variables + $failed = array (); + + /* + * Ensure eid is an array of extension ids in the form id => client_id + * TODO: If it isn't an array do we want to set an error and fail? + */ + if (!is_array($eid)) { + $eid = array($eid => 0); + } + + // Get a database connector + $db =& JFactory::getDBO(); + + // Get an installer object for the extension type + jimport('joomla.installer.installer'); + $installer = & JInstaller::getInstance(); + + // Uninstall the chosen extensions + foreach ($eid as $id => $clientId) + { + $id = trim( $id ); + $result = $installer->uninstall($this->_type, $id, $clientId ); + + // Build an array of extensions that failed to uninstall + if ($result === false) { + $failed[] = $id; + } + } + + if (count($failed)) { + // There was an error in uninstalling the package + $msg = JText::sprintf('UNINSTALLEXT', JText::_($this->_type), JText::_('Error')); + $result = false; + } else { + // Package uninstalled sucessfully + $msg = JText::sprintf('UNINSTALLEXT', JText::_($this->_type), JText::_('Success')); + $result = true; + } + + $mainframe->enqueueMessage($msg); + $this->setState('action', 'remove'); + $this->setState('name', $installer->get('name')); + $this->setState('message', $installer->message); + $this->setState('extension.message', $installer->get('extension.message')); + + return $result; + } + + function _loadItems() + { + return JError::raiseError( 500, JText::_('Method Not Implemented')); + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_installer/models/install.php b/oss/joomla/trunk/administrator/components/com_installer/models/install.php index 41f65bb7..0004e5fb 100644 --- a/oss/joomla/trunk/administrator/components/com_installer/models/install.php +++ b/oss/joomla/trunk/administrator/components/com_installer/models/install.php @@ -1,236 +1,236 @@ -setState('action', 'install'); - - switch(JRequest::getWord('installtype')) - { - case 'folder': - $package = $this->_getPackageFromFolder(); - break; - - case 'upload': - $package = $this->_getPackageFromUpload(); - break; - - case 'url': - $package = $this->_getPackageFromUrl(); - break; - - default: - $this->setState('message', 'No Install Type Found'); - return false; - break; - } - - // Was the package unpacked? - if (!$package) { - $this->setState('message', 'Unable to find install package'); - return false; - } - - // Get a database connector - //$db = & JFactory::getDBO(); - - // Get an installer instance - $installer =& JInstaller::getInstance(); - - // Install the package - if (!$installer->install($package['dir'])) { - // There was an error installing the package - $msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Error')); - $result = false; - } else { - // Package installed sucessfully - $msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Success')); - $result = true; - } - - // Set some model state values - $mainframe->enqueueMessage($msg); - $this->setState('name', $installer->get('name')); - $this->setState('result', $result); - $this->setState('message', $installer->message); - $this->setState('extension.message', $installer->get('extension.message')); - - // Cleanup the install files - if (!is_file($package['packagefile'])) { - $config =& JFactory::getConfig(); - $package['packagefile'] = $config->getValue('config.tmp_path').DS.$package['packagefile']; - } - - JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']); - - return $result; - } - - /** - * @param string The class name for the installer - */ - function _getPackageFromUpload() - { - // Get the uploaded file information - $userfile = JRequest::getVar('install_package', null, 'files', 'array' ); - - // Make sure that file uploads are enabled in php - if (!(bool) ini_get('file_uploads')) { - JError::raiseWarning('SOME_ERROR_CODE', JText::_('WARNINSTALLFILE')); - return false; - } - - // Make sure that zlib is loaded so that the package can be unpacked - if (!extension_loaded('zlib')) { - JError::raiseWarning('SOME_ERROR_CODE', JText::_('WARNINSTALLZLIB')); - return false; - } - - // If there is no uploaded file, we have a problem... - if (!is_array($userfile) ) { - JError::raiseWarning('SOME_ERROR_CODE', JText::_('No file selected')); - return false; - } - - // Check if there was a problem uploading the file. - if ( $userfile['error'] || $userfile['size'] < 1 ) - { - JError::raiseWarning('SOME_ERROR_CODE', JText::_('WARNINSTALLUPLOADERROR')); - return false; - } - - // Build the appropriate paths - $config =& JFactory::getConfig(); - $tmp_dest = $config->getValue('config.tmp_path').DS.$userfile['name']; - $tmp_src = $userfile['tmp_name']; - - // Move uploaded file - jimport('joomla.filesystem.file'); - $uploaded = JFile::upload($tmp_src, $tmp_dest); - - // Unpack the downloaded package file - $package = JInstallerHelper::unpack($tmp_dest); - - return $package; - } - - /** - * Install an extension from a directory - * - * @static - * @return boolean True on success - * @since 1.0 - */ - function _getPackageFromFolder() - { - // Get the path to the package to install - $p_dir = JRequest::getString('install_directory'); - $p_dir = JPath::clean( $p_dir ); - - // Did you give us a valid directory? - if (!is_dir($p_dir)) { - JError::raiseWarning('SOME_ERROR_CODE', JText::_('Please enter a package directory')); - return false; - } - - // Detect the package type - $type = JInstallerHelper::detectType($p_dir); - - // Did you give us a valid package? - if (!$type) { - JError::raiseWarning('SOME_ERROR_CODE', JText::_('Path does not have a valid package')); - return false; - } - - $package['packagefile'] = null; - $package['extractdir'] = null; - $package['dir'] = $p_dir; - $package['type'] = $type; - - return $package; - } - - /** - * Install an extension from a URL - * - * @static - * @return boolean True on success - * @since 1.5 - */ - function _getPackageFromUrl() - { - // Get a database connector - $db = & JFactory::getDBO(); - - // Get the URL of the package to install - $url = JRequest::getString('install_url'); - - // Did you give us a URL? - if (!$url) { - JError::raiseWarning('SOME_ERROR_CODE', JText::_('Please enter a URL')); - return false; - } - - // Download the package at the URL given - $p_file = JInstallerHelper::downloadPackage($url); - - // Was the package downloaded? - if (!$p_file) { - JError::raiseWarning('SOME_ERROR_CODE', JText::_('Invalid URL')); - return false; - } - - $config =& JFactory::getConfig(); - $tmp_dest = $config->getValue('config.tmp_path'); - - // Unpack the downloaded package file - $package = JInstallerHelper::unpack($tmp_dest.DS.$p_file); - - return $package; - } +setState('action', 'install'); + + switch(JRequest::getWord('installtype')) + { + case 'folder': + $package = $this->_getPackageFromFolder(); + break; + + case 'upload': + $package = $this->_getPackageFromUpload(); + break; + + case 'url': + $package = $this->_getPackageFromUrl(); + break; + + default: + $this->setState('message', 'No Install Type Found'); + return false; + break; + } + + // Was the package unpacked? + if (!$package) { + $this->setState('message', 'Unable to find install package'); + return false; + } + + // Get a database connector + //$db = & JFactory::getDBO(); + + // Get an installer instance + $installer =& JInstaller::getInstance(); + + // Install the package + if (!$installer->install($package['dir'])) { + // There was an error installing the package + $msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Error')); + $result = false; + } else { + // Package installed sucessfully + $msg = JText::sprintf('INSTALLEXT', JText::_($package['type']), JText::_('Success')); + $result = true; + } + + // Set some model state values + $mainframe->enqueueMessage($msg); + $this->setState('name', $installer->get('name')); + $this->setState('result', $result); + $this->setState('message', $installer->message); + $this->setState('extension.message', $installer->get('extension.message')); + + // Cleanup the install files + if (!is_file($package['packagefile'])) { + $config =& JFactory::getConfig(); + $package['packagefile'] = $config->getValue('config.tmp_path').DS.$package['packagefile']; + } + + JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']); + + return $result; + } + + /** + * @param string The class name for the installer + */ + function _getPackageFromUpload() + { + // Get the uploaded file information + $userfile = JRequest::getVar('install_package', null, 'files', 'array' ); + + // Make sure that file uploads are enabled in php + if (!(bool) ini_get('file_uploads')) { + JError::raiseWarning('SOME_ERROR_CODE', JText::_('WARNINSTALLFILE')); + return false; + } + + // Make sure that zlib is loaded so that the package can be unpacked + if (!extension_loaded('zlib')) { + JError::raiseWarning('SOME_ERROR_CODE', JText::_('WARNINSTALLZLIB')); + return false; + } + + // If there is no uploaded file, we have a problem... + if (!is_array($userfile) ) { + JError::raiseWarning('SOME_ERROR_CODE', JText::_('No file selected')); + return false; + } + + // Check if there was a problem uploading the file. + if ( $userfile['error'] || $userfile['size'] < 1 ) + { + JError::raiseWarning('SOME_ERROR_CODE', JText::_('WARNINSTALLUPLOADERROR')); + return false; + } + + // Build the appropriate paths + $config =& JFactory::getConfig(); + $tmp_dest = $config->getValue('config.tmp_path').DS.$userfile['name']; + $tmp_src = $userfile['tmp_name']; + + // Move uploaded file + jimport('joomla.filesystem.file'); + $uploaded = JFile::upload($tmp_src, $tmp_dest); + + // Unpack the downloaded package file + $package = JInstallerHelper::unpack($tmp_dest); + + return $package; + } + + /** + * Install an extension from a directory + * + * @static + * @return boolean True on success + * @since 1.0 + */ + function _getPackageFromFolder() + { + // Get the path to the package to install + $p_dir = JRequest::getString('install_directory'); + $p_dir = JPath::clean( $p_dir ); + + // Did you give us a valid directory? + if (!is_dir($p_dir)) { + JError::raiseWarning('SOME_ERROR_CODE', JText::_('Please enter a package directory')); + return false; + } + + // Detect the package type + $type = JInstallerHelper::detectType($p_dir); + + // Did you give us a valid package? + if (!$type) { + JError::raiseWarning('SOME_ERROR_CODE', JText::_('Path does not have a valid package')); + return false; + } + + $package['packagefile'] = null; + $package['extractdir'] = null; + $package['dir'] = $p_dir; + $package['type'] = $type; + + return $package; + } + + /** + * Install an extension from a URL + * + * @static + * @return boolean True on success + * @since 1.5 + */ + function _getPackageFromUrl() + { + // Get a database connector + $db = & JFactory::getDBO(); + + // Get the URL of the package to install + $url = JRequest::getString('install_url'); + + // Did you give us a URL? + if (!$url) { + JError::raiseWarning('SOME_ERROR_CODE', JText::_('Please enter a URL')); + return false; + } + + // Download the package at the URL given + $p_file = JInstallerHelper::downloadPackage($url); + + // Was the package downloaded? + if (!$p_file) { + JError::raiseWarning('SOME_ERROR_CODE', JText::_('Invalid URL')); + return false; + } + + $config =& JFactory::getConfig(); + $tmp_dest = $config->getValue('config.tmp_path'); + + // Unpack the downloaded package file + $package = JInstallerHelper::unpack($tmp_dest.DS.$p_file); + + return $package; + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_installer/models/languages.php b/oss/joomla/trunk/administrator/components/com_installer/models/languages.php index 6cdb9294..dd5a242c 100644 --- a/oss/joomla/trunk/administrator/components/com_installer/models/languages.php +++ b/oss/joomla/trunk/administrator/components/com_installer/models/languages.php @@ -1,239 +1,239 @@ -setState('filter.string', $mainframe->getUserStateFromRequest( "com_installer.languages.string", 'filter', '', 'string' )); - $this->setState('filter.client', $mainframe->getUserStateFromRequest( "com_installer.languages.client", 'client', -1, 'int' )); - } - - function _loadItems() - { - global $mainframe, $option; - - $db = &JFactory::getDBO(); - - if ($this->_state->get('filter.client') < 0) { - $client = 'all'; - // Get the site languages - $langBDir = JLanguage::getLanguagePath(JPATH_SITE); - $langDirs = JFolder::folders($langBDir); - - for ($i=0; $i < count($langDirs); $i++) - { - $lang = new stdClass(); - $lang->folder = $langDirs[$i]; - $lang->client = 0; - $lang->baseDir = $langBDir; - $languages[] = $lang; - } - // Get the admin languages - $langBDir = JLanguage::getLanguagePath(JPATH_ADMINISTRATOR); - $langDirs = JFolder::folders($langBDir); - - for ($i=0; $i < count($langDirs); $i++) - { - $lang = new stdClass(); - $lang->folder = $langDirs[$i]; - $lang->client = 1; - $lang->baseDir = $langBDir; - $languages[] = $lang; - } - } - else - { - $clientInfo =& JApplicationHelper::getClientInfo($this->_state->get('filter.client')); - $client = $clientInfo->name; - $langBDir = JLanguage::getLanguagePath($clientInfo->path); - $langDirs = JFolder::folders($langBDir); - - for ($i=0, $n=count($langDirs); $i < $n; $i++) - { - $lang = new stdClass(); - $lang->folder = $langDirs[$i]; - $lang->client = $clientInfo->id; - $lang->baseDir = $langBDir; - - if ($this->_state->get('filter.string')) { - if (strpos($lang->folder, $this->_state->get('filter.string')) !== false) { - $languages[] = $lang; - } - } else { - $languages[] = $lang; - } - } - } - - $rows = array(); - $rowid = 0; - foreach ($languages as $language) - { - $files = JFolder::files( $language->baseDir.DS.$language->folder, '^([-_A-Za-z]*)\.xml$' ); - foreach ($files as $file) - { - $data = JApplicationHelper::parseXMLLangMetaFile($language->baseDir.DS.$language->folder.DS.$file); - - $row = new StdClass(); - $row->id = $rowid; - $row->client_id = $language->client; - $row->language = $language->baseDir.DS.$language->folder; - - // If we didn't get valid data from the xml file, move on... - if (!is_array($data)) { - continue; - } - - // Populate the row from the xml meta file - foreach($data as $key => $value) { - $row->$key = $value; - } - - // if current than set published - $clientVals =& JApplicationHelper::getClientInfo($row->client_id); - $lang = JComponentHelper::getParams('com_languages'); - if ( $lang->get($clientVals->name, 'en-GB') == basename( $row->language ) ) { - $row->published = 1; - } else { - $row->published = 0; - } - - $row->checked_out = 0; - $row->jname = JString::strtolower( str_replace( " ", "_", $row->name ) ); - $rows[] = $row; - $rowid++; - } - } - $this->setState('pagination.total', count($rows)); - // if the offset is greater than the total, then can the offset - if($this->_state->get('pagination.offset') > $this->_state->get('pagination.total')) { - $this->setState('pagination.offset',0); - } - - if($this->_state->get('pagination.limit') > 0) { - $this->_items = array_slice( $rows, $this->_state->get('pagination.offset'), $this->_state->get('pagination.limit') ); - } else { - $this->_items = $rows; - } - } - - /** - * Remove (uninstall) an extension - * - * @static - * @return boolean True on success - * @since 1.0 - */ - function remove($eid=array()) - { - global $mainframe; - - $lang =& JFactory::getLanguage(); - $lang->load('com_installer'); - - // Initialize variables - $failed = array (); - - /* - * Ensure eid is an array of extension ids - * TODO: If it isn't an array do we want to set an error and fail? - */ - if (!is_array($eid)) { - $eid = array ($eid); - } - // construct the list of all language - $this->_loadItems(); - - // Get a database connector - $db =& JFactory::getDBO(); - - // Get an installer object for the extension type - jimport('joomla.installer.installer'); - $installer =& JInstaller::getInstance($db, $this->_type); - - // Uninstall the chosen extensions - foreach ($eid as $id) - { - $item = $this->_items[$id]; - - // Get client information - $client =& JApplicationHelper::getClientInfo($item->client_id); - - // Don't delete a default ( published language ) - $params = JComponentHelper::getParams('com_languages'); - $tag = basename($item->language); - if ( $params->get($client->name, 'en-GB') == $tag ) { - $failed[] = $id; - JError::raiseWarning('', JText::_('UNINSTALLLANGPUBLISHEDALREADY')); - return; - } - - $result = $installer->uninstall( 'language', $item->language ); - - // Build an array of extensions that failed to uninstall - if ($result === false) { - $failed[] = $id; - } - } - - if (count($failed)) { - // There was an error in uninstalling the package - $msg = JText::sprintf('UNINSTALLEXT', JText::_($this->_type), JText::_('Error')); - $result = false; - } else { - // Package uninstalled sucessfully - $msg = JText::sprintf('UNINSTALLEXT', JText::_($this->_type), JText::_('Success')); - $result = true; - } - - $mainframe->enqueueMessage($msg); - $this->setState('action', 'remove'); - $this->setState('message', $installer->message); - // re-construct the list of all language - $this->_loadItems(); - - return $result; - } +setState('filter.string', $mainframe->getUserStateFromRequest( "com_installer.languages.string", 'filter', '', 'string' )); + $this->setState('filter.client', $mainframe->getUserStateFromRequest( "com_installer.languages.client", 'client', -1, 'int' )); + } + + function _loadItems() + { + global $mainframe, $option; + + $db = &JFactory::getDBO(); + + if ($this->_state->get('filter.client') < 0) { + $client = 'all'; + // Get the site languages + $langBDir = JLanguage::getLanguagePath(JPATH_SITE); + $langDirs = JFolder::folders($langBDir); + + for ($i=0; $i < count($langDirs); $i++) + { + $lang = new stdClass(); + $lang->folder = $langDirs[$i]; + $lang->client = 0; + $lang->baseDir = $langBDir; + $languages[] = $lang; + } + // Get the admin languages + $langBDir = JLanguage::getLanguagePath(JPATH_ADMINISTRATOR); + $langDirs = JFolder::folders($langBDir); + + for ($i=0; $i < count($langDirs); $i++) + { + $lang = new stdClass(); + $lang->folder = $langDirs[$i]; + $lang->client = 1; + $lang->baseDir = $langBDir; + $languages[] = $lang; + } + } + else + { + $clientInfo =& JApplicationHelper::getClientInfo($this->_state->get('filter.client')); + $client = $clientInfo->name; + $langBDir = JLanguage::getLanguagePath($clientInfo->path); + $langDirs = JFolder::folders($langBDir); + + for ($i=0, $n=count($langDirs); $i < $n; $i++) + { + $lang = new stdClass(); + $lang->folder = $langDirs[$i]; + $lang->client = $clientInfo->id; + $lang->baseDir = $langBDir; + + if ($this->_state->get('filter.string')) { + if (strpos($lang->folder, $this->_state->get('filter.string')) !== false) { + $languages[] = $lang; + } + } else { + $languages[] = $lang; + } + } + } + + $rows = array(); + $rowid = 0; + foreach ($languages as $language) + { + $files = JFolder::files( $language->baseDir.DS.$language->folder, '^([-_A-Za-z]*)\.xml$' ); + foreach ($files as $file) + { + $data = JApplicationHelper::parseXMLLangMetaFile($language->baseDir.DS.$language->folder.DS.$file); + + $row = new StdClass(); + $row->id = $rowid; + $row->client_id = $language->client; + $row->language = $language->baseDir.DS.$language->folder; + + // If we didn't get valid data from the xml file, move on... + if (!is_array($data)) { + continue; + } + + // Populate the row from the xml meta file + foreach($data as $key => $value) { + $row->$key = $value; + } + + // if current than set published + $clientVals =& JApplicationHelper::getClientInfo($row->client_id); + $lang = JComponentHelper::getParams('com_languages'); + if ( $lang->get($clientVals->name, 'en-GB') == basename( $row->language ) ) { + $row->published = 1; + } else { + $row->published = 0; + } + + $row->checked_out = 0; + $row->jname = JString::strtolower( str_replace( " ", "_", $row->name ) ); + $rows[] = $row; + $rowid++; + } + } + $this->setState('pagination.total', count($rows)); + // if the offset is greater than the total, then can the offset + if($this->_state->get('pagination.offset') > $this->_state->get('pagination.total')) { + $this->setState('pagination.offset',0); + } + + if($this->_state->get('pagination.limit') > 0) { + $this->_items = array_slice( $rows, $this->_state->get('pagination.offset'), $this->_state->get('pagination.limit') ); + } else { + $this->_items = $rows; + } + } + + /** + * Remove (uninstall) an extension + * + * @static + * @return boolean True on success + * @since 1.0 + */ + function remove($eid=array()) + { + global $mainframe; + + $lang =& JFactory::getLanguage(); + $lang->load('com_installer'); + + // Initialize variables + $failed = array (); + + /* + * Ensure eid is an array of extension ids + * TODO: If it isn't an array do we want to set an error and fail? + */ + if (!is_array($eid)) { + $eid = array ($eid); + } + // construct the list of all language + $this->_loadItems(); + + // Get a database connector + $db =& JFactory::getDBO(); + + // Get an installer object for the extension type + jimport('joomla.installer.installer'); + $installer =& JInstaller::getInstance($db, $this->_type); + + // Uninstall the chosen extensions + foreach ($eid as $id) + { + $item = $this->_items[$id]; + + // Get client information + $client =& JApplicationHelper::getClientInfo($item->client_id); + + // Don't delete a default ( published language ) + $params = JComponentHelper::getParams('com_languages'); + $tag = basename($item->language); + if ( $params->get($client->name, 'en-GB') == $tag ) { + $failed[] = $id; + JError::raiseWarning('', JText::_('UNINSTALLLANGPUBLISHEDALREADY')); + return; + } + + $result = $installer->uninstall( 'language', $item->language ); + + // Build an array of extensions that failed to uninstall + if ($result === false) { + $failed[] = $id; + } + } + + if (count($failed)) { + // There was an error in uninstalling the package + $msg = JText::sprintf('UNINSTALLEXT', JText::_($this->_type), JText::_('Error')); + $result = false; + } else { + // Package uninstalled sucessfully + $msg = JText::sprintf('UNINSTALLEXT', JText::_($this->_type), JText::_('Success')); + $result = true; + } + + $mainframe->enqueueMessage($msg); + $this->setState('action', 'remove'); + $this->setState('message', $installer->message); + // re-construct the list of all language + $this->_loadItems(); + + return $result; + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_installer/models/modules.php b/oss/joomla/trunk/administrator/components/com_installer/models/modules.php index 29c74127..73c59139 100644 --- a/oss/joomla/trunk/administrator/components/com_installer/models/modules.php +++ b/oss/joomla/trunk/administrator/components/com_installer/models/modules.php @@ -1,118 +1,118 @@ -setState('filter.string', $mainframe->getUserStateFromRequest( 'com_installer.modules.string', 'filter', '', 'string' )); - $this->setState('filter.client', $mainframe->getUserStateFromRequest( 'com_installer.modules.client', 'client', -1, 'int' )); - } - - function _loadItems() - { - global $mainframe, $option; - - $db = &JFactory::getDBO(); - - $and = null; - if ($this->_state->get('filter.client') < 0) { - if ($search = $this->_state->get('filter.string')) { - $and = ' AND title LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); - } - } else { - if ($search = $this->_state->get('filter.string')) - { - $and = ' AND client_id = '.(int)$this->_state->get('filter.client'); - $and .= ' AND title LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); - } - else { - $and = ' AND client_id = '.(int)$this->_state->get('filter.client'); - } - } - - $query = 'SELECT id, module, client_id, title, iscore' . - ' FROM #__modules' . - ' WHERE module LIKE "mod_%" ' . - $and . - ' GROUP BY module, client_id' . - ' ORDER BY iscore, client_id, module'; - $db->setQuery($query); - $rows = $db->loadObjectList(); - - $n = count($rows); - for ($i = 0; $i < $n; $i ++) { - $row = & $rows[$i]; - - // path to module directory - if ($row->client_id == "1") { - $moduleBaseDir = JPATH_ADMINISTRATOR.DS."modules"; - } else { - $moduleBaseDir = JPATH_SITE.DS."modules"; - } - - // xml file for module - $xmlfile = $moduleBaseDir . DS . $row->module .DS. $row->module.".xml"; - - if (file_exists($xmlfile)) - { - if ($data = JApplicationHelper::parseXMLInstallFile($xmlfile)) { - foreach($data as $key => $value) { - $row->$key = $value; - } - } - } - } - $this->setState('pagination.total', $n); - // if the offset is greater than the total, then can the offset - if($this->_state->get('pagination.offset') > $this->_state->get('pagination.total')) { - $this->setState('pagination.offset',0); - } - - if($this->_state->get('pagination.limit') > 0) { - $this->_items = array_slice( $rows, $this->_state->get('pagination.offset'), $this->_state->get('pagination.limit') ); - } else { - $this->_items = $rows; - } - } +setState('filter.string', $mainframe->getUserStateFromRequest( 'com_installer.modules.string', 'filter', '', 'string' )); + $this->setState('filter.client', $mainframe->getUserStateFromRequest( 'com_installer.modules.client', 'client', -1, 'int' )); + } + + function _loadItems() + { + global $mainframe, $option; + + $db = &JFactory::getDBO(); + + $and = null; + if ($this->_state->get('filter.client') < 0) { + if ($search = $this->_state->get('filter.string')) { + $and = ' AND title LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + } else { + if ($search = $this->_state->get('filter.string')) + { + $and = ' AND client_id = '.(int)$this->_state->get('filter.client'); + $and .= ' AND title LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + else { + $and = ' AND client_id = '.(int)$this->_state->get('filter.client'); + } + } + + $query = 'SELECT id, module, client_id, title, iscore' . + ' FROM #__modules' . + ' WHERE module LIKE "mod_%" ' . + $and . + ' GROUP BY module, client_id' . + ' ORDER BY iscore, client_id, module'; + $db->setQuery($query); + $rows = $db->loadObjectList(); + + $n = count($rows); + for ($i = 0; $i < $n; $i ++) { + $row = & $rows[$i]; + + // path to module directory + if ($row->client_id == "1") { + $moduleBaseDir = JPATH_ADMINISTRATOR.DS."modules"; + } else { + $moduleBaseDir = JPATH_SITE.DS."modules"; + } + + // xml file for module + $xmlfile = $moduleBaseDir . DS . $row->module .DS. $row->module.".xml"; + + if (file_exists($xmlfile)) + { + if ($data = JApplicationHelper::parseXMLInstallFile($xmlfile)) { + foreach($data as $key => $value) { + $row->$key = $value; + } + } + } + } + $this->setState('pagination.total', $n); + // if the offset is greater than the total, then can the offset + if($this->_state->get('pagination.offset') > $this->_state->get('pagination.total')) { + $this->setState('pagination.offset',0); + } + + if($this->_state->get('pagination.limit') > 0) { + $this->_items = array_slice( $rows, $this->_state->get('pagination.offset'), $this->_state->get('pagination.limit') ); + } else { + $this->_items = $rows; + } + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_installer/models/plugins.php b/oss/joomla/trunk/administrator/components/com_installer/models/plugins.php index 2bcfc077..afa2465f 100644 --- a/oss/joomla/trunk/administrator/components/com_installer/models/plugins.php +++ b/oss/joomla/trunk/administrator/components/com_installer/models/plugins.php @@ -1,132 +1,132 @@ -setState('filter.group', $mainframe->getUserStateFromRequest( "com_installer.plugins.group", 'group', '', 'cmd' )); - $this->setState('filter.string', $mainframe->getUserStateFromRequest( "com_installer.plugins.string", 'filter', '', 'string' )); - } - - function &getGroups() - { - // Get a database connector object - $db = &$this->getDBO(); - - // get list of Positions for dropdown filter - $query = 'SELECT folder AS value, folder AS text' . - ' FROM #__plugins' . - ' GROUP BY folder' . - ' ORDER BY folder'; - $db->setQuery( $query ); - - $types[] = JHTML::_('select.option', '', JText::_( 'All' ) ); - $types = array_merge( $types, $db->loadObjectList() ); - - return $types; - } - - function _loadItems() - { - global $mainframe, $option; - - // Get a database connector - $db = & JFactory::getDBO(); - - $where = null; - if ($this->_state->get('filter.group')) { - if ($search = $this->_state->get('filter.string')) - { - $where = ' WHERE folder = "'.$db->getEscaped($this->_state->get('filter.group')).'"'; - $where .= ' AND name LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); - } - else { - $where = ' WHERE folder = "'.$db->getEscaped($this->_state->get('filter.group')).'"'; - } - } else { - if ($search = $this->_state->get('filter.string')) { - $where .= ' WHERE name LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); - } - } - - $query = 'SELECT id, name, folder, element, client_id, iscore' . - ' FROM #__plugins' . - $where . - ' ORDER BY iscore, folder, name'; - $db->setQuery($query); - $rows = $db->loadObjectList(); - - // Get the plugin base path - $baseDir = JPATH_ROOT.DS.'plugins'; - - $numRows = count($rows); - for ($i = 0; $i < $numRows; $i ++) { - $row = & $rows[$i]; - - // Get the plugin xml file - $xmlfile = $baseDir.DS.$row->folder.DS.$row->element.".xml"; - - if (file_exists($xmlfile)) { - if ($data = JApplicationHelper::parseXMLInstallFile($xmlfile)) { - foreach($data as $key => $value) - { - $row->$key = $value; - } - } - } - } - - $this->setState('pagination.total', $numRows); - // if the offset is greater than the total, then can the offset - if($this->_state->get('pagination.offset') > $this->_state->get('pagination.total')) { - $this->setState('pagination.offset',0); - } - - if($this->_state->get('pagination.limit') > 0) { - $this->_items = array_slice( $rows, $this->_state->get('pagination.offset'), $this->_state->get('pagination.limit') ); - } else { - $this->_items = $rows; - } - } +setState('filter.group', $mainframe->getUserStateFromRequest( "com_installer.plugins.group", 'group', '', 'cmd' )); + $this->setState('filter.string', $mainframe->getUserStateFromRequest( "com_installer.plugins.string", 'filter', '', 'string' )); + } + + function &getGroups() + { + // Get a database connector object + $db = &$this->getDBO(); + + // get list of Positions for dropdown filter + $query = 'SELECT folder AS value, folder AS text' . + ' FROM #__plugins' . + ' GROUP BY folder' . + ' ORDER BY folder'; + $db->setQuery( $query ); + + $types[] = JHTML::_('select.option', '', JText::_( 'All' ) ); + $types = array_merge( $types, $db->loadObjectList() ); + + return $types; + } + + function _loadItems() + { + global $mainframe, $option; + + // Get a database connector + $db = & JFactory::getDBO(); + + $where = null; + if ($this->_state->get('filter.group')) { + if ($search = $this->_state->get('filter.string')) + { + $where = ' WHERE folder = "'.$db->getEscaped($this->_state->get('filter.group')).'"'; + $where .= ' AND name LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + else { + $where = ' WHERE folder = "'.$db->getEscaped($this->_state->get('filter.group')).'"'; + } + } else { + if ($search = $this->_state->get('filter.string')) { + $where .= ' WHERE name LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + } + + $query = 'SELECT id, name, folder, element, client_id, iscore' . + ' FROM #__plugins' . + $where . + ' ORDER BY iscore, folder, name'; + $db->setQuery($query); + $rows = $db->loadObjectList(); + + // Get the plugin base path + $baseDir = JPATH_ROOT.DS.'plugins'; + + $numRows = count($rows); + for ($i = 0; $i < $numRows; $i ++) { + $row = & $rows[$i]; + + // Get the plugin xml file + $xmlfile = $baseDir.DS.$row->folder.DS.$row->element.".xml"; + + if (file_exists($xmlfile)) { + if ($data = JApplicationHelper::parseXMLInstallFile($xmlfile)) { + foreach($data as $key => $value) + { + $row->$key = $value; + } + } + } + } + + $this->setState('pagination.total', $numRows); + // if the offset is greater than the total, then can the offset + if($this->_state->get('pagination.offset') > $this->_state->get('pagination.total')) { + $this->setState('pagination.offset',0); + } + + if($this->_state->get('pagination.limit') > 0) { + $this->_items = array_slice( $rows, $this->_state->get('pagination.offset'), $this->_state->get('pagination.limit') ); + } else { + $this->_items = $rows; + } + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_installer/models/templates.php b/oss/joomla/trunk/administrator/components/com_installer/models/templates.php index ef8315bc..5468336d 100644 --- a/oss/joomla/trunk/administrator/components/com_installer/models/templates.php +++ b/oss/joomla/trunk/administrator/components/com_installer/models/templates.php @@ -1,173 +1,173 @@ -setState('filter.string', $mainframe->getUserStateFromRequest( "com_installer.templates.string", 'filter', '', 'string' )); - $this->setState('filter.client', $mainframe->getUserStateFromRequest( "com_installer.templates.client", 'client', -1, 'int' )); - } - - function _loadItems() - { - global $mainframe, $option; - - $db = &JFactory::getDBO(); - - if ($this->_state->get('filter.client') < 0) { - $client = 'all'; - // Get the site templates - $templateDirs = JFolder::folders(JPATH_SITE.DS.'templates'); - - for ($i=0; $i < count($templateDirs); $i++) { - $template = new stdClass(); - $template->folder = $templateDirs[$i]; - $template->client = 0; - $template->baseDir = JPATH_SITE.DS.'templates'; - - if ($this->_state->get('filter.string')) { - if (strpos($template->folder, $this->_state->get('filter.string')) !== false) { - $templates[] = $template; - } - } else { - $templates[] = $template; - } - } - // Get the admin templates - $templateDirs = JFolder::folders(JPATH_ADMINISTRATOR.DS.'templates'); - - for ($i=0; $i < count($templateDirs); $i++) { - $template = new stdClass(); - $template->folder = $templateDirs[$i]; - $template->client = 1; - $template->baseDir = JPATH_ADMINISTRATOR.DS.'templates'; - - if ($this->_state->get('filter.string')) { - if (strpos($template->folder, $this->_state->get('filter.string')) !== false) { - $templates[] = $template; - } - } else { - $templates[] = $template; - } - } - } else { - $clientInfo =& JApplicationHelper::getClientInfo($this->_state->get('filter.client')); - $client = $clientInfo->name; - $templateDirs = JFolder::folders($clientInfo->path.DS.'templates'); - - for ($i=0; $i < count($templateDirs); $i++) { - $template = new stdClass(); - $template->folder = $templateDirs[$i]; - $template->client = $clientInfo->id; - $template->baseDir = $clientInfo->path.DS.'templates'; - - if ($this->_state->get('filter.string')) { - if (strpos($template->folder, $this->_state->get('filter.string')) !== false) { - $templates[] = $template; - } - } else { - $templates[] = $template; - } - } - } - - // Get a list of the currently active templates - $query = 'SELECT template' . - ' FROM #__templates_menu' . - ' WHERE 1'; - $db->setQuery($query); - $activeList = $db->loadResultArray(); - - $rows = array(); - $rowid = 0; - // Check that the directory contains an xml file - foreach($templates as $template) - { - $dirName = $template->baseDir .DS. $template->folder; - $xmlFilesInDir = JFolder::files($dirName,'.xml$'); - - foreach($xmlFilesInDir as $xmlfile) - { - $data = JApplicationHelper::parseXMLInstallFile($dirName . DS. $xmlfile); - - $row = new StdClass(); - $row->id = $rowid; - $row->client_id = $template->client; - $row->directory = $template->folder; - $row->baseDir = $template->baseDir; - - // Is the template active? - if (in_array($row->directory, $activeList)) { - $row->active = true; - } else { - $row->active = false; - } - - if ($data) { - foreach($data as $key => $value) { - $row->$key = $value; - } - } - - $row->checked_out = 0; - $row->jname = JString::strtolower( str_replace( ' ', '_', $row->name ) ); - - $rows[] = $row; - $rowid++; - } - } - $this->setState('pagination.total', count($rows)); - // if the offset is greater than the total, then can the offset - if($this->_state->get('pagination.offset') > $this->_state->get('pagination.total')) { - $this->setState('pagination.offset',0); - } - - if($this->_state->get('pagination.limit') > 0) { - $this->_items = array_slice( $rows, $this->_state->get('pagination.offset'), $this->_state->get('pagination.limit') ); - } else { - $this->_items = $rows; - } - } +setState('filter.string', $mainframe->getUserStateFromRequest( "com_installer.templates.string", 'filter', '', 'string' )); + $this->setState('filter.client', $mainframe->getUserStateFromRequest( "com_installer.templates.client", 'client', -1, 'int' )); + } + + function _loadItems() + { + global $mainframe, $option; + + $db = &JFactory::getDBO(); + + if ($this->_state->get('filter.client') < 0) { + $client = 'all'; + // Get the site templates + $templateDirs = JFolder::folders(JPATH_SITE.DS.'templates'); + + for ($i=0; $i < count($templateDirs); $i++) { + $template = new stdClass(); + $template->folder = $templateDirs[$i]; + $template->client = 0; + $template->baseDir = JPATH_SITE.DS.'templates'; + + if ($this->_state->get('filter.string')) { + if (strpos($template->folder, $this->_state->get('filter.string')) !== false) { + $templates[] = $template; + } + } else { + $templates[] = $template; + } + } + // Get the admin templates + $templateDirs = JFolder::folders(JPATH_ADMINISTRATOR.DS.'templates'); + + for ($i=0; $i < count($templateDirs); $i++) { + $template = new stdClass(); + $template->folder = $templateDirs[$i]; + $template->client = 1; + $template->baseDir = JPATH_ADMINISTRATOR.DS.'templates'; + + if ($this->_state->get('filter.string')) { + if (strpos($template->folder, $this->_state->get('filter.string')) !== false) { + $templates[] = $template; + } + } else { + $templates[] = $template; + } + } + } else { + $clientInfo =& JApplicationHelper::getClientInfo($this->_state->get('filter.client')); + $client = $clientInfo->name; + $templateDirs = JFolder::folders($clientInfo->path.DS.'templates'); + + for ($i=0; $i < count($templateDirs); $i++) { + $template = new stdClass(); + $template->folder = $templateDirs[$i]; + $template->client = $clientInfo->id; + $template->baseDir = $clientInfo->path.DS.'templates'; + + if ($this->_state->get('filter.string')) { + if (strpos($template->folder, $this->_state->get('filter.string')) !== false) { + $templates[] = $template; + } + } else { + $templates[] = $template; + } + } + } + + // Get a list of the currently active templates + $query = 'SELECT template' . + ' FROM #__templates_menu' . + ' WHERE 1'; + $db->setQuery($query); + $activeList = $db->loadResultArray(); + + $rows = array(); + $rowid = 0; + // Check that the directory contains an xml file + foreach($templates as $template) + { + $dirName = $template->baseDir .DS. $template->folder; + $xmlFilesInDir = JFolder::files($dirName,'.xml$'); + + foreach($xmlFilesInDir as $xmlfile) + { + $data = JApplicationHelper::parseXMLInstallFile($dirName . DS. $xmlfile); + + $row = new StdClass(); + $row->id = $rowid; + $row->client_id = $template->client; + $row->directory = $template->folder; + $row->baseDir = $template->baseDir; + + // Is the template active? + if (in_array($row->directory, $activeList)) { + $row->active = true; + } else { + $row->active = false; + } + + if ($data) { + foreach($data as $key => $value) { + $row->$key = $value; + } + } + + $row->checked_out = 0; + $row->jname = JString::strtolower( str_replace( ' ', '_', $row->name ) ); + + $rows[] = $row; + $rowid++; + } + } + $this->setState('pagination.total', count($rows)); + // if the offset is greater than the total, then can the offset + if($this->_state->get('pagination.offset') > $this->_state->get('pagination.total')) { + $this->setState('pagination.offset',0); + } + + if($this->_state->get('pagination.limit') > 0) { + $this->_items = array_slice( $rows, $this->_state->get('pagination.offset'), $this->_state->get('pagination.limit') ); + } else { + $this->_items = $rows; + } + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_installer/views/components/view.php b/oss/joomla/trunk/administrator/components/com_installer/views/components/view.php index d8baeb14..4887f8ce 100644 --- a/oss/joomla/trunk/administrator/components/com_installer/views/components/view.php +++ b/oss/joomla/trunk/administrator/components/com_installer/views/components/view.php @@ -1,69 +1,69 @@ -get('State'); - $items = &$this->get('Items'); - $pagination = &$this->get('Pagination'); - - $this->assignRef('items', $items); - $this->assignRef('pagination', $pagination); - - parent::display($tpl); - } - - function loadItem($index=0) - { - $item =& $this->items[$index]; - $item->index = $index; - $item->img = $item->enabled ? 'tick.png' : 'publish_x.png'; - $item->task = $item->enabled ? 'disable' : 'enable'; - $item->alt = $item->enabled ? JText::_( 'Enabled' ) : JText::_( 'Disabled' ); - $item->action = $item->enabled ? JText::_( 'disable' ) : JText::_( 'enable' ); - - if ($item->iscore) { - $item->cbd = 'disabled'; - $item->style = 'style="color:#999999;"'; - } else { - $item->cbd = null; - $item->style = null; - } - $item->author_info = @$item->authorEmail .'
    '. @$item->authorUrl; - - $this->assignRef('item', $item); - } -} +get('State'); + $items = &$this->get('Items'); + $pagination = &$this->get('Pagination'); + + $this->assignRef('items', $items); + $this->assignRef('pagination', $pagination); + + parent::display($tpl); + } + + function loadItem($index=0) + { + $item =& $this->items[$index]; + $item->index = $index; + $item->img = $item->enabled ? 'tick.png' : 'publish_x.png'; + $item->task = $item->enabled ? 'disable' : 'enable'; + $item->alt = $item->enabled ? JText::_( 'Enabled' ) : JText::_( 'Disabled' ); + $item->action = $item->enabled ? JText::_( 'disable' ) : JText::_( 'enable' ); + + if ($item->iscore) { + $item->cbd = 'disabled'; + $item->style = 'style="color:#999999;"'; + } else { + $item->cbd = null; + $item->style = null; + } + $item->author_info = @$item->authorEmail .'
    '. @$item->authorUrl; + + $this->assignRef('item', $item); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_installer/views/default/view.php b/oss/joomla/trunk/administrator/components/com_installer/views/default/view.php index 308fb840..2dd423e1 100644 --- a/oss/joomla/trunk/administrator/components/com_installer/views/default/view.php +++ b/oss/joomla/trunk/administrator/components/com_installer/views/default/view.php @@ -1,73 +1,73 @@ -_addPath('template', $this->_basePath.DS.'views'.DS.'default'.DS.'tmpl'); - } - - function display($tpl=null) - { - /* - * Set toolbar items for the page - */ - JToolBarHelper::title( JText::_( 'Extension Manager'), 'install.png' ); - - // Document - $document = & JFactory::getDocument(); - $document->setTitle(JText::_('Extension Manager').' : '.JText::_( $this->getName() )); - - // Get data from the model - $state = &$this->get('State'); - - // Are there messages to display ? - $showMessage = false; - if ( is_object($state) ) - { - $message1 = $state->get('message'); - $message2 = $state->get('extension.message'); - $showMessage = ( $message1 || $message2 ); - } - - $this->assign('showMessage', $showMessage); - $this->assignRef('state', $state); - - JHTML::_('behavior.tooltip'); - parent::display($tpl); - } - - /** - * Should be overloaded by extending view - * - * @param int $index - */ - function loadItem($index=0) - { - } +_addPath('template', $this->_basePath.DS.'views'.DS.'default'.DS.'tmpl'); + } + + function display($tpl=null) + { + /* + * Set toolbar items for the page + */ + JToolBarHelper::title( JText::_( 'Extension Manager'), 'install.png' ); + + // Document + $document = & JFactory::getDocument(); + $document->setTitle(JText::_('Extension Manager').' : '.JText::_( $this->getName() )); + + // Get data from the model + $state = &$this->get('State'); + + // Are there messages to display ? + $showMessage = false; + if ( is_object($state) ) + { + $message1 = $state->get('message'); + $message2 = $state->get('extension.message'); + $showMessage = ( $message1 || $message2 ); + } + + $this->assign('showMessage', $showMessage); + $this->assignRef('state', $state); + + JHTML::_('behavior.tooltip'); + parent::display($tpl); + } + + /** + * Should be overloaded by extending view + * + * @param int $index + */ + function loadItem($index=0) + { + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_installer/views/install/view.php b/oss/joomla/trunk/administrator/components/com_installer/views/install/view.php index df2bd529..26942ccf 100644 --- a/oss/joomla/trunk/administrator/components/com_installer/views/install/view.php +++ b/oss/joomla/trunk/administrator/components/com_installer/views/install/view.php @@ -1,46 +1,46 @@ -first = ''; - - $this->assignRef('paths', $paths); - $this->assignRef('state', $this->get('state')); - - parent::display($tpl); - } - +first = ''; + + $this->assignRef('paths', $paths); + $this->assignRef('state', $this->get('state')); + + parent::display($tpl); + } + } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_installer/views/languages/view.php b/oss/joomla/trunk/administrator/components/com_installer/views/languages/view.php index 2257833d..517bba60 100644 --- a/oss/joomla/trunk/administrator/components/com_installer/views/languages/view.php +++ b/oss/joomla/trunk/administrator/components/com_installer/views/languages/view.php @@ -1,73 +1,73 @@ -get('State'); - $items = &$this->get('Items'); - $pagination = &$this->get('Pagination'); - - $lists = new stdClass(); - $select[] = JHTML::_('select.option', '-1', JText::_('All')); - $select[] = JHTML::_('select.option', '0', JText::_('Site Languages')); - $select[] = JHTML::_('select.option', '1', JText::_('Admin Languages')); - $lists->client = JHTML::_('select.genericlist', $select, 'client', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $state->get('filter.client')); - - $this->assignRef('items', $items); - $this->assignRef('pagination', $pagination); - $this->assignRef('lists', $lists); - - parent::display($tpl); - } - - function loadItem($index=0) - { - $item =& $this->items[$index]; - $item->index = $index; - - if ($item->published) { - $item->cbd = 'disabled'; - $item->style = 'style="color:#999999;"'; - } else { - $item->cbd = null; - $item->style = null; - } - $item->author_info = @$item->authorEmail .'
    '. @$item->authorUrl; - - $this->assignRef('item', $item); - } -} +get('State'); + $items = &$this->get('Items'); + $pagination = &$this->get('Pagination'); + + $lists = new stdClass(); + $select[] = JHTML::_('select.option', '-1', JText::_('All')); + $select[] = JHTML::_('select.option', '0', JText::_('Site Languages')); + $select[] = JHTML::_('select.option', '1', JText::_('Admin Languages')); + $lists->client = JHTML::_('select.genericlist', $select, 'client', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $state->get('filter.client')); + + $this->assignRef('items', $items); + $this->assignRef('pagination', $pagination); + $this->assignRef('lists', $lists); + + parent::display($tpl); + } + + function loadItem($index=0) + { + $item =& $this->items[$index]; + $item->index = $index; + + if ($item->published) { + $item->cbd = 'disabled'; + $item->style = 'style="color:#999999;"'; + } else { + $item->cbd = null; + $item->style = null; + } + $item->author_info = @$item->authorEmail .'
    '. @$item->authorUrl; + + $this->assignRef('item', $item); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_installer/views/modules/view.php b/oss/joomla/trunk/administrator/components/com_installer/views/modules/view.php index 983f9480..5b5f8b9c 100644 --- a/oss/joomla/trunk/administrator/components/com_installer/views/modules/view.php +++ b/oss/joomla/trunk/administrator/components/com_installer/views/modules/view.php @@ -1,75 +1,75 @@ -get('State'); - $items = &$this->get('Items'); - $pagination = &$this->get('Pagination'); - - $lists = new stdClass(); - $select[] = JHTML::_('select.option', '-1', JText::_('All')); - $select[] = JHTML::_('select.option', '0', JText::_('Site Modules')); - $select[] = JHTML::_('select.option', '1', JText::_('Admin Modules')); - $lists->client = JHTML::_('select.genericlist', $select, 'client', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $state->get('filter.client')); - - $this->assignRef('items', $items); - $this->assignRef('pagination', $pagination); - $this->assignRef('lists', $lists); - - JHTML::_('behavior.tooltip'); - parent::display($tpl); - } - - function loadItem($index=0) - { - $item =& $this->items[$index]; - $item->index = $index; - - if ($item->iscore) { - $item->cbd = 'disabled'; - $item->style = 'style="color:#999999;"'; - } else { - $item->cbd = null; - $item->style = null; - } - $item->author_info = @$item->authorEmail .'
    '. @$item->authorUrl; - - $this->assignRef('item', $item); - } -} +get('State'); + $items = &$this->get('Items'); + $pagination = &$this->get('Pagination'); + + $lists = new stdClass(); + $select[] = JHTML::_('select.option', '-1', JText::_('All')); + $select[] = JHTML::_('select.option', '0', JText::_('Site Modules')); + $select[] = JHTML::_('select.option', '1', JText::_('Admin Modules')); + $lists->client = JHTML::_('select.genericlist', $select, 'client', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $state->get('filter.client')); + + $this->assignRef('items', $items); + $this->assignRef('pagination', $pagination); + $this->assignRef('lists', $lists); + + JHTML::_('behavior.tooltip'); + parent::display($tpl); + } + + function loadItem($index=0) + { + $item =& $this->items[$index]; + $item->index = $index; + + if ($item->iscore) { + $item->cbd = 'disabled'; + $item->style = 'style="color:#999999;"'; + } else { + $item->cbd = null; + $item->style = null; + } + $item->author_info = @$item->authorEmail .'
    '. @$item->authorUrl; + + $this->assignRef('item', $item); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_installer/views/plugins/view.php b/oss/joomla/trunk/administrator/components/com_installer/views/plugins/view.php index 1f882abd..008d876b 100644 --- a/oss/joomla/trunk/administrator/components/com_installer/views/plugins/view.php +++ b/oss/joomla/trunk/administrator/components/com_installer/views/plugins/view.php @@ -1,71 +1,71 @@ -get('State'); - $items = &$this->get('Items'); - $pagination = &$this->get('Pagination'); - $groups = &$this->get('Groups'); - - $fields = new stdClass(); - $fields->groups = JHTML::_('select.genericlist', $groups, 'group', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $state->get('filter.group') ); - - $this->assignRef('items', $items); - $this->assignRef('pagination', $pagination); - $this->assignRef('fields', $fields); - - parent::display($tpl); - } - - function loadItem($index=0) - { - $item =& $this->items[$index]; - $item->index = $index; - - if ($item->iscore) { - $item->cbd = 'disabled'; - $item->style = 'style="color:#999999;"'; - } else { - $item->cbd = null; - $item->style = null; - } - $item->author_info = @$item->authorEmail .'
    '. @$item->authorUrl; - - $this->assignRef('item', $item); - } -} +get('State'); + $items = &$this->get('Items'); + $pagination = &$this->get('Pagination'); + $groups = &$this->get('Groups'); + + $fields = new stdClass(); + $fields->groups = JHTML::_('select.genericlist', $groups, 'group', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $state->get('filter.group') ); + + $this->assignRef('items', $items); + $this->assignRef('pagination', $pagination); + $this->assignRef('fields', $fields); + + parent::display($tpl); + } + + function loadItem($index=0) + { + $item =& $this->items[$index]; + $item->index = $index; + + if ($item->iscore) { + $item->cbd = 'disabled'; + $item->style = 'style="color:#999999;"'; + } else { + $item->cbd = null; + $item->style = null; + } + $item->author_info = @$item->authorEmail .'
    '. @$item->authorUrl; + + $this->assignRef('item', $item); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_installer/views/templates/view.php b/oss/joomla/trunk/administrator/components/com_installer/views/templates/view.php index 170d1f4a..72ba55a1 100644 --- a/oss/joomla/trunk/administrator/components/com_installer/views/templates/view.php +++ b/oss/joomla/trunk/administrator/components/com_installer/views/templates/view.php @@ -1,73 +1,73 @@ -get('State'); - $items = &$this->get('Items'); - $pagination = &$this->get('Pagination'); - - $lists = new stdClass(); - $select[] = JHTML::_('select.option', '-1', JText::_('All')); - $select[] = JHTML::_('select.option', '0', JText::_('Site Templates')); - $select[] = JHTML::_('select.option', '1', JText::_('Admin Templates')); - $lists->client = JHTML::_('select.genericlist', $select, 'client', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $state->get('filter.client')); - - $this->assignRef('items', $items); - $this->assignRef('pagination', $pagination); - $this->assignRef('lists', $lists); - - parent::display($tpl); - } - - function loadItem($index=0) - { - $item =& $this->items[$index]; - $item->id = $item->directory; - $item->index = $index; - - if ($item->active) { - $item->cbd = 'disabled'; - $item->style = 'style="color:#999999;"'; - } else { - $item->cbd = null; - $item->style = null; - } - $item->author_information = @$item->authorEmail .'
    '. @$item->authorUrl; - - $this->assignRef('item', $item); - } -} +get('State'); + $items = &$this->get('Items'); + $pagination = &$this->get('Pagination'); + + $lists = new stdClass(); + $select[] = JHTML::_('select.option', '-1', JText::_('All')); + $select[] = JHTML::_('select.option', '0', JText::_('Site Templates')); + $select[] = JHTML::_('select.option', '1', JText::_('Admin Templates')); + $lists->client = JHTML::_('select.genericlist', $select, 'client', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $state->get('filter.client')); + + $this->assignRef('items', $items); + $this->assignRef('pagination', $pagination); + $this->assignRef('lists', $lists); + + parent::display($tpl); + } + + function loadItem($index=0) + { + $item =& $this->items[$index]; + $item->id = $item->directory; + $item->index = $index; + + if ($item->active) { + $item->cbd = 'disabled'; + $item->style = 'style="color:#999999;"'; + } else { + $item->cbd = null; + $item->style = null; + } + $item->author_information = @$item->authorEmail .'
    '. @$item->authorUrl; + + $this->assignRef('item', $item); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_languages/admin.languages.html.php b/oss/joomla/trunk/administrator/components/com_languages/admin.languages.html.php index a5c8c234..aa2746cb 100644 --- a/oss/joomla/trunk/administrator/components/com_languages/admin.languages.html.php +++ b/oss/joomla/trunk/administrator/components/com_languages/admin.languages.html.php @@ -1,157 +1,157 @@ - -
    - - -
    - - - - - -

    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; ?> +
    + + + + + + +
    + authorize( 'com_languages', 'manage' )) { - $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); -} - -require_once( JApplicationHelper::getPath( 'admin_html' ) ); - -$task = strtolower( JRequest::getCmd( 'task' ) ); -$cid = JRequest::getVar( 'cid', array(0), '', 'array' ); -$cid = array(JFilterInput::clean(@$cid[0], 'cmd')); - -$client = JRequest::getVar('client', 0, '', 'int'); -if ($client == 1) { - JSubMenuHelper::addEntry(JText::_('Site'),'#" onclick="javascript:document.adminForm.client.value=\'0\';submitbutton(\'\');'); - JSubMenuHelper::addEntry(JText::_('Administrator'), '#" onclick="javascript:document.adminForm.client.value=\'1\';submitbutton(\'\');', true ); -} else { - JSubMenuHelper::addEntry(JText::_('Site'), '#" onclick="javascript:document.adminForm.client.value=\'0\';submitbutton(\'\');', true ); - JSubMenuHelper::addEntry(JText::_('Administrator'), '#" onclick="javascript:document.adminForm.client.value=\'1\';submitbutton(\'\');'); -} - -switch ($task) -{ - case 'publish': - publishLanguage( $cid[0]); - break; - - default: - viewLanguages(); - break; -} - -/** -* Compiles a list of installed languages -*/ -function viewLanguages() -{ - global $mainframe, $option; - - // Initialize some variables - $db =& JFactory::getDBO(); - $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); - $rows = array (); - - $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); - $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); - - $rowid = 0; - - // Set FTP credentials, if given - jimport('joomla.client.helper'); - $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); - - //load folder filesystem class - jimport('joomla.filesystem.folder'); - $path = JLanguage::getLanguagePath($client->path); - $dirs = JFolder::folders( $path ); - - foreach ($dirs as $dir) - { - $files = JFolder::files( $path.DS.$dir, '^([-_A-Za-z]*)\.xml$' ); - foreach ($files as $file) - { - $data = JApplicationHelper::parseXMLLangMetaFile($path.DS.$dir.DS.$file); - - $row = new StdClass(); - $row->id = $rowid; - $row->language = substr($file,0,-4); - - if (!is_array($data)) { - continue; - } - foreach($data as $key => $value) { - $row->$key = $value; - } - - // if current than set published - $params = JComponentHelper::getParams('com_languages'); - if ( $params->get($client->name, 'en-GB') == $row->language) { - $row->published = 1; - } else { - $row->published = 0; - } - - $row->checked_out = 0; - $row->mosname = JString::strtolower( str_replace( " ", "_", $row->name ) ); - $rows[] = $row; - $rowid++; - } - } - - - jimport('joomla.html.pagination'); - $pageNav = new JPagination( $rowid, $limitstart, $limit ); - - $rows = array_slice( $rows, $pageNav->limitstart, $pageNav->limit ); - - HTML_languages::showLanguages( $rows, $pageNav, $option, $client, $ftp ); -} - -/** -* Publish, or make current, the selected language -*/ -function publishLanguage( $language ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize some variables - $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); - - $params = JComponentHelper::getParams('com_languages'); - $params->set($client->name, $language); - - $table =& JTable::getInstance('component'); - $table->loadByOption( 'com_languages' ); - - $table->params = $params->toString(); - - // pre-save checks - if (!$table->check()) { - JError::raiseWarning( 500, $table->getError() ); - return false; - } - - // save the changes - if (!$table->store()) { - JError::raiseWarning( 500, $table->getError() ); - return false; - } - - $mainframe->redirect('index.php?option=com_languages&client='.$client->id); +authorize( 'com_languages', 'manage' )) { + $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); +} + +require_once( JApplicationHelper::getPath( 'admin_html' ) ); + +$task = strtolower( JRequest::getCmd( 'task' ) ); +$cid = JRequest::getVar( 'cid', array(0), '', 'array' ); +$cid = array(JFilterInput::clean(@$cid[0], 'cmd')); + +$client = JRequest::getVar('client', 0, '', 'int'); +if ($client == 1) { + JSubMenuHelper::addEntry(JText::_('Site'),'#" onclick="javascript:document.adminForm.client.value=\'0\';submitbutton(\'\');'); + JSubMenuHelper::addEntry(JText::_('Administrator'), '#" onclick="javascript:document.adminForm.client.value=\'1\';submitbutton(\'\');', true ); +} else { + JSubMenuHelper::addEntry(JText::_('Site'), '#" onclick="javascript:document.adminForm.client.value=\'0\';submitbutton(\'\');', true ); + JSubMenuHelper::addEntry(JText::_('Administrator'), '#" onclick="javascript:document.adminForm.client.value=\'1\';submitbutton(\'\');'); +} + +switch ($task) +{ + case 'publish': + publishLanguage( $cid[0]); + break; + + default: + viewLanguages(); + break; +} + +/** +* Compiles a list of installed languages +*/ +function viewLanguages() +{ + global $mainframe, $option; + + // Initialize some variables + $db =& JFactory::getDBO(); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $rows = array (); + + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); + + $rowid = 0; + + // Set FTP credentials, if given + jimport('joomla.client.helper'); + $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); + + //load folder filesystem class + jimport('joomla.filesystem.folder'); + $path = JLanguage::getLanguagePath($client->path); + $dirs = JFolder::folders( $path ); + + foreach ($dirs as $dir) + { + $files = JFolder::files( $path.DS.$dir, '^([-_A-Za-z]*)\.xml$' ); + foreach ($files as $file) + { + $data = JApplicationHelper::parseXMLLangMetaFile($path.DS.$dir.DS.$file); + + $row = new StdClass(); + $row->id = $rowid; + $row->language = substr($file,0,-4); + + if (!is_array($data)) { + continue; + } + foreach($data as $key => $value) { + $row->$key = $value; + } + + // if current than set published + $params = JComponentHelper::getParams('com_languages'); + if ( $params->get($client->name, 'en-GB') == $row->language) { + $row->published = 1; + } else { + $row->published = 0; + } + + $row->checked_out = 0; + $row->mosname = JString::strtolower( str_replace( " ", "_", $row->name ) ); + $rows[] = $row; + $rowid++; + } + } + + + jimport('joomla.html.pagination'); + $pageNav = new JPagination( $rowid, $limitstart, $limit ); + + $rows = array_slice( $rows, $pageNav->limitstart, $pageNav->limit ); + + HTML_languages::showLanguages( $rows, $pageNav, $option, $client, $ftp ); +} + +/** +* Publish, or make current, the selected language +*/ +function publishLanguage( $language ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize some variables + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + + $params = JComponentHelper::getParams('com_languages'); + $params->set($client->name, $language); + + $table =& JTable::getInstance('component'); + $table->loadByOption( 'com_languages' ); + + $table->params = $params->toString(); + + // pre-save checks + if (!$table->check()) { + JError::raiseWarning( 500, $table->getError() ); + return false; + } + + // save the changes + if (!$table->store()) { + JError::raiseWarning( 500, $table->getError() ); + return false; + } + + $mainframe->redirect('index.php?option=com_languages&client='.$client->id); } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_languages/languages.xml b/oss/joomla/trunk/administrator/components/com_languages/languages.xml index 09761c60..caee8fe2 100644 --- a/oss/joomla/trunk/administrator/components/com_languages/languages.xml +++ b/oss/joomla/trunk/administrator/components/com_languages/languages.xml @@ -1,12 +1,12 @@ - - - Language Manager - Joomla! Project - 2006 - Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - admin@joomla.org - www.joomla.org - 1.5.0 - Language Manager - + + + Language Manager + Joomla! Project + 2006 + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + Language Manager + diff --git a/oss/joomla/trunk/administrator/components/com_languages/toolbar.languages.html.php b/oss/joomla/trunk/administrator/components/com_languages/toolbar.languages.html.php index fb14b3fc..30f7e083 100644 --- a/oss/joomla/trunk/administrator/components/com_languages/toolbar.languages.html.php +++ b/oss/joomla/trunk/administrator/components/com_languages/toolbar.languages.html.php @@ -1,30 +1,30 @@ - 'rounded', 'id' => 'section-box')); - echo $module; - } - - function login() - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken('request') or jexit( 'Invalid Token' ); - - $credentials = array(); - - $credentials['username'] = JRequest::getVar('username', '', 'method', 'username'); - $credentials['password'] = JRequest::getVar('passwd', '', 'post', 'string', JREQUEST_ALLOWRAW); - - $result = $mainframe->login($credentials); - - if (!JError::isError($result)) { - $mainframe->redirect('index.php'); - } - - LoginController::display(); - } - - function logout() - { - global $mainframe; - - $result = $mainframe->logout(); - - if (!JError::isError($result)) { - $mainframe->redirect('index.php?option=com_login'); - } - - LoginController::display(); - } -} + 'rounded', 'id' => 'section-box')); + echo $module; + } + + function login() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken('request') or jexit( 'Invalid Token' ); + + $credentials = array(); + + $credentials['username'] = JRequest::getVar('username', '', 'method', 'username'); + $credentials['password'] = JRequest::getVar('passwd', '', 'post', 'string', JREQUEST_ALLOWRAW); + + $result = $mainframe->login($credentials); + + if (!JError::isError($result)) { + $mainframe->redirect('index.php'); + } + + LoginController::display(); + } + + function logout() + { + global $mainframe; + + $result = $mainframe->logout(); + + if (!JError::isError($result)) { + $mainframe->redirect('index.php?option=com_login'); + } + + LoginController::display(); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_massmail/admin.massmail.html.php b/oss/joomla/trunk/administrator/components/com_massmail/admin.massmail.html.php index 6f6edc00..eb62aeac 100644 --- a/oss/joomla/trunk/administrator/components/com_massmail/admin.massmail.html.php +++ b/oss/joomla/trunk/administrator/components/com_massmail/admin.massmail.html.php @@ -1,139 +1,139 @@ - - - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - -
    - - - -
    - - -
    - -
    - - - -
    -
    -
    - -
    -
    - - - - - - - - - - - -
    - - - -
    - - - -
    -
    -
    -
    - - - - -
    - + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + +
    + + + +
    + + +
    + +
    + + + +
    +
    +
    + +
    +
    + + + + + + + + + + + +
    + + + +
    + + + +
    +
    +
    +
    + + + + +
    + authorize( 'com_massmail', 'manage' )) { - $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); -} - -require_once( JApplicationHelper::getPath( 'admin_html' ) ); - -switch ($task) -{ - case 'send': - sendMail(); - break; - - case 'cancel': - $mainframe->redirect( 'index.php' ); - break; - - default: - messageForm( $option ); - break; -} - -function messageForm( $option ) -{ - $acl =& JFactory::getACL(); - - $gtree = array( - JHTML::_('select.option', 0, '- '. JText::_( 'All User Groups' ) .' -' ) - ); - - // get list of groups - $lists = array(); - $gtree = array_merge( $gtree, $acl->get_group_children_tree( null, 'users', false ) ); - $lists['gid'] = JHTML::_('select.genericlist', $gtree, 'mm_group', 'size="10"', 'value', 'text', 0 ); - - HTML_massmail::messageForm( $lists, $option ); -} - -function sendMail() -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $user =& JFactory::getUser(); - $acl =& JFactory::getACL(); - - $mode = JRequest::getVar( 'mm_mode', 0, 'post', 'int' ); - $subject = JRequest::getVar( 'mm_subject', '', 'post', 'string' ); - $gou = JRequest::getVar( 'mm_group', '0', 'post', 'int' ); - $recurse = JRequest::getVar( 'mm_recurse', 'NO_RECURSE', 'post', 'word' ); - $bcc = JRequest::getVar( 'mm_bcc', 0, 'post', 'int' ); - - // pulls message inoformation either in text or html format - if ( $mode ) { - $message_body = JRequest::getVar( 'mm_message', '', 'post', 'string', JREQUEST_ALLOWRAW ); - } else { - // automatically removes html formatting - $message_body = JRequest::getVar( 'mm_message', '', 'post', 'string' ); - } - - // Check for a message body and subject - if (!$message_body || !$subject) { - $mainframe->redirect( 'index.php?option=com_massmail', JText::_( 'Please fill in the form correctly' ) ); - } - - // get users in the group out of the acl - $to = $acl->get_group_objects( $gou, 'ARO', $recurse ); - JArrayHelper::toInteger($to['users']); - - // Get sending email address - /* - $query = 'SELECT email' - . ' FROM #__users' - . ' WHERE id = '.(int) $user->get('id') - ; - $db->setQuery( $query ); - $user->set( 'email', $db->loadResult() ); - */ - - // Get all users email and group except for senders - $query = 'SELECT email' - . ' FROM #__users' - . ' WHERE id != '.(int) $user->get('id') - . ( $gou !== 0 ? ' AND id IN (' . implode( ',', $to['users'] ) . ')' : '' ) - ; - - $db->setQuery( $query ); - $rows = $db->loadObjectList(); - - // Check to see if there are any users in this group before we continue - if ( ! count($rows) ) { - $msg = JText::_('No users could be found in this group.'); - $mainframe->redirect( 'index.php?option=com_massmail', $msg ); - } - - $mailer =& JFactory::getMailer(); - $params =& JComponentHelper::getParams( 'com_massmail' ); - - // Build e-mail message format - $mailer->setSender(array($mainframe->getCfg('mailfrom'), $mainframe->getCfg('fromname'))); - $mailer->setSubject($params->get('mailSubjectPrefix') . stripslashes( $subject)); - $mailer->setBody($message_body . $params->get('mailBodySuffix')); - $mailer->IsHTML($mode); - - // Add recipients - - if ( $bcc ) { - foreach ($rows as $row) { - $mailer->addBCC($row->email); - } - $mailer->addRecipient($mainframe->getCfg('mailfrom')); - }else { - foreach ($rows as $row) { - $mailer->addRecipient($row->email); - } - } - - // Send the Mail - $rs = $mailer->Send(); - - // Check for an error - if ( JError::isError($rs) ) { - $msg = $rs->getError(); - } else { - $msg = $rs ? JText::sprintf( 'E-mail sent to', count( $rows ) ) : JText::_('The mail could not be sent'); - } - - // Redirect with the message - $mainframe->redirect( 'index.php?option=com_massmail', $msg ); - -} +authorize( 'com_massmail', 'manage' )) { + $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); +} + +require_once( JApplicationHelper::getPath( 'admin_html' ) ); + +switch ($task) +{ + case 'send': + sendMail(); + break; + + case 'cancel': + $mainframe->redirect( 'index.php' ); + break; + + default: + messageForm( $option ); + break; +} + +function messageForm( $option ) +{ + $acl =& JFactory::getACL(); + + $gtree = array( + JHTML::_('select.option', 0, '- '. JText::_( 'All User Groups' ) .' -' ) + ); + + // get list of groups + $lists = array(); + $gtree = array_merge( $gtree, $acl->get_group_children_tree( null, 'users', false ) ); + $lists['gid'] = JHTML::_('select.genericlist', $gtree, 'mm_group', 'size="10"', 'value', 'text', 0 ); + + HTML_massmail::messageForm( $lists, $option ); +} + +function sendMail() +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + $acl =& JFactory::getACL(); + + $mode = JRequest::getVar( 'mm_mode', 0, 'post', 'int' ); + $subject = JRequest::getVar( 'mm_subject', '', 'post', 'string' ); + $gou = JRequest::getVar( 'mm_group', '0', 'post', 'int' ); + $recurse = JRequest::getVar( 'mm_recurse', 'NO_RECURSE', 'post', 'word' ); + $bcc = JRequest::getVar( 'mm_bcc', 0, 'post', 'int' ); + + // pulls message inoformation either in text or html format + if ( $mode ) { + $message_body = JRequest::getVar( 'mm_message', '', 'post', 'string', JREQUEST_ALLOWRAW ); + } else { + // automatically removes html formatting + $message_body = JRequest::getVar( 'mm_message', '', 'post', 'string' ); + } + + // Check for a message body and subject + if (!$message_body || !$subject) { + $mainframe->redirect( 'index.php?option=com_massmail', JText::_( 'Please fill in the form correctly' ) ); + } + + // get users in the group out of the acl + $to = $acl->get_group_objects( $gou, 'ARO', $recurse ); + JArrayHelper::toInteger($to['users']); + + // Get sending email address + /* + $query = 'SELECT email' + . ' FROM #__users' + . ' WHERE id = '.(int) $user->get('id') + ; + $db->setQuery( $query ); + $user->set( 'email', $db->loadResult() ); + */ + + // Get all users email and group except for senders + $query = 'SELECT email' + . ' FROM #__users' + . ' WHERE id != '.(int) $user->get('id') + . ( $gou !== 0 ? ' AND id IN (' . implode( ',', $to['users'] ) . ')' : '' ) + ; + + $db->setQuery( $query ); + $rows = $db->loadObjectList(); + + // Check to see if there are any users in this group before we continue + if ( ! count($rows) ) { + $msg = JText::_('No users could be found in this group.'); + $mainframe->redirect( 'index.php?option=com_massmail', $msg ); + } + + $mailer =& JFactory::getMailer(); + $params =& JComponentHelper::getParams( 'com_massmail' ); + + // Build e-mail message format + $mailer->setSender(array($mainframe->getCfg('mailfrom'), $mainframe->getCfg('fromname'))); + $mailer->setSubject($params->get('mailSubjectPrefix') . stripslashes( $subject)); + $mailer->setBody($message_body . $params->get('mailBodySuffix')); + $mailer->IsHTML($mode); + + // Add recipients + + if ( $bcc ) { + foreach ($rows as $row) { + $mailer->addBCC($row->email); + } + $mailer->addRecipient($mainframe->getCfg('mailfrom')); + }else { + foreach ($rows as $row) { + $mailer->addRecipient($row->email); + } + } + + // Send the Mail + $rs = $mailer->Send(); + + // Check for an error + if ( JError::isError($rs) ) { + $msg = $rs->getError(); + } else { + $msg = $rs ? JText::sprintf( 'E-mail sent to', count( $rows ) ) : JText::_('The mail could not be sent'); + } + + // Redirect with the message + $mainframe->redirect( 'index.php?option=com_massmail', $msg ); + +} diff --git a/oss/joomla/trunk/administrator/components/com_massmail/massmail.xml b/oss/joomla/trunk/administrator/components/com_massmail/massmail.xml index 40cca433..a267e099 100644 --- a/oss/joomla/trunk/administrator/components/com_massmail/massmail.xml +++ b/oss/joomla/trunk/administrator/components/com_massmail/massmail.xml @@ -1,12 +1,12 @@ - - - Mass Mail - Joomla! Project - April 2006 - Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - admin@joomla.org - www.joomla.org - 1.5.0 - DESCMASSMAIL - + + + Mass Mail + Joomla! Project + April 2006 + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + DESCMASSMAIL + diff --git a/oss/joomla/trunk/administrator/components/com_massmail/toolbar.massmail.html.php b/oss/joomla/trunk/administrator/components/com_massmail/toolbar.massmail.html.php index d89f2263..7691ed26 100644 --- a/oss/joomla/trunk/administrator/components/com_massmail/toolbar.massmail.html.php +++ b/oss/joomla/trunk/administrator/components/com_massmail/toolbar.massmail.html.php @@ -1,35 +1,35 @@ - - * @package Joomla - * @since 1.5 - * @version 1.0 - */ -#treeview { - padding: 10px; - width: 190px; - overflow: auto; - /*height: 390px;*/ - border: 0; -} - -#folderview { - -} - -#folderview .path { - margin-bottom: 10px; -} - -#folderview .view { - display: block; - margin: 0; - padding: 0; - height: 360px; -} - -#folderview input#folderpath { - width: 65%; - background-color: #EEE; -} - -#folderview input#foldername { - width: 20%; -} - -#folderview iframe#folderframe { - height: 100%; -} - -#uploads .upload { - padding: 4px; -} - -/** - * Upload Widget CSS - */ -.upload-queue { - list-style: none; -} - -.upload-queue li { - background: url(upload.png) no-repeat 0 5px; - padding: 5px 0 5px 22px; -} - -.upload-queue .queue-file { - font-weight: bold; -} - -.upload-queue .queue-size { - color: #aaa; - margin-left: 1em; - font-size: 0.9em; -} - -.upload-queue .queue-loader { - position: relative; - margin: 3px 15px; - font-size: 0.9em; - background-color: #ddd; - color: #fff; - border: 1px inset #ddd; -} - -.upload-queue .queue-subloader { - text-align: center; - position: absolute; - background-color: #81B466; - height: 100%; - width: 0%; - left: 0; - top: 0; -} - -.upload-queue .input-delete { - width: 16px; - height: 16px; - background: url(delete.png) no-repeat 0 0; - text-decoration: none; - border: none; - float: right; -} +/** +* @version $Id: mediamanager.css 14401 2010-01-26 14:10:00Z louis $ +* @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. +* @license GNU/GPL, see LICENSE.php +* Joomla! is free software. This version may have been modified pursuant +* to the GNU General Public License, and as distributed it includes or +* is derivative of works licensed under the GNU General Public License or +* other free or open source software licenses. +* See COPYRIGHT.php for copyright notices and details. +*/ /** + * MediaManager javascript behvaior styling + * + * @author Johan Janssens + * @package Joomla + * @since 1.5 + * @version 1.0 + */ +#treeview { + padding: 10px; + width: 190px; + overflow: auto; + /*height: 390px;*/ + border: 0; +} + +#folderview { + +} + +#folderview .path { + margin-bottom: 10px; +} + +#folderview .view { + display: block; + margin: 0; + padding: 0; + height: 360px; +} + +#folderview input#folderpath { + width: 65%; + background-color: #EEE; +} + +#folderview input#foldername { + width: 20%; +} + +#folderview iframe#folderframe { + height: 100%; +} + +#uploads .upload { + padding: 4px; +} + +/** + * Upload Widget CSS + */ +.upload-queue { + list-style: none; +} + +.upload-queue li { + background: url(upload.png) no-repeat 0 5px; + padding: 5px 0 5px 22px; +} + +.upload-queue .queue-file { + font-weight: bold; +} + +.upload-queue .queue-size { + color: #aaa; + margin-left: 1em; + font-size: 0.9em; +} + +.upload-queue .queue-loader { + position: relative; + margin: 3px 15px; + font-size: 0.9em; + background-color: #ddd; + color: #fff; + border: 1px inset #ddd; +} + +.upload-queue .queue-subloader { + text-align: center; + position: absolute; + background-color: #81B466; + height: 100%; + width: 0%; + left: 0; + top: 0; +} + +.upload-queue .input-delete { + width: 16px; + height: 16px; + background: url(delete.png) no-repeat 0 0; + text-decoration: none; + border: none; + float: right; +} diff --git a/oss/joomla/trunk/administrator/components/com_media/assets/mediamanager.js b/oss/joomla/trunk/administrator/components/com_media/assets/mediamanager.js index fbfe0ff4..cf4d7664 100644 --- a/oss/joomla/trunk/administrator/components/com_media/assets/mediamanager.js +++ b/oss/joomla/trunk/administrator/components/com_media/assets/mediamanager.js @@ -1,180 +1,180 @@ -/** -* @version $Id: mediamanager.js 10710 2008-08-21 10:08:12Z eddieajau $ -* @package Joomla -* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. -* @license GNU/GPL, see LICENSE.php -* Joomla! is free software. This version may have been modified pursuant -* to the GNU General Public License, and as distributed it includes or -* is derivative of works licensed under the GNU General Public License or -* other free or open source software licenses. -* See COPYRIGHT.php for copyright notices and details. -*/ - - -/** - * JMediaManager behavior for media component - * - * @package Joomla.Extensions - * @subpackage Media - * @since 1.5 - */ -var MediaManager = { - - initialize: function() - { - this.folderframe = $('folderframe'); - this.folderpath = $('folderpath'); - - this.updatepaths = $$('input.update-folder'); - - this.frame = window.frames['folderframe']; - this.frameurl = this.frame.location.href; - //this.frameurl = window.frames['folderframe'].location.href; - - this.tree = new MooTreeControl({ div: 'media-tree_tree', mode: 'folders', grid: true, theme: 'components/com_media/assets/mootree.gif', onClick: - function(node){ - target = $chk(node.data.target) ? node.data.target : '_self'; - window.frames[target].location.href = node.data.url; - } - },{ text: 'Media', open: true, data: { url: 'index.php?option=com_media&view=mediaList&tmpl=component', target: 'folderframe'}}); - this.tree.adopt('media-tree'); - }, - - submit: function(task) - { - form = window.frames['folderframe'].document.getElementById('mediamanager-form'); - form.task.value = task; - if ($('username')) { - form.username.value = $('username').value; - form.password.value = $('password').value; - } - form.submit(); - }, - - onloadframe: function() - { - // Update the frame url - this.frameurl = this.frame.location.href; - - var folder = this.getFolder(); - if (folder) { - this.updatepaths.each(function(path){ path.value =folder; }); - this.folderpath.value = basepath+'/'+folder; - node = this.tree.get('node_'+folder); - node.toggle(false, true); - } else { - this.updatepaths.each(function(path){ path.value = ''; }); - this.folderpath.value = basepath; - node = this.tree.root; - } - - if (node) { - this.tree.select(node, true); - } - - $(viewstyle).addClass('active'); - - a = this._getUriObject($('uploadForm').getProperty('action')); - q = $H(this._getQueryObject(a.query)); - q.set('folder', folder); - var query = []; - q.each(function(v, k){ - if ($chk(v)) { - this.push(k+'='+v); - } - }, query); - a.query = query.join('&'); - if (a.port) { - $('uploadForm').setProperty('action', a.scheme+'://'+a.domain+':'+a.port+a.path+'?'+a.query); - } else { - $('uploadForm').setProperty('action', a.scheme+'://'+a.domain+a.path+'?'+a.query); - } - }, - - oncreatefolder: function() - { - if ($('foldername').value.length) { - $('dirpath').value = this.getFolder(); - submitbutton('createfolder'); - } - }, - - setViewType: function(type) - { - $(type).addClass('active'); - $(viewstyle).removeClass('active'); - viewstyle = type; - var folder = this.getFolder(); - this._setFrameUrl('index.php?option=com_media&view=mediaList&tmpl=component&folder='+folder+'&layout='+type); - }, - - refreshFrame: function() - { - this._setFrameUrl(); - }, - - getFolder: function() - { - var url = this.frame.location.search.substring(1); - var args = this.parseQuery(url); - - if (args['folder'] == "undefined") { - args['folder'] = ""; - } - - return args['folder']; - }, - - parseQuery: function(query) - { - var params = new Object(); - if (!query) { - return params; - } - var pairs = query.split(/[;&]/); - for ( var i = 0; i < pairs.length; i++ ) - { - var KeyVal = pairs[i].split('='); - if ( ! KeyVal || KeyVal.length != 2 ) { - continue; - } - var key = unescape( KeyVal[0] ); - var val = unescape( KeyVal[1] ).replace(/\+ /g, ' '); - params[key] = val; - } - return params; - }, - - _setFrameUrl: function(url) - { - if ($chk(url)) { - this.frameurl = url; - } - this.frame.location.href = this.frameurl; - }, - - _getQueryObject: function(q) { - var vars = q.split(/[&;]/); - var rs = {}; - if (vars.length) vars.each(function(val) { - var keys = val.split('='); - if (keys.length && keys.length == 2) rs[encodeURIComponent(keys[0])] = encodeURIComponent(keys[1]); - }); - return rs; - }, - - _getUriObject: function(u){ - var bits = u.match(/^(?:([^:\/?#.]+):)?(?:\/\/)?(([^:\/?#]*)(?::(\d*))?)((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[\?#]|$)))*\/?)?([^?#\/]*))?(?:\?([^#]*))?(?:#(.*))?/); - return (bits) - ? bits.associate(['uri', 'scheme', 'authority', 'domain', 'port', 'path', 'directory', 'file', 'query', 'fragment']) - : null; - } -}; - -window.addEvent('domready', function(){ - // Added to populate data on iframe load - MediaManager.initialize(); - MediaManager.trace = 'start'; - document.updateUploader = function() { MediaManager.onloadframe(); }; - MediaManager.onloadframe(); -}); +/** +* @version $Id: mediamanager.js 14401 2010-01-26 14:10:00Z louis $ +* @package Joomla +* @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. +* @license GNU/GPL, see LICENSE.php +* Joomla! is free software. This version may have been modified pursuant +* to the GNU General Public License, and as distributed it includes or +* is derivative of works licensed under the GNU General Public License or +* other free or open source software licenses. +* See COPYRIGHT.php for copyright notices and details. +*/ + + +/** + * JMediaManager behavior for media component + * + * @package Joomla.Extensions + * @subpackage Media + * @since 1.5 + */ +var MediaManager = { + + initialize: function() + { + this.folderframe = $('folderframe'); + this.folderpath = $('folderpath'); + + this.updatepaths = $$('input.update-folder'); + + this.frame = window.frames['folderframe']; + this.frameurl = this.frame.location.href; + //this.frameurl = window.frames['folderframe'].location.href; + + this.tree = new MooTreeControl({ div: 'media-tree_tree', mode: 'folders', grid: true, theme: 'components/com_media/assets/mootree.gif', onClick: + function(node){ + target = $chk(node.data.target) ? node.data.target : '_self'; + window.frames[target].location.href = node.data.url; + } + },{ text: 'Media', open: true, data: { url: 'index.php?option=com_media&view=mediaList&tmpl=component', target: 'folderframe'}}); + this.tree.adopt('media-tree'); + }, + + submit: function(task) + { + form = window.frames['folderframe'].document.getElementById('mediamanager-form'); + form.task.value = task; + if ($('username')) { + form.username.value = $('username').value; + form.password.value = $('password').value; + } + form.submit(); + }, + + onloadframe: function() + { + // Update the frame url + this.frameurl = this.frame.location.href; + + var folder = this.getFolder(); + if (folder) { + this.updatepaths.each(function(path){ path.value =folder; }); + this.folderpath.value = basepath+'/'+folder; + node = this.tree.get('node_'+folder); + node.toggle(false, true); + } else { + this.updatepaths.each(function(path){ path.value = ''; }); + this.folderpath.value = basepath; + node = this.tree.root; + } + + if (node) { + this.tree.select(node, true); + } + + $(viewstyle).addClass('active'); + + a = this._getUriObject($('uploadForm').getProperty('action')); + q = $H(this._getQueryObject(a.query)); + q.set('folder', folder); + var query = []; + q.each(function(v, k){ + if ($chk(v)) { + this.push(k+'='+v); + } + }, query); + a.query = query.join('&'); + if (a.port) { + $('uploadForm').setProperty('action', a.scheme+'://'+a.domain+':'+a.port+a.path+'?'+a.query); + } else { + $('uploadForm').setProperty('action', a.scheme+'://'+a.domain+a.path+'?'+a.query); + } + }, + + oncreatefolder: function() + { + if ($('foldername').value.length) { + $('dirpath').value = this.getFolder(); + submitbutton('createfolder'); + } + }, + + setViewType: function(type) + { + $(type).addClass('active'); + $(viewstyle).removeClass('active'); + viewstyle = type; + var folder = this.getFolder(); + this._setFrameUrl('index.php?option=com_media&view=mediaList&tmpl=component&folder='+folder+'&layout='+type); + }, + + refreshFrame: function() + { + this._setFrameUrl(); + }, + + getFolder: function() + { + var url = this.frame.location.search.substring(1); + var args = this.parseQuery(url); + + if (args['folder'] == "undefined") { + args['folder'] = ""; + } + + return args['folder']; + }, + + parseQuery: function(query) + { + var params = new Object(); + if (!query) { + return params; + } + var pairs = query.split(/[;&]/); + for ( var i = 0; i < pairs.length; i++ ) + { + var KeyVal = pairs[i].split('='); + if ( ! KeyVal || KeyVal.length != 2 ) { + continue; + } + var key = unescape( KeyVal[0] ); + var val = unescape( KeyVal[1] ).replace(/\+ /g, ' '); + params[key] = val; + } + return params; + }, + + _setFrameUrl: function(url) + { + if ($chk(url)) { + this.frameurl = url; + } + this.frame.location.href = this.frameurl; + }, + + _getQueryObject: function(q) { + var vars = q.split(/[&;]/); + var rs = {}; + if (vars.length) vars.each(function(val) { + var keys = val.split('='); + if (keys.length && keys.length == 2) rs[encodeURIComponent(keys[0])] = encodeURIComponent(keys[1]); + }); + return rs; + }, + + _getUriObject: function(u){ + var bits = u.match(/^(?:([^:\/?#.]+):)?(?:\/\/)?(([^:\/?#]*)(?::(\d*))?)((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[\?#]|$)))*\/?)?([^?#\/]*))?(?:\?([^#]*))?(?:#(.*))?/); + return (bits) + ? bits.associate(['uri', 'scheme', 'authority', 'domain', 'port', 'path', 'directory', 'file', 'query', 'fragment']) + : null; + } +}; + +window.addEvent('domready', function(){ + // Added to populate data on iframe load + MediaManager.initialize(); + MediaManager.trace = 'start'; + document.updateUploader = function() { MediaManager.onloadframe(); }; + MediaManager.onloadframe(); +}); diff --git a/oss/joomla/trunk/administrator/components/com_media/assets/popup-imagelist.css b/oss/joomla/trunk/administrator/components/com_media/assets/popup-imagelist.css index c9df2904..7e1652cf 100644 --- a/oss/joomla/trunk/administrator/components/com_media/assets/popup-imagelist.css +++ b/oss/joomla/trunk/administrator/components/com_media/assets/popup-imagelist.css @@ -1,54 +1,54 @@ -/** -* @version $Id: popup-imagelist.css 10387 2008-06-03 10:59:16Z pasamio $ -* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. -* @license GNU/GPL, see LICENSE.php -* Joomla! is free software. This version may have been modified pursuant -* to the GNU General Public License, and as distributed it includes or -* is derivative of works licensed under the GNU General Public License or -* other free or open source software licenses. -* See COPYRIGHT.php for copyright notices and details. -*/ - -/** - * ImageManager imagelist styling - * - * @author Johan Janssens - * @package Joomla - * @since 1.5 - * @version 1.0 - */ - - html, body { margin: 0 !important; padding: 0 !important; font: 10px Tahoma, Verdana, sans-serif; } - -.item { float: left; border: 1px solid #ccc; margin: 3px; position: relative; } - -.item a { - display: table-cell !important; - display: block; - width: 80px; height: 90px; - overflow: hidden; - vertical-align: middle; - text-align: center; - text-decoration: none; - color: black; - - line-height: 90px; -} - -.item img { display: inline; margin-top: expression(( 80 - this.height ) / 2);} - -html>body .item img {margin: auto;} - -.item span { - line-height: 100%; - clear:both; - display: block; - width: 100%; - position: absolute; - bottom: 0; - left: 0; - padding: 2px 0; - background-color: #eee; - overflow: hidden; -} - +/** +* @version $Id: popup-imagelist.css 14401 2010-01-26 14:10:00Z louis $ +* @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. +* @license GNU/GPL, see LICENSE.php +* Joomla! is free software. This version may have been modified pursuant +* to the GNU General Public License, and as distributed it includes or +* is derivative of works licensed under the GNU General Public License or +* other free or open source software licenses. +* See COPYRIGHT.php for copyright notices and details. +*/ + +/** + * ImageManager imagelist styling + * + * @author Johan Janssens + * @package Joomla + * @since 1.5 + * @version 1.0 + */ + + html, body { margin: 0 !important; padding: 0 !important; font: 10px Tahoma, Verdana, sans-serif; } + +.item { float: left; border: 1px solid #ccc; margin: 3px; position: relative; } + +.item a { + display: table-cell !important; + display: block; + width: 80px; height: 90px; + overflow: hidden; + vertical-align: middle; + text-align: center; + text-decoration: none; + color: black; + + line-height: 90px; +} + +.item img { display: inline; margin-top: expression(( 80 - this.height ) / 2);} + +html>body .item img {margin: auto;} + +.item span { + line-height: 100%; + clear:both; + display: block; + width: 100%; + position: absolute; + bottom: 0; + left: 0; + padding: 2px 0; + background-color: #eee; + overflow: hidden; +} + diff --git a/oss/joomla/trunk/administrator/components/com_media/assets/popup-imagemanager.css b/oss/joomla/trunk/administrator/components/com_media/assets/popup-imagemanager.css index 362daa73..3f4e42f0 100644 --- a/oss/joomla/trunk/administrator/components/com_media/assets/popup-imagemanager.css +++ b/oss/joomla/trunk/administrator/components/com_media/assets/popup-imagemanager.css @@ -1,114 +1,114 @@ -/** -* @version $Id: popup-imagemanager.css 10387 2008-06-03 10:59:16Z pasamio $ -* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. -* @license GNU/GPL, see LICENSE.php -* Joomla! is free software. This version may have been modified pursuant -* to the GNU General Public License, and as distributed it includes or -* is derivative of works licensed under the GNU General Public License or -* other free or open source software licenses. -* See COPYRIGHT.php for copyright notices and details. -*/ - -/** - * ImageManager javascript behavior styling - * - * @author Johan Janssens - * @package Joomla - * @since 1.5 - * @version 1.0 - */ - -html, body { - background-color: #F0F0F0; - color: ButtonText; - font: 11px Tahoma, Verdana, sans-serif; - margin: 0px !important; padding: 0px !important; -} - -img { border: 0 none; } - -form { padding: 0px; margin: 0 auto; width: 100%; } -fieldset { border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; } -button { padding: 3px; border: 1px solid #CCCCCC; font-weight: bold; color: #0B55C4; background-color: white; } -button:hover { border: 1px solid #0B55C4; } - -select,input,button { font: 11px Tahoma, Verdana, sans-serif; } - -iframe { width: 100%; overflow-x: false; border: 0 none; margin: 0 0 0.5em 0; padding: 0;} -iframe#imageframe { height: 195px; } - -a { padding: 5px; border: 1px solid ButtonFace; } -a:hover { border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight; } - -.buttons { width: 70px; text-align: center; } - -#f_alt, #f_url, #f_title { width: 22em; } - -#messages { - position: relative; - left: 175px; - top: 115px; - background-color: white; - width: 200px; - float: left; - margin-top: -52px; - border: 1px solid #ccc; - text-align: center; - padding: 15px; -} - -#message { - font-size: 15px; - font-weight: bold; - color: #69c; -} - -/** - * Upload Widget CSS - */ -.upload-queue { - list-style: none; -} - -.upload-queue li { - background: url(upload.png) no-repeat 0 5px; - padding: 5px 0 5px 5px; -} - -.upload-queue .queue-file { - font-weight: bold; -} - -.upload-queue .queue-size { - color: #aaa; - margin-left: 1em; - font-size: 0.9em; -} - -.upload-queue .queue-loader { - position: relative; - margin: 3px 15px; - font-size: 0.9em; - background-color: #ddd; - color: #fff; - border: 1px inset #ddd; -} - -.upload-queue .queue-subloader { - text-align: center; - position: absolute; - background-color: #81B466; - height: 100%; - width: 0%; - left: 0; - top: 0; -} - -.upload-queue .input-delete { - width: 16px; - height: 16px; - background: url(delete.png) no-repeat 0 0; - text-decoration: none; - border: none; - float: right; -} +/** +* @version $Id: popup-imagemanager.css 14401 2010-01-26 14:10:00Z louis $ +* @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. +* @license GNU/GPL, see LICENSE.php +* Joomla! is free software. This version may have been modified pursuant +* to the GNU General Public License, and as distributed it includes or +* is derivative of works licensed under the GNU General Public License or +* other free or open source software licenses. +* See COPYRIGHT.php for copyright notices and details. +*/ + +/** + * ImageManager javascript behavior styling + * + * @author Johan Janssens + * @package Joomla + * @since 1.5 + * @version 1.0 + */ + +html, body { + background-color: #F0F0F0; + color: ButtonText; + font: 11px Tahoma, Verdana, sans-serif; + margin: 0px !important; padding: 0px !important; +} + +img { border: 0 none; } + +form { padding: 0px; margin: 0 auto; width: 100%; } +fieldset { border-top: 1px solid #CCCCCC; border-bottom: 1px solid #CCCCCC; } +button { padding: 3px; border: 1px solid #CCCCCC; font-weight: bold; color: #0B55C4; background-color: white; } +button:hover { border: 1px solid #0B55C4; } + +select,input,button { font: 11px Tahoma, Verdana, sans-serif; } + +iframe { width: 100%; overflow-x: false; border: 0 none; margin: 0 0 0.5em 0; padding: 0;} +iframe#imageframe { height: 195px; } + +a { padding: 5px; border: 1px solid ButtonFace; } +a:hover { border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight; } + +.buttons { width: 70px; text-align: center; } + +#f_alt, #f_url, #f_title { width: 22em; } + +#messages { + position: relative; + left: 175px; + top: 115px; + background-color: white; + width: 200px; + float: left; + margin-top: -52px; + border: 1px solid #ccc; + text-align: center; + padding: 15px; +} + +#message { + font-size: 15px; + font-weight: bold; + color: #69c; +} + +/** + * Upload Widget CSS + */ +.upload-queue { + list-style: none; +} + +.upload-queue li { + background: url(upload.png) no-repeat 0 5px; + padding: 5px 0 5px 5px; +} + +.upload-queue .queue-file { + font-weight: bold; +} + +.upload-queue .queue-size { + color: #aaa; + margin-left: 1em; + font-size: 0.9em; +} + +.upload-queue .queue-loader { + position: relative; + margin: 3px 15px; + font-size: 0.9em; + background-color: #ddd; + color: #fff; + border: 1px inset #ddd; +} + +.upload-queue .queue-subloader { + text-align: center; + position: absolute; + background-color: #81B466; + height: 100%; + width: 0%; + left: 0; + top: 0; +} + +.upload-queue .input-delete { + width: 16px; + height: 16px; + background: url(delete.png) no-repeat 0 0; + text-decoration: none; + border: none; + float: right; +} diff --git a/oss/joomla/trunk/administrator/components/com_media/assets/popup-imagemanager.js b/oss/joomla/trunk/administrator/components/com_media/assets/popup-imagemanager.js index eb5532ba..6e740984 100644 --- a/oss/joomla/trunk/administrator/components/com_media/assets/popup-imagemanager.js +++ b/oss/joomla/trunk/administrator/components/com_media/assets/popup-imagemanager.js @@ -1,246 +1,246 @@ -/** -* @version $Id: popup-imagemanager.js 10702 2008-08-21 09:31:31Z eddieajau $ -* @package Joomla -* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. -* @license GNU/GPL, see LICENSE.php -* Joomla! is free software. This version may have been modified pursuant -* to the GNU General Public License, and as distributed it includes or -* is derivative of works licensed under the GNU General Public License or -* other free or open source software licenses. -* See COPYRIGHT.php for copyright notices and details. -*/ - -/** - * JImageManager behavior for media component - * - * @package Joomla.Extensions - * @subpackage Media - * @since 1.5 - */ -var ImageManager = { - initialize: function() - { - o = this._getUriObject(window.self.location.href); - //console.log(o); - q = $H(this._getQueryObject(o.query)); - this.editor = decodeURIComponent(q.get('e_name')); - - // Setup image manager fields object - this.fields = new Object(); - this.fields.url = $("f_url"); - this.fields.alt = $("f_alt"); - this.fields.align = $("f_align"); - this.fields.title = $("f_title"); - this.fields.caption = $("f_caption"); - - // Setup image listing objects - this.folderlist = $('folderlist'); - - this.frame = window.frames['imageframe']; - this.frameurl = this.frame.location.href; - - // Setup imave listing frame - this.imageframe = $('imageframe'); - this.imageframe.manager = this; - this.imageframe.addEvent('load', function(){ ImageManager.onloadimageview(); }); - - // Setup folder up button - this.upbutton = $('upbutton'); - this.upbutton.removeEvents('click'); - this.upbutton.addEvent('click', function(){ ImageManager.upFolder(); }); - }, - - onloadimageview: function() - { - // Update the frame url - this.frameurl = this.frame.location.href; - - var folder = this.getImageFolder(); - for(var i = 0; i < this.folderlist.length; i++) - { - if(folder == this.folderlist.options[i].value) { - this.folderlist.selectedIndex = i; - break; - } - } - - a = this._getUriObject($('uploadForm').getProperty('action')); - //console.log(a); - q = $H(this._getQueryObject(a.query)); - q.set('folder', folder); - var query = []; - q.each(function(v, k){ - if ($chk(v)) { - this.push(k+'='+v); - } - }, query); - a.query = query.join('&'); - $('uploadForm').setProperty('action', a.scheme+'://'+a.domain+a.path+'?'+a.query); - }, - - getImageFolder: function() - { - var url = this.frame.location.search.substring(1); - var args = this.parseQuery(url); - - return args['folder']; - }, - - onok: function() - { - extra = ''; - // Get the image tag field information - var url = this.fields.url.getValue(); - var alt = this.fields.alt.getValue(); - var align = this.fields.align.getValue(); - var title = this.fields.title.getValue(); - var caption = this.fields.caption.getValue(); - - if (url != '') { - // Set alt attribute - if (alt != '') { - extra = extra + 'alt="'+alt+'" '; - } else { - extra = extra + 'alt="" '; - } - // Set align attribute - if (align != '') { - extra = extra + 'align="'+align+'" '; - } - // Set align attribute - if (title != '') { - extra = extra + 'title="'+title+'" '; - } - // Set align attribute - if (caption != '') { - extra = extra + 'class="caption" '; - } - - var tag = ""; - } - - window.parent.jInsertEditorText(tag, this.editor); - return false; - }, - - setFolder: function(folder) - { - //this.showMessage('Loading'); - - for(var i = 0; i < this.folderlist.length; i++) - { - if(folder == this.folderlist.options[i].value) { - this.folderlist.selectedIndex = i; - break; - } - } - this.frame.location.href='index.php?option=com_media&view=imagesList&tmpl=component&folder=' + folder; - }, - - getFolder: function() { - return this.folderlist.getValue(); - }, - - upFolder: function() - { - var currentFolder = this.getFolder(); - if(currentFolder.length < 2) { - return false; - } - - var folders = currentFolder.split('/'); - var search = ''; - - for(var i = 0; i < folders.length - 1; i++) { - search += folders[i]; - search += '/'; - } - - // remove the trailing slash - search = search.substring(0, search.length - 1); - - for(var i = 0; i < this.folderlist.length; i++) - { - var thisFolder = this.folderlist.options[i].value; - - if(thisFolder == search) - { - this.folderlist.selectedIndex = i; - var newFolder = this.folderlist.options[i].value; - this.setFolder(newFolder); - break; - } - } - }, - - populateFields: function(file) - { - $("f_url").value = image_base_path+file; - }, - - showMessage: function(text) - { - var message = $('message'); - var messages = $('messages'); - - if(message.firstChild) - message.removeChild(message.firstChild); - - message.appendChild(document.createTextNode(text)); - messages.style.display = "block"; - }, - - parseQuery: function(query) - { - var params = new Object(); - if (!query) { - return params; - } - var pairs = query.split(/[;&]/); - for ( var i = 0; i < pairs.length; i++ ) - { - var KeyVal = pairs[i].split('='); - if ( ! KeyVal || KeyVal.length != 2 ) { - continue; - } - var key = unescape( KeyVal[0] ); - var val = unescape( KeyVal[1] ).replace(/\+ /g, ' '); - params[key] = val; - } - return params; - }, - - refreshFrame: function() - { - this._setFrameUrl(); - }, - - _setFrameUrl: function(url) - { - if ($chk(url)) { - this.frameurl = url; - } - this.frame.location.href = this.frameurl; - }, - - _getQueryObject: function(q) { - var vars = q.split(/[&;]/); - var rs = {}; - if (vars.length) vars.each(function(val) { - var keys = val.split('='); - if (keys.length && keys.length == 2) rs[encodeURIComponent(keys[0])] = encodeURIComponent(keys[1]); - }); - return rs; - }, - - _getUriObject: function(u){ - var bits = u.match(/^(?:([^:\/?#.]+):)?(?:\/\/)?(([^:\/?#]*)(?::(\d*))?)((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[\?#]|$)))*\/?)?([^?#\/]*))?(?:\?([^#]*))?(?:#(.*))?/); - return (bits) - ? bits.associate(['uri', 'scheme', 'authority', 'domain', 'port', 'path', 'directory', 'file', 'query', 'fragment']) - : null; - } -}; - -window.addEvent('domready', function(){ - ImageManager.initialize(); -}); +/** +* @version $Id: popup-imagemanager.js 14401 2010-01-26 14:10:00Z louis $ +* @package Joomla +* @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. +* @license GNU/GPL, see LICENSE.php +* Joomla! is free software. This version may have been modified pursuant +* to the GNU General Public License, and as distributed it includes or +* is derivative of works licensed under the GNU General Public License or +* other free or open source software licenses. +* See COPYRIGHT.php for copyright notices and details. +*/ + +/** + * JImageManager behavior for media component + * + * @package Joomla.Extensions + * @subpackage Media + * @since 1.5 + */ +var ImageManager = { + initialize: function() + { + o = this._getUriObject(window.self.location.href); + //console.log(o); + q = $H(this._getQueryObject(o.query)); + this.editor = decodeURIComponent(q.get('e_name')); + + // Setup image manager fields object + this.fields = new Object(); + this.fields.url = $("f_url"); + this.fields.alt = $("f_alt"); + this.fields.align = $("f_align"); + this.fields.title = $("f_title"); + this.fields.caption = $("f_caption"); + + // Setup image listing objects + this.folderlist = $('folderlist'); + + this.frame = window.frames['imageframe']; + this.frameurl = this.frame.location.href; + + // Setup imave listing frame + this.imageframe = $('imageframe'); + this.imageframe.manager = this; + this.imageframe.addEvent('load', function(){ ImageManager.onloadimageview(); }); + + // Setup folder up button + this.upbutton = $('upbutton'); + this.upbutton.removeEvents('click'); + this.upbutton.addEvent('click', function(){ ImageManager.upFolder(); }); + }, + + onloadimageview: function() + { + // Update the frame url + this.frameurl = this.frame.location.href; + + var folder = this.getImageFolder(); + for(var i = 0; i < this.folderlist.length; i++) + { + if(folder == this.folderlist.options[i].value) { + this.folderlist.selectedIndex = i; + break; + } + } + + a = this._getUriObject($('uploadForm').getProperty('action')); + //console.log(a); + q = $H(this._getQueryObject(a.query)); + q.set('folder', folder); + var query = []; + q.each(function(v, k){ + if ($chk(v)) { + this.push(k+'='+v); + } + }, query); + a.query = query.join('&'); + $('uploadForm').setProperty('action', a.scheme+'://'+a.domain+a.path+'?'+a.query); + }, + + getImageFolder: function() + { + var url = this.frame.location.search.substring(1); + var args = this.parseQuery(url); + + return args['folder']; + }, + + onok: function() + { + extra = ''; + // Get the image tag field information + var url = this.fields.url.getValue(); + var alt = this.fields.alt.getValue(); + var align = this.fields.align.getValue(); + var title = this.fields.title.getValue(); + var caption = this.fields.caption.getValue(); + + if (url != '') { + // Set alt attribute + if (alt != '') { + extra = extra + 'alt="'+alt+'" '; + } else { + extra = extra + 'alt="" '; + } + // Set align attribute + if (align != '') { + extra = extra + 'align="'+align+'" '; + } + // Set align attribute + if (title != '') { + extra = extra + 'title="'+title+'" '; + } + // Set align attribute + if (caption != '') { + extra = extra + 'class="caption" '; + } + + var tag = ""; + } + + window.parent.jInsertEditorText(tag, this.editor); + return false; + }, + + setFolder: function(folder) + { + //this.showMessage('Loading'); + + for(var i = 0; i < this.folderlist.length; i++) + { + if(folder == this.folderlist.options[i].value) { + this.folderlist.selectedIndex = i; + break; + } + } + this.frame.location.href='index.php?option=com_media&view=imagesList&tmpl=component&folder=' + folder; + }, + + getFolder: function() { + return this.folderlist.getValue(); + }, + + upFolder: function() + { + var currentFolder = this.getFolder(); + if(currentFolder.length < 2) { + return false; + } + + var folders = currentFolder.split('/'); + var search = ''; + + for(var i = 0; i < folders.length - 1; i++) { + search += folders[i]; + search += '/'; + } + + // remove the trailing slash + search = search.substring(0, search.length - 1); + + for(var i = 0; i < this.folderlist.length; i++) + { + var thisFolder = this.folderlist.options[i].value; + + if(thisFolder == search) + { + this.folderlist.selectedIndex = i; + var newFolder = this.folderlist.options[i].value; + this.setFolder(newFolder); + break; + } + } + }, + + populateFields: function(file) + { + $("f_url").value = image_base_path+file; + }, + + showMessage: function(text) + { + var message = $('message'); + var messages = $('messages'); + + if(message.firstChild) + message.removeChild(message.firstChild); + + message.appendChild(document.createTextNode(text)); + messages.style.display = "block"; + }, + + parseQuery: function(query) + { + var params = new Object(); + if (!query) { + return params; + } + var pairs = query.split(/[;&]/); + for ( var i = 0; i < pairs.length; i++ ) + { + var KeyVal = pairs[i].split('='); + if ( ! KeyVal || KeyVal.length != 2 ) { + continue; + } + var key = unescape( KeyVal[0] ); + var val = unescape( KeyVal[1] ).replace(/\+ /g, ' '); + params[key] = val; + } + return params; + }, + + refreshFrame: function() + { + this._setFrameUrl(); + }, + + _setFrameUrl: function(url) + { + if ($chk(url)) { + this.frameurl = url; + } + this.frame.location.href = this.frameurl; + }, + + _getQueryObject: function(q) { + var vars = q.split(/[&;]/); + var rs = {}; + if (vars.length) vars.each(function(val) { + var keys = val.split('='); + if (keys.length && keys.length == 2) rs[encodeURIComponent(keys[0])] = encodeURIComponent(keys[1]); + }); + return rs; + }, + + _getUriObject: function(u){ + var bits = u.match(/^(?:([^:\/?#.]+):)?(?:\/\/)?(([^:\/?#]*)(?::(\d*))?)((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[\?#]|$)))*\/?)?([^?#\/]*))?(?:\?([^#]*))?(?:#(.*))?/); + return (bits) + ? bits.associate(['uri', 'scheme', 'authority', 'domain', 'port', 'path', 'directory', 'file', 'query', 'fragment']) + : null; + } +}; + +window.addEvent('domready', function(){ + ImageManager.initialize(); +}); diff --git a/oss/joomla/trunk/administrator/components/com_media/controller.php b/oss/joomla/trunk/administrator/components/com_media/controller.php index d9263d4c..a8101b35 100644 --- a/oss/joomla/trunk/administrator/components/com_media/controller.php +++ b/oss/joomla/trunk/administrator/components/com_media/controller.php @@ -1,90 +1,90 @@ -getUserStateFromRequest('media.list.layout', 'layout', 'thumbs', 'word'); - - break; - - case 'media': - default: - $vName = 'media'; - $vLayout = JRequest::getCmd( 'layout', 'default' ); - $mName = 'manager'; - break; - } - - $document = &JFactory::getDocument(); - $vType = $document->getType(); - - // Get/Create the view - $view = &$this->getView( $vName, $vType); - - // Get/Create the model - if ($model = &$this->getModel($mName)) { - // Push the model into the view (as default) - $view->setModel($model, true); - } - - // Set the layout - $view->setLayout($vLayout); - - // Display the view - $view->display(); - } - - function ftpValidate() - { - // Set FTP credentials, if given - jimport('joomla.client.helper'); - JClientHelper::setCredentialsFromRequest('ftp'); - } -} +getUserStateFromRequest('media.list.layout', 'layout', 'thumbs', 'word'); + + break; + + case 'media': + default: + $vName = 'media'; + $vLayout = JRequest::getCmd( 'layout', 'default' ); + $mName = 'manager'; + break; + } + + $document = &JFactory::getDocument(); + $vType = $document->getType(); + + // Get/Create the view + $view = &$this->getView( $vName, $vType); + + // Get/Create the model + if ($model = &$this->getModel($mName)) { + // Push the model into the view (as default) + $view->setModel($model, true); + } + + // Set the layout + $view->setLayout($vLayout); + + // Display the view + $view->display(); + } + + function ftpValidate() + { + // Set FTP credentials, if given + jimport('joomla.client.helper'); + JClientHelper::setCredentialsFromRequest('ftp'); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_media/controllers/file.php b/oss/joomla/trunk/administrator/components/com_media/controllers/file.php index d13d6820..14914e04 100644 --- a/oss/joomla/trunk/administrator/components/com_media/controllers/file.php +++ b/oss/joomla/trunk/administrator/components/com_media/controllers/file.php @@ -1,188 +1,188 @@ -addEntry(array('comment' => 'Invalid: '.$filepath.': '.$err)); - header('HTTP/1.0 415 Unsupported Media Type'); - jexit('Error. Unsupported Media Type!'); - } else { - JError::raiseNotice(100, JText::_($err)); - // REDIRECT - if ($return) { - $mainframe->redirect(base64_decode($return).'&folder='.$folder); - } - return; - } - } - - if (JFile::exists($filepath)) { - if ($format == 'json') { - jimport('joomla.error.log'); - $log = &JLog::getInstance('upload.error.php'); - $log->addEntry(array('comment' => 'File already exists: '.$filepath)); - header('HTTP/1.0 409 Conflict'); - jexit('Error. File already exists'); - } else { - JError::raiseNotice(100, JText::_('Error. File already exists')); - // REDIRECT - if ($return) { - $mainframe->redirect(base64_decode($return).'&folder='.$folder); - } - return; - } - } - - if (!JFile::upload($file['tmp_name'], $filepath)) { - if ($format == 'json') { - jimport('joomla.error.log'); - $log = &JLog::getInstance('upload.error.php'); - $log->addEntry(array('comment' => 'Cannot upload: '.$filepath)); - header('HTTP/1.0 400 Bad Request'); - jexit('Error. Unable to upload file'); - } else { - JError::raiseWarning(100, JText::_('Error. Unable to upload file')); - // REDIRECT - if ($return) { - $mainframe->redirect(base64_decode($return).'&folder='.$folder); - } - return; - } - } else { - if ($format == 'json') { - jimport('joomla.error.log'); - $log = &JLog::getInstance(); - $log->addEntry(array('comment' => $folder)); - jexit('Upload complete'); - } else { - $mainframe->enqueueMessage(JText::_('Upload complete')); - // REDIRECT - if ($return) { - $mainframe->redirect(base64_decode($return).'&folder='.$folder); - } - return; - } - } - } else { - $mainframe->redirect('index.php', 'Invalid Request', 'error'); - } - } - - /** - * Deletes paths from the current path - * - * @param string $listFolder The image directory to delete a file from - * @since 1.5 - */ - function delete() - { - global $mainframe; - - JRequest::checkToken( 'request' ) or jexit( 'Invalid Token' ); - - // Set FTP credentials, if given - jimport('joomla.client.helper'); - JClientHelper::setCredentialsFromRequest('ftp'); - - // Get some data from the request - $tmpl = JRequest::getCmd( 'tmpl' ); - $paths = JRequest::getVar( 'rm', array(), '', 'array' ); - $folder = JRequest::getVar( 'folder', '', '', 'path'); - - // Initialize variables - $msg = array(); - $ret = true; - - if (count($paths)) { - foreach ($paths as $path) - { - if ($path !== JFile::makeSafe($path)) { - JError::raiseWarning(100, JText::_('Unable to delete:').htmlspecialchars($path, ENT_COMPAT, 'UTF-8').' '.JText::_('WARNFILENAME')); - continue; - } - - $fullPath = JPath::clean(COM_MEDIA_BASE.DS.$folder.DS.$path); - if (is_file($fullPath)) { - $ret |= !JFile::delete($fullPath); - } else if (is_dir($fullPath)) { - $files = JFolder::files($fullPath, '.', true); - $canDelete = true; - foreach ($files as $file) { - if ($file != 'index.html') { - $canDelete = false; - } - } - if ($canDelete) { - $ret |= !JFolder::delete($fullPath); - } else { - JError::raiseWarning(100, JText::_('Unable to delete:').$fullPath.' '.JText::_('Not Empty!')); - } - } - } - } - if ($tmpl == 'component') { - // We are inside the iframe - $mainframe->redirect('index.php?option=com_media&view=mediaList&folder='.$folder.'&tmpl=component'); - } else { - $mainframe->redirect('index.php?option=com_media&folder='.$folder); - } - } -} +addEntry(array('comment' => 'Invalid: '.$filepath.': '.$err)); + header('HTTP/1.0 415 Unsupported Media Type'); + jexit('Error. Unsupported Media Type!'); + } else { + JError::raiseNotice(100, JText::_($err)); + // REDIRECT + if ($return) { + $mainframe->redirect(base64_decode($return).'&folder='.$folder); + } + return; + } + } + + if (JFile::exists($filepath)) { + if ($format == 'json') { + jimport('joomla.error.log'); + $log = &JLog::getInstance('upload.error.php'); + $log->addEntry(array('comment' => 'File already exists: '.$filepath)); + header('HTTP/1.0 409 Conflict'); + jexit('Error. File already exists'); + } else { + JError::raiseNotice(100, JText::_('Error. File already exists')); + // REDIRECT + if ($return) { + $mainframe->redirect(base64_decode($return).'&folder='.$folder); + } + return; + } + } + + if (!JFile::upload($file['tmp_name'], $filepath)) { + if ($format == 'json') { + jimport('joomla.error.log'); + $log = &JLog::getInstance('upload.error.php'); + $log->addEntry(array('comment' => 'Cannot upload: '.$filepath)); + header('HTTP/1.0 400 Bad Request'); + jexit('Error. Unable to upload file'); + } else { + JError::raiseWarning(100, JText::_('Error. Unable to upload file')); + // REDIRECT + if ($return) { + $mainframe->redirect(base64_decode($return).'&folder='.$folder); + } + return; + } + } else { + if ($format == 'json') { + jimport('joomla.error.log'); + $log = &JLog::getInstance(); + $log->addEntry(array('comment' => $folder)); + jexit('Upload complete'); + } else { + $mainframe->enqueueMessage(JText::_('Upload complete')); + // REDIRECT + if ($return) { + $mainframe->redirect(base64_decode($return).'&folder='.$folder); + } + return; + } + } + } else { + $mainframe->redirect('index.php', 'Invalid Request', 'error'); + } + } + + /** + * Deletes paths from the current path + * + * @param string $listFolder The image directory to delete a file from + * @since 1.5 + */ + function delete() + { + global $mainframe; + + JRequest::checkToken( 'request' ) or jexit( 'Invalid Token' ); + + // Set FTP credentials, if given + jimport('joomla.client.helper'); + JClientHelper::setCredentialsFromRequest('ftp'); + + // Get some data from the request + $tmpl = JRequest::getCmd( 'tmpl' ); + $paths = JRequest::getVar( 'rm', array(), '', 'array' ); + $folder = JRequest::getVar( 'folder', '', '', 'path'); + + // Initialize variables + $msg = array(); + $ret = true; + + if (count($paths)) { + foreach ($paths as $path) + { + if ($path !== JFile::makeSafe($path)) { + JError::raiseWarning(100, JText::_('Unable to delete:').htmlspecialchars($path, ENT_COMPAT, 'UTF-8').' '.JText::_('WARNFILENAME')); + continue; + } + + $fullPath = JPath::clean(COM_MEDIA_BASE.DS.$folder.DS.$path); + if (is_file($fullPath)) { + $ret |= !JFile::delete($fullPath); + } else if (is_dir($fullPath)) { + $files = JFolder::files($fullPath, '.', true); + $canDelete = true; + foreach ($files as $file) { + if ($file != 'index.html') { + $canDelete = false; + } + } + if ($canDelete) { + $ret |= !JFolder::delete($fullPath); + } else { + JError::raiseWarning(100, JText::_('Unable to delete:').$fullPath.' '.JText::_('Not Empty!')); + } + } + } + } + if ($tmpl == 'component') { + // We are inside the iframe + $mainframe->redirect('index.php?option=com_media&view=mediaList&folder='.$folder.'&tmpl=component'); + } else { + $mainframe->redirect('index.php?option=com_media&folder='.$folder); + } + } +} diff --git a/oss/joomla/trunk/administrator/components/com_media/controllers/folder.php b/oss/joomla/trunk/administrator/components/com_media/controllers/folder.php index 7a53b6cd..2bb47e0d 100644 --- a/oss/joomla/trunk/administrator/components/com_media/controllers/folder.php +++ b/oss/joomla/trunk/administrator/components/com_media/controllers/folder.php @@ -1,130 +1,130 @@ -redirect('index.php?option=com_media&view=mediaList&folder='.$folder.'&tmpl=component'); - } else { - $mainframe->redirect('index.php?option=com_media&folder='.$folder); - } - } - - /** - * Create a folder - * - * @param string $path Path of the folder to create - * @since 1.5 - */ - function create() - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Set FTP credentials, if given - jimport('joomla.client.helper'); - JClientHelper::setCredentialsFromRequest('ftp'); - - $folder = JRequest::getCmd( 'foldername', ''); - $folderCheck = JRequest::getVar( 'foldername', null, '', 'string', JREQUEST_ALLOWRAW); - $parent = JRequest::getVar( 'folderbase', '', '', 'path' ); - - JRequest::setVar('folder', $parent); - - if (($folderCheck !== null) && ($folder !== $folderCheck)) { - $mainframe->redirect('index.php?option=com_media&folder='.$parent, JText::_('WARNDIRNAME')); - } - - if (strlen($folder) > 0) { - $path = JPath::clean(COM_MEDIA_BASE.DS.$parent.DS.$folder); - if (!is_dir($path) && !is_file($path)) - { - jimport('joomla.filesystem.*'); - JFolder::create($path); - JFile::write($path.DS."index.html", "\n\n\n"); - } - JRequest::setVar('folder', ($parent) ? $parent.'/'.$folder : $folder); - } - $mainframe->redirect('index.php?option=com_media&folder='.$parent); - } -} +redirect('index.php?option=com_media&view=mediaList&folder='.$folder.'&tmpl=component'); + } else { + $mainframe->redirect('index.php?option=com_media&folder='.$folder); + } + } + + /** + * Create a folder + * + * @param string $path Path of the folder to create + * @since 1.5 + */ + function create() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Set FTP credentials, if given + jimport('joomla.client.helper'); + JClientHelper::setCredentialsFromRequest('ftp'); + + $folder = JRequest::getCmd( 'foldername', ''); + $folderCheck = JRequest::getVar( 'foldername', null, '', 'string', JREQUEST_ALLOWRAW); + $parent = JRequest::getVar( 'folderbase', '', '', 'path' ); + + JRequest::setVar('folder', $parent); + + if (($folderCheck !== null) && ($folder !== $folderCheck)) { + $mainframe->redirect('index.php?option=com_media&folder='.$parent, JText::_('WARNDIRNAME')); + } + + if (strlen($folder) > 0) { + $path = JPath::clean(COM_MEDIA_BASE.DS.$parent.DS.$folder); + if (!is_dir($path) && !is_file($path)) + { + jimport('joomla.filesystem.*'); + JFolder::create($path); + JFile::write($path.DS."index.html", "\n\n\n"); + } + JRequest::setVar('folder', ($parent) ? $parent.'/'.$folder : $folder); + } + $mainframe->redirect('index.php?option=com_media&folder='.$parent); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_media/helpers/media.php b/oss/joomla/trunk/administrator/components/com_media/helpers/media.php index cbf469fb..a33bc528 100644 --- a/oss/joomla/trunk/administrator/components/com_media/helpers/media.php +++ b/oss/joomla/trunk/administrator/components/com_media/helpers/media.php @@ -1,186 +1,186 @@ -get( 'upload_extensions' )); - $ignored = explode(',', $params->get( 'ignore_extensions' )); - if (!in_array($format, $allowable) && !in_array($format,$ignored)) - { - $err = 'WARNFILETYPE'; - return false; - } - - $maxSize = (int) $params->get( 'upload_maxsize', 0 ); - if ($maxSize > 0 && (int) $file['size'] > $maxSize) - { - $err = 'WARNFILETOOLARGE'; - return false; - } - - $user = JFactory::getUser(); - $imginfo = null; - if($params->get('restrict_uploads',1) ) { - $images = explode( ',', $params->get( 'image_extensions' )); - if(in_array($format, $images)) { // if its an image run it through getimagesize - if(($imginfo = getimagesize($file['tmp_name'])) === FALSE) { - $err = 'WARNINVALIDIMG'; - return false; - } - } else if(!in_array($format, $ignored)) { - // if its not an image...and we're not ignoring it - $allowed_mime = explode(',', $params->get('upload_mime')); - $illegal_mime = explode(',', $params->get('upload_mime_illegal')); - if(function_exists('finfo_open') && $params->get('check_mime',1)) { - // We have fileinfo - $finfo = finfo_open(FILEINFO_MIME); - $type = finfo_file($finfo, $file['tmp_name']); - if(strlen($type) && !in_array($type, $allowed_mime) && in_array($type, $illegal_mime)) { - $err = 'WARNINVALIDMIME'; - return false; - } - finfo_close($finfo); - } else if(function_exists('mime_content_type') && $params->get('check_mime',1)) { - // we have mime magic - $type = mime_content_type($file['tmp_name']); - if(strlen($type) && !in_array($type, $allowed_mime) && in_array($type, $illegal_mime)) { - $err = 'WARNINVALIDMIME'; - return false; - } - } else if(!$user->authorize( 'login', 'administrator' )) { - $err = 'WARNNOTADMIN'; - return false; - } - } - } - - $xss_check = JFile::read($file['tmp_name'],false,256); - $html_tags = array('abbr','acronym','address','applet','area','audioscope','base','basefont','bdo','bgsound','big','blackface','blink','blockquote','body','bq','br','button','caption','center','cite','code','col','colgroup','comment','custom','dd','del','dfn','dir','div','dl','dt','em','embed','fieldset','fn','font','form','frame','frameset','h1','h2','h3','h4','h5','h6','head','hr','html','iframe','ilayer','img','input','ins','isindex','keygen','kbd','label','layer','legend','li','limittext','link','listing','map','marquee','menu','meta','multicol','nobr','noembed','noframes','noscript','nosmartquotes','object','ol','optgroup','option','param','plaintext','pre','rt','ruby','s','samp','script','select','server','shadow','sidebar','small','spacer','span','strike','strong','style','sub','sup','table','tbody','td','textarea','tfoot','th','thead','title','tr','tt','ul','var','wbr','xml','xmp','!DOCTYPE', '!--'); - foreach($html_tags as $tag) { - // A tag is '' - if(stristr($xss_check, '<'.$tag.' ') || stristr($xss_check, '<'.$tag.'>')) { - $err = 'WARNIEXSS'; - return false; - } - } - return true; - } - - function parseSize($size) - { - if ($size < 1024) { - return $size . ' bytes'; - } - else - { - if ($size >= 1024 && $size < 1024 * 1024) { - return sprintf('%01.2f', $size / 1024.0) . ' Kb'; - } else { - return sprintf('%01.2f', $size / (1024.0 * 1024)) . ' Mb'; - } - } - } - - function imageResize($width, $height, $target) - { - //takes the larger size of the width and height and applies the - //formula accordingly...this is so this script will work - //dynamically with any size image - if ($width > $height) { - $percentage = ($target / $width); - } else { - $percentage = ($target / $height); - } - - //gets the new value and applies the percentage, then rounds the value - $width = round($width * $percentage); - $height = round($height * $percentage); - - return array($width, $height); - } - - function countFiles( $dir ) - { - $total_file = 0; - $total_dir = 0; - - if (is_dir($dir)) { - $d = dir($dir); - - while (false !== ($entry = $d->read())) { - if (substr($entry, 0, 1) != '.' && is_file($dir . DIRECTORY_SEPARATOR . $entry) && strpos($entry, '.html') === false && strpos($entry, '.php') === false) { - $total_file++; - } - if (substr($entry, 0, 1) != '.' && is_dir($dir . DIRECTORY_SEPARATOR . $entry)) { - $total_dir++; - } - } - - $d->close(); - } - - return array ( $total_file, $total_dir ); - } - +get( 'upload_extensions' )); + $ignored = explode(',', $params->get( 'ignore_extensions' )); + if (!in_array($format, $allowable) && !in_array($format,$ignored)) + { + $err = 'WARNFILETYPE'; + return false; + } + + $maxSize = (int) $params->get( 'upload_maxsize', 0 ); + if ($maxSize > 0 && (int) $file['size'] > $maxSize) + { + $err = 'WARNFILETOOLARGE'; + return false; + } + + $user = JFactory::getUser(); + $imginfo = null; + if($params->get('restrict_uploads',1) ) { + $images = explode( ',', $params->get( 'image_extensions' )); + if(in_array($format, $images)) { // if its an image run it through getimagesize + if(($imginfo = getimagesize($file['tmp_name'])) === FALSE) { + $err = 'WARNINVALIDIMG'; + return false; + } + } else if(!in_array($format, $ignored)) { + // if its not an image...and we're not ignoring it + $allowed_mime = explode(',', $params->get('upload_mime')); + $illegal_mime = explode(',', $params->get('upload_mime_illegal')); + if(function_exists('finfo_open') && $params->get('check_mime',1)) { + // We have fileinfo + $finfo = finfo_open(FILEINFO_MIME); + $type = finfo_file($finfo, $file['tmp_name']); + if(strlen($type) && !in_array($type, $allowed_mime) && in_array($type, $illegal_mime)) { + $err = 'WARNINVALIDMIME'; + return false; + } + finfo_close($finfo); + } else if(function_exists('mime_content_type') && $params->get('check_mime',1)) { + // we have mime magic + $type = mime_content_type($file['tmp_name']); + if(strlen($type) && !in_array($type, $allowed_mime) && in_array($type, $illegal_mime)) { + $err = 'WARNINVALIDMIME'; + return false; + } + } else if(!$user->authorize( 'login', 'administrator' )) { + $err = 'WARNNOTADMIN'; + return false; + } + } + } + + $xss_check = JFile::read($file['tmp_name'],false,256); + $html_tags = array('abbr','acronym','address','applet','area','audioscope','base','basefont','bdo','bgsound','big','blackface','blink','blockquote','body','bq','br','button','caption','center','cite','code','col','colgroup','comment','custom','dd','del','dfn','dir','div','dl','dt','em','embed','fieldset','fn','font','form','frame','frameset','h1','h2','h3','h4','h5','h6','head','hr','html','iframe','ilayer','img','input','ins','isindex','keygen','kbd','label','layer','legend','li','limittext','link','listing','map','marquee','menu','meta','multicol','nobr','noembed','noframes','noscript','nosmartquotes','object','ol','optgroup','option','param','plaintext','pre','rt','ruby','s','samp','script','select','server','shadow','sidebar','small','spacer','span','strike','strong','style','sub','sup','table','tbody','td','textarea','tfoot','th','thead','title','tr','tt','ul','var','wbr','xml','xmp','!DOCTYPE', '!--'); + foreach($html_tags as $tag) { + // A tag is '' + if(stristr($xss_check, '<'.$tag.' ') || stristr($xss_check, '<'.$tag.'>')) { + $err = 'WARNIEXSS'; + return false; + } + } + return true; + } + + function parseSize($size) + { + if ($size < 1024) { + return $size . ' bytes'; + } + else + { + if ($size >= 1024 && $size < 1024 * 1024) { + return sprintf('%01.2f', $size / 1024.0) . ' Kb'; + } else { + return sprintf('%01.2f', $size / (1024.0 * 1024)) . ' Mb'; + } + } + } + + function imageResize($width, $height, $target) + { + //takes the larger size of the width and height and applies the + //formula accordingly...this is so this script will work + //dynamically with any size image + if ($width > $height) { + $percentage = ($target / $width); + } else { + $percentage = ($target / $height); + } + + //gets the new value and applies the percentage, then rounds the value + $width = round($width * $percentage); + $height = round($height * $percentage); + + return array($width, $height); + } + + function countFiles( $dir ) + { + $total_file = 0; + $total_dir = 0; + + if (is_dir($dir)) { + $d = dir($dir); + + while (false !== ($entry = $d->read())) { + if (substr($entry, 0, 1) != '.' && is_file($dir . DIRECTORY_SEPARATOR . $entry) && strpos($entry, '.html') === false && strpos($entry, '.php') === false) { + $total_file++; + } + if (substr($entry, 0, 1) != '.' && is_dir($dir . DIRECTORY_SEPARATOR . $entry)) { + $total_dir++; + } + } + + $d->close(); + } + + return array ( $total_file, $total_dir ); + } + } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_media/media.php b/oss/joomla/trunk/administrator/components/com_media/media.php index 56a96c66..e515f134 100644 --- a/oss/joomla/trunk/administrator/components/com_media/media.php +++ b/oss/joomla/trunk/administrator/components/com_media/media.php @@ -1,77 +1,77 @@ -authorize( 'com_media', 'manage' )) { - $mainframe->redirect('index.php', JText::_('ALERTNOTAUTH')); -} - -$params =& JComponentHelper::getParams('com_media'); - -// Load the admin HTML view -require_once( JPATH_COMPONENT.DS.'helpers'.DS.'media.php' ); - -// Set the path definitions -$view = JRequest::getCmd('view',null); -$popup_upload = JRequest::getCmd('pop_up',null); -$path = "file_path"; -if(substr(strtolower($view),0,6) == "images" || $popup_upload == 1) $path = "image_path"; -define('COM_MEDIA_BASE', JPATH_ROOT.DS.$params->get($path, 'images/stories')); -define('COM_MEDIA_BASEURL', JURI::root().$params->get($path, 'images/stories')); - -// Require the base controller -require_once (JPATH_COMPONENT.DS.'controller.php'); - -$cmd = JRequest::getCmd('task', null); - -if (strpos($cmd, '.') != false) -{ - // We have a defined controller/task pair -- lets split them out - list($controllerName, $task) = explode('.', $cmd); - - // Define the controller name and path - $controllerName = strtolower($controllerName); - $controllerPath = JPATH_COMPONENT.DS.'controllers'.DS.$controllerName.'.php'; - - // If the controller file path exists, include it ... else lets die with a 500 error - if (file_exists($controllerPath)) { - require_once($controllerPath); - } else { - JError::raiseError(500, 'Invalid Controller'); - } -} -else -{ - // Base controller, just set the task :) - $controllerName = null; - $task = $cmd; -} - -// Set the name for the controller and instantiate it -$controllerClass = 'MediaController'.ucfirst($controllerName); -if (class_exists($controllerClass)) { - $controller = new $controllerClass(); -} else { - JError::raiseError(500, 'Invalid Controller Class'); -} - -// Perform the Request task -$controller->execute($task); - -// Redirect if set by the controller -$controller->redirect(); +authorize( 'com_media', 'manage' )) { + $mainframe->redirect('index.php', JText::_('ALERTNOTAUTH')); +} + +$params =& JComponentHelper::getParams('com_media'); + +// Load the admin HTML view +require_once( JPATH_COMPONENT.DS.'helpers'.DS.'media.php' ); + +// Set the path definitions +$view = JRequest::getCmd('view',null); +$popup_upload = JRequest::getCmd('pop_up',null); +$path = "file_path"; +if(substr(strtolower($view),0,6) == "images" || $popup_upload == 1) $path = "image_path"; +define('COM_MEDIA_BASE', JPath::clean(JPATH_ROOT.DS.$params->get($path, 'images'.DS.'stories'))); +define('COM_MEDIA_BASEURL', JURI::root().$params->get($path, 'images/stories')); + +// Require the base controller +require_once (JPATH_COMPONENT.DS.'controller.php'); + +$cmd = JRequest::getCmd('task', null); + +if (strpos($cmd, '.') != false) +{ + // We have a defined controller/task pair -- lets split them out + list($controllerName, $task) = explode('.', $cmd); + + // Define the controller name and path + $controllerName = strtolower($controllerName); + $controllerPath = JPATH_COMPONENT.DS.'controllers'.DS.$controllerName.'.php'; + + // If the controller file path exists, include it ... else lets die with a 500 error + if (file_exists($controllerPath)) { + require_once($controllerPath); + } else { + JError::raiseError(500, 'Invalid Controller'); + } +} +else +{ + // Base controller, just set the task :) + $controllerName = null; + $task = $cmd; +} + +// Set the name for the controller and instantiate it +$controllerClass = 'MediaController'.ucfirst($controllerName); +if (class_exists($controllerClass)) { + $controller = new $controllerClass(); +} else { + JError::raiseError(500, 'Invalid Controller Class'); +} + +// Perform the Request task +$controller->execute($task); + +// Redirect if set by the controller +$controller->redirect(); diff --git a/oss/joomla/trunk/administrator/components/com_media/media.xml b/oss/joomla/trunk/administrator/components/com_media/media.xml index a47c39db..882d6f79 100644 --- a/oss/joomla/trunk/administrator/components/com_media/media.xml +++ b/oss/joomla/trunk/administrator/components/com_media/media.xml @@ -1,12 +1,12 @@ - - - Media Manager - Joomla! Project - April 2006 - Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - admin@joomla.org - www.joomla.org - 1.5.0 - This component manages site media - + + + Media Manager + Joomla! Project + April 2006 + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + This component manages site media + diff --git a/oss/joomla/trunk/administrator/components/com_media/models/list.php b/oss/joomla/trunk/administrator/components/com_media/models/list.php index 6420a4b7..8da8e89d 100644 --- a/oss/joomla/trunk/administrator/components/com_media/models/list.php +++ b/oss/joomla/trunk/administrator/components/com_media/models/list.php @@ -1,194 +1,194 @@ -setState('folder', $folder); - - $parent = str_replace("\\", "/", dirname($folder)); - $parent = ($parent == '.') ? null : $parent; - $this->setState('parent', $parent); - $set = true; - } - return parent::getState($property); - } - - function getImages() - { - $list = $this->getList(); - return $list['images']; - } - - function getFolders() - { - $list = $this->getList(); - return $list['folders']; - } - - function getDocuments() - { - $list = $this->getList(); - return $list['docs']; - } - - /** - * Build imagelist - * - * @param string $listFolder The image directory to display - * @since 1.5 - */ - function getList() - { - static $list; - - // Only process the list once per request - if (is_array($list)) { - return $list; - } - - // Get current path from request - $current = $this->getState('folder'); - - // If undefined, set to empty - if ($current == 'undefined') { - $current = ''; - } - - // Initialize variables - if (strlen($current) > 0) { - $basePath = COM_MEDIA_BASE.DS.$current; - } else { - $basePath = COM_MEDIA_BASE; - } - $mediaBase = str_replace(DS, '/', COM_MEDIA_BASE.'/'); - - $images = array (); - $folders = array (); - $docs = array (); - - // Get the list of files and folders from the given folder - $fileList = JFolder::files($basePath); - $folderList = JFolder::folders($basePath); - - // Iterate over the files if they exist - if ($fileList !== false) { - foreach ($fileList as $file) - { - if (is_file($basePath.DS.$file) && substr($file, 0, 1) != '.' && strtolower($file) !== 'index.html') { - $tmp = new JObject(); - $tmp->name = $file; - $tmp->path = str_replace(DS, '/', JPath::clean($basePath.DS.$file)); - $tmp->path_relative = str_replace($mediaBase, '', $tmp->path); - $tmp->size = filesize($tmp->path); - - $ext = strtolower(JFile::getExt($file)); - switch ($ext) - { - // Image - case 'jpg': - case 'png': - case 'gif': - case 'xcf': - case 'odg': - case 'bmp': - case 'jpeg': - $info = @getimagesize($tmp->path); - $tmp->width = @$info[0]; - $tmp->height = @$info[1]; - $tmp->type = @$info[2]; - $tmp->mime = @$info['mime']; - - $filesize = MediaHelper::parseSize($tmp->size); - - if (($info[0] > 60) || ($info[1] > 60)) { - $dimensions = MediaHelper::imageResize($info[0], $info[1], 60); - $tmp->width_60 = $dimensions[0]; - $tmp->height_60 = $dimensions[1]; - } else { - $tmp->width_60 = $tmp->width; - $tmp->height_60 = $tmp->height; - } - - if (($info[0] > 16) || ($info[1] > 16)) { - $dimensions = MediaHelper::imageResize($info[0], $info[1], 16); - $tmp->width_16 = $dimensions[0]; - $tmp->height_16 = $dimensions[1]; - } else { - $tmp->width_16 = $tmp->width; - $tmp->height_16 = $tmp->height; - } - $images[] = $tmp; - break; - // Non-image document - default: - $iconfile_32 = JPATH_ADMINISTRATOR.DS."components".DS."com_media".DS."images".DS."mime-icon-32".DS.$ext.".png"; - if (file_exists($iconfile_32)) { - $tmp->icon_32 = "components/com_media/images/mime-icon-32/".$ext.".png"; - } else { - $tmp->icon_32 = "components/com_media/images/con_info.png"; - } - $iconfile_16 = JPATH_ADMINISTRATOR.DS."components".DS."com_media".DS."images".DS."mime-icon-16".DS.$ext.".png"; - if (file_exists($iconfile_16)) { - $tmp->icon_16 = "components/com_media/images/mime-icon-16/".$ext.".png"; - } else { - $tmp->icon_16 = "components/com_media/images/con_info.png"; - } - $docs[] = $tmp; - break; - } - } - } - } - - // Iterate over the folders if they exist - if ($folderList !== false) { - foreach ($folderList as $folder) { - $tmp = new JObject(); - $tmp->name = basename($folder); - $tmp->path = str_replace(DS, '/', JPath::clean($basePath.DS.$folder)); - $tmp->path_relative = str_replace($mediaBase, '', $tmp->path); - $count = MediaHelper::countFiles($tmp->path); - $tmp->files = $count[0]; - $tmp->folders = $count[1]; - - $folders[] = $tmp; - } - } - - $list = array('folders' => $folders, 'docs' => $docs, 'images' => $images); - - return $list; - } +setState('folder', $folder); + + $parent = str_replace("\\", "/", dirname($folder)); + $parent = ($parent == '.') ? null : $parent; + $this->setState('parent', $parent); + $set = true; + } + return parent::getState($property); + } + + function getImages() + { + $list = $this->getList(); + return $list['images']; + } + + function getFolders() + { + $list = $this->getList(); + return $list['folders']; + } + + function getDocuments() + { + $list = $this->getList(); + return $list['docs']; + } + + /** + * Build imagelist + * + * @param string $listFolder The image directory to display + * @since 1.5 + */ + function getList() + { + static $list; + + // Only process the list once per request + if (is_array($list)) { + return $list; + } + + // Get current path from request + $current = $this->getState('folder'); + + // If undefined, set to empty + if ($current == 'undefined') { + $current = ''; + } + + // Initialize variables + if (strlen($current) > 0) { + $basePath = COM_MEDIA_BASE.DS.$current; + } else { + $basePath = COM_MEDIA_BASE; + } + $mediaBase = str_replace(DS, '/', COM_MEDIA_BASE.'/'); + + $images = array (); + $folders = array (); + $docs = array (); + + // Get the list of files and folders from the given folder + $fileList = JFolder::files($basePath); + $folderList = JFolder::folders($basePath); + + // Iterate over the files if they exist + if ($fileList !== false) { + foreach ($fileList as $file) + { + if (is_file($basePath.DS.$file) && substr($file, 0, 1) != '.' && strtolower($file) !== 'index.html') { + $tmp = new JObject(); + $tmp->name = $file; + $tmp->path = str_replace(DS, '/', JPath::clean($basePath.DS.$file)); + $tmp->path_relative = str_replace($mediaBase, '', $tmp->path); + $tmp->size = filesize($tmp->path); + + $ext = strtolower(JFile::getExt($file)); + switch ($ext) + { + // Image + case 'jpg': + case 'png': + case 'gif': + case 'xcf': + case 'odg': + case 'bmp': + case 'jpeg': + $info = @getimagesize($tmp->path); + $tmp->width = @$info[0]; + $tmp->height = @$info[1]; + $tmp->type = @$info[2]; + $tmp->mime = @$info['mime']; + + $filesize = MediaHelper::parseSize($tmp->size); + + if (($info[0] > 60) || ($info[1] > 60)) { + $dimensions = MediaHelper::imageResize($info[0], $info[1], 60); + $tmp->width_60 = $dimensions[0]; + $tmp->height_60 = $dimensions[1]; + } else { + $tmp->width_60 = $tmp->width; + $tmp->height_60 = $tmp->height; + } + + if (($info[0] > 16) || ($info[1] > 16)) { + $dimensions = MediaHelper::imageResize($info[0], $info[1], 16); + $tmp->width_16 = $dimensions[0]; + $tmp->height_16 = $dimensions[1]; + } else { + $tmp->width_16 = $tmp->width; + $tmp->height_16 = $tmp->height; + } + $images[] = $tmp; + break; + // Non-image document + default: + $iconfile_32 = JPATH_ADMINISTRATOR.DS."components".DS."com_media".DS."images".DS."mime-icon-32".DS.$ext.".png"; + if (file_exists($iconfile_32)) { + $tmp->icon_32 = "components/com_media/images/mime-icon-32/".$ext.".png"; + } else { + $tmp->icon_32 = "components/com_media/images/con_info.png"; + } + $iconfile_16 = JPATH_ADMINISTRATOR.DS."components".DS."com_media".DS."images".DS."mime-icon-16".DS.$ext.".png"; + if (file_exists($iconfile_16)) { + $tmp->icon_16 = "components/com_media/images/mime-icon-16/".$ext.".png"; + } else { + $tmp->icon_16 = "components/com_media/images/con_info.png"; + } + $docs[] = $tmp; + break; + } + } + } + } + + // Iterate over the folders if they exist + if ($folderList !== false) { + foreach ($folderList as $folder) { + $tmp = new JObject(); + $tmp->name = basename($folder); + $tmp->path = str_replace(DS, '/', JPath::clean($basePath.DS.$folder)); + $tmp->path_relative = str_replace($mediaBase, '', $tmp->path); + $count = MediaHelper::countFiles($tmp->path); + $tmp->files = $count[0]; + $tmp->folders = $count[1]; + + $folders[] = $tmp; + } + } + + $list = array('folders' => $folders, 'docs' => $docs, 'images' => $images); + + return $list; + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_media/models/manager.php b/oss/joomla/trunk/administrator/components/com_media/models/manager.php index 48a3469a..0cd53321 100644 --- a/oss/joomla/trunk/administrator/components/com_media/models/manager.php +++ b/oss/joomla/trunk/administrator/components/com_media/models/manager.php @@ -1,133 +1,132 @@ -setState('folder', $folder); - - $parent = str_replace("\\", "/", dirname($folder)); - $parent = ($parent == '.') ? null : $parent; - $this->setState('parent', $parent); - $set = true; - } - return parent::getState($property); - } - - /** - * Image Manager Popup - * - * @param string $listFolder The image directory to display - * @since 1.5 - */ - function getFolderList($base = null) - { - global $mainframe; - - // Get some paths from the request - if (empty($base)) { - $base = COM_MEDIA_BASE; - } - - // Get the list of folders - jimport('joomla.filesystem.folder'); - $folders = JFolder::folders($base, '.', true, true); - - // Load appropriate language files - $lang = & JFactory::getLanguage(); - $lang->load('', JPATH_ADMINISTRATOR); - $lang->load(JRequest::getCmd( 'option' ), JPATH_ADMINISTRATOR); - - $document =& JFactory::getDocument(); - $document->setTitle(JText::_('Insert Image')); - - // Build the array of select options for the folder list - $options[] = JHTML::_('select.option', "","/"); - foreach ($folders as $folder) { - $folder = str_replace(COM_MEDIA_BASE, "", $folder); - $value = substr($folder, 1); - $text = str_replace(DS, "/", $folder); - $options[] = JHTML::_('select.option', $value, $text); - } - - // Sort the folder list array - if (is_array($options)) { - sort($options); - } - - // Create the drop-down folder select list - $list = JHTML::_('select.genericlist', $options, 'folderlist', "class=\"inputbox\" size=\"1\" onchange=\"ImageManager.setFolder(this.options[this.selectedIndex].value)\" ", 'value', 'text', $base); - return $list; - } - - function getFolderTree($base = null) - { - // Get some paths from the request - if (empty($base)) { - $base = COM_MEDIA_BASE; - } - $mediaBase = str_replace(DS, '/', COM_MEDIA_BASE.'/'); - - // Get the list of folders - jimport('joomla.filesystem.folder'); - $folders = JFolder::folders($base, '.', true, true); - - $tree = array(); - foreach ($folders as $folder) - { - $folder = str_replace(DS, '/', $folder); - $name = substr($folder, strrpos($folder, '/') + 1); - $relative = str_replace($mediaBase, '', $folder); - $absolute = $folder; - $path = explode('/', $relative); - $node = (object) array('name' => $name, 'relative' => $relative, 'absolute' => $absolute); - - $tmp = &$tree; - for ($i=0,$n=count($path); $i<$n; $i++) - { - if (!isset($tmp['children'])) { - $tmp['children'] = array(); - } - if ($i == $n-1) { - // We need to place the node - $tmp['children'][$relative] = array('data' =>$node, 'children' => array()); - break; - } - if (array_key_exists($key = implode('/', array_slice($path, 0, $i+1)), $tmp['children'])) { - $tmp = &$tmp['children'][$key]; - } - } - } - $tree['data'] = (object) array('name' => JText::_('Media'), 'relative' => '', 'absolute' => $base); - return $tree; - } +setState('folder', $folder); + + $parent = str_replace("\\", "/", dirname($folder)); + $parent = ($parent == '.') ? null : $parent; + $this->setState('parent', $parent); + $set = true; + } + return parent::getState($property); + } + + /** + * Image Manager Popup + * + * @param string $listFolder The image directory to display + * @since 1.5 + */ + function getFolderList($base = null) + { + global $mainframe; + + // Get some paths from the request + if (empty($base)) { + $base = COM_MEDIA_BASE; + } + + // Get the list of folders + jimport('joomla.filesystem.folder'); + $folders = JFolder::folders($base, '.', true, true); + + // Load appropriate language files + $lang = & JFactory::getLanguage(); + $lang->load(JRequest::getCmd( 'option' ), JPATH_ADMINISTRATOR); + + $document =& JFactory::getDocument(); + $document->setTitle(JText::_('Insert Image')); + + // Build the array of select options for the folder list + $options[] = JHTML::_('select.option', "","/"); + foreach ($folders as $folder) { + $folder = str_replace(COM_MEDIA_BASE, "", $folder); + $value = substr($folder, 1); + $text = str_replace(DS, "/", $folder); + $options[] = JHTML::_('select.option', $value, $text); + } + + // Sort the folder list array + if (is_array($options)) { + sort($options); + } + + // Create the drop-down folder select list + $list = JHTML::_('select.genericlist', $options, 'folderlist', "class=\"inputbox\" size=\"1\" onchange=\"ImageManager.setFolder(this.options[this.selectedIndex].value)\" ", 'value', 'text', $base); + return $list; + } + + function getFolderTree($base = null) + { + // Get some paths from the request + if (empty($base)) { + $base = COM_MEDIA_BASE; + } + $mediaBase = str_replace(DS, '/', COM_MEDIA_BASE.'/'); + + // Get the list of folders + jimport('joomla.filesystem.folder'); + $folders = JFolder::folders($base, '.', true, true); + + $tree = array(); + foreach ($folders as $folder) + { + $folder = str_replace(DS, '/', $folder); + $name = substr($folder, strrpos($folder, '/') + 1); + $relative = str_replace($mediaBase, '', $folder); + $absolute = $folder; + $path = explode('/', $relative); + $node = (object) array('name' => $name, 'relative' => $relative, 'absolute' => $absolute); + + $tmp = &$tree; + for ($i=0,$n=count($path); $i<$n; $i++) + { + if (!isset($tmp['children'])) { + $tmp['children'] = array(); + } + if ($i == $n-1) { + // We need to place the node + $tmp['children'][$relative] = array('data' =>$node, 'children' => array()); + break; + } + if (array_key_exists($key = implode('/', array_slice($path, 0, $i+1)), $tmp['children'])) { + $tmp = &$tmp['children'][$key]; + } + } + } + $tree['data'] = (object) array('name' => JText::_('Media'), 'relative' => '', 'absolute' => $base); + return $tree; + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_media/views/images/view.html.php b/oss/joomla/trunk/administrator/components/com_media/views/images/view.html.php index b4d34848..c62e4bbd 100644 --- a/oss/joomla/trunk/administrator/components/com_media/views/images/view.html.php +++ b/oss/joomla/trunk/administrator/components/com_media/views/images/view.html.php @@ -1,61 +1,61 @@ -getClientId() == 1) $append = 'administrator/'; - - JHTML::_('script' , 'popup-imagemanager.js', $append .'components/com_media/assets/'); - JHTML::_('stylesheet', 'popup-imagemanager.css', $append .'components/com_media/assets/'); - if ($config->get('enable_flash', 0)) { - JHTML::_('behavior.uploader', 'file-upload', array('onAllComplete' => 'function(){ ImageManager.refreshFrame(); }')); - } - - /* - * Display form for FTP credentials? - * Don't set them here, as there are other functions called before this one if there is any file write operation - */ - jimport('joomla.client.helper'); - $ftp = !JClientHelper::hasCredentials('ftp'); - - $this->assignRef( 'session', JFactory::getSession()); - $this->assignRef( 'config', $config); - $this->assignRef( 'state', $this->get('state')); - $this->assignRef( 'folderList', $this->get('folderList')); - $this->assign('require_ftp', $ftp); - - parent::display($tpl); - } -} +getClientId() == 1) $append = 'administrator/'; + + JHTML::_('script' , 'popup-imagemanager.js', $append .'components/com_media/assets/'); + JHTML::_('stylesheet', 'popup-imagemanager.css', $append .'components/com_media/assets/'); + if ($config->get('enable_flash', 0)) { + JHTML::_('behavior.uploader', 'file-upload', array('onAllComplete' => 'function(){ ImageManager.refreshFrame(); }')); + } + + /* + * Display form for FTP credentials? + * Don't set them here, as there are other functions called before this one if there is any file write operation + */ + jimport('joomla.client.helper'); + $ftp = !JClientHelper::hasCredentials('ftp'); + + $this->assignRef( 'session', JFactory::getSession()); + $this->assignRef( 'config', $config); + $this->assignRef( 'state', $this->get('state')); + $this->assignRef( 'folderList', $this->get('folderList')); + $this->assign('require_ftp', $ftp); + + parent::display($tpl); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_media/views/imageslist/view.html.php b/oss/joomla/trunk/administrator/components/com_media/views/imageslist/view.html.php index 8fc682a2..08d663ad 100644 --- a/oss/joomla/trunk/administrator/components/com_media/views/imageslist/view.html.php +++ b/oss/joomla/trunk/administrator/components/com_media/views/imageslist/view.html.php @@ -1,73 +1,73 @@ -getClientId() == 1) $append = 'administrator/'; - - JHTML::_('behavior.mootools'); - JHTML::_('stylesheet', 'popup-imagelist.css', $append .'components/com_media/assets/'); - - $document =& JFactory::getDocument(); - $document->addScriptDeclaration("var ImageManager = window.parent.ImageManager;"); - - $this->assign('baseURL', COM_MEDIA_BASEURL); - $this->assignRef('images', $this->get('images')); - $this->assignRef('folders', $this->get('folders')); - $this->assignRef('state', $this->get('state')); - - parent::display($tpl); - } - - - function setFolder($index = 0) - { - if (isset($this->folders[$index])) { - $this->_tmp_folder = &$this->folders[$index]; - } else { - $this->_tmp_folder = new JObject; - } - } - - function setImage($index = 0) - { - if (isset($this->images[$index])) { - $this->_tmp_img = &$this->images[$index]; - } else { - $this->_tmp_img = new JObject; - } - } -} +getClientId() == 1) $append = 'administrator/'; + + JHTML::_('behavior.mootools'); + JHTML::_('stylesheet', 'popup-imagelist.css', $append .'components/com_media/assets/'); + + $document =& JFactory::getDocument(); + $document->addScriptDeclaration("var ImageManager = window.parent.ImageManager;"); + + $this->assign('baseURL', COM_MEDIA_BASEURL); + $this->assignRef('images', $this->get('images')); + $this->assignRef('folders', $this->get('folders')); + $this->assignRef('state', $this->get('state')); + + parent::display($tpl); + } + + + function setFolder($index = 0) + { + if (isset($this->folders[$index])) { + $this->_tmp_folder = &$this->folders[$index]; + } else { + $this->_tmp_folder = new JObject; + } + } + + function setImage($index = 0) + { + if (isset($this->images[$index])) { + $this->_tmp_img = &$this->images[$index]; + } else { + $this->_tmp_img = new JObject; + } + } +} diff --git a/oss/joomla/trunk/administrator/components/com_media/views/media/view.html.php b/oss/joomla/trunk/administrator/components/com_media/views/media/view.html.php index e7ab7fef..28bb480e 100644 --- a/oss/joomla/trunk/administrator/components/com_media/views/media/view.html.php +++ b/oss/joomla/trunk/administrator/components/com_media/views/media/view.html.php @@ -1,133 +1,133 @@ -getUserStateFromRequest('media.list.layout', 'layout', 'thumbs', 'word'); - - $listStyle = " - - "; - - $document =& JFactory::getDocument(); - $document->setBuffer($listStyle, 'modules', 'submenu'); - - JHTML::_('behavior.mootools'); - $document->addScript('components/com_media/assets/mediamanager.js'); - $document->addStyleSheet('components/com_media/assets/mediamanager.css'); - - JHTML::_('behavior.modal'); - $document->addScriptDeclaration(" - window.addEvent('domready', function() { - document.preview = SqueezeBox; - });"); - - JHTML::script('mootree.js'); - JHTML::stylesheet('mootree.css'); - - if ($config->get('enable_flash', 0)) { - JHTML::_('behavior.uploader', 'file-upload', array('onAllComplete' => 'function(){ MediaManager.refreshFrame(); }')); - } - - if(DS == '\\') - { - $base = str_replace(DS,"\\\\",COM_MEDIA_BASE); - } else { - $base = COM_MEDIA_BASE; - } - - $js = " - var basepath = '".$base."'; - var viewstyle = '".$style."'; - " ; - $document->addScriptDeclaration($js); - - /* - * Display form for FTP credentials? - * Don't set them here, as there are other functions called before this one if there is any file write operation - */ - jimport('joomla.client.helper'); - $ftp = !JClientHelper::hasCredentials('ftp'); - - $this->assignRef('session', JFactory::getSession()); - $this->assignRef('config', $config); - $this->assignRef('state', $this->get('state')); - $this->assign('require_ftp', $ftp); - $this->assign('folders_id', ' id="media-tree"'); - $this->assign('folders', $this->get('folderTree')); - - $user =& JFactory::getUser(); - $this->assignRef('user', $user); - - // Set the toolbar - $this->_setToolBar(); - - parent::display($tpl); - echo JHTML::_('behavior.keepalive'); - } - - function _setToolBar() - { - // Get the toolbar object instance - $bar =& JToolBar::getInstance('toolbar'); - - // Set the titlebar text - JToolBarHelper::title( JText::_( 'Media Manager' ), 'mediamanager.png'); - - // Add a delete button - $title = JText::_('Delete'); - $dhtml = " - - $title"; - $bar->appendButton( 'Custom', $dhtml, 'delete' ); - - // Add a popup configuration button - JToolBarHelper::help( 'screen.mediamanager' ); - } - - function getFolderLevel($folder) - { - $this->folders_id = null; - $txt = null; - if (isset($folder['children']) && count($folder['children'])) { - $tmp = $this->folders; - $this->folders = $folder; - $txt = $this->loadTemplate('folders'); - $this->folders = $tmp; - } - return $txt; - } -} +getUserStateFromRequest('media.list.layout', 'layout', 'thumbs', 'word'); + + $listStyle = " + + "; + + $document =& JFactory::getDocument(); + $document->setBuffer($listStyle, 'modules', 'submenu'); + + JHTML::_('behavior.mootools'); + $document->addScript('components/com_media/assets/mediamanager.js'); + $document->addStyleSheet('components/com_media/assets/mediamanager.css'); + + JHTML::_('behavior.modal'); + $document->addScriptDeclaration(" + window.addEvent('domready', function() { + document.preview = SqueezeBox; + });"); + + JHTML::script('mootree.js'); + JHTML::stylesheet('mootree.css'); + + if ($config->get('enable_flash', 0)) { + JHTML::_('behavior.uploader', 'file-upload', array('onAllComplete' => 'function(){ MediaManager.refreshFrame(); }')); + } + + if(DS == '\\') + { + $base = str_replace(DS,"\\\\",COM_MEDIA_BASE); + } else { + $base = COM_MEDIA_BASE; + } + + $js = " + var basepath = '".$base."'; + var viewstyle = '".$style."'; + " ; + $document->addScriptDeclaration($js); + + /* + * Display form for FTP credentials? + * Don't set them here, as there are other functions called before this one if there is any file write operation + */ + jimport('joomla.client.helper'); + $ftp = !JClientHelper::hasCredentials('ftp'); + + $this->assignRef('session', JFactory::getSession()); + $this->assignRef('config', $config); + $this->assignRef('state', $this->get('state')); + $this->assign('require_ftp', $ftp); + $this->assign('folders_id', ' id="media-tree"'); + $this->assign('folders', $this->get('folderTree')); + + $user =& JFactory::getUser(); + $this->assignRef('user', $user); + + // Set the toolbar + $this->_setToolBar(); + + parent::display($tpl); + echo JHTML::_('behavior.keepalive'); + } + + function _setToolBar() + { + // Get the toolbar object instance + $bar =& JToolBar::getInstance('toolbar'); + + // Set the titlebar text + JToolBarHelper::title( JText::_( 'Media Manager' ), 'mediamanager.png'); + + // Add a delete button + $title = JText::_('Delete'); + $dhtml = " + + $title"; + $bar->appendButton( 'Custom', $dhtml, 'delete' ); + + // Add a popup configuration button + JToolBarHelper::help( 'screen.mediamanager' ); + } + + function getFolderLevel($folder) + { + $this->folders_id = null; + $txt = null; + if (isset($folder['children']) && count($folder['children'])) { + $tmp = $this->folders; + $this->folders = $folder; + $txt = $this->loadTemplate('folders'); + $this->folders = $tmp; + } + return $txt; + } +} diff --git a/oss/joomla/trunk/administrator/components/com_media/views/medialist/view.html.php b/oss/joomla/trunk/administrator/components/com_media/views/medialist/view.html.php index 92cc549a..5f92805a 100644 --- a/oss/joomla/trunk/administrator/components/com_media/views/medialist/view.html.php +++ b/oss/joomla/trunk/administrator/components/com_media/views/medialist/view.html.php @@ -1,90 +1,90 @@ -getUserStateFromRequest('media.list.layout', 'layout', 'thumbs', 'word'); - - JHTML::_('behavior.mootools'); - - $document = &JFactory::getDocument(); - $document->addStyleSheet('components/com_media/assets/medialist-'.$style.'.css'); - - $document->addScriptDeclaration(" - window.addEvent('domready', function() { - window.top.document.updateUploader && window.top.document.updateUploader(); - $$('a.img-preview').each(function(el) { - el.addEvent('click', function(e) { - new Event(e).stop(); - window.top.document.preview.fromElement(el); - }); - }); - });"); - - $this->assign('baseURL', JURI::root()); - $this->assignRef('images', $this->get('images')); - $this->assignRef('documents', $this->get('documents')); - $this->assignRef('folders', $this->get('folders')); - $this->assignRef('state', $this->get('state')); - - parent::display($tpl); - } - - function setFolder($index = 0) - { - if (isset($this->folders[$index])) { - $this->_tmp_folder = &$this->folders[$index]; - } else { - $this->_tmp_folder = new JObject; - } - } - - function setImage($index = 0) - { - if (isset($this->images[$index])) { - $this->_tmp_img = &$this->images[$index]; - } else { - $this->_tmp_img = new JObject; - } - } - - function setDoc($index = 0) - { - if (isset($this->documents[$index])) { - $this->_tmp_doc = &$this->documents[$index]; - } else { - $this->_tmp_doc = new JObject; - } - } -} +getUserStateFromRequest('media.list.layout', 'layout', 'thumbs', 'word'); + + JHTML::_('behavior.mootools'); + + $document = &JFactory::getDocument(); + $document->addStyleSheet('components/com_media/assets/medialist-'.$style.'.css'); + + $document->addScriptDeclaration(" + window.addEvent('domready', function() { + window.top.document.updateUploader && window.top.document.updateUploader(); + $$('a.img-preview').each(function(el) { + el.addEvent('click', function(e) { + new Event(e).stop(); + window.top.document.preview.fromElement(el); + }); + }); + });"); + + $this->assign('baseURL', JURI::root()); + $this->assignRef('images', $this->get('images')); + $this->assignRef('documents', $this->get('documents')); + $this->assignRef('folders', $this->get('folders')); + $this->assignRef('state', $this->get('state')); + + parent::display($tpl); + } + + function setFolder($index = 0) + { + if (isset($this->folders[$index])) { + $this->_tmp_folder = &$this->folders[$index]; + } else { + $this->_tmp_folder = new JObject; + } + } + + function setImage($index = 0) + { + if (isset($this->images[$index])) { + $this->_tmp_img = &$this->images[$index]; + } else { + $this->_tmp_img = new JObject; + } + } + + function setDoc($index = 0) + { + if (isset($this->documents[$index])) { + $this->_tmp_doc = &$this->documents[$index]; + } else { + $this->_tmp_doc = new JObject; + } + } +} diff --git a/oss/joomla/trunk/administrator/components/com_menus/admin.menus.php b/oss/joomla/trunk/administrator/components/com_menus/admin.menus.php index b832c2ba..8e608084 100644 --- a/oss/joomla/trunk/administrator/components/com_menus/admin.menus.php +++ b/oss/joomla/trunk/administrator/components/com_menus/admin.menus.php @@ -1,24 +1,24 @@ - 'viewMenus') ); -$controller->registerTask('apply', 'save'); -$controller->execute( JRequest::getCmd( 'task' ) ); + 'viewMenus') ); +$controller->registerTask('apply', 'save'); +$controller->execute( JRequest::getCmd( 'task' ) ); $controller->redirect(); \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/classes/ilink.php b/oss/joomla/trunk/administrator/components/com_menus/classes/ilink.php index 75586069..ec25ff78 100644 --- a/oss/joomla/trunk/administrator/components/com_menus/classes/ilink.php +++ b/oss/joomla/trunk/administrator/components/com_menus/classes/ilink.php @@ -1,390 +1,397 @@ -_cid = "&cid[]=".$id; - } else { - $this->_cid = null; - } - - if ($menutype) { - $this->_menutype = "&menutype=".$menutype; - } else { - $this->_menutype = null; - } - - $this->_com = preg_replace( '#\W#', '', $component ); - - // Build the tree - if (!$this->_getOptions($this->_getXML(JPATH_SITE.'/components/com_'.$this->_com.'/metadata.xml', 'menu'), $this->_root)) { - if (!$this->_getViews()) - { - // Default behavior - } - } - } - - /** - * Returns the component - * @return string - */ - function getComponent() - { - return $this->_com; - } - - function getTree() - { - $depth = 0; - $this->reset(); - $class = null; - - // Recurse through children if they exist - while ($this->_current->hasChildren()) - { - $this->_output .= '
      '; - $children = $this->_current->getChildren(); - for ($i=0,$n=count($children);$i<$n;$i++) - { - $this->_current = & $children[$i]; - $this->renderLevel($depth,($i==$n-1)?1:0); - } - $this->_output .= '
    '; - } - return $this->_output; - } - - function renderLevel($depth, $isLast=0) - { - $depth++; - if (!isset($this->_depthHash[$depth])) { - $this->_depthHash[$depth] = 0; - } - $this->_depthHash[$depth]++; - - if ($this->_current->hasChildren()) { - $classes = 'node-open'; - } else { - $classes = 'leaf'; - } - - if ($isLast) { - $last = ' class="last"'; - } else { - $last = ''; - } - - $parent = & $this->_current->getParent(); - // Print the item - $this->_output .= "\n"; - - // Print the url - if ($this->_current->hasChildren()) { - $this->_output .= ""; - } else { - $this->_output .= ""; - } - - // Recurse through children if they exist - while ($this->_current->hasChildren()) - { - $this->_output .= "
      \n"; - $children = $this->_current->getChildren(); - for ($i=0,$n=count($children);$i<$n;$i++) - { - $this->_current = & $children[$i]; - $this->renderLevel($depth,($i==$n-1)?1:0); - } - $this->_output .= "
    \n"; - } - - // Close item - $this->_output .= "\n"; - } - - function _getOptions($e, &$parent, $purl=null) - { - if (!$purl) { - $purl = 'url[option]=com_'.$this->_com; - - // No metadata xml file in component root - if (!$e) { - return false; - } - } - - // Does the metadata file say no options available? - if ($e->attributes('options') == 'none') { - $node =& new iLinkNode($e->attributes('name'), $purl, $e->attributes('msg')); - $parent->addChild($node); - return true; - } - - // Do we have defined options available? - $options = &$e->getElementByPath('options'); - if ($options) { - $children = $options->children(); - foreach ($children as $child) - { - if ($child->name() == 'option') { - $url = $purl.'&url['.$options->attributes('var').']='.$child->attributes('value'); - $node =& new iLinkNode($child->attributes('name'), $url, $child->attributes('msg')); - $parent->addChild($node); - } elseif ($child->name() == 'default') { - $node =& new iLinkNode($child->attributes('name'), $purl, $child->attributes('msg')); - $parent->addChild($node); - } - } - return true; - } else { - return false; - } - } - - /** - * @access private - */ - function _getViews() - { - $return = false; - $path = JPATH_SITE.DS.'components'.DS.'com_'.$this->_com.DS.'views'; - - if (JFolder::exists($path)) { - $views = JFolder::folders($path); - } else { - return $return; - } - - if (is_array($views) && count($views)) - { - //$this->addChild(new iLinkNode('Views', null, 'Select the view'), true); - $return = true; - foreach ($views as $view) - { - if (strpos($view, '_') === false) { - // Load view metadata if it exists - $xmlpath = $path.DS.$view.DS.'metadata.xml'; - if (JFile::exists($xmlpath)) { - $data = $this->_getXML($xmlpath, 'view'); - } else { - $data = null; - } - - $url = 'url[option]=com_'.$this->_com.'&url[view]='.$view; - if ($data) { - if ($data->attributes('hidden') != 'true') { - $m = $data->getElementByPath('message'); - if ($m) { - $message = $m->data(); - } - $node =& new iLinkNode($data->attributes('title'), $url, $message); - $this->addChild($node); - if ($options = $data->getElementByPath('options')) { - $this->_getOptions($data, $node, $url); - } else { - $this->_getLayouts(dirname($xmlpath), $node); - } - } - } else { - $onclick = null; - $node =& new iLinkNode(ucfirst($view), $url); - $this->addChild($node); - $this->_getLayouts(dirname($xmlpath), $node); - } - } - } - } - return $return; - } - - /** - * @access private - */ - function _getLayouts($path, &$node) - { - $return = false; - $folder = $path.DS.'tmpl'; - if (is_dir( $folder )) - { - $files = JFolder::files($folder, '.php$'); - if (count($files)) { - foreach ($files as $file) - { - if (strpos($file, '_') === false) { - // Load view metadata if it exists - $layout = JFile::stripext($file); - $xmlpath = $path.DS.'tmpl'.DS.$layout.'.xml'; - if (JFile::exists($xmlpath)) { - $data = $this->_getXML($xmlpath, 'layout'); - } else { - $data = null; - } - - if ($layout != 'default') { - $url = 'url[option]=com_'.$this->_com.'&url[view]='.basename($path).'&url[layout]='.$layout; - } else { - $url = 'url[option]=com_'.$this->_com.'&url[view]='.basename($path); - } - if ($data) { - if ($data->attributes('hidden') != 'true') { - $m = $data->getElementByPath('message'); - if ($m) { - $message = $m->data(); - } - $child =& new iLinkNode($data->attributes('title'), $url, $message); - $node->addChild($child); - } - } else { - // Add default info for the layout - $child =& new iLinkNode(ucfirst($layout).' '.JText::_('Layout'), $url); - $node->addChild($child); - } - } - } - } - } - return $return; - } - - function _getXML($path, $xpath='control') - { - // Initialize variables - $result = null; - // load the xml metadata - if (file_exists( $path )) { - $xml =& JFactory::getXMLParser('Simple'); - if ($xml->loadFile($path)) { - if (isset( $xml->document )) { - $result = $xml->document->getElementByPath($xpath); - } - } - return $result; - } - return $result; - } - - function _findNodes(&$node) - { - foreach ($node->children() as $step) - { - /* - * For each child we need to see if it is an include and if so we - * need to get those children and process them as well (break out into - * another method). Then we need to create the objects in the _steps - * array for each child of type step. For now we aren't going to handle - * nested includes. - */ - if ($step->name() == 'include') { - // Handle include - $this->_getIncludedSteps($step, $node); - } elseif ($step->name() == 'step') { - // Include step to array - $this->_nodes[] = $step; - } else { - // Do nothing - continue; - } - } - } - - function _getIncludedSteps($include, &$parent) - { - $tags = array(); - $source = $include->attributes('source'); - $path = $include->attributes('path'); - - preg_match_all( "/{([A-Za-z\-_]+)}/", $source, $tags); - if (isset( $tags[1] )) { - $n = count( $tags[1] ); - for ($i=0; $i < $n; $i++) - { - $source = str_replace($tags[0][$i], @$this->_vars[$tags[1][$i]], $source); - } - } - - // load the source xml file - if (file_exists( JPATH_ROOT.$source )) - { - $xml = & JFactory::getXMLParser('Simple'); - if ($xml->loadFile(JPATH_ROOT.$source)) - { - $document = &$xml->document; - $steps = $document->getElementByPath($path); - - foreach($steps->children() as $step) - { - if ($step->name() == 'include') { - // Handle include - } elseif ($step->name() == 'step') { - // Include step to array - $node->addChild('step', $step->attributes(), $node->level()+1); - } else { - // Do nothing - continue; - } - } - } - } - } -} - -class iLinkNode extends JNode -{ - /** - * Node Title - */ - var $title = null; - - /** - * Node URL - */ - var $url = null; - - /** - * Node message - */ - var $msg = null; - - function __construct($title, $url = null, $msg = null) - { - $this->title = trim($title); - $this->url = $url; - $this->msg = trim($msg); - } -} \ No newline at end of file +_cid = "&cid[]=".$id; + } else { + $this->_cid = null; + } + + if ($menutype) { + $this->_menutype = "&menutype=".$menutype; + } else { + $this->_menutype = null; + } + + $this->_com = preg_replace( '#\W#', '', $component ); + + // Build the tree + if (!$this->_getOptions($this->_getXML(JPATH_SITE.'/components/com_'.$this->_com.'/metadata.xml', 'menu'), $this->_root)) { + if (!$this->_getViews()) + { + // Default behavior + } + } + } + + /** + * Returns the component + * @return string + */ + function getComponent() + { + return $this->_com; + } + + function getTree() + { + $depth = 0; + $this->reset(); + $class = null; + + // Recurse through children if they exist + while ($this->_current->hasChildren()) + { + $this->_output .= '
      '; + $children = $this->_current->getChildren(); + for ($i=0,$n=count($children);$i<$n;$i++) + { + $this->_current = & $children[$i]; + $this->renderLevel($depth,($i==$n-1)?1:0); + } + $this->_output .= '
    '; + } + return $this->_output; + } + + function renderLevel($depth, $isLast=0) + { + $depth++; + if (!isset($this->_depthHash[$depth])) { + $this->_depthHash[$depth] = 0; + } + $this->_depthHash[$depth]++; + + if ($this->_current->hasChildren()) { + $classes = 'node-open'; + } else { + $classes = 'leaf'; + } + + if ($isLast) { + $last = ' class="last"'; + } else { + $last = ''; + } + + $parent = & $this->_current->getParent(); + // Print the item + $this->_output .= "\n"; + + // Print the url + if ($this->_current->hasChildren()) { + $this->_output .= ""; + } else { + $this->_output .= ""; + } + + // Recurse through children if they exist + while ($this->_current->hasChildren()) + { + $this->_output .= "
      \n"; + $children = $this->_current->getChildren(); + for ($i=0,$n=count($children);$i<$n;$i++) + { + $this->_current = & $children[$i]; + $this->renderLevel($depth,($i==$n-1)?1:0); + } + $this->_output .= "
    \n"; + } + + // Close item + $this->_output .= "\n"; + } + + function _getOptions($e, &$parent, $purl=null) + { + if (!$purl) { + $purl = 'url[option]=com_'.$this->_com; + + // No metadata xml file in component root + if (!$e) { + return false; + } + } + + // Does the metadata file say no options available? + if ($e->attributes('options') == 'none') { + unset($node); + $node = new iLinkNode($e->attributes('name'), $purl, $e->attributes('msg')); + $parent->addChild($node); + return true; + } + + // Do we have defined options available? + $options = &$e->getElementByPath('options'); + if ($options) { + $children = $options->children(); + foreach ($children as $child) + { + if ($child->name() == 'option') { + $url = $purl.'&url['.$options->attributes('var').']='.$child->attributes('value'); + unset($node); + $node = new iLinkNode($child->attributes('name'), $url, $child->attributes('msg')); + $parent->addChild($node); + } elseif ($child->name() == 'default') { + unset($node); + $node = new iLinkNode($child->attributes('name'), $purl, $child->attributes('msg')); + $parent->addChild($node); + } + } + return true; + } else { + return false; + } + } + + /** + * @access private + */ + function _getViews() + { + $return = false; + $path = JPATH_SITE.DS.'components'.DS.'com_'.$this->_com.DS.'views'; + + if (JFolder::exists($path)) { + $views = JFolder::folders($path); + } else { + return $return; + } + + if (is_array($views) && count($views)) + { + //$this->addChild(new iLinkNode('Views', null, 'Select the view'), true); + $return = true; + foreach ($views as $view) + { + if (strpos($view, '_') === false) { + // Load view metadata if it exists + $xmlpath = $path.DS.$view.DS.'metadata.xml'; + if (JFile::exists($xmlpath)) { + $data = $this->_getXML($xmlpath, 'view'); + } else { + $data = null; + } + + $url = 'url[option]=com_'.$this->_com.'&url[view]='.$view; + if ($data) { + if ($data->attributes('hidden') != 'true') { + $m = $data->getElementByPath('message'); + if ($m) { + $message = $m->data(); + } + unset($node); + $node = new iLinkNode($data->attributes('title'), $url, $message); + $this->addChild($node); + if ($options = $data->getElementByPath('options')) { + $this->_getOptions($data, $node, $url); + } else { + $this->_getLayouts(dirname($xmlpath), $node); + } + } + } else { + $onclick = null; + unset($node); + $node = new iLinkNode(ucfirst($view), $url); + $this->addChild($node); + $this->_getLayouts(dirname($xmlpath), $node); + } + } + } + } + return $return; + } + + /** + * @access private + */ + function _getLayouts($path, &$node) + { + $return = false; + $folder = $path.DS.'tmpl'; + if (is_dir( $folder )) + { + $files = JFolder::files($folder, '.php$'); + if (count($files)) { + foreach ($files as $file) + { + if (strpos($file, '_') === false) { + // Load view metadata if it exists + $layout = JFile::stripext($file); + $xmlpath = $path.DS.'tmpl'.DS.$layout.'.xml'; + if (JFile::exists($xmlpath)) { + $data = $this->_getXML($xmlpath, 'layout'); + } else { + $data = null; + } + + if ($layout != 'default') { + $url = 'url[option]=com_'.$this->_com.'&url[view]='.basename($path).'&url[layout]='.$layout; + } else { + $url = 'url[option]=com_'.$this->_com.'&url[view]='.basename($path); + } + if ($data) { + if ($data->attributes('hidden') != 'true') { + $m = $data->getElementByPath('message'); + if ($m) { + $message = $m->data(); + } + unset($child); + $child = new iLinkNode($data->attributes('title'), $url, $message); + $node->addChild($child); + } + } else { + // Add default info for the layout + unset($child); + $child = new iLinkNode(ucfirst($layout).' '.JText::_('Layout'), $url); + $node->addChild($child); + } + } + } + } + } + return $return; + } + + function _getXML($path, $xpath='control') + { + // Initialize variables + $result = null; + // load the xml metadata + if (file_exists( $path )) { + $xml =& JFactory::getXMLParser('Simple'); + if ($xml->loadFile($path)) { + if (isset( $xml->document )) { + $result = $xml->document->getElementByPath($xpath); + } + } + return $result; + } + return $result; + } + + function _findNodes(&$node) + { + foreach ($node->children() as $step) + { + /* + * For each child we need to see if it is an include and if so we + * need to get those children and process them as well (break out into + * another method). Then we need to create the objects in the _steps + * array for each child of type step. For now we aren't going to handle + * nested includes. + */ + if ($step->name() == 'include') { + // Handle include + $this->_getIncludedSteps($step, $node); + } elseif ($step->name() == 'step') { + // Include step to array + $this->_nodes[] = $step; + } else { + // Do nothing + continue; + } + } + } + + function _getIncludedSteps($include, &$parent) + { + $tags = array(); + $source = $include->attributes('source'); + $path = $include->attributes('path'); + + preg_match_all( "/{([A-Za-z\-_]+)}/", $source, $tags); + if (isset( $tags[1] )) { + $n = count( $tags[1] ); + for ($i=0; $i < $n; $i++) + { + $source = str_replace($tags[0][$i], @$this->_vars[$tags[1][$i]], $source); + } + } + + // load the source xml file + if (file_exists( JPATH_ROOT.$source )) + { + $xml = & JFactory::getXMLParser('Simple'); + if ($xml->loadFile(JPATH_ROOT.$source)) + { + $document = &$xml->document; + $steps = $document->getElementByPath($path); + + foreach($steps->children() as $step) + { + if ($step->name() == 'include') { + // Handle include + } elseif ($step->name() == 'step') { + // Include step to array + $node->addChild('step', $step->attributes(), $node->level()+1); + } else { + // Do nothing + continue; + } + } + } + } + } +} + +class iLinkNode extends JNode +{ + /** + * Node Title + */ + var $title = null; + + /** + * Node URL + */ + var $url = null; + + /** + * Node message + */ + var $msg = null; + + function __construct($title, $url = null, $msg = null) + { + $this->title = trim($title); + $this->url = $url; + $this->msg = trim($msg); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_menus/controller.php b/oss/joomla/trunk/administrator/components/com_menus/controller.php index effb106d..3290c5b7 100644 --- a/oss/joomla/trunk/administrator/components/com_menus/controller.php +++ b/oss/joomla/trunk/administrator/components/com_menus/controller.php @@ -1,797 +1,799 @@ -getModel( 'Item' ); - $view =& $this->getView( 'Item' ); - $view->setModel( $model, true ); - - // Set the layout and display - $view->setLayout('type'); - $view->type(); - } - /** - * Edit menu item wizard - */ - - function type() - { - JRequest::setVar( 'edit', true ); - $model =& $this->getModel( 'Item' ); - $view =& $this->getView( 'Item' ); - $view->setModel( $model, true ); - - // Set the layout and display - $view->setLayout('type'); - $view->type(); - } - - /** - * Edits a menu item - */ - function edit() - { - JRequest::setVar( 'edit', true ); - $model =& $this->getModel( 'Item' ); - $model->checkout(); - - $view =& $this->getView( 'Item' ); - $view->setModel( $model, true ); - // Set the layout and display - $view->setLayout('form'); - $view->edit(); - } - - /** - * Saves a menu item - */ - function save() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $model =& $this->getModel( 'Item' ); - $post = JRequest::get('post'); - // allow name only to contain html - $post['name'] = JRequest::getVar( 'name', '', 'post', 'string', JREQUEST_ALLOWHTML ); - $model->setState( 'request', $post ); - - if ($model->store()) { - $msg = JText::_( 'Menu item Saved' ); - } else { - $msg = JText::_( 'Error Saving Menu item' ); - } - - $item =& $model->getItem(); - switch ( $this->_task ) { - case 'apply': - $this->setRedirect( 'index.php?option=com_menus&menutype='.$item->menutype.'&task=edit&cid[]='.$item->id.'' , $msg ); - break; - - case 'save': - default: - $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$item->menutype, $msg ); - break; - } - } - - /** - * Cancels an edit operation - */ - function cancelItem() - { - global $mainframe; - - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $menutype = $mainframe->getUserStateFromRequest( 'com_menus.menutype', 'menutype', 'mainmenu', 'string' ); - - $model = $this->getModel('item'); - $model->checkin(); - - $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menutype); - } - - /** - * Cancels an edit operation - */ - function cancel() - { - $this->setRedirect( 'index.php?option=com_menus'); - } - - /** - * Form for copying item(s) to a specific menu - */ - function copy() - { - $model =& $this->getModel( 'List' ); - $view =& $this->getView( 'List' ); - $view->setModel( $model, true ); - $view->copyForm(); - } - - /** - * Save the item(s) to the menu selected - */ - function doCopy() - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Get some variables from the request - $menu = JRequest::getString( 'menu', '', 'post'); - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - JArrayHelper::toInteger($cid); - - //Check to see of a menu was selected to copy the items too - if (empty($menu)) - { - $msg = JText::_('Please select a menu from the list'); - $mainframe->enqueueMessage($msg, 'message'); - return $this->execute('copy'); - } - - $model =& $this->getModel( 'List' ); - - if ($model->copy($cid, $menu)) { - $msg = JText::sprintf( 'Menu Items Copied to', count( $cid ), $menu ); - } else { - $msg = $model->getError(); - } - $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); - } - - /** - * Form for moving item(s) to a specific menu - */ - function move() - { - $model =& $this->getModel( 'List'); - $view =& $this->getView( 'List' ); - $view->setModel( $model, true ); - $view->moveForm(); - } - - /** - * Save the item(s) to the menu selected - */ - function doMove() - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Get some variables from the request - $menu = JRequest::getVar( 'menu', '', 'post', 'string' ); - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - JArrayHelper::toInteger($cid); - - //Check to see if a menu was selected to copy the items too - if (empty($menu)) - { - $msg = JText::_('Please select a menu from the list'); - $mainframe->enqueueMessage($msg, 'message'); - return $this->execute('move'); - } - - $model =& $this->getModel( 'List' ); - - if ($model->move($cid, $menu)) { - $msg = JText::sprintf( 'Menu Items Moved to', count( $cid ), $menu ); - } else { - $msg = $model->getError(); - } - $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); - } - - /** - * Save the item(s) to the menu selected - */ - function publish() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Get some variables from the request - $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - JArrayHelper::toInteger($cid); - - $model =& $this->getModel( 'List' ); - if ($model->setItemState($cid, 1)) { - $msg = JText::sprintf( 'Menu Items Published', count( $cid ) ); - } else { - $msg = $model->getError(); - } - $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); - } - - /** - * Save the item(s) to the menu selected - */ - function unpublish() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Get some variables from the request - $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - JArrayHelper::toInteger($cid); - - $model =& $this->getModel( 'List' ); - if ($model->setItemState($cid, 0)) { - $msg = JText::sprintf( 'Menu Items Unpublished', count( $cid ) ); - } else { - $msg = $model->getError(); - } - $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); - } - - /** - * Save the item(s) to the menu selected - */ - function orderup() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - JArrayHelper::toInteger($cid); - - if (isset($cid[0]) && $cid[0]) { - $id = $cid[0]; - } else { - $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, JText::_('No Items Selected') ); - return false; - } - - $model =& $this->getModel( 'List' ); - if ($model->orderItem($id, -1)) { - $msg = JText::_( 'Menu Item Moved Up' ); - } else { - $msg = $model->getError(); - } - $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); - } - - /** - * Save the item(s) to the menu selected - */ - function orderdown() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - JArrayHelper::toInteger($cid); - - if (isset($cid[0]) && $cid[0]) { - $id = $cid[0]; - } else { - $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, JText::_('No Items Selected') ); - return false; - } - - $model =& $this->getModel( 'List' ); - if ($model->orderItem($id, 1)) { - $msg = JText::_( 'Menu Item Moved Down' ); - } else { - $msg = $model->getError(); - } - $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); - } - - /** - * Save the item(s) to the menu selected - */ - function saveorder() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - JArrayHelper::toInteger($cid); - - $model =& $this->getModel( 'List' ); - if ($model->setOrder($cid, $menu)) { - $msg = JText::_( 'New ordering saved' ); - } else { - $msg = $model->getError(); - } - $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); - } - - /** - * Save the item(s) to the menu selected - */ - function accesspublic() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Get some variables from the request - $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - JArrayHelper::toInteger($cid); - - $model =& $this->getModel( 'List' ); - if ($model->setAccess($cid, 0)) { - $msg = JText::sprintf( 'Menu Items Set Public', count( $cid ) ); - } else { - $msg = $model->getError(); - } - $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); - } - - /** - * Save the item(s) to the menu selected - */ - function accessregistered() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Get some variables from the request - $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - JArrayHelper::toInteger($cid); - - $model =& $this->getModel( 'List' ); - if ($model->setAccess($cid, 1)) { - $msg = JText::sprintf( 'Menu Items Set Registered', count( $cid ) ); - } else { - $msg = $model->getError(); - } - $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); - } - - /** - * Save the item(s) to the menu selected - */ - function accessspecial() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Get some variables from the request - $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - JArrayHelper::toInteger($cid); - - $model =& $this->getModel( 'List' ); - if ($model->setAccess($cid, 2)) { - $msg = JText::sprintf( 'Menu Items Set Special', count( $cid ) ); - } else { - $msg = $model->getError(); - } - $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); - } - - /** - * Save the item(s) to the menu selected - */ - function setdefault() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Get some variables from the request - $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - JArrayHelper::toInteger($cid); - - if (isset($cid[0]) && $cid[0]) { - $id = $cid[0]; - } else { - $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, JText::_('No Items Selected') ); - return false; - } - - $item =& JTable::getInstance( 'menu' ); - $item->load($id); - if(!$item->get('published')) { - $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, JText::_('The Default Menu Item Must Be Published') ); - return false; - } - - $model =& $this->getModel( 'List' ); - if ($model->setHome($id)) { - $msg = JText::_( 'Default Menu Item Set' ); - } else { - $msg = $model->getError(); - } - $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); - } - - function remove() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Get some variables from the request - $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - JArrayHelper::toInteger($cid); - - if (!count($cid)) { - $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, JText::_('No Items Selected') ); - return false; - } - - $model =& $this->getModel( 'List' ); - if ($n = $model->toTrash($cid)) { - $msg = JText::sprintf( 'Item(s) sent to the Trash', $n ); - } else { - $msg = $model->getError(); - } - $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); - } - - /** - * Save the item(s) to the menu selected - */ - function view() - { - $model =& $this->getModel( 'List' ); - $view =& $this->getView( 'List' ); - $view->setModel( $model, true ); - $view->display(); - } - - - /** - * Controller for view listing menu types and related statical info - * @param string The URL option - */ - function viewMenus() - { - - $view =& $this->getView( 'Menus'); - $model =& $this->getModel( 'Menutype' ); - $view->setModel( $model, true ); - $view->display(); - } - - - /** - * Controller for view to edit a menu type - */ - function editMenu() - { - $view =& $this->getView( 'Menus' ); - $model =& $this->getModel( 'Menutype' ); - $view->setModel( $model, true ); - $view->editForm(true,null); - - } - - /** - * Controller for view to create a menu type - */ - function addMenu() - { - $view =& $this->getView( 'Menus' ); - $model =& $this->getModel( 'Menutype' ); - $view->setModel( $model, true ); - $view->editForm(false,null); - } - - /** - * Controller for saving a menu type - */ - function saveMenu() - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $id = JRequest::getVar( 'id', 0, 'post', 'int' ); - - $oldType =& JTable::getInstance('menutypes' ); - $oldType->load( $id ); - - $menuType =& JTable::getInstance('menutypes'); - $menuType->bind( JRequest::get( 'post' ) ); - - $isNew = ($menuType->id == 0); - $isChanged = ($oldType->menutype != $menuType->menutype); - - if (!$menuType->check()) { - JError::raiseWarning( 500, $menuType->getError() ); - $this->setRedirect( 'index.php?option=com_menus&task=editMenu', 'Please check your menu settings' ); - return false; - } - - if (!$menuType->store()) { - JError::raiseWarning( 500, $menuType->getError() ); - $this->setRedirect( 'index.php?option=com_menus&task=editMenu', 'Please check your menu settings' ); - return false; - } - - if ($isNew) - { - if ($title = JRequest::getVar( 'module_title', $menuType->menutype, 'post', 'string' )) - { - $module =& JTable::getInstance( 'module'); - $module->title = $title; - $module->position = 'left'; - $module->module = 'mod_mainmenu'; - $module->published = 0; - $module->iscore = 0; - $module->params = 'menutype='. $menuType->menutype; - - // check then store data in db - if (!$module->check()) { - return JError::raiseWarning( 500, $module->getError() ); - } - if (!$module->store()) { - return JError::raiseWarning( 500, $module->getError() ); - } - $module->checkin(); - $module->reorder( 'position='.$db->Quote($module->position) ); - - // module assigned to show on All pages by default - // Clean up possible garbage first - $query = 'DELETE FROM #__modules_menu WHERE moduleid = '.(int) $module->id; - $db->setQuery( $query ); - if (!$db->query()) { - return JError::raiseWarning( 500, $db->getError() ); - } - - // ToDO: Changed to become a Joomla! db-object - $query = 'INSERT INTO #__modules_menu VALUES ( '.(int) $module->id.', 0 )'; - $db->setQuery( $query ); - if (!$db->query()) { - return JError::raiseWarning( 500, $db->getError() ); - } - } - - $msg = JText::sprintf( 'New Menu created', $menuType->menutype ); - } - else if ($isChanged) - { - $oldTerm = $oldType->menutype; - $newTerm = $menuType->menutype; - - // change menutype being of all mod_mainmenu modules calling old menutype - $query = 'SELECT id' - . ' FROM #__modules' - . ' WHERE module = "mod_mainmenu"' - . ' AND params LIKE "%menutype='.$db->getEscaped($oldTerm).'%"' - ; - $db->setQuery( $query ); - $modules = $db->loadResultArray(); - - foreach ($modules as $id) - { - $row =& JTable::getInstance('module'); - $row->load( $id ); - - $row->params = str_replace( $oldTerm, $newTerm, $row->params ); - - // check then store data in db - if ( !$row->check() ) { - return JError::raiseWarning( 500, $db->getError() ); - } - if ( !$row->store() ) { - return JError::raiseWarning( 500, $db->getError() ); - } - $row->checkin(); - } - - // change menutype of all menuitems using old menutype - $query = 'UPDATE #__menu' - . ' SET menutype = '.$db->Quote($newTerm) - . ' WHERE menutype = '.$db->Quote($oldTerm) - ; - $db->setQuery( $query ); - $db->query(); - - $msg = JText::_( 'Menu Items & Modules updated' ); - } - - $this->setRedirect( 'index.php?option=com_menus', $msg ); - } - - /** - * Controller for a view to confirm the deletion of a menu type - */ - function deleteMenu() - { - $view =& $this->getView( 'Menus' ); - $model =& $this->getModel( 'Menutype' ); - $view->setModel( $model, true ); - $view->deleteForm(); - } - - /** - * Delete a menu - */ - function doDeleteMenu() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $id = JRequest::getVar( 'id', 0, '', 'int' ); - if ($id <= 0) { - JError::raiseWarning( 500, JText::_( 'Invalid ID provided' ) ); - $this->setRedirect( 'index.php?option=com_menus' ); - return false; - } - - $model =& $this->getModel( 'Menutype' ); - if (!$model->canDelete()) { - JError::raiseWarning( 500, $model->getError() ); - $this->setRedirect( 'index.php?option=com_menus' ); - return false; - } - $err = null; - if (!$model->delete()) { - $err = $model->getError(); - } - $this->setRedirect( 'index.php?option=com_menus', $err ); - } - - /** - * Compiles a list of the articles you have selected to Copy - */ - function copyMenu() - { - $view =& $this->getView( 'Menus' ); - $model =& $this->getModel( 'Menutype' ); - $view->setModel( $model, true ); - $view->copyForm(); - } - - /** - * Copies a complete menu, all its items and creates a new module, using the name speified - */ - function doCopyMenu() - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $type = JRequest::getVar( 'type', '', 'post', 'string' ); - $menu_name = JRequest::getVar( 'menu_name', 'New Menu', 'post', 'string' ); - $module_name = JRequest::getVar( 'module_name', 'New Module', 'post', 'string' ); - - // check for unique menutype for new menu copy - $query = 'SELECT params' . - ' FROM #__modules' . - ' WHERE module = "mod_mainmenu"'; - $db->setQuery( $query ); - $menus = $db->loadResultArray(); - - foreach ( $menus as $menu ) - { - $params = new JParameter( $menu ); - if ( $params->get('menutype') == $menu_name ) { - JError::raiseWarning( 500, JText::_( 'ERRORMENUNAMEEXISTS' ) ); - $this->setRedirect( 'index.php?option=com_menus' ); - return; - } - } - - // copy the menu items - $mids = JRequest::getVar( 'mids', array(), 'post', 'array' ); - JArrayHelper::toInteger($mids); - $total = count( $mids ); - $copy =& JTable::getInstance('menu'); - $original =& JTable::getInstance('menu'); - sort( $mids ); - $a_ids = array(); - - foreach( $mids as $mid ) - { - $original->load( $mid ); - $copy = $original; - $copy->id = NULL; - $copy->parent = $a_ids[$original->parent]; - $copy->menutype = $menu_name; - $copy->home = 0; - - if ( !$copy->check() ) { - JError::raiseWarning( 500, $copy->getError() ); - $this->setRedirect( 'index.php?option=com_menus' ); - return; - } - if ( !$copy->store() ) { - JError::raiseWarning( 500, $copy->getError() ); - $this->setRedirect( 'index.php?option=com_menus' ); - return; - } - $a_ids[$original->id] = $copy->id; - } - - // create the module copy - $row =& JTable::getInstance('module'); - $row->load( 0 ); - $row->title = $module_name; - $row->iscore = 0; - $row->published = 1; - $row->position = 'left'; - $row->module = 'mod_mainmenu'; - $row->params = 'menutype='. $menu_name; - - if (!$row->check()) { - JError::raiseWarning( 500, $db->getError() ); - $this->setRedirect( 'index.php?option=com_menus' ); - return; - } - if (!$row->store()) { - JError::raiseWarning( 500, $db->getError() ); - $this->setRedirect( 'index.php?option=com_menus' ); - return; - } - $row->checkin(); - $row->reorder( 'position='.$db->Quote($row->position) ); - // module assigned to show on All pages by default - // ToDO: Changed to become a Joomla! db-object - $query = 'INSERT INTO #__modules_menu' . - ' VALUES ( '.(int) $row->id.', 0 )'; - $db->setQuery( $query ); - if ( !$db->query() ) { - JError::raiseWarning( 500, $db->getErrorMsg(true) ); - $this->setRedirect( 'index.php?option=com_menus' ); - return; - //echo "\n"; - //$mainframe->close(); - } - - // Insert the menu type - $query = 'INSERT INTO `#__menu_types` ( `menutype` , `title` , `description` ) ' . - ' VALUES ( '.$db->Quote($menu_name).', '.$db->Quote($menu_name).', "")'; - $db->setQuery( $query ); - if ( !$db->query() ) { - JError::raiseWarning( 500, $db->getErrorMsg(true) ); - $this->setRedirect( 'index.php?option=com_menus' ); - return; - //echo "\n"; - //$mainframe->close(); - } - - $msg = JText::sprintf( 'Copy of Menu created', $type, $total ); - $mainframe->redirect( 'index.php?option=com_menus', $msg ); - } -} +getModel( 'Item' ); + $view =& $this->getView( 'Item' ); + $view->setModel( $model, true ); + + // Set the layout and display + $view->setLayout('type'); + $view->type(); + } + /** + * Edit menu item wizard + */ + + function type() + { + JRequest::setVar( 'edit', true ); + $model =& $this->getModel( 'Item' ); + $view =& $this->getView( 'Item' ); + $view->setModel( $model, true ); + + // Set the layout and display + $view->setLayout('type'); + $view->type(); + } + + /** + * Edits a menu item + */ + function edit() + { + JRequest::setVar( 'edit', true ); + $model =& $this->getModel( 'Item' ); + $model->checkout(); + + $view =& $this->getView( 'Item' ); + $view->setModel( $model, true ); + // Set the layout and display + $view->setLayout('form'); + $view->edit(); + } + + /** + * Saves a menu item + */ + function save() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $model =& $this->getModel( 'Item' ); + $post = JRequest::get('post'); + // allow name only to contain html + $post['name'] = JRequest::getVar( 'name', '', 'post', 'string', JREQUEST_ALLOWHTML ); + $model->setState( 'request', $post ); + + if ($model->store()) { + $msg = JText::_( 'Menu item Saved' ); + } else { + $msg = JText::_( 'Error Saving Menu item' ); + } + + $item =& $model->getItem(); + switch ( $this->_task ) { + case 'apply': + $this->setRedirect( 'index.php?option=com_menus&menutype='.$item->menutype.'&task=edit&cid[]='.$item->id.'' , $msg ); + break; + + case 'save': + default: + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$item->menutype, $msg ); + break; + } + } + + /** + * Cancels an edit operation + */ + function cancelItem() + { + global $mainframe; + + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $menutype = $mainframe->getUserStateFromRequest( 'com_menus.menutype', 'menutype', 'mainmenu', 'string' ); + + $model = $this->getModel('item'); + $model->checkin(); + + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menutype); + } + + /** + * Cancels an edit operation + */ + function cancel() + { + $this->setRedirect( 'index.php?option=com_menus'); + } + + /** + * Form for copying item(s) to a specific menu + */ + function copy() + { + $model =& $this->getModel( 'List' ); + $view =& $this->getView( 'List' ); + $view->setModel( $model, true ); + $view->copyForm(); + } + + /** + * Save the item(s) to the menu selected + */ + function doCopy() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Get some variables from the request + $menu = JRequest::getString( 'menu', '', 'post'); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + //Check to see of a menu was selected to copy the items too + if (empty($menu)) + { + $msg = JText::_('Please select a menu from the list'); + $mainframe->enqueueMessage($msg, 'message'); + return $this->execute('copy'); + } + + $model =& $this->getModel( 'List' ); + + if ($model->copy($cid, $menu)) { + $msg = JText::sprintf( 'Menu Items Copied to', count( $cid ), $menu ); + } else { + $msg = $model->getError(); + } + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); + } + + /** + * Form for moving item(s) to a specific menu + */ + function move() + { + $model =& $this->getModel( 'List'); + $view =& $this->getView( 'List' ); + $view->setModel( $model, true ); + $view->moveForm(); + } + + /** + * Save the item(s) to the menu selected + */ + function doMove() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Get some variables from the request + $menu = JRequest::getVar( 'menu', '', 'post', 'string' ); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + //Check to see if a menu was selected to copy the items too + if (empty($menu)) + { + $msg = JText::_('Please select a menu from the list'); + $mainframe->enqueueMessage($msg, 'message'); + return $this->execute('move'); + } + + $model =& $this->getModel( 'List' ); + + if ($model->move($cid, $menu)) { + $msg = JText::sprintf( 'Menu Items Moved to', count( $cid ), $menu ); + } else { + $msg = $model->getError(); + } + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); + } + + /** + * Save the item(s) to the menu selected + */ + function publish() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Get some variables from the request + $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + $model =& $this->getModel( 'List' ); + if ($model->setItemState($cid, 1)) { + $msg = JText::sprintf( 'Menu Items Published', count( $cid ) ); + } else { + $msg = $model->getError(); + } + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); + } + + /** + * Save the item(s) to the menu selected + */ + function unpublish() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Get some variables from the request + $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + $model =& $this->getModel( 'List' ); + if ($model->setItemState($cid, 0)) { + $msg = JText::sprintf( 'Menu Items Unpublished', count( $cid ) ); + } else { + $msg = $model->getError(); + } + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); + } + + /** + * Save the item(s) to the menu selected + */ + function orderup() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + if (isset($cid[0]) && $cid[0]) { + $id = $cid[0]; + } else { + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, JText::_('No Items Selected') ); + return false; + } + + $model =& $this->getModel( 'List' ); + if ($model->orderItem($id, -1)) { + $msg = JText::_( 'Menu Item Moved Up' ); + } else { + $msg = $model->getError(); + } + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); + } + + /** + * Save the item(s) to the menu selected + */ + function orderdown() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + if (isset($cid[0]) && $cid[0]) { + $id = $cid[0]; + } else { + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, JText::_('No Items Selected') ); + return false; + } + + $model =& $this->getModel( 'List' ); + if ($model->orderItem($id, 1)) { + $msg = JText::_( 'Menu Item Moved Down' ); + } else { + $msg = $model->getError(); + } + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); + } + + /** + * Save the item(s) to the menu selected + */ + function saveorder() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + $model =& $this->getModel( 'List' ); + if ($model->setOrder($cid, $menu)) { + $msg = JText::_( 'New ordering saved' ); + } else { + $msg = $model->getError(); + } + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); + } + + /** + * Save the item(s) to the menu selected + */ + function accesspublic() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Get some variables from the request + $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + $model =& $this->getModel( 'List' ); + if ($model->setAccess($cid, 0)) { + $msg = JText::sprintf( 'Menu Items Set Public', count( $cid ) ); + } else { + $msg = $model->getError(); + } + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); + } + + /** + * Save the item(s) to the menu selected + */ + function accessregistered() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Get some variables from the request + $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + $model =& $this->getModel( 'List' ); + if ($model->setAccess($cid, 1)) { + $msg = JText::sprintf( 'Menu Items Set Registered', count( $cid ) ); + } else { + $msg = $model->getError(); + } + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); + } + + /** + * Save the item(s) to the menu selected + */ + function accessspecial() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Get some variables from the request + $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + $model =& $this->getModel( 'List' ); + if ($model->setAccess($cid, 2)) { + $msg = JText::sprintf( 'Menu Items Set Special', count( $cid ) ); + } else { + $msg = $model->getError(); + } + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); + } + + /** + * Save the item(s) to the menu selected + */ + function setdefault() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Get some variables from the request + $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + if (isset($cid[0]) && $cid[0]) { + $id = $cid[0]; + } else { + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, JText::_('No Items Selected') ); + return false; + } + + $item =& JTable::getInstance( 'menu' ); + $item->load($id); + if(!$item->get('published')) { + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, JText::_('The Default Menu Item Must Be Published') ); + return false; + } + + $model =& $this->getModel( 'List' ); + if ($model->setHome($id)) { + $msg = JText::_( 'Default Menu Item Set' ); + } else { + $msg = $model->getError(); + } + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); + } + + function remove() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Get some variables from the request + $menu = JRequest::getVar( 'menutype', '', 'post', 'string' ); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + if (!count($cid)) { + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, JText::_('No Items Selected') ); + return false; + } + + $model =& $this->getModel( 'List' ); + if ($n = $model->toTrash($cid)) { + $msg = JText::sprintf( 'Item(s) sent to the Trash', $n ); + } else { + $msg = $model->getError(); + } + $this->setRedirect( 'index.php?option=com_menus&task=view&menutype='.$menu, $msg ); + } + + /** + * Save the item(s) to the menu selected + */ + function view() + { + $model =& $this->getModel( 'List' ); + $view =& $this->getView( 'List' ); + $view->setModel( $model, true ); + $view->display(); + } + + + /** + * Controller for view listing menu types and related statical info + * @param string The URL option + */ + function viewMenus() + { + + $view =& $this->getView( 'Menus'); + $model =& $this->getModel( 'Menutype' ); + $view->setModel( $model, true ); + $view->display(); + } + + + /** + * Controller for view to edit a menu type + */ + function editMenu() + { + $view =& $this->getView( 'Menus' ); + $model =& $this->getModel( 'Menutype' ); + $view->setModel( $model, true ); + $view->editForm(true,null); + + } + + /** + * Controller for view to create a menu type + */ + function addMenu() + { + $view =& $this->getView( 'Menus' ); + $model =& $this->getModel( 'Menutype' ); + $view->setModel( $model, true ); + $view->editForm(false,null); + } + + /** + * Controller for saving a menu type + */ + function saveMenu() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $id = JRequest::getVar( 'id', 0, 'post', 'int' ); + + $oldType =& JTable::getInstance('menutypes' ); + $oldType->load( $id ); + + $menuType =& JTable::getInstance('menutypes'); + $menuType->bind( JRequest::get( 'post' ) ); + + $isNew = ($menuType->id == 0); + $isChanged = ($oldType->menutype != $menuType->menutype); + + if (!$menuType->check()) { + JError::raiseWarning( 500, $menuType->getError() ); + $this->setRedirect( 'index.php?option=com_menus&task=editMenu', 'Please check your menu settings' ); + return false; + } + + if (!$menuType->store()) { + JError::raiseWarning( 500, $menuType->getError() ); + $this->setRedirect( 'index.php?option=com_menus&task=editMenu', 'Please check your menu settings' ); + return false; + } + + if ($isNew) + { + if ($title = JRequest::getVar( 'module_title', $menuType->menutype, 'post', 'string' )) + { + $module =& JTable::getInstance( 'module'); + $module->title = $title; + $module->position = 'left'; + $module->module = 'mod_mainmenu'; + $module->published = 0; + $module->iscore = 0; + $module->params = 'menutype='. $menuType->menutype; + + // check then store data in db + if (!$module->check()) { + return JError::raiseWarning( 500, $module->getError() ); + } + if (!$module->store()) { + return JError::raiseWarning( 500, $module->getError() ); + } + $module->checkin(); + $module->reorder( 'position='.$db->Quote($module->position) ); + + // module assigned to show on All pages by default + // Clean up possible garbage first + $query = 'DELETE FROM #__modules_menu WHERE moduleid = '.(int) $module->id; + $db->setQuery( $query ); + if (!$db->query()) { + return JError::raiseWarning( 500, $db->getError() ); + } + + // ToDO: Changed to become a Joomla! db-object + $query = 'INSERT INTO #__modules_menu VALUES ( '.(int) $module->id.', 0 )'; + $db->setQuery( $query ); + if (!$db->query()) { + return JError::raiseWarning( 500, $db->getError() ); + } + } + + $msg = JText::sprintf( 'New Menu created', $menuType->menutype ); + } + else if ($isChanged) + { + $oldTerm = $oldType->menutype; + $newTerm = $menuType->menutype; + + // change menutype being of all mod_mainmenu modules calling old menutype + $query = 'SELECT id' + . ' FROM #__modules' + . ' WHERE module = "mod_mainmenu"' + . ' AND params LIKE "%menutype='.$db->getEscaped($oldTerm).'%"' + ; + $db->setQuery( $query ); + $modules = $db->loadResultArray(); + + foreach ($modules as $id) + { + $row =& JTable::getInstance('module'); + $row->load( $id ); + + $row->params = str_replace( $oldTerm, $newTerm, $row->params ); + + // check then store data in db + if ( !$row->check() ) { + return JError::raiseWarning( 500, $db->getError() ); + } + if ( !$row->store() ) { + return JError::raiseWarning( 500, $db->getError() ); + } + $row->checkin(); + } + + // change menutype of all menuitems using old menutype + $query = 'UPDATE #__menu' + . ' SET menutype = '.$db->Quote($newTerm) + . ' WHERE menutype = '.$db->Quote($oldTerm) + ; + $db->setQuery( $query ); + $db->query(); + + $msg = JText::_( 'Menu Items & Modules updated' ); + } + + $this->setRedirect( 'index.php?option=com_menus', $msg ); + } + + /** + * Controller for a view to confirm the deletion of a menu type + */ + function deleteMenu() + { + $view =& $this->getView( 'Menus' ); + $model =& $this->getModel( 'Menutype' ); + $view->setModel( $model, true ); + $view->deleteForm(); + } + + /** + * Delete a menu + */ + function doDeleteMenu() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $id = JRequest::getVar( 'id', 0, '', 'int' ); + if ($id <= 0) { + JError::raiseWarning( 500, JText::_( 'Invalid ID provided' ) ); + $this->setRedirect( 'index.php?option=com_menus' ); + return false; + } + + $model =& $this->getModel( 'Menutype' ); + if (!$model->canDelete()) { + JError::raiseWarning( 500, $model->getError() ); + $this->setRedirect( 'index.php?option=com_menus' ); + return false; + } + $err = null; + if (!$model->delete()) { + $err = $model->getError(); + } + $this->setRedirect( 'index.php?option=com_menus', $err ); + } + + /** + * Compiles a list of the articles you have selected to Copy + */ + function copyMenu() + { + $view =& $this->getView( 'Menus' ); + $model =& $this->getModel( 'Menutype' ); + $view->setModel( $model, true ); + $view->copyForm(); + } + + /** + * Copies a complete menu, all its items and creates a new module, using the name speified + */ + function doCopyMenu() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $type = JRequest::getVar( 'type', '', 'post', 'string' ); + $menu_name = JRequest::getVar( 'menu_name', 'New Menu', 'post', 'string' ); + $module_name = JRequest::getVar( 'module_name', 'New Module', 'post', 'string' ); + + // check for unique menutype for new menu copy + $query = 'SELECT params' . + ' FROM #__modules' . + ' WHERE module = "mod_mainmenu"'; + $db->setQuery( $query ); + $menus = $db->loadResultArray(); + + foreach ( $menus as $menu ) + { + $params = new JParameter( $menu ); + if ( $params->get('menutype') == $menu_name ) { + JError::raiseWarning( 500, JText::_( 'ERRORMENUNAMEEXISTS' ) ); + $this->setRedirect( 'index.php?option=com_menus' ); + return; + } + } + + // copy the menu items + $mids = JRequest::getVar( 'mids', array(), 'post', 'array' ); + JArrayHelper::toInteger($mids); + $total = count( $mids ); + $copy =& JTable::getInstance('menu'); + $original =& JTable::getInstance('menu'); + sort( $mids ); + $a_ids = array(); + + foreach( $mids as $mid ) + { + $original->load( $mid ); + $parent = $original->parent; + $id = $original->id; + $copy = $original; + $copy->id = NULL; + $copy->parent = $a_ids[$parent]; + $copy->menutype = $menu_name; + $copy->home = 0; + + if ( !$copy->check() ) { + JError::raiseWarning( 500, $copy->getError() ); + $this->setRedirect( 'index.php?option=com_menus' ); + return; + } + if ( !$copy->store() ) { + JError::raiseWarning( 500, $copy->getError() ); + $this->setRedirect( 'index.php?option=com_menus' ); + return; + } + $a_ids[$id] = $copy->id; + } + + // create the module copy + $row =& JTable::getInstance('module'); + $row->load( 0 ); + $row->title = $module_name; + $row->iscore = 0; + $row->published = 1; + $row->position = 'left'; + $row->module = 'mod_mainmenu'; + $row->params = 'menutype='. $menu_name; + + if (!$row->check()) { + JError::raiseWarning( 500, $db->getError() ); + $this->setRedirect( 'index.php?option=com_menus' ); + return; + } + if (!$row->store()) { + JError::raiseWarning( 500, $db->getError() ); + $this->setRedirect( 'index.php?option=com_menus' ); + return; + } + $row->checkin(); + $row->reorder( 'position='.$db->Quote($row->position) ); + // module assigned to show on All pages by default + // ToDO: Changed to become a Joomla! db-object + $query = 'INSERT INTO #__modules_menu' . + ' VALUES ( '.(int) $row->id.', 0 )'; + $db->setQuery( $query ); + if ( !$db->query() ) { + JError::raiseWarning( 500, $db->getErrorMsg(true) ); + $this->setRedirect( 'index.php?option=com_menus' ); + return; + //echo "\n"; + //$mainframe->close(); + } + + // Insert the menu type + $query = 'INSERT INTO `#__menu_types` ( `menutype` , `title` , `description` ) ' . + ' VALUES ( '.$db->Quote($menu_name).', '.$db->Quote($menu_name).', "")'; + $db->setQuery( $query ); + if ( !$db->query() ) { + JError::raiseWarning( 500, $db->getErrorMsg(true) ); + $this->setRedirect( 'index.php?option=com_menus' ); + return; + //echo "\n"; + //$mainframe->close(); + } + + $msg = JText::sprintf( 'Copy of Menu created', $type, $total ); + $mainframe->redirect( 'index.php?option=com_menus', $msg ); + } +} \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/helpers/helper.php b/oss/joomla/trunk/administrator/components/com_menus/helpers/helper.php index 87093b8f..3aebe442 100644 --- a/oss/joomla/trunk/administrator/components/com_menus/helpers/helper.php +++ b/oss/joomla/trunk/administrator/components/com_menus/helpers/helper.php @@ -1,171 +1,171 @@ -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' . - ' ORDER BY c.name'; - $db->setQuery( $query ); - $result = $db->loadObjectList( ); - 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(); - } - } -} +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 ); + $result = $db->loadObjectList( ); + 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(); + } + } +} diff --git a/oss/joomla/trunk/administrator/components/com_menus/menus.xml b/oss/joomla/trunk/administrator/components/com_menus/menus.xml index 876a799c..8e79833c 100644 --- a/oss/joomla/trunk/administrator/components/com_menus/menus.xml +++ b/oss/joomla/trunk/administrator/components/com_menus/menus.xml @@ -1,12 +1,12 @@ - - - Menus Manager - Joomla! Project - 2006 - Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - admin@joomla.org - www.joomla.org - 1.5.0 - Menu Manager - + + + Menus Manager + Joomla! Project + 2006 + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + Menu Manager + diff --git a/oss/joomla/trunk/administrator/components/com_menus/models/item.php b/oss/joomla/trunk/administrator/components/com_menus/models/item.php index a4ba5427..983fd036 100644 --- a/oss/joomla/trunk/administrator/components/com_menus/models/item.php +++ b/oss/joomla/trunk/administrator/components/com_menus/models/item.php @@ -1,792 +1,792 @@ -_url = 'index.php?option='.$url['option']; - unset($url['option']); - if (count($url)) { - foreach ($url as $k => $v) - { - $this->_url .= '&'.$k.'='.$v; - } - } - } - - $this->setId(); - } - - function setId() - { - $array = JRequest::getVar('cid', array(0), '', 'array'); - $this->_id = (int) $array[0]; - - if (!$this->_id) { - $this->_id = JRequest::getInt('id', 0); - } - } - - function &getItem() - { - static $item; - if (isset($item)) { - return $item; - } - - $table =& $this->_getTable(); - - // Load the current item if it has been defined - $edit = JRequest::getVar('edit',true); - $cid = JRequest::getVar( 'cid', array(0), '', 'array' ); - JArrayHelper::toInteger($cid, array(0)); - if ($edit) { - $table->load($cid[0]); - } - - // Override the current item's type field if defined in the request - if ($type = JRequest::getString('type')) { - $table->type = $type; - } - - // Override the current item's menutype field if defined in the request - if ($menu_type = JRequest::getString('menutype')) { - $table->menutype = $menu_type; - } - - switch ($table->type) - { - case 'separator': - $table->link = null; - $table->componentid = 0; - break; - case 'url': - $table->componentid = 0; - break; - case 'menulink': - $table->componentid = 0; - break; - case 'component': - // Override the current item's link field if defined in the request - if (!is_null($this->_url)) { - $table->link = $this->_url; - } - $url = str_replace('index.php?', '', $table->link); - $url = str_replace('&', '&', $url); - $table->linkparts = null; - if(strpos($url, '&') !== false) - { - $url = str_replace('&','&',$url); - } - - parse_str($url, $table->linkparts); - - $db = &$this->getDBO(); - if ($component = @$table->linkparts['option']) { - $query = 'SELECT `id`' . - ' FROM `#__components`' . - ' WHERE `link` <> \'\'' . - ' AND `parent` = 0' . - ' AND `option` = "'.$db->getEscaped($component).'"'; - $db->setQuery( $query ); - $table->componentid = $db->loadResult(); - } - break; - } - - $item = $table; - return $item; - } - - function &getExpansion() - { - $item = &$this->getItem(); - $return['option'] = JRequest::getCmd('expand'); - $menutype = JRequest::getString('menutype'); - - if ($return['option']) - { - require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_menus'.DS.'classes'.DS.'ilink.php'); - $handler = new iLink($return['option'], $item->id, $menutype); - $return['html'] = $handler->getTree(); - return $return; - } else { - $return['html'] = null; - } - return $return; - } - - function &getUrlParams() - { - // Get the state parameters - $item =& $this->getItem(); - $params = new JParameter(''); - - if ($state =& $this->_getStateXML()) - { - if (is_a($state, 'JSimpleXMLElement')) - { - $sp =& $state->getElementByPath('url'); - $params->setXML($sp); - if (isset($item->linkparts) && is_array($item->linkparts)) { - $params->loadArray($item->linkparts); - } - } - } - return $params; - } - - function &getStateParams() - { - // Get the state parameters - $item =& $this->getItem(); - $params = new JParameter($item->params); - - if ($state =& $this->_getStateXML()) - { - if (is_a($state, 'JSimpleXMLElement')) - { - $sp =& $state->getElementByPath('params'); - $params->setXML($sp); - } - } - return $params; - } - - function &getAdvancedParams() - { - // Get the state parameters - $item =& $this->getItem(); - $params = new JParameter($item->params); - - if ($state =& $this->_getStateXML()) - { - if (is_a($state, 'JSimpleXMLElement')) - { - $ap =& $state->getElementByPath('advanced'); - $params->setXML($ap); - } - } - return $params; - } - - function &getComponentParams() - { - // Initialize variables - $params = null; - $item = &$this->getItem(); - - if ($item->type == 'component') - { - $comp = &$this->getComponent(); - $option = preg_replace( '#\W#', '', $comp->option ); - $path = JPATH_ADMINISTRATOR.DS.'components'.DS.$option.DS.'config.xml'; - - $params = new JParameter( $item->params ); - if (file_exists( $path )) - { - $xml =& JFactory::getXMLParser('Simple'); - if ($xml->loadFile($path)) - { - $document =& $xml->document; - - // if hide is set, don't show the component configuration while editing menu item - $menu = $document->attributes('menu'); - if ( isset($menu) && $menu == 'hide' ) - { - $params = null; - return $params; - } - - if (isset($document->params[0]->param)) - { - // We will collect the hidden elements in an array - // loop will mess up if we do it within the loop - $hide = array(); - for ($i=0,$n=count($document->params[0]->param); $i<$n; $i++) - { - if ($document->params[0]->param[$i]->attributes('menu') == 'hide') - { - $hide[] = &$document->params[0]->param[$i]; - } - else if ($document->params[0]->param[$i]->attributes('type') == 'radio' || $document->params[0]->param[$i]->attributes('type') == 'list') { - $document->params[0]->param[$i]->addAttribute('default', ''); - $document->params[0]->param[$i]->addAttribute('type', 'list'); - $child = &$document->params[0]->param[$i]->addChild('option', array('value' => '')); - $child->setData('Use Global'); - } - } - // Now remove any hidden elements - for ($i = 0, $n = count( $hide ); $i < $n; $i++) { - $document->params[0]->removeChild( $hide[$i] ); - } - } - $params->setXML( $document->params[0] ); - } - } - } - return $params; - } - - function &getSystemParams() - { - // Initialize variables - $params = null; - $item = &$this->getItem(); - - $params = new JParameter( $item->params ); - if ($item->type == 'component') { - $path = JPATH_BASE.DS.'components'.DS.'com_menus'.DS.'models'.DS.'metadata'.DS.'component.xml'; - if (file_exists( $path )) { - $xml =& JFactory::getXMLParser('Simple'); - if ($xml->loadFile($path)) { - $document =& $xml->document; - $params->setXML($document->getElementByPath('state/params')); - } - } - } - return $params; - } - - /** - * Get the name of the current menu item - * - * @return string - * @access public - * @since 1.5 - */ - function getStateName() - { - $state =& $this->_getStateXML(); - - if ( ! is_a($state, 'JSimpleXMLElement')) - { - return null; - } - - $name = null; - $sn =& $state->getElementByPath('name'); - if ($sn) { - $name = $sn->data(); - } - - return JText::_($name); - } - - /** - * Get the description of the current menu item - * - * @return string - * @access public - * @since 1.5 - */ - function getStateDescription() - { - $state =& $this->_getStateXML(); - - - if ( ! is_a($state, 'JSimpleXMLElement')) - { - return null; - } - - $description = null; - $sd =& $state->getElementByPath('description'); - if ($sd) { - $description = $sd->data(); - } - - return JText::_($description); - } - - /** - * Gets the componet table object related to this menu item - */ - function &getComponent() - { - $item =& $this->getItem(); - $id = $item->componentid; - $component = & JTable::getInstance( 'component'); - $component->load( $id ); - return $component; - } - - function checkout($uid = null) - { - $id = JRequest::getVar('cid', array(0), '', 'array'); - JArrayHelper::toInteger( $id, array(0) ); - - // Make sure we have a user id to checkout the article with - if (is_null($uid)) { - $user =& JFactory::getUser(); - $uid = $user->get('id'); - } - - // Lets get to it and checkout the thing... - $item =& $this->getItem(); - if(!$item->checkout($uid, $id[0])) { - $this->setError($this->_db->getErrorMsg()); - return false; - } - - return true; - } - - function checkin() - { - if ($this->_id) { - $item =& $this->_getTable(); - - if(!$item->checkin($this->_id)) { - $this->setError($this->_db->getErrorMsg()); - return false; - } - - return true; - } - - return false; - } - - function store() - { - // Initialize variables - $db =& JFactory::getDBO(); - $row =& $this->getItem(); - $post = $this->_state->get( 'request' ); - - switch ($post['type']) - { - case 'separator': - break; - case 'url': - break; - case 'menulink': - $post['link'] = 'index.php?Itemid='.$post['params']['menu_item']; - break; - case 'component': - break; - } - if (!$row->bind( $post )) { - echo "\n"; - return false; - } - - if ($row->id > 0) - { - // existing item - $query = 'SELECT menutype FROM #__menu WHERE id = '.(int) $row->id; - $this->_db->setQuery( $query ); - $oldType = $this->_db->loadResult(); - if ($oldType != $row->menutype) { - // moved to another menu, disconnect the old parent - $row->parent = 0; - } - $query = 'SELECT parent FROM #__menu WHERE id = '.(int) $row->id; - $this->_db->setQuery( $query ); - $oldParent = $this->_db->loadResult(); - if ($oldParent != $row->parent) { - // we have changed parents, so we have to fix the submenu values - if ($row->parent != 0) { - $query = 'SELECT sublevel FROM #__menu WHERE id = '.(int) $row->parent; - $this->_db->setQuery( $query ); - $sublevel = $this->_db->loadResult() + 1; - } else { - $sublevel = 0; - } - $row->sublevel = $sublevel; - $this->_setSubLevel( array( (int) $row->id ), $sublevel ); - } - } - else - { - // if new item order last in appropriate group - $where = "menutype = " . $db->Quote($row->menutype) . " AND published >= 0 AND parent = ".(int) $row->parent; - $row->ordering = $row->getNextOrder( $where ); - - if( $row->parent != 0 ) { - $query = 'SELECT sublevel FROM #__menu WHERE id = '. (int) $row->parent; - $this->_db->setQuery($query); - $row->sublevel = $this->_db->loadResult() + 1; - } - } - - if (isset($post['urlparams']) && is_array($post['urlparams'])) - { - $pos = strpos( $row->link, '?' ); - if ($pos !== false) - { - $prefix = substr( $row->link, 0, $pos ); - $query = substr( $row->link, $pos+1 ); - - $temp = array(); - if(strpos($query, '&') !== false) { - $query = str_replace('&', '&', $query); - } - parse_str( $query, $temp ); - $temp2 = array_merge( $temp, $post['urlparams'] ); - - $temp3 = array(); - foreach ($temp2 as $k => $v) - { - if ( $k && strlen($v) ) - { - $temp3[] = $k.'='.$v; - } - } - $url = null; - $row->link = $prefix . '?' . implode( '&', $temp3 ); - } - } - - if (!$row->check()) - { - echo "\n"; - return false; - } - - if (!$row->store()) - { - echo "\n"; - return false; - } - - $row->checkin(); - $row->reorder( 'menutype='.$db->Quote( $row->menutype ).' AND parent='.(int)$row->parent ); - - // clean cache - MenusHelper::cleanCache(); - - return true; - } - - - - /** - * Delete one or more menu items - * @param mixed int or array of id values - */ - function delete( $ids ) - { - JArrayHelper::toInteger($ids); - - $db = &$this->getDBO(); - - if (count( $ids )) - { - // Delete associated module and template mappings - $where = 'WHERE menuid = ' . implode( ' OR menuid = ', $ids ); - - $query = 'DELETE FROM #__modules_menu ' - . $where; - $db->setQuery( $query ); - if (!$db->query()) { - $this->setError( $menuTable->getErrorMsg() ); - return false; - } - - $query = 'DELETE FROM #__templates_menu ' - . $where; - $db->setQuery( $query ); - if (!$db->query()) { - $this->setError( $menuTable->getErrorMsg() ); - return false; - } - - // Set any alias menu types to not point to missing menu items - $query = 'UPDATE #__menu SET link = 0 WHERE type = \'menulink\' AND (link = '.implode( ' OR id = ', $ids ).')'; - $db->setQuery( $query ); - if (!$db->query()) { - $this->setError( $db->getErrorMsg() ); - return false; - } - - // Delete the menu items - $where = 'WHERE id = ' . implode( ' OR id = ', $ids ); - - $query = 'DELETE FROM #__menu ' . $where; - $db->setQuery( $query ); - if (!$db->query()) { - $this->setError( $db->getErrorMsg() ); - return false; - } - } - - // clean cache - MenusHelper::cleanCache(); - - return true; - } - - /** - * Delete menu items by type - */ - function deleteByType( $type = '' ) - { - $db = &$this->getDBO(); - - $query = 'SELECT id' . - ' FROM #__menu' . - ' WHERE menutype = ' . $db->Quote( $type ); - $db->setQuery( $query ); - $ids = $db->loadResultArray(); - - if ($db->getErrorNum()) - { - $this->setError( $db->getErrorMsg() ); - return false; - } - - return $this->delete( $ids ); - } - - /** - * Returns the internal table object - * @return JTable - */ - function &_getTable() - { - if ($this->_table == null) { - $this->_table =& JTable::getInstance( 'menu'); - } - return $this->_table; - } - - function &_getStateXML() - { - static $xml; - - if (isset($xml)) { - return $xml; - } - $xml = null; - $xmlpath = null; - $item = &$this->getItem(); - - switch ($item->type) - { - case 'separator': - $xmlpath = JPATH_BASE.DS.'components'.DS.'com_menus'.DS.'models'.DS.'metadata'.DS.'separator.xml'; - break; - case 'url': - $xmlpath = JPATH_BASE.DS.'components'.DS.'com_menus'.DS.'models'.DS.'metadata'.DS.'url.xml'; - break; - case 'menulink': - $xmlpath = JPATH_BASE.DS.'components'.DS.'com_menus'.DS.'models'.DS.'metadata'.DS.'menulink.xml'; - break; - case 'component': - default: - if (isset($item->linkparts['view'])) - { - // View is set... so we konw to look in view file - if (isset($item->linkparts['layout'])) { - $layout = $item->linkparts['layout']; - } else { - $layout = 'default'; - } - $lpath = JPATH_ROOT.DS.'components'.DS.$item->linkparts['option'].DS.'views'.DS.$item->linkparts['view'].DS.'tmpl'.DS.$layout.'.xml'; - $vpath = JPATH_ROOT.DS.'components'.DS.$item->linkparts['option'].DS.'views'.DS.$item->linkparts['view'].DS.'metadata.xml'; - if (file_exists($lpath)) { - $xmlpath = $lpath; - } elseif (file_exists($vpath)) { - $xmlpath = $vpath; - } - } - if (!$xmlpath && isset($item->linkparts['option'])) { - $xmlpath = JPATH_ROOT.DS.'components'.DS.$item->linkparts['option'].DS.'metadata.xml'; - if(!file_exists($xmlpath)) { - $xmlpath = JApplicationHelper::getPath('com_xml', $item->linkparts['option']); - } - } - break; - } - - if (file_exists($xmlpath)) - { - $xml =& JFactory::getXMLParser('Simple'); - if ($xml->loadFile($xmlpath)) { - $this->_xml = &$xml; - $document =& $xml->document; - - /* - * HANDLE NO OPTION CASE - */ - $menus =& $document->getElementByPath('menu'); - if (is_a($menus, 'JSimpleXMLElement') && $menus->attributes('options') == 'none') { - $xml =& $menus->getElementByPath('state'); - } else { - $xml =& $document->getElementByPath('state'); - } - - // Handle error case... path doesn't exist - if (!is_a($xml, 'JSimpleXMLElement')) { - return $document; - } - - /* - * HANDLE A SWITCH IF IT EXISTS - */ - if ($switch = $xml->attributes('switch')) - { - $default = $xml->attributes('default'); - // Handle switch - $switchVal = (isset($item->linkparts[$switch]))? $item->linkparts[$switch] : 'default'; - $found = false; - - foreach ($xml->children() as $child) { - if ($child->name() == $switchVal) { - $xml =& $child; - $found = true; - break; - } - } - - if (!$found) { - foreach ($xml->children() as $child) { - if ($child->name() == $default) { - $xml =& $child; - break; - } - } - } - } - - /* - * HANDLE INCLUDED PARAMS - */ - $children = $xml->children(); - if (count($children) == 1) - { - if ($children[0]->name() == 'include') { - $ret =& $this->_getIncludedParams($children[0]); - if ($ret) { - $xml =& $ret; - } - } - } - - if ($switch = $xml->attributes('switch')) - { - $default = $xml->attributes('default'); - // Handle switch - $switchVal = ($item->linkparts[$switch])? $item->linkparts[$switch] : 'default'; - $found = false; - - foreach ($xml->children() as $child) { - if ($child->name() == $switchVal) { - $xml =& $child; - $found = true; - break; - } - } - - if (!$found) { - foreach ($xml->children() as $child) { - if ($child->name() == $default) { - $xml =& $child; - break; - } - } - } - } - } - } - return $xml; - } - - function &_getIncludedParams($include) - { - $tags = array(); - $state = null; - $source = $include->attributes('source'); - $path = $include->attributes('path'); - $item = &$this->getItem(); - - preg_match_all( "/{([A-Za-z\-_]+)}/", $source, $tags); - if (isset($tags[1])) { - for ($i=0;$ilinkparts[$tags[1][$i]], $source); - } - } - - // load the source xml file - if (file_exists( JPATH_ROOT.$source )) - { - $xml = & JFactory::getXMLParser('Simple'); - - if ($xml->loadFile(JPATH_ROOT.$source)) { - $document = &$xml->document; - $state = $document->getElementByPath($path); - } - } - return $state; - } - - /** - * Sets the sublevel for menu items - * - * @param array id values to set - * @param int level to assign to the sublevel - */ - function _setSubLevel( $cid, $level ) - { - JArrayHelper::toInteger($cid, array(0)); - - $ids = implode( ',', $cid ); - - $query = 'UPDATE #__menu SET sublevel = '.(int) $level - .' WHERE id IN ('.$ids.')'; - $this->_db->setQuery( $query ); - $this->_db->query(); - - $query = 'SELECT id FROM #__menu WHERE parent IN ('.$ids.')'; - $this->_db->setQuery( $query ); - $cids = $this->_db->loadResultArray( 0 ); - - if (!empty( $cids )) { - $this->_setSubLevel( $cids, $level + 1 ); - } - } -} +_url = 'index.php?option='.$url['option']; + unset($url['option']); + if (count($url)) { + foreach ($url as $k => $v) + { + $this->_url .= '&'.$k.'='.$v; + } + } + } + + $this->setId(); + } + + function setId() + { + $array = JRequest::getVar('cid', array(0), '', 'array'); + $this->_id = (int) $array[0]; + + if (!$this->_id) { + $this->_id = JRequest::getInt('id', 0); + } + } + + function &getItem() + { + static $item; + if (isset($item)) { + return $item; + } + + $table =& $this->_getTable(); + + // Load the current item if it has been defined + $edit = JRequest::getVar('edit',true); + $cid = JRequest::getVar( 'cid', array(0), '', 'array' ); + JArrayHelper::toInteger($cid, array(0)); + if ($edit) { + $table->load($cid[0]); + } + + // Override the current item's type field if defined in the request + if ($type = JRequest::getString('type')) { + $table->type = $type; + } + + // Override the current item's menutype field if defined in the request + if ($menu_type = JRequest::getString('menutype')) { + $table->menutype = $menu_type; + } + + switch ($table->type) + { + case 'separator': + $table->link = null; + $table->componentid = 0; + break; + case 'url': + $table->componentid = 0; + break; + case 'menulink': + $table->componentid = 0; + break; + case 'component': + // Override the current item's link field if defined in the request + if (!is_null($this->_url)) { + $table->link = $this->_url; + } + $url = str_replace('index.php?', '', $table->link); + $url = str_replace('&', '&', $url); + $table->linkparts = null; + if(strpos($url, '&') !== false) + { + $url = str_replace('&','&',$url); + } + + parse_str($url, $table->linkparts); + + $db = &$this->getDBO(); + if ($component = @$table->linkparts['option']) { + $query = 'SELECT `id`' . + ' FROM `#__components`' . + ' WHERE `link` <> \'\'' . + ' AND `parent` = 0' . + ' AND `option` = "'.$db->getEscaped($component).'"'; + $db->setQuery( $query ); + $table->componentid = $db->loadResult(); + } + break; + } + + $item = $table; + return $item; + } + + function &getExpansion() + { + $item = &$this->getItem(); + $return['option'] = JRequest::getCmd('expand'); + $menutype = JRequest::getString('menutype'); + + if ($return['option']) + { + require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_menus'.DS.'classes'.DS.'ilink.php'); + $handler = new iLink($return['option'], $item->id, $menutype); + $return['html'] = $handler->getTree(); + return $return; + } else { + $return['html'] = null; + } + return $return; + } + + function &getUrlParams() + { + // Get the state parameters + $item =& $this->getItem(); + $params = new JParameter(''); + + if ($state =& $this->_getStateXML()) + { + if (is_a($state, 'JSimpleXMLElement')) + { + $sp =& $state->getElementByPath('url'); + $params->setXML($sp); + if (isset($item->linkparts) && is_array($item->linkparts)) { + $params->loadArray($item->linkparts); + } + } + } + return $params; + } + + function &getStateParams() + { + // Get the state parameters + $item =& $this->getItem(); + $params = new JParameter($item->params); + + if ($state =& $this->_getStateXML()) + { + if (is_a($state, 'JSimpleXMLElement')) + { + $sp =& $state->getElementByPath('params'); + $params->setXML($sp); + } + } + return $params; + } + + function &getAdvancedParams() + { + // Get the state parameters + $item =& $this->getItem(); + $params = new JParameter($item->params); + + if ($state =& $this->_getStateXML()) + { + if (is_a($state, 'JSimpleXMLElement')) + { + $ap =& $state->getElementByPath('advanced'); + $params->setXML($ap); + } + } + return $params; + } + + function &getComponentParams() + { + // Initialize variables + $params = null; + $item = &$this->getItem(); + + if ($item->type == 'component') + { + $comp = &$this->getComponent(); + $option = preg_replace( '#\W#', '', $comp->option ); + $path = JPATH_ADMINISTRATOR.DS.'components'.DS.$option.DS.'config.xml'; + + $params = new JParameter( $item->params ); + if (file_exists( $path )) + { + $xml =& JFactory::getXMLParser('Simple'); + if ($xml->loadFile($path)) + { + $document =& $xml->document; + + // if hide is set, don't show the component configuration while editing menu item + $menu = $document->attributes('menu'); + if ( isset($menu) && $menu == 'hide' ) + { + $params = null; + return $params; + } + + if (isset($document->params[0]->param)) + { + // We will collect the hidden elements in an array + // loop will mess up if we do it within the loop + $hide = array(); + for ($i=0,$n=count($document->params[0]->param); $i<$n; $i++) + { + if ($document->params[0]->param[$i]->attributes('menu') == 'hide') + { + $hide[] = &$document->params[0]->param[$i]; + } + else if ($document->params[0]->param[$i]->attributes('type') == 'radio' || $document->params[0]->param[$i]->attributes('type') == 'list') { + $document->params[0]->param[$i]->addAttribute('default', ''); + $document->params[0]->param[$i]->addAttribute('type', 'list'); + $child = &$document->params[0]->param[$i]->addChild('option', array('value' => '')); + $child->setData('Use Global'); + } + } + // Now remove any hidden elements + for ($i = 0, $n = count( $hide ); $i < $n; $i++) { + $document->params[0]->removeChild( $hide[$i] ); + } + } + $params->setXML( $document->params[0] ); + } + } + } + return $params; + } + + function &getSystemParams() + { + // Initialize variables + $params = null; + $item = &$this->getItem(); + + $params = new JParameter( $item->params ); + if ($item->type == 'component') { + $path = JPATH_BASE.DS.'components'.DS.'com_menus'.DS.'models'.DS.'metadata'.DS.'component.xml'; + if (file_exists( $path )) { + $xml =& JFactory::getXMLParser('Simple'); + if ($xml->loadFile($path)) { + $document =& $xml->document; + $params->setXML($document->getElementByPath('state/params')); + } + } + } + return $params; + } + + /** + * Get the name of the current menu item + * + * @return string + * @access public + * @since 1.5 + */ + function getStateName() + { + $state =& $this->_getStateXML(); + + if ( ! is_a($state, 'JSimpleXMLElement')) + { + return null; + } + + $name = null; + $sn =& $state->getElementByPath('name'); + if ($sn) { + $name = $sn->data(); + } + + return JText::_($name); + } + + /** + * Get the description of the current menu item + * + * @return string + * @access public + * @since 1.5 + */ + function getStateDescription() + { + $state =& $this->_getStateXML(); + + + if ( ! is_a($state, 'JSimpleXMLElement')) + { + return null; + } + + $description = null; + $sd =& $state->getElementByPath('description'); + if ($sd) { + $description = $sd->data(); + } + + return JText::_($description); + } + + /** + * Gets the componet table object related to this menu item + */ + function &getComponent() + { + $item =& $this->getItem(); + $id = $item->componentid; + $component = & JTable::getInstance( 'component'); + $component->load( $id ); + return $component; + } + + function checkout($uid = null) + { + $id = JRequest::getVar('cid', array(0), '', 'array'); + JArrayHelper::toInteger( $id, array(0) ); + + // Make sure we have a user id to checkout the article with + if (is_null($uid)) { + $user =& JFactory::getUser(); + $uid = $user->get('id'); + } + + // Lets get to it and checkout the thing... + $item =& $this->getItem(); + if(!$item->checkout($uid, $id[0])) { + $this->setError($this->_db->getErrorMsg()); + return false; + } + + return true; + } + + function checkin() + { + if ($this->_id) { + $item =& $this->_getTable(); + + if(!$item->checkin($this->_id)) { + $this->setError($this->_db->getErrorMsg()); + return false; + } + + return true; + } + + return false; + } + + function store() + { + // Initialize variables + $db =& JFactory::getDBO(); + $row =& $this->getItem(); + $post = $this->_state->get( 'request' ); + + switch ($post['type']) + { + case 'separator': + break; + case 'url': + break; + case 'menulink': + $post['link'] = 'index.php?Itemid='.$post['params']['menu_item']; + break; + case 'component': + break; + } + if (!$row->bind( $post )) { + echo "\n"; + return false; + } + + if ($row->id > 0) + { + // existing item + $query = 'SELECT menutype FROM #__menu WHERE id = '.(int) $row->id; + $this->_db->setQuery( $query ); + $oldType = $this->_db->loadResult(); + if ($oldType != $row->menutype) { + // moved to another menu, disconnect the old parent + $row->parent = 0; + } + $query = 'SELECT parent FROM #__menu WHERE id = '.(int) $row->id; + $this->_db->setQuery( $query ); + $oldParent = $this->_db->loadResult(); + if ($oldParent != $row->parent) { + // we have changed parents, so we have to fix the submenu values + if ($row->parent != 0) { + $query = 'SELECT sublevel FROM #__menu WHERE id = '.(int) $row->parent; + $this->_db->setQuery( $query ); + $sublevel = $this->_db->loadResult() + 1; + } else { + $sublevel = 0; + } + $row->sublevel = $sublevel; + $this->_setSubLevel( array( (int) $row->id ), $sublevel ); + } + } + else + { + // if new item order last in appropriate group + $where = "menutype = " . $db->Quote($row->menutype) . " AND published >= 0 AND parent = ".(int) $row->parent; + $row->ordering = $row->getNextOrder( $where ); + + if( $row->parent != 0 ) { + $query = 'SELECT sublevel FROM #__menu WHERE id = '. (int) $row->parent; + $this->_db->setQuery($query); + $row->sublevel = $this->_db->loadResult() + 1; + } + } + + if (isset($post['urlparams']) && is_array($post['urlparams'])) + { + $pos = strpos( $row->link, '?' ); + if ($pos !== false) + { + $prefix = substr( $row->link, 0, $pos ); + $query = substr( $row->link, $pos+1 ); + + $temp = array(); + if(strpos($query, '&') !== false) { + $query = str_replace('&', '&', $query); + } + parse_str( $query, $temp ); + $temp2 = array_merge( $temp, $post['urlparams'] ); + + $temp3 = array(); + foreach ($temp2 as $k => $v) + { + if ( $k && strlen($v) ) + { + $temp3[] = $k.'='.$v; + } + } + $url = null; + $row->link = $prefix . '?' . implode( '&', $temp3 ); + } + } + + if (!$row->check()) + { + echo "\n"; + return false; + } + + if (!$row->store()) + { + echo "\n"; + return false; + } + + $row->checkin(); + $row->reorder( 'menutype='.$db->Quote( $row->menutype ).' AND parent='.(int)$row->parent ); + + // clean cache + MenusHelper::cleanCache(); + + return true; + } + + + + /** + * Delete one or more menu items + * @param mixed int or array of id values + */ + function delete( $ids ) + { + JArrayHelper::toInteger($ids); + + $db = &$this->getDBO(); + + if (count( $ids )) + { + // Delete associated module and template mappings + $where = 'WHERE menuid = ' . implode( ' OR menuid = ', $ids ); + + $query = 'DELETE FROM #__modules_menu ' + . $where; + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $menuTable->getErrorMsg() ); + return false; + } + + $query = 'DELETE FROM #__templates_menu ' + . $where; + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $menuTable->getErrorMsg() ); + return false; + } + + // Set any alias menu types to not point to missing menu items + $query = 'UPDATE #__menu SET link = 0 WHERE type = \'menulink\' AND (link = '.implode( ' OR id = ', $ids ).')'; + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $db->getErrorMsg() ); + return false; + } + + // Delete the menu items + $where = 'WHERE id = ' . implode( ' OR id = ', $ids ); + + $query = 'DELETE FROM #__menu ' . $where; + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $db->getErrorMsg() ); + return false; + } + } + + // clean cache + MenusHelper::cleanCache(); + + return true; + } + + /** + * Delete menu items by type + */ + function deleteByType( $type = '' ) + { + $db = &$this->getDBO(); + + $query = 'SELECT id' . + ' FROM #__menu' . + ' WHERE menutype = ' . $db->Quote( $type ); + $db->setQuery( $query ); + $ids = $db->loadResultArray(); + + if ($db->getErrorNum()) + { + $this->setError( $db->getErrorMsg() ); + return false; + } + + return $this->delete( $ids ); + } + + /** + * Returns the internal table object + * @return JTable + */ + function &_getTable() + { + if ($this->_table == null) { + $this->_table =& JTable::getInstance( 'menu'); + } + return $this->_table; + } + + function &_getStateXML() + { + static $xml; + + if (isset($xml)) { + return $xml; + } + $xml = null; + $xmlpath = null; + $item = &$this->getItem(); + + switch ($item->type) + { + case 'separator': + $xmlpath = JPATH_BASE.DS.'components'.DS.'com_menus'.DS.'models'.DS.'metadata'.DS.'separator.xml'; + break; + case 'url': + $xmlpath = JPATH_BASE.DS.'components'.DS.'com_menus'.DS.'models'.DS.'metadata'.DS.'url.xml'; + break; + case 'menulink': + $xmlpath = JPATH_BASE.DS.'components'.DS.'com_menus'.DS.'models'.DS.'metadata'.DS.'menulink.xml'; + break; + case 'component': + default: + if (isset($item->linkparts['view'])) + { + // View is set... so we konw to look in view file + if (isset($item->linkparts['layout'])) { + $layout = $item->linkparts['layout']; + } else { + $layout = 'default'; + } + $lpath = JPATH_ROOT.DS.'components'.DS.$item->linkparts['option'].DS.'views'.DS.$item->linkparts['view'].DS.'tmpl'.DS.$layout.'.xml'; + $vpath = JPATH_ROOT.DS.'components'.DS.$item->linkparts['option'].DS.'views'.DS.$item->linkparts['view'].DS.'metadata.xml'; + if (file_exists($lpath)) { + $xmlpath = $lpath; + } elseif (file_exists($vpath)) { + $xmlpath = $vpath; + } + } + if (!$xmlpath && isset($item->linkparts['option'])) { + $xmlpath = JPATH_ROOT.DS.'components'.DS.$item->linkparts['option'].DS.'metadata.xml'; + if(!file_exists($xmlpath)) { + $xmlpath = JApplicationHelper::getPath('com_xml', $item->linkparts['option']); + } + } + break; + } + + if (file_exists($xmlpath)) + { + $xml =& JFactory::getXMLParser('Simple'); + if ($xml->loadFile($xmlpath)) { + $this->_xml = &$xml; + $document =& $xml->document; + + /* + * HANDLE NO OPTION CASE + */ + $menus =& $document->getElementByPath('menu'); + if (is_a($menus, 'JSimpleXMLElement') && $menus->attributes('options') == 'none') { + $xml =& $menus->getElementByPath('state'); + } else { + $xml =& $document->getElementByPath('state'); + } + + // Handle error case... path doesn't exist + if (!is_a($xml, 'JSimpleXMLElement')) { + return $document; + } + + /* + * HANDLE A SWITCH IF IT EXISTS + */ + if ($switch = $xml->attributes('switch')) + { + $default = $xml->attributes('default'); + // Handle switch + $switchVal = (isset($item->linkparts[$switch]))? $item->linkparts[$switch] : 'default'; + $found = false; + + foreach ($xml->children() as $child) { + if ($child->name() == $switchVal) { + $xml =& $child; + $found = true; + break; + } + } + + if (!$found) { + foreach ($xml->children() as $child) { + if ($child->name() == $default) { + $xml =& $child; + break; + } + } + } + } + + /* + * HANDLE INCLUDED PARAMS + */ + $children = $xml->children(); + if (count($children) == 1) + { + if ($children[0]->name() == 'include') { + $ret =& $this->_getIncludedParams($children[0]); + if ($ret) { + $xml =& $ret; + } + } + } + + if ($switch = $xml->attributes('switch')) + { + $default = $xml->attributes('default'); + // Handle switch + $switchVal = ($item->linkparts[$switch])? $item->linkparts[$switch] : 'default'; + $found = false; + + foreach ($xml->children() as $child) { + if ($child->name() == $switchVal) { + $xml =& $child; + $found = true; + break; + } + } + + if (!$found) { + foreach ($xml->children() as $child) { + if ($child->name() == $default) { + $xml =& $child; + break; + } + } + } + } + } + } + return $xml; + } + + function &_getIncludedParams($include) + { + $tags = array(); + $state = null; + $source = $include->attributes('source'); + $path = $include->attributes('path'); + $item = &$this->getItem(); + + preg_match_all( "/{([A-Za-z\-_]+)}/", $source, $tags); + if (isset($tags[1])) { + for ($i=0;$ilinkparts[$tags[1][$i]], $source); + } + } + + // load the source xml file + if (file_exists( JPATH_ROOT.$source )) + { + $xml = & JFactory::getXMLParser('Simple'); + + if ($xml->loadFile(JPATH_ROOT.$source)) { + $document = &$xml->document; + $state = $document->getElementByPath($path); + } + } + return $state; + } + + /** + * Sets the sublevel for menu items + * + * @param array id values to set + * @param int level to assign to the sublevel + */ + function _setSubLevel( $cid, $level ) + { + JArrayHelper::toInteger($cid, array(0)); + + $ids = implode( ',', $cid ); + + $query = 'UPDATE #__menu SET sublevel = '.(int) $level + .' WHERE id IN ('.$ids.')'; + $this->_db->setQuery( $query ); + $this->_db->query(); + + $query = 'SELECT id FROM #__menu WHERE parent IN ('.$ids.')'; + $this->_db->setQuery( $query ); + $cids = $this->_db->loadResultArray( 0 ); + + if (!empty( $cids )) { + $this->_setSubLevel( $cids, $level + 1 ); + } + } +} diff --git a/oss/joomla/trunk/administrator/components/com_menus/models/list.php b/oss/joomla/trunk/administrator/components/com_menus/models/list.php index 25d842f7..4702f1b9 100644 --- a/oss/joomla/trunk/administrator/components/com_menus/models/list.php +++ b/oss/joomla/trunk/administrator/components/com_menus/models/list.php @@ -1,749 +1,752 @@ -_table == null) - { - $this->_table =& JTable::getInstance( 'menu'); - } - return $this->_table; - } - - function &getItems() - { - global $mainframe; - - static $items; - - if (isset($items)) { - return $items; - } - - $db =& $this->getDBO(); - - $menutype = $mainframe->getUserStateFromRequest( "com_menus.menutype", 'menutype', 'mainmenu', 'string' ); - $filter_order = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.filter_order', 'filter_order', 'm.ordering', 'cmd' ); - $filter_order_Dir = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.filter_order_Dir', 'filter_order_Dir', 'ASC', 'word' ); - $filter_state = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.filter_state', 'filter_state', '', 'word' ); - $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg( 'list_limit' ), 'int' ); - $limitstart = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.limitstart', 'limitstart', 0, 'int' ); - $levellimit = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.levellimit', 'levellimit', 10, 'int' ); - $search = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.search', 'search', '', 'string' ); - $search = JString::strtolower( $search ); - - $and = ''; - if ( $filter_state ) - { - if ( $filter_state == 'P' ) { - $and = ' AND m.published = 1'; - } else if ($filter_state == 'U' ) { - $and = ' AND m.published = 0'; - } - } - - // just in case filter_order get's messed up - if ($filter_order) { - $orderby = ' ORDER BY '.$filter_order .' '. $filter_order_Dir .', m.parent, m.ordering'; - } else { - $orderby = ' ORDER BY m.parent, m.ordering'; - } - - // select the records - // note, since this is a tree we have to do the limits code-side - if ($search) { - $query = 'SELECT m.id' . - ' FROM #__menu AS m' . - ' WHERE menutype = '.$db->Quote($menutype) . - ' AND LOWER( m.name ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ) . - $and; - $db->setQuery( $query ); - $search_rows = $db->loadResultArray(); - } - - $query = 'SELECT m.*, u.name AS editor, g.name AS groupname, c.publish_up, c.publish_down, com.name AS com_name' . - ' FROM #__menu AS m' . - ' LEFT JOIN #__users AS u ON u.id = m.checked_out' . - ' LEFT JOIN #__groups AS g ON g.id = m.access' . - ' LEFT JOIN #__content AS c ON c.id = m.componentid AND m.type = "content_typed"' . - ' LEFT JOIN #__components AS com ON com.id = m.componentid AND m.type = "component"' . - ' WHERE m.menutype = '.$db->Quote($menutype) . - ' AND m.published != -2' . - $and . - $orderby; - $db->setQuery( $query ); - $rows = $db->loadObjectList(); - - // establish the hierarchy of the menu - $children = array(); - // first pass - collect children - foreach ($rows 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, max( 0, $levellimit-1 ) ); - // eventually only pick out the searched items. - if ($search) { - $list1 = array(); - - foreach ($search_rows as $sid ) - { - foreach ($list as $item) - { - if ($item->id == $sid) { - $list1[] = $item; - } - } - } - // replace full list with found items - $list = $list1; - } - - $total = count( $list ); - - jimport('joomla.html.pagination'); - $this->_pagination = new JPagination( $total, $limitstart, $limit ); - - // slice out elements based on limits - $list = array_slice( $list, $this->_pagination->limitstart, $this->_pagination->limit ); - - $i = 0; - $query = array(); - foreach ( $list as $mitem ) - { - $edit = ''; - switch ( $mitem->type ) - { - case 'separator': - $list[$i]->descrip = JText::_('Separator'); - break; - - case 'url': - $list[$i]->descrip = JText::_('URL'); - break; - - case 'menulink': - $list[$i]->descrip = JText::_('Menu Link'); - break; - - case 'component': - $list[$i]->descrip = JText::_('Component'); - $query = parse_url($list[$i]->link); - $view = array(); - if(isset($query['query'])) { - if(strpos($query['query'], '&') !== false) - { - $query['query'] = str_replace('&','&',$query['query']); - } - parse_str($query['query'], $view); - } - $list[$i]->view = $list[$i]->com_name; - if (isset($view['view'])) - { - $list[$i]->view .= ' » '.JText::_(ucfirst($view['view'])); - } - if (isset($view['layout'])) - { - $list[$i]->view .= ' / '.JText::_(ucfirst($view['layout'])); - } - if (isset($view['task']) && !isset($view['view'])) - { - $list[$i]->view .= ' :: '.JText::_(ucfirst($view['task'])); - } - break; - - default: - $list[$i]->descrip = JText::_('Unknown'); - break; - } - $i++; - } - - $items = $list; - return $items; - } - - function &getPagination() - { - if ($this->_pagination == null) { - $this->getItems(); - } - return $this->_pagination; - } - - /** - * Form for copying item(s) to a specific menu - */ - function getItemsFromRequest() - { - static $items; - - if (isset($items)) { - return $items; - } - - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - JArrayHelper::toInteger($cid); - - if (count($cid) < 1) { - $this->setError(JText::_( 'Select an item to move')); - return false; - } - - // Query to list the selected menu items - $db =& $this->getDBO(); - $cids = implode( ',', $cid ); - $query = 'SELECT `id`, `name`' . - ' FROM `#__menu`' . - ' WHERE `id` IN ( '.$cids.' )'; - - $db->setQuery( $query ); - $items = $db->loadObjectList(); - - return $items; - } - - /** - * Gets the componet table object related to this menu item - */ - function &getComponent() - { - $id = $this->_table->componentid; - $component = & JTable::getInstance( 'component'); - $component->load( $id ); - return $component; - } - - /** - * Save the item(s) to the menu selected - */ - function copy( $items, $menu ) - { - $curr =& JTable::getInstance('menu'); - $itemref = array(); - foreach ($items as $id) - { - $curr->load( $id ); - $curr->id = NULL; - $curr->home = 0; - if ( !$curr->store() ) { - $this->setError($curr->getError()); - return false; - } - $itemref[] = array($id, $curr->id); - } - foreach ($itemref as $ref) - { - $curr->load( $ref[1] ); - if ($curr->parent!=0) { - $found = false; - foreach ( $itemref as $ref2 ) - { - if ($curr->parent == $ref2[0]) { - $curr->parent = $ref2[1]; - $found = true; - break; - } // if - } - if (!$found && $curr->menutype!=$menu) { - $curr->parent = 0; - } - } - $curr->menutype = $menu; - $curr->ordering = '9999'; - $curr->home = 0; - if ( !$curr->store() ) { - $this->setError($curr->getError()); - return false; - } - $curr->reorder( 'menutype = '.$this->_db->Quote($curr->menutype).' AND parent = '.(int) $curr->parent ); - } // foreach - - //Now, we need to rebuild sublevels... - $this->_rebuildSubLevel(); - - // clean cache - MenusHelper::cleanCache(); - - return true; - } - - function move($items, $menu) - { - // Add all children to the list - foreach ($items as $id) - { - $this->_addChildren($id, $items); - } - - $row =& $this->getTable(); - $ordering = 1000000; - $firstroot = 0; - foreach ($items as $id) { - $row->load( $id ); - - // is it moved together with his parent? - $found = false; - if ($row->parent != 0) { - foreach ($items as $idx) - { - if ($idx == $row->parent) { - $found = true; - break; - } // if - } - } - if (!$found) { - $row->parent = 0; - $row->ordering = $ordering++; - if (!$firstroot) $firstroot = $row->id; - } // if - - $row->menutype = $menu; - if ( !$row->store() ) { - $this->setError($row->getError()); - return false; - } // if - } // foreach - - if ($firstroot) { - $row->load( $firstroot ); - $row->reorder( 'menutype = '.$this->_db->Quote($row->menutype).' AND parent = '.(int) $row->parent ); - } // if - - //Rebuild sublevel - $this->_rebuildSubLevel(); - - // clean cache - MenusHelper::cleanCache(); - - return true; - } - - function toTrash($items) - { - $db =& $this->getDBO(); - $nd = $db->getNullDate(); - $state = -2; - $row =& $this->getTable(); - $default = 0; - - // Add all children to the list - foreach ($items as $id) - { - //Check if it's the default item - $row->load( $id ); - if ($row->home != 1) { - $this->_addChildren($id, $items); - } else { - unset($items[$default]); - JError::raiseWarning( 'SOME_ERROR_CODE', JText::_('You cannot trash the default menu item')); - } - $default++; - } - if (!empty($items)) { - // Sent menu items to the trash - JArrayHelper::toInteger($items, array(0)); - $where = ' WHERE (id = ' . implode( ' OR id = ', $items ) . ') AND home = 0'; - $query = 'UPDATE #__menu' . - ' SET published = '.(int) $state.', parent = 0, ordering = 0, checked_out = 0, checked_out_time = '.$db->Quote($nd) . - $where; - $db->setQuery( $query ); - if (!$db->query()) { - $this->setError( $db->getErrorMsg() ); - return false; - } - } - - // clean cache - MenusHelper::cleanCache(); - - return count($items); - } - - function fromTrash($items) - { - $db =& $this->getDBO(); - $nd = $db->getNullDate(); - $state = 0; - - // Add all children to the list - foreach ($items as $id) - { - $this->_addChildren($id, $items); - } - - // Sent menu items to the trash - JArrayHelper::toInteger($items, array(0)); - $where = ' WHERE id = ' . implode( ' OR id = ', $items ); - $query = 'UPDATE #__menu' . - ' SET published = '.(int) $state.', parent = 0, ordering = 99999, checked_out = 0, checked_out_time = '.$db->Quote($nd) . - $where; - $db->setQuery( $query ); - if (!$db->query()) { - $this->setError( $db->getErrorMsg() ); - return false; - } - - // clean cache (require helper because method can be called from com_trash) - require_once( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_menus'.DS.'helpers'.DS.'helper.php' ); - MenusHelper::cleanCache(); - - return count($items); - } - - /** - * Set the state of selected menu items - */ - function setHome( $item ) - { - $db =& $this->getDBO(); - - // Clear home field for all other items - $query = 'UPDATE #__menu' . - ' SET home = 0' . - ' WHERE 1'; - $db->setQuery( $query ); - if ( !$db->query() ) { - $this->setError($db->getErrorMsg()); - return false; - } - - // Set the given item to home - $query = 'UPDATE #__menu' . - ' SET home = 1' . - ' WHERE id = '.(int) $item; - $db->setQuery( $query ); - if ( !$db->query() ) { - $this->setError($db->getErrorMsg()); - return false; - } - - // clean cache - MenusHelper::cleanCache(); - - return true; - } - - /** - * Set the state of selected menu items - */ - function setItemState( $items, $state ) - { - if(is_array($items)) - { - $row =& $this->getTable(); - foreach ($items as $id) - { - $row->load( $id ); - - if ($row->home != 1) { - $row->published = $state; - - if ($state != 1) { - // Set any alias menu types to not point to unpublished menu items - $db = &$this->getDBO(); - $query = 'UPDATE #__menu SET link = 0 WHERE type = \'menulink\' AND link = '.(int)$id; - $db->setQuery( $query ); - if (!$db->query()) { - $this->setError( $db->getErrorMsg() ); - return false; - } - } - - if (!$row->check()) { - $this->setError($row->getError()); - return false; - } - if (!$row->store()) { - $this->setError($row->getError()); - return false; - } - } else { - JError::raiseWarning( 'SOME_ERROR_CODE', JText::_('You cannot unpublish the default menu item')); - return false; - } - } - } - - // clean cache - MenusHelper::cleanCache(); - - return true; - } - - /** - * Set the access of selected menu items - */ - function setAccess( $items, $access ) - { - $row =& $this->getTable(); - foreach ($items as $id) - { - $row->load( $id ); - $row->access = $access; - - // Set any alias menu types to not point to unpublished menu items - $db = &$this->getDBO(); - $query = 'UPDATE #__menu SET link = 0 WHERE type = \'menulink\' AND access < '.(int)$access.' AND link = '.(int)$id; - $db->setQuery( $query ); - if (!$db->query()) { - $this->setError( $db->getErrorMsg() ); - return false; - } - - if (!$row->check()) { - $this->setError($row->getError()); - return false; - } - if (!$row->store()) { - $this->setError($row->getError()); - return false; - } - } - - // clean cache - MenusHelper::cleanCache(); - - return true; - } - - function orderItem($item, $movement) - { - $row =& $this->getTable(); - $row->load( $item ); - if (!$row->move( $movement, 'menutype = '.$this->_db->Quote($row->menutype).' AND parent = '.(int) $row->parent )) { - $this->setError($row->getError()); - return false; - } - - // clean cache - MenusHelper::cleanCache(); - - return true; - } - - function setOrder($items, $menutype) - { - $total = count( $items ); - $row =& $this->getTable(); - $groupings = array(); - - $order = JRequest::getVar( 'order', array(), 'post', 'array' ); - JArrayHelper::toInteger($order); - - // update ordering values - for( $i=0; $i < $total; $i++ ) { - $row->load( $items[$i] ); - // track parents - $groupings[] = $row->parent; - if ($row->ordering != $order[$i]) { - $row->ordering = $order[$i]; - if (!$row->store()) { - $this->setError($row->getError()); - return false; - } - } // if - } // for - - // execute updateOrder for each parent group - $groupings = array_unique( $groupings ); - foreach ($groupings as $group){ - $row->reorder('menutype = '.$this->_db->Quote($menutype).' AND parent = '.(int) $group.' AND published >=0'); - } - - // clean cache - MenusHelper::cleanCache(); - - return true; - } - - /** - * Delete one or more menu items - * @param mixed int or array of id values - */ - function delete( $ids ) - { - JArrayHelper::toInteger($ids); - - if (!empty( $ids )) { - - // Add all children to the list - foreach ($ids as $id) - { - $this->_addChildren($id, $ids); - } - - $db = &$this->getDBO(); - - // Delete associated module and template mappings - $where = 'WHERE menuid = ' . implode( ' OR menuid = ', $ids ); - - $query = 'DELETE FROM #__modules_menu ' - . $where; - $db->setQuery( $query ); - if (!$db->query()) { - $this->setError( $menuTable->getErrorMsg() ); - return false; - } - - $query = 'DELETE FROM #__templates_menu ' - . $where; - $db->setQuery( $query ); - if (!$db->query()) { - $this->setError( $menuTable->getErrorMsg() ); - return false; - } - - // Set any alias menu types to not point to missing menu items - $query = 'UPDATE #__menu SET link = 0 WHERE type = \'menulink\' AND (link = '.implode( ' OR id = ', $ids ).')'; - $db->setQuery( $query ); - if (!$db->query()) { - $this->setError( $db->getErrorMsg() ); - return false; - } - - // Delete the menu items - $where = 'WHERE id = ' . implode( ' OR id = ', $ids ); - - $query = 'DELETE FROM #__menu ' . $where; - $db->setQuery( $query ); - if (!$db->query()) { - $this->setError( $db->getErrorMsg() ); - return false; - } - } - - // clean cache - MenusHelper::cleanCache(); - - return true; - } - - /** - * Delete menu items by type - */ - function deleteByType( $type = '' ) - { - $db = &$this->getDBO(); - - $query = 'SELECT id' . - ' FROM #__menu' . - ' WHERE menutype = ' . $db->Quote( $type ); - $db->setQuery( $query ); - $ids = $db->loadResultArray(); - - if ($db->getErrorNum()) { - $this->setError( $db->getErrorMsg() ); - return false; - } - - return $this->delete( $ids ); - } - - function _addChildren($id, &$list) - { - // Initialize variables - $return = true; - - // Get all rows with parent of $id - $db =& $this->getDBO(); - $query = 'SELECT id' . - ' FROM #__menu' . - ' WHERE parent = '.(int) $id; - $db->setQuery( $query ); - $rows = $db->loadObjectList(); - - // Make sure there aren't any errors - if ($db->getErrorNum()) { - $this->setError($db->getErrorMsg()); - return false; - } - - // Recursively iterate through all children... kinda messy - // TODO: Cleanup this method - foreach ($rows as $row) - { - $found = false; - foreach ($list as $idx) - { - if ($idx == $row->id) { - $found = true; - break; - } - } - if (!$found) { - $list[] = $row->id; - } - $return = $this->_addChildren($row->id, $list); - } - return $return; - } - - /* - * Rebuild the sublevel field for items in the menu (if called with 2nd param = 0 or no params, it will rebuild entire menu tree's sublevel - * @param array of menu item ids to change level to - * @param int level to set the menu items to (based on parent - */ - function _rebuildSubLevel($cid = array(0), $level = 0) - { - JArrayHelper::toInteger($cid, array(0)); - $db =& $this->getDBO(); - $ids = implode( ',', $cid ); - $cids = array(); - if($level == 0) { - $query = 'UPDATE #__menu SET sublevel = 0 WHERE parent = 0'; - $db->setQuery($query); - $db->query(); - $query = 'SELECT id FROM #__menu WHERE parent = 0'; - $db->setQuery($query); - $cids = $db->loadResultArray(0); - } else { - $query = 'UPDATE #__menu SET sublevel = '.(int) $level - .' WHERE parent IN ('.$ids.')'; - $db->setQuery( $query ); - $db->query(); - $query = 'SELECT id FROM #__menu WHERE parent IN ('.$ids.')'; - $db->setQuery( $query ); - $cids = $db->loadResultArray( 0 ); - } - if (!empty( $cids )) { - $this->_rebuildSubLevel( $cids, $level + 1 ); - } - } -} +_table == null) + { + $this->_table =& JTable::getInstance( 'menu'); + } + return $this->_table; + } + + function &getItems() + { + global $mainframe; + + static $items; + + if (isset($items)) { + return $items; + } + + $db =& $this->getDBO(); + + $menutype = $mainframe->getUserStateFromRequest( "com_menus.menutype", 'menutype', 'mainmenu', 'string' ); + $filter_order = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.filter_order', 'filter_order', 'm.ordering', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.filter_order_Dir', 'filter_order_Dir', 'ASC', 'word' ); + $filter_state = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.filter_state', 'filter_state', '', 'word' ); + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg( 'list_limit' ), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.limitstart', 'limitstart', 0, 'int' ); + $levellimit = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.levellimit', 'levellimit', 10, 'int' ); + $search = $mainframe->getUserStateFromRequest( 'com_menus.'.$menutype.'.search', 'search', '', 'string' ); + if (strpos($search, '"') !== false) { + $search = str_replace(array('=', '<'), '', $search); + } + $search = JString::strtolower($search); + + $and = ''; + if ( $filter_state ) + { + if ( $filter_state == 'P' ) { + $and = ' AND m.published = 1'; + } else if ($filter_state == 'U' ) { + $and = ' AND m.published = 0'; + } + } + + // just in case filter_order get's messed up + if ($filter_order) { + $orderby = ' ORDER BY '.$filter_order .' '. $filter_order_Dir .', m.parent, m.ordering'; + } else { + $orderby = ' ORDER BY m.parent, m.ordering'; + } + + // select the records + // note, since this is a tree we have to do the limits code-side + if ($search) { + $query = 'SELECT m.id' . + ' FROM #__menu AS m' . + ' WHERE menutype = '.$db->Quote($menutype) . + ' AND LOWER( m.name ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ) . + $and; + $db->setQuery( $query ); + $search_rows = $db->loadResultArray(); + } + + $query = 'SELECT m.*, u.name AS editor, g.name AS groupname, c.publish_up, c.publish_down, com.name AS com_name' . + ' FROM #__menu AS m' . + ' LEFT JOIN #__users AS u ON u.id = m.checked_out' . + ' LEFT JOIN #__groups AS g ON g.id = m.access' . + ' LEFT JOIN #__content AS c ON c.id = m.componentid AND m.type = "content_typed"' . + ' LEFT JOIN #__components AS com ON com.id = m.componentid AND m.type = "component"' . + ' WHERE m.menutype = '.$db->Quote($menutype) . + ' AND m.published != -2' . + $and . + $orderby; + $db->setQuery( $query ); + $rows = $db->loadObjectList(); + + // establish the hierarchy of the menu + $children = array(); + // first pass - collect children + foreach ($rows 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, max( 0, $levellimit-1 ) ); + // eventually only pick out the searched items. + if ($search) { + $list1 = array(); + + foreach ($search_rows as $sid ) + { + foreach ($list as $item) + { + if ($item->id == $sid) { + $list1[] = $item; + } + } + } + // replace full list with found items + $list = $list1; + } + + $total = count( $list ); + + jimport('joomla.html.pagination'); + $this->_pagination = new JPagination( $total, $limitstart, $limit ); + + // slice out elements based on limits + $list = array_slice( $list, $this->_pagination->limitstart, $this->_pagination->limit ); + + $i = 0; + $query = array(); + foreach ( $list as $mitem ) + { + $edit = ''; + switch ( $mitem->type ) + { + case 'separator': + $list[$i]->descrip = JText::_('Separator'); + break; + + case 'url': + $list[$i]->descrip = JText::_('URL'); + break; + + case 'menulink': + $list[$i]->descrip = JText::_('Menu Link'); + break; + + case 'component': + $list[$i]->descrip = JText::_('Component'); + $query = parse_url($list[$i]->link); + $view = array(); + if(isset($query['query'])) { + if(strpos($query['query'], '&') !== false) + { + $query['query'] = str_replace('&','&',$query['query']); + } + parse_str($query['query'], $view); + } + $list[$i]->view = JText::_($list[$i]->com_name); + if (isset($view['view'])) + { + $list[$i]->view .= ' » '.JText::_(ucfirst($view['view'])); + } + if (isset($view['layout'])) + { + $list[$i]->view .= ' / '.JText::_(ucfirst($view['layout'])); + } + if (isset($view['task']) && !isset($view['view'])) + { + $list[$i]->view .= ' :: '.JText::_(ucfirst($view['task'])); + } + break; + + default: + $list[$i]->descrip = JText::_('Unknown'); + break; + } + $i++; + } + + $items = $list; + return $items; + } + + function &getPagination() + { + if ($this->_pagination == null) { + $this->getItems(); + } + return $this->_pagination; + } + + /** + * Form for copying item(s) to a specific menu + */ + function getItemsFromRequest() + { + static $items; + + if (isset($items)) { + return $items; + } + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + if (count($cid) < 1) { + $this->setError(JText::_( 'Select an item to move')); + return false; + } + + // Query to list the selected menu items + $db =& $this->getDBO(); + $cids = implode( ',', $cid ); + $query = 'SELECT `id`, `name`' . + ' FROM `#__menu`' . + ' WHERE `id` IN ( '.$cids.' )'; + + $db->setQuery( $query ); + $items = $db->loadObjectList(); + + return $items; + } + + /** + * Gets the componet table object related to this menu item + */ + function &getComponent() + { + $id = $this->_table->componentid; + $component = & JTable::getInstance( 'component'); + $component->load( $id ); + return $component; + } + + /** + * Save the item(s) to the menu selected + */ + function copy( $items, $menu ) + { + $curr =& JTable::getInstance('menu'); + $itemref = array(); + foreach ($items as $id) + { + $curr->load( $id ); + $curr->id = NULL; + $curr->home = 0; + if ( !$curr->store() ) { + $this->setError($curr->getError()); + return false; + } + $itemref[] = array($id, $curr->id); + } + foreach ($itemref as $ref) + { + $curr->load( $ref[1] ); + if ($curr->parent!=0) { + $found = false; + foreach ( $itemref as $ref2 ) + { + if ($curr->parent == $ref2[0]) { + $curr->parent = $ref2[1]; + $found = true; + break; + } // if + } + if (!$found && $curr->menutype!=$menu) { + $curr->parent = 0; + } + } + $curr->menutype = $menu; + $curr->ordering = '9999'; + $curr->home = 0; + if ( !$curr->store() ) { + $this->setError($curr->getError()); + return false; + } + $curr->reorder( 'menutype = '.$this->_db->Quote($curr->menutype).' AND parent = '.(int) $curr->parent ); + } // foreach + + //Now, we need to rebuild sublevels... + $this->_rebuildSubLevel(); + + // clean cache + MenusHelper::cleanCache(); + + return true; + } + + function move($items, $menu) + { + // Add all children to the list + foreach ($items as $id) + { + $this->_addChildren($id, $items); + } + + $row =& $this->getTable(); + $ordering = 1000000; + $firstroot = 0; + foreach ($items as $id) { + $row->load( $id ); + + // is it moved together with his parent? + $found = false; + if ($row->parent != 0) { + foreach ($items as $idx) + { + if ($idx == $row->parent) { + $found = true; + break; + } // if + } + } + if (!$found) { + $row->parent = 0; + $row->ordering = $ordering++; + if (!$firstroot) $firstroot = $row->id; + } // if + + $row->menutype = $menu; + if ( !$row->store() ) { + $this->setError($row->getError()); + return false; + } // if + } // foreach + + if ($firstroot) { + $row->load( $firstroot ); + $row->reorder( 'menutype = '.$this->_db->Quote($row->menutype).' AND parent = '.(int) $row->parent ); + } // if + + //Rebuild sublevel + $this->_rebuildSubLevel(); + + // clean cache + MenusHelper::cleanCache(); + + return true; + } + + function toTrash($items) + { + $db =& $this->getDBO(); + $nd = $db->getNullDate(); + $state = -2; + $row =& $this->getTable(); + $default = 0; + + // Add all children to the list + foreach ($items as $id) + { + //Check if it's the default item + $row->load( $id ); + if ($row->home != 1) { + $this->_addChildren($id, $items); + } else { + unset($items[$default]); + JError::raiseWarning( 'SOME_ERROR_CODE', JText::_('You cannot trash the default menu item')); + } + $default++; + } + if (!empty($items)) { + // Sent menu items to the trash + JArrayHelper::toInteger($items, array(0)); + $where = ' WHERE (id = ' . implode( ' OR id = ', $items ) . ') AND home = 0'; + $query = 'UPDATE #__menu' . + ' SET published = '.(int) $state.', parent = 0, ordering = 0, checked_out = 0, checked_out_time = '.$db->Quote($nd) . + $where; + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $db->getErrorMsg() ); + return false; + } + } + + // clean cache + MenusHelper::cleanCache(); + + return count($items); + } + + function fromTrash($items) + { + $db =& $this->getDBO(); + $nd = $db->getNullDate(); + $state = 0; + + // Add all children to the list + foreach ($items as $id) + { + $this->_addChildren($id, $items); + } + + // Sent menu items to the trash + JArrayHelper::toInteger($items, array(0)); + $where = ' WHERE id = ' . implode( ' OR id = ', $items ); + $query = 'UPDATE #__menu' . + ' SET published = '.(int) $state.', parent = 0, ordering = 99999, checked_out = 0, checked_out_time = '.$db->Quote($nd) . + $where; + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $db->getErrorMsg() ); + return false; + } + + // clean cache (require helper because method can be called from com_trash) + require_once( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_menus'.DS.'helpers'.DS.'helper.php' ); + MenusHelper::cleanCache(); + + return count($items); + } + + /** + * Set the state of selected menu items + */ + function setHome( $item ) + { + $db =& $this->getDBO(); + + // Clear home field for all other items + $query = 'UPDATE #__menu' . + ' SET home = 0' . + ' WHERE 1'; + $db->setQuery( $query ); + if ( !$db->query() ) { + $this->setError($db->getErrorMsg()); + return false; + } + + // Set the given item to home + $query = 'UPDATE #__menu' . + ' SET home = 1' . + ' WHERE id = '.(int) $item; + $db->setQuery( $query ); + if ( !$db->query() ) { + $this->setError($db->getErrorMsg()); + return false; + } + + // clean cache + MenusHelper::cleanCache(); + + return true; + } + + /** + * Set the state of selected menu items + */ + function setItemState( $items, $state ) + { + if(is_array($items)) + { + $row =& $this->getTable(); + foreach ($items as $id) + { + $row->load( $id ); + + if ($row->home != 1) { + $row->published = $state; + + if ($state != 1) { + // Set any alias menu types to not point to unpublished menu items + $db = &$this->getDBO(); + $query = 'UPDATE #__menu SET link = 0 WHERE type = \'menulink\' AND link = '.(int)$id; + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $db->getErrorMsg() ); + return false; + } + } + + if (!$row->check()) { + $this->setError($row->getError()); + return false; + } + if (!$row->store()) { + $this->setError($row->getError()); + return false; + } + } else { + JError::raiseWarning( 'SOME_ERROR_CODE', JText::_('You cannot unpublish the default menu item')); + return false; + } + } + } + + // clean cache + MenusHelper::cleanCache(); + + return true; + } + + /** + * Set the access of selected menu items + */ + function setAccess( $items, $access ) + { + $row =& $this->getTable(); + foreach ($items as $id) + { + $row->load( $id ); + $row->access = $access; + + // Set any alias menu types to not point to unpublished menu items + $db = &$this->getDBO(); + $query = 'UPDATE #__menu SET link = 0 WHERE type = \'menulink\' AND access < '.(int)$access.' AND link = '.(int)$id; + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $db->getErrorMsg() ); + return false; + } + + if (!$row->check()) { + $this->setError($row->getError()); + return false; + } + if (!$row->store()) { + $this->setError($row->getError()); + return false; + } + } + + // clean cache + MenusHelper::cleanCache(); + + return true; + } + + function orderItem($item, $movement) + { + $row =& $this->getTable(); + $row->load( $item ); + if (!$row->move( $movement, 'menutype = '.$this->_db->Quote($row->menutype).' AND parent = '.(int) $row->parent )) { + $this->setError($row->getError()); + return false; + } + + // clean cache + MenusHelper::cleanCache(); + + return true; + } + + function setOrder($items, $menutype) + { + $total = count( $items ); + $row =& $this->getTable(); + $groupings = array(); + + $order = JRequest::getVar( 'order', array(), 'post', 'array' ); + JArrayHelper::toInteger($order); + + // update ordering values + for( $i=0; $i < $total; $i++ ) { + $row->load( $items[$i] ); + // track parents + $groupings[] = $row->parent; + if ($row->ordering != $order[$i]) { + $row->ordering = $order[$i]; + if (!$row->store()) { + $this->setError($row->getError()); + return false; + } + } // if + } // for + + // execute updateOrder for each parent group + $groupings = array_unique( $groupings ); + foreach ($groupings as $group){ + $row->reorder('menutype = '.$this->_db->Quote($menutype).' AND parent = '.(int) $group.' AND published >=0'); + } + + // clean cache + MenusHelper::cleanCache(); + + return true; + } + + /** + * Delete one or more menu items + * @param mixed int or array of id values + */ + function delete( $ids ) + { + JArrayHelper::toInteger($ids); + + if (!empty( $ids )) { + + // Add all children to the list + foreach ($ids as $id) + { + $this->_addChildren($id, $ids); + } + + $db = &$this->getDBO(); + + // Delete associated module and template mappings + $where = 'WHERE menuid = ' . implode( ' OR menuid = ', $ids ); + + $query = 'DELETE FROM #__modules_menu ' + . $where; + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $menuTable->getErrorMsg() ); + return false; + } + + $query = 'DELETE FROM #__templates_menu ' + . $where; + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $menuTable->getErrorMsg() ); + return false; + } + + // Set any alias menu types to not point to missing menu items + $query = 'UPDATE #__menu SET link = 0 WHERE type = \'menulink\' AND (link = '.implode( ' OR id = ', $ids ).')'; + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $db->getErrorMsg() ); + return false; + } + + // Delete the menu items + $where = 'WHERE id = ' . implode( ' OR id = ', $ids ); + + $query = 'DELETE FROM #__menu ' . $where; + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $db->getErrorMsg() ); + return false; + } + } + + // clean cache + MenusHelper::cleanCache(); + + return true; + } + + /** + * Delete menu items by type + */ + function deleteByType( $type = '' ) + { + $db = &$this->getDBO(); + + $query = 'SELECT id' . + ' FROM #__menu' . + ' WHERE menutype = ' . $db->Quote( $type ); + $db->setQuery( $query ); + $ids = $db->loadResultArray(); + + if ($db->getErrorNum()) { + $this->setError( $db->getErrorMsg() ); + return false; + } + + return $this->delete( $ids ); + } + + function _addChildren($id, &$list) + { + // Initialize variables + $return = true; + + // Get all rows with parent of $id + $db =& $this->getDBO(); + $query = 'SELECT id' . + ' FROM #__menu' . + ' WHERE parent = '.(int) $id; + $db->setQuery( $query ); + $rows = $db->loadObjectList(); + + // Make sure there aren't any errors + if ($db->getErrorNum()) { + $this->setError($db->getErrorMsg()); + return false; + } + + // Recursively iterate through all children... kinda messy + // TODO: Cleanup this method + foreach ($rows as $row) + { + $found = false; + foreach ($list as $idx) + { + if ($idx == $row->id) { + $found = true; + break; + } + } + if (!$found) { + $list[] = $row->id; + } + $return = $this->_addChildren($row->id, $list); + } + return $return; + } + + /* + * Rebuild the sublevel field for items in the menu (if called with 2nd param = 0 or no params, it will rebuild entire menu tree's sublevel + * @param array of menu item ids to change level to + * @param int level to set the menu items to (based on parent + */ + function _rebuildSubLevel($cid = array(0), $level = 0) + { + JArrayHelper::toInteger($cid, array(0)); + $db =& $this->getDBO(); + $ids = implode( ',', $cid ); + $cids = array(); + if($level == 0) { + $query = 'UPDATE #__menu SET sublevel = 0 WHERE parent = 0'; + $db->setQuery($query); + $db->query(); + $query = 'SELECT id FROM #__menu WHERE parent = 0'; + $db->setQuery($query); + $cids = $db->loadResultArray(0); + } else { + $query = 'UPDATE #__menu SET sublevel = '.(int) $level + .' WHERE parent IN ('.$ids.')'; + $db->setQuery( $query ); + $db->query(); + $query = 'SELECT id FROM #__menu WHERE parent IN ('.$ids.')'; + $db->setQuery( $query ); + $cids = $db->loadResultArray( 0 ); + } + if (!empty( $cids )) { + $this->_rebuildSubLevel( $cids, $level + 1 ); + } + } +} diff --git a/oss/joomla/trunk/administrator/components/com_menus/models/menutype.php b/oss/joomla/trunk/administrator/components/com_menus/models/menutype.php index 89ad3aab..51f2fe87 100644 --- a/oss/joomla/trunk/administrator/components/com_menus/models/menutype.php +++ b/oss/joomla/trunk/administrator/components/com_menus/models/menutype.php @@ -1,280 +1,280 @@ -_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::getString('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; - } -} +_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::getString('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; + } +} diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/item/tmpl/form.php b/oss/joomla/trunk/administrator/components/com_menus/views/item/tmpl/form.php index 97d44214..c8a44934 100644 --- a/oss/joomla/trunk/administrator/components/com_menus/views/item/tmpl/form.php +++ b/oss/joomla/trunk/administrator/components/com_menus/views/item/tmpl/form.php @@ -1,204 +1,206 @@ - - - -
    - - - - - - -
    - -
    - - - -
    - -
    -

    name; ?>

    -
    - description; ?> -
    -
    - -
    - - - - - item->id) { ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - : - - item->id; ?> -
    - : - - -
    - : - - -
    - : - - lists->disabled;?> /> -
    - : - - menutypes, 'menutype', 'class="inputbox" size="1"', 'menutype', 'title', $this->item->menutype );?> -
    - : - - item ); ?> -
    - : - - lists->published ?> -
    - : - - item, $this->item->id ); ?> -
    - : - - item ); ?> -
    - : - - item ); ?> -
    -
    -
    - pane->startPane("menu-pane"); - echo $this->pane->startPanel(JText :: _('Parameters - Basic'), "param-page"); - echo $this->urlparams->render('urlparams'); - if(count($this->params->getParams('params'))) : - echo $this->params->render('params'); - endif; - - if(!count($this->params->getNumParams('params')) && !count($this->urlparams->getNumParams('urlparams'))) : - echo "
    ".JText::_('There are no parameters for this item')."
    "; - endif; - echo $this->pane->endPanel(); - - if($params = $this->advanced->render('params')) : - echo $this->pane->startPanel(JText :: _('Parameters - Advanced'), "advanced-page"); - echo $params; - echo $this->pane->endPanel(); - endif; - - if ($this->comp && ($params = $this->comp->render('params'))) : - echo $this->pane->startPanel(JText :: _('Parameters - Component'), "component-page"); - echo $params; - echo $this->pane->endPanel(); - endif; - - if ($this->sysparams && ($params = $this->sysparams->render('params'))) : - echo $this->pane->startPanel(JText :: _('Parameters - System'), "system-page"); - echo $params; - echo $this->pane->endPanel(); - endif; - echo $this->pane->endPane(); - ?> -
    - - item->linkfield; ?> - - - - - - - -
    + + + +
    + + + + + + +
    + +
    + + + +
    + +
    +

    name; ?>

    +
    + description; ?> +
    +
    + +
    + + + + + item->id) { ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + item->type != "menulink") : ?> + + + + + +
    + : + + item->id; ?> +
    + : + + +
    + : + + +
    + : + + lists->disabled;?> /> +
    + : + + menutypes, 'menutype', 'class="inputbox" size="1"', 'menutype', 'title', $this->item->menutype );?> +
    + : + + item ); ?> +
    + : + + lists->published ?> +
    + : + + item, $this->item->id ); ?> +
    + : + + item ); ?> +
    + : + + item ); ?> +
    +
    +
    + pane->startPane("menu-pane"); + echo $this->pane->startPanel(JText :: _('Parameters - Basic'), "param-page"); + echo $this->urlparams->render('urlparams'); + if(count($this->params->getParams('params'))) : + echo $this->params->render('params'); + endif; + + if(!count($this->params->getNumParams('params')) && !count($this->urlparams->getNumParams('urlparams'))) : + echo "
    ".JText::_('There are no parameters for this item')."
    "; + endif; + echo $this->pane->endPanel(); + + if($params = $this->advanced->render('params')) : + echo $this->pane->startPanel(JText :: _('Parameters - Advanced'), "advanced-page"); + echo $params; + echo $this->pane->endPanel(); + endif; + + if ($this->comp && ($params = $this->comp->render('params'))) : + echo $this->pane->startPanel(JText :: _('Parameters - Component'), "component-page"); + echo $params; + echo $this->pane->endPanel(); + endif; + + if ($this->sysparams && ($params = $this->sysparams->render('params'))) : + echo $this->pane->startPanel(JText :: _('Parameters - System'), "system-page"); + echo $params; + echo $this->pane->endPanel(); + endif; + echo $this->pane->endPane(); + ?> +
    + + item->linkfield; ?> + + + + + + + +
    diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/item/view.php b/oss/joomla/trunk/administrator/components/com_menus/views/item/view.php index 059de3c3..a34d7fcb 100644 --- a/oss/joomla/trunk/administrator/components/com_menus/views/item/view.php +++ b/oss/joomla/trunk/administrator/components/com_menus/views/item/view.php @@ -1,187 +1,187 @@ -_layout = 'form'; - - $item = &$this->get('Item'); - - // clean item data - JFilterOutput::objectHTMLSafe( $item, ENT_QUOTES, '' ); - - // Set toolbar items for the page - if (!$item->id) { - JToolBarHelper::title( JText::_( 'Menu Item' ) .': [ '. JText::_( 'New' ) .' ]', 'menu.png' ); - } else { - JToolBarHelper::title( JText::_( 'Menu Item' ) .': [ '. JText::_( 'Edit' ) .' ]', 'menu.png' ); - } - JToolBarHelper::save(); - JToolBarHelper::apply(); - if ($item->id) { - // for existing items the button is renamed `close` - JToolBarHelper::cancel( 'cancelItem', 'Close' ); - } else { - JToolBarHelper::cancel('cancelItem'); - } - JToolBarHelper::help( 'screen.menus.edit' ); - - // Load component language files - $component = &$this->get('Component'); - $lang->load($component->option, JPATH_ADMINISTRATOR); - - // Initialize variables - $urlparams = $this->get( 'UrlParams' ); - $params = $this->get( 'StateParams' ); - $sysparams = $this->get( 'SystemParams' ); - $advanced = $this->get( 'AdvancedParams' ); - $component = $this->get( 'ComponentParams' ); - $name = $this->get( 'StateName' ); - $description = $this->get( 'StateDescription' ); - $menuTypes = MenusHelper::getMenuTypeList(); - $components = MenusHelper::getComponentList(); - - JHTML::_('behavior.tooltip'); - - $document = & JFactory::getDocument(); - if ($item->id) { - $document->setTitle(JText::_( 'Menu Item' ) .': ['. JText::_( 'Edit' ) .']'); - } else { - $document->setTitle(JText::_( 'Menu Item' ) .': ['. JText::_( 'New' ) .']'); - } - - // Was showing up null in some cases.... - if (!$item->published) { - $item->published = 0; - } - $lists = new stdClass(); - $lists->published = MenusHelper::Published($item); - $lists->disabled = ($item->type != 'url' ? 'readonly="true"' : ''); - - $item->expansion = null; - if ($item->type != 'url') { - $lists->disabled = 'readonly="true"'; - $item->linkfield = ''; - if (($item->id) && ($item->type == 'component') && (isset($item->linkparts['option']))) { - $item->expansion = '&expand='.trim(str_replace('com_', '', $item->linkparts['option'])); - } - } else { - $lists->disabled = null; - $item->linkfield = null; - } - - $this->assignRef('lists' , $lists); - $this->assignRef('item' , $item); - $this->assignRef('urlparams', $urlparams); - $this->assignRef('sysparams', $sysparams); - $this->assignRef('params' , $params); - $this->assignRef('advanced' , $advanced); - $this->assignRef('comp' , $component); - $this->assignRef('menutypes', $menuTypes); - $this->assignRef('name' , $name); - $this->assignRef('description', $description); - - // Add slider pane - // TODO: allowAllClose should default true in J!1.6, so remove the array when it does. - $pane = &JPane::getInstance('sliders', array('allowAllClose' => true)); - $this->assignRef('pane', $pane); - - parent::display($tpl); - } - - function type($tpl = null) - { - JRequest::setVar( 'hidemainmenu', 1 ); - - global $mainframe; - - $lang =& JFactory::getLanguage(); - $this->_layout = 'type'; - - $item = &$this->get('Item'); - - // Set toolbar items for the page - if (!$item->id) { - JToolBarHelper::title( JText::_( 'Menu Item' ) .': [ '. JText::_( 'New' ) .' ]', 'menu.png' ); - } else { - JToolBarHelper::title( JText::_( 'Change Menu Item' ), 'menu.png' ); - } - - // Set toolbar items for the page - JToolBarHelper::cancel('view'); - JToolBarHelper::help( 'screen.menus.edit' ); - - // Add scripts and stylesheets to the document - $document = & JFactory::getDocument(); - - if($lang->isRTL()){ - $document->addStyleSheet('components/com_menus/assets/type_rtl.css'); - } else { - $document->addStyleSheet('components/com_menus/assets/type.css'); - } - JHTML::_('behavior.tooltip'); - - // Load component language files - $components = MenusHelper::getComponentList(); - $n = count($components); - for($i = 0; $i < $n; $i++) - { - $path = JPATH_SITE.DS.'components'.DS.$components[$i]->option.DS.'views'; - $components[$i]->legacy = !is_dir($path); - - $lang->load($components[$i]->option, JPATH_ADMINISTRATOR); - } - - // Initialize variables - $item = &$this->get('Item'); - $expansion = &$this->get('Expansion'); - $component = &$this->get('Component'); - $name = $this->get( 'StateName' ); - $description = $this->get( 'StateDescription' ); - $menuTypes = MenusHelper::getMenuTypeList(); - - // Set document title - if ($item->id) { - $document->setTitle(JText::_( 'Menu Item' ) .': ['. JText::_( 'Edit' ) .']'); - } else { - $document->setTitle(JText::_( 'Menu Item' ) .': ['. JText::_( 'New' ) .']'); - } - - $this->assignRef('item', $item); - $this->assignRef('components', $components); - $this->assignRef('expansion', $expansion); - - parent::display($tpl); - } -} +_layout = 'form'; + + $item = &$this->get('Item'); + + // clean item data + JFilterOutput::objectHTMLSafe( $item, ENT_QUOTES, '' ); + + // Set toolbar items for the page + if (!$item->id) { + JToolBarHelper::title( JText::_( 'Menu Item' ) .': [ '. JText::_( 'New' ) .' ]', 'menu.png' ); + } else { + JToolBarHelper::title( JText::_( 'Menu Item' ) .': [ '. JText::_( 'Edit' ) .' ]', 'menu.png' ); + } + JToolBarHelper::save(); + JToolBarHelper::apply(); + if ($item->id) { + // for existing items the button is renamed `close` + JToolBarHelper::cancel( 'cancelItem', 'Close' ); + } else { + JToolBarHelper::cancel('cancelItem'); + } + JToolBarHelper::help( 'screen.menus.edit' ); + + // Load component language files + $component = &$this->get('Component'); + $lang->load($component->option, JPATH_ADMINISTRATOR); + + // Initialize variables + $urlparams = $this->get( 'UrlParams' ); + $params = $this->get( 'StateParams' ); + $sysparams = $this->get( 'SystemParams' ); + $advanced = $this->get( 'AdvancedParams' ); + $component = $this->get( 'ComponentParams' ); + $name = $this->get( 'StateName' ); + $description = $this->get( 'StateDescription' ); + $menuTypes = MenusHelper::getMenuTypeList(); + $components = MenusHelper::getComponentList(); + + JHTML::_('behavior.tooltip'); + + $document = & JFactory::getDocument(); + if ($item->id) { + $document->setTitle(JText::_( 'Menu Item' ) .': ['. JText::_( 'Edit' ) .']'); + } else { + $document->setTitle(JText::_( 'Menu Item' ) .': ['. JText::_( 'New' ) .']'); + } + + // Was showing up null in some cases.... + if (!$item->published) { + $item->published = 0; + } + $lists = new stdClass(); + $lists->published = MenusHelper::Published($item); + $lists->disabled = ($item->type != 'url' ? 'readonly="true"' : ''); + + $item->expansion = null; + if ($item->type != 'url') { + $lists->disabled = 'readonly="true"'; + $item->linkfield = ''; + if (($item->id) && ($item->type == 'component') && (isset($item->linkparts['option']))) { + $item->expansion = '&expand='.trim(str_replace('com_', '', $item->linkparts['option'])); + } + } else { + $lists->disabled = null; + $item->linkfield = null; + } + + $this->assignRef('lists' , $lists); + $this->assignRef('item' , $item); + $this->assignRef('urlparams', $urlparams); + $this->assignRef('sysparams', $sysparams); + $this->assignRef('params' , $params); + $this->assignRef('advanced' , $advanced); + $this->assignRef('comp' , $component); + $this->assignRef('menutypes', $menuTypes); + $this->assignRef('name' , $name); + $this->assignRef('description', $description); + + // Add slider pane + // TODO: allowAllClose should default true in J!1.6, so remove the array when it does. + $pane = &JPane::getInstance('sliders', array('allowAllClose' => true)); + $this->assignRef('pane', $pane); + + parent::display($tpl); + } + + function type($tpl = null) + { + JRequest::setVar( 'hidemainmenu', 1 ); + + global $mainframe; + + $lang =& JFactory::getLanguage(); + $this->_layout = 'type'; + + $item = &$this->get('Item'); + + // Set toolbar items for the page + if (!$item->id) { + JToolBarHelper::title( JText::_( 'Menu Item' ) .': [ '. JText::_( 'New' ) .' ]', 'menu.png' ); + } else { + JToolBarHelper::title( JText::_( 'Change Menu Item' ), 'menu.png' ); + } + + // Set toolbar items for the page + JToolBarHelper::cancel('view'); + JToolBarHelper::help( 'screen.menus.edit' ); + + // Add scripts and stylesheets to the document + $document = & JFactory::getDocument(); + + if($lang->isRTL()){ + $document->addStyleSheet('components/com_menus/assets/type_rtl.css'); + } else { + $document->addStyleSheet('components/com_menus/assets/type.css'); + } + JHTML::_('behavior.tooltip'); + + // Load component language files + $components = MenusHelper::getComponentList(); + $n = count($components); + for($i = 0; $i < $n; $i++) + { + $path = JPATH_SITE.DS.'components'.DS.$components[$i]->option.DS.'views'; + $components[$i]->legacy = !is_dir($path); + + $lang->load($components[$i]->option, JPATH_ADMINISTRATOR); + } + + // Initialize variables + $item = &$this->get('Item'); + $expansion = &$this->get('Expansion'); + $component = &$this->get('Component'); + $name = $this->get( 'StateName' ); + $description = $this->get( 'StateDescription' ); + $menuTypes = MenusHelper::getMenuTypeList(); + + // Set document title + if ($item->id) { + $document->setTitle(JText::_( 'Menu Item' ) .': ['. JText::_( 'Edit' ) .']'); + } else { + $document->setTitle(JText::_( 'Menu Item' ) .': ['. JText::_( 'New' ) .']'); + } + + $this->assignRef('item', $item); + $this->assignRef('components', $components); + $this->assignRef('expansion', $expansion); + + parent::display($tpl); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/list/tmpl/default.php b/oss/joomla/trunk/administrator/components/com_menus/views/list/tmpl/default.php index b4cc545b..f4166478 100644 --- a/oss/joomla/trunk/administrator/components/com_menus/views/list/tmpl/default.php +++ b/oss/joomla/trunk/administrator/components/com_menus/views/list/tmpl/default.php @@ -1,130 +1,130 @@ - - -
    - - - - - - -
    - : - - - - - lists['levellist']; - echo $this->lists['state']; - ?> -
    - - - - - - - - - - - - - - - - - - - - - - items ); - $rows = &$this->items; - foreach ($rows as $row) : - $access = JHTML::_('grid.access', $row, $i ); - $checked = JHTML::_('grid.checkedout', $row, $i ); - $published = JHTML::_('grid.published', $row, $i ); - ?> - "> - - - - - - - - - - - - - -
    - - - - - lists['order_Dir'], @$this->lists['order'] ); ?> - - - - lists['order_Dir'], @$this->lists['order'] ); ?> - - lists['order_Dir'], @$this->lists['order'] ); ?> - ordering) echo JHTML::_('grid.order', $this->items ); ?> - - lists['order_Dir'], @$this->lists['order'] ); ?> - - lists['order_Dir'], @$this->lists['order'] ); ?> - - lists['order_Dir'], @$this->lists['order'] ); ?> -
    - pagination->getListFooter(); ?> -
    - pagination->limitstart;?> - - - - user->get('id'), $row->checked_out ) ) : ?> - treename; ?> - - - treename; ?> - - - home == 1 ) : ?> - <?php echo JText::_( 'Default' ); ?> - -   - - - - - pagination->orderUpIcon( $i, $row->parent == 0 || $row->parent == @$rows[$i-1]->parent, 'orderup', 'Move Up', $this->ordering); ?> - pagination->orderDownIcon( $i, $n, $row->parent == 0 || $row->parent == @$rows[$i+1]->parent, 'orderdown', 'Move Down', $this->ordering ); ?> - ordering ? '' : 'disabled="disabled"'; ?> - class="text_area" style="text-align: center" /> - - - - type == 'component') ? $row->view : $row->type; ?> - - id; ?> -
    - - - - - - - - + + + + + + + + + +
    + : + + + + + lists['levellist']; + echo $this->lists['state']; + ?> +
    + + + + + + + + + + + + + + + + + + + + + + items ); + $rows = &$this->items; + foreach ($rows as $row) : + $access = JHTML::_('grid.access', $row, $i ); + $checked = JHTML::_('grid.checkedout', $row, $i ); + $published = JHTML::_('grid.published', $row, $i ); + ?> + "> + + + + + + + + + + + + + +
    + + + + + lists['order_Dir'], @$this->lists['order'] ); ?> + + + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + ordering) echo JHTML::_('grid.order', $this->items ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> +
    + pagination->getListFooter(); ?> +
    + pagination->limitstart;?> + + + + user->get('id'), $row->checked_out ) ) : ?> + treename; ?> + + + treename; ?> + + + home == 1 ) : ?> + <?php echo JText::_( 'Default' ); ?> + +   + + + + + pagination->orderUpIcon( $i, $row->parent == 0 || $row->parent == @$rows[$i-1]->parent, 'orderup', 'Move Up', $this->ordering); ?> + pagination->orderDownIcon( $i, $n, $row->parent == 0 || $row->parent == @$rows[$i+1]->parent, 'orderdown', 'Move Down', $this->ordering ); ?> + ordering ? '' : 'disabled="disabled"'; ?> + class="text_area" style="text-align: center" /> + + + + type == 'component') ? $row->view : $row->type; ?> + + id; ?> +
    + + + + + + + +
    \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/list/view.php b/oss/joomla/trunk/administrator/components/com_menus/views/list/view.php index 872c5b82..b7b5c9f5 100644 --- a/oss/joomla/trunk/administrator/components/com_menus/views/list/view.php +++ b/oss/joomla/trunk/administrator/components/com_menus/views/list/view.php @@ -1,188 +1,191 @@ -_layout = 'default'; - - /* - * Set toolbar items for the page - */ - $menutype = $mainframe->getUserStateFromRequest( 'com_menus.menutype', 'menutype', 'mainmenu', 'string' ); - - JToolBarHelper::title( JText::_( 'MENU ITEM MANAGER' ) .': ['.$menutype.']', 'menu.png' ); - - $bar =& JToolBar::getInstance('toolbar'); - $bar->appendButton( 'Link', 'menus', 'Menus', "index.php?option=com_menus" ); - - JToolBarHelper::makeDefault( 'setdefault' ); - JToolBarHelper::publishList(); - JToolBarHelper::unpublishList(); - JToolBarHelper::customX( 'move', 'move.png', 'move_f2.png', 'Move', true ); - JToolBarHelper::customX( 'copy', 'copy.png', 'copy_f2.png', 'Copy', true ); - JToolBarHelper::trash(); - JToolBarHelper::editListX(); - JToolBarHelper::addNewX('newItem'); - JToolBarHelper::help( 'screen.menus' ); - - $document = & JFactory::getDocument(); - $document->setTitle(JText::_('View Menu Items')); - - $limitstart = JRequest::getVar('limitstart', '0', '', 'int'); - $items = &$this->get('Items'); - $pagination = &$this->get('Pagination'); - $lists = &$this->_getViewLists(); - $user = &JFactory::getUser(); - - // Ensure ampersands and double quotes are encoded in item titles - foreach ($items as $i => $item) { - $treename = $item->treename; - $treename = JFilterOutput::ampReplace($treename); - $treename = str_replace('"', '"', $treename); - $items[$i]->treename = $treename; - } - - //Ordering allowed ? - $ordering = ($lists['order'] == 'm.ordering'); - - JHTML::_('behavior.tooltip'); - - $this->assignRef('items', $items); - $this->assignRef('pagination', $pagination); - $this->assignRef('lists', $lists); - $this->assignRef('user', $user); - $this->assignRef('menutype', $menutype); - $this->assignRef('ordering', $ordering); - $this->assignRef('limitstart', $limitstart); - - parent::display($tpl); - } - - function copyForm($tpl=null) - { - global $mainframe; - - $this->_layout = 'copy'; - - /* - * Set toolbar items for the page - */ - JToolBarHelper::title( JText::_( 'Menu Items' ) . ': [ '. JText::_( 'Copy' ) .' ]' ); - JToolBarHelper::custom( 'doCopy', 'copy.png', 'copy_f2.png', 'Copy', false ); - JToolBarHelper::cancel('cancelItem'); - JToolBarHelper::help( 'screen.menus' ); - - $document = & JFactory::getDocument(); - $document->setTitle(JText::_('Copy Menu Items')); - - $menutype = $mainframe->getUserStateFromRequest( 'com_menus.menutype', 'menutype', 'mainmenu', 'string' ); - - // Build the menutypes select list - $menuTypes = MenusHelper::getMenuTypes(); - foreach ( $menuTypes as $menuType ) { - $menu[] = JHTML::_('select.option', $menuType, $menuType ); - } - $MenuList = JHTML::_('select.genericlist', $menu, 'menu', 'class="inputbox" size="10"', 'value', 'text', null ); - - $items = &$this->get('ItemsFromRequest'); - - $this->assignRef('menutype', $menutype); - $this->assignRef('items', $items); - $this->assignRef('menutypes', $menuTypes); - $this->assignRef('MenuList', $MenuList); - - parent::display($tpl); - } - - function moveForm($tpl=null) - { - global $mainframe; - - $this->_layout = 'move'; - - /* - * Set toolbar items for the page - */ - JToolBarHelper::title( JText::_( 'Menu Items' ) . ': [ '. JText::_( 'Move' ) .' ]' ); - JToolBarHelper::custom( 'doMove', 'move.png', 'move_f2.png', 'Move', false ); - JToolBarHelper::cancel('cancelItem'); - JToolBarHelper::help( 'screen.menus' ); - - $document = & JFactory::getDocument(); - $document->setTitle(JText::_('Move Menu Items')); - - $menutype = $mainframe->getUserStateFromRequest( 'com_menus.menutype', 'menutype', 'mainmenu', 'string' ); - - // Build the menutypes select list - $menuTypes = MenusHelper::getMenuTypes(); - foreach ( $menuTypes as $menuType ) { - $menu[] = JHTML::_('select.option', $menuType, $menuType ); - } - $MenuList = JHTML::_('select.genericlist', $menu, 'menu', 'class="inputbox" size="10"', 'value', 'text', null ); - - $items = &$this->get('ItemsFromRequest'); - - $this->assignRef('menutype', $menutype); - $this->assignRef('items', $items); - $this->assignRef('menutypes', $menuTypes); - $this->assignRef('MenuList', $MenuList); - - parent::display($tpl); - } - - function &_getViewLists() - { - global $mainframe; - $db =& JFactory::getDBO(); - - $menutype = $mainframe->getUserStateFromRequest( "com_menus.menutype", 'menutype', 'mainmenu', 'string' ); - $filter_order = $mainframe->getUserStateFromRequest( "com_menus.$menutype.filter_order", 'filter_order', 'm.ordering', 'cmd' ); - $filter_order_Dir = $mainframe->getUserStateFromRequest( "com_menus.$menutype.filter_order_Dir", 'filter_order_Dir', 'ASC', 'word' ); - $filter_state = $mainframe->getUserStateFromRequest( "com_menus.$menutype.filter_state", 'filter_state', '', 'word' ); - $levellimit = $mainframe->getUserStateFromRequest( "com_menus.$menutype.levellimit", 'levellimit', 10, 'int' ); - $search = $mainframe->getUserStateFromRequest( "com_menus.$menutype.search", 'search', '', 'string' ); - $search = JString::strtolower( $search ); - - // level limit filter - $lists['levellist'] = JHTML::_('select.integerlist', 1, 20, 1, 'levellimit', 'size="1" onchange="document.adminForm.submit();"', $levellimit ); - - // state filter - $lists['state'] = JHTML::_('grid.state', $filter_state ); - - // table ordering - $lists['order_Dir'] = $filter_order_Dir; - $lists['order'] = $filter_order; - - // search filter - $lists['search']= $search; - - return $lists; - } -} +_layout = 'default'; + + /* + * Set toolbar items for the page + */ + $menutype = $mainframe->getUserStateFromRequest( 'com_menus.menutype', 'menutype', 'mainmenu', 'string' ); + + JToolBarHelper::title( JText::_( 'MENU ITEM MANAGER' ) .': ['.$menutype.']', 'menu.png' ); + + $bar =& JToolBar::getInstance('toolbar'); + $bar->appendButton( 'Link', 'menus', 'Menus', "index.php?option=com_menus" ); + + JToolBarHelper::makeDefault( 'setdefault' ); + JToolBarHelper::publishList(); + JToolBarHelper::unpublishList(); + JToolBarHelper::customX( 'move', 'move.png', 'move_f2.png', 'Move', true ); + JToolBarHelper::customX( 'copy', 'copy.png', 'copy_f2.png', 'Copy', true ); + JToolBarHelper::trash(); + JToolBarHelper::editListX(); + JToolBarHelper::addNewX('newItem'); + JToolBarHelper::help( 'screen.menus' ); + + $document = & JFactory::getDocument(); + $document->setTitle(JText::_('View Menu Items')); + + $limitstart = JRequest::getVar('limitstart', '0', '', 'int'); + $items = &$this->get('Items'); + $pagination = &$this->get('Pagination'); + $lists = &$this->_getViewLists(); + $user = &JFactory::getUser(); + + // Ensure ampersands and double quotes are encoded in item titles + foreach ($items as $i => $item) { + $treename = $item->treename; + $treename = JFilterOutput::ampReplace($treename); + $treename = str_replace('"', '"', $treename); + $items[$i]->treename = $treename; + } + + //Ordering allowed ? + $ordering = ($lists['order'] == 'm.ordering'); + + JHTML::_('behavior.tooltip'); + + $this->assignRef('items', $items); + $this->assignRef('pagination', $pagination); + $this->assignRef('lists', $lists); + $this->assignRef('user', $user); + $this->assignRef('menutype', $menutype); + $this->assignRef('ordering', $ordering); + $this->assignRef('limitstart', $limitstart); + + parent::display($tpl); + } + + function copyForm($tpl=null) + { + global $mainframe; + + $this->_layout = 'copy'; + + /* + * Set toolbar items for the page + */ + JToolBarHelper::title( JText::_( 'Menu Items' ) . ': [ '. JText::_( 'Copy' ) .' ]' ); + JToolBarHelper::custom( 'doCopy', 'copy.png', 'copy_f2.png', 'Copy', false ); + JToolBarHelper::cancel('cancelItem'); + JToolBarHelper::help( 'screen.menus' ); + + $document = & JFactory::getDocument(); + $document->setTitle(JText::_('Copy Menu Items')); + + $menutype = $mainframe->getUserStateFromRequest( 'com_menus.menutype', 'menutype', 'mainmenu', 'string' ); + + // Build the menutypes select list + $menuTypes = MenusHelper::getMenuTypes(); + foreach ( $menuTypes as $menuType ) { + $menu[] = JHTML::_('select.option', $menuType, $menuType ); + } + $MenuList = JHTML::_('select.genericlist', $menu, 'menu', 'class="inputbox" size="10"', 'value', 'text', null ); + + $items = &$this->get('ItemsFromRequest'); + + $this->assignRef('menutype', $menutype); + $this->assignRef('items', $items); + $this->assignRef('menutypes', $menuTypes); + $this->assignRef('MenuList', $MenuList); + + parent::display($tpl); + } + + function moveForm($tpl=null) + { + global $mainframe; + + $this->_layout = 'move'; + + /* + * Set toolbar items for the page + */ + JToolBarHelper::title( JText::_( 'Menu Items' ) . ': [ '. JText::_( 'Move' ) .' ]' ); + JToolBarHelper::custom( 'doMove', 'move.png', 'move_f2.png', 'Move', false ); + JToolBarHelper::cancel('cancelItem'); + JToolBarHelper::help( 'screen.menus' ); + + $document = & JFactory::getDocument(); + $document->setTitle(JText::_('Move Menu Items')); + + $menutype = $mainframe->getUserStateFromRequest( 'com_menus.menutype', 'menutype', 'mainmenu', 'string' ); + + // Build the menutypes select list + $menuTypes = MenusHelper::getMenuTypes(); + foreach ( $menuTypes as $menuType ) { + $menu[] = JHTML::_('select.option', $menuType, $menuType ); + } + $MenuList = JHTML::_('select.genericlist', $menu, 'menu', 'class="inputbox" size="10"', 'value', 'text', null ); + + $items = &$this->get('ItemsFromRequest'); + + $this->assignRef('menutype', $menutype); + $this->assignRef('items', $items); + $this->assignRef('menutypes', $menuTypes); + $this->assignRef('MenuList', $MenuList); + + parent::display($tpl); + } + + function &_getViewLists() + { + global $mainframe; + $db =& JFactory::getDBO(); + + $menutype = $mainframe->getUserStateFromRequest( "com_menus.menutype", 'menutype', 'mainmenu', 'string' ); + $filter_order = $mainframe->getUserStateFromRequest( "com_menus.$menutype.filter_order", 'filter_order', 'm.ordering', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( "com_menus.$menutype.filter_order_Dir", 'filter_order_Dir', 'ASC', 'word' ); + $filter_state = $mainframe->getUserStateFromRequest( "com_menus.$menutype.filter_state", 'filter_state', '', 'word' ); + $levellimit = $mainframe->getUserStateFromRequest( "com_menus.$menutype.levellimit", 'levellimit', 10, 'int' ); + $search = $mainframe->getUserStateFromRequest( "com_menus.$menutype.search", 'search', '', 'string' ); + if (strpos($search, '"') !== false) { + $search = str_replace(array('=', '<'), '', $search); + } + $search = JString::strtolower($search); + + // level limit filter + $lists['levellist'] = JHTML::_('select.integerlist', 1, 20, 1, 'levellimit', 'size="1" onchange="document.adminForm.submit();"', $levellimit ); + + // state filter + $lists['state'] = JHTML::_('grid.state', $filter_state ); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search']= $search; + + return $lists; + } +} diff --git a/oss/joomla/trunk/administrator/components/com_menus/views/menus/view.php b/oss/joomla/trunk/administrator/components/com_menus/views/menus/view.php index f1ba5c36..f5deaae0 100644 --- a/oss/joomla/trunk/administrator/components/com_menus/views/menus/view.php +++ b/oss/joomla/trunk/administrator/components/com_menus/views/menus/view.php @@ -1,142 +1,142 @@ -_layout = 'default'; - - // Set toolbar items for the page - JToolBarHelper::title( JText::_( 'Menu Manager' ), 'menumgr.png' ); - JToolBarHelper::customX( 'copyMenu', 'copy.png', 'copy_f2.png', 'Copy', true ); - JToolBarHelper::customX( 'deleteMenu', 'delete.png', 'delete_f2.png', 'Delete', true ); - JToolBarHelper::editListX('editMenu'); - JToolBarHelper::addNewX('addMenu'); - JToolBarHelper::help( 'screen.menumanager' ); - - $document = & JFactory::getDocument(); - $document->setTitle(JText::_('View Menus')); - - $limitstart = JRequest::getVar('limitstart', '0', '', 'int'); - - $menus = &$this->get('Menus'); - $pagination = &$this->get('Pagination'); - - $this->assignRef('menus', $menus); - $this->assignRef('pagination', $pagination); - $this->assignRef('limitstart', $limitstart); - - JHTML::_('behavior.tooltip'); - - parent::display($tpl); - } - - function copyForm($tpl=null) - { - global $mainframe; - - $this->_layout = 'copy'; - - // view data - $table = $this->get('Table'); - $items = $this->get('MenuItems'); - - /* - * Set toolbar items for the page - */ - JToolBarHelper::title( JText::_( 'Copy Menu' ) ); - JToolBarHelper::custom( 'doCopyMenu', 'copy.png', 'copy_f2.png', 'Copy', false ); - JToolBarHelper::cancel(); - JToolBarHelper::help( 'screen.menumanager' ); - - $document = & JFactory::getDocument(); - $document->setTitle(JText::_('Copy Menu Items')); - - $this->assignRef('items', $items); - $this->assignRef('table', $table); - - parent::display($tpl); - } - - function deleteForm($tpl=null) - { - global $mainframe; - - $this->_layout = 'delete'; - - /* - * Set toolbar items for the page - */ - JToolBarHelper::title( JText::_( 'Menu' ) . ': [ '. JText::_( 'Delete' ) .' ]' ); - JToolBarHelper::custom( 'doDeleteMenu', 'delete.png', 'delete_f2.png', 'Delete', false ); - JToolBarHelper::cancel(); - JToolBarHelper::help( 'screen.menumanager.delete' ); - - // view data - $table = $this->get('Table'); - $modules = $this->get('Modules'); - $menuItems = $this->get('MenuItems'); - - $document = & JFactory::getDocument(); - $document->setTitle(JText::_('Confirm Delete Menu Type') . ': ' . $table->menutype ); - - - $this->assignRef('table', $table); - $this->assignRef('modules', $modules); - $this->assignRef('menuItems', $menuItems); - - parent::display($tpl); - } - - function editForm($edit,$tpl=null) - { - JRequest::setVar( 'hidemainmenu', 1 ); - - global $mainframe; - - $this->_layout = 'edit'; - if($edit) - $table = &$this->get('Table'); - else - $table=& JTable::getInstance('menuTypes'); - /* - * Set toolbar items for the page - */ - $text = ( ($table->id != 0) ? JText::_( 'Edit' ) : JText::_( 'New' ) ); - JToolBarHelper::title( JText::_( 'Menu Details' ).': [ '. $text.' ]', 'menumgr.png' ); - JToolBarHelper::custom( 'savemenu', 'save.png', 'save_f2.png', 'Save', false ); - JToolBarHelper::cancel(); - JToolBarHelper::help( 'screen.menumanager.new' ); - - $this->assignRef('row', $table); - $this->assign('isnew', ($table->id == 0)); - - JHTML::_('behavior.tooltip'); - - parent::display($tpl); - } -} +_layout = 'default'; + + // Set toolbar items for the page + JToolBarHelper::title( JText::_( 'Menu Manager' ), 'menumgr.png' ); + JToolBarHelper::customX( 'copyMenu', 'copy.png', 'copy_f2.png', 'Copy', true ); + JToolBarHelper::customX( 'deleteMenu', 'delete.png', 'delete_f2.png', 'Delete', true ); + JToolBarHelper::editListX('editMenu'); + JToolBarHelper::addNewX('addMenu'); + JToolBarHelper::help( 'screen.menumanager' ); + + $document = & JFactory::getDocument(); + $document->setTitle(JText::_('View Menus')); + + $limitstart = JRequest::getVar('limitstart', '0', '', 'int'); + + $menus = &$this->get('Menus'); + $pagination = &$this->get('Pagination'); + + $this->assignRef('menus', $menus); + $this->assignRef('pagination', $pagination); + $this->assignRef('limitstart', $limitstart); + + JHTML::_('behavior.tooltip'); + + parent::display($tpl); + } + + function copyForm($tpl=null) + { + global $mainframe; + + $this->_layout = 'copy'; + + // view data + $table = $this->get('Table'); + $items = $this->get('MenuItems'); + + /* + * Set toolbar items for the page + */ + JToolBarHelper::title( JText::_( 'Copy Menu' ) ); + JToolBarHelper::custom( 'doCopyMenu', 'copy.png', 'copy_f2.png', 'Copy', false ); + JToolBarHelper::cancel(); + JToolBarHelper::help( 'screen.menumanager' ); + + $document = & JFactory::getDocument(); + $document->setTitle(JText::_('Copy Menu Items')); + + $this->assignRef('items', $items); + $this->assignRef('table', $table); + + parent::display($tpl); + } + + function deleteForm($tpl=null) + { + global $mainframe; + + $this->_layout = 'delete'; + + /* + * Set toolbar items for the page + */ + JToolBarHelper::title( JText::_( 'Menu' ) . ': [ '. JText::_( 'Delete' ) .' ]' ); + JToolBarHelper::custom( 'doDeleteMenu', 'delete.png', 'delete_f2.png', 'Delete', false ); + JToolBarHelper::cancel(); + JToolBarHelper::help( 'screen.menumanager.delete' ); + + // view data + $table = $this->get('Table'); + $modules = $this->get('Modules'); + $menuItems = $this->get('MenuItems'); + + $document = & JFactory::getDocument(); + $document->setTitle(JText::_('Confirm Delete Menu Type') . ': ' . $table->menutype ); + + + $this->assignRef('table', $table); + $this->assignRef('modules', $modules); + $this->assignRef('menuItems', $menuItems); + + parent::display($tpl); + } + + function editForm($edit,$tpl=null) + { + JRequest::setVar( 'hidemainmenu', 1 ); + + global $mainframe; + + $this->_layout = 'edit'; + if($edit) + $table = &$this->get('Table'); + else + $table=& JTable::getInstance('menuTypes'); + /* + * Set toolbar items for the page + */ + $text = ( ($table->id != 0) ? JText::_( 'Edit' ) : JText::_( 'New' ) ); + JToolBarHelper::title( JText::_( 'Menu Details' ).': [ '. $text.' ]', 'menumgr.png' ); + JToolBarHelper::custom( 'savemenu', 'save.png', 'save_f2.png', 'Save', false ); + JToolBarHelper::cancel(); + JToolBarHelper::help( 'screen.menumanager.new' ); + + $this->assignRef('row', $table); + $this->assign('isnew', ($table->id == 0)); + + JHTML::_('behavior.tooltip'); + + parent::display($tpl); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_messages/admin.messages.html.php b/oss/joomla/trunk/administrator/components/com_messages/admin.messages.html.php index 09f8cb6c..ec3c93dd 100644 --- a/oss/joomla/trunk/administrator/components/com_messages/admin.messages.html.php +++ b/oss/joomla/trunk/administrator/components/com_messages/admin.messages.html.php @@ -1,296 +1,296 @@ - -
    - - - - - - -
    - : - - - - - -
    - -
    - - - - - - - - - - - - - - - - - - state ? 'tick.png' : 'publish_x.png'; - $alt = $row->state ? JText::_( 'Read' ) : JText::_( 'Read' ); - - if ( $user->authorize( 'com_users', 'manage' ) ) { - $linkA = 'index.php?option=com_users&view=user&task=edit&cid[]='. $row->user_id_from; - $author = ''. $row->user_from .''; - } else { - $author = $row->user_from; - } - - ?> - "> - - - - - - - - - -
    - - - - - - - - - - - -
    - getListFooter(); ?> -
    - limitstart;?> - - message_id ); ?> - - - subject; ?> - - - <?php echo $alt; ?> - - - - date_time, JText::_('DATE_FORMAT_LC2')); ?> -
    -
    - - - - - - - -
    - - -
    - -
    - - - - - - - - - - - - - -
    - : - - -
    - : - - -
    - : - - - -
    -
    - - - - -
    - -
    - - - - - - - - - - - - - - - - - - -
    - : - - user_from;?> -
    - : - - date_time;?> -
    - : - - subject;?> -
    - : - -
    message, ENT_COMPAT, 'UTF-8' );?>
    -
    - - - - - - - - -
    - - -
    - - - - - - - - - - - - - - -
    - : - - -
    - : - - -
    - : - - -
    - - - - - -
    - +
    + + + + + + +
    + : + + + + + +
    + +
    + + + + + + + + + + + + + + + + + + state ? 'tick.png' : 'publish_x.png'; + $alt = $row->state ? JText::_( 'Read' ) : JText::_( 'Read' ); + + if ( $user->authorize( 'com_users', 'manage' ) ) { + $linkA = 'index.php?option=com_users&view=user&task=edit&cid[]='. $row->user_id_from; + $author = ''. $row->user_from .''; + } else { + $author = $row->user_from; + } + + ?> + "> + + + + + + + + + +
    + + + + + + + + + + + +
    + getListFooter(); ?> +
    + limitstart;?> + + message_id ); ?> + + + subject; ?> + + + <?php echo $alt; ?> + + + + date_time, JText::_('DATE_FORMAT_LC2')); ?> +
    +
    + + + + + + + +
    + + +
    + +
    + + + + + + + + + + + + + +
    + : + + +
    + : + + +
    + : + + + +
    +
    + + + + +
    + +
    + + + + + + + + + + + + + + + + + + +
    + : + + user_from;?> +
    + : + + date_time;?> +
    + : + + subject;?> +
    + : + +
    message, ENT_COMPAT, 'UTF-8' );?>
    +
    + + + + + + + + +
    + + +
    + + + + + + + + + + + + + + +
    + : + + +
    + : + + +
    + : + + +
    + + + + + +
    + getUserStateFromRequest( $context.'.filter_order', 'filter_order', 'a.date_time', 'cmd' ); - $filter_order_Dir = $mainframe->getUserStateFromRequest( $context.'.filter_order_Dir','filter_order_Dir', 'DESC', 'word' ); - $filter_state = $mainframe->getUserStateFromRequest( $context.'.filter_state', 'filter_state', '', 'word' ); - $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); - $limitstart = $mainframe->getUserStateFromRequest( $context.'.limitstart', 'limitstart', 0, 'int' ); - $search = $mainframe->getUserStateFromRequest( $context.'search', 'search', '', 'string' ); - $search = JString::strtolower( $search ); - - $where = array(); - $where[] = ' a.user_id_to='.(int) $user->get('id'); - - if ($search != '') { - $searchEscaped = $db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); - $where[] = '( a.subject LIKE '.$searchEscaped.' OR a.message LIKE '.$searchEscaped.' )'; - } - if ( $filter_state ) { - if ( $filter_state == 'P' ) { - $where[] = 'a.state = 1'; - } else if ($filter_state == 'U' ) { - $where[] = 'a.state = 0'; - } - } - - $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); - $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', a.date_time DESC'; - - $query = 'SELECT COUNT(*)' - . ' FROM #__messages AS a' - . ' INNER JOIN #__users AS u ON u.id = a.user_id_from' - . $where - ; - $db->setQuery( $query ); - $total = $db->loadResult(); - - jimport('joomla.html.pagination'); - $pageNav = new JPagination( $total, $limitstart, $limit ); - - $query = 'SELECT a.*, u.name AS user_from' - . ' FROM #__messages AS a' - . ' INNER JOIN #__users AS u ON u.id = a.user_id_from' - . $where - . $orderby - ; - $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); - $rows = $db->loadObjectList(); - if ($db->getErrorNum()) { - echo $db->stderr(); - return false; - } - - // state filter - $lists['state'] = JHTML::_('grid.state', $filter_state, 'Read', 'Unread' ); - - // table ordering - $lists['order_Dir'] = $filter_order_Dir; - $lists['order'] = $filter_order; - - // search filter - $lists['search']= $search; - - HTML_messages::showMessages( $rows, $pageNav, $option, $lists ); -} - -function editConfig( $option ) -{ - $db =& JFactory::getDBO(); - $user =& JFactory::getUser(); - - $query = 'SELECT cfg_name, cfg_value' - . ' FROM #__messages_cfg' - . ' WHERE user_id = '.(int) $user->get('id') - ; - $db->setQuery( $query ); - $data = $db->loadObjectList( 'cfg_name' ); - - // initialize values if they do not exist - if (!isset($data['lock']->cfg_value)) { - $data['lock']->cfg_value = 0; - } - if (!isset($data['mail_on_new']->cfg_value)) { - $data['mail_on_new']->cfg_value = 0; - } - if (!isset($data['auto_purge']->cfg_value)) { - $data['auto_purge']->cfg_value = 7; - } - - $vars = array(); - $vars['lock'] = JHTML::_('select.booleanlist', "vars[lock]", '', $data['lock']->cfg_value, 'yes', 'no', 'varslock' ); - $vars['mail_on_new'] = JHTML::_('select.booleanlist', "vars[mail_on_new]", '', $data['mail_on_new']->cfg_value, 'yes', 'no', 'varsmail_on_new' ); - $vars['auto_purge'] = $data['auto_purge']->cfg_value; - - HTML_messages::editConfig( $vars, $option ); - -} - -function saveConfig( $option ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $user =& JFactory::getUser(); - - $query = 'DELETE FROM #__messages_cfg' - . ' WHERE user_id = '.(int) $user->get('id') - ; - $db->setQuery( $query ); - $db->query(); - - $vars = JRequest::getVar( 'vars', array(), 'post', 'array' ); - foreach ($vars as $k=>$v) { - $v = $db->getEscaped( $v ); - $query = 'INSERT INTO #__messages_cfg' - . ' ( user_id, cfg_name, cfg_value )' - . ' VALUES ( '.(int) $user->get('id').', '.$db->Quote($k).', '.$db->Quote($v).' )' - ; - $db->setQuery( $query ); - $db->query(); - } - $mainframe->redirect( "index.php?option=$option" ); -} - -function newMessage( $option, $user, $subject ) -{ - $db =& JFactory::getDBO(); - $acl =& JFactory::getACL(); - - // get available backend user groups - $gid = $acl->get_group_id( 'Public Backend', 'ARO' ); - $gids = $acl->get_group_children( $gid, 'ARO', 'RECURSE' ); - JArrayHelper::toInteger($gids, array(0)); - $gids = implode( ',', $gids ); - - // get list of usernames - $recipients = array( JHTML::_('select.option', '0', '- '. JText::_( 'Select User' ) .' -' ) ); - $query = 'SELECT id AS value, username AS text FROM #__users' - . ' WHERE gid IN ( '.$gids.' )' - . ' ORDER BY name' - ; - $db->setQuery( $query ); - $recipients = array_merge( $recipients, $db->loadObjectList() ); - - $recipientslist = - JHTML::_('select.genericlist', $recipients, 'user_id_to', 'class="inputbox" size="1"', 'value', 'text', $user); - HTML_messages::newMessage($option, $recipientslist, $subject ); -} - -function saveMessage( $option ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - require_once(dirname(__FILE__).DS.'tables'.DS.'message.php'); - - $db =& JFactory::getDBO(); - $row = new TableMessage( $db ); - - if (!$row->bind(JRequest::get('post'))) { - JError::raiseError(500, $row->getError() ); - } - - if (!$row->check()) { - JError::raiseError(500, $row->getError() ); - } - - if (!$row->send()) { - $mainframe->redirect( "index.php?option=com_messages", $row->getError() ); - } - $mainframe->redirect( "index.php?option=com_messages" ); -} - -function viewMessage( $uid='0', $option ) -{ - $db =& JFactory::getDBO(); - - $query = 'SELECT a.*, u.name AS user_from' - . ' FROM #__messages AS a' - . ' INNER JOIN #__users AS u ON u.id = a.user_id_from' - . ' WHERE a.message_id = '.(int) $uid - . ' ORDER BY date_time DESC' - ; - $db->setQuery( $query ); - $row = $db->loadObject(); - - $query = 'UPDATE #__messages' - . ' SET state = 1' - . ' WHERE message_id = '.(int) $uid - ; - $db->setQuery( $query ); - $db->query(); - - HTML_messages::viewMessage( $row, $option ); -} - -function removeMessage( $cid, $option ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - - JArrayHelper::toInteger($cid); - - if (count( $cid ) < 1) { - JError::raiseError(500, JText::_( 'Select an item to delete' ) ); - } - - if (count( $cid )) - { - $cids = implode( ',', $cid ); - $query = 'DELETE FROM #__messages' - . ' WHERE message_id IN ( '. $cids .' )' - ; - $db->setQuery( $query ); - if (!$db->query()) { - echo "\n"; - } - } - - $limit = JRequest::getVar( 'limit', 10, '', 'int' ); - $limitstart = JRequest::getVar( 'limitstart', 0, '', 'int' ); - - $mainframe->redirect( 'index.php?option='.$option.'&limit='.$limit.'&limitstart='.$limitstart ); -} +getUserStateFromRequest( $context.'.filter_order', 'filter_order', 'a.date_time', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( $context.'.filter_order_Dir','filter_order_Dir', 'DESC', 'word' ); + $filter_state = $mainframe->getUserStateFromRequest( $context.'.filter_state', 'filter_state', '', 'word' ); + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( $context.'.limitstart', 'limitstart', 0, 'int' ); + $search = $mainframe->getUserStateFromRequest( $context.'search', 'search', '', 'string' ); + if (strpos($search, '"') !== false) { + $search = str_replace(array('=', '<'), '', $search); + } + $search = JString::strtolower($search); + + $where = array(); + $where[] = ' a.user_id_to='.(int) $user->get('id'); + + if ($search != '') { + $searchEscaped = $db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + $where[] = '( a.subject LIKE '.$searchEscaped.' OR a.message LIKE '.$searchEscaped.' )'; + } + if ( $filter_state ) { + if ( $filter_state == 'P' ) { + $where[] = 'a.state = 1'; + } else if ($filter_state == 'U' ) { + $where[] = 'a.state = 0'; + } + } + + $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); + $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', a.date_time DESC'; + + $query = 'SELECT COUNT(*)' + . ' FROM #__messages AS a' + . ' INNER JOIN #__users AS u ON u.id = a.user_id_from' + . $where + ; + $db->setQuery( $query ); + $total = $db->loadResult(); + + jimport('joomla.html.pagination'); + $pageNav = new JPagination( $total, $limitstart, $limit ); + + $query = 'SELECT a.*, u.name AS user_from' + . ' FROM #__messages AS a' + . ' INNER JOIN #__users AS u ON u.id = a.user_id_from' + . $where + . $orderby + ; + $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); + $rows = $db->loadObjectList(); + if ($db->getErrorNum()) { + echo $db->stderr(); + return false; + } + + // state filter + $lists['state'] = JHTML::_('grid.state', $filter_state, 'Read', 'Unread' ); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search']= $search; + + HTML_messages::showMessages( $rows, $pageNav, $option, $lists ); +} + +function editConfig( $option ) +{ + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + + $query = 'SELECT cfg_name, cfg_value' + . ' FROM #__messages_cfg' + . ' WHERE user_id = '.(int) $user->get('id') + ; + $db->setQuery( $query ); + $data = $db->loadObjectList( 'cfg_name' ); + + // initialize values if they do not exist + if (!isset($data['lock']->cfg_value)) { + $data['lock']->cfg_value = 0; + } + if (!isset($data['mail_on_new']->cfg_value)) { + $data['mail_on_new']->cfg_value = 0; + } + if (!isset($data['auto_purge']->cfg_value)) { + $data['auto_purge']->cfg_value = 7; + } + + $vars = array(); + $vars['lock'] = JHTML::_('select.booleanlist', "vars[lock]", '', $data['lock']->cfg_value, 'yes', 'no', 'varslock' ); + $vars['mail_on_new'] = JHTML::_('select.booleanlist', "vars[mail_on_new]", '', $data['mail_on_new']->cfg_value, 'yes', 'no', 'varsmail_on_new' ); + $vars['auto_purge'] = $data['auto_purge']->cfg_value; + + HTML_messages::editConfig( $vars, $option ); + +} + +function saveConfig( $option ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + + $query = 'DELETE FROM #__messages_cfg' + . ' WHERE user_id = '.(int) $user->get('id') + ; + $db->setQuery( $query ); + $db->query(); + + $vars = JRequest::getVar( 'vars', array(), 'post', 'array' ); + foreach ($vars as $k=>$v) { + $v = $db->getEscaped( $v ); + $query = 'INSERT INTO #__messages_cfg' + . ' ( user_id, cfg_name, cfg_value )' + . ' VALUES ( '.(int) $user->get('id').', '.$db->Quote($k).', '.$db->Quote($v).' )' + ; + $db->setQuery( $query ); + $db->query(); + } + $mainframe->redirect( "index.php?option=$option" ); +} + +function newMessage( $option, $user, $subject ) +{ + $db =& JFactory::getDBO(); + $acl =& JFactory::getACL(); + + // get available backend user groups + $gid = $acl->get_group_id( 'Public Backend', 'ARO' ); + $gids = $acl->get_group_children( $gid, 'ARO', 'RECURSE' ); + JArrayHelper::toInteger($gids, array(0)); + $gids = implode( ',', $gids ); + + // get list of usernames + $recipients = array( JHTML::_('select.option', '0', '- '. JText::_( 'Select User' ) .' -' ) ); + $query = 'SELECT id AS value, username AS text FROM #__users' + . ' WHERE gid IN ( '.$gids.' )' + . ' ORDER BY name' + ; + $db->setQuery( $query ); + $recipients = array_merge( $recipients, $db->loadObjectList() ); + + $recipientslist = + JHTML::_('select.genericlist', $recipients, 'user_id_to', 'class="inputbox" size="1"', 'value', 'text', $user); + HTML_messages::newMessage($option, $recipientslist, $subject ); +} + +function saveMessage( $option ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + require_once(dirname(__FILE__).DS.'tables'.DS.'message.php'); + + $db =& JFactory::getDBO(); + $row = new TableMessage( $db ); + + if (!$row->bind(JRequest::get('post'))) { + JError::raiseError(500, $row->getError() ); + } + + if (!$row->check()) { + JError::raiseError(500, $row->getError() ); + } + + if (!$row->send()) { + $mainframe->redirect( "index.php?option=com_messages", $row->getError() ); + } + $mainframe->redirect( "index.php?option=com_messages" ); +} + +function viewMessage( $uid='0', $option ) +{ + $db =& JFactory::getDBO(); + + $query = 'SELECT a.*, u.name AS user_from' + . ' FROM #__messages AS a' + . ' INNER JOIN #__users AS u ON u.id = a.user_id_from' + . ' WHERE a.message_id = '.(int) $uid + . ' ORDER BY date_time DESC' + ; + $db->setQuery( $query ); + $row = $db->loadObject(); + + $query = 'UPDATE #__messages' + . ' SET state = 1' + . ' WHERE message_id = '.(int) $uid + ; + $db->setQuery( $query ); + $db->query(); + + HTML_messages::viewMessage( $row, $option ); +} + +function removeMessage( $cid, $option ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + + JArrayHelper::toInteger($cid); + + if (count( $cid ) < 1) { + JError::raiseError(500, JText::_( 'Select an item to delete' ) ); + } + + if (count( $cid )) + { + $cids = implode( ',', $cid ); + $query = 'DELETE FROM #__messages' + . ' WHERE message_id IN ( '. $cids .' )' + ; + $db->setQuery( $query ); + if (!$db->query()) { + echo "\n"; + } + } + + $limit = JRequest::getVar( 'limit', 10, '', 'int' ); + $limitstart = JRequest::getVar( 'limitstart', 0, '', 'int' ); + + $mainframe->redirect( 'index.php?option='.$option.'&limit='.$limit.'&limitstart='.$limitstart ); +} diff --git a/oss/joomla/trunk/administrator/components/com_messages/messages.xml b/oss/joomla/trunk/administrator/components/com_messages/messages.xml index 72497e2b..dde7e71d 100644 --- a/oss/joomla/trunk/administrator/components/com_messages/messages.xml +++ b/oss/joomla/trunk/administrator/components/com_messages/messages.xml @@ -1,12 +1,12 @@ - - - Messaging - Joomla! Project - 2006 - Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - admin@joomla.org - www.joomla.org - 1.5.0 - Messaging - + + + Messaging + Joomla! Project + 2006 + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + Messaging + diff --git a/oss/joomla/trunk/administrator/components/com_messages/tables/message.php b/oss/joomla/trunk/administrator/components/com_messages/tables/message.php index 4cfbcd53..f6d9ca22 100644 --- a/oss/joomla/trunk/administrator/components/com_messages/tables/message.php +++ b/oss/joomla/trunk/administrator/components/com_messages/tables/message.php @@ -1,187 +1,187 @@ -user_id_from; - $toId = $toId ? $toId : $this->user_id_to; - $subject = $subject ? $subject : $this->subject; - $message = $message ? $message : $this->message; - } - - $query = 'SELECT cfg_name, cfg_value' . - ' FROM #__messages_cfg' . - ' WHERE user_id = '.(int) $toId; - $db->setQuery($query); - - $config = $db->loadObjectList('cfg_name'); - $locked = @ $config['lock']->cfg_value; - $domail = @ $config['mail_on_new']->cfg_value; - - if (!$locked) - { - $this->user_id_from = $fromId; - $this->user_id_to = $toId; - $this->subject = $subject; - $this->message = $message; - $date =& JFactory::getDate(); - $this->date_time = $date->toMySQL(); - - if ($this->store()) - { - if ($domail) - { - $query = 'SELECT name, email' . - ' FROM #__users' . - ' WHERE id = '.(int) $fromId; - $db->setQuery($query); - $fromObject = $db->loadObject(); - $fromname = $fromObject->name; - $mailfrom = $fromObject->email; - $siteURL = JURI::base(); - $sitename = $mainframe->getCfg( 'sitename' ); - - $query = 'SELECT email' . - ' FROM #__users' . - ' WHERE id = '.(int) $toId; - $db->setQuery($query); - $recipient = $db->loadResult(); - - $subject = sprintf (JText::_('A new private message has arrived'), $sitename); - $msg = sprintf (JText::_('Please login to read your message'), $siteURL); - - JUtility::sendMail($mailfrom, $fromname, $recipient, $subject, $msg); - } - return true; - } - } - else - { - if (is_object($this)) { - $this->setError(JText::_('MESSAGE_FAILED')); - } - } - return false; - } -} +user_id_from; + $toId = $toId ? $toId : $this->user_id_to; + $subject = $subject ? $subject : $this->subject; + $message = $message ? $message : $this->message; + } + + $query = 'SELECT cfg_name, cfg_value' . + ' FROM #__messages_cfg' . + ' WHERE user_id = '.(int) $toId; + $db->setQuery($query); + + $config = $db->loadObjectList('cfg_name'); + $locked = @ $config['lock']->cfg_value; + $domail = @ $config['mail_on_new']->cfg_value; + + if (!$locked) + { + $this->user_id_from = $fromId; + $this->user_id_to = $toId; + $this->subject = $subject; + $this->message = $message; + $date =& JFactory::getDate(); + $this->date_time = $date->toMySQL(); + + if ($this->store()) + { + if ($domail) + { + $query = 'SELECT name, email' . + ' FROM #__users' . + ' WHERE id = '.(int) $fromId; + $db->setQuery($query); + $fromObject = $db->loadObject(); + $fromname = $fromObject->name; + $mailfrom = $fromObject->email; + $siteURL = JURI::base(); + $sitename = $mainframe->getCfg( 'sitename' ); + + $query = 'SELECT email' . + ' FROM #__users' . + ' WHERE id = '.(int) $toId; + $db->setQuery($query); + $recipient = $db->loadResult(); + + $subject = sprintf (JText::_('A new private message has arrived'), $sitename); + $msg = sprintf (JText::_('Please login to read your message'), $siteURL); + + JUtility::sendMail($mailfrom, $fromname, $recipient, $subject, $msg); + } + return true; + } + } + else + { + if (is_object($this)) { + $this->setError(JText::_('MESSAGE_FAILED')); + } + } + return false; + } +} diff --git a/oss/joomla/trunk/administrator/components/com_messages/toolbar.messages.html.php b/oss/joomla/trunk/administrator/components/com_messages/toolbar.messages.html.php index e9c072bd..d2c62723 100644 --- a/oss/joomla/trunk/administrator/components/com_messages/toolbar.messages.html.php +++ b/oss/joomla/trunk/administrator/components/com_messages/toolbar.messages.html.php @@ -1,55 +1,55 @@ - -
    - - - - - - -
    - : - - - - - -
    - - - - - - - - - - - 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 $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'); - // 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'); ?> -
    - - - - - - - -
    - +
    + + + + + + +
    + : + + + + + +
    + + + + + + + + + + + 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 $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'); + // 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'); ?> +
    + + + + + + + +
    + authorize( 'com_modules', 'manage' )) { - $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); -} - -// Require the base controller -require_once (JPATH_COMPONENT.DS.'controller.php'); - -// Create the controller -$controller = new ModulesController( array( 'default_task' => 'view' )); - -// Perform the Request task -$controller->execute( JRequest::getCmd('task', 'view') ); - -// Redirect if set by the controller -$controller->redirect(); +authorize( 'com_modules', 'manage' )) { + $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); +} + +// Require the base controller +require_once (JPATH_COMPONENT.DS.'controller.php'); + +// Create the controller +$controller = new ModulesController( array( 'default_task' => 'view' )); + +// Perform the Request task +$controller->execute( JRequest::getCmd('task', 'view') ); + +// Redirect if set by the controller +$controller->redirect(); diff --git a/oss/joomla/trunk/administrator/components/com_modules/controller.php b/oss/joomla/trunk/administrator/components/com_modules/controller.php index 2ae42ac4..4d1c4619 100644 --- a/oss/joomla/trunk/administrator/components/com_modules/controller.php +++ b/oss/joomla/trunk/administrator/components/com_modules/controller.php @@ -1,830 +1,833 @@ -registerTask( 'apply', 'save' ); - $this->registerTask( 'unpublish', 'publish' ); - $this->registerTask( 'orderup', 'reorder' ); - $this->registerTask( 'orderdown', 'reorder' ); - $this->registerTask( 'accesspublic', 'access' ); - $this->registerTask( 'accessregistered','access' ); - $this->registerTask( 'accessspecial', 'access' ); - } - - /** - * Compiles a list of installed or defined modules - */ - function view() - { - global $mainframe; - - // Initialize some variables - $db =& JFactory::getDBO(); - $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); - $option = 'com_modules'; - - $filter_order = $mainframe->getUserStateFromRequest( $option.'filter_order', 'filter_order', 'm.position', 'cmd' ); - $filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'filter_order_Dir', 'filter_order_Dir', '', 'word' ); - $filter_state = $mainframe->getUserStateFromRequest( $option.'filter_state', 'filter_state', '', 'word' ); - $filter_position = $mainframe->getUserStateFromRequest( $option.'filter_position', 'filter_position', '', 'cmd' ); - $filter_type = $mainframe->getUserStateFromRequest( $option.'filter_type', 'filter_type', '', 'cmd' ); - $filter_assigned = $mainframe->getUserStateFromRequest( $option.'filter_assigned', 'filter_assigned', '', 'cmd' ); - $search = $mainframe->getUserStateFromRequest( $option.'search', 'search', '', 'string' ); - $search = JString::strtolower( $search ); - - $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); - $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); - - $where[] = 'm.client_id = '.(int) $client->id; - - $joins[] = 'LEFT JOIN #__users AS u ON u.id = m.checked_out'; - $joins[] = 'LEFT JOIN #__groups AS g ON g.id = m.access'; - $joins[] = 'LEFT JOIN #__modules_menu AS mm ON mm.moduleid = m.id'; - - // used by filter - if ( $filter_assigned ) { - $joins[] = 'LEFT JOIN #__templates_menu AS t ON t.menuid = mm.menuid'; - $where[] = 't.template = '.$db->Quote($filter_assigned); - } - if ( $filter_position ) { - $where[] = 'm.position = '.$db->Quote($filter_position); - } - if ( $filter_type ) { - $where[] = 'm.module = '.$db->Quote($filter_type); - } - if ( $search ) { - $where[] = 'LOWER( m.title ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); - } - if ( $filter_state ) { - if ( $filter_state == 'P' ) { - $where[] = 'm.published = 1'; - } else if ($filter_state == 'U' ) { - $where[] = 'm.published = 0'; - } - } - - $where = ' WHERE ' . implode( ' AND ', $where ); - $join = ' ' . implode( ' ', $joins ); - if ($filter_order == 'm.ordering') { - $orderby = ' ORDER BY m.position, m.ordering '. $filter_order_Dir; - } else { - $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', m.ordering ASC'; - } - - // get the total number of records - $query = 'SELECT COUNT(DISTINCT m.id)' - . ' FROM #__modules AS m' - . $join - . $where - ; - $db->setQuery( $query ); - $total = $db->loadResult(); - - jimport('joomla.html.pagination'); - $pageNav = new JPagination( $total, $limitstart, $limit ); - - $query = 'SELECT m.*, u.name AS editor, g.name AS groupname, MIN(mm.menuid) AS pages' - . ' FROM #__modules AS m' - . $join - . $where - . ' GROUP BY m.id' - . $orderby - ; - $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); - $rows = $db->loadObjectList(); - if ($db->getErrorNum()) { - echo $db->stderr(); - return false; - } - - // get list of Positions for dropdown filter - $query = 'SELECT m.position AS value, m.position AS text' - . ' FROM #__modules as m' - . ' WHERE m.client_id = '.(int) $client->id - . ' GROUP BY m.position' - . ' ORDER BY m.position' - ; - $positions[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select Position' ) .' -' ); - $db->setQuery( $query ); - $positions = array_merge( $positions, $db->loadObjectList() ); - $lists['position'] = JHTML::_('select.genericlist', $positions, 'filter_position', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "$filter_position" ); - - // get list of Positions for dropdown filter - $query = 'SELECT module AS value, module AS text' - . ' FROM #__modules' - . ' WHERE client_id = '.(int) $client->id - . ' GROUP BY module' - . ' ORDER BY module' - ; - $db->setQuery( $query ); - $types[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select Type' ) .' -' ); - $types = array_merge( $types, $db->loadObjectList() ); - $lists['type'] = JHTML::_('select.genericlist', $types, 'filter_type', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "$filter_type" ); - - // state filter - $lists['state'] = JHTML::_('grid.state', $filter_state ); - - // template assignment filter - $query = 'SELECT DISTINCT(template) AS text, template AS value'. - ' FROM #__templates_menu' . - ' WHERE client_id = '.(int) $client->id; - $db->setQuery( $query ); - $assigned[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select Template' ) .' -' ); - $assigned = array_merge( $assigned, $db->loadObjectList() ); - $lists['assigned'] = JHTML::_('select.genericlist', $assigned, 'filter_assigned', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "$filter_assigned" ); - - // table ordering - $lists['order_Dir'] = $filter_order_Dir; - $lists['order'] = $filter_order; - - // search filter - $lists['search']= $search; - - require_once( JApplicationHelper::getPath( 'admin_html' ) ); - HTML_modules::view( $rows, $client, $pageNav, $lists ); - } - - /** - * Compiles information to add or edit a module - * @param string The current GET/POST option - * @param integer The unique id of the record to edit - */ - function copy() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize some variables - $db =& JFactory::getDBO(); - $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); - $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); - - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - $n = count( $cid ); - - if ($n == 0) { - return JError::raiseWarning( 500, JText::_( 'No items selected' ) ); - } - - $row =& JTable::getInstance('module'); - $tuples = array(); - - foreach ($cid as $id) - { - // load the row from the db table - $row->load( (int) $id ); - $row->title = JText::sprintf( 'Copy of', $row->title ); - $row->id = 0; - $row->iscore = 0; - $row->published = 0; - - if (!$row->check()) { - return JError::raiseWarning( 500, $row->getError() ); - } - if (!$row->store()) { - return JError::raiseWarning( 500, $row->getError() ); - } - $row->checkin(); - - $row->reorder( 'position='.$db->Quote( $row->position ).' AND client_id='.(int) $client->id ); - - $query = 'SELECT menuid' - . ' FROM #__modules_menu' - . ' WHERE moduleid = '.(int) $cid[0] - ; - $db->setQuery( $query ); - $rows = $db->loadResultArray(); - - foreach ($rows as $menuid) { - $tuples[] = '('.(int) $row->id.','.(int) $menuid.')'; - } - } - - if (!empty( $tuples )) - { - // Module-Menu Mapping: Do it in one query - $query = 'INSERT INTO #__modules_menu (moduleid,menuid) VALUES '.implode( ',', $tuples ); - $db->setQuery( $query ); - if (!$db->query()) { - return JError::raiseWarning( 500, $db->getError() ); - } - } - - $msg = JText::sprintf( 'Items Copied', $n ); - $this->setRedirect( 'index.php?option=com_modules&client='. $client->id, $msg ); - } - - /** - * Saves the module after an edit form submit - */ - function save() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - global $mainframe; - - // Initialize some variables - $db =& JFactory::getDBO(); - $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); - $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); - - $post = JRequest::get( 'post' ); - // fix up special html fields - $post['content'] = JRequest::getVar( 'content', '', 'post', 'string', JREQUEST_ALLOWRAW ); - $post['client_id'] = $client->id; - - $row =& JTable::getInstance('module'); - - if (!$row->bind( $post, 'selections' )) { - return JError::raiseWarning( 500, $row->getError() ); - } - - if (!$row->check()) { - return JError::raiseWarning( 500, $row->getError() ); - } - - // if new item, order last in appropriate group - if (!$row->id) { - $where = 'position='.$db->Quote( $row->position ).' AND client_id='.(int) $client->id ; - $row->ordering = $row->getNextOrder( $where ); - } - - if (!$row->store()) { - return JError::raiseWarning( 500, $row->getError() ); - } - $row->checkin(); - - $menus = JRequest::getVar( 'menus', '', 'post', 'word' ); - $selections = JRequest::getVar( 'selections', array(), 'post', 'array' ); - JArrayHelper::toInteger($selections); - - // delete old module to menu item associations - $query = 'DELETE FROM #__modules_menu' - . ' WHERE moduleid = '.(int) $row->id - ; - $db->setQuery( $query ); - if (!$db->query()) { - return JError::raiseWarning( 500, $db->getError() ); - } - - // check needed to stop a module being assigned to `All` - // and other menu items resulting in a module being displayed twice - if ( $menus == 'all' ) { - // assign new module to `all` menu item associations - $query = 'INSERT INTO #__modules_menu' - . ' SET moduleid = '.(int) $row->id.' , menuid = 0' - ; - $db->setQuery( $query ); - if (!$db->query()) { - return JError::raiseWarning( 500, $db->getError() ); - } - } - else - { - foreach ($selections as $menuid) - { - // this check for the blank spaces in the select box that have been added for cosmetic reasons - if ( (int) $menuid >= 0 ) { - // assign new module to menu item associations - $query = 'INSERT INTO #__modules_menu' - . ' SET moduleid = '.(int) $row->id .', menuid = '.(int) $menuid - ; - $db->setQuery( $query ); - if (!$db->query()) { - return JError::raiseWarning( 500, $db->getError() ); - } - } - } - } - - // clean cache for all 3 front-end user groups (guest, reg, special) - $cache =& JFactory::getCache(); - $cache->remove($row->id . '0', $row->module); - $cache->remove($row->id . '1', $row->module); - $cache->remove($row->id . '2', $row->module); - // clean content cache because of loadposition plugin - $cache->clean( 'com_content' ); - - $this->setMessage( JText::_( 'Item saved' ) ); - switch ($this->getTask()) - { - case 'apply': - $this->setRedirect( 'index.php?option=com_modules&client='. $client->id .'&task=edit&id='. $row->id ); - break; - } - } - - /** - * Compiles information to add or edit a module - * @param string The current GET/POST option - * @param integer The unique id of the record to edit - */ - function edit( ) - { - // Initialize some variables - $db =& JFactory::getDBO(); - $user =& JFactory::getUser(); - - $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); - $module = JRequest::getVar( 'module', '', '', 'cmd' ); - $id = JRequest::getVar( 'id', 0, 'method', 'int' ); - $cid = JRequest::getVar( 'cid', array( $id ), 'method', 'array' ); - JArrayHelper::toInteger($cid, array(0)); - - $model = &$this->getModel('module'); - $model->setState( 'id', $cid[0] ); - $model->setState( 'clientId', $client->id ); - - $lists = array(); - $row =& JTable::getInstance('module'); - // load the row from the db table - $row->load( (int) $cid[0] ); - // fail if checked out not by 'me' - if ($row->isCheckedOut( $user->get('id') )) { - $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); - return JError::raiseWarning( 500, JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The module' ), $row->title ) ); - } - - $row->content = htmlspecialchars($row->content, ENT_COMPAT, 'UTF-8'); - - if ( $cid[0] ) { - $row->checkout( $user->get('id') ); - } - // if a new record we must still prime the JTableModel object with a default - // position and the order; also add an extra item to the order list to - // place the 'new' record in last position if desired - if ($cid[0] == 0) { - $row->position = 'left'; - $row->showtitle = true; - $row->published = 1; - //$row->ordering = $l; - - $row->module = $module; - } - - if ($client->id == 1) - { - $where = 'client_id = 1'; - $lists['client_id'] = 1; - $path = 'mod1_xml'; - } - else - { - $where = 'client_id = 0'; - $lists['client_id'] = 0; - $path = 'mod0_xml'; - } - - $query = 'SELECT position, ordering, showtitle, title' - . ' FROM #__modules' - . ' WHERE '. $where - . ' ORDER BY ordering' - ; - $db->setQuery( $query ); - $orders = $db->loadObjectList(); - if ($db->getErrorNum()) { - echo $db->stderr(); - return false; - } - - $orders2 = array(); - - $l = 0; - $r = 0; - for ($i=0, $n=count( $orders ); $i < $n; $i++) { - $ord = 0; - if (array_key_exists( $orders[$i]->position, $orders2 )) { - $ord =count( array_keys( $orders2[$orders[$i]->position] ) ) + 1; - } - - $orders2[$orders[$i]->position][] = JHTML::_('select.option', $ord, $ord.'::'.addslashes( $orders[$i]->title ) ); - } - - // get selected pages for $lists['selections'] - if ( $cid[0] ) { - $query = 'SELECT menuid AS value' - . ' FROM #__modules_menu' - . ' WHERE moduleid = '.(int) $row->id - ; - $db->setQuery( $query ); - $lookup = $db->loadObjectList(); - if (empty( $lookup )) { - $lookup = array( JHTML::_('select.option', '-1' ) ); - $row->pages = 'none'; - } elseif (count($lookup) == 1 && $lookup[0]->value == 0) { - $row->pages = 'all'; - } else { - $row->pages = null; - } - } else { - $lookup = array( JHTML::_('select.option', 0, JText::_( 'All' ) ) ); - $row->pages = 'all'; - } - - if ( $row->access == 99 || $row->client_id == 1 || $lists['client_id'] ) { - $lists['access'] = 'Administrator'; - $lists['showtitle'] = 'N/A '; - $lists['selections'] = 'N/A'; - } else { - if ( $client->id == '1' ) { - $lists['access'] = 'N/A'; - $lists['selections'] = 'N/A'; - } else { - $lists['access'] = JHTML::_('list.accesslevel', $row ); - - $selections = JHTML::_('menu.linkoptions'); - $lists['selections'] = JHTML::_('select.genericlist', $selections, 'selections[]', 'class="inputbox" size="15" multiple="multiple"', 'value', 'text', $lookup, 'selections' ); - } - $lists['showtitle'] = JHTML::_('select.booleanlist', 'showtitle', 'class="inputbox"', $row->showtitle ); - } - - // build the html select list for published - $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $row->published ); - - $row->description = ''; - - $lang =& JFactory::getLanguage(); - if ( $client->id != '1' ) { - $lang->load( trim($row->module), JPATH_SITE ); - } else { - $lang->load( trim($row->module) ); - } - - // xml file for module - if ($row->module == 'custom') { - $xmlfile = JApplicationHelper::getPath( $path, 'mod_custom' ); - } else { - $xmlfile = JApplicationHelper::getPath( $path, $row->module ); - } - - $data = JApplicationHelper::parseXMLInstallFile($xmlfile); - if ($data) - { - foreach($data as $key => $value) { - $row->$key = $value; - } - } - - // get params definitions - $params = new JParameter( $row->params, $xmlfile, 'module' ); - - require_once( JApplicationHelper::getPath( 'admin_html' ) ); - HTML_modules::edit( $model, $row, $orders2, $lists, $params, $client ); - } - - /** - * Displays a list to select the creation of a new module - */ - function add() - { - global $mainframe; - - // Initialize some variables - $modules = array(); - $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); - - // path to search for modules - if ($client->id == '1') { - $path = JPATH_ADMINISTRATOR.DS.'modules'; - $langbase = JPATH_ADMINISTRATOR; - } else { - $path = JPATH_ROOT.DS.'modules'; - $langbase = JPATH_ROOT; - } - - jimport('joomla.filesystem.folder'); - $dirs = JFolder::folders( $path ); - $lang =& JFactory::getLanguage(); - - foreach ($dirs as $dir) - { - if (substr( $dir, 0, 4 ) == 'mod_') - { - $files = JFolder::files( $path.DS.$dir, '^([_A-Za-z0-9]*)\.xml$' ); - $module = new stdClass; - $module->file = $files[0]; - $module->module = str_replace( '.xml', '', $files[0] ); - $module->path = $path.DS.$dir; - $modules[] = $module; - - $lang->load( $module->module, $langbase ); - } - } - - require_once( JPATH_COMPONENT.DS.'helpers'.DS.'xml.php' ); - ModulesHelperXML::parseXMLModuleFile( $modules, $client ); - - $n = count($modules); - for ($i = 0; $i < $n; $i++) { - $modules[$i]->name = JText::_(stripslashes($modules[$i]->name)); - } - - // sort array of objects alphabetically by name - JArrayHelper::sortObjects( $modules, 'name' ); - - require_once( JApplicationHelper::getPath( 'admin_html' ) ); - HTML_modules::add( $modules, $client ); - } - - /** - * Deletes one or more modules - * - * Also deletes associated entries in the #__module_menu table. - * @param array An array of unique category id numbers - */ - function remove() - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize some variables - $db =& JFactory::getDBO(); - $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); - $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); - - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - JArrayHelper::toInteger( $cid ); - - if (empty( $cid )) { - return JError::raiseWarning( 500, 'No items selected' ); - } - - $cids = implode( ',', $cid ); - - // pasamio: Disabled this as it breaks the uninstall ability! - /*$query = 'SELECT id, module, title, iscore, params' - . ' FROM #__modules WHERE id IN ('.$cids.')' - ; - $db->setQuery( $query ); - if (!($rows = $db->loadObjectList())) { - return JError::raiseError( 500, $db->getErrorMsg() ); - }*/ - - // remove mappings first (lest we leave orphans) - $query = 'DELETE FROM #__modules_menu' - . ' WHERE moduleid IN ( '.$cids.' )' - ; - $db->setQuery( $query ); - if (!$db->query()) { - return JError::raiseError( 500, $db->getErrorMsg() ); - } - // remove module - $query = 'DELETE FROM #__modules' - . ' WHERE id IN ('.$cids.')' - ; - $db->setQuery( $query ); - if (!$db->query()) { - return JError::raiseError( 500, $db->getErrorMsg() ); - } - - $this->setMessage( JText::sprintf( 'Items removed', count( $cid ) ) ); - } - - /** - * Publishes or Unpublishes one or more modules - */ - function publish() - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize some variables - $db =& JFactory::getDBO(); - $user =& JFactory::getUser(); - $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); - $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); - - $cache = & JFactory::getCache(); - $cache->clean( 'com_content' ); - - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - JArrayHelper::toInteger($cid); - - $task = $this->getTask(); - $publish = ($task == 'publish'); - - if (empty( $cid )) { - return JError::raiseWarning( 500, 'No items selected' ); - } - - $cids = implode( ',', $cid ); - - $query = 'UPDATE #__modules' - . ' SET published = ' . intval( $publish ) - . ' WHERE id IN ( '.$cids.' )' - . ' AND ( checked_out = 0 OR ( checked_out = '.(int) $user->get('id').' ) )' - ; - $db->setQuery( $query ); - if (!$db->query()) { - return JError::raiseWarning( 500, $db->getErrorMsg() ); - } - - if (count( $cid ) == 1) { - $row =& JTable::getInstance('module'); - $row->checkin( $cid[0] ); - } - } - - /** - * Cancels an edit operation - */ - function cancel() - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize some variables - $db =& JFactory::getDBO(); - $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); - $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); - - $row =& JTable::getInstance('module'); - // ignore array elements - $row->bind(JRequest::get('post'), 'selections params' ); - $row->checkin(); - } - - /** - * Moves the order of a record - */ - function reorder() - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize some variables - $db =& JFactory::getDBO(); - $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); - $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); - - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - JArrayHelper::toInteger($cid); - - $task = $this->getTask(); - $inc = ($task == 'orderup' ? -1 : 1); - - if (empty( $cid )) { - return JError::raiseWarning( 500, 'No items selected' ); - } - - $row =& JTable::getInstance('module'); - $row->load( (int) $cid[0] ); - - $row->move( $inc, 'position = '.$db->Quote( $row->position ).' AND client_id='.(int) $client->id ); - } - - /** - * Changes the access level of a record - */ - function access() - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize some variables - $db =& JFactory::getDBO(); - $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); - $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); - - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - JArrayHelper::toInteger($cid); - - $task = JRequest::getCmd( 'task' ); - - if (empty( $cid )) { - return JError::raiseWarning( 500, 'No items selected' ); - } - - switch ( $task ) - { - case 'accesspublic': - $access = 0; - break; - - case 'accessregistered': - $access = 1; - break; - - case 'accessspecial': - $access = 2; - break; - } - - $row =& JTable::getInstance('module'); - $row->load( (int) $cid[0] ); - $row->access = $access; - - if ( !$row->check() ) { - JError::raiseWarning( 500, $row->getError() ); - } - if ( !$row->store() ) { - JError::raiseWarning( 500, $row->getError() ); - } - } - - /** - * Saves the orders of the supplied list - */ - function saveOrder() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize some variables - $db =& JFactory::getDBO(); - $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); - $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); - - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - JArrayHelper::toInteger($cid); - - if (empty( $cid )) { - return JError::raiseWarning( 500, 'No items selected' ); - } - - $total = count( $cid ); - $row =& JTable::getInstance('module'); - $groupings = array(); - - $order = JRequest::getVar( 'order', array(0), 'post', 'array' ); - JArrayHelper::toInteger($order); - - // update ordering values - for ($i = 0; $i < $total; $i++) - { - $row->load( (int) $cid[$i] ); - // track postions - $groupings[] = $row->position; - - if ($row->ordering != $order[$i]) - { - $row->ordering = $order[$i]; - if (!$row->store()) { - return JError::raiseWarning( 500, $db->getErrorMsg() ); - } - } - } - - // execute updateOrder for each parent group - $groupings = array_unique( $groupings ); - foreach ($groupings as $group){ - $row->reorder('position = '.$db->Quote($group).' AND client_id = '.(int) $client->id); - } - - $this->setMessage (JText::_( 'New ordering saved' )); - } - - function preview() - { - $document =& JFactory::getDocument(); - $document->setTitle(JText::_('Module Preview')); - - require_once( JApplicationHelper::getPath( 'admin_html' ) ); - HTML_modules::preview( ); - } -} +registerTask( 'apply', 'save' ); + $this->registerTask( 'unpublish', 'publish' ); + $this->registerTask( 'orderup', 'reorder' ); + $this->registerTask( 'orderdown', 'reorder' ); + $this->registerTask( 'accesspublic', 'access' ); + $this->registerTask( 'accessregistered','access' ); + $this->registerTask( 'accessspecial', 'access' ); + } + + /** + * Compiles a list of installed or defined modules + */ + function view() + { + global $mainframe; + + // Initialize some variables + $db =& JFactory::getDBO(); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $option = 'com_modules'; + + $filter_order = $mainframe->getUserStateFromRequest( $option.'filter_order', 'filter_order', 'm.position', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'filter_order_Dir', 'filter_order_Dir', '', 'word' ); + $filter_state = $mainframe->getUserStateFromRequest( $option.'filter_state', 'filter_state', '', 'word' ); + $filter_position = $mainframe->getUserStateFromRequest( $option.'filter_position', 'filter_position', '', 'cmd' ); + $filter_type = $mainframe->getUserStateFromRequest( $option.'filter_type', 'filter_type', '', 'cmd' ); + $filter_assigned = $mainframe->getUserStateFromRequest( $option.'filter_assigned', 'filter_assigned', '', 'cmd' ); + $search = $mainframe->getUserStateFromRequest( $option.'search', 'search', '', 'string' ); + if (strpos($search, '"') !== false) { + $search = str_replace(array('=', '<'), '', $search); + } + $search = JString::strtolower($search); + + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); + + $where[] = 'm.client_id = '.(int) $client->id; + + $joins[] = 'LEFT JOIN #__users AS u ON u.id = m.checked_out'; + $joins[] = 'LEFT JOIN #__groups AS g ON g.id = m.access'; + $joins[] = 'LEFT JOIN #__modules_menu AS mm ON mm.moduleid = m.id'; + + // used by filter + if ( $filter_assigned ) { + $joins[] = 'LEFT JOIN #__templates_menu AS t ON t.menuid = mm.menuid'; + $where[] = 't.template = '.$db->Quote($filter_assigned); + } + if ( $filter_position ) { + $where[] = 'm.position = '.$db->Quote($filter_position); + } + if ( $filter_type ) { + $where[] = 'm.module = '.$db->Quote($filter_type); + } + if ( $search ) { + $where[] = 'LOWER( m.title ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + if ( $filter_state ) { + if ( $filter_state == 'P' ) { + $where[] = 'm.published = 1'; + } else if ($filter_state == 'U' ) { + $where[] = 'm.published = 0'; + } + } + + $where = ' WHERE ' . implode( ' AND ', $where ); + $join = ' ' . implode( ' ', $joins ); + if ($filter_order == 'm.ordering') { + $orderby = ' ORDER BY m.position, m.ordering '. $filter_order_Dir; + } else { + $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', m.ordering ASC'; + } + + // get the total number of records + $query = 'SELECT COUNT(DISTINCT m.id)' + . ' FROM #__modules AS m' + . $join + . $where + ; + $db->setQuery( $query ); + $total = $db->loadResult(); + + jimport('joomla.html.pagination'); + $pageNav = new JPagination( $total, $limitstart, $limit ); + + $query = 'SELECT m.*, u.name AS editor, g.name AS groupname, MIN(mm.menuid) AS pages' + . ' FROM #__modules AS m' + . $join + . $where + . ' GROUP BY m.id' + . $orderby + ; + $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); + $rows = $db->loadObjectList(); + if ($db->getErrorNum()) { + echo $db->stderr(); + return false; + } + + // get list of Positions for dropdown filter + $query = 'SELECT m.position AS value, m.position AS text' + . ' FROM #__modules as m' + . ' WHERE m.client_id = '.(int) $client->id + . ' GROUP BY m.position' + . ' ORDER BY m.position' + ; + $positions[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select Position' ) .' -' ); + $db->setQuery( $query ); + $positions = array_merge( $positions, $db->loadObjectList() ); + $lists['position'] = JHTML::_('select.genericlist', $positions, 'filter_position', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "$filter_position" ); + + // get list of Positions for dropdown filter + $query = 'SELECT module AS value, module AS text' + . ' FROM #__modules' + . ' WHERE client_id = '.(int) $client->id + . ' GROUP BY module' + . ' ORDER BY module' + ; + $db->setQuery( $query ); + $types[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select Type' ) .' -' ); + $types = array_merge( $types, $db->loadObjectList() ); + $lists['type'] = JHTML::_('select.genericlist', $types, 'filter_type', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "$filter_type" ); + + // state filter + $lists['state'] = JHTML::_('grid.state', $filter_state ); + + // template assignment filter + $query = 'SELECT DISTINCT(template) AS text, template AS value'. + ' FROM #__templates_menu' . + ' WHERE client_id = '.(int) $client->id; + $db->setQuery( $query ); + $assigned[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select Template' ) .' -' ); + $assigned = array_merge( $assigned, $db->loadObjectList() ); + $lists['assigned'] = JHTML::_('select.genericlist', $assigned, 'filter_assigned', 'class="inputbox" size="1" onchange="this.form.submit()"', 'value', 'text', "$filter_assigned" ); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search']= $search; + + require_once( JApplicationHelper::getPath( 'admin_html' ) ); + HTML_modules::view( $rows, $client, $pageNav, $lists ); + } + + /** + * Compiles information to add or edit a module + * @param string The current GET/POST option + * @param integer The unique id of the record to edit + */ + function copy() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize some variables + $db =& JFactory::getDBO(); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + $n = count( $cid ); + + if ($n == 0) { + return JError::raiseWarning( 500, JText::_( 'No items selected' ) ); + } + + $row =& JTable::getInstance('module'); + $tuples = array(); + + foreach ($cid as $id) + { + // load the row from the db table + $row->load( (int) $id ); + $row->title = JText::sprintf( 'Copy of', $row->title ); + $row->id = 0; + $row->iscore = 0; + $row->published = 0; + + if (!$row->check()) { + return JError::raiseWarning( 500, $row->getError() ); + } + if (!$row->store()) { + return JError::raiseWarning( 500, $row->getError() ); + } + $row->checkin(); + + $row->reorder( 'position='.$db->Quote( $row->position ).' AND client_id='.(int) $client->id ); + + $query = 'SELECT menuid' + . ' FROM #__modules_menu' + . ' WHERE moduleid = '.(int) $cid[0] + ; + $db->setQuery( $query ); + $rows = $db->loadResultArray(); + + foreach ($rows as $menuid) { + $tuples[] = '('.(int) $row->id.','.(int) $menuid.')'; + } + } + + if (!empty( $tuples )) + { + // Module-Menu Mapping: Do it in one query + $query = 'INSERT INTO #__modules_menu (moduleid,menuid) VALUES '.implode( ',', $tuples ); + $db->setQuery( $query ); + if (!$db->query()) { + return JError::raiseWarning( 500, $db->getError() ); + } + } + + $msg = JText::sprintf( 'Items Copied', $n ); + $this->setRedirect( 'index.php?option=com_modules&client='. $client->id, $msg ); + } + + /** + * Saves the module after an edit form submit + */ + function save() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + global $mainframe; + + // Initialize some variables + $db =& JFactory::getDBO(); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); + + $post = JRequest::get( 'post' ); + // fix up special html fields + $post['content'] = JRequest::getVar( 'content', '', 'post', 'string', JREQUEST_ALLOWRAW ); + $post['client_id'] = $client->id; + + $row =& JTable::getInstance('module'); + + if (!$row->bind( $post, 'selections' )) { + return JError::raiseWarning( 500, $row->getError() ); + } + + if (!$row->check()) { + return JError::raiseWarning( 500, $row->getError() ); + } + + // if new item, order last in appropriate group + if (!$row->id) { + $where = 'position='.$db->Quote( $row->position ).' AND client_id='.(int) $client->id ; + $row->ordering = $row->getNextOrder( $where ); + } + + if (!$row->store()) { + return JError::raiseWarning( 500, $row->getError() ); + } + $row->checkin(); + + $menus = JRequest::getVar( 'menus', '', 'post', 'word' ); + $selections = JRequest::getVar( 'selections', array(), 'post', 'array' ); + JArrayHelper::toInteger($selections); + + // delete old module to menu item associations + $query = 'DELETE FROM #__modules_menu' + . ' WHERE moduleid = '.(int) $row->id + ; + $db->setQuery( $query ); + if (!$db->query()) { + return JError::raiseWarning( 500, $db->getError() ); + } + + // check needed to stop a module being assigned to `All` + // and other menu items resulting in a module being displayed twice + if ( $menus == 'all' ) { + // assign new module to `all` menu item associations + $query = 'INSERT INTO #__modules_menu' + . ' SET moduleid = '.(int) $row->id.' , menuid = 0' + ; + $db->setQuery( $query ); + if (!$db->query()) { + return JError::raiseWarning( 500, $db->getError() ); + } + } + else + { + foreach ($selections as $menuid) + { + // this check for the blank spaces in the select box that have been added for cosmetic reasons + if ( (int) $menuid >= 0 ) { + // assign new module to menu item associations + $query = 'INSERT INTO #__modules_menu' + . ' SET moduleid = '.(int) $row->id .', menuid = '.(int) $menuid + ; + $db->setQuery( $query ); + if (!$db->query()) { + return JError::raiseWarning( 500, $db->getError() ); + } + } + } + } + + // clean cache for all 3 front-end user groups (guest, reg, special) + $cache =& JFactory::getCache(); + $cache->remove($row->id . '0', $row->module); + $cache->remove($row->id . '1', $row->module); + $cache->remove($row->id . '2', $row->module); + // clean content cache because of loadposition plugin + $cache->clean( 'com_content' ); + + $this->setMessage( JText::_( 'Item saved' ) ); + switch ($this->getTask()) + { + case 'apply': + $this->setRedirect( 'index.php?option=com_modules&client='. $client->id .'&task=edit&id='. $row->id ); + break; + } + } + + /** + * Compiles information to add or edit a module + * @param string The current GET/POST option + * @param integer The unique id of the record to edit + */ + function edit( ) + { + // Initialize some variables + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $module = JRequest::getVar( 'module', '', '', 'cmd' ); + $id = JRequest::getVar( 'id', 0, 'method', 'int' ); + $cid = JRequest::getVar( 'cid', array( $id ), 'method', 'array' ); + JArrayHelper::toInteger($cid, array(0)); + + $model = &$this->getModel('module'); + $model->setState( 'id', $cid[0] ); + $model->setState( 'clientId', $client->id ); + + $lists = array(); + $row =& JTable::getInstance('module'); + // load the row from the db table + $row->load( (int) $cid[0] ); + // fail if checked out not by 'me' + if ($row->isCheckedOut( $user->get('id') )) { + $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); + return JError::raiseWarning( 500, JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The module' ), $row->title ) ); + } + + $row->content = htmlspecialchars($row->content, ENT_COMPAT, 'UTF-8'); + + if ( $cid[0] ) { + $row->checkout( $user->get('id') ); + } + // if a new record we must still prime the JTableModel object with a default + // position and the order; also add an extra item to the order list to + // place the 'new' record in last position if desired + if ($cid[0] == 0) { + $row->position = 'left'; + $row->showtitle = true; + $row->published = 1; + //$row->ordering = $l; + + $row->module = $module; + } + + if ($client->id == 1) + { + $where = 'client_id = 1'; + $lists['client_id'] = 1; + $path = 'mod1_xml'; + } + else + { + $where = 'client_id = 0'; + $lists['client_id'] = 0; + $path = 'mod0_xml'; + } + + $query = 'SELECT position, ordering, showtitle, title' + . ' FROM #__modules' + . ' WHERE '. $where + . ' ORDER BY ordering' + ; + $db->setQuery( $query ); + $orders = $db->loadObjectList(); + if ($db->getErrorNum()) { + echo $db->stderr(); + return false; + } + + $orders2 = array(); + + $l = 0; + $r = 0; + for ($i=0, $n=count( $orders ); $i < $n; $i++) { + $ord = 0; + if (array_key_exists( $orders[$i]->position, $orders2 )) { + $ord =count( array_keys( $orders2[$orders[$i]->position] ) ) + 1; + } + + $orders2[$orders[$i]->position][] = JHTML::_('select.option', $ord, $ord.'::'.addslashes( $orders[$i]->title ) ); + } + + // get selected pages for $lists['selections'] + if ( $cid[0] ) { + $query = 'SELECT menuid AS value' + . ' FROM #__modules_menu' + . ' WHERE moduleid = '.(int) $row->id + ; + $db->setQuery( $query ); + $lookup = $db->loadObjectList(); + if (empty( $lookup )) { + $lookup = array( JHTML::_('select.option', '-1' ) ); + $row->pages = 'none'; + } elseif (count($lookup) == 1 && $lookup[0]->value == 0) { + $row->pages = 'all'; + } else { + $row->pages = null; + } + } else { + $lookup = array( JHTML::_('select.option', 0, JText::_( 'All' ) ) ); + $row->pages = 'all'; + } + + if ( $row->access == 99 || $row->client_id == 1 || $lists['client_id'] ) { + $lists['access'] = 'Administrator'; + $lists['showtitle'] = 'N/A '; + $lists['selections'] = 'N/A'; + } else { + if ( $client->id == '1' ) { + $lists['access'] = 'N/A'; + $lists['selections'] = 'N/A'; + } else { + $lists['access'] = JHTML::_('list.accesslevel', $row ); + + $selections = JHTML::_('menu.linkoptions'); + $lists['selections'] = JHTML::_('select.genericlist', $selections, 'selections[]', 'class="inputbox" size="15" multiple="multiple"', 'value', 'text', $lookup, 'selections' ); + } + $lists['showtitle'] = JHTML::_('select.booleanlist', 'showtitle', 'class="inputbox"', $row->showtitle ); + } + + // build the html select list for published + $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $row->published ); + + $row->description = ''; + + $lang =& JFactory::getLanguage(); + if ( $client->id != '1' ) { + $lang->load( trim($row->module), JPATH_SITE ); + } else { + $lang->load( trim($row->module) ); + } + + // xml file for module + if ($row->module == 'custom') { + $xmlfile = JApplicationHelper::getPath( $path, 'mod_custom' ); + } else { + $xmlfile = JApplicationHelper::getPath( $path, $row->module ); + } + + $data = JApplicationHelper::parseXMLInstallFile($xmlfile); + if ($data) + { + foreach($data as $key => $value) { + $row->$key = $value; + } + } + + // get params definitions + $params = new JParameter( $row->params, $xmlfile, 'module' ); + + require_once( JApplicationHelper::getPath( 'admin_html' ) ); + HTML_modules::edit( $model, $row, $orders2, $lists, $params, $client ); + } + + /** + * Displays a list to select the creation of a new module + */ + function add() + { + global $mainframe; + + // Initialize some variables + $modules = array(); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + + // path to search for modules + if ($client->id == '1') { + $path = JPATH_ADMINISTRATOR.DS.'modules'; + $langbase = JPATH_ADMINISTRATOR; + } else { + $path = JPATH_ROOT.DS.'modules'; + $langbase = JPATH_ROOT; + } + + jimport('joomla.filesystem.folder'); + $dirs = JFolder::folders( $path ); + $lang =& JFactory::getLanguage(); + + foreach ($dirs as $dir) + { + if (substr( $dir, 0, 4 ) == 'mod_') + { + $files = JFolder::files( $path.DS.$dir, '^([_A-Za-z0-9]*)\.xml$' ); + $module = new stdClass; + $module->file = $files[0]; + $module->module = str_replace( '.xml', '', $files[0] ); + $module->path = $path.DS.$dir; + $modules[] = $module; + + $lang->load( $module->module, $langbase ); + } + } + + require_once( JPATH_COMPONENT.DS.'helpers'.DS.'xml.php' ); + ModulesHelperXML::parseXMLModuleFile( $modules, $client ); + + $n = count($modules); + for ($i = 0; $i < $n; $i++) { + $modules[$i]->name = JText::_(stripslashes($modules[$i]->name)); + } + + // sort array of objects alphabetically by name + JArrayHelper::sortObjects( $modules, 'name' ); + + require_once( JApplicationHelper::getPath( 'admin_html' ) ); + HTML_modules::add( $modules, $client ); + } + + /** + * Deletes one or more modules + * + * Also deletes associated entries in the #__module_menu table. + * @param array An array of unique category id numbers + */ + function remove() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize some variables + $db =& JFactory::getDBO(); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger( $cid ); + + if (empty( $cid )) { + return JError::raiseWarning( 500, 'No items selected' ); + } + + $cids = implode( ',', $cid ); + + // pasamio: Disabled this as it breaks the uninstall ability! + /*$query = 'SELECT id, module, title, iscore, params' + . ' FROM #__modules WHERE id IN ('.$cids.')' + ; + $db->setQuery( $query ); + if (!($rows = $db->loadObjectList())) { + return JError::raiseError( 500, $db->getErrorMsg() ); + }*/ + + // remove mappings first (lest we leave orphans) + $query = 'DELETE FROM #__modules_menu' + . ' WHERE moduleid IN ( '.$cids.' )' + ; + $db->setQuery( $query ); + if (!$db->query()) { + return JError::raiseError( 500, $db->getErrorMsg() ); + } + // remove module + $query = 'DELETE FROM #__modules' + . ' WHERE id IN ('.$cids.')' + ; + $db->setQuery( $query ); + if (!$db->query()) { + return JError::raiseError( 500, $db->getErrorMsg() ); + } + + $this->setMessage( JText::sprintf( 'Items removed', count( $cid ) ) ); + } + + /** + * Publishes or Unpublishes one or more modules + */ + function publish() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize some variables + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); + + $cache = & JFactory::getCache(); + $cache->clean( 'com_content' ); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + $task = $this->getTask(); + $publish = ($task == 'publish'); + + if (empty( $cid )) { + return JError::raiseWarning( 500, 'No items selected' ); + } + + $cids = implode( ',', $cid ); + + $query = 'UPDATE #__modules' + . ' SET published = ' . intval( $publish ) + . ' WHERE id IN ( '.$cids.' )' + . ' AND ( checked_out = 0 OR ( checked_out = '.(int) $user->get('id').' ) )' + ; + $db->setQuery( $query ); + if (!$db->query()) { + return JError::raiseWarning( 500, $db->getErrorMsg() ); + } + + if (count( $cid ) == 1) { + $row =& JTable::getInstance('module'); + $row->checkin( $cid[0] ); + } + } + + /** + * Cancels an edit operation + */ + function cancel() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize some variables + $db =& JFactory::getDBO(); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); + + $row =& JTable::getInstance('module'); + // ignore array elements + $row->bind(JRequest::get('post'), 'selections params' ); + $row->checkin(); + } + + /** + * Moves the order of a record + */ + function reorder() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize some variables + $db =& JFactory::getDBO(); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + $task = $this->getTask(); + $inc = ($task == 'orderup' ? -1 : 1); + + if (empty( $cid )) { + return JError::raiseWarning( 500, 'No items selected' ); + } + + $row =& JTable::getInstance('module'); + $row->load( (int) $cid[0] ); + + $row->move( $inc, 'position = '.$db->Quote( $row->position ).' AND client_id='.(int) $client->id ); + } + + /** + * Changes the access level of a record + */ + function access() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize some variables + $db =& JFactory::getDBO(); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + $task = JRequest::getCmd( 'task' ); + + if (empty( $cid )) { + return JError::raiseWarning( 500, 'No items selected' ); + } + + switch ( $task ) + { + case 'accesspublic': + $access = 0; + break; + + case 'accessregistered': + $access = 1; + break; + + case 'accessspecial': + $access = 2; + break; + } + + $row =& JTable::getInstance('module'); + $row->load( (int) $cid[0] ); + $row->access = $access; + + if ( !$row->check() ) { + JError::raiseWarning( 500, $row->getError() ); + } + if ( !$row->store() ) { + JError::raiseWarning( 500, $row->getError() ); + } + } + + /** + * Saves the orders of the supplied list + */ + function saveOrder() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize some variables + $db =& JFactory::getDBO(); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + if (empty( $cid )) { + return JError::raiseWarning( 500, 'No items selected' ); + } + + $total = count( $cid ); + $row =& JTable::getInstance('module'); + $groupings = array(); + + $order = JRequest::getVar( 'order', array(0), 'post', 'array' ); + JArrayHelper::toInteger($order); + + // update ordering values + for ($i = 0; $i < $total; $i++) + { + $row->load( (int) $cid[$i] ); + // track postions + $groupings[] = $row->position; + + if ($row->ordering != $order[$i]) + { + $row->ordering = $order[$i]; + if (!$row->store()) { + return JError::raiseWarning( 500, $db->getErrorMsg() ); + } + } + } + + // execute updateOrder for each parent group + $groupings = array_unique( $groupings ); + foreach ($groupings as $group){ + $row->reorder('position = '.$db->Quote($group).' AND client_id = '.(int) $client->id); + } + + $this->setMessage (JText::_( 'New ordering saved' )); + } + + function preview() + { + $document =& JFactory::getDocument(); + $document->setTitle(JText::_('Module Preview')); + + require_once( JApplicationHelper::getPath( 'admin_html' ) ); + HTML_modules::preview( ); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_modules/helpers/xml.php b/oss/joomla/trunk/administrator/components/com_modules/helpers/xml.php index c75479bb..95afc91e 100644 --- a/oss/joomla/trunk/administrator/components/com_modules/helpers/xml.php +++ b/oss/joomla/trunk/administrator/components/com_modules/helpers/xml.php @@ -1,46 +1,46 @@ - $row) - { - if ($row->module == '') - { - $rows[$i]->name = 'custom'; - $rows[$i]->module = 'custom'; - $rows[$i]->descrip = 'Custom created module, using Module Manager `New` function'; - } - else - { - $data = JApplicationHelper::parseXMLInstallFile( $row->path.DS.$row->file); - - if ( $data['type'] == 'module' ) - { - $rows[$i]->name = $data['name']; - $rows[$i]->descrip = $data['description']; - } - } - } - } + $row) + { + if ($row->module == '') + { + $rows[$i]->name = 'custom'; + $rows[$i]->module = 'custom'; + $rows[$i]->descrip = 'Custom created module, using Module Manager `New` function'; + } + else + { + $data = JApplicationHelper::parseXMLInstallFile( $row->path.DS.$row->file); + + if ( $data['type'] == 'module' ) + { + $rows[$i]->name = $data['name']; + $rows[$i]->descrip = $data['description']; + } + } + } + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_modules/models/module.php b/oss/joomla/trunk/administrator/components/com_modules/models/module.php index 495e0de4..95ebe865 100644 --- a/oss/joomla/trunk/administrator/components/com_modules/models/module.php +++ b/oss/joomla/trunk/administrator/components/com_modules/models/module.php @@ -1,170 +1,170 @@ -getTable( 'Module', 'JTable' ); - if ($id = $this->getState( 'id' )) { - $instance->load( (int) $id ); - } - } - return $instance; - } - - function &_getXML() - { - if (!$this->_xml) - { - $clientId = $this->getState( 'clientId', 0 ); - $path = ($clientId == 1) ? 'mod1_xml' : 'mod0_xml'; - $module = &$this->getModule(); - - if ($module->module == 'custom') { - $xmlpath = JApplicationHelper::getPath( $path, 'mod_custom' ); - } else { - $xmlpath = JApplicationHelper::getPath( $path, $module->module ); - } - - if (file_exists($xmlpath)) - { - $xml =& JFactory::getXMLParser('Simple'); - if ($xml->loadFile($xmlpath)) { - $this->_xml = &$xml; - } - } - } - return $this->_xml; - } - - function &getParams() - { - // Get the state parameters - $module =& $this->getModule(); - $params = new JParameter($module->params); - - if ($xml =& $this->_getXML()) - { - if ($ps = & $xml->document->params) { - foreach ($ps as $p) - { - $params->setXML( $p ); - } - } - } - return $params; - } - - function getPositions() - { - jimport('joomla.filesystem.folder'); - - $client =& JApplicationHelper::getClientInfo($this->getState('clientId')); - if ($client === false) { - return false; - } - - //Get the database object - $db =& JFactory::getDBO(); - - // template assignment filter - $query = 'SELECT DISTINCT(template) AS text, template AS value'. - ' FROM #__templates_menu' . - ' WHERE client_id = '.(int) $client->id; - $db->setQuery( $query ); - $templates = $db->loadObjectList(); - - // Get a list of all module positions as set in the database - $query = 'SELECT DISTINCT(position)'. - ' FROM #__modules' . - ' WHERE client_id = '.(int) $client->id; - $db->setQuery( $query ); - $positions = $db->loadResultArray(); - $positions = (is_array($positions)) ? $positions : array(); - - // Get a list of all template xml files for a given application - - // Get the xml parser first - for ($i = 0, $n = count($templates); $i < $n; $i++ ) - { - $path = $client->path.DS.'templates'.DS.$templates[$i]->value; - - $xml =& JFactory::getXMLParser('Simple'); - if ($xml->loadFile($path.DS.'templateDetails.xml')) - { - $p =& $xml->document->getElementByPath('positions'); - if (is_a($p, 'JSimpleXMLElement') && count($p->children())) - { - foreach ($p->children() as $child) - { - if (!in_array($child->data(), $positions)) { - $positions[] = $child->data(); - } - } - } - } - } - - if(defined('_JLEGACY') && _JLEGACY == '1.0') - { - $positions[] = 'left'; - $positions[] = 'right'; - $positions[] = 'top'; - $positions[] = 'bottom'; - $positions[] = 'inset'; - $positions[] = 'banner'; - $positions[] = 'header'; - $positions[] = 'footer'; - $positions[] = 'newsflash'; - $positions[] = 'legals'; - $positions[] = 'pathway'; - $positions[] = 'breadcrumb'; - $positions[] = 'user1'; - $positions[] = 'user2'; - $positions[] = 'user3'; - $positions[] = 'user4'; - $positions[] = 'user5'; - $positions[] = 'user6'; - $positions[] = 'user7'; - $positions[] = 'user8'; - $positions[] = 'user9'; - $positions[] = 'advert1'; - $positions[] = 'advert2'; - $positions[] = 'advert3'; - $positions[] = 'debug'; - $positions[] = 'syndicate'; - } - - $positions = array_unique($positions); - sort($positions); - - return $positions; - } -} +getTable( 'Module', 'JTable' ); + if ($id = $this->getState( 'id' )) { + $instance->load( (int) $id ); + } + } + return $instance; + } + + function &_getXML() + { + if (!$this->_xml) + { + $clientId = $this->getState( 'clientId', 0 ); + $path = ($clientId == 1) ? 'mod1_xml' : 'mod0_xml'; + $module = &$this->getModule(); + + if ($module->module == 'custom') { + $xmlpath = JApplicationHelper::getPath( $path, 'mod_custom' ); + } else { + $xmlpath = JApplicationHelper::getPath( $path, $module->module ); + } + + if (file_exists($xmlpath)) + { + $xml =& JFactory::getXMLParser('Simple'); + if ($xml->loadFile($xmlpath)) { + $this->_xml = &$xml; + } + } + } + return $this->_xml; + } + + function &getParams() + { + // Get the state parameters + $module =& $this->getModule(); + $params = new JParameter($module->params); + + if ($xml =& $this->_getXML()) + { + if ($ps = & $xml->document->params) { + foreach ($ps as $p) + { + $params->setXML( $p ); + } + } + } + return $params; + } + + function getPositions() + { + jimport('joomla.filesystem.folder'); + + $client =& JApplicationHelper::getClientInfo($this->getState('clientId')); + if ($client === false) { + return false; + } + + //Get the database object + $db =& JFactory::getDBO(); + + // template assignment filter + $query = 'SELECT DISTINCT(template) AS text, template AS value'. + ' FROM #__templates_menu' . + ' WHERE client_id = '.(int) $client->id; + $db->setQuery( $query ); + $templates = $db->loadObjectList(); + + // Get a list of all module positions as set in the database + $query = 'SELECT DISTINCT(position)'. + ' FROM #__modules' . + ' WHERE client_id = '.(int) $client->id; + $db->setQuery( $query ); + $positions = $db->loadResultArray(); + $positions = (is_array($positions)) ? $positions : array(); + + // Get a list of all template xml files for a given application + + // Get the xml parser first + for ($i = 0, $n = count($templates); $i < $n; $i++ ) + { + $path = $client->path.DS.'templates'.DS.$templates[$i]->value; + + $xml =& JFactory::getXMLParser('Simple'); + if ($xml->loadFile($path.DS.'templateDetails.xml')) + { + $p =& $xml->document->getElementByPath('positions'); + if (is_a($p, 'JSimpleXMLElement') && count($p->children())) + { + foreach ($p->children() as $child) + { + if (!in_array($child->data(), $positions)) { + $positions[] = $child->data(); + } + } + } + } + } + + if(defined('_JLEGACY') && _JLEGACY == '1.0') + { + $positions[] = 'left'; + $positions[] = 'right'; + $positions[] = 'top'; + $positions[] = 'bottom'; + $positions[] = 'inset'; + $positions[] = 'banner'; + $positions[] = 'header'; + $positions[] = 'footer'; + $positions[] = 'newsflash'; + $positions[] = 'legals'; + $positions[] = 'pathway'; + $positions[] = 'breadcrumb'; + $positions[] = 'user1'; + $positions[] = 'user2'; + $positions[] = 'user3'; + $positions[] = 'user4'; + $positions[] = 'user5'; + $positions[] = 'user6'; + $positions[] = 'user7'; + $positions[] = 'user8'; + $positions[] = 'user9'; + $positions[] = 'advert1'; + $positions[] = 'advert2'; + $positions[] = 'advert3'; + $positions[] = 'debug'; + $positions[] = 'syndicate'; + } + + $positions = array_unique($positions); + sort($positions); + + return $positions; + } +} diff --git a/oss/joomla/trunk/administrator/components/com_modules/modules.xml b/oss/joomla/trunk/administrator/components/com_modules/modules.xml index ec6e6321..fc839d50 100644 --- a/oss/joomla/trunk/administrator/components/com_modules/modules.xml +++ b/oss/joomla/trunk/administrator/components/com_modules/modules.xml @@ -1,12 +1,12 @@ - - - Module Manager - Joomla! Project - 2006 - Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - admin@joomla.org - www.joomla.org - 1.5.0 - Module Manager - + + + Module Manager + Joomla! Project + 2006 + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + Module Manager + diff --git a/oss/joomla/trunk/administrator/components/com_modules/toolbar.modules.html.php b/oss/joomla/trunk/administrator/components/com_modules/toolbar.modules.html.php index 0b69be78..1dcd37cf 100644 --- a/oss/joomla/trunk/administrator/components/com_modules/toolbar.modules.html.php +++ b/oss/joomla/trunk/administrator/components/com_modules/toolbar.modules.html.php @@ -1,73 +1,73 @@ -[ '. 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' ); - } -} +[ '. 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' ); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_modules/toolbar.modules.php b/oss/joomla/trunk/administrator/components/com_modules/toolbar.modules.php index 568baa64..f08c22cf 100644 --- a/oss/joomla/trunk/administrator/components/com_modules/toolbar.modules.php +++ b/oss/joomla/trunk/administrator/components/com_modules/toolbar.modules.php @@ -1,36 +1,36 @@ - -
    - - - - - - -
    - : - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - id ); - - $checked = JHTML::_('grid.checkedout', $row, $i ); - $published = JHTML::_('grid.published', $row, $i ); - - $row->cat_link = JRoute::_( 'index.php?option=com_categories§ion=com_newsfeeds&task=edit&cid[]='. $row->catid ); - ?> - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - -
    - getListFooter(); ?> -
    - getRowOffset( $i ); ?> - - - - get ('id'), $row->checked_out ) ) { - echo $row->name; - } else { - ?> - - - name; ?> - - - - - orderUpIcon($i, ($row->catid == @$rows[$i-1]->catid), 'orderup', 'Move Up', $ordering ); ?> - orderDownIcon($i, $n, ($row->catid == @$rows[$i+1]->catid), 'orderdown', 'Move Down', $ordering ); ?> - - class="text_area" style="text-align: center" /> - - - catname;?> - - numarticles;?> - - cache_time;?> - - id; ?> -
    - - - - - -
    - - get('gid') == 25 ) { - $visible = 1; - } - HTML_newsfeeds::writableCell( JPATH_SITE.DS.'cache', 0, ''. JText::_('Cache Directory') .' ', $visible ); - ?> -
    -
    - - - - - - - -
    - - - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - -
    - - - -
    - : - - -
    - - - -
    - - - -
    - - - -
    - - - - - -
    - - - -
    - - - -
    -
    -
    -
    -
    - - - - - - -
    - '. JText::_( 'Writable' ) .''; - $unwriteable = ''. JText::_( 'Unwritable' ) .''; - - echo ''; - echo ''; - echo $text; - if ( $visible ) { - echo $folder . '/'; - } - echo ''; - echo ''; - if ( $relative ) { - echo is_writable( "../$folder" ) ? $writeable : $unwriteable; - } else { - echo is_writable( "$folder" ) ? $writeable : $unwriteable; - } - echo ''; - echo ''; - } + +
    + + + + + + +
    + : + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + id ); + + $checked = JHTML::_('grid.checkedout', $row, $i ); + $published = JHTML::_('grid.published', $row, $i ); + + $row->cat_link = JRoute::_( 'index.php?option=com_categories§ion=com_newsfeeds&task=edit&cid[]='. $row->catid ); + ?> + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + +
    + getListFooter(); ?> +
    + getRowOffset( $i ); ?> + + + + get ('id'), $row->checked_out ) ) { + echo $row->name; + } else { + ?> + + + name; ?> + + + + + orderUpIcon($i, ($row->catid == @$rows[$i-1]->catid), 'orderup', 'Move Up', $ordering ); ?> + orderDownIcon($i, $n, ($row->catid == @$rows[$i+1]->catid), 'orderdown', 'Move Down', $ordering ); ?> + + class="text_area" style="text-align: center" /> + + + catname;?> + + numarticles;?> + + cache_time;?> + + id; ?> +
    + + + + + +
    + + get('gid') == 25 ) { + $visible = 1; + } + HTML_newsfeeds::writableCell( JPATH_SITE.DS.'cache', 0, ''. JText::_('Cache Directory') .' ', $visible ); + ?> +
    +
    + + + + + + + +
    + + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + +
    + + + +
    + : + + +
    + + + +
    + + + +
    + + + +
    + + + + + +
    + + + +
    + + + +
    +
    +
    +
    +
    + + + + + + +
    + '. JText::_( 'Writable' ) .''; + $unwriteable = ''. JText::_( 'Unwritable' ) .''; + + echo ''; + echo ''; + echo $text; + if ( $visible ) { + echo $folder . '/'; + } + echo ''; + echo ''; + if ( $relative ) { + echo is_writable( "../$folder" ) ? $writeable : $unwriteable; + } else { + echo is_writable( "$folder" ) ? $writeable : $unwriteable; + } + echo ''; + echo ''; + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_newsfeeds/admin.newsfeeds.php b/oss/joomla/trunk/administrator/components/com_newsfeeds/admin.newsfeeds.php index e17327d5..ccb01ca6 100644 --- a/oss/joomla/trunk/administrator/components/com_newsfeeds/admin.newsfeeds.php +++ b/oss/joomla/trunk/administrator/components/com_newsfeeds/admin.newsfeeds.php @@ -1,464 +1,467 @@ -authorize( 'com_newsfeeds', 'manage' )) { - $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); -} - -// Set the table directory -JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_newsfeeds'.DS.'tables'); - -require_once( JApplicationHelper::getPath( 'admin_html' ) ); - -$task = JRequest::getCmd('task'); - -switch ($task) { - - case 'add' : - editNewsFeed(false); - break; - case 'edit': - editNewsFeed(true); - break; - - case 'save': - case 'apply': - saveNewsFeed( ); - break; - - case 'publish': - publishNewsFeeds( ); - break; - - case 'unpublish': - unPublishNewsFeeds( ); - break; - - case 'remove': - removeNewsFeeds( ); - break; - - case 'cancel': - cancelNewsFeed( ); - break; - - case 'orderup': - moveUpNewsFeed( ); - break; - - case 'orderdown': - moveDownNewsFeed( ); - break; - - case 'saveorder': - saveOrder( ); - break; - - default: - showNewsFeeds( ); - break; -} - -/** -* List the records -*/ -function showNewsFeeds( ) -{ - global $mainframe, $option; - - $db =& JFactory::getDBO(); - - $filter_order = $mainframe->getUserStateFromRequest( "$option.filter_order", 'filter_order', 'a.ordering', 'cmd' ); - $filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.filter_order_Dir", 'filter_order_Dir', '', 'word' ); - $filter_state = $mainframe->getUserStateFromRequest( "$option.filter_state", 'filter_state', '', 'word' ); - $filter_catid = $mainframe->getUserStateFromRequest( "$option.filter_catid", 'filter_catid', 0, 'int' ); - $search = $mainframe->getUserStateFromRequest( "$option.search", 'search', '', 'string' ); - $search = JString::strtolower( $search ); - - $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); - $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); - - $where = array(); - if ( $filter_catid ) { - $where[] = 'a.catid = '.(int) $filter_catid; - } - if ($search) { - $where[] = 'LOWER(a.name) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); - } - if ( $filter_state ) { - if ( $filter_state == 'P' ) { - $where[] = 'a.published = 1'; - } else if ($filter_state == 'U' ) { - $where[] = 'a.published = 0'; - } - } - - $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); - if ($filter_order == 'a.ordering'){ - $orderby = ' ORDER BY catname, a.ordering'; - } else { - $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', catname, a.ordering'; - } - - // get the total number of records - $query = 'SELECT COUNT(*) ' - . ' FROM #__newsfeeds AS a' - . $where - ; - $db->setQuery( $query ); - $total = $db->loadResult(); - - jimport('joomla.html.pagination'); - $pageNav = new JPagination( $total, $limitstart, $limit ); - - // get the subset (based on limits) of required records - $query = 'SELECT a.*, c.title AS catname, u.name AS editor' - . ' FROM #__newsfeeds AS a' - . ' LEFT JOIN #__categories AS c ON c.id = a.catid' - . ' LEFT JOIN #__users AS u ON u.id = a.checked_out' - . $where - . $orderby - ; - $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); - - $rows = $db->loadObjectList(); - if ($db->getErrorNum()) { - echo $db->stderr(); - return false; - } - - // build list of categories - $javascript = 'onchange="document.adminForm.submit();"'; - $lists['catid'] = JHTML::_('list.category', 'filter_catid', 'com_newsfeeds', $filter_catid, $javascript ); - - // state filter - $lists['state'] = JHTML::_('grid.state', $filter_state ); - - // table ordering - $lists['order_Dir'] = $filter_order_Dir; - $lists['order'] = $filter_order; - - // search filter - $lists['search']= $search; - - HTML_newsfeeds::showNewsFeeds( $rows, $lists, $pageNav, $option ); -} - -/** -* Creates a new or edits and existing user record -*/ -function editNewsFeed($edit) -{ - $db =& JFactory::getDBO(); - $user =& JFactory::getUser(); - - $catid = JRequest::getVar( 'catid', 0, '', 'int' ); - $cid = JRequest::getVar( 'cid', array(0), '', 'array' ); - $option = JRequest::getCmd( 'option' ); - JArrayHelper::toInteger($cid, array(0)); - - $row =& JTable::getInstance( 'newsfeed', 'Table' ); - // load the row from the db table - if($edit) - $row->load( $cid[0] ); - - if ($edit) { - // do stuff for existing records - $row->checkout( $user->get('id') ); - } else { - // do stuff for new records - $row->ordering = 0; - $row->numarticles = 5; - $row->cache_time = 3600; - $row->published = 1; - } - - // build the html select list for ordering - $query = 'SELECT a.ordering AS value, a.name AS text' - . ' FROM #__newsfeeds AS a' - . ' ORDER BY a.ordering' - ; - - if($edit) - $lists['ordering'] = JHTML::_('list.specificordering', $row, $cid[0], $query ); - else - $lists['ordering'] = JHTML::_('list.specificordering', $row, '', $query ); - - // build list of categories - $lists['category'] = JHTML::_('list.category', 'catid', $option, intval( $row->catid ) ); - // build the html select list - $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $row->published ); - $rtl[] = JHTML::_('select.option', '0', JText::_( 'Site Language Direction' ) ); - $rtl[] = JHTML::_('select.option', '1', JText::_( 'Left to Right Direction' ) ); - $rtl[] = JHTML::_('select.option', '2', JText::_( 'Right to Left Direction' ) ); - $lists['rtl'] = JHTML::_('select.genericlist', $rtl, 'rtl', 'class="inputbox"', 'value', 'text', intval( $row->rtl ) ); - HTML_newsfeeds::editNewsFeed( $row, $lists, $option ); -} - -/** -* Saves the record from an edit form submit -*/ -function saveNewsFeed( ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $task = JRequest::getVar( 'task'); - - $row =& JTable::getInstance( 'newsfeed', 'Table' ); - if (!$row->bind(JRequest::get('post'))) { - JError::raiseError(500, $row->getError() ); - } - - // Sets rtl value when rtl checkbox ticked - $isRtl = JRequest::getInt('rtl'); - - - // pre-save checks - if (!$row->check()) { - JError::raiseError(500, $row->getError() ); - } - - // if new item, order last in appropriate group - if (!$row->id) { - $where = "catid = " . (int) $row->catid; - $row->ordering = $row->getNextOrder( $where ); - } - - // save the changes - if (!$row->store()) { - JError::raiseError(500, $row->getError() ); - } - $row->checkin(); - - switch ($task) - { - case 'apply': - $msg = JText::_( 'Changes to Newsfeed saved' ); - $link = 'index.php?option=com_newsfeeds&task=edit&cid[]='. $row->id ; - break; - - case 'save': - default: - $msg = JText::_( 'Newsfeed saved' ); - $link = 'index.php?option=com_newsfeeds'; - break; - } - - $mainframe->redirect( $link, $msg ); -} - -/** -* Publishes one or more modules -*/ -function publishNewsFeeds( ) { - changePublishNewsFeeds( 1 ); -} - -/** -* Unpublishes one or more modules -*/ -function unPublishNewsFeeds( ) { - changePublishNewsFeeds( 0 ); -} - -/** -* Publishes or Unpublishes one or more modules -* @param integer 0 if unpublishing, 1 if publishing -*/ -function changePublishNewsFeeds( $publish ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $user =& JFactory::getUser(); - - $cid = JRequest::getVar('cid', array(), '', 'array'); - $option = JRequest::getCmd('option'); - JArrayHelper::toInteger($cid); - - if (empty( $cid )) { - JError::raiseWarning( 500, 'No items selected' ); - $mainframe->redirect( 'index.php?option='. $option ); - } - - $cids = implode( ',', $cid ); - - $query = 'UPDATE #__newsfeeds' - . ' SET published = '.(int) $publish - . ' WHERE id IN ( '. $cids .' )' - . ' AND ( checked_out = 0 OR ( checked_out = '.(int) $user->get('id') .' ) )' - ; - $db->setQuery( $query ); - if (!$db->query()) { - JError::raiseError(500, $db->getErrorMsg() ); - } - - if (count( $cid ) == 1) { - $row =& JTable::getInstance( 'newsfeed', 'Table' ); - $row->checkin( $cid[0] ); - } - - $mainframe->redirect( 'index.php?option='. $option ); -} - -/** -* Removes records -*/ -function removeNewsFeeds( ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $cid = JRequest::getVar('cid', array(), '', 'array'); - $option = JRequest::getCmd('option'); - JArrayHelper::toInteger($cid); - - if (count($cid) < 1) { - JError::raiseWarning(500, JText::_( 'Select an item to delete', true ) ); - $mainframe->redirect( 'index.php?option='. $option ); - } - - $cids = implode( ',', $cid ); - $query = 'DELETE FROM #__newsfeeds' - . ' WHERE id IN ( '. $cids .' )' - ; - $db->setQuery( $query ); - if (!$db->query()) { - echo "\n"; - } - - $mainframe->redirect( 'index.php?option='. $option ); -} - -/** -* Cancels an edit operation -*/ -function cancelNewsFeed( ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $option = JRequest::getCmd('option'); - - $row =& JTable::getInstance( 'newsfeed', 'Table' ); - $row->bind(JRequest::get('post')); - $row->checkin(); - $mainframe->redirect( 'index.php?option='. $option ); -} - -/** -* Moves the record up one position -*/ -function moveUpNewsFeed( ) { - orderNewsFeed( -1 ); -} - -/** -* Moves the record down one position -*/ -function moveDownNewsFeed( ) { - orderNewsFeed( 1 ); -} - -/** -* Moves the order of a record -* @param integer The direction to reorder, +1 down, -1 up -*/ -function orderNewsFeed( $inc ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $cid = JRequest::getVar('cid', array(0), '', 'array'); - $option = JRequest::getCmd('option'); - JArrayHelper::toInteger($cid, array(0)); - - $limit = JRequest::getVar( 'limit', 0, '', 'int' ); - $limitstart = JRequest::getVar( 'limitstart', 0, '', 'int' ); - $catid = JRequest::getVar( 'catid', 0, '', 'int' ); - - $row =& JTable::getInstance( 'newsfeed', 'Table' ); - $row->load( $cid[0] ); - $row->move( $inc, 'catid = '.(int) $row->catid.' AND published != 0' ); - - $mainframe->redirect( 'index.php?option='. $option ); -} - -/** -* Saves user reordering entry -*/ -function saveOrder( ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - JArrayHelper::toInteger($cid); - - $total = count( $cid ); - $order = JRequest::getVar( 'order', array(0), 'post', 'array' ); - JArrayHelper::toInteger($order, array(0)); - - $row =& JTable::getInstance( 'newsfeed', 'Table' ); - $groupings = array(); - - // update ordering values - for( $i=0; $i < $total; $i++ ) { - $row->load( (int) $cid[$i] ); - // track categories - $groupings[] = $row->catid; - - if ($row->ordering != $order[$i]) { - $row->ordering = $order[$i]; - if (!$row->store()) { - JError::raiseError(500, $db->getErrorMsg() ); - } - } - } - - // execute updateOrder for each parent group - $groupings = array_unique( $groupings ); - foreach ($groupings as $group){ - $row->reorder('catid = '.(int) $group); - } - - $msg = JText::_( 'New ordering saved' ); - $mainframe->redirect( 'index.php?option=com_newsfeeds', $msg ); -} +authorize( 'com_newsfeeds', 'manage' )) { + $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); +} + +// Set the table directory +JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_newsfeeds'.DS.'tables'); + +require_once( JApplicationHelper::getPath( 'admin_html' ) ); + +$task = JRequest::getCmd('task'); + +switch ($task) { + + case 'add' : + editNewsFeed(false); + break; + case 'edit': + editNewsFeed(true); + break; + + case 'save': + case 'apply': + saveNewsFeed( ); + break; + + case 'publish': + publishNewsFeeds( ); + break; + + case 'unpublish': + unPublishNewsFeeds( ); + break; + + case 'remove': + removeNewsFeeds( ); + break; + + case 'cancel': + cancelNewsFeed( ); + break; + + case 'orderup': + moveUpNewsFeed( ); + break; + + case 'orderdown': + moveDownNewsFeed( ); + break; + + case 'saveorder': + saveOrder( ); + break; + + default: + showNewsFeeds( ); + break; +} + +/** +* List the records +*/ +function showNewsFeeds( ) +{ + global $mainframe, $option; + + $db =& JFactory::getDBO(); + + $filter_order = $mainframe->getUserStateFromRequest( "$option.filter_order", 'filter_order', 'a.ordering', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.filter_order_Dir", 'filter_order_Dir', '', 'word' ); + $filter_state = $mainframe->getUserStateFromRequest( "$option.filter_state", 'filter_state', '', 'word' ); + $filter_catid = $mainframe->getUserStateFromRequest( "$option.filter_catid", 'filter_catid', 0, 'int' ); + $search = $mainframe->getUserStateFromRequest( "$option.search", 'search', '', 'string' ); + if (strpos($search, '"') !== false) { + $search = str_replace(array('=', '<'), '', $search); + } + $search = JString::strtolower($search); + + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); + + $where = array(); + if ( $filter_catid ) { + $where[] = 'a.catid = '.(int) $filter_catid; + } + if ($search) { + $where[] = 'LOWER(a.name) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + if ( $filter_state ) { + if ( $filter_state == 'P' ) { + $where[] = 'a.published = 1'; + } else if ($filter_state == 'U' ) { + $where[] = 'a.published = 0'; + } + } + + $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); + if ($filter_order == 'a.ordering'){ + $orderby = ' ORDER BY catname, a.ordering'; + } else { + $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', catname, a.ordering'; + } + + // get the total number of records + $query = 'SELECT COUNT(*) ' + . ' FROM #__newsfeeds AS a' + . $where + ; + $db->setQuery( $query ); + $total = $db->loadResult(); + + jimport('joomla.html.pagination'); + $pageNav = new JPagination( $total, $limitstart, $limit ); + + // get the subset (based on limits) of required records + $query = 'SELECT a.*, c.title AS catname, u.name AS editor' + . ' FROM #__newsfeeds AS a' + . ' LEFT JOIN #__categories AS c ON c.id = a.catid' + . ' LEFT JOIN #__users AS u ON u.id = a.checked_out' + . $where + . $orderby + ; + $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); + + $rows = $db->loadObjectList(); + if ($db->getErrorNum()) { + echo $db->stderr(); + return false; + } + + // build list of categories + $javascript = 'onchange="document.adminForm.submit();"'; + $lists['catid'] = JHTML::_('list.category', 'filter_catid', 'com_newsfeeds', $filter_catid, $javascript ); + + // state filter + $lists['state'] = JHTML::_('grid.state', $filter_state ); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search']= $search; + + HTML_newsfeeds::showNewsFeeds( $rows, $lists, $pageNav, $option ); +} + +/** +* Creates a new or edits and existing user record +*/ +function editNewsFeed($edit) +{ + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + + $catid = JRequest::getVar( 'catid', 0, '', 'int' ); + $cid = JRequest::getVar( 'cid', array(0), '', 'array' ); + $option = JRequest::getCmd( 'option' ); + JArrayHelper::toInteger($cid, array(0)); + + $row =& JTable::getInstance( 'newsfeed', 'Table' ); + // load the row from the db table + if($edit) + $row->load( $cid[0] ); + + if ($edit) { + // do stuff for existing records + $row->checkout( $user->get('id') ); + } else { + // do stuff for new records + $row->ordering = 0; + $row->numarticles = 5; + $row->cache_time = 3600; + $row->published = 1; + } + + // build the html select list for ordering + $query = 'SELECT a.ordering AS value, a.name AS text' + . ' FROM #__newsfeeds AS a' + . ' ORDER BY a.ordering' + ; + + if($edit) + $lists['ordering'] = JHTML::_('list.specificordering', $row, $cid[0], $query ); + else + $lists['ordering'] = JHTML::_('list.specificordering', $row, '', $query ); + + // build list of categories + $lists['category'] = JHTML::_('list.category', 'catid', $option, intval( $row->catid ) ); + // build the html select list + $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $row->published ); + $rtl[] = JHTML::_('select.option', '0', JText::_( 'Site Language Direction' ) ); + $rtl[] = JHTML::_('select.option', '1', JText::_( 'Left to Right Direction' ) ); + $rtl[] = JHTML::_('select.option', '2', JText::_( 'Right to Left Direction' ) ); + $lists['rtl'] = JHTML::_('select.genericlist', $rtl, 'rtl', 'class="inputbox"', 'value', 'text', intval( $row->rtl ) ); + HTML_newsfeeds::editNewsFeed( $row, $lists, $option ); +} + +/** +* Saves the record from an edit form submit +*/ +function saveNewsFeed( ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $task = JRequest::getVar( 'task'); + + $row =& JTable::getInstance( 'newsfeed', 'Table' ); + if (!$row->bind(JRequest::get('post'))) { + JError::raiseError(500, $row->getError() ); + } + + // Sets rtl value when rtl checkbox ticked + $isRtl = JRequest::getInt('rtl'); + + + // pre-save checks + if (!$row->check()) { + JError::raiseError(500, $row->getError() ); + } + + // if new item, order last in appropriate group + if (!$row->id) { + $where = "catid = " . (int) $row->catid; + $row->ordering = $row->getNextOrder( $where ); + } + + // save the changes + if (!$row->store()) { + JError::raiseError(500, $row->getError() ); + } + $row->checkin(); + + switch ($task) + { + case 'apply': + $msg = JText::_( 'Changes to Newsfeed saved' ); + $link = 'index.php?option=com_newsfeeds&task=edit&cid[]='. $row->id ; + break; + + case 'save': + default: + $msg = JText::_( 'Newsfeed saved' ); + $link = 'index.php?option=com_newsfeeds'; + break; + } + + $mainframe->redirect( $link, $msg ); +} + +/** +* Publishes one or more modules +*/ +function publishNewsFeeds( ) { + changePublishNewsFeeds( 1 ); +} + +/** +* Unpublishes one or more modules +*/ +function unPublishNewsFeeds( ) { + changePublishNewsFeeds( 0 ); +} + +/** +* Publishes or Unpublishes one or more modules +* @param integer 0 if unpublishing, 1 if publishing +*/ +function changePublishNewsFeeds( $publish ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + + $cid = JRequest::getVar('cid', array(), '', 'array'); + $option = JRequest::getCmd('option'); + JArrayHelper::toInteger($cid); + + if (empty( $cid )) { + JError::raiseWarning( 500, 'No items selected' ); + $mainframe->redirect( 'index.php?option='. $option ); + } + + $cids = implode( ',', $cid ); + + $query = 'UPDATE #__newsfeeds' + . ' SET published = '.(int) $publish + . ' WHERE id IN ( '. $cids .' )' + . ' AND ( checked_out = 0 OR ( checked_out = '.(int) $user->get('id') .' ) )' + ; + $db->setQuery( $query ); + if (!$db->query()) { + JError::raiseError(500, $db->getErrorMsg() ); + } + + if (count( $cid ) == 1) { + $row =& JTable::getInstance( 'newsfeed', 'Table' ); + $row->checkin( $cid[0] ); + } + + $mainframe->redirect( 'index.php?option='. $option ); +} + +/** +* Removes records +*/ +function removeNewsFeeds( ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $cid = JRequest::getVar('cid', array(), '', 'array'); + $option = JRequest::getCmd('option'); + JArrayHelper::toInteger($cid); + + if (count($cid) < 1) { + JError::raiseWarning(500, JText::_( 'Select an item to delete', true ) ); + $mainframe->redirect( 'index.php?option='. $option ); + } + + $cids = implode( ',', $cid ); + $query = 'DELETE FROM #__newsfeeds' + . ' WHERE id IN ( '. $cids .' )' + ; + $db->setQuery( $query ); + if (!$db->query()) { + echo "\n"; + } + + $mainframe->redirect( 'index.php?option='. $option ); +} + +/** +* Cancels an edit operation +*/ +function cancelNewsFeed( ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $option = JRequest::getCmd('option'); + + $row =& JTable::getInstance( 'newsfeed', 'Table' ); + $row->bind(JRequest::get('post')); + $row->checkin(); + $mainframe->redirect( 'index.php?option='. $option ); +} + +/** +* Moves the record up one position +*/ +function moveUpNewsFeed( ) { + orderNewsFeed( -1 ); +} + +/** +* Moves the record down one position +*/ +function moveDownNewsFeed( ) { + orderNewsFeed( 1 ); +} + +/** +* Moves the order of a record +* @param integer The direction to reorder, +1 down, -1 up +*/ +function orderNewsFeed( $inc ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $cid = JRequest::getVar('cid', array(0), '', 'array'); + $option = JRequest::getCmd('option'); + JArrayHelper::toInteger($cid, array(0)); + + $limit = JRequest::getVar( 'limit', 0, '', 'int' ); + $limitstart = JRequest::getVar( 'limitstart', 0, '', 'int' ); + $catid = JRequest::getVar( 'catid', 0, '', 'int' ); + + $row =& JTable::getInstance( 'newsfeed', 'Table' ); + $row->load( $cid[0] ); + $row->move( $inc, 'catid = '.(int) $row->catid.' AND published != 0' ); + + $mainframe->redirect( 'index.php?option='. $option ); +} + +/** +* Saves user reordering entry +*/ +function saveOrder( ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + $total = count( $cid ); + $order = JRequest::getVar( 'order', array(0), 'post', 'array' ); + JArrayHelper::toInteger($order, array(0)); + + $row =& JTable::getInstance( 'newsfeed', 'Table' ); + $groupings = array(); + + // update ordering values + for( $i=0; $i < $total; $i++ ) { + $row->load( (int) $cid[$i] ); + // track categories + $groupings[] = $row->catid; + + if ($row->ordering != $order[$i]) { + $row->ordering = $order[$i]; + if (!$row->store()) { + JError::raiseError(500, $db->getErrorMsg() ); + } + } + } + + // execute updateOrder for each parent group + $groupings = array_unique( $groupings ); + foreach ($groupings as $group){ + $row->reorder('catid = '.(int) $group); + } + + $msg = JText::_( 'New ordering saved' ); + $mainframe->redirect( 'index.php?option=com_newsfeeds', $msg ); +} diff --git a/oss/joomla/trunk/administrator/components/com_newsfeeds/elements/newsfeed.php b/oss/joomla/trunk/administrator/components/com_newsfeeds/elements/newsfeed.php index 69dfb6bf..bbb88a40 100644 --- a/oss/joomla/trunk/administrator/components/com_newsfeeds/elements/newsfeed.php +++ b/oss/joomla/trunk/administrator/components/com_newsfeeds/elements/newsfeed.php @@ -1,59 +1,59 @@ -setQuery( $query ); - $options = $db->loadObjectList( ); - - $n = count( $options ); - for ($i = 0; $i < $n; $i++) - { - $options[$i]->text = $options[$i]->title . '-' . $options[$i]->name; - } - - array_unshift($options, JHTML::_('select.option', '0', '- '.JText::_('Select Feed').' -', 'id', 'text')); - - return JHTML::_('select.genericlist', $options, ''.$control_name.'['.$name.']', 'class="inputbox"', 'id', 'text', $value, $control_name.$name ); - } -} +setQuery( $query ); + $options = $db->loadObjectList( ); + + $n = count( $options ); + for ($i = 0; $i < $n; $i++) + { + $options[$i]->text = $options[$i]->title . '-' . $options[$i]->name; + } + + array_unshift($options, JHTML::_('select.option', '0', '- '.JText::_('Select Feed').' -', 'id', 'text')); + + return JHTML::_('select.genericlist', $options, ''.$control_name.'['.$name.']', 'class="inputbox"', 'id', 'text', $value, $control_name.$name ); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_newsfeeds/newsfeeds.xml b/oss/joomla/trunk/administrator/components/com_newsfeeds/newsfeeds.xml index 2ec4c241..5f9dc55e 100644 --- a/oss/joomla/trunk/administrator/components/com_newsfeeds/newsfeeds.xml +++ b/oss/joomla/trunk/administrator/components/com_newsfeeds/newsfeeds.xml @@ -1,12 +1,12 @@ - - - Newsfeeds - Joomla! Project - April 2006 - (C) 2005 - 2008 Open Source Matters. All rights reserved. - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - admin@joomla.org - www.joomla.org - 1.5.0 - This component manages RSS/RDF newsfeeds - + + + Newsfeeds + Joomla! Project + April 2006 + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + This component manages RSS/RDF newsfeeds + diff --git a/oss/joomla/trunk/administrator/components/com_newsfeeds/tables/newsfeed.php b/oss/joomla/trunk/administrator/components/com_newsfeeds/tables/newsfeed.php index 36d9bf2e..fd581f25 100644 --- a/oss/joomla/trunk/administrator/components/com_newsfeeds/tables/newsfeed.php +++ b/oss/joomla/trunk/administrator/components/com_newsfeeds/tables/newsfeed.php @@ -1,79 +1,79 @@ -alias)) { - $this->alias = $this->name; - } - $this->alias = JFilterOutput::stringURLSafe($this->alias); - if(trim(str_replace('-','',$this->alias)) == '') { - $datenow =& JFactory::getDate(); - $this->alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S"); - } - - return true; - } -} +alias)) { + $this->alias = $this->name; + } + $this->alias = JFilterOutput::stringURLSafe($this->alias); + if(trim(str_replace('-','',$this->alias)) == '') { + $datenow =& JFactory::getDate(); + $this->alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S"); + } + + return true; + } +} diff --git a/oss/joomla/trunk/administrator/components/com_newsfeeds/toolbar.newsfeeds.html.php b/oss/joomla/trunk/administrator/components/com_newsfeeds/toolbar.newsfeeds.html.php index 9cdad80d..f2628857 100644 --- a/oss/joomla/trunk/administrator/components/com_newsfeeds/toolbar.newsfeeds.html.php +++ b/oss/joomla/trunk/administrator/components/com_newsfeeds/toolbar.newsfeeds.html.php @@ -1,54 +1,54 @@ -[ '. $text.' ]' ); - JToolBarHelper::save(); - JToolBarHelper::apply(); - if ($edit) { - // for existing items the button is renamed `close` - JToolBarHelper::cancel( 'cancel', 'Close' ); - } else { - JToolBarHelper::cancel(); - } - JToolBarHelper::help( 'screen.newsfeeds.edit' ); - } +[ '. $text.' ]' ); + JToolBarHelper::save(); + JToolBarHelper::apply(); + if ($edit) { + // for existing items the button is renamed `close` + JToolBarHelper::cancel( 'cancel', 'Close' ); + } else { + JToolBarHelper::cancel(); + } + JToolBarHelper::help( 'screen.newsfeeds.edit' ); + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_newsfeeds/toolbar.newsfeeds.php b/oss/joomla/trunk/administrator/components/com_newsfeeds/toolbar.newsfeeds.php index a9dada68..06ebb946 100644 --- a/oss/joomla/trunk/administrator/components/com_newsfeeds/toolbar.newsfeeds.php +++ b/oss/joomla/trunk/administrator/components/com_newsfeeds/toolbar.newsfeeds.php @@ -1,32 +1,32 @@ -registerTask( 'apply', 'save'); - $this->registerTask( 'unpublish', 'publish'); - $this->registerTask( 'edit' , 'display' ); - $this->registerTask( 'add' , 'display' ); - $this->registerTask( 'orderup' , 'order' ); - $this->registerTask( 'orderdown' , 'order' ); - - $this->registerTask( 'accesspublic' , 'access' ); - $this->registerTask( 'accessregistered' , 'access' ); - $this->registerTask( 'accessspecial' , 'access' ); - - } - - function display( ) - { - switch($this->getTask()) - { - case 'add' : - case 'edit' : - { - JRequest::setVar( 'hidemainmenu', 1 ); - JRequest::setVar( 'layout', 'form' ); - JRequest::setVar( 'view', 'plugin' ); - } break; - } - - parent::display(); - } - - function save() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $row =& JTable::getInstance('plugin'); - $task = $this->getTask(); - - $client = JRequest::getWord( 'filter_client', 'site' ); - - if (!$row->bind(JRequest::get('post'))) { - JError::raiseError(500, $row->getError() ); - } - if (!$row->check()) { - JError::raiseError(500, $row->getError() ); - } - if (!$row->store()) { - JError::raiseError(500, $row->getError() ); - } - $row->checkin(); - - if ($client == 'admin') { - $where = "client_id=1"; - } else { - $where = "client_id=0"; - } - - $row->reorder( 'folder = '.$db->Quote($row->folder).' AND ordering > -10000 AND ordering < 10000 AND ( '.$where.' )' ); - - switch ( $task ) - { - case 'apply': - $msg = JText::sprintf( 'Successfully Saved changes to Plugin', $row->name ); - $this->setRedirect( 'index.php?option=com_plugins&view=plugin&client='. $client .'&task=edit&cid[]='. $row->id, $msg ); - break; - - case 'save': - default: - $msg = JText::sprintf( 'Successfully Saved Plugin', $row->name ); - $this->setRedirect( 'index.php?option=com_plugins&client='. $client, $msg ); - break; - } - } - - function publish( ) - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $user =& JFactory::getUser(); - $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); - JArrayHelper::toInteger($cid, array(0)); - $publish = ( $this->getTask() == 'publish' ? 1 : 0 ); - $client = JRequest::getWord( 'filter_client', 'site' ); - - if (count( $cid ) < 1) { - $action = $publish ? JText::_( 'publish' ) : JText::_( 'unpublish' ); - JError::raiseError(500, JText::_( 'Select a plugin to '.$action ) ); - } - - $cids = implode( ',', $cid ); - - $query = 'UPDATE #__plugins SET published = '.(int) $publish - . ' WHERE id IN ( '.$cids.' )' - . ' AND ( checked_out = 0 OR ( checked_out = '.(int) $user->get('id').' ))' - ; - $db->setQuery( $query ); - if (!$db->query()) { - JError::raiseError(500, $db->getErrorMsg() ); - } - - if (count( $cid ) == 1) { - $row =& JTable::getInstance('plugin'); - $row->checkin( $cid[0] ); - } - - $this->setRedirect( 'index.php?option=com_plugins&client='. $client ); - } - - function cancel( ) - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $client = JRequest::getWord( 'filter_client', 'site' ); - - $db =& JFactory::getDBO(); - $row =& JTable::getInstance('plugin'); - $row->bind(JRequest::get('post')); - $row->checkin(); - - $this->setRedirect( JRoute::_( 'index.php?option=com_plugins&client='. $client, false ) ); - } - - function order( ) - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - - $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); - JArrayHelper::toInteger($cid, array(0)); - - $uid = $cid[0]; - $inc = ( $this->getTask() == 'orderup' ? -1 : 1 ); - $client = JRequest::getWord( 'filter_client', 'site' ); - - - // Currently Unsupported - if ($client == 'admin') { - $where = "client_id = 1"; - } else { - $where = "client_id = 0"; - } - $row =& JTable::getInstance('plugin'); - $row->load( $uid ); - $row->move( $inc, 'folder='.$db->Quote($row->folder).' AND ordering > -10000 AND ordering < 10000 AND ('.$where.')' ); - - $this->setRedirect( 'index.php?option=com_plugins' ); - } - - function access( ) - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); - JArrayHelper::toInteger($cid, array(0)); - - $uid = $cid[0]; - $access = $this->getTask(); - - $db =& JFactory::getDBO(); - switch ( $access ) - { - case 'accesspublic': - $access = 0; - break; - - case 'accessregistered': - $access = 1; - break; - - case 'accessspecial': - $access = 2; - break; - } - - $row =& JTable::getInstance('plugin'); - $row->load( $uid ); - $row->access = $access; - - if ( !$row->check() ) { - return $row->getError(); - } - if ( !$row->store() ) { - return $row->getError(); - } - - $this->setRedirect( 'index.php?option=com_plugins' ); - } - - function saveorder( ) - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); - JArrayHelper::toInteger($cid, array(0)); - - $db =& JFactory::getDBO(); - $total = count( $cid ); - $order = JRequest::getVar( 'order', array(0), 'post', 'array' ); - JArrayHelper::toInteger($order, array(0)); - - $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); - JArrayHelper::toInteger($cid, array(0)); - - $row =& JTable::getInstance('plugin'); - $conditions = array(); - - // update ordering values - for ( $i=0; $i < $total; $i++ ) - { - $row->load( (int) $cid[$i] ); - if ($row->ordering != $order[$i]) - { - $row->ordering = $order[$i]; - if (!$row->store()) { - JError::raiseError(500, $db->getErrorMsg() ); - } - // remember to updateOrder this group - $condition = 'folder = '.$db->Quote($row->folder).' AND ordering > -10000 AND ordering < 10000 AND client_id = ' . (int) $row->client_id; - $found = false; - foreach ( $conditions as $cond ) - { - if ($cond[1]==$condition) { - $found = true; - break; - } - } - if (!$found) $conditions[] = array($row->id, $condition); - } - } - - // execute updateOrder for each group - foreach ( $conditions as $cond ) { - $row->load( $cond[0] ); - $row->reorder( $cond[1] ); - } - - $msg = JText::_( 'New ordering saved' ); - $this->setRedirect( 'index.php?option=com_plugins', $msg ); - } +registerTask( 'apply', 'save'); + $this->registerTask( 'unpublish', 'publish'); + $this->registerTask( 'edit' , 'display' ); + $this->registerTask( 'add' , 'display' ); + $this->registerTask( 'orderup' , 'order' ); + $this->registerTask( 'orderdown' , 'order' ); + + $this->registerTask( 'accesspublic' , 'access' ); + $this->registerTask( 'accessregistered' , 'access' ); + $this->registerTask( 'accessspecial' , 'access' ); + + } + + function display( ) + { + switch($this->getTask()) + { + case 'add' : + case 'edit' : + { + JRequest::setVar( 'hidemainmenu', 1 ); + JRequest::setVar( 'layout', 'form' ); + JRequest::setVar( 'view', 'plugin' ); + } break; + } + + parent::display(); + } + + function save() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $row =& JTable::getInstance('plugin'); + $task = $this->getTask(); + + $client = JRequest::getWord( 'filter_client', 'site' ); + + if (!$row->bind(JRequest::get('post'))) { + JError::raiseError(500, $row->getError() ); + } + if (!$row->check()) { + JError::raiseError(500, $row->getError() ); + } + if (!$row->store()) { + JError::raiseError(500, $row->getError() ); + } + $row->checkin(); + + if ($client == 'admin') { + $where = "client_id=1"; + } else { + $where = "client_id=0"; + } + + $row->reorder( 'folder = '.$db->Quote($row->folder).' AND ordering > -10000 AND ordering < 10000 AND ( '.$where.' )' ); + + switch ( $task ) + { + case 'apply': + $msg = JText::sprintf( 'Successfully Saved changes to Plugin', $row->name ); + $this->setRedirect( 'index.php?option=com_plugins&view=plugin&client='. $client .'&task=edit&cid[]='. $row->id, $msg ); + break; + + case 'save': + default: + $msg = JText::sprintf( 'Successfully Saved Plugin', $row->name ); + $this->setRedirect( 'index.php?option=com_plugins&client='. $client, $msg ); + break; + } + } + + function publish( ) + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); + JArrayHelper::toInteger($cid, array(0)); + $publish = ( $this->getTask() == 'publish' ? 1 : 0 ); + $client = JRequest::getWord( 'filter_client', 'site' ); + + if (count( $cid ) < 1) { + $action = $publish ? JText::_( 'publish' ) : JText::_( 'unpublish' ); + JError::raiseError(500, JText::_( 'Select a plugin to '.$action ) ); + } + + $cids = implode( ',', $cid ); + + $query = 'UPDATE #__plugins SET published = '.(int) $publish + . ' WHERE id IN ( '.$cids.' )' + . ' AND ( checked_out = 0 OR ( checked_out = '.(int) $user->get('id').' ))' + ; + $db->setQuery( $query ); + if (!$db->query()) { + JError::raiseError(500, $db->getErrorMsg() ); + } + + if (count( $cid ) == 1) { + $row =& JTable::getInstance('plugin'); + $row->checkin( $cid[0] ); + } + + $this->setRedirect( 'index.php?option=com_plugins&client='. $client ); + } + + function cancel( ) + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $client = JRequest::getWord( 'filter_client', 'site' ); + + $db =& JFactory::getDBO(); + $row =& JTable::getInstance('plugin'); + $row->bind(JRequest::get('post')); + $row->checkin(); + + $this->setRedirect( JRoute::_( 'index.php?option=com_plugins&client='. $client, false ) ); + } + + function order( ) + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + + $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); + JArrayHelper::toInteger($cid, array(0)); + + $uid = $cid[0]; + $inc = ( $this->getTask() == 'orderup' ? -1 : 1 ); + $client = JRequest::getWord( 'filter_client', 'site' ); + + + // Currently Unsupported + if ($client == 'admin') { + $where = "client_id = 1"; + } else { + $where = "client_id = 0"; + } + $row =& JTable::getInstance('plugin'); + $row->load( $uid ); + $row->move( $inc, 'folder='.$db->Quote($row->folder).' AND ordering > -10000 AND ordering < 10000 AND ('.$where.')' ); + + $this->setRedirect( 'index.php?option=com_plugins' ); + } + + function access( ) + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); + JArrayHelper::toInteger($cid, array(0)); + + $uid = $cid[0]; + $access = $this->getTask(); + + $db =& JFactory::getDBO(); + switch ( $access ) + { + case 'accesspublic': + $access = 0; + break; + + case 'accessregistered': + $access = 1; + break; + + case 'accessspecial': + $access = 2; + break; + } + + $row =& JTable::getInstance('plugin'); + $row->load( $uid ); + $row->access = $access; + + if ( !$row->check() ) { + return $row->getError(); + } + if ( !$row->store() ) { + return $row->getError(); + } + + $this->setRedirect( 'index.php?option=com_plugins' ); + } + + function saveorder( ) + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); + JArrayHelper::toInteger($cid, array(0)); + + $db =& JFactory::getDBO(); + $total = count( $cid ); + $order = JRequest::getVar( 'order', array(0), 'post', 'array' ); + JArrayHelper::toInteger($order, array(0)); + + $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); + JArrayHelper::toInteger($cid, array(0)); + + $row =& JTable::getInstance('plugin'); + $conditions = array(); + + // update ordering values + for ( $i=0; $i < $total; $i++ ) + { + $row->load( (int) $cid[$i] ); + if ($row->ordering != $order[$i]) + { + $row->ordering = $order[$i]; + if (!$row->store()) { + JError::raiseError(500, $db->getErrorMsg() ); + } + // remember to updateOrder this group + $condition = 'folder = '.$db->Quote($row->folder).' AND ordering > -10000 AND ordering < 10000 AND client_id = ' . (int) $row->client_id; + $found = false; + foreach ( $conditions as $cond ) + { + if ($cond[1]==$condition) { + $found = true; + break; + } + } + if (!$found) $conditions[] = array($row->id, $condition); + } + } + + // execute updateOrder for each group + foreach ( $conditions as $cond ) { + $row->load( $cond[0] ); + $row->reorder( $cond[1] ); + } + + $msg = JText::_( 'New ordering saved' ); + $this->setRedirect( 'index.php?option=com_plugins', $msg ); + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_plugins/plugins.php b/oss/joomla/trunk/administrator/components/com_plugins/plugins.php index a45bc5de..63ad1022 100644 --- a/oss/joomla/trunk/administrator/components/com_plugins/plugins.php +++ b/oss/joomla/trunk/administrator/components/com_plugins/plugins.php @@ -1,32 +1,32 @@ -authorize( 'com_plugins', 'manage' )) { - $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); -} - -require_once( JPATH_COMPONENT.DS.'controller.php' ); - -// Create the controller -$controller = new PluginsController( ); - -$controller->execute( JRequest::getCmd( 'task' ) ); +authorize( 'com_plugins', 'manage' )) { + $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); +} + +require_once( JPATH_COMPONENT.DS.'controller.php' ); + +// Create the controller +$controller = new PluginsController( ); + +$controller->execute( JRequest::getCmd( 'task' ) ); $controller->redirect(); \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_plugins/plugins.xml b/oss/joomla/trunk/administrator/components/com_plugins/plugins.xml index df827382..30df0d3a 100644 --- a/oss/joomla/trunk/administrator/components/com_plugins/plugins.xml +++ b/oss/joomla/trunk/administrator/components/com_plugins/plugins.xml @@ -1,12 +1,12 @@ - - - Plugin Manager - Joomla! Project - 2006 - Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - admin@joomla.org - www.joomla.org - 1.5.0 - Plugin Manager - + + + Plugin Manager + Joomla! Project + 2006 + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + Plugin Manager + diff --git a/oss/joomla/trunk/administrator/components/com_plugins/views/plugin/view.html.php b/oss/joomla/trunk/administrator/components/com_plugins/views/plugin/view.html.php index d9fe9f4d..4c167ccb 100644 --- a/oss/joomla/trunk/administrator/components/com_plugins/views/plugin/view.html.php +++ b/oss/joomla/trunk/administrator/components/com_plugins/views/plugin/view.html.php @@ -1,117 +1,117 @@ -load( $cid[0] ); - - // fail if checked out not by 'me' - - if ($row->isCheckedOut( $user->get('id') )) - { - $msg = JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The plugin' ), $row->title ); - $this->setRedirect( 'index.php?option='. $option .'&client='. $client, $msg, 'error' ); - return false; - } - - if ($client == 'admin') { - $where = "client_id='1'"; - } else { - $where = "client_id='0'"; - } - - // get list of groups - if ($row->access == 99 || $row->client_id == 1) { - $lists['access'] = 'Administrator'; - } else { - // build the html select list for the group access - $lists['access'] = JHTML::_('list.accesslevel', $row ); - } - - if ($cid[0]) - { - $row->checkout( $user->get('id') ); - - if ( $row->ordering > -10000 && $row->ordering < 10000 ) - { - // build the html select list for ordering - $query = 'SELECT ordering AS value, name AS text' - . ' FROM #__plugins' - . ' WHERE folder = '.$db->Quote($row->folder) - . ' AND published > 0' - . ' AND '. $where - . ' AND ordering > -10000' - . ' AND ordering < 10000' - . ' ORDER BY ordering' - ; - $order = JHTML::_('list.genericordering', $query ); - $lists['ordering'] = JHTML::_('select.genericlist', $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) ); - } else { - $lists['ordering'] = ''. JText::_( 'This plugin cannot be reordered' ); - } - - $lang =& JFactory::getLanguage(); - $lang->load( 'plg_' . trim( $row->folder ) . '_' . trim( $row->element ), JPATH_ADMINISTRATOR ); - - $data = JApplicationHelper::parseXMLInstallFile(JPATH_SITE . DS . 'plugins'. DS .$row->folder . DS . $row->element .'.xml'); - - $row->description = $data['description']; - - } else { - $row->folder = ''; - $row->ordering = 999; - $row->published = 1; - $row->description = ''; - } - - $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $row->published ); - - // get params definitions - $params = new JParameter( $row->params, JApplicationHelper::getPath( 'plg_xml', $row->folder.DS.$row->element ), 'plugin' ); - - $this->assignRef('lists', $lists); - $this->assignRef('plugin', $row); - $this->assignRef('params', $params); - - parent::display($tpl); - } +load( $cid[0] ); + + // fail if checked out not by 'me' + + if ($row->isCheckedOut( $user->get('id') )) + { + $msg = JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The plugin' ), $row->title ); + $this->setRedirect( 'index.php?option='. $option .'&client='. $client, $msg, 'error' ); + return false; + } + + if ($client == 'admin') { + $where = "client_id='1'"; + } else { + $where = "client_id='0'"; + } + + // get list of groups + if ($row->access == 99 || $row->client_id == 1) { + $lists['access'] = 'Administrator'; + } else { + // build the html select list for the group access + $lists['access'] = JHTML::_('list.accesslevel', $row ); + } + + if ($cid[0]) + { + $row->checkout( $user->get('id') ); + + if ( $row->ordering > -10000 && $row->ordering < 10000 ) + { + // build the html select list for ordering + $query = 'SELECT ordering AS value, name AS text' + . ' FROM #__plugins' + . ' WHERE folder = '.$db->Quote($row->folder) + . ' AND published > 0' + . ' AND '. $where + . ' AND ordering > -10000' + . ' AND ordering < 10000' + . ' ORDER BY ordering' + ; + $order = JHTML::_('list.genericordering', $query ); + $lists['ordering'] = JHTML::_('select.genericlist', $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) ); + } else { + $lists['ordering'] = ''. JText::_( 'This plugin cannot be reordered' ); + } + + $lang =& JFactory::getLanguage(); + $lang->load( 'plg_' . trim( $row->folder ) . '_' . trim( $row->element ), JPATH_ADMINISTRATOR ); + + $data = JApplicationHelper::parseXMLInstallFile(JPATH_SITE . DS . 'plugins'. DS .$row->folder . DS . $row->element .'.xml'); + + $row->description = $data['description']; + + } else { + $row->folder = ''; + $row->ordering = 999; + $row->published = 1; + $row->description = ''; + } + + $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $row->published ); + + // get params definitions + $params = new JParameter( $row->params, JApplicationHelper::getPath( 'plg_xml', $row->folder.DS.$row->element ), 'plugin' ); + + $this->assignRef('lists', $lists); + $this->assignRef('plugin', $row); + $this->assignRef('params', $params); + + parent::display($tpl); + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_plugins/views/plugins/tmpl/default.php b/oss/joomla/trunk/administrator/components/com_plugins/views/plugins/tmpl/default.php index 9b8184be..10564e37 100644 --- a/oss/joomla/trunk/administrator/components/com_plugins/views/plugins/tmpl/default.php +++ b/oss/joomla/trunk/administrator/components/com_plugins/views/plugins/tmpl/default.php @@ -1,141 +1,141 @@ - - - - -lists['order'] == 'p.folder' || $this->lists['order'] == 'p.ordering'); - $rows =& $this->items; - -?> - -
    - - - - - -
    - : - - - - - lists['type']; - echo $this->lists['state']; - ?> -
    - - - - - - - - - - - - - - - - - - - - - -client .'&task=edit&cid[]='. $row->id ); - - $access = JHTML::_('grid.access', $row, $i ); - $checked = JHTML::_('grid.checkedout', $row, $i ); - $published = JHTML::_('grid.published', $row, $i ); - -?> - "> - - - - - - - - - - - - -
    - - - - - lists['order_Dir'], @$this->lists['order'] ); ?> - - lists['order_Dir'], @$this->lists['order'] ); ?> - - lists['order_Dir'], @$this->lists['order'] ); ?> - - - lists['order_Dir'], @$this->lists['order'] ); ?> - - lists['order_Dir'], @$this->lists['order'] ); ?> - - lists['order_Dir'], @$this->lists['order'] ); ?> - - lists['order_Dir'], @$this->lists['order'] ); ?> -
    - pagination->getListFooter(); ?> -
    - pagination->getRowOffset( $i ); ?> - - - - user->get ('id'), $row->checked_out ) ) { - echo $row->name; - } else { - ?> - - - name; ?> - - - - - pagination->orderUpIcon( $i, ($row->folder == @$rows[$i-1]->folder && $row->ordering > -10000 && $row->ordering < 10000), 'orderup', 'Move Up', $ordering ); ?> - pagination->orderDownIcon( $i, $n, ($row->folder == @$rows[$i+1]->folder && $row->ordering > -10000 && $row->ordering < 10000), 'orderdown', 'Move Down', $ordering ); ?> - - class="text_area" style="text-align: center" /> - - - - folder;?> - - element;?> - - id;?> -
    - - - - - - - - + + + + +lists['order'] == 'p.folder' || $this->lists['order'] == 'p.ordering'); + $rows =& $this->items; + +?> + + + + + + + +
    + : + + + + + lists['type']; + echo $this->lists['state']; + ?> +
    + + + + + + + + + + + + + + + + + + + + + +client .'&task=edit&cid[]='. $row->id ); + + $access = JHTML::_('grid.access', $row, $i ); + $checked = JHTML::_('grid.checkedout', $row, $i ); + $published = JHTML::_('grid.published', $row, $i ); + +?> + "> + + + + + + + + + + + + +
    + + + + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> +
    + pagination->getListFooter(); ?> +
    + pagination->getRowOffset( $i ); ?> + + + + user->get ('id'), $row->checked_out ) ) { + echo $row->name; + } else { + ?> + + + name; ?> + + + + + pagination->orderUpIcon( $i, ($row->folder == @$rows[$i-1]->folder && $row->ordering > -10000 && $row->ordering < 10000), 'orderup', 'Move Up', $ordering ); ?> + pagination->orderDownIcon( $i, $n, ($row->folder == @$rows[$i+1]->folder && $row->ordering > -10000 && $row->ordering < 10000), 'orderdown', 'Move Down', $ordering ); ?> + + class="text_area" style="text-align: center" /> + + + + folder;?> + + element;?> + + id;?> +
    + + + + + + + +
    \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_plugins/views/plugins/view.html.php b/oss/joomla/trunk/administrator/components/com_plugins/views/plugins/view.html.php index 548f952a..2c0d9b21 100644 --- a/oss/joomla/trunk/administrator/components/com_plugins/views/plugins/view.html.php +++ b/oss/joomla/trunk/administrator/components/com_plugins/views/plugins/view.html.php @@ -1,139 +1,142 @@ -getUserStateFromRequest( "$option.$client.filter_order", 'filter_order', 'p.folder', 'cmd' ); - $filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.$client.filter_order_Dir", 'filter_order_Dir', '', 'word' ); - $filter_state = $mainframe->getUserStateFromRequest( "$option.$client.filter_state", 'filter_state', '', 'word' ); - $filter_type = $mainframe->getUserStateFromRequest( "$option.$client.filter_type", 'filter_type', 1, 'cmd' ); - $search = $mainframe->getUserStateFromRequest( "$option.$client.search", 'search', '', 'string' ); - $search = JString::strtolower( $search ); - - $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); - $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); - - $where = ''; - if ($client == 'admin') { - $where[] = 'p.client_id = 1'; - $client_id = 1; - } else { - $where[] = 'p.client_id = 0'; - $client_id = 0; - } - - // used by filter - if ( $filter_type != 1 ) { - $where[] = 'p.folder = '.$db->Quote($filter_type); - } - if ( $search ) { - $where[] = 'LOWER( p.name ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); - } - if ( $filter_state ) { - if ( $filter_state == 'P' ) { - $where[] = 'p.published = 1'; - } else if ($filter_state == 'U' ) { - $where[] = 'p.published = 0'; - } - } - - $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); - if ($filter_order == 'p.ordering') { - $orderby = ' ORDER BY p.folder, p.ordering '. $filter_order_Dir; - } else { - $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', p.ordering ASC'; - } - - - // get the total number of records - $query = 'SELECT COUNT(*)' - . ' FROM #__plugins AS p' - . $where - ; - $db->setQuery( $query ); - $total = $db->loadResult(); - - jimport('joomla.html.pagination'); - $pagination = new JPagination( $total, $limitstart, $limit ); - - $query = 'SELECT p.*, u.name AS editor, g.name AS groupname' - . ' FROM #__plugins AS p' - . ' LEFT JOIN #__users AS u ON u.id = p.checked_out' - . ' LEFT JOIN #__groups AS g ON g.id = p.access' - . $where - . ' GROUP BY p.id' - . $orderby - ; - $db->setQuery( $query, $pagination->limitstart, $pagination->limit ); - $rows = $db->loadObjectList(); - if ($db->getErrorNum()) { - echo $db->stderr(); - return false; - } - - - // get list of Positions for dropdown filter - $query = 'SELECT folder AS value, folder AS text' - . ' FROM #__plugins' - . ' WHERE client_id = '.(int) $client_id - . ' GROUP BY folder' - . ' ORDER BY folder' - ; - $types[] = JHTML::_('select.option', 1, '- '. JText::_( 'Select Type' ) .' -' ); - $db->setQuery( $query ); - $types = array_merge( $types, $db->loadObjectList() ); - $lists['type'] = JHTML::_('select.genericlist', $types, 'filter_type', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $filter_type ); - - // state filter - $lists['state'] = JHTML::_('grid.state', $filter_state ); - - - // table ordering - $lists['order_Dir'] = $filter_order_Dir; - $lists['order'] = $filter_order; - - // search filter - $lists['search']= $search; - - $this->assign('client', $client); - - $this->assignRef('user', JFactory::getUser()); - $this->assignRef('lists', $lists); - $this->assignRef('items', $rows); - $this->assignRef('pagination', $pagination); - - parent::display($tpl); - } +getUserStateFromRequest( "$option.$client.filter_order", 'filter_order', 'p.folder', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.$client.filter_order_Dir", 'filter_order_Dir', '', 'word' ); + $filter_state = $mainframe->getUserStateFromRequest( "$option.$client.filter_state", 'filter_state', '', 'word' ); + $filter_type = $mainframe->getUserStateFromRequest( "$option.$client.filter_type", 'filter_type', 1, 'cmd' ); + $search = $mainframe->getUserStateFromRequest( "$option.$client.search", 'search', '', 'string' ); + if (strpos($search, '"') !== false) { + $search = str_replace(array('=', '<'), '', $search); + } + $search = JString::strtolower($search); + + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); + + $where = ''; + if ($client == 'admin') { + $where[] = 'p.client_id = 1'; + $client_id = 1; + } else { + $where[] = 'p.client_id = 0'; + $client_id = 0; + } + + // used by filter + if ( $filter_type != 1 ) { + $where[] = 'p.folder = '.$db->Quote($filter_type); + } + if ( $search ) { + $where[] = 'LOWER( p.name ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + if ( $filter_state ) { + if ( $filter_state == 'P' ) { + $where[] = 'p.published = 1'; + } else if ($filter_state == 'U' ) { + $where[] = 'p.published = 0'; + } + } + + $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); + if ($filter_order == 'p.ordering') { + $orderby = ' ORDER BY p.folder, p.ordering '. $filter_order_Dir; + } else { + $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', p.ordering ASC'; + } + + + // get the total number of records + $query = 'SELECT COUNT(*)' + . ' FROM #__plugins AS p' + . $where + ; + $db->setQuery( $query ); + $total = $db->loadResult(); + + jimport('joomla.html.pagination'); + $pagination = new JPagination( $total, $limitstart, $limit ); + + $query = 'SELECT p.*, u.name AS editor, g.name AS groupname' + . ' FROM #__plugins AS p' + . ' LEFT JOIN #__users AS u ON u.id = p.checked_out' + . ' LEFT JOIN #__groups AS g ON g.id = p.access' + . $where + . ' GROUP BY p.id' + . $orderby + ; + $db->setQuery( $query, $pagination->limitstart, $pagination->limit ); + $rows = $db->loadObjectList(); + if ($db->getErrorNum()) { + echo $db->stderr(); + return false; + } + + + // get list of Positions for dropdown filter + $query = 'SELECT folder AS value, folder AS text' + . ' FROM #__plugins' + . ' WHERE client_id = '.(int) $client_id + . ' GROUP BY folder' + . ' ORDER BY folder' + ; + $types[] = JHTML::_('select.option', 1, '- '. JText::_( 'Select Type' ) .' -' ); + $db->setQuery( $query ); + $types = array_merge( $types, $db->loadObjectList() ); + $lists['type'] = JHTML::_('select.genericlist', $types, 'filter_type', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', $filter_type ); + + // state filter + $lists['state'] = JHTML::_('grid.state', $filter_state ); + + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search']= $search; + + $this->assign('client', $client); + + $this->assignRef('user', JFactory::getUser()); + $this->assignRef('lists', $lists); + $this->assignRef('items', $rows); + $this->assignRef('pagination', $pagination); + + parent::display($tpl); + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_poll/controller.php b/oss/joomla/trunk/administrator/components/com_poll/controller.php index 0f55e85e..8d957818 100644 --- a/oss/joomla/trunk/administrator/components/com_poll/controller.php +++ b/oss/joomla/trunk/administrator/components/com_poll/controller.php @@ -1,223 +1,223 @@ -registerTask( 'apply', 'save'); - $this->registerTask( 'unpublish', 'publish'); - $this->registerTask( 'preview', 'display'); - $this->registerTask( 'edit', 'display'); - $this->registerTask( 'add' , 'display' ); - - } - - function display( ) - { - switch($this->getTask()) - { - case 'add' : - { - JRequest::setVar( 'hidemainmenu', 1 ); - JRequest::setVar( 'layout', 'form' ); - JRequest::setVar( 'view', 'poll' ); - JRequest::setVar( 'edit', false ); - } break; - case 'edit' : - { - JRequest::setVar( 'hidemainmenu', 1 ); - JRequest::setVar( 'layout', 'form' ); - JRequest::setVar( 'view', 'poll' ); - JRequest::setVar( 'edit', true ); - } break; - - case 'preview' : - { - JRequest::setVar( 'tmpl', 'component' ); - JRequest::setVar( 'view', 'poll' ); - } break; - } - - //Set the default view, just in case - $view = JRequest::getCmd('view'); - if(empty($view)) { - JRequest::setVar('view', 'polls'); - }; - - parent::display(); - } - - function save() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - - // save the poll parent information - $row =& JTable::getInstance('poll', 'Table'); - $post = JRequest::get( 'post' ); - if (!$row->bind( $post )) - { - JError::raiseError(500, $row->getError() ); - } - $isNew = ($row->id == 0); - - if (!$row->check()) - { - JError::raiseError(500, $row->getError() ); - } - - if (!$row->store()) - { - JError::raiseError(500, $row->getError() ); - } - $row->checkin(); - // save the poll options - $options = JArrayHelper::getValue( $post, 'polloption', array(), 'array' ); - - foreach ($options as $i=>$text) - { - $text = htmlspecialchars($text, ENT_QUOTES, 'UTF-8'); - if ($isNew) - { - $obj = new stdClass(); - $obj->pollid = (int)$row->id; - $obj->text = $text; - $db->insertObject('#__poll_data', $obj); - } - else - { - $obj = new stdClass(); - $obj->id = (int)$i; - $obj->text = $text; - $db->updateObject('#__poll_data', $obj, 'id'); - } - } - - switch ($this->_task) - { - case 'apply': - $msg = JText::_( 'Changes to Poll saved' ); - $link = 'index.php?option=com_poll&view=poll&task=edit&cid[]='. $row->id .''; - break; - - case 'save': - default: - $msg = JText::_( 'Poll saved' ); - $link = 'index.php?option=com_poll'; - break; - } - - $this->setRedirect($link); - } - - function remove() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $cid = JRequest::getVar( 'cid', array(), '', 'array' ); - - JArrayHelper::toInteger($cid); - $msg = ''; - - for ($i=0, $n=count($cid); $i < $n; $i++) - { - $poll =& JTable::getInstance('poll', 'Table'); - if (!$poll->delete( $cid[$i] )) - { - $msg .= $poll->getError(); - } - } - $this->setRedirect( 'index.php?option=com_poll', $msg ); - } - - /** - * Publishes or Unpublishes one or more records - * @param array An array of unique category id numbers - * @param integer 0 if unpublishing, 1 if publishing - * @param string The current url option - */ - function publish() - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $user =& JFactory::getUser(); - - $cid = JRequest::getVar( 'cid', array(), '', 'array' ); - $publish = ( $this->getTask() == 'publish' ? 1 : 0 ); - - JArrayHelper::toInteger($cid); - - if (count( $cid ) < 1) - { - $action = $publish ? 'publish' : 'unpublish'; - JError::raiseError(500, JText::_( 'Select an item to' .$action, true ) ); - } - - $cids = implode( ',', $cid ); - - $query = 'UPDATE #__polls' - . ' SET published = ' . (int) $publish - . ' WHERE id IN ( '. $cids .' )' - . ' AND ( checked_out = 0 OR ( checked_out = '.(int) $user->get('id').' ) )' - ; - $db->setQuery( $query ); - if (!$db->query()) - { - JError::raiseError(500, $db->getErrorMsg() ); - } - - if (count( $cid ) == 1) - { - $row =& JTable::getInstance('poll', 'Table'); - $row->checkin( $cid[0] ); - } - $mainframe->redirect( 'index.php?option=com_poll' ); - } - - function cancel() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $id = JRequest::getVar( 'id', 0, '', 'int' ); - $db =& JFactory::getDBO(); - $row =& JTable::getInstance('poll', 'Table'); - - $row->checkin( $id ); - $this->setRedirect( 'index.php?option=com_poll' ); - } +registerTask( 'apply', 'save'); + $this->registerTask( 'unpublish', 'publish'); + $this->registerTask( 'preview', 'display'); + $this->registerTask( 'edit', 'display'); + $this->registerTask( 'add' , 'display' ); + + } + + function display( ) + { + switch($this->getTask()) + { + case 'add' : + { + JRequest::setVar( 'hidemainmenu', 1 ); + JRequest::setVar( 'layout', 'form' ); + JRequest::setVar( 'view', 'poll' ); + JRequest::setVar( 'edit', false ); + } break; + case 'edit' : + { + JRequest::setVar( 'hidemainmenu', 1 ); + JRequest::setVar( 'layout', 'form' ); + JRequest::setVar( 'view', 'poll' ); + JRequest::setVar( 'edit', true ); + } break; + + case 'preview' : + { + JRequest::setVar( 'tmpl', 'component' ); + JRequest::setVar( 'view', 'poll' ); + } break; + } + + //Set the default view, just in case + $view = JRequest::getCmd('view'); + if(empty($view)) { + JRequest::setVar('view', 'polls'); + }; + + parent::display(); + } + + function save() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + + // save the poll parent information + $row =& JTable::getInstance('poll', 'Table'); + $post = JRequest::get( 'post' ); + if (!$row->bind( $post )) + { + JError::raiseError(500, $row->getError() ); + } + $isNew = ($row->id == 0); + + if (!$row->check()) + { + JError::raiseError(500, $row->getError() ); + } + + if (!$row->store()) + { + JError::raiseError(500, $row->getError() ); + } + $row->checkin(); + // save the poll options + $options = JArrayHelper::getValue( $post, 'polloption', array(), 'array' ); + + foreach ($options as $i=>$text) + { + $text = htmlspecialchars($text, ENT_QUOTES, 'UTF-8'); + if ($isNew) + { + $obj = new stdClass(); + $obj->pollid = (int)$row->id; + $obj->text = $text; + $db->insertObject('#__poll_data', $obj); + } + else + { + $obj = new stdClass(); + $obj->id = (int)$i; + $obj->text = $text; + $db->updateObject('#__poll_data', $obj, 'id'); + } + } + + switch ($this->_task) + { + case 'apply': + $msg = JText::_( 'Changes to Poll saved' ); + $link = 'index.php?option=com_poll&view=poll&task=edit&cid[]='. $row->id .''; + break; + + case 'save': + default: + $msg = JText::_( 'Poll saved' ); + $link = 'index.php?option=com_poll'; + break; + } + + $this->setRedirect($link, $msg); + } + + function remove() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $cid = JRequest::getVar( 'cid', array(), '', 'array' ); + + JArrayHelper::toInteger($cid); + $msg = ''; + + for ($i=0, $n=count($cid); $i < $n; $i++) + { + $poll =& JTable::getInstance('poll', 'Table'); + if (!$poll->delete( $cid[$i] )) + { + $msg .= $poll->getError(); + } + } + $this->setRedirect( 'index.php?option=com_poll', $msg ); + } + + /** + * Publishes or Unpublishes one or more records + * @param array An array of unique category id numbers + * @param integer 0 if unpublishing, 1 if publishing + * @param string The current url option + */ + function publish() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + + $cid = JRequest::getVar( 'cid', array(), '', 'array' ); + $publish = ( $this->getTask() == 'publish' ? 1 : 0 ); + + JArrayHelper::toInteger($cid); + + if (count( $cid ) < 1) + { + $action = $publish ? 'publish' : 'unpublish'; + JError::raiseError(500, JText::_( 'Select an item to' .$action, true ) ); + } + + $cids = implode( ',', $cid ); + + $query = 'UPDATE #__polls' + . ' SET published = ' . (int) $publish + . ' WHERE id IN ( '. $cids .' )' + . ' AND ( checked_out = 0 OR ( checked_out = '.(int) $user->get('id').' ) )' + ; + $db->setQuery( $query ); + if (!$db->query()) + { + JError::raiseError(500, $db->getErrorMsg() ); + } + + if (count( $cid ) == 1) + { + $row =& JTable::getInstance('poll', 'Table'); + $row->checkin( $cid[0] ); + } + $mainframe->redirect( 'index.php?option=com_poll' ); + } + + function cancel() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $id = JRequest::getVar( 'id', 0, '', 'int' ); + $db =& JFactory::getDBO(); + $row =& JTable::getInstance('poll', 'Table'); + + $row->checkin( $id ); + $this->setRedirect( 'index.php?option=com_poll' ); + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_poll/elements/poll.php b/oss/joomla/trunk/administrator/components/com_poll/elements/poll.php index ba0cb7b0..7c6da6b0 100644 --- a/oss/joomla/trunk/administrator/components/com_poll/elements/poll.php +++ b/oss/joomla/trunk/administrator/components/com_poll/elements/poll.php @@ -1,43 +1,43 @@ -setQuery( $query ); - $options = $db->loadObjectList(); - - array_unshift($options, JHTML::_('select.option', '0', '- '.JText::_('Select Poll').' -', 'id', 'title')); - - return JHTML::_('select.genericlist', $options, ''.$control_name.'['.$name.']', 'class="inputbox"', 'id', 'title', $value, $control_name.$name ); - } -} +setQuery( $query ); + $options = $db->loadObjectList(); + + array_unshift($options, JHTML::_('select.option', '0', '- '.JText::_('Select Poll').' -', 'id', 'title')); + + return JHTML::_('select.genericlist', $options, ''.$control_name.'['.$name.']', 'class="inputbox"', 'id', 'title', $value, $control_name.$name ); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_poll/poll.php b/oss/joomla/trunk/administrator/components/com_poll/poll.php index 38213cc6..0d77b89e 100644 --- a/oss/joomla/trunk/administrator/components/com_poll/poll.php +++ b/oss/joomla/trunk/administrator/components/com_poll/poll.php @@ -1,33 +1,33 @@ -authorize( 'com_poll', 'manage' )) { - $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); -} - -require_once( JPATH_COMPONENT.DS.'controller.php' ); - -// Set the table directory -JTable::addIncludePath( JPATH_COMPONENT.DS.'tables' ); - -// Create the controller -$controller = new PollController( ); - -$controller->execute( JRequest::getCmd( 'task' ) ); +authorize( 'com_poll', 'manage' )) { + $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); +} + +require_once( JPATH_COMPONENT.DS.'controller.php' ); + +// Set the table directory +JTable::addIncludePath( JPATH_COMPONENT.DS.'tables' ); + +// Create the controller +$controller = new PollController( ); + +$controller->execute( JRequest::getCmd( 'task' ) ); $controller->redirect(); \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_poll/poll.xml b/oss/joomla/trunk/administrator/components/com_poll/poll.xml index 479c9019..5dd69c34 100644 --- a/oss/joomla/trunk/administrator/components/com_poll/poll.xml +++ b/oss/joomla/trunk/administrator/components/com_poll/poll.xml @@ -1,12 +1,12 @@ - - - Polls - Joomla! Project - July 2004 - Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - admin@joomla.org - www.joomla.org - 1.5.0 - This component manages polls - + + + Polls + Joomla! Project + July 2004 + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + This component manages polls + diff --git a/oss/joomla/trunk/administrator/components/com_poll/tables/poll.php b/oss/joomla/trunk/administrator/components/com_poll/tables/poll.php index 350a029f..3704e51f 100644 --- a/oss/joomla/trunk/administrator/components/com_poll/tables/poll.php +++ b/oss/joomla/trunk/administrator/components/com_poll/tables/poll.php @@ -1,138 +1,138 @@ -id = (int) $this->id; - - return $result; - } - - /** - * Overloaded check function - * - * @access public - * @return boolean - * @see JTable::check - * @since 1.5 - */ - function check() - { - // check for valid name - if (trim( $this->title ) == '') - { - $this->setError(JText::_( 'Your Poll must contain a title.' )); - return false; - } - // check for valid lag - $this->lag = intval( $this->lag ); - if ($this->lag == 0) { - $this->setError(JText::_( 'Your Poll must have a non-zero lag time.' )); - return false; - } - - if(empty($this->alias)) { - $this->alias = $this->title; - } - $this->alias = JFilterOutput::stringURLSafe($this->alias); - if(trim(str_replace('-','',$this->alias)) == '') { - $datenow =& JFactory::getDate(); - $this->alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S"); - } - - return true; - } - - // overloaded delete function - function delete( $oid=null ) - { - $k = $this->_tbl_key; - if ( $oid ) { - $this->$k = intval( $oid ); - } - - if ( parent::delete( $oid )) - { - $query = 'DELETE FROM #__poll_data' - . ' WHERE pollid = '.(int) $this->$k - ; - $this->_db->setQuery( $query ); - if ( !$this->_db->query() ) { - $this->_error .= $this->_db->getErrorMsg() . "\n"; - } - - $query = 'DELETE FROM #__poll_date' - . ' WHERE poll_id = '.(int) $this->$k - ; - $this->_db->setQuery( $query ); - if ( !$this->_db->query() ) { - $this->_error .= $this->_db->getErrorMsg() . "\n"; - } - - $query = 'DELETE from #__poll_menu' - . ' WHERE pollid = '.(int) $this->$k - ; - $this->_db->setQuery( $query ); - if ( !$this->_db->query() ) { - $this->_error .= $this->_db->getErrorMsg() . "\n"; - } - - return true; - } - - return false; - } -} +id = (int) $this->id; + + return $result; + } + + /** + * Overloaded check function + * + * @access public + * @return boolean + * @see JTable::check + * @since 1.5 + */ + function check() + { + // check for valid name + if (trim( $this->title ) == '') + { + $this->setError(JText::_( 'Your Poll must contain a title.' )); + return false; + } + // check for valid lag + $this->lag = intval( $this->lag ); + if ($this->lag == 0) { + $this->setError(JText::_( 'Your Poll must have a non-zero lag time.' )); + return false; + } + + if(empty($this->alias)) { + $this->alias = $this->title; + } + $this->alias = JFilterOutput::stringURLSafe($this->alias); + if(trim(str_replace('-','',$this->alias)) == '') { + $datenow =& JFactory::getDate(); + $this->alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S"); + } + + return true; + } + + // overloaded delete function + function delete( $oid=null ) + { + $k = $this->_tbl_key; + if ( $oid ) { + $this->$k = intval( $oid ); + } + + if ( parent::delete( $oid )) + { + $query = 'DELETE FROM #__poll_data' + . ' WHERE pollid = '.(int) $this->$k + ; + $this->_db->setQuery( $query ); + if ( !$this->_db->query() ) { + $this->_error .= $this->_db->getErrorMsg() . "\n"; + } + + $query = 'DELETE FROM #__poll_date' + . ' WHERE poll_id = '.(int) $this->$k + ; + $this->_db->setQuery( $query ); + if ( !$this->_db->query() ) { + $this->_error .= $this->_db->getErrorMsg() . "\n"; + } + + $query = 'DELETE from #__poll_menu' + . ' WHERE pollid = '.(int) $this->$k + ; + $this->_db->setQuery( $query ); + if ( !$this->_db->query() ) { + $this->_error .= $this->_db->getErrorMsg() . "\n"; + } + + return true; + } + + return false; + } +} diff --git a/oss/joomla/trunk/administrator/components/com_poll/views/poll/view.html.php b/oss/joomla/trunk/administrator/components/com_poll/views/poll/view.html.php index 415c9154..3cbd596e 100644 --- a/oss/joomla/trunk/administrator/components/com_poll/views/poll/view.html.php +++ b/oss/joomla/trunk/administrator/components/com_poll/views/poll/view.html.php @@ -1,83 +1,83 @@ -load( $uid ); - - // fail if checked out not by 'me' - if ($poll->isCheckedOut( $user->get('id') )) { - $msg = JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The poll' ), $poll->title ); - $this->setRedirect( 'index.php?option='. $option, $msg ); - } - - if ($poll->id == 0) - { - // defaults - $row->published = 1; - } - - $options = array(); - - if ($edit) - { - $poll->checkout( $user->get('id') ); - $query = 'SELECT id, text' - . ' FROM #__poll_data' - . ' WHERE pollid = '.(int) $uid - . ' ORDER BY id' - ; - $db->setQuery($query); - $options = $db->loadObjectList(); - } - else - { - $poll->lag = 3600*24; - } - - $this->assignRef('poll', $poll); - $this->assignRef('options', $options); - - parent::display($tpl); - - } +load( $uid ); + + // fail if checked out not by 'me' + if ($poll->isCheckedOut( $user->get('id') )) { + $msg = JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The poll' ), $poll->title ); + $this->setRedirect( 'index.php?option='. $option, $msg ); + } + + if ($poll->id == 0) + { + // defaults + $row->published = 1; + } + + $options = array(); + + if ($edit) + { + $poll->checkout( $user->get('id') ); + $query = 'SELECT id, text' + . ' FROM #__poll_data' + . ' WHERE pollid = '.(int) $uid + . ' ORDER BY id' + ; + $db->setQuery($query); + $options = $db->loadObjectList(); + } + else + { + $poll->lag = 3600*24; + } + + $this->assignRef('poll', $poll); + $this->assignRef('options', $options); + + parent::display($tpl); + + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_poll/views/polls/tmpl/default.php b/oss/joomla/trunk/administrator/components/com_poll/views/polls/tmpl/default.php index de81a361..7889c629 100644 --- a/oss/joomla/trunk/administrator/components/com_poll/views/polls/tmpl/default.php +++ b/oss/joomla/trunk/administrator/components/com_poll/views/polls/tmpl/default.php @@ -1,127 +1,127 @@ - - - - - - -
    - - - - - -
    - : - - - - - lists['state']; ?> -
    -
    - - - - - - - - - - - - - - - - - - - - items ); $i < $n; $i++) - { - $row = &$this->items[$i]; - - $link = JRoute::_( 'index.php?option=com_poll&view=poll&task=edit&cid[]='. $row->id ); - - $checked = JHTML::_('grid.checkedout', $row, $i ); - $published = JHTML::_('grid.published', $row, $i ); - ?> - "> - - - - - - - - - - - -
    - - - - - lists['order_Dir'], @$this->lists['order'] ); ?> - - lists['order_Dir'], @$this->lists['order'] ); ?> - - lists['order_Dir'], @$this->lists['order'] ); ?> - - lists['order_Dir'], @$this->lists['order'] ); ?> - - lists['order_Dir'], @$this->lists['order'] ); ?> - - lists['order_Dir'], @$this->lists['order'] ); ?> -
    - pagination->getListFooter(); ?> -
    - pagination->getRowOffset( $i ); ?> - - - - user->get ('id'), $row->checked_out ) ) { - echo $row->title; - } else { - ?> - - - title; ?> - - - - - voters; ?> - - numoptions; ?> - - lag; ?> - - id; ?> -
    -
    - - - - - - - + + + + + + + + + + + + +
    + : + + + + + lists['state']; ?> +
    +
    + + + + + + + + + + + + + + + + + + + + items ); $i < $n; $i++) + { + $row = &$this->items[$i]; + + $link = JRoute::_( 'index.php?option=com_poll&view=poll&task=edit&cid[]='. $row->id ); + + $checked = JHTML::_('grid.checkedout', $row, $i ); + $published = JHTML::_('grid.published', $row, $i ); + ?> + "> + + + + + + + + + + + +
    + + + + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> +
    + pagination->getListFooter(); ?> +
    + pagination->getRowOffset( $i ); ?> + + + + user->get ('id'), $row->checked_out ) ) { + echo $row->title; + } else { + ?> + + + title; ?> + + + + + voters; ?> + + numoptions; ?> + + lag; ?> + + id; ?> +
    +
    + + + + + + +
    \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_poll/views/polls/view.html.php b/oss/joomla/trunk/administrator/components/com_poll/views/polls/view.html.php index be9169c9..3d640a2f 100644 --- a/oss/joomla/trunk/administrator/components/com_poll/views/polls/view.html.php +++ b/oss/joomla/trunk/administrator/components/com_poll/views/polls/view.html.php @@ -1,109 +1,112 @@ -getUserStateFromRequest( "$option.filter_order", 'filter_order', 'm.id', 'cmd' ); - $filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.filter_order_Dir", 'filter_order_Dir', '', 'word' ); - $filter_state = $mainframe->getUserStateFromRequest( "$option.filter_state", 'filter_state', '', 'word' ); - $search = $mainframe->getUserStateFromRequest( "$option.search", 'search', '', 'string' ); - $search = JString::strtolower( $search ); - - $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); - $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); - - $where = array(); - - if ( $filter_state ) - { - if ( $filter_state == 'P' ) - { - $where[] = 'm.published = 1'; - } - else if ($filter_state == 'U' ) - { - $where[] = 'm.published = 0'; - } - } - if ($search) - { - $where[] = 'LOWER(m.title) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); - } - - $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); - $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir; - - $query = 'SELECT COUNT(m.id)' - . ' FROM #__polls AS m' - . $where - ; - $db->setQuery( $query ); - $total = $db->loadResult(); - - jimport('joomla.html.pagination'); - $pagination = new JPagination( $total, $limitstart, $limit ); - - $query = 'SELECT m.*, u.name AS editor, COUNT(d.id) AS numoptions' - . ' FROM #__polls AS m' - . ' LEFT JOIN #__users AS u ON u.id = m.checked_out' - . ' LEFT JOIN #__poll_data AS d ON d.pollid = m.id AND d.text <> ""' - . $where - . ' GROUP BY m.id' - . $orderby - ; - $db->setQuery( $query, $pagination->limitstart, $pagination->limit ); - $rows = $db->loadObjectList(); - - if ($db->getErrorNum()) - { - echo $db->stderr(); - return false; - } - - // state filter - $lists['state'] = JHTML::_('grid.state', $filter_state ); - - // table ordering - $lists['order_Dir'] = $filter_order_Dir; - $lists['order'] = $filter_order; - - // search filter - $lists['search']= $search; - - $this->assignRef('user', JFactory::getUser()); - $this->assignRef('lists', $lists); - $this->assignRef('items', $rows); - $this->assignRef('pagination', $pagination); - - parent::display($tpl); - } +getUserStateFromRequest( "$option.filter_order", 'filter_order', 'm.id', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.filter_order_Dir", 'filter_order_Dir', '', 'word' ); + $filter_state = $mainframe->getUserStateFromRequest( "$option.filter_state", 'filter_state', '', 'word' ); + $search = $mainframe->getUserStateFromRequest( "$option.search", 'search', '', 'string' ); + if (strpos($search, '"') !== false) { + $search = str_replace(array('=', '<'), '', $search); + } + $search = JString::strtolower($search); + + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); + + $where = array(); + + if ( $filter_state ) + { + if ( $filter_state == 'P' ) + { + $where[] = 'm.published = 1'; + } + else if ($filter_state == 'U' ) + { + $where[] = 'm.published = 0'; + } + } + if ($search) + { + $where[] = 'LOWER(m.title) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + + $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); + $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir; + + $query = 'SELECT COUNT(m.id)' + . ' FROM #__polls AS m' + . $where + ; + $db->setQuery( $query ); + $total = $db->loadResult(); + + jimport('joomla.html.pagination'); + $pagination = new JPagination( $total, $limitstart, $limit ); + + $query = 'SELECT m.*, u.name AS editor, COUNT(d.id) AS numoptions' + . ' FROM #__polls AS m' + . ' LEFT JOIN #__users AS u ON u.id = m.checked_out' + . ' LEFT JOIN #__poll_data AS d ON d.pollid = m.id AND d.text <> ""' + . $where + . ' GROUP BY m.id' + . $orderby + ; + $db->setQuery( $query, $pagination->limitstart, $pagination->limit ); + $rows = $db->loadObjectList(); + + if ($db->getErrorNum()) + { + echo $db->stderr(); + return false; + } + + // state filter + $lists['state'] = JHTML::_('grid.state', $filter_state ); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search']= $search; + + $this->assignRef('user', JFactory::getUser()); + $this->assignRef('lists', $lists); + $this->assignRef('items', $rows); + $this->assignRef('pagination', $pagination); + + parent::display($tpl); + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_search/controller.php b/oss/joomla/trunk/administrator/components/com_search/controller.php index 027beb5a..a7790e7a 100644 --- a/oss/joomla/trunk/administrator/components/com_search/controller.php +++ b/oss/joomla/trunk/administrator/components/com_search/controller.php @@ -1,46 +1,46 @@ -getModel( 'Search' ); - $view =& $this->getView( 'Search' ); - $view->setModel( $model, true ); - $view->display(); - } - - /** - * Reset Statistics - */ - function reset() - { - $model =& $this->getModel( 'Search' ); - $model->reset(); - $this->setRedirect('index.php?option=com_search'); - } +getModel( 'Search' ); + $view =& $this->getView( 'Search' ); + $view->setModel( $model, true ); + $view->display(); + } + + /** + * Reset Statistics + */ + function reset() + { + $model =& $this->getModel( 'Search' ); + $model->reset(); + $this->setRedirect('index.php?option=com_search'); + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_search/helpers/search.php b/oss/joomla/trunk/administrator/components/com_search/helpers/search.php index 9807a776..b37bb059 100644 --- a/oss/joomla/trunk/administrator/components/com_search/helpers/search.php +++ b/oss/joomla/trunk/administrator/components/com_search/helpers/search.php @@ -1,204 +1,204 @@ -getTag(); - $ignoreFile = $lang->getLanguagePath().DS.$tag.DS.$tag.'.ignore.php'; - if (file_exists($ignoreFile)) { - include $ignoreFile; - } - - // check for words to ignore - $aterms = explode( ' ', JString::strtolower( $searchword ) ); - - // first case is single ignored word - if ( count( $aterms ) == 1 && in_array( JString::strtolower( $searchword ), $search_ignore ) ) { - $ignored = true; - } - - // filter out search terms that are too small - foreach( $aterms AS $aterm ) { - if (JString::strlen( $aterm ) < 3) { - $search_ignore[] = $aterm; - } - } - - // next is to remove ignored words from type 'all' or 'any' (not exact) searches with multiple words - if ( count( $aterms ) > 1 && $searchphrase != 'exact' ) { - $pruned = array_diff( $aterms, $search_ignore ); - $searchword = implode( ' ', $pruned ); - } - - return $ignored; - } - - function limitSearchWord(&$searchword) - { - $restriction = false; - - // limit searchword to 20 characters - if ( JString::strlen( $searchword ) > 20 ) { - $searchword = JString::substr( $searchword, 0, 19 ); - $restriction = true; - } - - // searchword must contain a minimum of 3 characters - if ( $searchword && JString::strlen( $searchword ) < 3 ) { - $searchword = ''; - $restriction = true; - } - - return $restriction; - } - - function logSearch( $search_term ) - { - global $mainframe; - - $db =& JFactory::getDBO(); - - $params = &JComponentHelper::getParams( 'com_search' ); - $enable_log_searches = $params->get('enabled'); - - $search_term = $db->getEscaped( trim( $search_term) ); - - if ( @$enable_log_searches ) - { - $db =& JFactory::getDBO(); - $query = 'SELECT hits' - . ' FROM #__core_log_searches' - . ' WHERE LOWER( search_term ) = "'.$search_term.'"' - ; - $db->setQuery( $query ); - $hits = intval( $db->loadResult() ); - if ( $hits ) { - $query = 'UPDATE #__core_log_searches' - . ' SET hits = ( hits + 1 )' - . ' WHERE LOWER( search_term ) = "'.$search_term.'"' - ; - $db->setQuery( $query ); - $db->query(); - } else { - $query = 'INSERT INTO #__core_log_searches VALUES ( "'.$search_term.'", 1 )'; - $db->setQuery( $query ); - $db->query(); - } - } - } - - /** - * Prepares results from search for display - * - * @param string The source string - * @param int Number of chars to trim - * @param string The searchword to select around - * @return string - */ - function prepareSearchContent( $text, $length = 200, $searchword ) - { - // strips tags won't remove the actual jscript - $text = preg_replace( "']*>.*?'si", "", $text ); - $text = preg_replace( '/{.+?}/', '', $text); - //$text = preg_replace( '/]*>([^<]+)<\/a>/is','\2', $text ); - // replace line breaking tags with whitespace - $text = preg_replace( "'<(br[^/>]*?/|hr[^/>]*?/|/(div|h[1-6]|li|p|td))>'si", ' ', $text ); - - return SearchHelper::_smartSubstr( strip_tags( $text ), $length, $searchword ); - } - - /** - * Checks an object for search terms (after stripping fields of HTML) - * - * @param object The object to check - * @param string Search words to check for - * @param array List of object variables to check against - * @returns boolean True if searchTerm is in object, false otherwise - */ - function checkNoHtml($object, $searchTerm, $fields) { - $searchRegex = array( - '#]*>.*?#si', - '#]*>.*?#si', - '##si', - '#<[^>]*>#i' - ); - $terms = explode(' ', $searchTerm); - if(empty($fields)) return false; - foreach($fields AS $field) { - if(!isset($object->$field)) continue; - $text = $object->$field; - foreach($searchRegex As $regex) { - $text = preg_replace($regex, '', $text); - } - foreach($terms AS $term) { - if(JString::stristr($text, $term) !== false) { - return true; - } - } - } - return false; - } - - /** - * returns substring of characters around a searchword - * - * @param string The source string - * @param int Number of chars to return - * @param string The searchword to select around - * @return string - */ - function _smartSubstr($text, $length = 200, $searchword) - { - $textlen = JString::strlen($text); - $lsearchword = JString::strtolower($searchword); - $wordfound = false; - $pos = 0; - while ($wordfound === false && $pos < $textlen) { - if (($wordpos = @JString::strpos($text, ' ', $pos + $length)) !== false) { - $chunk_size = $wordpos - $pos; - } else { - $chunk_size = $length; - } - $chunk = JString::substr($text, $pos, $chunk_size); - $wordfound = JString::strpos(JString::strtolower($chunk), $lsearchword); - if ($wordfound === false) { - $pos += $chunk_size + 1; - } - } - - if ($wordfound !== false) { - return (($pos > 0) ? '... ' : '') . $chunk . ' ...'; - } else { - if (($wordpos = @JString::strpos($text, ' ', $length)) !== false) { - return JString::substr($text, 0, $wordpos) . ' ...'; - } else { - return JString::substr($text, 0, $length); - } - } - } -} +getTag(); + $ignoreFile = $lang->getLanguagePath().DS.$tag.DS.$tag.'.ignore.php'; + if (file_exists($ignoreFile)) { + include $ignoreFile; + } + + // check for words to ignore + $aterms = explode( ' ', JString::strtolower( $searchword ) ); + + // first case is single ignored word + if ( count( $aterms ) == 1 && in_array( JString::strtolower( $searchword ), $search_ignore ) ) { + $ignored = true; + } + + // filter out search terms that are too small + foreach( $aterms AS $aterm ) { + if (JString::strlen( $aterm ) < 3) { + $search_ignore[] = $aterm; + } + } + + // next is to remove ignored words from type 'all' or 'any' (not exact) searches with multiple words + if ( count( $aterms ) > 1 && $searchphrase != 'exact' ) { + $pruned = array_diff( $aterms, $search_ignore ); + $searchword = implode( ' ', $pruned ); + } + + return $ignored; + } + + function limitSearchWord(&$searchword) + { + $restriction = false; + + // limit searchword to 20 characters + if ( JString::strlen( $searchword ) > 20 ) { + $searchword = JString::substr( $searchword, 0, 19 ); + $restriction = true; + } + + // searchword must contain a minimum of 3 characters + if ( $searchword && JString::strlen( $searchword ) < 3 ) { + $searchword = ''; + $restriction = true; + } + + return $restriction; + } + + function logSearch( $search_term ) + { + global $mainframe; + + $db =& JFactory::getDBO(); + + $params = &JComponentHelper::getParams( 'com_search' ); + $enable_log_searches = $params->get('enabled'); + + $search_term = $db->getEscaped( trim( $search_term) ); + + if ( @$enable_log_searches ) + { + $db =& JFactory::getDBO(); + $query = 'SELECT hits' + . ' FROM #__core_log_searches' + . ' WHERE LOWER( search_term ) = "'.$search_term.'"' + ; + $db->setQuery( $query ); + $hits = intval( $db->loadResult() ); + if ( $hits ) { + $query = 'UPDATE #__core_log_searches' + . ' SET hits = ( hits + 1 )' + . ' WHERE LOWER( search_term ) = "'.$search_term.'"' + ; + $db->setQuery( $query ); + $db->query(); + } else { + $query = 'INSERT INTO #__core_log_searches VALUES ( "'.$search_term.'", 1 )'; + $db->setQuery( $query ); + $db->query(); + } + } + } + + /** + * Prepares results from search for display + * + * @param string The source string + * @param int Number of chars to trim + * @param string The searchword to select around + * @return string + */ + function prepareSearchContent( $text, $length = 200, $searchword ) + { + // strips tags won't remove the actual jscript + $text = preg_replace( "']*>.*?'si", "", $text ); + $text = preg_replace( '/{.+?}/', '', $text); + //$text = preg_replace( '/]*>([^<]+)<\/a>/is','\2', $text ); + // replace line breaking tags with whitespace + $text = preg_replace( "'<(br[^/>]*?/|hr[^/>]*?/|/(div|h[1-6]|li|p|td))>'si", ' ', $text ); + + return SearchHelper::_smartSubstr( strip_tags( $text ), $length, $searchword ); + } + + /** + * Checks an object for search terms (after stripping fields of HTML) + * + * @param object The object to check + * @param string Search words to check for + * @param array List of object variables to check against + * @returns boolean True if searchTerm is in object, false otherwise + */ + function checkNoHtml($object, $searchTerm, $fields) { + $searchRegex = array( + '#]*>.*?#si', + '#]*>.*?#si', + '##si', + '#<[^>]*>#i' + ); + $terms = explode(' ', $searchTerm); + if(empty($fields)) return false; + foreach($fields AS $field) { + if(!isset($object->$field)) continue; + $text = $object->$field; + foreach($searchRegex As $regex) { + $text = preg_replace($regex, '', $text); + } + foreach($terms AS $term) { + if(JString::stristr($text, $term) !== false) { + return true; + } + } + } + return false; + } + + /** + * returns substring of characters around a searchword + * + * @param string The source string + * @param int Number of chars to return + * @param string The searchword to select around + * @return string + */ + function _smartSubstr($text, $length = 200, $searchword) + { + $textlen = JString::strlen($text); + $lsearchword = JString::strtolower($searchword); + $wordfound = false; + $pos = 0; + while ($wordfound === false && $pos < $textlen) { + if (($wordpos = @JString::strpos($text, ' ', $pos + $length)) !== false) { + $chunk_size = $wordpos - $pos; + } else { + $chunk_size = $length; + } + $chunk = JString::substr($text, $pos, $chunk_size); + $wordfound = JString::strpos(JString::strtolower($chunk), $lsearchword); + if ($wordfound === false) { + $pos += $chunk_size + 1; + } + } + + if ($wordfound !== false) { + return (($pos > 0) ? '... ' : '') . $chunk . ' ...'; + } else { + if (($wordpos = @JString::strpos($text, ' ', $length)) !== false) { + return JString::substr($text, 0, $wordpos) . ' ...'; + } else { + return JString::substr($text, 0, $length); + } + } + } +} diff --git a/oss/joomla/trunk/administrator/components/com_search/helpers/site.php b/oss/joomla/trunk/administrator/components/com_search/helpers/site.php index 659400e8..330f6b1e 100644 --- a/oss/joomla/trunk/administrator/components/com_search/helpers/site.php +++ b/oss/joomla/trunk/administrator/components/com_search/helpers/site.php @@ -1,38 +1,38 @@ -setQuery( 'DELETE FROM #__core_log_searches' ); - $db->query(); - } - - function getItems( ) - { - global $mainframe, $option; - $db =& JFactory::getDBO(); - - $filter_order = $mainframe->getUserStateFromRequest( 'com_search.filter_order', 'filter_order', 'hits', 'cmd' ); - $filter_order_Dir = $mainframe->getUserStateFromRequest( 'com_search.filter_order_Dir', 'filter_order_Dir', '', 'word' ); - $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); - $limitstart = $mainframe->getUserStateFromRequest( 'com_search.limitstart', 'limitstart', 0, 'int' ); - $search = $mainframe->getUserStateFromRequest( 'com_search.search', 'search', '', 'string' ); - $search = JString::strtolower( $search ); - $showResults = JRequest::getInt('search_results'); - - // table ordering - if ( $filter_order_Dir == 'ASC' ) { - $this->lists['order_Dir'] = 'ASC'; - } else { - $this->lists['order_Dir'] = 'DESC'; - } - $this->lists['order'] = $filter_order; - - // search filter - $this->lists['search']= $search; - - $where = array(); - if ($search) { - $where[] = 'LOWER( search_term ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); - } - - $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); - $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', hits DESC'; - - // get the total number of records - $query = 'SELECT COUNT(*)' - . ' FROM #__core_log_searches' - . $where; - $db->setQuery( $query ); - $total = $db->loadResult(); - - jimport( 'joomla.html.pagination' ); - $pageNav = new JPagination( $total, $limitstart, $limit ); - - $query = ' SELECT * ' - . ' FROM #__core_log_searches ' - . $where - . $orderby; - $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); - - $rows = $db->loadObjectList(); - - JPluginHelper::importPlugin( 'search' ); - - if (!class_exists( 'JSite' )) - { - // This fools the routers in the search plugins into thinking it's in the frontend - require_once( JPATH_COMPONENT.DS.'helpers'.DS.'site.php' ); - } - - for ($i=0, $n = count($rows); $i < $n; $i++) { - // determine if number of results for search item should be calculated - // by default it is `off` as it is highly query intensive - if ( $showResults ) { - $results = $mainframe->triggerEvent( 'onSearch', array( $rows[$i]->search_term ) ); - - $count = 0; - for ($j = 0, $n2 = count( $results ); $j < $n2; $j++) { - $count += count( $results[$j] ); - } - - $rows[$i]->returns = $count; - } else { - $rows[$i]->returns = null; - } - } - - return $rows; - } +setQuery( 'DELETE FROM #__core_log_searches' ); + $db->query(); + } + + function getItems( ) + { + global $mainframe, $option; + $db =& JFactory::getDBO(); + + $filter_order = $mainframe->getUserStateFromRequest( 'com_search.filter_order', 'filter_order', 'hits', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( 'com_search.filter_order_Dir', 'filter_order_Dir', '', 'word' ); + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( 'com_search.limitstart', 'limitstart', 0, 'int' ); + $search = $mainframe->getUserStateFromRequest( 'com_search.search', 'search', '', 'string' ); + if (strpos($search, '"') !== false) { + $search = str_replace(array('=', '<'), '', $search); + } + $search = JString::strtolower($search); + $showResults = JRequest::getInt('search_results'); + + // table ordering + if ( $filter_order_Dir == 'ASC' ) { + $this->lists['order_Dir'] = 'ASC'; + } else { + $this->lists['order_Dir'] = 'DESC'; + } + $this->lists['order'] = $filter_order; + + // search filter + $this->lists['search']= $search; + + $where = array(); + if ($search) { + $where[] = 'LOWER( search_term ) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + + $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); + $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', hits DESC'; + + // get the total number of records + $query = 'SELECT COUNT(*)' + . ' FROM #__core_log_searches' + . $where; + $db->setQuery( $query ); + $total = $db->loadResult(); + + jimport( 'joomla.html.pagination' ); + $pageNav = new JPagination( $total, $limitstart, $limit ); + + $query = ' SELECT * ' + . ' FROM #__core_log_searches ' + . $where + . $orderby; + $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); + + $rows = $db->loadObjectList(); + + JPluginHelper::importPlugin( 'search' ); + + if (!class_exists( 'JSite' )) + { + // This fools the routers in the search plugins into thinking it's in the frontend + require_once( JPATH_COMPONENT.DS.'helpers'.DS.'site.php' ); + } + + for ($i=0, $n = count($rows); $i < $n; $i++) { + // determine if number of results for search item should be calculated + // by default it is `off` as it is highly query intensive + if ( $showResults ) { + $results = $mainframe->triggerEvent( 'onSearch', array( $rows[$i]->search_term ) ); + + $count = 0; + for ($j = 0, $n2 = count( $results ); $j < $n2; $j++) { + $count += count( $results[$j] ); + } + + $rows[$i]->returns = $count; + } else { + $rows[$i]->returns = null; + } + } + + return $rows; + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_search/search.php b/oss/joomla/trunk/administrator/components/com_search/search.php index 9964b045..f3adb6d4 100644 --- a/oss/joomla/trunk/administrator/components/com_search/search.php +++ b/oss/joomla/trunk/administrator/components/com_search/search.php @@ -1,22 +1,22 @@ -execute( JRequest::getCmd( 'task' ) ); +execute( JRequest::getCmd( 'task' ) ); $controller->redirect(); \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_search/search.xml b/oss/joomla/trunk/administrator/components/com_search/search.xml index 4c829243..1bcf47f2 100644 --- a/oss/joomla/trunk/administrator/components/com_search/search.xml +++ b/oss/joomla/trunk/administrator/components/com_search/search.xml @@ -1,12 +1,12 @@ - - - Search - Joomla! Project - 2006 - Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - admin@joomla.org - www.joomla.org - 1.5.0 - DESCSEARCH - + + + Search + Joomla! Project + 2006 + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + DESCSEARCH + diff --git a/oss/joomla/trunk/administrator/components/com_search/views/search/view.php b/oss/joomla/trunk/administrator/components/com_search/views/search/view.php index 8e43bb66..57d7a351 100644 --- a/oss/joomla/trunk/administrator/components/com_search/views/search/view.php +++ b/oss/joomla/trunk/administrator/components/com_search/views/search/view.php @@ -1,64 +1,68 @@ -setTitle(JText::_('Search Statistics')); - - $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); - $limitstart = $mainframe->getUserStateFromRequest( 'com_search.limitstart', 'limitstart', 0, 'int' ); - - $model = $this->getModel(); - $items = $model->getItems(); - $params = &JComponentHelper::getParams( 'com_search' ); - $enabled = $params->get('enabled'); - JHTML::_('behavior.tooltip'); - jimport('joomla.html.pagination'); - $pageNav = new JPagination( count($items), $limitstart, $limit ); - - $showResults = JRequest::getInt('search_results'); - - $search = $mainframe->getUserStateFromRequest( 'com_search.search', 'search', '', 'string' ); - - $this->assignRef('items', $items); - $this->assignRef('enabled', $enabled); - $this->assignRef('pageNav', $pageNav); - $this->assignRef('search', $search ); - $this->assignRef('lists', $model->lists ); - - $this->assignRef('showResults', $showResults); - - parent::display($tpl); - } +setTitle(JText::_('Search Statistics')); + + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( 'com_search.limitstart', 'limitstart', 0, 'int' ); + + $model = $this->getModel(); + $items = $model->getItems(); + $params = &JComponentHelper::getParams( 'com_search' ); + $enabled = $params->get('enabled'); + JHTML::_('behavior.tooltip'); + jimport('joomla.html.pagination'); + $pageNav = new JPagination( count($items), $limitstart, $limit ); + + $showResults = JRequest::getInt('search_results'); + + $search = $mainframe->getUserStateFromRequest( 'com_search.search', 'search', '', 'string' ); + if (strpos($search, '"') !== false) { + $search = str_replace(array('=', '<'), '', $search); + } + $search = JString::strtolower($search); + + $this->assignRef('items', $items); + $this->assignRef('enabled', $enabled); + $this->assignRef('pageNav', $pageNav); + $this->assignRef('search', $search ); + $this->assignRef('lists', $model->lists ); + + $this->assignRef('showResults', $showResults); + + parent::display($tpl); + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_sections/admin.sections.html.php b/oss/joomla/trunk/administrator/components/com_sections/admin.sections.html.php index a05c7a45..dca86dfd 100644 --- a/oss/joomla/trunk/administrator/components/com_sections/admin.sections.html.php +++ b/oss/joomla/trunk/administrator/components/com_sections/admin.sections.html.php @@ -1,435 +1,435 @@ - -
    - - - - - - -
    - : - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - id; - - $access = JHTML::_('grid.access', $row, $i ); - $checked = JHTML::_('grid.checkedout', $row, $i ); - $published = JHTML::_('grid.published', $row, $i ); - ?> - "> - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - -
    - getListFooter(); ?> -
    - getRowOffset( $i ); ?> - - - - - get ('id'), $row->checked_out ) ) { - echo $row->title; - } else { - ?> - - title; ?> - - - - - orderUpIcon( $i, true, 'orderup', 'Move Up', $ordering ); ?> - orderDownIcon( $i, $n, true, 'orderdown', 'Move Down', $ordering ); ?> - - class="text_area" style="text-align: center" /> - - - - categories; ?> - - active; ?> - - trash; ?> - - id; ?> -
    - - - - - - - - - - -
    - $row is passed with the id - * property set to 0. Note that the section property must be defined - * even for a new record. - * @param JTableCategory The category object - * @param string The html for the image list select list - * @param string The html for the image position select list - * @param string The html for the ordering list - * @param string The html for the groups select list - */ - function edit( &$row, $option, &$lists ) - { - JRequest::setVar( 'hidemainmenu', 1 ); - - global $mainframe; - - $editor =& JFactory::getEditor(); - - if ( $row->name != '' ) { - $name = $row->name; - } else { - $name = JText::_( 'New Section' ); - } - if ($row->image == '') { - $row->image = 'blank.png'; - } - - JFilterOutput::objectHTMLSafe( $row, ENT_QUOTES, 'description' ); - ?> - - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - : - - - scope; ?> - -
    - - - -
    - - - -
    - : - - -
    - - - -
    - - - - - image != 'blank.png') { - $path.= 'stories/'; - } - ?> - <?php echo JText::_( 'Preview' ); ?> -
    - - - -
    - - - -
    -
    - -
    - - - - - - -
    - display( 'description', $row->description, '550', '300', '60', '20', array('pagebreak', 'readmore') ) ; - ?> -
    -
    -
    -
    - - - - - - - -
    - - -
    - - - - - - - - . - -
    - : -
    - -

    -
    - : -
    - "; - foreach ( $categories as $category ) { - echo "
  • ". $category->title ."
  • "; - echo "\n id\" />"; - } - echo ""; - ?> -
    - : -
    - "; - foreach ( $contents as $content ) { - echo "
  • ". $content->title ."
  • "; - echo "\n id\" />"; - } - echo ""; - ?> -
    - -
    - -
    - -
    -

    - - - - - - - "; - } - ?> - -
    - +
    + + + + + + +
    + : + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + id; + + $access = JHTML::_('grid.access', $row, $i ); + $checked = JHTML::_('grid.checkedout', $row, $i ); + $published = JHTML::_('grid.published', $row, $i ); + ?> + "> + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + +
    + getListFooter(); ?> +
    + getRowOffset( $i ); ?> + + + + + get ('id'), $row->checked_out ) ) { + echo $row->title; + } else { + ?> + + title; ?> + + + + + orderUpIcon( $i, true, 'orderup', 'Move Up', $ordering ); ?> + orderDownIcon( $i, $n, true, 'orderdown', 'Move Down', $ordering ); ?> + + class="text_area" style="text-align: center" /> + + + + categories; ?> + + active; ?> + + trash; ?> + + id; ?> +
    + + + + + + + + + + +
    + $row is passed with the id + * property set to 0. Note that the section property must be defined + * even for a new record. + * @param JTableCategory The category object + * @param string The html for the image list select list + * @param string The html for the image position select list + * @param string The html for the ordering list + * @param string The html for the groups select list + */ + function edit( &$row, $option, &$lists ) + { + JRequest::setVar( 'hidemainmenu', 1 ); + + global $mainframe; + + $editor =& JFactory::getEditor(); + + if ( $row->name != '' ) { + $name = $row->name; + } else { + $name = JText::_( 'New Section' ); + } + if ($row->image == '') { + $row->image = 'blank.png'; + } + + JFilterOutput::objectHTMLSafe( $row, ENT_QUOTES, 'description' ); + ?> + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + : + + + scope; ?> + +
    + + + +
    + + + +
    + : + + +
    + + + +
    + + + + + image != 'blank.png') { + $path.= 'stories/'; + } + ?> + <?php echo JText::_( 'Preview' ); ?> +
    + + + +
    + + + +
    +
    + +
    + + + + + + +
    + display( 'description', $row->description, '550', '300', '60', '20', array('pagebreak', 'readmore') ) ; + ?> +
    +
    +
    +
    + + + + + + + +
    + + +
    + + + + + + + + . + +
    + : +
    + +

    +
    + : +
    + "; + foreach ( $categories as $category ) { + echo "
  • ". $category->title ."
  • "; + echo "\n id\" />"; + } + echo ""; + ?> +
    + : +
    + "; + foreach ( $contents as $content ) { + echo "
  • ". $content->title ."
  • "; + echo "\n id\" />"; + } + echo ""; + ?> +
    + +
    + +
    + +
    +

    + + + + + + + "; + } + ?> + +
    + getUserStateFromRequest( $option.'.filter_order', 'filter_order', 's.ordering', 'cmd' ); - $filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'.filter_order_Dir', 'filter_order_Dir', '', 'word' ); - $filter_state = $mainframe->getUserStateFromRequest( $option.'.filter_state', 'filter_state', '', 'word' ); - $search = $mainframe->getUserStateFromRequest( $option.'.search', 'search', '', 'string' ); - $search = JString::strtolower( $search ); - - $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); - $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); - - $where[] = 's.scope = '.$db->Quote($scope); - - if ( $filter_state ) { - if ( $filter_state == 'P' ) { - $where[] = 's.published = 1'; - } else if ($filter_state == 'U' ) { - $where[] = 's.published = 0'; - } - } - if ($search) { - $where[] = 'LOWER(s.title) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); - } - - $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); - $orderby = ' ORDER BY '.$filter_order.' '. $filter_order_Dir .', s.ordering'; - - // get the total number of records - $query = 'SELECT COUNT(*)' - . ' FROM #__sections AS s' - . $where - ; - $db->setQuery( $query ); - $total = $db->loadResult(); - - jimport('joomla.html.pagination'); - $pageNav = new JPagination( $total, $limitstart, $limit ); - - $query = 'SELECT s.*, g.name AS groupname, u.name AS editor' - . ' FROM #__sections AS s' - . ' LEFT JOIN #__content AS cc ON s.id = cc.sectionid' - . ' LEFT JOIN #__users AS u ON u.id = s.checked_out' - . ' LEFT JOIN #__groups AS g ON g.id = s.access' - . $where - . ' GROUP BY s.id' - . $orderby - ; - $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); - $rows = $db->loadObjectList(); - if ($db->getErrorNum()) { - echo $db->stderr(); - return false; - } - - $count = count( $rows ); - // number of Active Categories - for ( $i = 0; $i < $count; $i++ ) { - $query = 'SELECT COUNT( a.id )' - . ' FROM #__categories AS a' - . ' WHERE a.section = '.$db->Quote($rows[$i]->id) - . ' AND a.published <> -2' - ; - $db->setQuery( $query ); - $active = $db->loadResult(); - $rows[$i]->categories = $active; - } - // number of Active Items - for ( $i = 0; $i < $count; $i++ ) { - $query = 'SELECT COUNT( a.id )' - . ' FROM #__content AS a' - . ' WHERE a.sectionid = '.(int) $rows[$i]->id - . ' AND a.state <> -2' - ; - $db->setQuery( $query ); - $active = $db->loadResult(); - $rows[$i]->active = $active; - } - // number of Trashed Items - for ( $i = 0; $i < $count; $i++ ) { - $query = 'SELECT COUNT( a.id )' - . ' FROM #__content AS a' - . ' WHERE a.sectionid = '.(int) $rows[$i]->id - . ' AND a.state = -2' - ; - $db->setQuery( $query ); - $trash = $db->loadResult(); - $rows[$i]->trash = $trash; - } - - // state filter - $lists['state'] = JHTML::_('grid.state', $filter_state ); - - // table ordering - $lists['order_Dir'] = $filter_order_Dir; - $lists['order'] = $filter_order; - - // search filter - $lists['search']= $search; - - sections_html::show( $rows, $scope, $user->get('id'), $pageNav, $option, $lists ); -} - -/** -* Compiles information to add or edit a section -* @param database A database connector object -* @param string The name of the category section -* @param integer The unique id of the category to edit (0 if new) -* @param string The name of the current user -*/ -function editSection( $edit) -{ - global $mainframe; - - $db =& JFactory::getDBO(); - $user =& JFactory::getUser(); - - $option = JRequest::getCmd( 'option'); - $scope = JRequest::getCmd( 'scope' ); - $cid = JRequest::getVar( 'cid', array(0), '', 'array' ); - JArrayHelper::toInteger($cid, array(0)); - - $row =& JTable::getInstance('section'); - // load the row from the db table - if ($edit) - $row->load( $cid[0] ); - - // fail if checked out not by 'me' - if ($row->isCheckedOut( $user->get('id') )) { - $msg = JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The section' ), $row->title ); - $mainframe->redirect( 'index.php?option='. $option .'&scope='. $row->scope, $msg ); - } - - if ( $edit ) { - $row->checkout( $user->get('id') ); - } else { - $row->scope = $scope; - $row->published = 1; - } - - // build the html select list for ordering - $query = 'SELECT ordering AS value, title AS text' - . ' FROM #__sections' - . ' WHERE scope='.$db->Quote($row->scope).' ORDER BY ordering' - ; - if($edit) - $lists['ordering'] = JHTML::_('list.specificordering', $row, $cid[0], $query ); - else - $lists['ordering'] = JHTML::_('list.specificordering', $row, '', $query ); - // build the select list for the image positions - $active = ( $row->image_position ? $row->image_position : 'left' ); - $lists['image_position'] = JHTML::_('list.positions', 'image_position', $active, NULL, 0 ); - // build the html select list for images - $lists['image'] = JHTML::_('list.images', 'image', $row->image ); - // build the html select list for the group access - $lists['access'] = JHTML::_('list.accesslevel', $row ); - // build the html radio buttons for published - $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $row->published ); - - sections_html::edit( $row, $option, $lists ); -} - -/** -* Saves the catefory after an edit form submit -* @param database A database connector object -* @param string The name of the category section -*/ -function saveSection( $option, $scope, $task ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $menu = JRequest::getVar( 'menu', 'mainmenu', 'post', 'string' ); - $menuid = JRequest::getVar( 'menuid', 0, 'post', 'int' ); - $oldtitle = JRequest::getVar( 'oldtitle', '', '', 'post', 'string' ); - - $post = JRequest::get('post'); - - // fix up special html fields - $post['description'] = JRequest::getVar( 'description', '', 'post', 'string', JREQUEST_ALLOWRAW ); - - $row =& JTable::getInstance('section'); - if (!$row->bind($post)) { - JError::raiseError(500, $row->getError() ); - } - if (!$row->check()) { - JError::raiseError(500, $row->getError() ); - } - if ( $oldtitle ) { - if ( $oldtitle <> $row->title ) { - $query = 'UPDATE #__menu' - . ' SET name = '.$db->Quote($row->title) - . ' WHERE name = '.$db->Quote($oldtitle) - . ' AND type = "content_section"' - ; - $db->setQuery( $query ); - $db->query(); - } - } - - // if new item order last in appropriate group - if (!$row->id) { - $row->ordering = $row->getNextOrder(); - } - - if (!$row->store()) { - JError::raiseError(500, $row->getError() ); - } - $row->checkin(); - - switch ( $task ) - { - case 'go2menu': - $mainframe->redirect( 'index.php?option=com_menus&menutype='. $menu ); - break; - - case 'go2menuitem': - $mainframe->redirect( 'index.php?option=com_menus&menutype='. $menu .'&task=edit&id='. $menuid ); - break; - - case 'apply': - $msg = JText::_( 'Changes to Section saved' ); - $mainframe->redirect( 'index.php?option='. $option .'&scope='. $scope .'&task=edit&cid[]='. $row->id, $msg ); - break; - - case 'save': - default: - $msg = JText::_( 'Section saved' ); - $mainframe->redirect( 'index.php?option='. $option .'&scope='. $scope, $msg ); - break; - } -} -/** -* Deletes one or more categories from the categories table -* @param database A database connector object -* @param string The name of the category section -* @param array An array of unique category id numbers -*/ -function removeSections( $cid, $scope, $option ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - if (count( $cid ) < 1) { - JError::raiseError(500, JText::_( 'Select a section to delete', true ) ); - } - - JArrayHelper::toInteger( $cid ); - $cids = implode( ',', $cid ); - - $query = 'SELECT s.id, s.title, COUNT(c.id) AS numcat' - . ' FROM #__sections AS s' - . ' LEFT JOIN #__categories AS c ON c.section=s.id' - . ' WHERE s.id IN ( '.$cids.' )' - . ' GROUP BY s.id' - ; - $db->setQuery( $query ); - if (!($rows = $db->loadObjectList())) { - echo "\n"; - } - - $name = array(); - $err = array(); - $cid = array(); - foreach ($rows as $row) { - if ($row->numcat == 0) { - $cid[] = (int) $row->id; - $name[] = $row->title; - } else { - $err[] = $row->title; - } - } - - if (count( $cid )) - { - $cids = implode( ',', $cid ); - $query = 'DELETE FROM #__sections' - . ' WHERE id IN ( '.$cids.' )' - ; - $db->setQuery( $query ); - if (!$db->query()) { - echo "\n"; - } - } - - if (count( $err )) - { - $cids = implode( ', ', $err ); - $msg = JText::sprintf( 'DESCCANNOTBEREMOVED', $cids ); - $mainframe->redirect( 'index.php?option='. $option .'&scope='. $scope, $msg ); - } - - $names = implode( ', ', $name ); - $msg = JText::sprintf( 'Sections successfully deleted', $names ); - $mainframe->redirect( 'index.php?option='. $option .'&scope='. $scope, $msg ); -} - -/** -* Publishes or Unpublishes one or more categories -* @param database A database connector object -* @param string The name of the category section -* @param integer A unique category id (passed from an edit form) -* @param array An array of unique category id numbers -* @param integer 0 if unpublishing, 1 if publishing -* @param string The name of the current user -*/ -function publishSections( $scope, $cid=null, $publish=1, $option ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $user =& JFactory::getUser(); - - JArrayHelper::toInteger($cid); - - if ( count( $cid ) < 1 ) { - $action = $publish ? 'publish' : 'unpublish'; - JError::raiseError(500, JText::_( 'Select a section to '.$action, true ) ); - } - - $cids = implode( ',', $cid ); - $count = count( $cid ); - $query = 'UPDATE #__sections' - . ' SET published = '.(int) $publish - . ' WHERE id IN ( '.$cids.' )' - . ' AND ( checked_out = 0 OR ( checked_out = '.(int) $user->get('id').' ) )' - ; - $db->setQuery( $query ); - if (!$db->query()) { - JError::raiseError(500, $db->getErrorMsg() ); - } - - if ( $count == 1 ) { - $row =& JTable::getInstance('section'); - $row->checkin( $cid[0] ); - } - - // check if section linked to menu items if unpublishing - if ( $publish == 0 ) { - $query = 'SELECT id' - . ' FROM #__menu' - . ' WHERE type = "content_section"' - . ' AND componentid IN ( '.$cids.' )' - ; - $db->setQuery( $query ); - $menus = $db->loadObjectList(); - - if ($menus) { - foreach ($menus as $menu) { - $query = 'UPDATE #__menu' - . ' SET published = '.(int) $publish - . ' WHERE id = '.(int) $menu->id - ; - $db->setQuery( $query ); - $db->query(); - } - } - } - - $mainframe->redirect( 'index.php?option='. $option .'&scope='. $scope ); -} - -/** -* Cancels an edit operation -* @param database A database connector object -* @param string The name of the category section -* @param integer A unique category id -*/ -function cancelSection( $option, $scope ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $row =& JTable::getInstance('section'); - $row->bind(JRequest::get('post')); - $row->checkin(); - - $mainframe->redirect( 'index.php?option='. $option .'&scope='. $scope ); -} - -/** -* Moves the order of a record -* @param integer The increment to reorder by -*/ -function orderSection( $uid, $inc, $option, $scope ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $row =& JTable::getInstance('section'); - $row->load( $uid ); - $row->move( $inc, 'scope = '.$db->Quote($row->scope) ); - - $mainframe->redirect( 'index.php?option='. $option .'&scope='. $scope ); -} - -/** -* Form for copying item(s) to a specific menu -*/ -function copySectionSelect( $option, $cid, $section ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - - JArrayHelper::toInteger($cid); - - if ( count( $cid ) < 1) { - JError::raiseError(500, JText::_( 'Select an item to move', true ) ); - } - - ## query to list selected categories - $cids = implode( ',', $cid ); - $query = 'SELECT a.title, a.id' - . ' FROM #__categories AS a' - . ' WHERE a.section IN ( '.$cids.' )' - ; - $db->setQuery( $query ); - $categories = $db->loadObjectList(); - - ## query to list items from categories - $query = 'SELECT a.title, a.id' - . ' FROM #__content AS a' - . ' WHERE a.sectionid IN ( '.$cids.' )' - . ' ORDER BY a.sectionid, a.catid, a.title' - ; - $db->setQuery( $query ); - $contents = $db->loadObjectList(); - - sections_html::copySectionSelect( $option, $cid, $categories, $contents, $section ); -} - - -/** -* Save the item(s) to the menu selected -*/ -function copySectionSave( $sectionid, $scope ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $title = JRequest::getString( 'title' ); - $contentid = JRequest::getVar( 'content' ); - $categoryid = JRequest::getVar( 'category' ); - JArrayHelper::toInteger($contentid); - JArrayHelper::toInteger($categoryid); - - // copy section - $section =& JTable::getInstance('section'); - foreach( $sectionid as $id ) { - $section->load( $id ); - $section->id = NULL; - $section->title = $title; - $section->name = $title; - if ( !$section->check() ) { - copySectionSelect('com_sections', $sectionid, $scope ); - JError::raiseWarning(500, $section->getError() ); - return; - } - - if ( !$section->store() ) { - JError::raiseError(500, $section->getError() ); - } - $section->checkin(); - $section->reorder( 'scope = '.$db->Quote($section->scope) ); - // stores original catid - $newsectids[]["old"] = $id; - // pulls new catid - $newsectids[]["new"] = $section->id; - } - $sectionMove = $section->id; - - // copy categories - $category =& JTable::getInstance('category'); - foreach( $categoryid as $id ) { - $category->load( $id ); - $category->id = NULL; - $category->section = $sectionMove; - foreach( $newsectids as $newsectid ) { - if ( $category->section == $newsectid["old"] ) { - $category->section = $newsectid["new"]; - } - } - if (!$category->check()) { - JError::raiseError(500, $category->getError() ); - } - - if (!$category->store()) { - JError::raiseError(500, $category->getError() ); - } - $category->checkin(); - $category->reorder( 'section = '.$db->Quote($category->section) ); - // stores original catid - $newcatids[]["old"] = $id; - // pulls new catid - $newcatids[]["new"] = $category->id; - } - - $content =& JTable::getInstance('content'); - foreach( $contentid as $id) { - $content->load( $id ); - $content->id = NULL; - $content->hits = 0; - foreach( $newsectids as $newsectid ) { - if ( $content->sectionid == $newsectid["old"] ) { - $content->sectionid = $newsectid["new"]; - } - } - foreach( $newcatids as $newcatid ) { - if ( $content->catid == $newcatid["old"] ) { - $content->catid = $newcatid["new"]; - } - } - if (!$content->check()) { - JError::raiseError(500, $content->getError() ); - } - - if (!$content->store()) { - JError::raiseError(500, $content->getError() ); - } - $content->checkin(); - } - $sectionOld =& JTable::getInstance('section'); - $sectionOld->load( $sectionMove ); - - $msg = JText::sprintf( 'DESCCATANDITEMSCOPIED', $sectionOld-> name, $title ); - $mainframe->redirect( 'index.php?option=com_sections&scope=content', $msg ); -} - -/** -* changes the access level of a record -* @param integer The increment to reorder by -*/ -function accessMenu( $uid, $access, $option ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $row =& JTable::getInstance('section'); - $row->load( $uid ); - $row->access = $access; - - if ( !$row->check() ) { - return $row->getError(); - } - if ( !$row->store() ) { - return $row->getError(); - } - - $mainframe->redirect( 'index.php?option='. $option .'&scope='. $row->scope ); -} - -function saveOrder( &$cid ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $row =& JTable::getInstance('section'); - - $total = count( $cid ); - $order = JRequest::getVar( 'order', array(0), 'post', 'array' ); - JArrayHelper::toInteger($order, array(0)); - - // update ordering values - for( $i=0; $i < $total; $i++ ) - { - $row->load( (int) $cid[$i] ); - if ($row->ordering != $order[$i]) { - $row->ordering = $order[$i]; - if (!$row->store()) { - JError::raiseError(500, $db->getErrorMsg() ); - } - } - } - - $row->reorder( ); - - $msg = JText::_( 'New ordering saved' ); - $mainframe->redirect( 'index.php?option=com_sections&scope=content', $msg ); +getUserStateFromRequest( $option.'.filter_order', 'filter_order', 's.ordering', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'.filter_order_Dir', 'filter_order_Dir', '', 'word' ); + $filter_state = $mainframe->getUserStateFromRequest( $option.'.filter_state', 'filter_state', '', 'word' ); + $search = $mainframe->getUserStateFromRequest( $option.'.search', 'search', '', 'string' ); + if (strpos($search, '"') !== false) { + $search = str_replace(array('=', '<'), '', $search); + } + $search = JString::strtolower($search); + + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); + + $where[] = 's.scope = '.$db->Quote($scope); + + if ( $filter_state ) { + if ( $filter_state == 'P' ) { + $where[] = 's.published = 1'; + } else if ($filter_state == 'U' ) { + $where[] = 's.published = 0'; + } + } + if ($search) { + $where[] = 'LOWER(s.title) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + + $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); + $orderby = ' ORDER BY '.$filter_order.' '. $filter_order_Dir .', s.ordering'; + + // get the total number of records + $query = 'SELECT COUNT(*)' + . ' FROM #__sections AS s' + . $where + ; + $db->setQuery( $query ); + $total = $db->loadResult(); + + jimport('joomla.html.pagination'); + $pageNav = new JPagination( $total, $limitstart, $limit ); + + $query = 'SELECT s.*, g.name AS groupname, u.name AS editor' + . ' FROM #__sections AS s' + . ' LEFT JOIN #__content AS cc ON s.id = cc.sectionid' + . ' LEFT JOIN #__users AS u ON u.id = s.checked_out' + . ' LEFT JOIN #__groups AS g ON g.id = s.access' + . $where + . ' GROUP BY s.id' + . $orderby + ; + $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); + $rows = $db->loadObjectList(); + if ($db->getErrorNum()) { + echo $db->stderr(); + return false; + } + + $count = count( $rows ); + // number of Active Categories + for ( $i = 0; $i < $count; $i++ ) { + $query = 'SELECT COUNT( a.id )' + . ' FROM #__categories AS a' + . ' WHERE a.section = '.$db->Quote($rows[$i]->id) + . ' AND a.published <> -2' + ; + $db->setQuery( $query ); + $active = $db->loadResult(); + $rows[$i]->categories = $active; + } + // number of Active Items + for ( $i = 0; $i < $count; $i++ ) { + $query = 'SELECT COUNT( a.id )' + . ' FROM #__content AS a' + . ' WHERE a.sectionid = '.(int) $rows[$i]->id + . ' AND a.state <> -2' + ; + $db->setQuery( $query ); + $active = $db->loadResult(); + $rows[$i]->active = $active; + } + // number of Trashed Items + for ( $i = 0; $i < $count; $i++ ) { + $query = 'SELECT COUNT( a.id )' + . ' FROM #__content AS a' + . ' WHERE a.sectionid = '.(int) $rows[$i]->id + . ' AND a.state = -2' + ; + $db->setQuery( $query ); + $trash = $db->loadResult(); + $rows[$i]->trash = $trash; + } + + // state filter + $lists['state'] = JHTML::_('grid.state', $filter_state ); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search']= $search; + + sections_html::show( $rows, $scope, $user->get('id'), $pageNav, $option, $lists ); +} + +/** +* Compiles information to add or edit a section +* @param database A database connector object +* @param string The name of the category section +* @param integer The unique id of the category to edit (0 if new) +* @param string The name of the current user +*/ +function editSection( $edit) +{ + global $mainframe; + + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + + $option = JRequest::getCmd( 'option'); + $scope = JRequest::getCmd( 'scope' ); + $cid = JRequest::getVar( 'cid', array(0), '', 'array' ); + JArrayHelper::toInteger($cid, array(0)); + + $row =& JTable::getInstance('section'); + // load the row from the db table + if ($edit) + $row->load( $cid[0] ); + + // fail if checked out not by 'me' + if ($row->isCheckedOut( $user->get('id') )) { + $msg = JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The section' ), $row->title ); + $mainframe->redirect( 'index.php?option='. $option .'&scope='. $row->scope, $msg ); + } + + if ( $edit ) { + $row->checkout( $user->get('id') ); + } else { + $row->scope = $scope; + $row->published = 1; + } + + // build the html select list for ordering + $query = 'SELECT ordering AS value, title AS text' + . ' FROM #__sections' + . ' WHERE scope='.$db->Quote($row->scope).' ORDER BY ordering' + ; + if($edit) + $lists['ordering'] = JHTML::_('list.specificordering', $row, $cid[0], $query ); + else + $lists['ordering'] = JHTML::_('list.specificordering', $row, '', $query ); + // build the select list for the image positions + $active = ( $row->image_position ? $row->image_position : 'left' ); + $lists['image_position'] = JHTML::_('list.positions', 'image_position', $active, NULL, 0 ); + // build the html select list for images + $lists['image'] = JHTML::_('list.images', 'image', $row->image ); + // build the html select list for the group access + $lists['access'] = JHTML::_('list.accesslevel', $row ); + // build the html radio buttons for published + $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $row->published ); + + sections_html::edit( $row, $option, $lists ); +} + +/** +* Saves the catefory after an edit form submit +* @param database A database connector object +* @param string The name of the category section +*/ +function saveSection( $option, $scope, $task ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $menu = JRequest::getVar( 'menu', 'mainmenu', 'post', 'string' ); + $menuid = JRequest::getVar( 'menuid', 0, 'post', 'int' ); + $oldtitle = JRequest::getVar( 'oldtitle', '', '', 'post', 'string' ); + + $post = JRequest::get('post'); + + // fix up special html fields + $post['description'] = JRequest::getVar( 'description', '', 'post', 'string', JREQUEST_ALLOWRAW ); + + $row =& JTable::getInstance('section'); + if (!$row->bind($post)) { + JError::raiseError(500, $row->getError() ); + } + if (!$row->check()) { + JError::raiseError(500, $row->getError() ); + } + if ( $oldtitle ) { + if ( $oldtitle <> $row->title ) { + $query = 'UPDATE #__menu' + . ' SET name = '.$db->Quote($row->title) + . ' WHERE name = '.$db->Quote($oldtitle) + . ' AND type = "content_section"' + ; + $db->setQuery( $query ); + $db->query(); + } + } + + // if new item order last in appropriate group + if (!$row->id) { + $row->ordering = $row->getNextOrder(); + } + + if (!$row->store()) { + JError::raiseError(500, $row->getError() ); + } + $row->checkin(); + + switch ( $task ) + { + case 'go2menu': + $mainframe->redirect( 'index.php?option=com_menus&menutype='. $menu ); + break; + + case 'go2menuitem': + $mainframe->redirect( 'index.php?option=com_menus&menutype='. $menu .'&task=edit&id='. $menuid ); + break; + + case 'apply': + $msg = JText::_( 'Changes to Section saved' ); + $mainframe->redirect( 'index.php?option='. $option .'&scope='. $scope .'&task=edit&cid[]='. $row->id, $msg ); + break; + + case 'save': + default: + $msg = JText::_( 'Section saved' ); + $mainframe->redirect( 'index.php?option='. $option .'&scope='. $scope, $msg ); + break; + } +} +/** +* Deletes one or more categories from the categories table +* @param database A database connector object +* @param string The name of the category section +* @param array An array of unique category id numbers +*/ +function removeSections( $cid, $scope, $option ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + if (count( $cid ) < 1) { + JError::raiseError(500, JText::_( 'Select a section to delete', true ) ); + } + + JArrayHelper::toInteger( $cid ); + $cids = implode( ',', $cid ); + + $query = 'SELECT s.id, s.title, COUNT(c.id) AS numcat' + . ' FROM #__sections AS s' + . ' LEFT JOIN #__categories AS c ON c.section=s.id' + . ' WHERE s.id IN ( '.$cids.' )' + . ' GROUP BY s.id' + ; + $db->setQuery( $query ); + if (!($rows = $db->loadObjectList())) { + echo "\n"; + } + + $name = array(); + $err = array(); + $cid = array(); + foreach ($rows as $row) { + if ($row->numcat == 0) { + $cid[] = (int) $row->id; + $name[] = $row->title; + } else { + $err[] = $row->title; + } + } + + if (count( $cid )) + { + $cids = implode( ',', $cid ); + $query = 'DELETE FROM #__sections' + . ' WHERE id IN ( '.$cids.' )' + ; + $db->setQuery( $query ); + if (!$db->query()) { + echo "\n"; + } + } + + if (count( $err )) + { + $cids = implode( ', ', $err ); + $msg = JText::sprintf( 'DESCCANNOTBEREMOVED', $cids ); + $mainframe->redirect( 'index.php?option='. $option .'&scope='. $scope, $msg ); + } + + $names = implode( ', ', $name ); + $msg = JText::sprintf( 'Sections successfully deleted', $names ); + $mainframe->redirect( 'index.php?option='. $option .'&scope='. $scope, $msg ); +} + +/** +* Publishes or Unpublishes one or more categories +* @param database A database connector object +* @param string The name of the category section +* @param integer A unique category id (passed from an edit form) +* @param array An array of unique category id numbers +* @param integer 0 if unpublishing, 1 if publishing +* @param string The name of the current user +*/ +function publishSections( $scope, $cid=null, $publish=1, $option ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + + JArrayHelper::toInteger($cid); + + if ( count( $cid ) < 1 ) { + $action = $publish ? 'publish' : 'unpublish'; + JError::raiseError(500, JText::_( 'Select a section to '.$action, true ) ); + } + + $cids = implode( ',', $cid ); + $count = count( $cid ); + $query = 'UPDATE #__sections' + . ' SET published = '.(int) $publish + . ' WHERE id IN ( '.$cids.' )' + . ' AND ( checked_out = 0 OR ( checked_out = '.(int) $user->get('id').' ) )' + ; + $db->setQuery( $query ); + if (!$db->query()) { + JError::raiseError(500, $db->getErrorMsg() ); + } + + if ( $count == 1 ) { + $row =& JTable::getInstance('section'); + $row->checkin( $cid[0] ); + } + + // check if section linked to menu items if unpublishing + if ( $publish == 0 ) { + $query = 'SELECT id' + . ' FROM #__menu' + . ' WHERE type = "content_section"' + . ' AND componentid IN ( '.$cids.' )' + ; + $db->setQuery( $query ); + $menus = $db->loadObjectList(); + + if ($menus) { + foreach ($menus as $menu) { + $query = 'UPDATE #__menu' + . ' SET published = '.(int) $publish + . ' WHERE id = '.(int) $menu->id + ; + $db->setQuery( $query ); + $db->query(); + } + } + } + + $mainframe->redirect( 'index.php?option='. $option .'&scope='. $scope ); +} + +/** +* Cancels an edit operation +* @param database A database connector object +* @param string The name of the category section +* @param integer A unique category id +*/ +function cancelSection( $option, $scope ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $row =& JTable::getInstance('section'); + $row->bind(JRequest::get('post')); + $row->checkin(); + + $mainframe->redirect( 'index.php?option='. $option .'&scope='. $scope ); +} + +/** +* Moves the order of a record +* @param integer The increment to reorder by +*/ +function orderSection( $uid, $inc, $option, $scope ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $row =& JTable::getInstance('section'); + $row->load( $uid ); + $row->move( $inc, 'scope = '.$db->Quote($row->scope) ); + + $mainframe->redirect( 'index.php?option='. $option .'&scope='. $scope ); +} + +/** +* Form for copying item(s) to a specific menu +*/ +function copySectionSelect( $option, $cid, $section ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + + JArrayHelper::toInteger($cid); + + if ( count( $cid ) < 1) { + JError::raiseError(500, JText::_( 'Select an item to move', true ) ); + } + + ## query to list selected categories + $cids = implode( ',', $cid ); + $query = 'SELECT a.title, a.id' + . ' FROM #__categories AS a' + . ' WHERE a.section IN ( '.$cids.' )' + ; + $db->setQuery( $query ); + $categories = $db->loadObjectList(); + + ## query to list items from categories + $query = 'SELECT a.title, a.id' + . ' FROM #__content AS a' + . ' WHERE a.sectionid IN ( '.$cids.' )' + . ' ORDER BY a.sectionid, a.catid, a.title' + ; + $db->setQuery( $query ); + $contents = $db->loadObjectList(); + + sections_html::copySectionSelect( $option, $cid, $categories, $contents, $section ); +} + + +/** +* Save the item(s) to the menu selected +*/ +function copySectionSave( $sectionid, $scope ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $title = JRequest::getString( 'title' ); + $contentid = JRequest::getVar( 'content' ); + $categoryid = JRequest::getVar( 'category' ); + JArrayHelper::toInteger($contentid); + JArrayHelper::toInteger($categoryid); + + // copy section + $section =& JTable::getInstance('section'); + foreach( $sectionid as $id ) { + $section->load( $id ); + $section->id = NULL; + $section->title = $title; + $section->name = $title; + if ( !$section->check() ) { + copySectionSelect('com_sections', $sectionid, $scope ); + JError::raiseWarning(500, $section->getError() ); + return; + } + + if ( !$section->store() ) { + JError::raiseError(500, $section->getError() ); + } + $section->checkin(); + $section->reorder( 'scope = '.$db->Quote($section->scope) ); + // stores original catid + $newsectids[]["old"] = $id; + // pulls new catid + $newsectids[]["new"] = $section->id; + } + $sectionMove = $section->id; + + // copy categories + $category =& JTable::getInstance('category'); + foreach( $categoryid as $id ) { + $category->load( $id ); + $category->id = NULL; + $category->section = $sectionMove; + foreach( $newsectids as $newsectid ) { + if ( $category->section == $newsectid["old"] ) { + $category->section = $newsectid["new"]; + } + } + if (!$category->check()) { + JError::raiseError(500, $category->getError() ); + } + + if (!$category->store()) { + JError::raiseError(500, $category->getError() ); + } + $category->checkin(); + $category->reorder( 'section = '.$db->Quote($category->section) ); + // stores original catid + $newcatids[]["old"] = $id; + // pulls new catid + $newcatids[]["new"] = $category->id; + } + + $content =& JTable::getInstance('content'); + foreach( $contentid as $id) { + $content->load( $id ); + $content->id = NULL; + $content->hits = 0; + foreach( $newsectids as $newsectid ) { + if ( $content->sectionid == $newsectid["old"] ) { + $content->sectionid = $newsectid["new"]; + } + } + foreach( $newcatids as $newcatid ) { + if ( $content->catid == $newcatid["old"] ) { + $content->catid = $newcatid["new"]; + } + } + if (!$content->check()) { + JError::raiseError(500, $content->getError() ); + } + + if (!$content->store()) { + JError::raiseError(500, $content->getError() ); + } + $content->checkin(); + } + $sectionOld =& JTable::getInstance('section'); + $sectionOld->load( $sectionMove ); + + $msg = JText::sprintf( 'DESCCATANDITEMSCOPIED', $sectionOld-> name, $title ); + $mainframe->redirect( 'index.php?option=com_sections&scope=content', $msg ); +} + +/** +* changes the access level of a record +* @param integer The increment to reorder by +*/ +function accessMenu( $uid, $access, $option ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $row =& JTable::getInstance('section'); + $row->load( $uid ); + $row->access = $access; + + if ( !$row->check() ) { + return $row->getError(); + } + if ( !$row->store() ) { + return $row->getError(); + } + + $mainframe->redirect( 'index.php?option='. $option .'&scope='. $row->scope ); +} + +function saveOrder( &$cid ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $row =& JTable::getInstance('section'); + + $total = count( $cid ); + $order = JRequest::getVar( 'order', array(0), 'post', 'array' ); + JArrayHelper::toInteger($order, array(0)); + + // update ordering values + for( $i=0; $i < $total; $i++ ) + { + $row->load( (int) $cid[$i] ); + if ($row->ordering != $order[$i]) { + $row->ordering = $order[$i]; + if (!$row->store()) { + JError::raiseError(500, $db->getErrorMsg() ); + } + } + } + + $row->reorder( ); + + $msg = JText::_( 'New ordering saved' ); + $mainframe->redirect( 'index.php?option=com_sections&scope=content', $msg ); } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_sections/toolbar.sections.html.php b/oss/joomla/trunk/administrator/components/com_sections/toolbar.sections.html.php index 28fd5986..8b7a389f 100644 --- a/oss/joomla/trunk/administrator/components/com_sections/toolbar.sections.html.php +++ b/oss/joomla/trunk/administrator/components/com_sections/toolbar.sections.html.php @@ -1,66 +1,66 @@ -[ '. $text.' ]', 'sections.png' ); - JToolBarHelper::save(); - JToolBarHelper::apply(); - if ( $edit ) { - // for existing items the button is renamed `close` - JToolBarHelper::cancel( 'cancel', 'Close' ); - } else { - JToolBarHelper::cancel(); - } - JToolBarHelper::help( 'screen.sections.edit' ); - } - /** - * Draws the menu for Copying existing sections - * @param int The published state (to display the inverse button) - */ - function _COPY() { - JToolBarHelper::title( JText::_( 'Section' ) .': [ '. JText::_( 'Copy' ).' ]', 'section.png' ); - //JToolBarHelper::title( JText::_( 'Copy Section' ), 'sections.png' ); - JToolBarHelper::save( 'copysave' ); - JToolBarHelper::cancel(); - } - /** - * Draws the menu for Editing an existing category - */ - function _DEFAULT(){ - JToolBarHelper::title( JText::_( 'Section Manager' ), 'sections.png' ); - JToolBarHelper::publishList(); - JToolBarHelper::unpublishList(); - JToolBarHelper::customX( 'copyselect', 'copy.png', 'copy_f2.png', 'Copy', true ); - JToolBarHelper::deleteList(); - JToolBarHelper::editListX(); - JToolBarHelper::addNewX(); - JToolBarHelper::help( 'screen.sections' ); - } +[ '. $text.' ]', 'sections.png' ); + JToolBarHelper::save(); + JToolBarHelper::apply(); + if ( $edit ) { + // for existing items the button is renamed `close` + JToolBarHelper::cancel( 'cancel', 'Close' ); + } else { + JToolBarHelper::cancel(); + } + JToolBarHelper::help( 'screen.sections.edit' ); + } + /** + * Draws the menu for Copying existing sections + * @param int The published state (to display the inverse button) + */ + function _COPY() { + JToolBarHelper::title( JText::_( 'Section' ) .': [ '. JText::_( 'Copy' ).' ]', 'section.png' ); + //JToolBarHelper::title( JText::_( 'Copy Section' ), 'sections.png' ); + JToolBarHelper::save( 'copysave' ); + JToolBarHelper::cancel(); + } + /** + * Draws the menu for Editing an existing category + */ + function _DEFAULT(){ + JToolBarHelper::title( JText::_( 'Section Manager' ), 'sections.png' ); + JToolBarHelper::publishList(); + JToolBarHelper::unpublishList(); + JToolBarHelper::customX( 'copyselect', 'copy.png', 'copy_f2.png', 'Copy', true ); + JToolBarHelper::deleteList(); + JToolBarHelper::editListX(); + JToolBarHelper::addNewX(); + JToolBarHelper::help( 'screen.sections' ); + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_sections/toolbar.sections.php b/oss/joomla/trunk/administrator/components/com_sections/toolbar.sections.php index 668a13cb..0b8cb72c 100644 --- a/oss/joomla/trunk/administrator/components/com_sections/toolbar.sections.php +++ b/oss/joomla/trunk/administrator/components/com_sections/toolbar.sections.php @@ -1,38 +1,38 @@ -authorUrl) && $row->authorUrl != '') { - $row->authorUrl = str_replace('http://', '', $row->authorUrl); - } - - JHTML::_('behavior.tooltip'); -?> -
    - - - - - - - id == 1) { -?> - - - - - - - - - - - - - - - - - authorEmail . '
    ' . @ $row->authorUrl; -?> - - - - - id == 1) { -?> - - - - - - - - - - - -
    - - - - - - - - - - - - - - - -
    - getListFooter(); ?> -
    - getRowOffset( $i ); ?> - - get ('id'), $row->checked_out )) { -?> -   - - - - id == 1 ? JURI::root().'administrator' : $mainframe->getSiteURL() ).'/templates/'.$row->directory.'/template_thumbnail.png'; ?> - - name;?> - - published == 1) { -?> - <?php echo JText::_( 'Published' ); ?> - -   - - - published == 1) { -?> - <?php echo JText::_( 'Default' ); ?> - -   - - - assigned == 1) { -?> - <?php echo JText::_( 'Assigned' ); ?> - -   - - - version; ?> - - creationdate; ?> - - - author != '' ? $row->author : ' '; ?> - -
    - - - - - - -
    - id ? JURI::base() : $mainframe->getSiteURL(); -?> - - - - - - - - - - -
    - - - '_blank')); ?> -
    - 'previewFrame')) ?> -
    - -
    - - -
    - - - - - -

    message); ?>

    - - - - - - - - - - - - - -
    - - - -
    - - - -
    -
    - - -
    -
    - - - - - - - - - - - -
    - : - - - name); ?> - -
    - : - - description); ?> -
    -
    - -
    - - - - - - - - pages != 'all' && $client->id != 1) : ?> - - - - - -
    - : - - id == 1) { - echo JText::_('Cannot assign administrator template'); - } elseif ($row->pages == 'all') { - echo JText::_('Cannot assign default template'); - echo ''; - } elseif ($row->pages == 'none') { ?> - - - - - - -
    - : - - - pages == 'none') { ?> - - -
    -
    -
    - -
    -
    - - path.$templatefile) ? JText::sprintf('PARAMSWRITABLE', $templatefile):JText::sprintf('PARAMSUNWRITABLE', $templatefile); ?> - - - - -
    - render(); - } else { - echo '' . JText :: _('No Parameters') . ''; - } -?> -
    -
    -
    -
    - - - - - - -
    - path .DS. 'templates' .DS. $template .DS. 'index.php'; -?> -
    - - -
    - - - - - -

    message); ?>

    - - - - - - - - - - - - - -
    - - - -
    - - - -
    -
    - - - - - - - - - -
    - -
    - -
    - -
    - - - - - - - -
    - -
    - - - - - -
    -   -
    - - - - - - - - - - - - - -
    - - - - - / -
    - - - - - '. JText::_( 'Writable' ) .'' : ' '. JText::_( 'Unwritable' ) .'' ?> -
    - - - - - - -
    - path.DS.'templates'.DS.$template.DS.'css'.DS.$filename; - -?> -
    - - -
    - - - - - -

    message); ?>

    - - - - - - - - - - - - - -
    - - - -
    - - - -
    -
    - - - - - - - - - -
    - -
    - -
    - - - - - - - - -
    - authorUrl) && $row->authorUrl != '') { + $row->authorUrl = str_replace('http://', '', $row->authorUrl); + } + + JHTML::_('behavior.tooltip'); +?> +
    + + + + + + + id == 1) { +?> + + + + + + + + + + + + + + + + + authorEmail . '
    ' . @ $row->authorUrl; +?> + + + + + id == 1) { +?> + + + + + + + + + + + +
    + + + + + + + + + + + + + + + +
    + getListFooter(); ?> +
    + getRowOffset( $i ); ?> + + get ('id'), $row->checked_out )) { +?> +   + + + + id == 1 ? JURI::root().'administrator' : $mainframe->getSiteURL() ).'/templates/'.$row->directory.'/template_thumbnail.png'; ?> + + name;?> + + published == 1) { +?> + <?php echo JText::_( 'Published' ); ?> + +   + + + published == 1) { +?> + <?php echo JText::_( 'Default' ); ?> + +   + + + assigned == 1) { +?> + <?php echo JText::_( 'Assigned' ); ?> + +   + + + version; ?> + + creationdate; ?> + + + author != '' ? $row->author : ' '; ?> + +
    + + + + + + +
    + id ? JURI::base() : $mainframe->getSiteURL(); +?> + + + + + + + + + + +
    + + + '_blank')); ?> +
    + 'previewFrame')) ?> +
    + +
    + + +
    + + + + + +

    message); ?>

    + + + + + + + + + + + + + +
    + + + +
    + + + +
    +
    + + +
    +
    + + + + + + + + + + + +
    + : + + + name); ?> + +
    + : + + description); ?> +
    +
    + +
    + + + + + + + + pages != 'all' && $client->id != 1) : ?> + + + + + +
    + : + + id == 1) { + echo JText::_('Cannot assign administrator template'); + } elseif ($row->pages == 'all') { + echo JText::_('Cannot assign default template'); + echo ''; + } elseif ($row->pages == 'none') { ?> + + + + + + +
    + : + + + pages == 'none') { ?> + + +
    +
    +
    + +
    +
    + + path.$templatefile) ? JText::sprintf('PARAMSWRITABLE', $templatefile):JText::sprintf('PARAMSUNWRITABLE', $templatefile); ?> + + + + +
    + render(); + } else { + echo '' . JText :: _('No Parameters') . ''; + } +?> +
    +
    +
    +
    + + + + + + +
    + path .DS. 'templates' .DS. $template .DS. 'index.php'; +?> +
    + + +
    + + + + + +

    message); ?>

    + + + + + + + + + + + + + +
    + + + +
    + + + +
    +
    + + + + + + + + + +
    + +
    + +
    + +
    + + + + + + + +
    + +
    + + + + + +
    +   +
    + + + + + + + + + + + + + +
    + + + + + / +
    + + + + + '. JText::_( 'Writable' ) .'' : ' '. JText::_( 'Unwritable' ) .'' ?> +
    + + + + + + +
    + path.DS.'templates'.DS.$template.DS.'css'.DS.$filename; + +?> +
    + + +
    + + + + + +

    message); ?>

    + + + + + + + + + + + + + +
    + + + +
    + + + +
    +
    + + + + + + + + + +
    + +
    + +
    + + + + + + + + +
    + authorize('com_templates', 'manage')) { - $mainframe->redirect('index.php', JText::_('ALERTNOTAUTH')); -} - -// Set the table directory -JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_templates'.DS.'tables'); - -// Import file dependencies -require_once (JPATH_COMPONENT.DS.'helpers'.DS.'template.php'); -require_once (JPATH_COMPONENT.DS.'controller.php'); - -$task = JRequest::getCmd('task'); - -$client = JRequest::getVar('client', 0, '', 'int'); - -if ($client == 1) { - JSubMenuHelper::addEntry(JText::_('Site'), 'index.php?option=com_templates&client=0'); - JSubMenuHelper::addEntry(JText::_('Administrator'), 'index.php?option=com_templates&client=1', true); -} elseif ($client == 0 && !$task) { - JSubMenuHelper::addEntry(JText::_('Site'), 'index.php?option=com_templates&client=0', true); - JSubMenuHelper::addEntry(JText::_('Administrator'), 'index.php?option=com_templates&client=1'); -} else { - JSubMenuHelper::addEntry(JText::_('Site'), 'index.php?option=com_templates&client=0'); - JSubMenuHelper::addEntry(JText::_('Administrator'), 'index.php?option=com_templates&client=1'); -} - -switch ($task) -{ - case 'edit' : - TemplatesController::editTemplate(); - break; - - case 'save' : - case 'apply' : - TemplatesController::saveTemplate(); - break; - - case 'edit_source' : - TemplatesController::editTemplateSource(); - break; - - case 'save_source' : - case 'apply_source' : - TemplatesController::saveTemplateSource(); - break; - - case 'choose_css' : - TemplatesController::chooseTemplateCSS(); - break; - - case 'edit_css' : - TemplatesController::editTemplateCSS(); - break; - - case 'save_css' : - case 'apply_css' : - TemplatesController::saveTemplateCSS(); - break; - - case 'publish' : - case 'default' : - TemplatesController::publishTemplate(); - break; - - case 'cancel' : - TemplatesController::cancelTemplate(); - break; - - case 'save_positions' : - TemplatesController::savePositions(); - break; - - case 'preview' : - TemplatesController::previewTemplate(); - break; - - default : - TemplatesController::viewTemplates(); - break; +authorize('com_templates', 'manage')) { + $mainframe->redirect('index.php', JText::_('ALERTNOTAUTH')); +} + +// Set the table directory +JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_templates'.DS.'tables'); + +// Import file dependencies +require_once (JPATH_COMPONENT.DS.'helpers'.DS.'template.php'); +require_once (JPATH_COMPONENT.DS.'controller.php'); + +$task = JRequest::getCmd('task'); + +$client = JRequest::getVar('client', 0, '', 'int'); + +if ($client == 1) { + JSubMenuHelper::addEntry(JText::_('Site'), 'index.php?option=com_templates&client=0'); + JSubMenuHelper::addEntry(JText::_('Administrator'), 'index.php?option=com_templates&client=1', true); +} elseif ($client == 0 && !$task) { + JSubMenuHelper::addEntry(JText::_('Site'), 'index.php?option=com_templates&client=0', true); + JSubMenuHelper::addEntry(JText::_('Administrator'), 'index.php?option=com_templates&client=1'); +} else { + JSubMenuHelper::addEntry(JText::_('Site'), 'index.php?option=com_templates&client=0'); + JSubMenuHelper::addEntry(JText::_('Administrator'), 'index.php?option=com_templates&client=1'); +} + +switch ($task) +{ + case 'edit' : + TemplatesController::editTemplate(); + break; + + case 'save' : + case 'apply' : + TemplatesController::saveTemplate(); + break; + + case 'edit_source' : + TemplatesController::editTemplateSource(); + break; + + case 'save_source' : + case 'apply_source' : + TemplatesController::saveTemplateSource(); + break; + + case 'choose_css' : + TemplatesController::chooseTemplateCSS(); + break; + + case 'edit_css' : + TemplatesController::editTemplateCSS(); + break; + + case 'save_css' : + case 'apply_css' : + TemplatesController::saveTemplateCSS(); + break; + + case 'publish' : + case 'default' : + TemplatesController::publishTemplate(); + break; + + case 'cancel' : + TemplatesController::cancelTemplate(); + break; + + case 'save_positions' : + TemplatesController::savePositions(); + break; + + case 'preview' : + TemplatesController::previewTemplate(); + break; + + default : + TemplatesController::viewTemplates(); + break; } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_templates/controller.php b/oss/joomla/trunk/administrator/components/com_templates/controller.php index c5fa8fb9..d419d5f5 100644 --- a/oss/joomla/trunk/administrator/components/com_templates/controller.php +++ b/oss/joomla/trunk/administrator/components/com_templates/controller.php @@ -1,500 +1,500 @@ -getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); - $limitstart = $mainframe->getUserStateFromRequest($option.'.'.$client->id.'.limitstart', 'limitstart', 0, 'int'); - - $select[] = JHTML::_('select.option', '0', JText::_('Site')); - $select[] = JHTML::_('select.option', '1', JText::_('Administrator')); - $lists['client'] = JHTML::_('select.genericlist', $select, 'client', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $client->id); - - $tBaseDir = $client->path.DS.'templates'; - - //get template xml file info - $rows = array(); - $rows = TemplatesHelper::parseXMLTemplateFiles($tBaseDir); - - // set dynamic template information - for($i = 0; $i < count($rows); $i++) { - $rows[$i]->assigned = TemplatesHelper::isTemplateAssigned($rows[$i]->directory); - $rows[$i]->published = TemplatesHelper::isTemplateDefault($rows[$i]->directory, $client->id); - } - - jimport('joomla.html.pagination'); - $page = new JPagination(count($rows), $limitstart, $limit); - - $rows = array_slice($rows, $page->limitstart, $page->limit); - - require_once (JPATH_COMPONENT.DS.'admin.templates.html.php'); - TemplatesView::showTemplates($rows, $lists, $page, $option, $client); - } - - /** - * Show the template with module position in an iframe - */ - function previewTemplate() - { - $template = JRequest::getVar('id', '', 'method', 'cmd'); - $option = JRequest::getCmd('option'); - $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); - - if (!$template) - { - return JError::raiseWarning( 500, JText::_('Template not specified') ); - } - - // Set FTP credentials, if given - jimport('joomla.client.helper'); - JClientHelper::setCredentialsFromRequest('ftp'); - - require_once (JPATH_COMPONENT.DS.'admin.templates.html.php'); - TemplatesView::previewTemplate($template, true, $client, $option); - } - - /** - * Publish, or make current, the selected template - */ - function publishTemplate() - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize some variables - $db = & JFactory::getDBO(); - $cid = JRequest::getVar('cid', array(), 'method', 'array'); - $cid = array(JFilterInput::clean(@$cid[0], 'cmd')); - $option = JRequest::getCmd('option'); - $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); - - if ($cid[0]) - { - $query = 'DELETE FROM #__templates_menu' . - ' WHERE client_id = '.(int) $client->id . - ' AND (menuid = 0 OR template = '.$db->Quote($cid[0]).')'; - $db->setQuery($query); - $db->query(); - - $query = 'INSERT INTO #__templates_menu' . - ' SET client_id = '.(int) $client->id .', template = '.$db->Quote($cid[0]).', menuid = 0'; - $db->setQuery($query); - $db->query(); - } - - $mainframe->redirect('index.php?option='.$option.'&client='.$client->id); - } - - function editTemplate() - { - jimport('joomla.filesystem.path'); - - // Initialize some variables - $db = & JFactory::getDBO(); - $cid = JRequest::getVar('cid', array(), 'method', 'array'); - $cid = array(JFilterInput::clean(@$cid[0], 'cmd')); - $template = $cid[0]; - $option = JRequest::getCmd('option'); - $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); - - if (!$cid[0]) { - return JError::raiseWarning( 500, JText::_('Template not specified') ); - } - - $tBaseDir = JPath::clean($client->path.DS.'templates'); - - if (!is_dir( $tBaseDir . DS . $template )) { - return JError::raiseWarning( 500, JText::_('Template not found') ); - } - $lang =& JFactory::getLanguage(); - $lang->load( 'tpl_'.$template, JPATH_ADMINISTRATOR ); - - $ini = $client->path.DS.'templates'.DS.$template.DS.'params.ini'; - $xml = $client->path.DS.'templates'.DS.$template.DS.'templateDetails.xml'; - $row = TemplatesHelper::parseXMLTemplateFile($tBaseDir, $template); - - jimport('joomla.filesystem.file'); - // Read the ini file - if (JFile::exists($ini)) { - $content = JFile::read($ini); - } else { - $content = null; - } - - $params = new JParameter($content, $xml, 'template'); - - $assigned = TemplatesHelper::isTemplateAssigned($row->directory); - $default = TemplatesHelper::isTemplateDefault($row->directory, $client->id); - - if($client->id == '1') { - $lists['selections'] = JText::_('Cannot assign an administrator template'); - } else { - $lists['selections'] = TemplatesHelper::createMenuList($template); - } - - if ($default) { - $row->pages = 'all'; - } elseif (!$assigned) { - $row->pages = 'none'; - } else { - $row->pages = null; - } - - // Set FTP credentials, if given - jimport('joomla.client.helper'); - $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); - - require_once (JPATH_COMPONENT.DS.'admin.templates.html.php'); - TemplatesView::editTemplate($row, $lists, $params, $option, $client, $ftp, $template); - } - - function saveTemplate() - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize some variables - $db = & JFactory::getDBO(); - - $template = JRequest::getVar('id', '', 'method', 'cmd'); - $option = JRequest::getVar('option', '', '', 'cmd'); - $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); - $menus = JRequest::getVar('selections', array(), 'post', 'array'); - $params = JRequest::getVar('params', array(), 'post', 'array'); - $default = JRequest::getBool('default'); - JArrayHelper::toInteger($menus); - - if (!$template) { - $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('No template specified.')); - } - - // Set FTP credentials, if given - jimport('joomla.client.helper'); - JClientHelper::setCredentialsFromRequest('ftp'); - $ftp = JClientHelper::getCredentials('ftp'); - - $file = $client->path.DS.'templates'.DS.$template.DS.'params.ini'; - - jimport('joomla.filesystem.file'); - if (JFile::exists($file) && count($params)) - { - $registry = new JRegistry(); - $registry->loadArray($params); - $txt = $registry->toString(); - - // Try to make the params file writeable - if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0755')) { - JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the template parameter file writable')); - } - - $return = JFile::write($file, $txt); - - // Try to make the params file unwriteable - if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0555')) { - JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the template parameter file unwritable')); - } - - if (!$return) { - $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::sprintf('Failed to open file for writing.', $file)); - } - } - - // Reset all existing assignments - $query = 'DELETE FROM #__templates_menu' . - ' WHERE client_id = 0' . - ' AND template = '.$db->Quote( $template ); - $db->setQuery($query); - $db->query(); - - if ($default) { - $menus = array( 0 ); - } - - foreach ($menus as $menuid) - { - // If 'None' is not in array - if ((int) $menuid >= 0) - { - // check if there is already a template assigned to this menu item - $query = 'DELETE FROM #__templates_menu' . - ' WHERE client_id = 0' . - ' AND menuid = '.(int) $menuid; - $db->setQuery($query); - $db->query(); - - $query = 'INSERT INTO #__templates_menu' . - ' SET client_id = 0, template = '. $db->Quote( $template ) .', menuid = '.(int) $menuid; - $db->setQuery($query); - $db->query(); - } - } - - $task = JRequest::getCmd('task'); - if($task == 'apply') { - $mainframe->redirect('index.php?option='.$option.'&task=edit&cid[]='.$template.'&client='.$client->id); - } else { - $mainframe->redirect('index.php?option='.$option.'&client='.$client->id); - } - } - - function cancelTemplate() - { - global $mainframe; - - // Initialize some variables - $option = JRequest::getCmd('option'); - $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); - - // Set FTP credentials, if given - jimport('joomla.client.helper'); - JClientHelper::setCredentialsFromRequest('ftp'); - - $mainframe->redirect('index.php?option='.$option.'&client='.$client->id); - } - - function editTemplateSource() - { - global $mainframe; - - // Initialize some variables - $option = JRequest::getCmd('option'); - $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); - $template = JRequest::getVar('id', '', 'method', 'cmd'); - $file = $client->path.DS.'templates'.DS.$template.DS.'index.php'; - - // Read the source file - jimport('joomla.filesystem.file'); - $content = JFile::read($file); - - if ($content !== false) - { - // Set FTP credentials, if given - jimport('joomla.client.helper'); - $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); - - $content = htmlspecialchars($content, ENT_COMPAT, 'UTF-8'); - require_once (JPATH_COMPONENT.DS.'admin.templates.html.php'); - TemplatesView::editTemplateSource($template, $content, $option, $client, $ftp); - } else { - $msg = JText::sprintf('Operation Failed Could not open', $file); - $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, $msg); - } - } - - function saveTemplateSource() - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize some variables - $option = JRequest::getCmd('option'); - $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); - $template = JRequest::getVar('id', '', 'method', 'cmd'); - $filecontent = JRequest::getVar('filecontent', '', 'post', 'string', JREQUEST_ALLOWRAW); - - if (!$template) { - $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('No template specified.')); - } - - if (!$filecontent) { - $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('Content empty.')); - } - - // Set FTP credentials, if given - jimport('joomla.client.helper'); - JClientHelper::setCredentialsFromRequest('ftp'); - $ftp = JClientHelper::getCredentials('ftp'); - - $file = $client->path.DS.'templates'.DS.$template.DS.'index.php'; - - // Try to make the template file writeable - if (!$ftp['enabled'] && !JPath::setPermissions($file, '0755')) { - JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the template file writable')); - } - - jimport('joomla.filesystem.file'); - $return = JFile::write($file, $filecontent); - - // Try to make the template file unwriteable - if (!$ftp['enabled'] && !JPath::setPermissions($file, '0555')) { - JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the template file unwritable')); - } - - if ($return) - { - $task = JRequest::getCmd('task'); - switch($task) - { - case 'apply_source': - $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=edit_source&id='.$template, JText::_('Template source saved')); - break; - - case 'save_source': - default: - $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=edit&cid[]='.$template, JText::_('Template source saved')); - break; - } - } - else { - $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::sprintf('Failed to open file for writing.', $file)); - } - } - - function chooseTemplateCSS() - { - global $mainframe; - - // Initialize some variables - $option = JRequest::getCmd('option'); - $template = JRequest::getVar('id', '', 'method', 'cmd'); - $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); - - // Determine template CSS directory - $dir = $client->path.DS.'templates'.DS.$template.DS.'css'; - - // List template .css files - jimport('joomla.filesystem.folder'); - $files = JFolder::files($dir, '\.css$', false, false); - - // Set FTP credentials, if given - jimport('joomla.client.helper'); - JClientHelper::setCredentialsFromRequest('ftp'); - - require_once (JPATH_COMPONENT.DS.'admin.templates.html.php'); - TemplatesView::chooseCSSFiles($template, $dir, $files, $option, $client); - } - - function editTemplateCSS() - { - global $mainframe; - - // Initialize some variables - $option = JRequest::getCmd('option'); - $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); - $template = JRequest::getVar('id', '', 'method', 'cmd'); - $filename = JRequest::getVar('filename', '', 'method', 'cmd'); - - jimport('joomla.filesystem.file'); - - if (JFile::getExt($filename) !== 'css') { - $msg = JText::_('Wrong file type given, only CSS files can be edited.'); - $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=choose_css&id='.$template, $msg, 'error'); - } - - $content = JFile::read($client->path.DS.'templates'.DS.$template.DS.'css'.DS.$filename); - - if ($content !== false) - { - // Set FTP credentials, if given - jimport('joomla.client.helper'); - $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); - - $content = htmlspecialchars($content, ENT_COMPAT, 'UTF-8'); - require_once (JPATH_COMPONENT.DS.'admin.templates.html.php'); - TemplatesView::editCSSSource($template, $filename, $content, $option, $client, $ftp); - } - else - { - $msg = JText::sprintf('Operation Failed Could not open', $client->path.$filename); - $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, $msg); - } - } - - function saveTemplateCSS() - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Initialize some variables - $option = JRequest::getCmd('option'); - $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); - $template = JRequest::getVar('id', '', 'post', 'cmd'); - $filename = JRequest::getVar('filename', '', 'post', 'cmd'); - $filecontent = JRequest::getVar('filecontent', '', 'post', 'string', JREQUEST_ALLOWRAW); - - if (!$template) { - $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('No template specified.')); - } - - if (!$filecontent) { - $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('Content empty.')); - } - - // Set FTP credentials, if given - jimport('joomla.client.helper'); - JClientHelper::setCredentialsFromRequest('ftp'); - $ftp = JClientHelper::getCredentials('ftp'); - - $file = $client->path.DS.'templates'.DS.$template.DS.'css'.DS.$filename; - - // Try to make the css file writeable - if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0755')) { - JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the css file writable')); - } - - jimport('joomla.filesystem.file'); - $return = JFile::write($file, $filecontent); - - // Try to make the css file unwriteable - if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0555')) { - JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the css file unwritable')); - } - - if ($return) - { - $task = JRequest::getCmd('task'); - switch($task) - { - case 'apply_css': - $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=edit_css&id='.$template.'&filename='.$filename, JText::_('File Saved')); - break; - - case 'save_css': - default: - $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=edit&cid[]='.$template, JText::_('File Saved')); - break; - } - } - else { - $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&id='.$template.'&task=choose_css', JText::_('Operation Failed').': '.JText::sprintf('Failed to open file for writing.', $file)); - } - } -} +getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); + $limitstart = $mainframe->getUserStateFromRequest($option.'.'.$client->id.'.limitstart', 'limitstart', 0, 'int'); + + $select[] = JHTML::_('select.option', '0', JText::_('Site')); + $select[] = JHTML::_('select.option', '1', JText::_('Administrator')); + $lists['client'] = JHTML::_('select.genericlist', $select, 'client', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $client->id); + + $tBaseDir = $client->path.DS.'templates'; + + //get template xml file info + $rows = array(); + $rows = TemplatesHelper::parseXMLTemplateFiles($tBaseDir); + + // set dynamic template information + for($i = 0; $i < count($rows); $i++) { + $rows[$i]->assigned = TemplatesHelper::isTemplateAssigned($rows[$i]->directory); + $rows[$i]->published = TemplatesHelper::isTemplateDefault($rows[$i]->directory, $client->id); + } + + jimport('joomla.html.pagination'); + $page = new JPagination(count($rows), $limitstart, $limit); + + $rows = array_slice($rows, $page->limitstart, $page->limit); + + require_once (JPATH_COMPONENT.DS.'admin.templates.html.php'); + TemplatesView::showTemplates($rows, $lists, $page, $option, $client); + } + + /** + * Show the template with module position in an iframe + */ + function previewTemplate() + { + $template = JRequest::getVar('id', '', 'method', 'cmd'); + $option = JRequest::getCmd('option'); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + + if (!$template) + { + return JError::raiseWarning( 500, JText::_('Template not specified') ); + } + + // Set FTP credentials, if given + jimport('joomla.client.helper'); + JClientHelper::setCredentialsFromRequest('ftp'); + + require_once (JPATH_COMPONENT.DS.'admin.templates.html.php'); + TemplatesView::previewTemplate($template, true, $client, $option); + } + + /** + * Publish, or make current, the selected template + */ + function publishTemplate() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize some variables + $db = & JFactory::getDBO(); + $cid = JRequest::getVar('cid', array(), 'method', 'array'); + $cid = array(JFilterInput::clean(@$cid[0], 'cmd')); + $option = JRequest::getCmd('option'); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + + if ($cid[0]) + { + $query = 'DELETE FROM #__templates_menu' . + ' WHERE client_id = '.(int) $client->id . + ' AND (menuid = 0 OR template = '.$db->Quote($cid[0]).')'; + $db->setQuery($query); + $db->query(); + + $query = 'INSERT INTO #__templates_menu' . + ' SET client_id = '.(int) $client->id .', template = '.$db->Quote($cid[0]).', menuid = 0'; + $db->setQuery($query); + $db->query(); + } + + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id); + } + + function editTemplate() + { + jimport('joomla.filesystem.path'); + + // Initialize some variables + $db = & JFactory::getDBO(); + $cid = JRequest::getVar('cid', array(), 'method', 'array'); + $cid = array(JFilterInput::clean(@$cid[0], 'cmd')); + $template = $cid[0]; + $option = JRequest::getCmd('option'); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + + if (!$cid[0]) { + return JError::raiseWarning( 500, JText::_('Template not specified') ); + } + + $tBaseDir = JPath::clean($client->path.DS.'templates'); + + if (!is_dir( $tBaseDir . DS . $template )) { + return JError::raiseWarning( 500, JText::_('Template not found') ); + } + $lang =& JFactory::getLanguage(); + $lang->load( 'tpl_'.$template, JPATH_ADMINISTRATOR ); + + $ini = $client->path.DS.'templates'.DS.$template.DS.'params.ini'; + $xml = $client->path.DS.'templates'.DS.$template.DS.'templateDetails.xml'; + $row = TemplatesHelper::parseXMLTemplateFile($tBaseDir, $template); + + jimport('joomla.filesystem.file'); + // Read the ini file + if (JFile::exists($ini)) { + $content = JFile::read($ini); + } else { + $content = null; + } + + $params = new JParameter($content, $xml, 'template'); + + $assigned = TemplatesHelper::isTemplateAssigned($row->directory); + $default = TemplatesHelper::isTemplateDefault($row->directory, $client->id); + + if($client->id == '1') { + $lists['selections'] = JText::_('Cannot assign an administrator template'); + } else { + $lists['selections'] = TemplatesHelper::createMenuList($template); + } + + if ($default) { + $row->pages = 'all'; + } elseif (!$assigned) { + $row->pages = 'none'; + } else { + $row->pages = null; + } + + // Set FTP credentials, if given + jimport('joomla.client.helper'); + $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); + + require_once (JPATH_COMPONENT.DS.'admin.templates.html.php'); + TemplatesView::editTemplate($row, $lists, $params, $option, $client, $ftp, $template); + } + + function saveTemplate() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize some variables + $db = & JFactory::getDBO(); + + $template = JRequest::getVar('id', '', 'method', 'cmd'); + $option = JRequest::getVar('option', '', '', 'cmd'); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $menus = JRequest::getVar('selections', array(), 'post', 'array'); + $params = JRequest::getVar('params', array(), 'post', 'array'); + $default = JRequest::getBool('default'); + JArrayHelper::toInteger($menus); + + if (!$template) { + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('No template specified.')); + } + + // Set FTP credentials, if given + jimport('joomla.client.helper'); + JClientHelper::setCredentialsFromRequest('ftp'); + $ftp = JClientHelper::getCredentials('ftp'); + + $file = $client->path.DS.'templates'.DS.$template.DS.'params.ini'; + + jimport('joomla.filesystem.file'); + if (JFile::exists($file) && count($params)) + { + $registry = new JRegistry(); + $registry->loadArray($params); + $txt = $registry->toString(); + + // Try to make the params file writeable + if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0755')) { + JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the template parameter file writable')); + } + + $return = JFile::write($file, $txt); + + // Try to make the params file unwriteable + if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0555')) { + JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the template parameter file unwritable')); + } + + if (!$return) { + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::sprintf('Failed to open file for writing.', $file)); + } + } + + // Reset all existing assignments + $query = 'DELETE FROM #__templates_menu' . + ' WHERE client_id = 0' . + ' AND template = '.$db->Quote( $template ); + $db->setQuery($query); + $db->query(); + + if ($default) { + $menus = array( 0 ); + } + + foreach ($menus as $menuid) + { + // If 'None' is not in array + if ((int) $menuid >= 0) + { + // check if there is already a template assigned to this menu item + $query = 'DELETE FROM #__templates_menu' . + ' WHERE client_id = 0' . + ' AND menuid = '.(int) $menuid; + $db->setQuery($query); + $db->query(); + + $query = 'INSERT INTO #__templates_menu' . + ' SET client_id = 0, template = '. $db->Quote( $template ) .', menuid = '.(int) $menuid; + $db->setQuery($query); + $db->query(); + } + } + + $task = JRequest::getCmd('task'); + if($task == 'apply') { + $mainframe->redirect('index.php?option='.$option.'&task=edit&cid[]='.$template.'&client='.$client->id); + } else { + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id); + } + } + + function cancelTemplate() + { + global $mainframe; + + // Initialize some variables + $option = JRequest::getCmd('option'); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + + // Set FTP credentials, if given + jimport('joomla.client.helper'); + JClientHelper::setCredentialsFromRequest('ftp'); + + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id); + } + + function editTemplateSource() + { + global $mainframe; + + // Initialize some variables + $option = JRequest::getCmd('option'); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $template = JRequest::getVar('id', '', 'method', 'cmd'); + $file = $client->path.DS.'templates'.DS.$template.DS.'index.php'; + + // Read the source file + jimport('joomla.filesystem.file'); + $content = JFile::read($file); + + if ($content !== false) + { + // Set FTP credentials, if given + jimport('joomla.client.helper'); + $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); + + $content = htmlspecialchars($content, ENT_COMPAT, 'UTF-8'); + require_once (JPATH_COMPONENT.DS.'admin.templates.html.php'); + TemplatesView::editTemplateSource($template, $content, $option, $client, $ftp); + } else { + $msg = JText::sprintf('Operation Failed Could not open', $file); + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, $msg); + } + } + + function saveTemplateSource() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize some variables + $option = JRequest::getCmd('option'); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $template = JRequest::getVar('id', '', 'method', 'cmd'); + $filecontent = JRequest::getVar('filecontent', '', 'post', 'string', JREQUEST_ALLOWRAW); + + if (!$template) { + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('No template specified.')); + } + + if (!$filecontent) { + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('Content empty.')); + } + + // Set FTP credentials, if given + jimport('joomla.client.helper'); + JClientHelper::setCredentialsFromRequest('ftp'); + $ftp = JClientHelper::getCredentials('ftp'); + + $file = $client->path.DS.'templates'.DS.$template.DS.'index.php'; + + // Try to make the template file writeable + if (!$ftp['enabled'] && !JPath::setPermissions($file, '0755')) { + JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the template file writable')); + } + + jimport('joomla.filesystem.file'); + $return = JFile::write($file, $filecontent); + + // Try to make the template file unwriteable + if (!$ftp['enabled'] && !JPath::setPermissions($file, '0555')) { + JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the template file unwritable')); + } + + if ($return) + { + $task = JRequest::getCmd('task'); + switch($task) + { + case 'apply_source': + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=edit_source&id='.$template, JText::_('Template source saved')); + break; + + case 'save_source': + default: + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=edit&cid[]='.$template, JText::_('Template source saved')); + break; + } + } + else { + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::sprintf('Failed to open file for writing.', $file)); + } + } + + function chooseTemplateCSS() + { + global $mainframe; + + // Initialize some variables + $option = JRequest::getCmd('option'); + $template = JRequest::getVar('id', '', 'method', 'cmd'); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + + // Determine template CSS directory + $dir = $client->path.DS.'templates'.DS.$template.DS.'css'; + + // List template .css files + jimport('joomla.filesystem.folder'); + $files = JFolder::files($dir, '\.css$', false, false); + + // Set FTP credentials, if given + jimport('joomla.client.helper'); + JClientHelper::setCredentialsFromRequest('ftp'); + + require_once (JPATH_COMPONENT.DS.'admin.templates.html.php'); + TemplatesView::chooseCSSFiles($template, $dir, $files, $option, $client); + } + + function editTemplateCSS() + { + global $mainframe; + + // Initialize some variables + $option = JRequest::getCmd('option'); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $template = JRequest::getVar('id', '', 'method', 'cmd'); + $filename = JRequest::getVar('filename', '', 'method', 'cmd'); + + jimport('joomla.filesystem.file'); + + if (JFile::getExt($filename) !== 'css') { + $msg = JText::_('Wrong file type given, only CSS files can be edited.'); + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=choose_css&id='.$template, $msg, 'error'); + } + + $content = JFile::read($client->path.DS.'templates'.DS.$template.DS.'css'.DS.$filename); + + if ($content !== false) + { + // Set FTP credentials, if given + jimport('joomla.client.helper'); + $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); + + $content = htmlspecialchars($content, ENT_COMPAT, 'UTF-8'); + require_once (JPATH_COMPONENT.DS.'admin.templates.html.php'); + TemplatesView::editCSSSource($template, $filename, $content, $option, $client, $ftp); + } + else + { + $msg = JText::sprintf('Operation Failed Could not open', $client->path.$filename); + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, $msg); + } + } + + function saveTemplateCSS() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Initialize some variables + $option = JRequest::getCmd('option'); + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + $template = JRequest::getVar('id', '', 'post', 'cmd'); + $filename = JRequest::getVar('filename', '', 'post', 'cmd'); + $filecontent = JRequest::getVar('filecontent', '', 'post', 'string', JREQUEST_ALLOWRAW); + + if (!$template) { + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('No template specified.')); + } + + if (!$filecontent) { + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id, JText::_('Operation Failed').': '.JText::_('Content empty.')); + } + + // Set FTP credentials, if given + jimport('joomla.client.helper'); + JClientHelper::setCredentialsFromRequest('ftp'); + $ftp = JClientHelper::getCredentials('ftp'); + + $file = $client->path.DS.'templates'.DS.$template.DS.'css'.DS.$filename; + + // Try to make the css file writeable + if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0755')) { + JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the css file writable')); + } + + jimport('joomla.filesystem.file'); + $return = JFile::write($file, $filecontent); + + // Try to make the css file unwriteable + if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0555')) { + JError::raiseNotice('SOME_ERROR_CODE', JText::_('Could not make the css file unwritable')); + } + + if ($return) + { + $task = JRequest::getCmd('task'); + switch($task) + { + case 'apply_css': + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=edit_css&id='.$template.'&filename='.$filename, JText::_('File Saved')); + break; + + case 'save_css': + default: + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&task=edit&cid[]='.$template, JText::_('File Saved')); + break; + } + } + else { + $mainframe->redirect('index.php?option='.$option.'&client='.$client->id.'&id='.$template.'&task=choose_css', JText::_('Operation Failed').': '.JText::sprintf('Failed to open file for writing.', $file)); + } + } +} diff --git a/oss/joomla/trunk/administrator/components/com_templates/helpers/template.php b/oss/joomla/trunk/administrator/components/com_templates/helpers/template.php index 99ae4328..3d6e3157 100644 --- a/oss/joomla/trunk/administrator/components/com_templates/helpers/template.php +++ b/oss/joomla/trunk/administrator/components/com_templates/helpers/template.php @@ -1,120 +1,120 @@ -setQuery($query); - $defaultemplate = $db->loadResult(); - - return $defaultemplate == $template ? 1 : 0; - } - - function isTemplateAssigned($template) - { - $db =& JFactory::getDBO(); - - // check if template is assigned - $query = 'SELECT COUNT(*)' . - ' FROM #__templates_menu' . - ' WHERE client_id = 0' . - ' AND template = '.$db->Quote($template) . - ' AND menuid <> 0'; - $db->setQuery($query); - return $db->loadResult() ? 1 : 0; - } - - function parseXMLTemplateFiles($templateBaseDir) - { - // Read the template folder to find templates - jimport('joomla.filesystem.folder'); - $templateDirs = JFolder::folders($templateBaseDir); - - $rows = array(); - - // Check that the directory contains an xml file - foreach ($templateDirs as $templateDir) - { - if(!$data = TemplatesHelper::parseXMLTemplateFile($templateBaseDir, $templateDir)){ - continue; - } else { - $rows[] = $data; - } - } - - return $rows; - } - - function parseXMLTemplateFile($templateBaseDir, $templateDir) - { - // Check of the xml file exists - if(!is_file($templateBaseDir.DS.$templateDir.DS.'templateDetails.xml')) { - return false; - } - - $xml = JApplicationHelper::parseXMLInstallFile($templateBaseDir.DS.$templateDir.DS.'templateDetails.xml'); - - if ($xml['type'] != 'template') { - return false; - } - - $data = new StdClass(); - $data->directory = $templateDir; - - foreach($xml as $key => $value) { - $data->$key = $value; - } - - $data->checked_out = 0; - $data->mosname = JString::strtolower(str_replace(' ', '_', $data->name)); - - return $data; - } - - function createMenuList($template) - { - $db =& JFactory::getDBO(); - - // get selected pages for $menulist - $query = 'SELECT menuid AS value' . - ' FROM #__templates_menu' . - ' WHERE client_id = 0' . - ' AND template = '.$db->Quote($template); - $db->setQuery($query); - $lookup = $db->loadObjectList(); - if (empty( $lookup )) { - $lookup = array( JHTML::_('select.option', '-1' ) ); - } - - // build the html select list - $options = JHTML::_('menu.linkoptions'); - $result = JHTML::_('select.genericlist', $options, 'selections[]', 'class="inputbox" size="15" multiple="multiple"', 'value', 'text', $lookup, 'selections' ); - return $result; - } +setQuery($query); + $defaultemplate = $db->loadResult(); + + return $defaultemplate == $template ? 1 : 0; + } + + function isTemplateAssigned($template) + { + $db =& JFactory::getDBO(); + + // check if template is assigned + $query = 'SELECT COUNT(*)' . + ' FROM #__templates_menu' . + ' WHERE client_id = 0' . + ' AND template = '.$db->Quote($template) . + ' AND menuid <> 0'; + $db->setQuery($query); + return $db->loadResult() ? 1 : 0; + } + + function parseXMLTemplateFiles($templateBaseDir) + { + // Read the template folder to find templates + jimport('joomla.filesystem.folder'); + $templateDirs = JFolder::folders($templateBaseDir); + + $rows = array(); + + // Check that the directory contains an xml file + foreach ($templateDirs as $templateDir) + { + if(!$data = TemplatesHelper::parseXMLTemplateFile($templateBaseDir, $templateDir)){ + continue; + } else { + $rows[] = $data; + } + } + + return $rows; + } + + function parseXMLTemplateFile($templateBaseDir, $templateDir) + { + // Check of the xml file exists + if(!is_file($templateBaseDir.DS.$templateDir.DS.'templateDetails.xml')) { + return false; + } + + $xml = JApplicationHelper::parseXMLInstallFile($templateBaseDir.DS.$templateDir.DS.'templateDetails.xml'); + + if ($xml['type'] != 'template') { + return false; + } + + $data = new StdClass(); + $data->directory = $templateDir; + + foreach($xml as $key => $value) { + $data->$key = $value; + } + + $data->checked_out = 0; + $data->mosname = JString::strtolower(str_replace(' ', '_', $data->name)); + + return $data; + } + + function createMenuList($template) + { + $db =& JFactory::getDBO(); + + // get selected pages for $menulist + $query = 'SELECT menuid AS value' . + ' FROM #__templates_menu' . + ' WHERE client_id = 0' . + ' AND template = '.$db->Quote($template); + $db->setQuery($query); + $lookup = $db->loadObjectList(); + if (empty( $lookup )) { + $lookup = array( JHTML::_('select.option', '-1' ) ); + } + + // build the html select list + $options = JHTML::_('menu.linkoptions'); + $result = JHTML::_('select.genericlist', $options, 'selections[]', 'class="inputbox" size="15" multiple="multiple"', 'value', 'text', $lookup, 'selections' ); + return $result; + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_templates/templates.xml b/oss/joomla/trunk/administrator/components/com_templates/templates.xml index bdb42ed4..5f6e766b 100644 --- a/oss/joomla/trunk/administrator/components/com_templates/templates.xml +++ b/oss/joomla/trunk/administrator/components/com_templates/templates.xml @@ -1,12 +1,12 @@ - - - Template Manager - Joomla! Project - 2006 - Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - admin@joomla.org - www.joomla.org - 1.5.0 - Template Manager - + + + Template Manager + Joomla! Project + 2006 + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + Template Manager + diff --git a/oss/joomla/trunk/administrator/components/com_templates/toolbar.templates.html.php b/oss/joomla/trunk/administrator/components/com_templates/toolbar.templates.html.php index 04b9ee68..bfbe946a 100644 --- a/oss/joomla/trunk/administrator/components/com_templates/toolbar.templates.html.php +++ b/oss/joomla/trunk/administrator/components/com_templates/toolbar.templates.html.php @@ -1,77 +1,77 @@ -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' ); - } +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 diff --git a/oss/joomla/trunk/administrator/components/com_templates/toolbar.templates.php b/oss/joomla/trunk/administrator/components/com_templates/toolbar.templates.php index b6ce0ba3..17246ac7 100644 --- a/oss/joomla/trunk/administrator/components/com_templates/toolbar.templates.php +++ b/oss/joomla/trunk/administrator/components/com_templates/toolbar.templates.php @@ -1,48 +1,48 @@ - -
    - - - - - - -
    - : - - - - -
    - -
    - - - - - - - - - - - - - - - - - - - "> - - - - - - - - - -
    - - - - - - - - - - - -
    - getListFooter(); ?> -
    - limitstart;?> - - id ); ?> - - title; ?> - - id; ?> - - sectname; ?> - - catname; ?> -
    -
    - - - - - - - -
    - - -
    - - - - - - -
    - : - - - - -
    - -
    - - - - - - - - - - - - - - - - - - - "> - - - - - - - - - -
    - - - - - - - - - - - -
    - getListFooter(); ?> -
    - limitstart;?> - - - - name; ?> - - id; ?> - - menutype; ?> - - type; ?> -
    -
    - - - - - - - -
    - -
    - - - - - - - - - - - -
    - - : -
    - -

    -
    - : -
    - "; - foreach ( $items as $item ) { - echo "
  • ". $item->name ."
  • "; - } - echo ""; - ?> -
    -


    - -   -
     
    -

    - - - - - - - "; - } - ?> - -
    - -
    - - - - - - - - - - - -
    - : -
    - -

    -
    - : -
    - "; - foreach ( $items as $item ) { - echo "
  • ". $item->name ."
  • "; - } - echo ""; - ?> -

    -


    -
    - - <?php echo JText::_( 'Restore' ); ?> -   -
    -
     
    -

    - - - - - - - "; - } - ?> - -
    - +
    + + + + + + +
    + : + + + + +
    + +
    + + + + + + + + + + + + + + + + + + + "> + + + + + + + + + +
    + + + + + + + + + + + +
    + getListFooter(); ?> +
    + limitstart;?> + + id ); ?> + + title; ?> + + id; ?> + + sectname; ?> + + catname; ?> +
    +
    + + + + + + + +
    + + +
    + + + + + + +
    + : + + + + +
    + +
    + + + + + + + + + + + + + + + + + + + "> + + + + + + + + + +
    + + + + + + + + + + + +
    + getListFooter(); ?> +
    + limitstart;?> + + + + name; ?> + + id; ?> + + menutype; ?> + + type; ?> +
    +
    + + + + + + + +
    + +
    + + + + + + + + + + + +
    + + : +
    + +

    +
    + : +
    + "; + foreach ( $items as $item ) { + echo "
  • ". $item->name ."
  • "; + } + echo ""; + ?> +
    +


    + +   +
     
    +

    + + + + + + + "; + } + ?> + +
    + +
    + + + + + + + + + + + +
    + : +
    + +

    +
    + : +
    + "; + foreach ( $items as $item ) { + echo "
  • ". $item->name ."
  • "; + } + echo ""; + ?> +

    +


    +
    + + <?php echo JText::_( 'Restore' ); ?> +   +
    +
     
    +

    + + + + + + + "; + } + ?> + +
    + authorize( 'com_trash', 'manage' )) { - $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); -} - -require_once( JApplicationHelper::getPath( 'admin_html' ) ); - -$cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); -$mid = JRequest::getVar( 'mid', array(0), 'post', 'array' ); - -JArrayHelper::toInteger($cid, array(0)); -JArrayHelper::toInteger($mid, array(0)); - -switch ($task) -{ - case 'deleteconfirm': - viewdeleteTrash( $cid, $mid, $option ); - break; - - case 'delete': - deleteTrash( $cid, $option ); - break; - - case 'restoreconfirm': - viewrestoreTrash( $cid, $mid, $option ); - break; - - case 'restore': - restoreTrash( $cid, $option ); - break; - - case 'viewMenu': - viewTrashMenu( $option ); - break; - - case 'viewContent': - viewTrashContent( $option ); - break; - - default: - $return = JRequest::getCmd( 'return', 'viewContent', 'post' ); - if ( $return == 'viewMenu' ) { - viewTrashMenu( $option ); - } else { - viewTrashContent( $option ); - } - break; -} - - -/** -* Compiles a list of trash items -*/ -function viewTrashContent( $option ) -{ - global $mainframe; - - $db =& JFactory::getDBO(); - $filter_order = $mainframe->getUserStateFromRequest( "$option.viewContent.filter_order", 'filter_order', 'sectname', 'cmd' ); - $filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.viewContent.filter_order_Dir", 'filter_order_Dir', '', 'word' ); - $search = $mainframe->getUserStateFromRequest( "$option.search", 'search', '', 'string' ); - $search = JString::strtolower( $search ); - - $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); - $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); - - $where[] = 'c.state = -2'; - - if ($search) { - $where[] = 'LOWER(c.title) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); - } - - $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); - $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', s.name, cc.name, c.title'; - - // get the total number of content - $query = 'SELECT count(c.id)' - . ' FROM #__content AS c' - . ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' - . ' LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope = "content"' - . ' LEFT JOIN #__groups AS g ON g.id = c.access' - . ' LEFT JOIN #__users AS u ON u.id = c.checked_out' - . $where - ; - $db->setQuery( $query ); - $total = $db->loadResult(); - - jimport('joomla.html.pagination'); - $pageNav = new JPagination( $total, $limitstart, $limit ); - - // Query articles - $query = 'SELECT c.title, c.id, c.sectionid, c.catid, g.name AS groupname, cc.title AS catname, s.title AS sectname' - . ' FROM #__content AS c' - . ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' - . ' LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope="content"' - . ' LEFT JOIN #__groups AS g ON g.id = c.access' - . ' LEFT JOIN #__users AS u ON u.id = c.checked_out' - . $where - . $orderby - ; - $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); - $contents = $db->loadObjectList(); - - for ( $i = 0; $i < count($contents); $i++ ) { - if ( ( $contents[$i]->sectionid == 0 ) && ( $contents[$i]->catid == 0 ) ) { - $contents[$i]->sectname = JText::_('UNCATEGORIZED'); - } - } - - // table ordering - $lists['order_Dir'] = $filter_order_Dir; - $lists['order'] = $filter_order; - - // search filter - $lists['search']= $search; - - HTML_trash::showListContent( $option, $contents, $pageNav, $lists ); -} - -/** -* Compiles a list of trash items -*/ -function viewTrashMenu( $option ) -{ - global $mainframe; - - $db =& JFactory::getDBO(); - $filter_order = $mainframe->getUserStateFromRequest( "$option.viewMenu.filter_order", 'filter_order', 'm.menutype', 'cmd' ); - $filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.viewMenu.filter_order_Dir", 'filter_order_Dir', '', 'word' ); - $limit = $mainframe->getUserStateFromRequest( "limit", 'limit', $mainframe->getCfg('list_limit'), 'int' ); - $limitstart = $mainframe->getUserStateFromRequest( "$option.viewMenu.limitstart", 'limitstart', 0, 'int' ); - $search = $mainframe->getUserStateFromRequest( "$option.search", 'search', '', 'string' ); - $search = JString::strtolower( $search ); - - $where[] = 'm.published = -2'; - - if ($search) { - $where[] = 'LOWER(m.name) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); - } - - $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); - $orderby = ' ORDER BY '. $filter_order . ' ' . $filter_order_Dir .', m.menutype, m.ordering, m.ordering, m.name'; - - $query = 'SELECT count(*)' - . ' FROM #__menu AS m' - . ' LEFT JOIN #__users AS u ON u.id = m.checked_out' - . $where - ; - $db->setQuery( $query ); - $total = $db->loadResult(); - - jimport('joomla.html.pagination'); - $pageNav = new JPagination( $total, $limitstart, $limit ); - - // Query menu items - $query = 'SELECT m.name, m.id, m.menutype, m.type, com.name AS com_name' - . ' FROM #__menu AS m' - . ' LEFT JOIN #__users AS u ON u.id = m.checked_out' - . ' LEFT JOIN #__components AS com ON com.id = m.componentid AND m.type = "components"' - . $where - . $orderby - ; - $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); - $menus = $db->loadObjectList(); - - // table ordering - $lists['order_Dir'] = $filter_order_Dir; - $lists['order'] = $filter_order; - - // search filter - $lists['search']= $search; - - HTML_trash::showListMenu( $option, $menus, $pageNav, $lists ); -} - - -/** -* Compiles a list of the items you have selected to permanently delte -*/ -function viewdeleteTrash( $cid, $mid, $option ) -{ - global $mainframe; - - $db =& JFactory::getDBO(); - $return = JRequest::getCmd( 'return', 'viewContent', 'post' ); - - JArrayHelper::toInteger($cid, array(0)); - JArrayHelper::toInteger($mid, array(0)); - - // seperate contentids - $cids = implode( ',', $cid ); - $mids = implode( ',', $mid ); - - if ( $cids ) { - // Articles query - $query = 'SELECT a.title AS name' - . ' FROM #__content AS a' - . ' WHERE ( a.id IN ( '.$cids.' ) )' - . ' ORDER BY a.title' - ; - $db->setQuery( $query ); - $items = $db->loadObjectList(); - $id = $cid; - $type = "content"; - } else if ( $mids ) { - // Articles query - $query = 'SELECT a.name' - . ' FROM #__menu AS a' - . ' WHERE ( a.id IN ( '.$mids.' ) )' - . ' ORDER BY a.name' - ; - $db->setQuery( $query ); - $items = $db->loadObjectList(); - $id = $mid; - $type = "menu"; - } - - HTML_trash::showDelete( $option, $id, $items, $type, $return ); -} - - -/** -* Permanently deletes the selected list of trash items -*/ -function deleteTrash( $cid, $option ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $return = JRequest::getCmd( 'return', 'viewContent', 'post' ); - $type = JRequest::getCmd( 'type', '', 'post' ); - - $total = count( $cid ); - - if ( $type == 'content' ) - { - $obj =& JTable::getInstance('content'); - - require_once (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_frontpage'.DS.'tables'.DS.'frontpage.php'); - $fp = new TableFrontPage( $db ); - foreach ( $cid as $id ) { - $id = intval( $id ); - $obj->delete( $id ); - $fp->delete( $id ); - } - } else if ( $type == "menu" ) { - $obj =& JTable::getInstance('menu'); - foreach ( $cid as $id ) { - $id = intval( $id ); - $obj->delete( $id ); - } - } - - $msg = JText::sprintf( 'Item(s) successfully Deleted', $total ); - $mainframe->redirect( 'index.php?option='.$option.'&task='.$return, $msg ); -} - - -/** -* Compiles a list of the items you have selected to permanently delte -*/ -function viewrestoreTrash( $cid, $mid, $option ) { - global $mainframe; - - $db =& JFactory::getDBO(); - $return = JRequest::getCmd( 'return', 'viewContent', 'post' ); - - JArrayHelper::toInteger($cid, array(0)); - JArrayHelper::toInteger($mid, array(0)); - - // seperate contentids - $cids = implode( ',', $cid ); - $mids = implode( ',', $mid ); - - if ( $cids ) { - // Articles query - $query = 'SELECT a.title AS name' - . ' FROM #__content AS a' - . ' WHERE ( a.id IN ( '.$cids.' ) )' - . ' ORDER BY a.title' - ; - $db->setQuery( $query ); - $items = $db->loadObjectList(); - $id = $cid; - $type = "content"; - } else if ( $mids ) { - // Articles query - $query = 'SELECT a.name' - . ' FROM #__menu AS a' - . ' WHERE ( a.id IN ( '.$mids.' ) )' - . ' ORDER BY a.name' - ; - $db->setQuery( $query ); - $items = $db->loadObjectList(); - $id = $mid; - $type = "menu"; - } - - HTML_trash::showRestore( $option, $id, $items, $type, $return ); -} - - -/** -* Restores items selected to normal - restores to an unpublished state -*/ -function restoreTrash( $cid, $option ) -{ - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db = & JFactory::getDBO(); - $type = JRequest::getCmd( 'type', '', 'post' ); - - $total = count( $cid ); - - // restores to an unpublished state - $state = 0; - $ordering = 9999; - - if ( $type == 'content' ) { - $return = 'viewContent'; - - //seperate contentids - JArrayHelper::toInteger($cid, array(0)); - $cids = implode( ',', $cid ); - - // query to restore article - $query = 'UPDATE #__content' - . ' SET state = '.(int) $state.', ordering = '.(int) $ordering - . ' WHERE id IN ( '.$cids.' )' - ; - $db->setQuery( $query ); - if ( !$db->query() ) { - JError::raiseError(500, $db->getErrorMsg() ); - } - } else if ( $type == 'menu' ) { - $return = 'viewMenu'; - - jimport('joomla.application.component.model'); - JModel::addIncludePath(JPATH_BASE.DS.'components'.DS.'com_menus'.DS.'models'); - $model =& JModel::getInstance('List', 'MenusModel'); - $total = $model->fromTrash($cid); - - if (!$total) { - JError::raiseError(500, $db->getErrorMsg() ); - } - } - - $msg = JText::sprintf( 'Item(s) successfully Restored', $total ); - $mainframe->redirect( 'index.php?option='.$option.'&task='.$return, $msg ); -} - -function ReadMenuXML( $type, $component=-1 ) -{ - // xml file for module - $xmlfile = JPATH_ADMINISTRATOR .'/components/com_menus/'. $type .'/'. $type .'.xml'; - - $data = JApplicationHelper::parseXMLInstallFile($xmlfile); - - if ( $data['type'] == 'component' || $data['type'] == 'menu' ) - { - if ( ( $component <> -1 ) && ( $data['name'] == 'Component') ) { - $data['name'] .= ' - '. $component; - } - - $row[0] = $data['name']; - } - - return $row; +authorize( 'com_trash', 'manage' )) { + $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); +} + +require_once( JApplicationHelper::getPath( 'admin_html' ) ); + +$cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); +$mid = JRequest::getVar( 'mid', array(0), 'post', 'array' ); + +JArrayHelper::toInteger($cid, array(0)); +JArrayHelper::toInteger($mid, array(0)); + +switch ($task) +{ + case 'deleteconfirm': + viewdeleteTrash( $cid, $mid, $option ); + break; + + case 'delete': + deleteTrash( $cid, $option ); + break; + + case 'restoreconfirm': + viewrestoreTrash( $cid, $mid, $option ); + break; + + case 'restore': + restoreTrash( $cid, $option ); + break; + + case 'viewMenu': + viewTrashMenu( $option ); + break; + + case 'viewContent': + viewTrashContent( $option ); + break; + + default: + $return = JRequest::getCmd( 'return', 'viewContent', 'post' ); + if ( $return == 'viewMenu' ) { + viewTrashMenu( $option ); + } else { + viewTrashContent( $option ); + } + break; +} + + +/** +* Compiles a list of trash items +*/ +function viewTrashContent( $option ) +{ + global $mainframe; + + $db =& JFactory::getDBO(); + $filter_order = $mainframe->getUserStateFromRequest( "$option.viewContent.filter_order", 'filter_order', 'sectname', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.viewContent.filter_order_Dir", 'filter_order_Dir', '', 'word' ); + $search = $mainframe->getUserStateFromRequest( "$option.search", 'search', '', 'string' ); + if (strpos($search, '"') !== false) { + $search = str_replace(array('=', '<'), '', $search); + } + $search = JString::strtolower($search); + + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); + + $where[] = 'c.state = -2'; + + if ($search) { + $where[] = 'LOWER(c.title) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + + $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); + $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir .', s.name, cc.name, c.title'; + + // get the total number of content + $query = 'SELECT count(c.id)' + . ' FROM #__content AS c' + . ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' + . ' LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope = "content"' + . ' LEFT JOIN #__groups AS g ON g.id = c.access' + . ' LEFT JOIN #__users AS u ON u.id = c.checked_out' + . $where + ; + $db->setQuery( $query ); + $total = $db->loadResult(); + + jimport('joomla.html.pagination'); + $pageNav = new JPagination( $total, $limitstart, $limit ); + + // Query articles + $query = 'SELECT c.title, c.id, c.sectionid, c.catid, g.name AS groupname, cc.title AS catname, s.title AS sectname' + . ' FROM #__content AS c' + . ' LEFT JOIN #__categories AS cc ON cc.id = c.catid' + . ' LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope="content"' + . ' LEFT JOIN #__groups AS g ON g.id = c.access' + . ' LEFT JOIN #__users AS u ON u.id = c.checked_out' + . $where + . $orderby + ; + $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); + $contents = $db->loadObjectList(); + + for ( $i = 0; $i < count($contents); $i++ ) { + if ( ( $contents[$i]->sectionid == 0 ) && ( $contents[$i]->catid == 0 ) ) { + $contents[$i]->sectname = JText::_('UNCATEGORIZED'); + } + } + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search']= $search; + + HTML_trash::showListContent( $option, $contents, $pageNav, $lists ); +} + +/** +* Compiles a list of trash items +*/ +function viewTrashMenu( $option ) +{ + global $mainframe; + + $db =& JFactory::getDBO(); + $filter_order = $mainframe->getUserStateFromRequest( "$option.viewMenu.filter_order", 'filter_order', 'm.menutype', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.viewMenu.filter_order_Dir", 'filter_order_Dir', '', 'word' ); + $limit = $mainframe->getUserStateFromRequest( "limit", 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( "$option.viewMenu.limitstart", 'limitstart', 0, 'int' ); + $search = $mainframe->getUserStateFromRequest( "$option.search", 'search', '', 'string' ); + if (strpos($search, '"') !== false) { + $search = str_replace(array('=', '<'), '', $search); + } + $search = JString::strtolower($search); + + $where[] = 'm.published = -2'; + + if ($search) { + $where[] = 'LOWER(m.name) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + + $where = ( count( $where ) ? ' WHERE ' . implode( ' AND ', $where ) : '' ); + $orderby = ' ORDER BY '. $filter_order . ' ' . $filter_order_Dir .', m.menutype, m.ordering, m.ordering, m.name'; + + $query = 'SELECT count(*)' + . ' FROM #__menu AS m' + . ' LEFT JOIN #__users AS u ON u.id = m.checked_out' + . $where + ; + $db->setQuery( $query ); + $total = $db->loadResult(); + + jimport('joomla.html.pagination'); + $pageNav = new JPagination( $total, $limitstart, $limit ); + + // Query menu items + $query = 'SELECT m.name, m.id, m.menutype, m.type, com.name AS com_name' + . ' FROM #__menu AS m' + . ' LEFT JOIN #__users AS u ON u.id = m.checked_out' + . ' LEFT JOIN #__components AS com ON com.id = m.componentid AND m.type = "components"' + . $where + . $orderby + ; + $db->setQuery( $query, $pageNav->limitstart, $pageNav->limit ); + $menus = $db->loadObjectList(); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search']= $search; + + HTML_trash::showListMenu( $option, $menus, $pageNav, $lists ); +} + + +/** +* Compiles a list of the items you have selected to permanently delte +*/ +function viewdeleteTrash( $cid, $mid, $option ) +{ + global $mainframe; + + $db =& JFactory::getDBO(); + $return = JRequest::getCmd( 'return', 'viewContent', 'post' ); + + JArrayHelper::toInteger($cid, array(0)); + JArrayHelper::toInteger($mid, array(0)); + + // seperate contentids + $cids = implode( ',', $cid ); + $mids = implode( ',', $mid ); + + if ( $cids ) { + // Articles query + $query = 'SELECT a.title AS name' + . ' FROM #__content AS a' + . ' WHERE ( a.id IN ( '.$cids.' ) )' + . ' ORDER BY a.title' + ; + $db->setQuery( $query ); + $items = $db->loadObjectList(); + $id = $cid; + $type = "content"; + } else if ( $mids ) { + // Articles query + $query = 'SELECT a.name' + . ' FROM #__menu AS a' + . ' WHERE ( a.id IN ( '.$mids.' ) )' + . ' ORDER BY a.name' + ; + $db->setQuery( $query ); + $items = $db->loadObjectList(); + $id = $mid; + $type = "menu"; + } + + HTML_trash::showDelete( $option, $id, $items, $type, $return ); +} + + +/** +* Permanently deletes the selected list of trash items +*/ +function deleteTrash( $cid, $option ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $return = JRequest::getCmd( 'return', 'viewContent', 'post' ); + $type = JRequest::getCmd( 'type', '', 'post' ); + + $total = count( $cid ); + + if ( $type == 'content' ) + { + $obj =& JTable::getInstance('content'); + + require_once (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_frontpage'.DS.'tables'.DS.'frontpage.php'); + $fp = new TableFrontPage( $db ); + foreach ( $cid as $id ) { + $id = intval( $id ); + $obj->delete( $id ); + $fp->delete( $id ); + } + } else if ( $type == "menu" ) { + $obj =& JTable::getInstance('menu'); + foreach ( $cid as $id ) { + $id = intval( $id ); + $obj->delete( $id ); + } + } + + $msg = JText::sprintf( 'Item(s) successfully Deleted', $total ); + $mainframe->redirect( 'index.php?option='.$option.'&task='.$return, $msg ); +} + + +/** +* Compiles a list of the items you have selected to permanently delte +*/ +function viewrestoreTrash( $cid, $mid, $option ) { + global $mainframe; + + $db =& JFactory::getDBO(); + $return = JRequest::getCmd( 'return', 'viewContent', 'post' ); + + JArrayHelper::toInteger($cid, array(0)); + JArrayHelper::toInteger($mid, array(0)); + + // seperate contentids + $cids = implode( ',', $cid ); + $mids = implode( ',', $mid ); + + if ( $cids ) { + // Articles query + $query = 'SELECT a.title AS name' + . ' FROM #__content AS a' + . ' WHERE ( a.id IN ( '.$cids.' ) )' + . ' ORDER BY a.title' + ; + $db->setQuery( $query ); + $items = $db->loadObjectList(); + $id = $cid; + $type = "content"; + } else if ( $mids ) { + // Articles query + $query = 'SELECT a.name' + . ' FROM #__menu AS a' + . ' WHERE ( a.id IN ( '.$mids.' ) )' + . ' ORDER BY a.name' + ; + $db->setQuery( $query ); + $items = $db->loadObjectList(); + $id = $mid; + $type = "menu"; + } + + HTML_trash::showRestore( $option, $id, $items, $type, $return ); +} + + +/** +* Restores items selected to normal - restores to an unpublished state +*/ +function restoreTrash( $cid, $option ) +{ + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db = & JFactory::getDBO(); + $type = JRequest::getCmd( 'type', '', 'post' ); + + $total = count( $cid ); + + // restores to an unpublished state + $state = 0; + $ordering = 9999; + + if ( $type == 'content' ) { + $return = 'viewContent'; + + //seperate contentids + JArrayHelper::toInteger($cid, array(0)); + $cids = implode( ',', $cid ); + + // query to restore article + $query = 'UPDATE #__content' + . ' SET state = '.(int) $state.', ordering = '.(int) $ordering + . ' WHERE id IN ( '.$cids.' )' + ; + $db->setQuery( $query ); + if ( !$db->query() ) { + JError::raiseError(500, $db->getErrorMsg() ); + } + } else if ( $type == 'menu' ) { + $return = 'viewMenu'; + + jimport('joomla.application.component.model'); + JModel::addIncludePath(JPATH_BASE.DS.'components'.DS.'com_menus'.DS.'models'); + $model =& JModel::getInstance('List', 'MenusModel'); + $total = $model->fromTrash($cid); + + if (!$total) { + JError::raiseError(500, $db->getErrorMsg() ); + } + } + + $msg = JText::sprintf( 'Item(s) successfully Restored', $total ); + $mainframe->redirect( 'index.php?option='.$option.'&task='.$return, $msg ); +} + +function ReadMenuXML( $type, $component=-1 ) +{ + // xml file for module + $xmlfile = JPATH_ADMINISTRATOR .'/components/com_menus/'. $type .'/'. $type .'.xml'; + + $data = JApplicationHelper::parseXMLInstallFile($xmlfile); + + if ( $data['type'] == 'component' || $data['type'] == 'menu' ) + { + if ( ( $component <> -1 ) && ( $data['name'] == 'Component') ) { + $data['name'] .= ' - '. $component; + } + + $row[0] = $data['name']; + } + + return $row; } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_trash/toolbar.trash.html.php b/oss/joomla/trunk/administrator/components/com_trash/toolbar.trash.html.php index 68b7c327..f80c897e 100644 --- a/oss/joomla/trunk/administrator/components/com_trash/toolbar.trash.html.php +++ b/oss/joomla/trunk/administrator/components/com_trash/toolbar.trash.html.php @@ -1,48 +1,48 @@ -['. JText::_( 'Menu Items' ) .']'; - } else { - $text = ': ['. JText::_( 'Articles' ) .']'; - } - - JToolBarHelper::title( JText::_( 'Trash Manager' ) . $text, 'trash.png' ); - JToolBarHelper::custom('restoreconfirm','restore.png','restore_f2.png', 'Restore', true); - JToolBarHelper::custom('deleteconfirm','delete.png','delete_f2.png', 'Delete', true); - JToolBarHelper::help( 'screen.trashmanager' ); - } - - function _RESTORE() { - JToolBarHelper::title( JText::_( 'Restore Items' ), 'restoredb.png' ); - JToolBarHelper::cancel(); - } - - function _DELETE() { - JToolBarHelper::title( JText::_( 'Delete Items' ), 'delete_f2.png' ); - JToolBarHelper::cancel(); - } +['. JText::_( 'Menu Items' ) .']'; + } else { + $text = ': ['. JText::_( 'Articles' ) .']'; + } + + JToolBarHelper::title( JText::_( 'Trash Manager' ) . $text, 'trash.png' ); + JToolBarHelper::custom('restoreconfirm','restore.png','restore_f2.png', 'Restore', true); + JToolBarHelper::custom('deleteconfirm','delete.png','delete_f2.png', 'Delete', true); + JToolBarHelper::help( 'screen.trashmanager' ); + } + + function _RESTORE() { + JToolBarHelper::title( JText::_( 'Restore Items' ), 'restoredb.png' ); + JToolBarHelper::cancel(); + } + + function _DELETE() { + JToolBarHelper::title( JText::_( 'Delete Items' ), 'delete_f2.png' ); + JToolBarHelper::cancel(); + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_trash/toolbar.trash.php b/oss/joomla/trunk/administrator/components/com_trash/toolbar.trash.php index 9e06f1c5..9975c788 100644 --- a/oss/joomla/trunk/administrator/components/com_trash/toolbar.trash.php +++ b/oss/joomla/trunk/administrator/components/com_trash/toolbar.trash.php @@ -1,33 +1,33 @@ - - - Trash - Joomla! Project - Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - admin@joomla.org - www.joomla.org - 1.0.0 - PARAMTRASH - + + + Trash + Joomla! Project + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.0.0 + PARAMTRASH + diff --git a/oss/joomla/trunk/administrator/components/com_users/controller.php b/oss/joomla/trunk/administrator/components/com_users/controller.php index 8836312b..369afc55 100644 --- a/oss/joomla/trunk/administrator/components/com_users/controller.php +++ b/oss/joomla/trunk/administrator/components/com_users/controller.php @@ -1,464 +1,465 @@ -registerTask( 'add' , 'display' ); - $this->registerTask( 'edit' , 'display' ); - $this->registerTask( 'apply', 'save' ); - $this->registerTask( 'flogout', 'logout'); - $this->registerTask( 'unblock', 'block' ); - } - - /** - * Displays a view - */ - function display( ) - { - switch($this->getTask()) - { - case 'add' : - { JRequest::setVar( 'hidemainmenu', 1 ); - JRequest::setVar( 'layout', 'form' ); - JRequest::setVar( 'view', 'user' ); - JRequest::setVar( 'edit', false ); - } break; - case 'edit' : - { - JRequest::setVar( 'hidemainmenu', 1 ); - JRequest::setVar( 'layout', 'form' ); - JRequest::setVar( 'view', 'user' ); - JRequest::setVar( 'edit', true ); - } break; - } - - parent::display(); - } - - /** - * Saves the record - */ - function save() - { - global $mainframe; - - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $option = JRequest::getCmd( 'option'); - - // Initialize some variables - $db = & JFactory::getDBO(); - $me = & JFactory::getUser(); - $acl =& JFactory::getACL(); - $MailFrom = $mainframe->getCfg('mailfrom'); - $FromName = $mainframe->getCfg('fromname'); - $SiteName = $mainframe->getCfg('sitename'); - - // Create a new JUser object - $user = new JUser(JRequest::getVar( 'id', 0, 'post', 'int')); - $original_gid = $user->get('gid'); - - $post = JRequest::get('post'); - $post['username'] = JRequest::getVar('username', '', 'post', 'username'); - $post['password'] = JRequest::getVar('password', '', 'post', 'string', JREQUEST_ALLOWRAW); - $post['password2'] = JRequest::getVar('password2', '', 'post', 'string', JREQUEST_ALLOWRAW); - - if (!$user->bind($post)) - { - $mainframe->enqueueMessage(JText::_('CANNOT SAVE THE USER INFORMATION'), 'message'); - $mainframe->enqueueMessage($user->getError(), 'error'); - //$mainframe->redirect( 'index.php?option=com_users', $user->getError() ); - //return false; - return $this->execute('edit'); - } - - $objectID = $acl->get_object_id( 'users', $user->get('id'), 'ARO' ); - $groups = $acl->get_object_groups( $objectID, 'ARO' ); - $this_group = strtolower( $acl->get_group_name( $groups[0], 'ARO' ) ); - - - if ( $user->get('id') == $me->get( 'id' ) && $user->get('block') == 1 ) - { - $msg = JText::_( 'You cannot block Yourself!' ); - $mainframe->enqueueMessage($msg, 'message'); - return $this->execute('edit'); - } - else if ( ( $this_group == 'super administrator' ) && $user->get('block') == 1 ) { - $msg = JText::_( 'You cannot block a Super Administrator' ); - $mainframe->enqueueMessage($msg, 'message'); - return $this->execute('edit'); - } - else if ( ( $this_group == 'administrator' ) && ( $me->get( 'gid' ) == 24 ) && $user->get('block') == 1 ) - { - $msg = JText::_( 'WARNBLOCK' ); - $mainframe->enqueueMessage($msg, 'message'); - return $this->execute('edit'); - } - else if ( ( $this_group == 'super administrator' ) && ( $me->get( 'gid' ) != 25 ) ) - { - $msg = JText::_( 'You cannot edit a super administrator account' ); - $mainframe->enqueueMessage($msg, 'message'); - return $this->execute('edit'); - } - // Are we dealing with a new user which we need to create? - $isNew = ($user->get('id') < 1); - if (!$isNew) - { - // if group has been changed and where original group was a Super Admin - if ( $user->get('gid') != $original_gid && $original_gid == 25 ) - { - // count number of active super admins - $query = 'SELECT COUNT( id )' - . ' FROM #__users' - . ' WHERE gid = 25' - . ' AND block = 0' - ; - $db->setQuery( $query ); - $count = $db->loadResult(); - - if ( $count <= 1 ) - { - // disallow change if only one Super Admin exists - $this->setRedirect( 'index.php?option=com_users', JText::_('WARN_ONLY_SUPER') ); - return false; - } - } - } - - /* - * Lets save the JUser object - */ - if (!$user->save()) - { - - $mainframe->enqueueMessage(JText::_('CANNOT SAVE THE USER INFORMATION'), 'message'); - $mainframe->enqueueMessage($user->getError(), 'error'); - return $this->execute('edit'); - } - - /* - * Time for the email magic so get ready to sprinkle the magic dust... - */ - if ($isNew) - { - $adminEmail = $me->get('email'); - $adminName = $me->get('name'); - - $subject = JText::_('NEW_USER_MESSAGE_SUBJECT'); - $message = sprintf ( JText::_('NEW_USER_MESSAGE'), $user->get('name'), $SiteName, JURI::root(), $user->get('username'), $user->password_clear ); - - if ($MailFrom != '' && $FromName != '') - { - $adminName = $FromName; - $adminEmail = $MailFrom; - } - JUtility::sendMail( $adminEmail, $adminName, $user->get('email'), $subject, $message ); - } - - // If updating self, load the new user object into the session - if ($user->get('id') == $me->get('id')) - { - // Get an ACL object - $acl = &JFactory::getACL(); - - // Get the user group from the ACL - $grp = $acl->getAroGroup($user->get('id')); - - // Mark the user as logged in - $user->set('guest', 0); - $user->set('aid', 1); - - // Fudge Authors, Editors, Publishers and Super Administrators into the special access group - if ($acl->is_group_child_of($grp->name, 'Registered') || - $acl->is_group_child_of($grp->name, 'Public Backend')) { - $user->set('aid', 2); - } - - // Set the usertype based on the ACL group name - $user->set('usertype', $grp->name); - - $session = &JFactory::getSession(); - $session->set('user', $user); - } - - switch ( $this->getTask() ) - { - case 'apply': - $msg = JText::sprintf( 'Successfully Saved changes to User', $user->get('name') ); - $this->setRedirect( 'index.php?option=com_users&view=user&task=edit&cid[]='. $user->get('id'), $msg ); - break; - - case 'save': - default: - $msg = JText::sprintf( 'Successfully Saved User', $user->get('name') ); - $this->setRedirect( 'index.php?option=com_users', $msg ); - break; - } - } - - /** - * Removes the record(s) from the database - */ - function remove() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $currentUser =& JFactory::getUser(); - $acl =& JFactory::getACL(); - $cid = JRequest::getVar( 'cid', array(), '', 'array' ); - - JArrayHelper::toInteger( $cid ); - - if (count( $cid ) < 1) { - JError::raiseError(500, JText::_( 'Select a User to delete', true ) ); - } - - foreach ($cid as $id) - { - // check for a super admin ... can't delete them - $objectID = $acl->get_object_id( 'users', $id, 'ARO' ); - $groups = $acl->get_object_groups( $objectID, 'ARO' ); - $this_group = strtolower( $acl->get_group_name( $groups[0], 'ARO' ) ); - - $success = false; - if ( $this_group == 'super administrator' ) - { - $msg = JText::_( 'You cannot delete a Super Administrator' ); - } - else if ( $id == $currentUser->get( 'id' ) ) - { - $msg = JText::_( 'You cannot delete Yourself!' ); - } - else if ( ( $this_group == 'administrator' ) && ( $currentUser->get( 'gid' ) == 24 ) ) - { - $msg = JText::_( 'WARNDELETE' ); - } - else - { - $user =& JUser::getInstance((int)$id); - $count = 2; - - if ( $user->get( 'gid' ) == 25 ) - { - // count number of active super admins - $query = 'SELECT COUNT( id )' - . ' FROM #__users' - . ' WHERE gid = 25' - . ' AND block = 0' - ; - $db->setQuery( $query ); - $count = $db->loadResult(); - } - - if ( $count <= 1 && $user->get( 'gid' ) == 25 ) - { - // cannot delete Super Admin where it is the only one that exists - $msg = "You cannot delete this Super Administrator as it is the only active Super Administrator for your site"; - } - else - { - // delete user - $user->delete(); - $msg = ''; - - JRequest::setVar( 'task', 'remove' ); - JRequest::setVar( 'cid', $id ); - - // delete user acounts active sessions - $this->logout(); - } - } - } - - $this->setRedirect( 'index.php?option=com_users', $msg); - } - - /** - * Cancels an edit operation - */ - function cancel( ) - { - $this->setRedirect( 'index.php?option=com_users' ); - } - - /** - * Disables the user account - */ - function block( ) - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $db =& JFactory::getDBO(); - $acl =& JFactory::getACL(); - $currentUser =& JFactory::getUser(); - - $cid = JRequest::getVar( 'cid', array(), '', 'array' ); - $block = $this->getTask() == 'block' ? 1 : 0; - - JArrayHelper::toInteger( $cid ); - - if (count( $cid ) < 1) { - JError::raiseError(500, JText::_( 'Select a User to '.$this->getTask(), true ) ); - } - foreach ($cid as $id) - { - // check for a super admin ... can't delete them - $objectID = $acl->get_object_id( 'users', $id, 'ARO' ); - $groups = $acl->get_object_groups( $objectID, 'ARO' ); - $this_group = strtolower( $acl->get_group_name( $groups[0], 'ARO' ) ); - - $success = false; - if ( $this_group == 'super administrator' ) - { - $msg = JText::_( 'You cannot block a Super Administrator' ); - } - else if ( $id == $currentUser->get( 'id' ) ) - { - $msg = JText::_( 'You cannot block Yourself!' ); - } - else if ( ( $this_group == 'administrator' ) && ( $currentUser->get( 'gid' ) == 24 ) ) - { - $msg = JText::_( 'WARNBLOCK' ); - } - else - { - $user =& JUser::getInstance((int)$id); - $count = 2; - - if ( $user->get( 'gid' ) == 25 ) - { - // count number of active super admins - $query = 'SELECT COUNT( id )' - . ' FROM #__users' - . ' WHERE gid = 25' - . ' AND block = 0' - ; - $db->setQuery( $query ); - $count = $db->loadResult(); - } - - if ( $count <= 1 && $user->get( 'gid' ) == 25 ) - { - // cannot delete Super Admin where it is the only one that exists - $msg = "You cannot block this Super Administrator as it is the only active Super Administrator for your site"; - } - else - { - $user =& JUser::getInstance((int)$id); - $user->block = $block; - $user->save(); - - if($block) - { - JRequest::setVar( 'task', 'block' ); - JRequest::setVar( 'cid', array($id) ); - - // delete user acounts active sessions - $this->logout(); - } - } - } - } - - $this->setRedirect( 'index.php?option=com_users', $msg); - } - - /** - * Force log out a user - */ - function logout( ) - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - global $mainframe; - - $db =& JFactory::getDBO(); - $task = $this->getTask(); - $cids = JRequest::getVar( 'cid', array(), '', 'array' ); - $client = JRequest::getVar( 'client', 0, '', 'int' ); - $id = JRequest::getVar( 'id', 0, '', 'int' ); - - JArrayHelper::toInteger($cids); - - if ( count( $cids ) < 1 ) { - $this->setRedirect( 'index.php?option=com_users', JText::_( 'User Deleted' ) ); - return false; - } - - foreach($cids as $cid) - { - $options = array(); - - if ($task == 'logout' || $task == 'block') { - $options['clientid'][] = 0; //site - $options['clientid'][] = 1; //administrator - } else if ($task == 'flogout') { - $options['clientid'][] = $client; - } - - $mainframe->logout((int)$cid, $options); - } - - - $msg = JText::_( 'User Session Ended' ); - switch ( $task ) - { - case 'flogout': - $this->setRedirect( 'index.php', $msg ); - break; - - case 'remove': - case 'block': - return; - break; - - default: - $this->setRedirect( 'index.php?option=com_users', $msg ); - break; - } - } - - function contact() - { - $contact_id = JRequest::getVar( 'contact_id', '', 'post', 'int' ); - $this->setRedirect( 'index.php?option=com_contact&task=edit&cid[]='. $contact_id ); - } -} +registerTask( 'add' , 'display' ); + $this->registerTask( 'edit' , 'display' ); + $this->registerTask( 'apply', 'save' ); + $this->registerTask( 'flogout', 'logout'); + $this->registerTask( 'unblock', 'block' ); + } + + /** + * Displays a view + */ + function display( ) + { + switch($this->getTask()) + { + case 'add' : + { JRequest::setVar( 'hidemainmenu', 1 ); + JRequest::setVar( 'layout', 'form' ); + JRequest::setVar( 'view', 'user' ); + JRequest::setVar( 'edit', false ); + } break; + case 'edit' : + { + JRequest::setVar( 'hidemainmenu', 1 ); + JRequest::setVar( 'layout', 'form' ); + JRequest::setVar( 'view', 'user' ); + JRequest::setVar( 'edit', true ); + } break; + } + + parent::display(); + } + + /** + * Saves the record + */ + function save() + { + global $mainframe; + + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $option = JRequest::getCmd( 'option'); + + // Initialize some variables + $db = & JFactory::getDBO(); + $me = & JFactory::getUser(); + $acl =& JFactory::getACL(); + $MailFrom = $mainframe->getCfg('mailfrom'); + $FromName = $mainframe->getCfg('fromname'); + $SiteName = $mainframe->getCfg('sitename'); + + // Create a new JUser object + $user = new JUser(JRequest::getVar( 'id', 0, 'post', 'int')); + $original_gid = $user->get('gid'); + + $post = JRequest::get('post'); + $post['username'] = JRequest::getVar('username', '', 'post', 'username'); + $post['password'] = JRequest::getVar('password', '', 'post', 'string', JREQUEST_ALLOWRAW); + $post['password2'] = JRequest::getVar('password2', '', 'post', 'string', JREQUEST_ALLOWRAW); + + if (!$user->bind($post)) + { + $mainframe->enqueueMessage(JText::_('CANNOT SAVE THE USER INFORMATION'), 'message'); + $mainframe->enqueueMessage($user->getError(), 'error'); + //$mainframe->redirect( 'index.php?option=com_users', $user->getError() ); + //return false; + return $this->execute('edit'); + } + + $objectID = $acl->get_object_id( 'users', $user->get('id'), 'ARO' ); + $groups = $acl->get_object_groups( $objectID, 'ARO' ); + $this_group = strtolower( $acl->get_group_name( $groups[0], 'ARO' ) ); + + + if ( $user->get('id') == $me->get( 'id' ) && $user->get('block') == 1 ) + { + $msg = JText::_( 'You cannot block Yourself!' ); + $mainframe->enqueueMessage($msg, 'message'); + return $this->execute('edit'); + } + else if ( ( $this_group == 'super administrator' ) && $user->get('block') == 1 ) { + $msg = JText::_( 'You cannot block a Super Administrator' ); + $mainframe->enqueueMessage($msg, 'message'); + return $this->execute('edit'); + } + else if ( ( $this_group == 'administrator' ) && ( $me->get( 'gid' ) == 24 ) && $user->get('block') == 1 ) + { + $msg = JText::_( 'WARNBLOCK' ); + $mainframe->enqueueMessage($msg, 'message'); + return $this->execute('edit'); + } + else if ( ( $this_group == 'super administrator' ) && ( $me->get( 'gid' ) != 25 ) ) + { + $msg = JText::_( 'You cannot edit a super administrator account' ); + $mainframe->enqueueMessage($msg, 'message'); + return $this->execute('edit'); + } + // Are we dealing with a new user which we need to create? + $isNew = ($user->get('id') < 1); + if (!$isNew) + { + // if group has been changed and where original group was a Super Admin + if ( $user->get('gid') != $original_gid && $original_gid == 25 ) + { + // count number of active super admins + $query = 'SELECT COUNT( id )' + . ' FROM #__users' + . ' WHERE gid = 25' + . ' AND block = 0' + ; + $db->setQuery( $query ); + $count = $db->loadResult(); + + if ( $count <= 1 ) + { + // disallow change if only one Super Admin exists + $this->setRedirect( 'index.php?option=com_users', JText::_('WARN_ONLY_SUPER') ); + return false; + } + } + } + + /* + * Lets save the JUser object + */ + if (!$user->save()) + { + + $mainframe->enqueueMessage(JText::_('CANNOT SAVE THE USER INFORMATION'), 'message'); + $mainframe->enqueueMessage($user->getError(), 'error'); + return $this->execute('edit'); + } + + /* + * Time for the email magic so get ready to sprinkle the magic dust... + */ + if ($isNew) + { + $adminEmail = $me->get('email'); + $adminName = $me->get('name'); + + $subject = JText::_('NEW_USER_MESSAGE_SUBJECT'); + $message = sprintf ( JText::_('NEW_USER_MESSAGE'), $user->get('name'), $SiteName, JURI::root(), $user->get('username'), $user->password_clear ); + + if ($MailFrom != '' && $FromName != '') + { + $adminName = $FromName; + $adminEmail = $MailFrom; + } + JUtility::sendMail( $adminEmail, $adminName, $user->get('email'), $subject, $message ); + } + + // If updating self, load the new user object into the session + if ($user->get('id') == $me->get('id')) + { + // Get an ACL object + $acl = &JFactory::getACL(); + + // Get the user group from the ACL + $grp = $acl->getAroGroup($user->get('id')); + + // Mark the user as logged in + $user->set('guest', 0); + $user->set('aid', 1); + + // Fudge Authors, Editors, Publishers and Super Administrators into the special access group + if ($acl->is_group_child_of($grp->name, 'Registered') || + $acl->is_group_child_of($grp->name, 'Public Backend')) { + $user->set('aid', 2); + } + + // Set the usertype based on the ACL group name + $user->set('usertype', $grp->name); + + $session = &JFactory::getSession(); + $session->set('user', $user); + } + + switch ( $this->getTask() ) + { + case 'apply': + $msg = JText::sprintf( 'Successfully Saved changes to User', $user->get('name') ); + $this->setRedirect( 'index.php?option=com_users&view=user&task=edit&cid[]='. $user->get('id'), $msg ); + break; + + case 'save': + default: + $msg = JText::sprintf( 'Successfully Saved User', $user->get('name') ); + $this->setRedirect( 'index.php?option=com_users', $msg ); + break; + } + } + + /** + * Removes the record(s) from the database + */ + function remove() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $currentUser =& JFactory::getUser(); + $acl =& JFactory::getACL(); + $cid = JRequest::getVar( 'cid', array(), '', 'array' ); + + JArrayHelper::toInteger( $cid ); + + if (count( $cid ) < 1) { + JError::raiseError(500, JText::_( 'Select a User to delete', true ) ); + } + + foreach ($cid as $id) + { + // check for a super admin ... can't delete them + $objectID = $acl->get_object_id( 'users', $id, 'ARO' ); + $groups = $acl->get_object_groups( $objectID, 'ARO' ); + $this_group = strtolower( $acl->get_group_name( $groups[0], 'ARO' ) ); + + $success = false; + if ( $this_group == 'super administrator' ) + { + $msg = JText::_( 'You cannot delete a Super Administrator' ); + } + else if ( $id == $currentUser->get( 'id' ) ) + { + $msg = JText::_( 'You cannot delete Yourself!' ); + } + else if ( ( $this_group == 'administrator' ) && ( $currentUser->get( 'gid' ) == 24 ) ) + { + $msg = JText::_( 'WARNDELETE' ); + } + else + { + $user =& JUser::getInstance((int)$id); + $count = 2; + + if ( $user->get( 'gid' ) == 25 ) + { + // count number of active super admins + $query = 'SELECT COUNT( id )' + . ' FROM #__users' + . ' WHERE gid = 25' + . ' AND block = 0' + ; + $db->setQuery( $query ); + $count = $db->loadResult(); + } + + if ( $count <= 1 && $user->get( 'gid' ) == 25 ) + { + // cannot delete Super Admin where it is the only one that exists + $msg = "You cannot delete this Super Administrator as it is the only active Super Administrator for your site"; + } + else + { + // delete user + $user->delete(); + $msg = ''; + + JRequest::setVar( 'task', 'remove' ); + JRequest::setVar( 'cid', $id ); + + // delete user acounts active sessions + $this->logout(); + } + } + } + + $this->setRedirect( 'index.php?option=com_users', $msg); + } + + /** + * Cancels an edit operation + */ + function cancel( ) + { + $this->setRedirect( 'index.php?option=com_users' ); + } + + /** + * Disables the user account + */ + function block( ) + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $db =& JFactory::getDBO(); + $acl =& JFactory::getACL(); + $currentUser =& JFactory::getUser(); + + $cid = JRequest::getVar( 'cid', array(), '', 'array' ); + $block = $this->getTask() == 'block' ? 1 : 0; + + JArrayHelper::toInteger( $cid ); + + if (count( $cid ) < 1) { + JError::raiseError(500, JText::_( 'Select a User to '.$this->getTask(), true ) ); + } + foreach ($cid as $id) + { + // check for a super admin ... can't delete them + $objectID = $acl->get_object_id( 'users', $id, 'ARO' ); + $groups = $acl->get_object_groups( $objectID, 'ARO' ); + $this_group = strtolower( $acl->get_group_name( $groups[0], 'ARO' ) ); + + $msg = ''; + $success = false; + if ( $this_group == 'super administrator' ) + { + $msg = JText::_( 'You cannot block a Super Administrator' ); + } + else if ( $id == $currentUser->get( 'id' ) ) + { + $msg = JText::_( 'You cannot block Yourself!' ); + } + else if ( ( $this_group == 'administrator' ) && ( $currentUser->get( 'gid' ) == 24 ) ) + { + $msg = JText::_( 'WARNBLOCK' ); + } + else + { + $user =& JUser::getInstance((int)$id); + $count = 2; + + if ( $user->get( 'gid' ) == 25 ) + { + // count number of active super admins + $query = 'SELECT COUNT( id )' + . ' FROM #__users' + . ' WHERE gid = 25' + . ' AND block = 0' + ; + $db->setQuery( $query ); + $count = $db->loadResult(); + } + + if ( $count <= 1 && $user->get( 'gid' ) == 25 ) + { + // cannot delete Super Admin where it is the only one that exists + $msg = "You cannot block this Super Administrator as it is the only active Super Administrator for your site"; + } + else + { + $user =& JUser::getInstance((int)$id); + $user->block = $block; + $user->save(); + + if($block) + { + JRequest::setVar( 'task', 'block' ); + JRequest::setVar( 'cid', array($id) ); + + // delete user acounts active sessions + $this->logout(); + } + } + } + } + + $this->setRedirect( 'index.php?option=com_users', $msg); + } + + /** + * Force log out a user + */ + function logout( ) + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + global $mainframe; + + $db =& JFactory::getDBO(); + $task = $this->getTask(); + $cids = JRequest::getVar( 'cid', array(), '', 'array' ); + $client = JRequest::getVar( 'client', 0, '', 'int' ); + $id = JRequest::getVar( 'id', 0, '', 'int' ); + + JArrayHelper::toInteger($cids); + + if ( count( $cids ) < 1 ) { + $this->setRedirect( 'index.php?option=com_users', JText::_( 'User Deleted' ) ); + return false; + } + + foreach($cids as $cid) + { + $options = array(); + + if ($task == 'logout' || $task == 'block') { + $options['clientid'][] = 0; //site + $options['clientid'][] = 1; //administrator + } else if ($task == 'flogout') { + $options['clientid'][] = $client; + } + + $mainframe->logout((int)$cid, $options); + } + + + $msg = JText::_( 'User Session Ended' ); + switch ( $task ) + { + case 'flogout': + $this->setRedirect( 'index.php', $msg ); + break; + + case 'remove': + case 'block': + return; + break; + + default: + $this->setRedirect( 'index.php?option=com_users', $msg ); + break; + } + } + + function contact() + { + $contact_id = JRequest::getVar( 'contact_id', '', 'post', 'int' ); + $this->setRedirect( 'index.php?option=com_contact&task=edit&cid[]='. $contact_id ); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_users/users.class.php b/oss/joomla/trunk/administrator/components/com_users/users.class.php index 1caa821f..ec8f6b60 100644 --- a/oss/joomla/trunk/administrator/components/com_users/users.class.php +++ b/oss/joomla/trunk/administrator/components/com_users/users.class.php @@ -1,30 +1,30 @@ -authorize( 'com_users', 'manage' )) { - $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); -} - -// Require the base controller -require_once (JPATH_COMPONENT.DS.'controller.php'); - -// Create the controller -$controller = new UsersController( ); - -// Perform the Request task -$controller->execute( JRequest::getCmd('task')); +authorize( 'com_users', 'manage' )) { + $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); +} + +// Require the base controller +require_once (JPATH_COMPONENT.DS.'controller.php'); + +// Create the controller +$controller = new UsersController( ); + +// Perform the Request task +$controller->execute( JRequest::getCmd('task')); $controller->redirect(); \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_users/users.xml b/oss/joomla/trunk/administrator/components/com_users/users.xml index 310edb4c..c59ff38a 100644 --- a/oss/joomla/trunk/administrator/components/com_users/users.xml +++ b/oss/joomla/trunk/administrator/components/com_users/users.xml @@ -1,12 +1,12 @@ - - - User Manager - Joomla! Project - April 2006 - (C) 2005 - 2008 Open Source Matters. All rights reserved. - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - admin@joomla.org - www.joomla.org - 1.5.0 - User Manager - + + + User Manager + Joomla! Project + April 2006 + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + User Manager + diff --git a/oss/joomla/trunk/administrator/components/com_users/views/user/view.html.php b/oss/joomla/trunk/administrator/components/com_users/views/user/view.html.php index bddb38ba..c800ccd3 100644 --- a/oss/joomla/trunk/administrator/components/com_users/views/user/view.html.php +++ b/oss/joomla/trunk/administrator/components/com_users/views/user/view.html.php @@ -1,141 +1,141 @@ -bind($post); - } - - if ( $user->get('id')) - { - $query = 'SELECT *' - . ' FROM #__contact_details' - . ' WHERE user_id = '.(int) $cid[0] - ; - $db->setQuery( $query ); - $contact = $db->loadObjectList(); - } - else - { - $contact = NULL; - // Get the default group id for a new user - $config = &JComponentHelper::getParams( 'com_users' ); - $newGrp = $config->get( 'new_usertype' ); - $user->set( 'gid', $acl->get_group_id( $newGrp, null, 'ARO' ) ); - } - - $userObjectID = $acl->get_object_id( 'users', $user->get('id'), 'ARO' ); - $userGroups = $acl->get_object_groups( $userObjectID, 'ARO' ); - $userGroupName = strtolower( $acl->get_group_name( $userGroups[0], 'ARO' ) ); - - $myObjectID = $acl->get_object_id( 'users', $myuser->get('id'), 'ARO' ); - $myGroups = $acl->get_object_groups( $myObjectID, 'ARO' ); - $myGroupName = strtolower( $acl->get_group_name( $myGroups[0], 'ARO' ) );; - - // ensure user can't add/edit group higher than themselves - /* NOTE : This check doesn't work commented out for the time being - if ( is_array( $myGroups ) && count( $myGroups ) > 0 ) - { - $excludeGroups = (array) $acl->get_group_children( $myGroups[0], 'ARO', 'RECURSE' ); - } - else - { - $excludeGroups = array(); - } - - if ( in_array( $userGroups[0], $excludeGroups ) ) - { - echo 'not auth'; - $mainframe->redirect( 'index.php?option=com_users', JText::_('NOT_AUTH') ); - } - */ - - /* - if ( $userGroupName == 'super administrator' ) - { - // super administrators can't change - $lists['gid'] = ''. JText::_( 'Super Administrator' ) .''; - } - else if ( $userGroupName == $myGroupName && $myGroupName == 'administrator' ) { - */ - - if ( $userGroupName == $myGroupName && $myGroupName == 'administrator' ) - { - // administrators can't change each other - $lists['gid'] = ''. JText::_( 'Administrator' ) .''; - } - else - { - $gtree = $acl->get_group_children_tree( null, 'USERS', false ); - - // remove users 'above' me - //$i = 0; - //while ($i < count( $gtree )) { - // if ( in_array( $gtree[$i]->value, (array)$excludeGroups ) ) { - // array_splice( $gtree, $i, 1 ); - // } else { - // $i++; - // } - //} - - $lists['gid'] = JHTML::_('select.genericlist', $gtree, 'gid', 'size="10"', 'value', 'text', $user->get('gid') ); - } - - // build the html select list - $lists['block'] = JHTML::_('select.booleanlist', 'block', 'class="inputbox" size="1"', $user->get('block') ); - - // build the html select list - $lists['sendEmail'] = JHTML::_('select.booleanlist', 'sendEmail', 'class="inputbox" size="1"', $user->get('sendEmail') ); - - $this->assignRef('me', $me); - $this->assignRef('lists', $lists); - $this->assignRef('user', $user); - $this->assignRef('contact', $contact); - - parent::display($tpl); - } -} +bind($post); + } + + if ( $user->get('id')) + { + $query = 'SELECT *' + . ' FROM #__contact_details' + . ' WHERE user_id = '.(int) $cid[0] + ; + $db->setQuery( $query ); + $contact = $db->loadObjectList(); + } + else + { + $contact = NULL; + // Get the default group id for a new user + $config = &JComponentHelper::getParams( 'com_users' ); + $newGrp = $config->get( 'new_usertype' ); + $user->set( 'gid', $acl->get_group_id( $newGrp, null, 'ARO' ) ); + } + + $userObjectID = $acl->get_object_id( 'users', $user->get('id'), 'ARO' ); + $userGroups = $acl->get_object_groups( $userObjectID, 'ARO' ); + $userGroupName = strtolower( $acl->get_group_name( $userGroups[0], 'ARO' ) ); + + $myObjectID = $acl->get_object_id( 'users', $myuser->get('id'), 'ARO' ); + $myGroups = $acl->get_object_groups( $myObjectID, 'ARO' ); + $myGroupName = strtolower( $acl->get_group_name( $myGroups[0], 'ARO' ) );; + + // ensure user can't add/edit group higher than themselves + /* NOTE : This check doesn't work commented out for the time being + if ( is_array( $myGroups ) && count( $myGroups ) > 0 ) + { + $excludeGroups = (array) $acl->get_group_children( $myGroups[0], 'ARO', 'RECURSE' ); + } + else + { + $excludeGroups = array(); + } + + if ( in_array( $userGroups[0], $excludeGroups ) ) + { + echo 'not auth'; + $mainframe->redirect( 'index.php?option=com_users', JText::_('NOT_AUTH') ); + } + */ + + /* + if ( $userGroupName == 'super administrator' ) + { + // super administrators can't change + $lists['gid'] = ''. JText::_( 'Super Administrator' ) .''; + } + else if ( $userGroupName == $myGroupName && $myGroupName == 'administrator' ) { + */ + + if ( $userGroupName == $myGroupName && $myGroupName == 'administrator' ) + { + // administrators can't change each other + $lists['gid'] = ''. JText::_( 'Administrator' ) .''; + } + else + { + $gtree = $acl->get_group_children_tree( null, 'USERS', false ); + + // remove users 'above' me + //$i = 0; + //while ($i < count( $gtree )) { + // if ( in_array( $gtree[$i]->value, (array)$excludeGroups ) ) { + // array_splice( $gtree, $i, 1 ); + // } else { + // $i++; + // } + //} + + $lists['gid'] = JHTML::_('select.genericlist', $gtree, 'gid', 'size="10"', 'value', 'text', $user->get('gid') ); + } + + // build the html select list + $lists['block'] = JHTML::_('select.booleanlist', 'block', 'class="inputbox" size="1"', $user->get('block') ); + + // build the html select list + $lists['sendEmail'] = JHTML::_('select.booleanlist', 'sendEmail', 'class="inputbox" size="1"', $user->get('sendEmail') ); + + $this->assignRef('me', $me); + $this->assignRef('lists', $lists); + $this->assignRef('user', $user); + $this->assignRef('contact', $contact); + + parent::display($tpl); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_users/views/users/tmpl/default.php b/oss/joomla/trunk/administrator/components/com_users/views/users/tmpl/default.php index 5a67726a..a78f3b6d 100644 --- a/oss/joomla/trunk/administrator/components/com_users/views/users/tmpl/default.php +++ b/oss/joomla/trunk/administrator/components/com_users/views/users/tmpl/default.php @@ -1,138 +1,138 @@ - - - - - - -
    - - - - - -
    - : - - - - - lists['type'];?> - lists['logged'];?> -
    - - - - - - - - - - - - - - - - - - - - - - - items ); $i < $n; $i++) - { - $row =& $this->items[$i]; - - $img = $row->block ? 'publish_x.png' : 'tick.png'; - $task = $row->block ? 'unblock' : 'block'; - $alt = $row->block ? JText::_( 'Enabled' ) : JText::_( 'Blocked' ); - $link = 'index.php?option=com_users&view=user&task=edit&cid[]='. $row->id. ''; - - if ($row->lastvisitDate == "0000-00-00 00:00:00") { - $lvisit = JText::_( 'Never' ); - } else { - $lvisit = JHTML::_('date', $row->lastvisitDate, '%Y-%m-%d %H:%M:%S'); - } - ?> - "> - - - - - - - - - - - - - -
    - - - - - lists['order_Dir'], @$this->lists['order'] ); ?> - - lists['order_Dir'], @$this->lists['order'] ); ?> - - - - lists['order_Dir'], @$this->lists['order'] ); ?> - - lists['order_Dir'], @$this->lists['order'] ); ?> - - lists['order_Dir'], @$this->lists['order'] ); ?> - - lists['order_Dir'], @$this->lists['order'] ); ?> - - lists['order_Dir'], @$this->lists['order'] ); ?> -
    - pagination->getListFooter(); ?> -
    - pagination->limitstart;?> - - id ); ?> - - - name; ?> - - username; ?> - - loggedin ? '': ''; ?> - - - <?php echo $alt; ?> - - groupname ); ?> - - - email; ?> - - - - id; ?> -
    - - - - - - - + + + + + + + + + + + + +
    + : + + + + + lists['type'];?> + lists['logged'];?> +
    + + + + + + + + + + + + + + + + + + + + + + + items ); $i < $n; $i++) + { + $row =& $this->items[$i]; + + $img = $row->block ? 'publish_x.png' : 'tick.png'; + $task = $row->block ? 'unblock' : 'block'; + $alt = $row->block ? JText::_( 'Enabled' ) : JText::_( 'Blocked' ); + $link = 'index.php?option=com_users&view=user&task=edit&cid[]='. $row->id. ''; + + if ($row->lastvisitDate == "0000-00-00 00:00:00") { + $lvisit = JText::_( 'Never' ); + } else { + $lvisit = JHTML::_('date', $row->lastvisitDate, '%Y-%m-%d %H:%M:%S'); + } + ?> + "> + + + + + + + + + + + + + +
    + + + + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + + + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> + + lists['order_Dir'], @$this->lists['order'] ); ?> +
    + pagination->getListFooter(); ?> +
    + pagination->limitstart;?> + + id ); ?> + + + name; ?> + + username; ?> + + loggedin ? '': ''; ?> + + + <?php echo $alt; ?> + + groupname ); ?> + + + email; ?> + + + + id; ?> +
    + + + + + + +
    \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_users/views/users/view.html.php b/oss/joomla/trunk/administrator/components/com_users/views/users/view.html.php index 182b1cab..badc2d6b 100644 --- a/oss/joomla/trunk/administrator/components/com_users/views/users/view.html.php +++ b/oss/joomla/trunk/administrator/components/com_users/views/users/view.html.php @@ -1,165 +1,168 @@ -getUserStateFromRequest( "$option.filter_order", 'filter_order', 'a.name', 'cmd' ); - $filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.filter_order_Dir", 'filter_order_Dir', '', 'word' ); - $filter_type = $mainframe->getUserStateFromRequest( "$option.filter_type", 'filter_type', 0, 'string' ); - $filter_logged = $mainframe->getUserStateFromRequest( "$option.filter_logged", 'filter_logged', 0, 'int' ); - $search = $mainframe->getUserStateFromRequest( "$option.search", 'search', '', 'string' ); - $search = JString::strtolower( $search ); - - $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); - $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); - - $where = array(); - if (isset( $search ) && $search!= '') - { - $searchEscaped = $db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); - $where[] = 'a.username LIKE '.$searchEscaped.' OR a.email LIKE '.$searchEscaped.' OR a.name LIKE '.$searchEscaped; - } - if ( $filter_type ) - { - if ( $filter_type == 'Public Frontend' ) - { - $where[] = ' a.usertype = \'Registered\' OR a.usertype = \'Author\' OR a.usertype = \'Editor\' OR a.usertype = \'Publisher\' '; - } - else if ( $filter_type == 'Public Backend' ) - { - $where[] = 'a.usertype = \'Manager\' OR a.usertype = \'Administrator\' OR a.usertype = \'Super Administrator\' '; - } - else - { - $where[] = 'a.usertype = LOWER( '.$db->Quote($filter_type).' ) '; - } - } - if ( $filter_logged == 1 ) - { - $where[] = 's.userid = a.id'; - } - else if ($filter_logged == 2) - { - $where[] = 's.userid IS NULL'; - } - - // exclude any child group id's for this user - $pgids = $acl->get_group_children( $currentUser->get('gid'), 'ARO', 'RECURSE' ); - - if (is_array( $pgids ) && count( $pgids ) > 0) - { - JArrayHelper::toInteger($pgids); - $where[] = 'a.gid NOT IN (' . implode( ',', $pgids ) . ')'; - } - $filter = ''; - if ($filter_logged == 1 || $filter_logged == 2) - { - $filter = ' INNER JOIN #__session AS s ON s.userid = a.id'; - } - - $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir; - $where = ( count( $where ) ? ' WHERE (' . implode( ') AND (', $where ) . ')' : '' ); - - $query = 'SELECT COUNT(a.id)' - . ' FROM #__users AS a' - . $filter - . $where - ; - $db->setQuery( $query ); - $total = $db->loadResult(); - - jimport('joomla.html.pagination'); - $pagination = new JPagination( $total, $limitstart, $limit ); - - $query = 'SELECT a.*, g.name AS groupname' - . ' FROM #__users AS a' - . ' INNER JOIN #__core_acl_aro AS aro ON aro.value = a.id' - . ' INNER JOIN #__core_acl_groups_aro_map AS gm ON gm.aro_id = aro.id' - . ' INNER JOIN #__core_acl_aro_groups AS g ON g.id = gm.group_id' - . $filter - . $where - . ' GROUP BY a.id' - . $orderby - ; - $db->setQuery( $query, $pagination->limitstart, $pagination->limit ); - $rows = $db->loadObjectList(); - - $n = count( $rows ); - $template = 'SELECT COUNT(s.userid)' - . ' FROM #__session AS s' - . ' WHERE s.userid = %d' - ; - for ($i = 0; $i < $n; $i++) - { - $row = &$rows[$i]; - $query = sprintf( $template, intval( $row->id ) ); - $db->setQuery( $query ); - $row->loggedin = $db->loadResult(); - } - - // get list of Groups for dropdown filter - $query = 'SELECT name AS value, name AS text' - . ' FROM #__core_acl_aro_groups' - . ' WHERE name != "ROOT"' - . ' AND name != "USERS"' - ; - $db->setQuery( $query ); - $types[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select Group' ) .' -' ); - foreach( $db->loadObjectList() as $obj ) - { - $types[] = JHTML::_('select.option', $obj->value, JText::_( $obj->text ) ); - } - $lists['type'] = JHTML::_('select.genericlist', $types, 'filter_type', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', "$filter_type" ); - - // get list of Log Status for dropdown filter - $logged[] = JHTML::_('select.option', 0, '- '. JText::_( 'Select Log Status' ) .' -'); - $logged[] = JHTML::_('select.option', 1, JText::_( 'Logged In' ) ); - $lists['logged'] = JHTML::_('select.genericlist', $logged, 'filter_logged', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', "$filter_logged" ); - - // table ordering - $lists['order_Dir'] = $filter_order_Dir; - $lists['order'] = $filter_order; - - // search filter - $lists['search']= $search; - - $this->assignRef('user', JFactory::getUser()); - $this->assignRef('lists', $lists); - $this->assignRef('items', $rows); - $this->assignRef('pagination', $pagination); - - parent::display($tpl); - } +getUserStateFromRequest( "$option.filter_order", 'filter_order', 'a.name', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( "$option.filter_order_Dir", 'filter_order_Dir', '', 'word' ); + $filter_type = $mainframe->getUserStateFromRequest( "$option.filter_type", 'filter_type', 0, 'string' ); + $filter_logged = $mainframe->getUserStateFromRequest( "$option.filter_logged", 'filter_logged', 0, 'int' ); + $search = $mainframe->getUserStateFromRequest( "$option.search", 'search', '', 'string' ); + if (strpos($search, '"') !== false) { + $search = str_replace(array('=', '<'), '', $search); + } + $search = JString::strtolower($search); + + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); + + $where = array(); + if (isset( $search ) && $search!= '') + { + $searchEscaped = $db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + $where[] = 'a.username LIKE '.$searchEscaped.' OR a.email LIKE '.$searchEscaped.' OR a.name LIKE '.$searchEscaped; + } + if ( $filter_type ) + { + if ( $filter_type == 'Public Frontend' ) + { + $where[] = ' a.usertype = \'Registered\' OR a.usertype = \'Author\' OR a.usertype = \'Editor\' OR a.usertype = \'Publisher\' '; + } + else if ( $filter_type == 'Public Backend' ) + { + $where[] = 'a.usertype = \'Manager\' OR a.usertype = \'Administrator\' OR a.usertype = \'Super Administrator\' '; + } + else + { + $where[] = 'a.usertype = LOWER( '.$db->Quote($filter_type).' ) '; + } + } + if ( $filter_logged == 1 ) + { + $where[] = 's.userid = a.id'; + } + else if ($filter_logged == 2) + { + $where[] = 's.userid IS NULL'; + } + + // exclude any child group id's for this user + $pgids = $acl->get_group_children( $currentUser->get('gid'), 'ARO', 'RECURSE' ); + + if (is_array( $pgids ) && count( $pgids ) > 0) + { + JArrayHelper::toInteger($pgids); + $where[] = 'a.gid NOT IN (' . implode( ',', $pgids ) . ')'; + } + $filter = ''; + if ($filter_logged == 1 || $filter_logged == 2) + { + $filter = ' INNER JOIN #__session AS s ON s.userid = a.id'; + } + + $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir; + $where = ( count( $where ) ? ' WHERE (' . implode( ') AND (', $where ) . ')' : '' ); + + $query = 'SELECT COUNT(a.id)' + . ' FROM #__users AS a' + . $filter + . $where + ; + $db->setQuery( $query ); + $total = $db->loadResult(); + + jimport('joomla.html.pagination'); + $pagination = new JPagination( $total, $limitstart, $limit ); + + $query = 'SELECT a.*, g.name AS groupname' + . ' FROM #__users AS a' + . ' INNER JOIN #__core_acl_aro AS aro ON aro.value = a.id' + . ' INNER JOIN #__core_acl_groups_aro_map AS gm ON gm.aro_id = aro.id' + . ' INNER JOIN #__core_acl_aro_groups AS g ON g.id = gm.group_id' + . $filter + . $where + . ' GROUP BY a.id' + . $orderby + ; + $db->setQuery( $query, $pagination->limitstart, $pagination->limit ); + $rows = $db->loadObjectList(); + + $n = count( $rows ); + $template = 'SELECT COUNT(s.userid)' + . ' FROM #__session AS s' + . ' WHERE s.userid = %d' + ; + for ($i = 0; $i < $n; $i++) + { + $row = &$rows[$i]; + $query = sprintf( $template, intval( $row->id ) ); + $db->setQuery( $query ); + $row->loggedin = $db->loadResult(); + } + + // get list of Groups for dropdown filter + $query = 'SELECT name AS value, name AS text' + . ' FROM #__core_acl_aro_groups' + . ' WHERE name != "ROOT"' + . ' AND name != "USERS"' + ; + $db->setQuery( $query ); + $types[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select Group' ) .' -' ); + foreach( $db->loadObjectList() as $obj ) + { + $types[] = JHTML::_('select.option', $obj->value, JText::_( $obj->text ) ); + } + $lists['type'] = JHTML::_('select.genericlist', $types, 'filter_type', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', "$filter_type" ); + + // get list of Log Status for dropdown filter + $logged[] = JHTML::_('select.option', 0, '- '. JText::_( 'Select Log Status' ) .' -'); + $logged[] = JHTML::_('select.option', 1, JText::_( 'Logged In' ) ); + $lists['logged'] = JHTML::_('select.genericlist', $logged, 'filter_logged', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', "$filter_logged" ); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search']= $search; + + $this->assignRef('user', JFactory::getUser()); + $this->assignRef('lists', $lists); + $this->assignRef('items', $rows); + $this->assignRef('pagination', $pagination); + + parent::display($tpl); + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_weblinks/controller.php b/oss/joomla/trunk/administrator/components/com_weblinks/controller.php index 5b22426c..9d2a524a 100644 --- a/oss/joomla/trunk/administrator/components/com_weblinks/controller.php +++ b/oss/joomla/trunk/administrator/components/com_weblinks/controller.php @@ -1,205 +1,205 @@ -registerTask( 'add', 'display' ); - $this->registerTask( 'edit', 'display' ); - } - - function display( ) - { - switch($this->getTask()) - { - case 'add' : - { - JRequest::setVar( 'hidemainmenu', 1 ); - JRequest::setVar( 'layout', 'form' ); - JRequest::setVar( 'view' , 'weblink'); - JRequest::setVar( 'edit', false ); - - // Checkout the weblink - $model = $this->getModel('weblink'); - $model->checkout(); - } break; - case 'edit' : - { - JRequest::setVar( 'hidemainmenu', 1 ); - JRequest::setVar( 'layout', 'form' ); - JRequest::setVar( 'view' , 'weblink'); - JRequest::setVar( 'edit', true ); - - // Checkout the weblink - $model = $this->getModel('weblink'); - $model->checkout(); - } break; - } - - parent::display(); - } - - function save() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $post = JRequest::get('post'); - $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); - $post['id'] = (int) $cid[0]; - - $model = $this->getModel('weblink'); - - if ($model->store($post)) { - $msg = JText::_( 'Weblink Saved' ); - } else { - $msg = JText::_( 'Error Saving Weblink' ); - } - - // Check the table in so it can be edited.... we are done with it anyway - $model->checkin(); - $link = 'index.php?option=com_weblinks'; - $this->setRedirect($link, $msg); - } - - function remove() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - JArrayHelper::toInteger($cid); - - if (count( $cid ) < 1) { - JError::raiseError(500, JText::_( 'Select an item to delete' ) ); - } - - $model = $this->getModel('weblink'); - if(!$model->delete($cid)) { - echo "\n"; - } - - $this->setRedirect( 'index.php?option=com_weblinks' ); - } - - - function publish() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - JArrayHelper::toInteger($cid); - - if (count( $cid ) < 1) { - JError::raiseError(500, JText::_( 'Select an item to publish' ) ); - } - - $model = $this->getModel('weblink'); - if(!$model->publish($cid, 1)) { - echo "\n"; - } - - $this->setRedirect( 'index.php?option=com_weblinks' ); - } - - - function unpublish() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - JArrayHelper::toInteger($cid); - - if (count( $cid ) < 1) { - JError::raiseError(500, JText::_( 'Select an item to unpublish' ) ); - } - - $model = $this->getModel('weblink'); - if(!$model->publish($cid, 0)) { - echo "\n"; - } - - $this->setRedirect( 'index.php?option=com_weblinks' ); - } - - function cancel() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - // Checkin the weblink - $model = $this->getModel('weblink'); - $model->checkin(); - - $this->setRedirect( 'index.php?option=com_weblinks' ); - } - - - function orderup() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $model = $this->getModel('weblink'); - $model->move(-1); - - $this->setRedirect( 'index.php?option=com_weblinks'); - } - - function orderdown() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $model = $this->getModel('weblink'); - $model->move(1); - - $this->setRedirect( 'index.php?option=com_weblinks'); - } - - function saveorder() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); - $order = JRequest::getVar( 'order', array(), 'post', 'array' ); - JArrayHelper::toInteger($cid); - JArrayHelper::toInteger($order); - - $model = $this->getModel('weblink'); - $model->saveorder($cid, $order); - - $msg = JText::_( 'New ordering saved' ); - $this->setRedirect( 'index.php?option=com_weblinks', $msg ); - } +registerTask( 'add', 'display' ); + $this->registerTask( 'edit', 'display' ); + } + + function display( ) + { + switch($this->getTask()) + { + case 'add' : + { + JRequest::setVar( 'hidemainmenu', 1 ); + JRequest::setVar( 'layout', 'form' ); + JRequest::setVar( 'view' , 'weblink'); + JRequest::setVar( 'edit', false ); + + // Checkout the weblink + $model = $this->getModel('weblink'); + $model->checkout(); + } break; + case 'edit' : + { + JRequest::setVar( 'hidemainmenu', 1 ); + JRequest::setVar( 'layout', 'form' ); + JRequest::setVar( 'view' , 'weblink'); + JRequest::setVar( 'edit', true ); + + // Checkout the weblink + $model = $this->getModel('weblink'); + $model->checkout(); + } break; + } + + parent::display(); + } + + function save() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $post = JRequest::get('post'); + $cid = JRequest::getVar( 'cid', array(0), 'post', 'array' ); + $post['id'] = (int) $cid[0]; + + $model = $this->getModel('weblink'); + + if ($model->store($post)) { + $msg = JText::_( 'Weblink Saved' ); + } else { + $msg = JText::_( 'Error Saving Weblink' ); + } + + // Check the table in so it can be edited.... we are done with it anyway + $model->checkin(); + $link = 'index.php?option=com_weblinks'; + $this->setRedirect($link, $msg); + } + + function remove() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + if (count( $cid ) < 1) { + JError::raiseError(500, JText::_( 'Select an item to delete' ) ); + } + + $model = $this->getModel('weblink'); + if(!$model->delete($cid)) { + echo "\n"; + } + + $this->setRedirect( 'index.php?option=com_weblinks' ); + } + + + function publish() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + if (count( $cid ) < 1) { + JError::raiseError(500, JText::_( 'Select an item to publish' ) ); + } + + $model = $this->getModel('weblink'); + if(!$model->publish($cid, 1)) { + echo "\n"; + } + + $this->setRedirect( 'index.php?option=com_weblinks' ); + } + + + function unpublish() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + + if (count( $cid ) < 1) { + JError::raiseError(500, JText::_( 'Select an item to unpublish' ) ); + } + + $model = $this->getModel('weblink'); + if(!$model->publish($cid, 0)) { + echo "\n"; + } + + $this->setRedirect( 'index.php?option=com_weblinks' ); + } + + function cancel() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + // Checkin the weblink + $model = $this->getModel('weblink'); + $model->checkin(); + + $this->setRedirect( 'index.php?option=com_weblinks' ); + } + + + function orderup() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $model = $this->getModel('weblink'); + $model->move(-1); + + $this->setRedirect( 'index.php?option=com_weblinks'); + } + + function orderdown() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $model = $this->getModel('weblink'); + $model->move(1); + + $this->setRedirect( 'index.php?option=com_weblinks'); + } + + function saveorder() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $cid = JRequest::getVar( 'cid', array(), 'post', 'array' ); + $order = JRequest::getVar( 'order', array(), 'post', 'array' ); + JArrayHelper::toInteger($cid); + JArrayHelper::toInteger($order); + + $model = $this->getModel('weblink'); + $model->saveorder($cid, $order); + + $msg = JText::_( 'New ordering saved' ); + $this->setRedirect( 'index.php?option=com_weblinks', $msg ); + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_weblinks/models/weblink.php b/oss/joomla/trunk/administrator/components/com_weblinks/models/weblink.php index f155f709..32d3b520 100644 --- a/oss/joomla/trunk/administrator/components/com_weblinks/models/weblink.php +++ b/oss/joomla/trunk/administrator/components/com_weblinks/models/weblink.php @@ -1,389 +1,389 @@ -setId((int)$array[0]); - } - - /** - * Method to set the weblink identifier - * - * @access public - * @param int Weblink identifier - */ - function setId($id) - { - // Set weblink id and wipe data - $this->_id = $id; - $this->_data = null; - } - - /** - * Method to get a weblink - * - * @since 1.5 - */ - function &getData() - { - // Load the weblink data - if ($this->_loadData()) - { - // Initialize some variables - $user = &JFactory::getUser(); - - // Check to see if the category is published - if (!$this->_data->cat_pub) { - JError::raiseError( 404, JText::_("Resource Not Found") ); - return; - } - - // Check whether category access level allows access - if ($this->_data->cat_access > $user->get('aid', 0)) { - JError::raiseError( 403, JText::_('ALERTNOTAUTH') ); - return; - } - } - else $this->_initData(); - - return $this->_data; - } - - /** - * Tests if weblink is checked out - * - * @access public - * @param int A user id - * @return boolean True if checked out - * @since 1.5 - */ - function isCheckedOut( $uid=0 ) - { - if ($this->_loadData()) - { - if ($uid) { - return ($this->_data->checked_out && $this->_data->checked_out != $uid); - } else { - return $this->_data->checked_out; - } - } - } - - /** - * Method to checkin/unlock the weblink - * - * @access public - * @return boolean True on success - * @since 1.5 - */ - function checkin() - { - if ($this->_id) - { - $weblink = & $this->getTable(); - if(! $weblink->checkin($this->_id)) { - $this->setError($this->_db->getErrorMsg()); - return false; - } - } - return false; - } - - /** - * Method to checkout/lock the weblink - * - * @access public - * @param int $uid User ID of the user checking the article out - * @return boolean True on success - * @since 1.5 - */ - function checkout($uid = null) - { - if ($this->_id) - { - // Make sure we have a user id to checkout the article with - if (is_null($uid)) { - $user =& JFactory::getUser(); - $uid = $user->get('id'); - } - // Lets get to it and checkout the thing... - $weblink = & $this->getTable(); - if(!$weblink->checkout($uid, $this->_id)) { - $this->setError($this->_db->getErrorMsg()); - return false; - } - - return true; - } - return false; - } - - /** - * Method to store the weblink - * - * @access public - * @return boolean True on success - * @since 1.5 - */ - function store($data) - { - $row =& $this->getTable(); - - // Bind the form fields to the web link table - if (!$row->bind($data)) { - $this->setError($this->_db->getErrorMsg()); - return false; - } - - // Create the timestamp for the date - $row->date = gmdate('Y-m-d H:i:s'); - - // if new item, order last in appropriate group - if (!$row->id) { - $where = 'catid = ' . (int) $row->catid ; - $row->ordering = $row->getNextOrder( $where ); - } - - // Make sure the web link table is valid - if (!$row->check()) { - $this->setError($this->_db->getErrorMsg()); - return false; - } - - // Store the web link table to the database - if (!$row->store()) { - $this->setError($this->_db->getErrorMsg()); - return false; - } - - return true; - } - - /** - * Method to remove a weblink - * - * @access public - * @return boolean True on success - * @since 1.5 - */ - function delete($cid = array()) - { - $result = false; - - if (count( $cid )) - { - JArrayHelper::toInteger($cid); - $cids = implode( ',', $cid ); - $query = 'DELETE FROM #__weblinks' - . ' WHERE id IN ( '.$cids.' )'; - $this->_db->setQuery( $query ); - if(!$this->_db->query()) { - $this->setError($this->_db->getErrorMsg()); - return false; - } - } - - return true; - } - - /** - * Method to (un)publish a weblink - * - * @access public - * @return boolean True on success - * @since 1.5 - */ - function publish($cid = array(), $publish = 1) - { - $user =& JFactory::getUser(); - - if (count( $cid )) - { - JArrayHelper::toInteger($cid); - $cids = implode( ',', $cid ); - - $query = 'UPDATE #__weblinks' - . ' SET published = '.(int) $publish - . ' WHERE id IN ( '.$cids.' )' - . ' AND ( checked_out = 0 OR ( checked_out = '.(int) $user->get('id').' ) )' - ; - $this->_db->setQuery( $query ); - if (!$this->_db->query()) { - $this->setError($this->_db->getErrorMsg()); - return false; - } - } - - return true; - } - - /** - * Method to move a weblink - * - * @access public - * @return boolean True on success - * @since 1.5 - */ - function move($direction) - { - $row =& $this->getTable(); - if (!$row->load($this->_id)) { - $this->setError($this->_db->getErrorMsg()); - return false; - } - - if (!$row->move( $direction, ' catid = '.(int) $row->catid.' AND published >= 0 ' )) { - $this->setError($this->_db->getErrorMsg()); - return false; - } - - return true; - } - - /** - * Method to move a weblink - * - * @access public - * @return boolean True on success - * @since 1.5 - */ - function saveorder($cid = array(), $order) - { - $row =& $this->getTable(); - $groupings = array(); - - // update ordering values - for( $i=0; $i < count($cid); $i++ ) - { - $row->load( (int) $cid[$i] ); - // track categories - $groupings[] = $row->catid; - - if ($row->ordering != $order[$i]) - { - $row->ordering = $order[$i]; - if (!$row->store()) { - $this->setError($this->_db->getErrorMsg()); - return false; - } - } - } - - // execute updateOrder for each parent group - $groupings = array_unique( $groupings ); - foreach ($groupings as $group){ - $row->reorder('catid = '.(int) $group); - } - - return true; - } - - /** - * Method to load content weblink data - * - * @access private - * @return boolean True on success - * @since 1.5 - */ - function _loadData() - { - // Lets load the content if it doesn't already exist - if (empty($this->_data)) - { - $query = 'SELECT w.*, cc.title AS category,'. - ' cc.published AS cat_pub, cc.access AS cat_access'. - ' FROM #__weblinks AS w' . - ' LEFT JOIN #__categories AS cc ON cc.id = w.catid' . - ' WHERE w.id = '.(int) $this->_id; - $this->_db->setQuery($query); - $this->_data = $this->_db->loadObject(); - return (boolean) $this->_data; - } - return true; - } - - /** - * Method to initialise the weblink data - * - * @access private - * @return boolean True on success - * @since 1.5 - */ - function _initData() - { - // Lets load the content if it doesn't already exist - if (empty($this->_data)) - { - $weblink = new stdClass(); - $weblink->id = 0; - $weblink->catid = 0; - $weblink->sid = 0; - $weblink->title = null; - $weblink->alias = null; - $weblink->url = null; - $weblink->description = null; - $weblink->date = null; - $weblink->hits = 0; - $weblink->published = 0; - $weblink->checked_out = 0; - $weblink->checked_out_time = 0; - $weblink->ordering = 0; - $weblink->archived = 0; - $weblink->approved = 0; - $weblink->params = null; - $weblink->category = null; - $this->_data = $weblink; - return (boolean) $this->_data; - } - return true; - } +setId((int)$array[0]); + } + + /** + * Method to set the weblink identifier + * + * @access public + * @param int Weblink identifier + */ + function setId($id) + { + // Set weblink id and wipe data + $this->_id = $id; + $this->_data = null; + } + + /** + * Method to get a weblink + * + * @since 1.5 + */ + function &getData() + { + // Load the weblink data + if ($this->_loadData()) + { + // Initialize some variables + $user = &JFactory::getUser(); + + // Check to see if the category is published + if (!$this->_data->cat_pub) { + JError::raiseError( 404, JText::_("Resource Not Found") ); + return; + } + + // Check whether category access level allows access + if ($this->_data->cat_access > $user->get('aid', 0)) { + JError::raiseError( 403, JText::_('ALERTNOTAUTH') ); + return; + } + } + else $this->_initData(); + + return $this->_data; + } + + /** + * Tests if weblink is checked out + * + * @access public + * @param int A user id + * @return boolean True if checked out + * @since 1.5 + */ + function isCheckedOut( $uid=0 ) + { + if ($this->_loadData()) + { + if ($uid) { + return ($this->_data->checked_out && $this->_data->checked_out != $uid); + } else { + return $this->_data->checked_out; + } + } + } + + /** + * Method to checkin/unlock the weblink + * + * @access public + * @return boolean True on success + * @since 1.5 + */ + function checkin() + { + if ($this->_id) + { + $weblink = & $this->getTable(); + if(! $weblink->checkin($this->_id)) { + $this->setError($this->_db->getErrorMsg()); + return false; + } + } + return false; + } + + /** + * Method to checkout/lock the weblink + * + * @access public + * @param int $uid User ID of the user checking the article out + * @return boolean True on success + * @since 1.5 + */ + function checkout($uid = null) + { + if ($this->_id) + { + // Make sure we have a user id to checkout the article with + if (is_null($uid)) { + $user =& JFactory::getUser(); + $uid = $user->get('id'); + } + // Lets get to it and checkout the thing... + $weblink = & $this->getTable(); + if(!$weblink->checkout($uid, $this->_id)) { + $this->setError($this->_db->getErrorMsg()); + return false; + } + + return true; + } + return false; + } + + /** + * Method to store the weblink + * + * @access public + * @return boolean True on success + * @since 1.5 + */ + function store($data) + { + $row =& $this->getTable(); + + // Bind the form fields to the web link table + if (!$row->bind($data)) { + $this->setError($this->_db->getErrorMsg()); + return false; + } + + // Create the timestamp for the date + $row->date = gmdate('Y-m-d H:i:s'); + + // if new item, order last in appropriate group + if (!$row->id) { + $where = 'catid = ' . (int) $row->catid ; + $row->ordering = $row->getNextOrder( $where ); + } + + // Make sure the web link table is valid + if (!$row->check()) { + $this->setError($this->_db->getErrorMsg()); + return false; + } + + // Store the web link table to the database + if (!$row->store()) { + $this->setError($this->_db->getErrorMsg()); + return false; + } + + return true; + } + + /** + * Method to remove a weblink + * + * @access public + * @return boolean True on success + * @since 1.5 + */ + function delete($cid = array()) + { + $result = false; + + if (count( $cid )) + { + JArrayHelper::toInteger($cid); + $cids = implode( ',', $cid ); + $query = 'DELETE FROM #__weblinks' + . ' WHERE id IN ( '.$cids.' )'; + $this->_db->setQuery( $query ); + if(!$this->_db->query()) { + $this->setError($this->_db->getErrorMsg()); + return false; + } + } + + return true; + } + + /** + * Method to (un)publish a weblink + * + * @access public + * @return boolean True on success + * @since 1.5 + */ + function publish($cid = array(), $publish = 1) + { + $user =& JFactory::getUser(); + + if (count( $cid )) + { + JArrayHelper::toInteger($cid); + $cids = implode( ',', $cid ); + + $query = 'UPDATE #__weblinks' + . ' SET published = '.(int) $publish + . ' WHERE id IN ( '.$cids.' )' + . ' AND ( checked_out = 0 OR ( checked_out = '.(int) $user->get('id').' ) )' + ; + $this->_db->setQuery( $query ); + if (!$this->_db->query()) { + $this->setError($this->_db->getErrorMsg()); + return false; + } + } + + return true; + } + + /** + * Method to move a weblink + * + * @access public + * @return boolean True on success + * @since 1.5 + */ + function move($direction) + { + $row =& $this->getTable(); + if (!$row->load($this->_id)) { + $this->setError($this->_db->getErrorMsg()); + return false; + } + + if (!$row->move( $direction, ' catid = '.(int) $row->catid.' AND published >= 0 ' )) { + $this->setError($this->_db->getErrorMsg()); + return false; + } + + return true; + } + + /** + * Method to move a weblink + * + * @access public + * @return boolean True on success + * @since 1.5 + */ + function saveorder($cid = array(), $order) + { + $row =& $this->getTable(); + $groupings = array(); + + // update ordering values + for( $i=0; $i < count($cid); $i++ ) + { + $row->load( (int) $cid[$i] ); + // track categories + $groupings[] = $row->catid; + + if ($row->ordering != $order[$i]) + { + $row->ordering = $order[$i]; + if (!$row->store()) { + $this->setError($this->_db->getErrorMsg()); + return false; + } + } + } + + // execute updateOrder for each parent group + $groupings = array_unique( $groupings ); + foreach ($groupings as $group){ + $row->reorder('catid = '.(int) $group); + } + + return true; + } + + /** + * Method to load content weblink data + * + * @access private + * @return boolean True on success + * @since 1.5 + */ + function _loadData() + { + // Lets load the content if it doesn't already exist + if (empty($this->_data)) + { + $query = 'SELECT w.*, cc.title AS category,'. + ' cc.published AS cat_pub, cc.access AS cat_access'. + ' FROM #__weblinks AS w' . + ' LEFT JOIN #__categories AS cc ON cc.id = w.catid' . + ' WHERE w.id = '.(int) $this->_id; + $this->_db->setQuery($query); + $this->_data = $this->_db->loadObject(); + return (boolean) $this->_data; + } + return true; + } + + /** + * Method to initialise the weblink data + * + * @access private + * @return boolean True on success + * @since 1.5 + */ + function _initData() + { + // Lets load the content if it doesn't already exist + if (empty($this->_data)) + { + $weblink = new stdClass(); + $weblink->id = 0; + $weblink->catid = 0; + $weblink->sid = 0; + $weblink->title = null; + $weblink->alias = null; + $weblink->url = null; + $weblink->description = null; + $weblink->date = null; + $weblink->hits = 0; + $weblink->published = 0; + $weblink->checked_out = 0; + $weblink->checked_out_time = 0; + $weblink->ordering = 0; + $weblink->archived = 0; + $weblink->approved = 0; + $weblink->params = null; + $weblink->category = null; + $this->_data = $weblink; + return (boolean) $this->_data; + } + return true; + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_weblinks/models/weblinks.php b/oss/joomla/trunk/administrator/components/com_weblinks/models/weblinks.php index 8cd5ec0b..0e2cb1f7 100644 --- a/oss/joomla/trunk/administrator/components/com_weblinks/models/weblinks.php +++ b/oss/joomla/trunk/administrator/components/com_weblinks/models/weblinks.php @@ -1,190 +1,193 @@ -getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); - $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); - - // In case limit has been changed, adjust limitstart accordingly - $limitstart = ($limit != 0 ? (floor($limitstart / $limit) * $limit) : 0); - - $this->setState('limit', $limit); - $this->setState('limitstart', $limitstart); - } - - /** - * Method to get weblinks item data - * - * @access public - * @return array - */ - function getData() - { - // Lets load the content if it doesn't already exist - if (empty($this->_data)) - { - $query = $this->_buildQuery(); - $this->_data = $this->_getList($query, $this->getState('limitstart'), $this->getState('limit')); - } - - return $this->_data; - } - - /** - * Method to get the total number of weblink items - * - * @access public - * @return integer - */ - function getTotal() - { - // Lets load the content if it doesn't already exist - if (empty($this->_total)) - { - $query = $this->_buildQuery(); - $this->_total = $this->_getListCount($query); - } - - return $this->_total; - } - - /** - * Method to get a pagination object for the weblinks - * - * @access public - * @return integer - */ - function getPagination() - { - // Lets load the content if it doesn't already exist - if (empty($this->_pagination)) - { - jimport('joomla.html.pagination'); - $this->_pagination = new JPagination( $this->getTotal(), $this->getState('limitstart'), $this->getState('limit') ); - } - - return $this->_pagination; - } - - function _buildQuery() - { - // Get the WHERE and ORDER BY clauses for the query - $where = $this->_buildContentWhere(); - $orderby = $this->_buildContentOrderBy(); - - $query = ' SELECT a.*, cc.title AS category, u.name AS editor ' - . ' FROM #__weblinks AS a ' - . ' LEFT JOIN #__categories AS cc ON cc.id = a.catid ' - . ' LEFT JOIN #__users AS u ON u.id = a.checked_out ' - . $where - . $orderby - ; - - return $query; - } - - function _buildContentOrderBy() - { - global $mainframe, $option; - - $filter_order = $mainframe->getUserStateFromRequest( $option.'filter_order', 'filter_order', 'a.ordering', 'cmd' ); - $filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'filter_order_Dir', 'filter_order_Dir', '', 'word' ); - - if ($filter_order == 'a.ordering'){ - $orderby = ' ORDER BY category, a.ordering '.$filter_order_Dir; - } else { - $orderby = ' ORDER BY '.$filter_order.' '.$filter_order_Dir.' , category, a.ordering '; - } - - return $orderby; - } - - function _buildContentWhere() - { - global $mainframe, $option; - $db =& JFactory::getDBO(); - $filter_state = $mainframe->getUserStateFromRequest( $option.'filter_state', 'filter_state', '', 'word' ); - $filter_catid = $mainframe->getUserStateFromRequest( $option.'filter_catid', 'filter_catid', 0, 'int' ); - $filter_order = $mainframe->getUserStateFromRequest( $option.'filter_order', 'filter_order', 'a.ordering', 'cmd' ); - $filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'filter_order_Dir', 'filter_order_Dir', '', 'word' ); - $search = $mainframe->getUserStateFromRequest( $option.'search', 'search', '', 'string' ); - $search = JString::strtolower( $search ); - - $where = array(); - - if ($filter_catid > 0) { - $where[] = 'a.catid = '.(int) $filter_catid; - } - if ($search) { - $where[] = 'LOWER(a.title) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); - } - if ( $filter_state ) { - if ( $filter_state == 'P' ) { - $where[] = 'a.published = 1'; - } else if ($filter_state == 'U' ) { - $where[] = 'a.published = 0'; - } - } - - $where = ( count( $where ) ? ' WHERE '. implode( ' AND ', $where ) : '' ); - - return $where; - } -} +getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' ); + + // In case limit has been changed, adjust limitstart accordingly + $limitstart = ($limit != 0 ? (floor($limitstart / $limit) * $limit) : 0); + + $this->setState('limit', $limit); + $this->setState('limitstart', $limitstart); + } + + /** + * Method to get weblinks item data + * + * @access public + * @return array + */ + function getData() + { + // Lets load the content if it doesn't already exist + if (empty($this->_data)) + { + $query = $this->_buildQuery(); + $this->_data = $this->_getList($query, $this->getState('limitstart'), $this->getState('limit')); + } + + return $this->_data; + } + + /** + * Method to get the total number of weblink items + * + * @access public + * @return integer + */ + function getTotal() + { + // Lets load the content if it doesn't already exist + if (empty($this->_total)) + { + $query = $this->_buildQuery(); + $this->_total = $this->_getListCount($query); + } + + return $this->_total; + } + + /** + * Method to get a pagination object for the weblinks + * + * @access public + * @return integer + */ + function getPagination() + { + // Lets load the content if it doesn't already exist + if (empty($this->_pagination)) + { + jimport('joomla.html.pagination'); + $this->_pagination = new JPagination( $this->getTotal(), $this->getState('limitstart'), $this->getState('limit') ); + } + + return $this->_pagination; + } + + function _buildQuery() + { + // Get the WHERE and ORDER BY clauses for the query + $where = $this->_buildContentWhere(); + $orderby = $this->_buildContentOrderBy(); + + $query = ' SELECT a.*, cc.title AS category, u.name AS editor ' + . ' FROM #__weblinks AS a ' + . ' LEFT JOIN #__categories AS cc ON cc.id = a.catid ' + . ' LEFT JOIN #__users AS u ON u.id = a.checked_out ' + . $where + . $orderby + ; + + return $query; + } + + function _buildContentOrderBy() + { + global $mainframe, $option; + + $filter_order = $mainframe->getUserStateFromRequest( $option.'filter_order', 'filter_order', 'a.ordering', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'filter_order_Dir', 'filter_order_Dir', '', 'word' ); + + if ($filter_order == 'a.ordering'){ + $orderby = ' ORDER BY category, a.ordering '.$filter_order_Dir; + } else { + $orderby = ' ORDER BY '.$filter_order.' '.$filter_order_Dir.' , category, a.ordering '; + } + + return $orderby; + } + + function _buildContentWhere() + { + global $mainframe, $option; + $db =& JFactory::getDBO(); + $filter_state = $mainframe->getUserStateFromRequest( $option.'filter_state', 'filter_state', '', 'word' ); + $filter_catid = $mainframe->getUserStateFromRequest( $option.'filter_catid', 'filter_catid', 0, 'int' ); + $filter_order = $mainframe->getUserStateFromRequest( $option.'filter_order', 'filter_order', 'a.ordering', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'filter_order_Dir', 'filter_order_Dir', '', 'word' ); + $search = $mainframe->getUserStateFromRequest( $option.'search', 'search', '', 'string' ); + if (strpos($search, '"') !== false) { + $search = str_replace(array('=', '<'), '', $search); + } + $search = JString::strtolower($search); + + $where = array(); + + if ($filter_catid > 0) { + $where[] = 'a.catid = '.(int) $filter_catid; + } + if ($search) { + $where[] = 'LOWER(a.title) LIKE '.$db->Quote( '%'.$db->getEscaped( $search, true ).'%', false ); + } + if ( $filter_state ) { + if ( $filter_state == 'P' ) { + $where[] = 'a.published = 1'; + } else if ($filter_state == 'U' ) { + $where[] = 'a.published = 0'; + } + } + + $where = ( count( $where ) ? ' WHERE '. implode( ' AND ', $where ) : '' ); + + return $where; + } +} diff --git a/oss/joomla/trunk/administrator/components/com_weblinks/tables/weblink.php b/oss/joomla/trunk/administrator/components/com_weblinks/tables/weblink.php index b09b1836..602e8094 100644 --- a/oss/joomla/trunk/administrator/components/com_weblinks/tables/weblink.php +++ b/oss/joomla/trunk/administrator/components/com_weblinks/tables/weblink.php @@ -1,190 +1,190 @@ -loadArray($array['params']); - $array['params'] = $registry->toString(); - } - - return parent::bind($array, $ignore); - } - - /** - * Overloaded check method to ensure data integrity - * - * @access public - * @return boolean True on success - * @since 1.0 - */ - function check() - { - if (JFilterInput::checkAttribute(array ('href', $this->url))) { - $this->setError( JText::_('Please provide a valid URL')); - return false; - } - - //Remove all HTML tags from the title and description - $filter = new JFilterInput(array(), array(), 0, 0); - $this->description = $filter->clean($this->description); - $this->title = $filter->clean($this->title); - - /** check for valid name */ - if (trim($this->title) == '') { - $this->setError(JText::_('Your Weblink must contain a title.')); - return false; - } - - if (!(eregi('http://', $this->url) || (eregi('https://', $this->url)) || (eregi('ftp://', $this->url)))) { - $this->url = 'http://'.$this->url; - } - - /** check for existing name */ - $query = 'SELECT id FROM #__weblinks WHERE title = '.$this->_db->Quote($this->title).' AND catid = '.(int) $this->catid; - $this->_db->setQuery($query); - - $xid = intval($this->_db->loadResult()); - if ($xid && $xid != intval($this->id)) { - $this->setError(JText::sprintf('WARNNAMETRYAGAIN', JText::_('Web Link'))); - return false; - } - - if(empty($this->alias)) { - $this->alias = $this->title; - } - $this->alias = JFilterOutput::stringURLSafe($this->alias); - if(trim(str_replace('-','',$this->alias)) == '') { - $datenow =& JFactory::getDate(); - $this->alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S"); - } - - return true; - } -} +loadArray($array['params']); + $array['params'] = $registry->toString(); + } + + return parent::bind($array, $ignore); + } + + /** + * Overloaded check method to ensure data integrity + * + * @access public + * @return boolean True on success + * @since 1.0 + */ + function check() + { + if (JFilterInput::checkAttribute(array ('href', $this->url))) { + $this->setError( JText::_('Please provide a valid URL')); + return false; + } + + //Remove all HTML tags from the title and description + $filter = new JFilterInput(array(), array(), 0, 0); + $this->description = $filter->clean($this->description); + $this->title = $filter->clean($this->title); + + /** check for valid name */ + if (trim($this->title) == '') { + $this->setError(JText::_('Your Weblink must contain a title.')); + return false; + } + + if (!(preg_match('#http://#i', $this->url) || (preg_match('#https://#i', $this->url)) || (preg_match('#ftp://#i', $this->url)))) { + $this->url = 'http://'.$this->url; + } + + /** check for existing name */ + $query = 'SELECT id FROM #__weblinks WHERE title = '.$this->_db->Quote($this->title).' AND catid = '.(int) $this->catid; + $this->_db->setQuery($query); + + $xid = intval($this->_db->loadResult()); + if ($xid && $xid != intval($this->id)) { + $this->setError(JText::sprintf('WARNNAMETRYAGAIN', JText::_('Web Link'))); + return false; + } + + if(empty($this->alias)) { + $this->alias = $this->title; + } + $this->alias = JFilterOutput::stringURLSafe($this->alias); + if(trim(str_replace('-','',$this->alias)) == '') { + $datenow =& JFactory::getDate(); + $this->alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S"); + } + + return true; + } +} diff --git a/oss/joomla/trunk/administrator/components/com_weblinks/views/weblink/view.html.php b/oss/joomla/trunk/administrator/components/com_weblinks/views/weblink/view.html.php index b069a3aa..05efa339 100644 --- a/oss/joomla/trunk/administrator/components/com_weblinks/views/weblink/view.html.php +++ b/oss/joomla/trunk/administrator/components/com_weblinks/views/weblink/view.html.php @@ -1,111 +1,111 @@ -getLayout() == 'form') { - $this->_displayForm($tpl); - return; - } - - //get the weblink - $weblink =& $this->get('data'); - - if ($weblink->url) { - // redirects to url if matching id found - $mainframe->redirect($weblink->url); - } - - parent::display($tpl); - } - - function _displayForm($tpl) - { - global $mainframe, $option; - - $db =& JFactory::getDBO(); - $uri =& JFactory::getURI(); - $user =& JFactory::getUser(); - $model =& $this->getModel(); - - - $lists = array(); - - //get the weblink - $weblink =& $this->get('data'); - $isNew = ($weblink->id < 1); - - // fail if checked out not by 'me' - if ($model->isCheckedOut( $user->get('id') )) { - $msg = JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The weblink' ), $weblink->title ); - $mainframe->redirect( 'index.php?option='. $option, $msg ); - } - - // Edit or Create? - if (!$isNew) - { - $model->checkout( $user->get('id') ); - } - else - { - // initialise new record - $weblink->published = 1; - $weblink->approved = 1; - $weblink->order = 0; - $weblink->catid = JRequest::getVar( 'catid', 0, 'post', 'int' ); - } - - // build the html select list for ordering - $query = 'SELECT ordering AS value, title AS text' - . ' FROM #__weblinks' - . ' WHERE catid = ' . (int) $weblink->catid - . ' ORDER BY ordering'; - - $lists['ordering'] = JHTML::_('list.specificordering', $weblink, $weblink->id, $query ); - - // build list of categories - $lists['catid'] = JHTML::_('list.category', 'catid', $option, intval( $weblink->catid ) ); - // build the html select list - $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $weblink->published ); - - //clean weblink data - JFilterOutput::objectHTMLSafe( $weblink, ENT_QUOTES, 'description' ); - - $file = JPATH_COMPONENT.DS.'models'.DS.'weblink.xml'; - $params = new JParameter( $weblink->params, $file ); - - $this->assignRef('lists', $lists); - $this->assignRef('weblink', $weblink); - $this->assignRef('params', $params); - - parent::display($tpl); - } -} +getLayout() == 'form') { + $this->_displayForm($tpl); + return; + } + + //get the weblink + $weblink =& $this->get('data'); + + if ($weblink->url) { + // redirects to url if matching id found + $mainframe->redirect($weblink->url); + } + + parent::display($tpl); + } + + function _displayForm($tpl) + { + global $mainframe, $option; + + $db =& JFactory::getDBO(); + $uri =& JFactory::getURI(); + $user =& JFactory::getUser(); + $model =& $this->getModel(); + + + $lists = array(); + + //get the weblink + $weblink =& $this->get('data'); + $isNew = ($weblink->id < 1); + + // fail if checked out not by 'me' + if ($model->isCheckedOut( $user->get('id') )) { + $msg = JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The weblink' ), $weblink->title ); + $mainframe->redirect( 'index.php?option='. $option, $msg ); + } + + // Edit or Create? + if (!$isNew) + { + $model->checkout( $user->get('id') ); + } + else + { + // initialise new record + $weblink->published = 1; + $weblink->approved = 1; + $weblink->order = 0; + $weblink->catid = JRequest::getVar( 'catid', 0, 'post', 'int' ); + } + + // build the html select list for ordering + $query = 'SELECT ordering AS value, title AS text' + . ' FROM #__weblinks' + . ' WHERE catid = ' . (int) $weblink->catid + . ' ORDER BY ordering'; + + $lists['ordering'] = JHTML::_('list.specificordering', $weblink, $weblink->id, $query ); + + // build list of categories + $lists['catid'] = JHTML::_('list.category', 'catid', $option, intval( $weblink->catid ) ); + // build the html select list + $lists['published'] = JHTML::_('select.booleanlist', 'published', 'class="inputbox"', $weblink->published ); + + //clean weblink data + JFilterOutput::objectHTMLSafe( $weblink, ENT_QUOTES, 'description' ); + + $file = JPATH_COMPONENT.DS.'models'.DS.'weblink.xml'; + $params = new JParameter( $weblink->params, $file ); + + $this->assignRef('lists', $lists); + $this->assignRef('weblink', $weblink); + $this->assignRef('params', $params); + + parent::display($tpl); + } +} diff --git a/oss/joomla/trunk/administrator/components/com_weblinks/views/weblinks/tmpl/default.php b/oss/joomla/trunk/administrator/components/com_weblinks/views/weblinks/tmpl/default.php index 767a5f95..75332c1e 100644 --- a/oss/joomla/trunk/administrator/components/com_weblinks/views/weblinks/tmpl/default.php +++ b/oss/joomla/trunk/administrator/components/com_weblinks/views/weblinks/tmpl/default.php @@ -1,141 +1,141 @@ - - - - -lists['order'] == 'a.ordering'); -?> -
    - - - - - -
    - : - - - - - lists['catid']; - echo $this->lists['state']; - ?> -
    -
    - - - - - - - - - - - - - - - - - - - - items ); $i < $n; $i++) - { - $row = &$this->items[$i]; - - $link = JRoute::_( 'index.php?option=com_weblinks&view=weblink&task=edit&cid[]='. $row->id ); - - $checked = JHTML::_('grid.checkedout', $row, $i ); - $published = JHTML::_('grid.published', $row, $i ); - - $row->cat_link = JRoute::_( 'index.php?option=com_categories§ion=com_weblinks&task=edit&type=other&cid[]='. $row->catid ); - ?> - "> - - - - - - - - - - - -
    - - - - - lists['order_Dir'], $this->lists['order'] ); ?> - - lists['order_Dir'], $this->lists['order'] ); ?> - - lists['order_Dir'], $this->lists['order'] ); ?> - items ); ?> - - lists['order_Dir'], $this->lists['order'] ); ?> - - lists['order_Dir'], $this->lists['order'] ); ?> - - lists['order_Dir'], $this->lists['order'] ); ?> -
    - pagination->getListFooter(); ?> -
    - pagination->getRowOffset( $i ); ?> - - - - user->get ('id'), $row->checked_out ) ) { - echo $this->escape($row->title); - } else { - ?> - - - escape($row->title); ?> - - - - - pagination->orderUpIcon( $i, ($row->catid == @$this->items[$i-1]->catid),'orderup', 'Move Up', $ordering ); ?> - pagination->orderDownIcon( $i, $n, ($row->catid == @$this->items[$i+1]->catid), 'orderdown', 'Move Down', $ordering ); ?> - - class="text_area" style="text-align: center" /> - - - - escape($row->category); ?> - - hits; ?> - - id; ?> -
    -
    - - - - - - - -
    + + + + +lists['order'] == 'a.ordering'); +?> +
    + + + + + +
    + : + + + + + lists['catid']; + echo $this->lists['state']; + ?> +
    +
    + + + + + + + + + + + + + + + + + + + + items ); $i < $n; $i++) + { + $row = &$this->items[$i]; + + $link = JRoute::_( 'index.php?option=com_weblinks&view=weblink&task=edit&cid[]='. $row->id ); + + $checked = JHTML::_('grid.checkedout', $row, $i ); + $published = JHTML::_('grid.published', $row, $i ); + + $row->cat_link = JRoute::_( 'index.php?option=com_categories§ion=com_weblinks&task=edit&type=other&cid[]='. $row->catid ); + ?> + "> + + + + + + + + + + + +
    + + + + + lists['order_Dir'], $this->lists['order'] ); ?> + + lists['order_Dir'], $this->lists['order'] ); ?> + + lists['order_Dir'], $this->lists['order'] ); ?> + items ); ?> + + lists['order_Dir'], $this->lists['order'] ); ?> + + lists['order_Dir'], $this->lists['order'] ); ?> + + lists['order_Dir'], $this->lists['order'] ); ?> +
    + pagination->getListFooter(); ?> +
    + pagination->getRowOffset( $i ); ?> + + + + user->get ('id'), $row->checked_out ) ) { + echo $this->escape($row->title); + } else { + ?> + + + escape($row->title); ?> + + + + + pagination->orderUpIcon( $i, ($row->catid == @$this->items[$i-1]->catid),'orderup', 'Move Up', $ordering ); ?> + pagination->orderDownIcon( $i, $n, ($row->catid == @$this->items[$i+1]->catid), 'orderdown', 'Move Down', $ordering ); ?> + + class="text_area" style="text-align: center" /> + + + + escape($row->category); ?> + + hits; ?> + + id; ?> +
    +
    + + + + + + + +
    diff --git a/oss/joomla/trunk/administrator/components/com_weblinks/views/weblinks/view.html.php b/oss/joomla/trunk/administrator/components/com_weblinks/views/weblinks/view.html.php index b1fceb85..c3190f58 100644 --- a/oss/joomla/trunk/administrator/components/com_weblinks/views/weblinks/view.html.php +++ b/oss/joomla/trunk/administrator/components/com_weblinks/views/weblinks/view.html.php @@ -1,70 +1,73 @@ -getUserStateFromRequest( $option.'filter_state', 'filter_state', '', 'word' ); - $filter_catid = $mainframe->getUserStateFromRequest( $option.'filter_catid', 'filter_catid', 0, 'int' ); - $filter_order = $mainframe->getUserStateFromRequest( $option.'filter_order', 'filter_order', 'a.ordering', 'cmd' ); - $filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'filter_order_Dir', 'filter_order_Dir', '', 'word' ); - $search = $mainframe->getUserStateFromRequest( $option.'search', 'search', '', 'string' ); - $search = JString::strtolower( $search ); - - // Get data from the model - $items = & $this->get( 'Data'); - $total = & $this->get( 'Total'); - $pagination = & $this->get( 'Pagination' ); - - // build list of categories - $javascript = 'onchange="document.adminForm.submit();"'; - $lists['catid'] = JHTML::_('list.category', 'filter_catid', $option, intval( $filter_catid ), $javascript ); - - // state filter - $lists['state'] = JHTML::_('grid.state', $filter_state ); - - // table ordering - $lists['order_Dir'] = $filter_order_Dir; - $lists['order'] = $filter_order; - - // search filter - $lists['search']= $search; - - $this->assignRef('user', JFactory::getUser()); - $this->assignRef('lists', $lists); - $this->assignRef('items', $items); - $this->assignRef('pagination', $pagination); - - parent::display($tpl); - } +getUserStateFromRequest( $option.'filter_state', 'filter_state', '', 'word' ); + $filter_catid = $mainframe->getUserStateFromRequest( $option.'filter_catid', 'filter_catid', 0, 'int' ); + $filter_order = $mainframe->getUserStateFromRequest( $option.'filter_order', 'filter_order', 'a.ordering', 'cmd' ); + $filter_order_Dir = $mainframe->getUserStateFromRequest( $option.'filter_order_Dir', 'filter_order_Dir', '', 'word' ); + $search = $mainframe->getUserStateFromRequest( $option.'search', 'search', '', 'string' ); + if (strpos($search, '"') !== false) { + $search = str_replace(array('=', '<'), '', $search); + } + $search = JString::strtolower($search); + + // Get data from the model + $items = & $this->get( 'Data'); + $total = & $this->get( 'Total'); + $pagination = & $this->get( 'Pagination' ); + + // build list of categories + $javascript = 'onchange="document.adminForm.submit();"'; + $lists['catid'] = JHTML::_('list.category', 'filter_catid', $option, intval( $filter_catid ), $javascript ); + + // state filter + $lists['state'] = JHTML::_('grid.state', $filter_state ); + + // table ordering + $lists['order_Dir'] = $filter_order_Dir; + $lists['order'] = $filter_order; + + // search filter + $lists['search']= $search; + + $this->assignRef('user', JFactory::getUser()); + $this->assignRef('lists', $lists); + $this->assignRef('items', $items); + $this->assignRef('pagination', $pagination); + + parent::display($tpl); + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_weblinks/weblinks.php b/oss/joomla/trunk/administrator/components/com_weblinks/weblinks.php index a8ee25cf..66ac844e 100644 --- a/oss/joomla/trunk/administrator/components/com_weblinks/weblinks.php +++ b/oss/joomla/trunk/administrator/components/com_weblinks/weblinks.php @@ -1,33 +1,33 @@ -authorize( 'com_weblinks', 'manage' )) { - $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); -} - -// Require the base controller -require_once (JPATH_COMPONENT.DS.'controller.php'); - -$controller = new WeblinksController( ); - -// Perform the Request task -$controller->execute( JRequest::getCmd('task')); +authorize( 'com_weblinks', 'manage' )) { + $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); +} + +// Require the base controller +require_once (JPATH_COMPONENT.DS.'controller.php'); + +$controller = new WeblinksController( ); + +// Perform the Request task +$controller->execute( JRequest::getCmd('task')); $controller->redirect(); \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/components/com_weblinks/weblinks.xml b/oss/joomla/trunk/administrator/components/com_weblinks/weblinks.xml index 049c0365..5c9d1502 100644 --- a/oss/joomla/trunk/administrator/components/com_weblinks/weblinks.xml +++ b/oss/joomla/trunk/administrator/components/com_weblinks/weblinks.xml @@ -1,12 +1,12 @@ - - - Weblinks - Joomla! Project - April 2006 - (C) 2005 - 2008 Open Source Matters. All rights reserved. - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - admin@joomla.org - www.joomla.org - 1.5.0 - This component shows a listing of Weblinks - + + + Weblinks + Joomla! Project + April 2006 + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + This component shows a listing of Weblinks + diff --git a/oss/joomla/trunk/administrator/help/en-GB/joomla.credits.html b/oss/joomla/trunk/administrator/help/en-GB/joomla.credits.html index 7f1ed505..90f52ddd 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/joomla.credits.html +++ b/oss/joomla/trunk/administrator/help/en-GB/joomla.credits.html @@ -1,14 +1,14 @@ - - - -Credits - - - - - -

    Credits

    -

    The local copy of this help file is no longer maintained. Please use the online version.

    - + + + +Credits + + + + + +

    Credits

    +

    The local copy of this help file is no longer maintained. Please use the online version.

    + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/help/en-GB/joomla.glossary.html b/oss/joomla/trunk/administrator/help/en-GB/joomla.glossary.html index cc8a7466..e88c532f 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/joomla.glossary.html +++ b/oss/joomla/trunk/administrator/help/en-GB/joomla.glossary.html @@ -1,14 +1,14 @@ - - - -Glossary - - - - - -

    Glossary

    -

    The local copy of this help file is no longer maintained. Please use the online version.

    - + + + +Glossary + + + + + +

    Glossary

    +

    The local copy of this help file is no longer maintained. Please use the online version.

    + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/help/en-GB/joomla.support.html b/oss/joomla/trunk/administrator/help/en-GB/joomla.support.html index 0cfe4fdd..f9b2fa89 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/joomla.support.html +++ b/oss/joomla/trunk/administrator/help/en-GB/joomla.support.html @@ -1,14 +1,14 @@ - - - -Support - - - - - -

    Support

    -

    The local copy of this help file is no longer maintained. Please use the online version.

    - + + + +Support + + + + + +

    Support

    +

    The local copy of this help file is no longer maintained. Please use the online version.

    + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/help/en-GB/joomla.whatsnew10.html b/oss/joomla/trunk/administrator/help/en-GB/joomla.whatsnew10.html index fd281238..df49b3c2 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/joomla.whatsnew10.html +++ b/oss/joomla/trunk/administrator/help/en-GB/joomla.whatsnew10.html @@ -4,7 +4,7 @@ What's New in Version 1.0 - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/joomla.whatsnew15.html b/oss/joomla/trunk/administrator/help/en-GB/joomla.whatsnew15.html index 7d928250..64ca590f 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/joomla.whatsnew15.html +++ b/oss/joomla/trunk/administrator/help/en-GB/joomla.whatsnew15.html @@ -1,54 +1,54 @@ - - - -What's New in Version 1.5 - - - - - - -

    What's New in Version 1.5

    - -

    The following outlines the highlights of the second major release of Joomla!

    - -

    As with previous releases, Joomla! provides a unified and easy-to-use framework for delivering content for websites of all kinds. To support the changing nature of the Internet and emerging web technologies, Joomla! required substantial restructuring of its core functionality and we also used this effort to simplify many challenges within the current user interface. Joomla! 1.5 has many new features.

    - -

    The goals for the Joomla! 1.5 release are to:

    -
      -
    • Substantially improve usability, manageability, and scalability far beyond the original Mambo foundations.
    • -
    • Expand accessibility to support internationalisation, double-byte characters and Right-to-Left support for Arabic and Hebrew languages.
    • -
    • Extend the integration of external applications through Web Services and remote authentication such as the Lightweight Directory Access Protocol (LDAP).
    • -
    • Enhance the content delivery, template and presentation capabilities to support accessibility standards and content delivery to any destination.
    • -
    • Achieve a more sustainable and flexible framework for component and extension developers.
    • -
    • Deliver backwards compatibility with previous releases of components, templates, modules and other extensions.
    • -
    - -

    What are "extensions"?

    -

    Components, languages, modules, plugins and templates are now collectively known as Extensions.

    - -

    Where did the installer go?

    -

    The improved installer can be found under the extensions option. With versions prior to 1.5 you needed to select a specific extension type when you wanted to install it. With Joomla! 1.5 you just select the extension you want to upload, and click on install. The installer will do all the hard work for you.

    - -

    What happened to the locale setting?

    -

    This is now defined in the language .xml file in the language metadata settings. If you are having locale problems (dates don't appear in your language, for example) you might want to check/edit the entries in the locale tag. Note that multiple locale strings can be set and the host will usually accept the first one recognised.

    - -

    Only one edit window! How do I create "Read more..."?

    -

    This is now implemented by inserting a tag (button is in the editor area) a dotted line appears in the edited text showing the split location for the "Read more...". A new bot takes care of the rest.

    -

    It is worth mentioning that this does not have a negative effect on migrated data from older sites. The new implementation is fully backwards compatible.

    - -

    Where did the Mambots go?

    -

    Mambots have been renamed as "Plugins". Mambots were introduced in Mambo and offered possibilities to add plugin logic to your site mainly for the purpose of manipulating content. In Joomla!, Plugins will now have much broader capabilities than Mambots. Plugins are able to extend functionality at the framework layer as well.

    - -

    Where is the static content?

    -

    In Joomla! versions prior to 1.5 there was a distinct difference between static and normal content. Both content types are still around, but are not handled as separate items. If you want to create static content, just select "uncategorised" as section and category and the content is handled as static content.

    - -

    What about developers?

    -

    This is the release that developers' have been waiting for. A massive effort has been made to refactor and reorganise the core of Joomla! into a true extendable framework. The new features in the framework are too many to list here but additional documentation can be found on the Joomla! Developer Network site.

    - -

    Compatibility

    -

    We have made every effort to make this version backwards compatible with Joomla 1.0. In order to install 1.0 extensions you will probably need to activate the legacy code plugin. This can be found in the Plugin Manager (it's called "System - Legacy") and you just need to enable it.

    - - - + + + +What's New in Version 1.5 + + + + + + +

    What's New in Version 1.5

    + +

    The following outlines the highlights of the second major release of Joomla!

    + +

    As with previous releases, Joomla! provides a unified and easy-to-use framework for delivering content for websites of all kinds. To support the changing nature of the Internet and emerging web technologies, Joomla! required substantial restructuring of its core functionality and we also used this effort to simplify many challenges within the current user interface. Joomla! 1.5 has many new features.

    + +

    The goals for the Joomla! 1.5 release are to:

    +
      +
    • Substantially improve usability, manageability, and scalability far beyond the original Mambo foundations.
    • +
    • Expand accessibility to support internationalisation, double-byte characters and Right-to-Left support for Arabic and Hebrew languages.
    • +
    • Extend the integration of external applications through Web Services and remote authentication such as the Lightweight Directory Access Protocol (LDAP).
    • +
    • Enhance the content delivery, template and presentation capabilities to support accessibility standards and content delivery to any destination.
    • +
    • Achieve a more sustainable and flexible framework for component and extension developers.
    • +
    • Deliver backwards compatibility with previous releases of components, templates, modules and other extensions.
    • +
    + +

    What are "extensions"?

    +

    Components, languages, modules, plugins and templates are now collectively known as Extensions.

    + +

    Where did the installer go?

    +

    The improved installer can be found under the extensions option. With versions prior to 1.5 you needed to select a specific extension type when you wanted to install it. With Joomla! 1.5 you just select the extension you want to upload, and click on install. The installer will do all the hard work for you.

    + +

    What happened to the locale setting?

    +

    This is now defined in the language .xml file in the language metadata settings. If you are having locale problems (dates don't appear in your language, for example) you might want to check/edit the entries in the locale tag. Note that multiple locale strings can be set and the host will usually accept the first one recognised.

    + +

    Only one edit window! How do I create "Read more..."?

    +

    This is now implemented by inserting a tag (button is in the editor area) a dotted line appears in the edited text showing the split location for the "Read more...". A new bot takes care of the rest.

    +

    It is worth mentioning that this does not have a negative effect on migrated data from older sites. The new implementation is fully backwards compatible.

    + +

    Where did the Mambots go?

    +

    Mambots have been renamed as "Plugins". Mambots were introduced in Mambo and offered possibilities to add plugin logic to your site mainly for the purpose of manipulating content. In Joomla!, Plugins will now have much broader capabilities than Mambots. Plugins are able to extend functionality at the framework layer as well.

    + +

    Where is the static content?

    +

    In Joomla! versions prior to 1.5 there was a distinct difference between static and normal content. Both content types are still around, but are not handled as separate items. If you want to create static content, just select "uncategorised" as section and category and the content is handled as static content.

    + +

    What about developers?

    +

    This is the release that developers' have been waiting for. A massive effort has been made to refactor and reorganise the core of Joomla! into a true extendable framework. The new features in the framework are too many to list here but additional documentation can be found on the Joomla! Developer Network site.

    + +

    Compatibility

    +

    We have made every effort to make this version backwards compatible with Joomla 1.0. In order to install 1.0 extensions you will probably need to activate the legacy code plugin. This can be found in the Plugin Manager (it's called "System - Legacy") and you just need to enable it.

    + + + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.banner.categories.edit.html b/oss/joomla/trunk/administrator/help/en-GB/screen.banner.categories.edit.html index 0ef2629d..62d96b5a 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.banner.categories.edit.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.banner.categories.edit.html @@ -4,7 +4,7 @@ Banner Category Manager - New/Edit - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.banner.categories.html b/oss/joomla/trunk/administrator/help/en-GB/screen.banner.categories.html index fb17744e..77ad43bf 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.banner.categories.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.banner.categories.html @@ -4,7 +4,7 @@ Banner Category Manager - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.banners.client.edit.html b/oss/joomla/trunk/administrator/help/en-GB/screen.banners.client.edit.html index bd03279f..0357e39f 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.banners.client.edit.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.banners.client.edit.html @@ -4,7 +4,7 @@ Banner Client Manager - New/Edit - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.banners.client.html b/oss/joomla/trunk/administrator/help/en-GB/screen.banners.client.html index 218ac93c..3e15f3dc 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.banners.client.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.banners.client.html @@ -4,7 +4,7 @@ Banner Client Manager - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.banners.edit.html b/oss/joomla/trunk/administrator/help/en-GB/screen.banners.edit.html index cc01e255..f2d31209 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.banners.edit.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.banners.edit.html @@ -4,7 +4,7 @@ Banner Manager - New/Edit - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.banners.html b/oss/joomla/trunk/administrator/help/en-GB/screen.banners.html index cbb4dd1a..c3e4452a 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.banners.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.banners.html @@ -4,11 +4,11 @@ Banner Manager - +

    Banner Manager

    -

    The local copy of this help file is no longer maintained. Please use the online version.

    +

    The local copy of this help file is no longer maintained. Please use the online version.

    - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.cache.html b/oss/joomla/trunk/administrator/help/en-GB/screen.cache.html index 266afc8a..dcdcf157 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.cache.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.cache.html @@ -4,7 +4,7 @@ Clean Cache - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.categories.edit.html b/oss/joomla/trunk/administrator/help/en-GB/screen.categories.edit.html index 5392d778..c1eee663 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.categories.edit.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.categories.edit.html @@ -4,7 +4,7 @@ Category Manager - New/Edit - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.categories.html b/oss/joomla/trunk/administrator/help/en-GB/screen.categories.html index 704efcc0..e6e217be 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.categories.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.categories.html @@ -4,11 +4,11 @@ Category Manager - +

    Category Manager

    -

    The local copy of this help file is no longer maintained. Please use the online version.

    +

    The local copy of this help file is no longer maintained. Please use the online version.

    - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.checkin.html b/oss/joomla/trunk/administrator/help/en-GB/screen.checkin.html index 83f1fb75..f4485218 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.checkin.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.checkin.html @@ -4,11 +4,11 @@ Global Check-in - +

    Global Check-in

    -

    The local copy of this help file is no longer maintained. Please use the online version.

    +

    The local copy of this help file is no longer maintained. Please use the online version.

    - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.config.html b/oss/joomla/trunk/administrator/help/en-GB/screen.config.html index 2bc951bf..0be0217a 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.config.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.config.html @@ -4,11 +4,11 @@ Global Configuration - +

    Global Configuration

    -

    The local copy of this help file is no longer maintained. Please use the online version.

    +

    The local copy of this help file is no longer maintained. Please use the online version.

    - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.contact_details.categories.edit.html b/oss/joomla/trunk/administrator/help/en-GB/screen.contact_details.categories.edit.html index 1dbb16e4..4830c86b 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.contact_details.categories.edit.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.contact_details.categories.edit.html @@ -4,7 +4,7 @@ Contact Category Manager - New/Edit - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.contact_details.categories.html b/oss/joomla/trunk/administrator/help/en-GB/screen.contact_details.categories.html index ceea68fb..494ed0e7 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.contact_details.categories.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.contact_details.categories.html @@ -4,7 +4,7 @@ Contact Category Manager - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.contactmanager.edit.html b/oss/joomla/trunk/administrator/help/en-GB/screen.contactmanager.edit.html index 75a9a099..118809d6 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.contactmanager.edit.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.contactmanager.edit.html @@ -4,7 +4,7 @@ Contact Manager - New/Edit - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.contactmanager.html b/oss/joomla/trunk/administrator/help/en-GB/screen.contactmanager.html index c15bd975..493ac339 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.contactmanager.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.contactmanager.html @@ -4,11 +4,11 @@ Contact Manager - +

    Contact Manager

    The local copy of this help file is no longer maintained. Please use the online version.

    - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.content.categories.edit.html b/oss/joomla/trunk/administrator/help/en-GB/screen.content.categories.edit.html index 3d5dc00b..db4d65f5 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.content.categories.edit.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.content.categories.edit.html @@ -4,7 +4,7 @@ Content Category Manager - New/Edit - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.content.categories.html b/oss/joomla/trunk/administrator/help/en-GB/screen.content.categories.html index 892f7213..a2bd712a 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.content.categories.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.content.categories.html @@ -4,7 +4,7 @@ Content Category Manager - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.content.edit.html b/oss/joomla/trunk/administrator/help/en-GB/screen.content.edit.html index 7cce5c6e..b64b3fda 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.content.edit.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.content.edit.html @@ -4,7 +4,7 @@ Article Manager - New/Edit - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.content.html b/oss/joomla/trunk/administrator/help/en-GB/screen.content.html index d308187d..002dfdf6 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.content.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.content.html @@ -4,11 +4,11 @@ Article Manager - +

    Article Manager

    -

    The local copy of this help file is no longer maintained. Please use the online version.

    +

    The local copy of this help file is no longer maintained. Please use the online version.

    - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.cpanel.html b/oss/joomla/trunk/administrator/help/en-GB/screen.cpanel.html index c1c2d135..d6dd3e45 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.cpanel.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.cpanel.html @@ -4,11 +4,11 @@ Control Panel - +

    Control Panel

    -

    The local copy of this help file is no longer maintained. Please use the online version.

    +

    The local copy of this help file is no longer maintained. Please use the online version.

    - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.frontpage.html b/oss/joomla/trunk/administrator/help/en-GB/screen.frontpage.html index 2dd88564..ec5f5b31 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.frontpage.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.frontpage.html @@ -4,11 +4,11 @@ Frontpage Manager - +

    Frontpage Manager

    -

    The local copy of this help file is no longer maintained. Please use the online version.

    +

    The local copy of this help file is no longer maintained. Please use the online version.

    - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.installer.html b/oss/joomla/trunk/administrator/help/en-GB/screen.installer.html index 6de5f4d0..df6d2dea 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.installer.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.installer.html @@ -4,7 +4,7 @@ Extension Manager - Install - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.languages.html b/oss/joomla/trunk/administrator/help/en-GB/screen.languages.html index ec3ab900..2685b202 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.languages.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.languages.html @@ -4,11 +4,11 @@ Language Manager - +

    Language Manager

    -

    The local copy of this help file is no longer maintained. Please use the online version.

    +

    The local copy of this help file is no longer maintained. Please use the online version.

    - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.mediamanager.html b/oss/joomla/trunk/administrator/help/en-GB/screen.mediamanager.html index 5354e5d1..928cfb16 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.mediamanager.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.mediamanager.html @@ -4,11 +4,11 @@ Media Manager - +

    Media Manager

    -

    The local copy of this help file is no longer maintained. Please use the online version.

    +

    The local copy of this help file is no longer maintained. Please use the online version.

    - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.menumanager.html b/oss/joomla/trunk/administrator/help/en-GB/screen.menumanager.html index 381d944b..b9534689 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.menumanager.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.menumanager.html @@ -4,11 +4,11 @@ Menu Manager - +

    Menu Manager

    -

    The local copy of this help file is no longer maintained. Please use the online version.

    +

    The local copy of this help file is no longer maintained. Please use the online version.

    - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.menumanager.new.html b/oss/joomla/trunk/administrator/help/en-GB/screen.menumanager.new.html index 743892b6..7a3d1955 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.menumanager.new.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.menumanager.new.html @@ -4,7 +4,7 @@ Menu Manager - New/Edit - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.menus.edit.html b/oss/joomla/trunk/administrator/help/en-GB/screen.menus.edit.html index caa9b761..3d41e671 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.menus.edit.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.menus.edit.html @@ -4,7 +4,7 @@ Menu Item Manager - New/Edit - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.menus.html b/oss/joomla/trunk/administrator/help/en-GB/screen.menus.html index 99c559aa..14b4a2a4 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.menus.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.menus.html @@ -4,7 +4,7 @@ Menu Item Manager - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.messages.edit.html b/oss/joomla/trunk/administrator/help/en-GB/screen.messages.edit.html index aecc6cc2..2ea234ae 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.messages.edit.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.messages.edit.html @@ -4,7 +4,7 @@ Private Messages - Edit - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.messages.inbox.html b/oss/joomla/trunk/administrator/help/en-GB/screen.messages.inbox.html index 4a63549a..31fb5883 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.messages.inbox.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.messages.inbox.html @@ -4,7 +4,7 @@ Private Messages - Inbox - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.messages.read.html b/oss/joomla/trunk/administrator/help/en-GB/screen.messages.read.html index 4f653d29..7fc4829b 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.messages.read.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.messages.read.html @@ -4,7 +4,7 @@ Private Messages - Read - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.modules.edit.html b/oss/joomla/trunk/administrator/help/en-GB/screen.modules.edit.html index 5c225c10..65d544b6 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.modules.edit.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.modules.edit.html @@ -4,11 +4,11 @@ Module - Edit - +

    Module - Edit

    The local copy of this help file is no longer maintained. Please use the online version.

    - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.modules.html b/oss/joomla/trunk/administrator/help/en-GB/screen.modules.html index 49f56cc7..41046f80 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.modules.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.modules.html @@ -4,11 +4,11 @@ Module Manager - +

    Module Manager

    The local copy of this help file is no longer maintained. Please use the online version.

    - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.modules.new.html b/oss/joomla/trunk/administrator/help/en-GB/screen.modules.new.html index 67be7ada..49349c8c 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.modules.new.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.modules.new.html @@ -4,11 +4,11 @@ Module - New - +

    Module - New

    The local copy of this help file is no longer maintained. Please use the online version.

    - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.modulesadministrator.edit.html b/oss/joomla/trunk/administrator/help/en-GB/screen.modulesadministrator.edit.html index 2cfbc4af..60c079cf 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.modulesadministrator.edit.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.modulesadministrator.edit.html @@ -4,7 +4,7 @@ Modules Administrator - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.modulessite.edit.html b/oss/joomla/trunk/administrator/help/en-GB/screen.modulessite.edit.html index 330af3e4..f51c9144 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.modulessite.edit.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.modulessite.edit.html @@ -4,7 +4,7 @@ Modules Site - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.newsfeeds.categories.edit.html b/oss/joomla/trunk/administrator/help/en-GB/screen.newsfeeds.categories.edit.html index 1f1bdd42..89a09104 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.newsfeeds.categories.edit.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.newsfeeds.categories.edit.html @@ -4,7 +4,7 @@ News Feeds Category Manager - New/Edit - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.newsfeeds.categories.html b/oss/joomla/trunk/administrator/help/en-GB/screen.newsfeeds.categories.html index b6f836a8..b8583d62 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.newsfeeds.categories.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.newsfeeds.categories.html @@ -4,7 +4,7 @@ News Feeds Category Manager - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.newsfeeds.edit.html b/oss/joomla/trunk/administrator/help/en-GB/screen.newsfeeds.edit.html index 98bac9ff..970aac1a 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.newsfeeds.edit.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.newsfeeds.edit.html @@ -4,7 +4,7 @@ News Feeds Manager - New/Edit - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.newsfeeds.html b/oss/joomla/trunk/administrator/help/en-GB/screen.newsfeeds.html index 4a793fe4..0e8b5dc9 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.newsfeeds.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.newsfeeds.html @@ -4,11 +4,11 @@ News Feeds Manager - +

    News Feeds Manager

    -

    The local copy of this help file is no longer maintained. Please use the online version.

    +

    The local copy of this help file is no longer maintained. Please use the online version.

    - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.plugins.edit.html b/oss/joomla/trunk/administrator/help/en-GB/screen.plugins.edit.html index 9ba759e6..bc17a312 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.plugins.edit.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.plugins.edit.html @@ -4,7 +4,7 @@ Plugins - New/Edit - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.plugins.html b/oss/joomla/trunk/administrator/help/en-GB/screen.plugins.html index b17a212f..1763e904 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.plugins.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.plugins.html @@ -4,11 +4,11 @@ Plugin Manager - +

    Plugin Manager

    The local copy of this help file is no longer maintained. Please use the online version.

    - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.polls.edit.html b/oss/joomla/trunk/administrator/help/en-GB/screen.polls.edit.html index 45970820..fe153342 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.polls.edit.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.polls.edit.html @@ -4,7 +4,7 @@ Poll Manager - New/Edit - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.polls.html b/oss/joomla/trunk/administrator/help/en-GB/screen.polls.html index b56e7e73..d89712e3 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.polls.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.polls.html @@ -4,11 +4,11 @@ Poll Manager - +

    Poll Manager

    -

    The local copy of this help file is no longer maintained. Please use the online version.

    +

    The local copy of this help file is no longer maintained. Please use the online version.

    - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.sections.edit.html b/oss/joomla/trunk/administrator/help/en-GB/screen.sections.edit.html index 570de0e8..706c0cd1 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.sections.edit.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.sections.edit.html @@ -4,7 +4,7 @@ Sections Manager - New/Edit - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.sections.html b/oss/joomla/trunk/administrator/help/en-GB/screen.sections.html index 289a151e..9c1cfae6 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.sections.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.sections.html @@ -4,11 +4,11 @@ Section Manager - +

    Section Manager

    -

    The local copy of this help file is no longer maintained. Please use the online version.

    +

    The local copy of this help file is no longer maintained. Please use the online version.

    - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.stats.searches.html b/oss/joomla/trunk/administrator/help/en-GB/screen.stats.searches.html index 31a15250..2a846337 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.stats.searches.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.stats.searches.html @@ -4,11 +4,11 @@ Search Statistics - +

    Search Statistics

    -

    The local copy of this help file is no longer maintained. Please use the online version.

    +

    The local copy of this help file is no longer maintained. Please use the online version.

    - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.system.info.html b/oss/joomla/trunk/administrator/help/en-GB/screen.system.info.html index 1132a9ef..bfc17c09 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.system.info.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.system.info.html @@ -4,11 +4,11 @@ System Information - +

    System Information

    -

    The local copy of this help file is no longer maintained. Please use the online version.

    +

    The local copy of this help file is no longer maintained. Please use the online version.

    - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.templates.html b/oss/joomla/trunk/administrator/help/en-GB/screen.templates.html index 64894c31..e0b3f2cc 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.templates.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.templates.html @@ -4,11 +4,11 @@ Template Manager - +

    Template Manager

    -

    The local copy of this help file is no longer maintained. Please use the online version.

    +

    The local copy of this help file is no longer maintained. Please use the online version.

    - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.trashmanager.html b/oss/joomla/trunk/administrator/help/en-GB/screen.trashmanager.html index b32ee516..293e44f1 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.trashmanager.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.trashmanager.html @@ -4,11 +4,11 @@ Trash Manager - +

    Trash Manager

    -

    The local copy of this help file is no longer maintained. Please use the online version.

    +

    The local copy of this help file is no longer maintained. Please use the online version.

    - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.users.edit.html b/oss/joomla/trunk/administrator/help/en-GB/screen.users.edit.html index 8ec990cd..d1ee6fed 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.users.edit.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.users.edit.html @@ -4,11 +4,11 @@ User Manager - Add or Edit Users - +

    User Manager - Add or Edit Users

    -

    The local copy of this help file is no longer maintained. Please use the online version.

    +

    The local copy of this help file is no longer maintained. Please use the online version.

    - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.users.html b/oss/joomla/trunk/administrator/help/en-GB/screen.users.html index ea4eef23..a6a07092 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.users.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.users.html @@ -4,7 +4,7 @@ User Manager - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.users.massmail.html b/oss/joomla/trunk/administrator/help/en-GB/screen.users.massmail.html index 55da0d6c..5a7e67d6 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.users.massmail.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.users.massmail.html @@ -4,11 +4,11 @@ Mass Mail Users - +

    Mass Mail Users

    -

    The local copy of this help file is no longer maintained. Please use the online version.

    +

    The local copy of this help file is no longer maintained. Please use the online version.

    - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.weblink.edit.html b/oss/joomla/trunk/administrator/help/en-GB/screen.weblink.edit.html index 633636df..4383c274 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.weblink.edit.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.weblink.edit.html @@ -4,11 +4,11 @@ Web Link Manager : New / Edit - +

    Web Link Manager : New / Edit

    -

    The local copy of this help file is no longer maintained. Please use the online version.

    +

    The local copy of this help file is no longer maintained. Please use the online version.

    - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.weblink.html b/oss/joomla/trunk/administrator/help/en-GB/screen.weblink.html index 85022a9d..1dab762e 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.weblink.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.weblink.html @@ -4,11 +4,11 @@ Web Link Manager - +

    Web Link Manager

    -

    The local copy of this help file is no longer maintained. Please use the online version.

    +

    The local copy of this help file is no longer maintained. Please use the online version.

    - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.weblinks.categories.edit.html b/oss/joomla/trunk/administrator/help/en-GB/screen.weblinks.categories.edit.html index ef2475a2..5a5175cd 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.weblinks.categories.edit.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.weblinks.categories.edit.html @@ -4,7 +4,7 @@ Web Link Category Manager - New/Edit - + diff --git a/oss/joomla/trunk/administrator/help/en-GB/screen.weblinks.categories.html b/oss/joomla/trunk/administrator/help/en-GB/screen.weblinks.categories.html index c1f0484d..6809ad6f 100644 --- a/oss/joomla/trunk/administrator/help/en-GB/screen.weblinks.categories.html +++ b/oss/joomla/trunk/administrator/help/en-GB/screen.weblinks.categories.html @@ -4,7 +4,7 @@ Web Link Category Manager - + diff --git a/oss/joomla/trunk/administrator/help/helpsites-15.xml b/oss/joomla/trunk/administrator/help/helpsites-15.xml index 96f19265..632c8e7b 100644 --- a/oss/joomla/trunk/administrator/help/helpsites-15.xml +++ b/oss/joomla/trunk/administrator/help/helpsites-15.xml @@ -8,5 +8,9 @@ German -hilfe.jgerman.de Dutch(NL) - help.joomlacommunity.eu Catalan - joomla.cat + French - Joomla.fr + Farsi - Joomfa.org + Norwegian - joomlainorge.no + Ukrainian - joomla-ua.org - \ No newline at end of file + diff --git a/oss/joomla/trunk/administrator/includes/application.php b/oss/joomla/trunk/administrator/includes/application.php index aacdaef2..1ca03aaf 100644 --- a/oss/joomla/trunk/administrator/includes/application.php +++ b/oss/joomla/trunk/administrator/includes/application.php @@ -1,293 +1,293 @@ -getName(), '', JURI::base(true))); - } - - /** - * Initialise the application. - * - * @access public - * @param array An optional associative array of configuration settings. - */ - function initialise($options = array()) - { - // if a language was specified it has priority - // otherwise use user or default language settings - if (empty($options['language'])) - { - $user = & JFactory::getUser(); - $lang = $user->getParam( 'admin_language' ); - - // Make sure that the user's language exists - if ( $lang && JLanguage::exists($lang) ) { - $options['language'] = $lang; - } else { - $params = JComponentHelper::getParams('com_languages'); - $client =& JApplicationHelper::getClientInfo($this->getClientId()); - $options['language'] = $params->get($client->name, 'en-GB'); - } - } - - // One last check to make sure we have something - if ( ! JLanguage::exists($options['language']) ) { - $options['language'] = 'en-GB'; - } - - parent::initialise($options); - } - - /** - * Route the application - * - * @access public - */ - function route() - { - $uri = JURI::getInstance(); - - if($this->getCfg('force_ssl') >= 1 && strtolower($uri->getScheme()) != 'https') { - //forward to https - $uri->setScheme('https'); - $this->redirect($uri->toString()); - } - } - - /** - * Return a reference to the JRouter object. - * - * @access public - * @return JRouter. - * @since 1.5 - */ - function &getRouter() - { - $router =& parent::getRouter('administrator'); - return $router; - } - - /** - * Dispatch the application - * - * @access public - */ - function dispatch($component) - { - $document =& JFactory::getDocument(); - $user =& JFactory::getUser(); - - switch($document->getType()) - { - case 'html' : - { - $document->setMetaData( 'keywords', $this->getCfg('MetaKeys') ); - - if ( $user->get('id') ) { - $document->addScript( JURI::root(true).'/includes/js/joomla.javascript.js'); - } - - JHTML::_('behavior.mootools'); - } break; - - default : break; - } - - $document->setTitle( htmlspecialchars_decode($this->getCfg('sitename' )). ' - ' .JText::_( 'Administration' )); - $document->setDescription( $this->getCfg('MetaDesc') ); - - $contents = JComponentHelper::renderComponent($component); - $document->setBuffer($contents, 'component'); - } - - /** - * Display the application. - * - * @access public - */ - function render() - { - $component = JRequest::getCmd('option'); - $template = $this->getTemplate(); - $file = JRequest::getCmd('tmpl', 'index'); - - if($component == 'com_login') { - $file = 'login'; - } - - $params = array( - 'template' => $template, - 'file' => $file.'.php', - 'directory' => JPATH_THEMES - ); - - $document =& JFactory::getDocument(); - $data = $document->render($this->getCfg('caching'), $params ); - JResponse::setBody($data); - } - - /** - * Login authentication function - * - * @param array Array( 'username' => string, 'password' => string ) - * @param array Array( 'remember' => boolean ) - * @access public - * @see JApplication::login - */ - function login($credentials, $options = array()) - { - //The minimum group - $options['group'] = 'Public Backend'; - - //Make sure users are not autoregistered - $options['autoregister'] = false; - - //Set the application login entry point - if(!array_key_exists('entry_url', $options)) { - $options['entry_url'] = JURI::base().'index.php?option=com_user&task=login'; - } - - $result = parent::login($credentials, $options); - - if(!JError::isError($result)) - { - $lang = JRequest::getCmd('lang'); - $lang = preg_replace( '/[^A-Z-]/i', '', $lang ); - $this->setUserState( 'application.lang', $lang ); - - JAdministrator::purgeMessages(); - } - - return $result; - } - - /** - * Get the template - * - * @return string The template name - * @since 1.0 - */ - function getTemplate() - { - static $template; - - if (!isset($template)) - { - // Load the template name from the database - $db =& JFactory::getDBO(); - $query = 'SELECT template' - . ' FROM #__templates_menu' - . ' WHERE client_id = 1' - . ' AND menuid = 0' - ; - $db->setQuery( $query ); - $template = $db->loadResult(); - - $template = JFilterInput::clean($template, 'cmd'); - - if (!file_exists(JPATH_THEMES.DS.$template.DS.'index.php')) { - $template = 'khepri'; - } - } - - return $template; - } - - /** - * Purge the jos_messages table of old messages - * - * static method - * @since 1.5 - */ - function purgeMessages() - { - $db =& JFactory::getDBO(); - $user =& JFactory::getUser(); - - $userid = $user->get('id'); - - $query = 'SELECT *' - . ' FROM #__messages_cfg' - . ' WHERE user_id = ' . (int) $userid - . ' AND cfg_name = "auto_purge"' - ; - $db->setQuery( $query ); - $config = $db->loadObject( ); - - // check if auto_purge value set - if (is_object( $config ) and $config->cfg_name == 'auto_purge' ) - { - $purge = $config->cfg_value; - } - else - { - // if no value set, default is 7 days - $purge = 7; - } - // calculation of past date - - // if purge value is not 0, then allow purging of old messages - if ($purge > 0) - { - // purge old messages at day set in message configuration - $past =& JFactory::getDate(time() - $purge * 86400); - $pastStamp = $past->toMySQL(); - - $query = 'DELETE FROM #__messages' - . ' WHERE date_time < ' . $db->Quote( $pastStamp ) - . ' AND user_id_to = ' . (int) $userid - ; - $db->setQuery( $query ); - $db->query(); - } - } - - /** - * Deprecated, use JURI::root() instead. - * - * @since 1.5 - * @deprecated As of version 1.5 - * @see JURI::root() - */ - function getSiteURL() - { - return JURI::root(); - } -} +getName(), '', JURI::base(true))); + } + + /** + * Initialise the application. + * + * @access public + * @param array An optional associative array of configuration settings. + */ + function initialise($options = array()) + { + // if a language was specified it has priority + // otherwise use user or default language settings + if (empty($options['language'])) + { + $user = & JFactory::getUser(); + $lang = $user->getParam( 'admin_language' ); + + // Make sure that the user's language exists + if ( $lang && JLanguage::exists($lang) ) { + $options['language'] = $lang; + } else { + $params = JComponentHelper::getParams('com_languages'); + $client =& JApplicationHelper::getClientInfo($this->getClientId()); + $options['language'] = $params->get($client->name, 'en-GB'); + } + } + + // One last check to make sure we have something + if ( ! JLanguage::exists($options['language']) ) { + $options['language'] = 'en-GB'; + } + + parent::initialise($options); + } + + /** + * Route the application + * + * @access public + */ + function route() + { + $uri = JURI::getInstance(); + + if($this->getCfg('force_ssl') >= 1 && strtolower($uri->getScheme()) != 'https') { + //forward to https + $uri->setScheme('https'); + $this->redirect($uri->toString()); + } + } + + /** + * Return a reference to the JRouter object. + * + * @access public + * @return JRouter. + * @since 1.5 + */ + function &getRouter() + { + $router =& parent::getRouter('administrator'); + return $router; + } + + /** + * Dispatch the application + * + * @access public + */ + function dispatch($component) + { + $document =& JFactory::getDocument(); + $user =& JFactory::getUser(); + + switch($document->getType()) + { + case 'html' : + { + $document->setMetaData( 'keywords', $this->getCfg('MetaKeys') ); + + if ( $user->get('id') ) { + $document->addScript( JURI::root(true).'/includes/js/joomla.javascript.js'); + } + + JHTML::_('behavior.mootools'); + } break; + + default : break; + } + + $document->setTitle( htmlspecialchars_decode($this->getCfg('sitename' )). ' - ' .JText::_( 'Administration' )); + $document->setDescription( $this->getCfg('MetaDesc') ); + + $contents = JComponentHelper::renderComponent($component); + $document->setBuffer($contents, 'component'); + } + + /** + * Display the application. + * + * @access public + */ + function render() + { + $component = JRequest::getCmd('option'); + $template = $this->getTemplate(); + $file = JRequest::getCmd('tmpl', 'index'); + + if($component == 'com_login') { + $file = 'login'; + } + + $params = array( + 'template' => $template, + 'file' => $file.'.php', + 'directory' => JPATH_THEMES + ); + + $document =& JFactory::getDocument(); + $data = $document->render($this->getCfg('caching'), $params ); + JResponse::setBody($data); + } + + /** + * Login authentication function + * + * @param array Array( 'username' => string, 'password' => string ) + * @param array Array( 'remember' => boolean ) + * @access public + * @see JApplication::login + */ + function login($credentials, $options = array()) + { + //The minimum group + $options['group'] = 'Public Backend'; + + //Make sure users are not autoregistered + $options['autoregister'] = false; + + //Set the application login entry point + if(!array_key_exists('entry_url', $options)) { + $options['entry_url'] = JURI::base().'index.php?option=com_user&task=login'; + } + + $result = parent::login($credentials, $options); + + if(!JError::isError($result)) + { + $lang = JRequest::getCmd('lang'); + $lang = preg_replace( '/[^A-Z-]/i', '', $lang ); + $this->setUserState( 'application.lang', $lang ); + + JAdministrator::purgeMessages(); + } + + return $result; + } + + /** + * Get the template + * + * @return string The template name + * @since 1.0 + */ + function getTemplate() + { + static $template; + + if (!isset($template)) + { + // Load the template name from the database + $db =& JFactory::getDBO(); + $query = 'SELECT template' + . ' FROM #__templates_menu' + . ' WHERE client_id = 1' + . ' AND menuid = 0' + ; + $db->setQuery( $query ); + $template = $db->loadResult(); + + $template = JFilterInput::clean($template, 'cmd'); + + if (!file_exists(JPATH_THEMES.DS.$template.DS.'index.php')) { + $template = 'khepri'; + } + } + + return $template; + } + + /** + * Purge the jos_messages table of old messages + * + * static method + * @since 1.5 + */ + function purgeMessages() + { + $db =& JFactory::getDBO(); + $user =& JFactory::getUser(); + + $userid = $user->get('id'); + + $query = 'SELECT *' + . ' FROM #__messages_cfg' + . ' WHERE user_id = ' . (int) $userid + . ' AND cfg_name = "auto_purge"' + ; + $db->setQuery( $query ); + $config = $db->loadObject( ); + + // check if auto_purge value set + if (is_object( $config ) and $config->cfg_name == 'auto_purge' ) + { + $purge = $config->cfg_value; + } + else + { + // if no value set, default is 7 days + $purge = 7; + } + // calculation of past date + + // if purge value is not 0, then allow purging of old messages + if ($purge > 0) + { + // purge old messages at day set in message configuration + $past =& JFactory::getDate(time() - $purge * 86400); + $pastStamp = $past->toMySQL(); + + $query = 'DELETE FROM #__messages' + . ' WHERE date_time < ' . $db->Quote( $pastStamp ) + . ' AND user_id_to = ' . (int) $userid + ; + $db->setQuery( $query ); + $db->query(); + } + } + + /** + * Deprecated, use JURI::root() instead. + * + * @since 1.5 + * @deprecated As of version 1.5 + * @see JURI::root() + */ + function getSiteURL() + { + return JURI::root(); + } +} diff --git a/oss/joomla/trunk/administrator/includes/defines.php b/oss/joomla/trunk/administrator/includes/defines.php index f20f37f0..fde0fe59 100644 --- a/oss/joomla/trunk/administrator/includes/defines.php +++ b/oss/joomla/trunk/administrator/includes/defines.php @@ -1,33 +1,33 @@ -error_reporting === 0) { - error_reporting( 0 ); -} else if (@$CONFIG->error_reporting > 0) { - error_reporting( $CONFIG->error_reporting ); - ini_set( 'display_errors', 1 ); -} - -define( 'JDEBUG', $CONFIG->debug ); - -unset( $CONFIG ); - -/* - * Joomla! framework loading - */ - -// Include object abstract class -require_once(JPATH_SITE.DS.'libraries'.DS.'joomla'.DS.'utilities'.DS.'compat'.DS.'compat.php'); - -// System profiler -if (JDEBUG) { - jimport( 'joomla.error.profiler' ); - $_PROFILER =& JProfiler::getInstance( 'Application' ); -} - -// Joomla! library imports -jimport( 'joomla.application.menu' ); -jimport( 'joomla.user.user'); -jimport( 'joomla.environment.uri' ); -jimport( 'joomla.html.html' ); -jimport( 'joomla.html.parameter' ); -jimport( 'joomla.utilities.utility' ); -jimport( 'joomla.event.event'); -jimport( 'joomla.event.dispatcher'); -jimport( 'joomla.language.language'); -jimport( 'joomla.utilities.string' ); - -?> +error_reporting === 0) { + error_reporting( 0 ); +} else if (@$CONFIG->error_reporting > 0) { + error_reporting( $CONFIG->error_reporting ); + ini_set( 'display_errors', 1 ); +} + +define( 'JDEBUG', $CONFIG->debug ); + +unset( $CONFIG ); + +/* + * Joomla! framework loading + */ + +// Include object abstract class +require_once(JPATH_SITE.DS.'libraries'.DS.'joomla'.DS.'utilities'.DS.'compat'.DS.'compat.php'); + +// System profiler +if (JDEBUG) { + jimport( 'joomla.error.profiler' ); + $_PROFILER =& JProfiler::getInstance( 'Application' ); +} + +// Joomla! library imports +jimport( 'joomla.application.menu' ); +jimport( 'joomla.user.user'); +jimport( 'joomla.environment.uri' ); +jimport( 'joomla.html.html' ); +jimport( 'joomla.html.parameter' ); +jimport( 'joomla.utilities.utility' ); +jimport( 'joomla.event.event'); +jimport( 'joomla.event.dispatcher'); +jimport( 'joomla.language.language'); +jimport( 'joomla.utilities.string' ); + +?> diff --git a/oss/joomla/trunk/administrator/includes/helper.php b/oss/joomla/trunk/administrator/includes/helper.php index 82b0c297..e5774bd1 100644 --- a/oss/joomla/trunk/administrator/includes/helper.php +++ b/oss/joomla/trunk/administrator/includes/helper.php @@ -1,52 +1,52 @@ -get('guest')) { - $option = 'com_login'; - } - - if(empty($option)) { - $option = 'com_cpanel'; - } - - JRequest::setVar('option', $option); - return $option; - } -} - +get('guest')) { + $option = 'com_login'; + } + + if(empty($option)) { + $option = 'com_cpanel'; + } + + JRequest::setVar('option', $option); + return $option; + } +} + ?> \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/includes/router.php b/oss/joomla/trunk/administrator/includes/router.php index 6e747207..d890729b 100644 --- a/oss/joomla/trunk/administrator/includes/router.php +++ b/oss/joomla/trunk/administrator/includes/router.php @@ -1,50 +1,50 @@ -_createURI($url); - - return $uri; - } +_createURI($url); + + return $uri; + } } \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/includes/toolbar.php b/oss/joomla/trunk/administrator/includes/toolbar.php index a92badf0..0e7e27bf 100644 --- a/oss/joomla/trunk/administrator/includes/toolbar.php +++ b/oss/joomla/trunk/administrator/includes/toolbar.php @@ -1,505 +1,505 @@ -\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 a media_manager button - * @param string The sub-drectory to upload the media to - * @since 1.0 - */ - function media_manager($directory = '', $alt = 'Upload') - { - $bar = & JToolBar::getInstance('toolbar'); - // Add an upload button - $bar->appendButton( 'Popup', 'upload', $alt, "index.php?option=com_media&tmpl=component&task=popupUpload&directory=$directory", 640, 520 ); - } - - /** - * 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 ); - } -} - -/** -* Utility class for the submenu -* -* @package Joomla -*/ -class JSubMenuHelper -{ - function addEntry($name, $link = '', $active = false) - { - $menu = &JToolBar::getInstance('submenu'); - $menu->appendButton($name, $link, $active); - } -} -?> +\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 a media_manager button + * @param string The sub-drectory to upload the media to + * @since 1.0 + */ + function media_manager($folder = '', $alt = 'Upload') + { + $bar = & JToolBar::getInstance('toolbar'); + // Add an upload button + $bar->appendButton( 'Popup', 'upload', $alt, "index.php?option=com_media&tmpl=component&task=popupUpload&folder=$folder", 640, 520 ); + } + + /** + * 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 ); + } +} + +/** +* Utility class for the submenu +* +* @package Joomla +*/ +class JSubMenuHelper +{ + function addEntry($name, $link = '', $active = false) + { + $menu = &JToolBar::getInstance('submenu'); + $menu->appendButton($name, $link, $active); + } +} +?> diff --git a/oss/joomla/trunk/administrator/index.php b/oss/joomla/trunk/administrator/index.php index 29d482ae..ab30cfa4 100644 --- a/oss/joomla/trunk/administrator/index.php +++ b/oss/joomla/trunk/administrator/index.php @@ -1,88 +1,88 @@ -mark( 'afterLoad' ) : null; - -/** - * CREATE THE APPLICATION - * - * NOTE : - */ -$mainframe =& JFactory::getApplication('administrator'); - -/** - * INITIALISE THE APPLICATION - * - * NOTE : - */ -$mainframe->initialise(array( - 'language' => $mainframe->getUserState( "application.lang", 'lang' ) -)); - -JPluginHelper::importPlugin('system'); - -// trigger the onAfterInitialise events -JDEBUG ? $_PROFILER->mark('afterInitialise') : null; -$mainframe->triggerEvent('onAfterInitialise'); - -/** - * ROUTE THE APPLICATION - * - * NOTE : - */ -$mainframe->route(); - -// trigger the onAfterRoute events -JDEBUG ? $_PROFILER->mark('afterRoute') : null; -$mainframe->triggerEvent('onAfterRoute'); - -/** - * DISPATCH THE APPLICATION - * - * NOTE : - */ -$option = JAdministratorHelper::findOption(); -$mainframe->dispatch($option); - -// trigger the onAfterDispatch events -JDEBUG ? $_PROFILER->mark('afterDispatch') : null; -$mainframe->triggerEvent('onAfterDispatch'); - -/** - * RENDER THE APPLICATION - * - * NOTE : - */ -$mainframe->render(); - -// trigger the onAfterRender events -JDEBUG ? $_PROFILER->mark( 'afterRender' ) : null; -$mainframe->triggerEvent( 'onAfterRender' ); - -/** - * RETURN THE RESPONSE - */ -echo JResponse::toString($mainframe->getCfg('gzip')); +mark( 'afterLoad' ) : null; + +/** + * CREATE THE APPLICATION + * + * NOTE : + */ +$mainframe =& JFactory::getApplication('administrator'); + +/** + * INITIALISE THE APPLICATION + * + * NOTE : + */ +$mainframe->initialise(array( + 'language' => $mainframe->getUserState( "application.lang", 'lang' ) +)); + +JPluginHelper::importPlugin('system'); + +// trigger the onAfterInitialise events +JDEBUG ? $_PROFILER->mark('afterInitialise') : null; +$mainframe->triggerEvent('onAfterInitialise'); + +/** + * ROUTE THE APPLICATION + * + * NOTE : + */ +$mainframe->route(); + +// trigger the onAfterRoute events +JDEBUG ? $_PROFILER->mark('afterRoute') : null; +$mainframe->triggerEvent('onAfterRoute'); + +/** + * DISPATCH THE APPLICATION + * + * NOTE : + */ +$option = JAdministratorHelper::findOption(); +$mainframe->dispatch($option); + +// trigger the onAfterDispatch events +JDEBUG ? $_PROFILER->mark('afterDispatch') : null; +$mainframe->triggerEvent('onAfterDispatch'); + +/** + * RENDER THE APPLICATION + * + * NOTE : + */ +$mainframe->render(); + +// trigger the onAfterRender events +JDEBUG ? $_PROFILER->mark( 'afterRender' ) : null; +$mainframe->triggerEvent( 'onAfterRender' ); + +/** + * RETURN THE RESPONSE + */ +echo JResponse::toString($mainframe->getCfg('gzip')); ?> \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/index2.php b/oss/joomla/trunk/administrator/index2.php index 0743a892..47aa6856 100644 --- a/oss/joomla/trunk/administrator/index2.php +++ b/oss/joomla/trunk/administrator/index2.php @@ -1,15 +1,15 @@ - \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/index3.php b/oss/joomla/trunk/administrator/index3.php index b84d6c02..c34c6517 100644 --- a/oss/joomla/trunk/administrator/index3.php +++ b/oss/joomla/trunk/administrator/index3.php @@ -1,16 +1,16 @@ - \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_admin.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_admin.ini index 69c25060..f6d5660f 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_admin.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_admin.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_admin.ini 11613 2009-02-07 13:41:23Z kdevine $ +# $Id: en-GB.com_admin.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_banners.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_banners.ini index 5bcd9253..5f2efe09 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_banners.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_banners.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_banners.ini 10554 2008-07-15 17:15:19Z ircmaxell $ +# $Id: en-GB.com_banners.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_banners.menu.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_banners.menu.ini index 2a6c10fe..1ea3b06f 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_banners.menu.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_banners.menu.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_banners.menu.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.com_banners.menu.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_cache.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_cache.ini index 3faf8945..0e682a2d 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_cache.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_cache.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_cache.ini 11403 2009-01-06 06:19:31Z ian $ +# $Id: en-GB.com_cache.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_categories.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_categories.ini index be8c56c1..06f13955 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_categories.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_categories.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_categories.ini 11622 2009-02-15 15:16:27Z kdevine $ +# $Id: en-GB.com_categories.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_checkin.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_checkin.ini index 255fb08b..80241d25 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_checkin.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_checkin.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_checkin.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.com_checkin.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_config.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_config.ini index 1847d8cf..a5077c79 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_config.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_config.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_config.ini 12308 2009-06-23 04:05:28Z ian $ +# $Id: en-GB.com_config.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_contact.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_contact.ini index 9819e6f7..f48e8b46 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_contact.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_contact.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_contact.ini 11624 2009-02-15 15:26:38Z kdevine $ +# $Id: en-GB.com_contact.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_contact.menu.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_contact.menu.ini index 45d8a546..e58583cb 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_contact.menu.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_contact.menu.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_contact.menu.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.com_contact.menu.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_content.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_content.ini index 094e7fa4..f1db4373 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_content.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_content.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_content.ini 12386 2009-06-30 01:15:31Z ian $ +# $Id: en-GB.com_content.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM @@ -186,4 +186,3 @@ WHITE LIST=Whitelist YOU CANNOT EDIT AN ARCHIVED ITEM=You cannot edit an Archived Article. YOU MUST SELECT A CATEGORY=You must select a Category. YOU MUST SELECT A SECTION=You must select a Section. -TOGGLE EDITOR=Toggle editor diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_cpanel.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_cpanel.ini index bfec75ee..f4c2c536 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_cpanel.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_cpanel.ini @@ -1,6 +1,6 @@ # $Id: en-GB.com_cpanel.ini $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_frontpage.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_frontpage.ini index b8d46433..311a78ec 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_frontpage.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_frontpage.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_frontpage.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.com_frontpage.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_installer.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_installer.ini index 661edb8c..43805ec3 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_installer.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_installer.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_installer.ini 11788 2009-04-24 18:32:46Z kdevine $ +# $Id: en-GB.com_installer.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_languages.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_languages.ini index 0752d32c..7e997238 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_languages.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_languages.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_languages.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.com_languages.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_login.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_login.ini index d2e38cc4..9fa8421f 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_login.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_login.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_login.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.com_login.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_massmail.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_massmail.ini index 014908b7..c2816a7a 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_massmail.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_massmail.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_massmail.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.com_massmail.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_media.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_media.ini index 98aeb6e1..c74c7e50 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_media.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_media.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_media.ini 12540 2009-07-22 17:34:44Z ian $ +# $Id: en-GB.com_media.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM @@ -30,6 +30,7 @@ DIRECTORIES=Directories DIRECTORY=Directory DIRECTORY UP=Directory Up DOES NOT EXIST.=does not exist! +ERROR. FILE ALREADY EXISTS=Error. File already exists ERROR. UNABLE TO UPLOAD FILE=Error. Unable to upload file. FILESIZE=Filesize FILES/FOLDERS IN=files/folders in @@ -70,6 +71,7 @@ NOT SET=Not Set NUMFILES=Files: NUMFOLDERS=Folders: PLEASE DELETE ALL FILES/FOLDER IN=Please delete all files/folder in +PLEASE INPUT A FILE FOR UPLOAD=Please input a file for upload PX=px REMOVE FROM QUEUE=Remove from queue SELECT FILE=Select File diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_menus.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_menus.ini index a19afe64..2d8ed582 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_menus.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_menus.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_menus.ini 11625 2009-02-15 15:32:42Z kdevine $ +# $Id: en-GB.com_menus.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_menus.menu.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_menus.menu.ini index 18f29c22..7f16de08 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_menus.menu.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_menus.menu.ini @@ -1,6 +1,6 @@ # $Id: en-GB.com_menus.menu.ini 9076 2007-09-29 13:11:48Z humvee $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_messages.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_messages.ini index 39e750ff..9aaabcc7 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_messages.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_messages.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_messages.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.com_messages.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_modules.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_modules.ini index 4989a282..709c265a 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_modules.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_modules.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_modules.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.com_modules.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM @@ -72,5 +72,5 @@ USER STATUS=User Status VARIES=Varies WARNMAINMENU=You cannot delete the mod_mainmenu Module because it is a core Menu. WARNMODULES=cannot be deleted they can only be uninstalled as they are Joomla! Modules. -WHO\'S ONLINE=WXho's Online +WHO\'S ONLINE=Who's Online YOU CAN ONLY PREVIEW NEW MODULES.=You can only preview new Modules. diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_newsfeeds.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_newsfeeds.ini index fc52be29..e752b24f 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_newsfeeds.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_newsfeeds.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_newsfeeds.ini 11371 2008-12-30 01:31:50Z ian $ +# $Id: en-GB.com_newsfeeds.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_newsfeeds.menu.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_newsfeeds.menu.ini index 52ad88dd..42789f86 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_newsfeeds.menu.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_newsfeeds.menu.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_newsfeeds.menu.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.com_newsfeeds.menu.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_plugins.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_plugins.ini index 295ebb93..d417271c 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_plugins.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_plugins.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_plugins.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.com_plugins.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_poll.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_poll.ini index 985ddd65..7608db8a 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_poll.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_poll.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_poll.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.com_poll.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_poll.menu.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_poll.menu.ini index 694f7998..9cb5d032 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_poll.menu.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_poll.menu.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_poll.menu.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.com_poll.menu.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_search.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_search.ini index 3d1b435a..48afaca1 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_search.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_search.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_search.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.com_search.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_search.menu.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_search.menu.ini index 1e85fddd..c1a575cc 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_search.menu.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_search.menu.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_search.menu.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.com_search.menu.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_sections.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_sections.ini index fbd9807e..f4b925d7 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_sections.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_sections.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_sections.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.com_sections.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_templates.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_templates.ini index 1ebe55d6..68988e18 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_templates.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_templates.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_templates.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.com_templates.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_trash.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_trash.ini index e4385854..cb69e16a 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_trash.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_trash.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_trash.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.com_trash.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_user.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_user.ini index 5ba7e0ee..855db1d7 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_user.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_user.ini @@ -1,6 +1,6 @@ # $Id: en-GB.com_login.ini 8913 2007-09-15 11:00:25Z humvee $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_users.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_users.ini index 6602de9a..5c385246 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_users.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_users.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_users.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.com_users.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_weblinks.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_weblinks.ini index 6e2fef6d..9721b535 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_weblinks.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_weblinks.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_weblinks.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.com_weblinks.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_weblinks.menu.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_weblinks.menu.ini index ffa6a494..d7454e13 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_weblinks.menu.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_weblinks.menu.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_weblinks.menu.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.com_weblinks.menu.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_wrapper.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_wrapper.ini index 30fc56f5..9586084c 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_wrapper.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.com_wrapper.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.com_wrapper.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.com_wrapper.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.ini index 36e263d4..bb009160 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.ini 12308 2009-06-23 04:05:28Z ian $ +# $Id: en-GB.ini 16380 2010-04-23 09:19:48Z ian $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM @@ -95,7 +95,7 @@ TIME ZONE=Time Zone (UTC -03:00) BRAZIL, BUENOS AIRES, GEORGETOWN=(UTC -03:00) Brazil, Buenos Aires, Georgetown (UTC -02:00) MID-ATLANTIC=(UTC -02:00) Mid-Atlantic (UTC -01:00) AZORES, CAPE VERDE ISLANDS=(UTC -01:00) Azores, Cape Verde Islands -(UTC 00:00) WESTERN EUROPE TIME, LONDON, LISBON, CASABLANCA=(UTC 00:00) Western Europe Time, London, Lisbon, Casablanca +(UTC 00:00) WESTERN EUROPE TIME, LONDON, LISBON, CASABLANCA=(UTC 00:00) Western Europe Time, London, Lisbon, Casablanca, Reykjavik (UTC +01:00) AMSTERDAM, BERLIN, BRUSSELS, COPENHAGEN, MADRID, PARIS=(UTC +01:00) Amsterdam, Berlin, Brussels, Copenhagen, Madrid, Paris (UTC +02:00) ISTANBUL, JERUSALEM, KALININGRAD, SOUTH AFRICA=(UTC +02:00) Istanbul, Jerusalem, Kaliningrad, South Africa (UTC +03:00) BAGHDAD, RIYADH, MOSCOW, ST. PETERSBURG=(UTC +03:00) Baghdad, Riyadh, Moscow, St. Petersburg @@ -107,9 +107,9 @@ TIME ZONE=Time Zone (UTC +05:45) KATHMANDU=(UTC +05:45) Kathmandu (UTC +06:00) ALMATY, DHAKA=(UTC +06:00) Almaty, Dhaka (UTC +06:30) YAGOON=(UTC +06:30) Yagoon -(UTC +07:00) BANGKOK, HANOI, JAKARTA=(UTC +07:00) Bangkok, Hanoi, Jakarta +(UTC +07:00) BANGKOK, HANOI, JAKARTA=(UTC +07:00) Bangkok, Hanoi, Jakarta, Phnom Penh (UTC +08:00) BEIJING, PERTH, SINGAPORE, HONG KONG=(UTC +08:00) Beijing, Perth, Singapore, Hong Kong -(UTC +08:00) WESTERN AUSTRALIA=(UTC +08:00) Western Australia +(UTC +08:00) ULAANBAATAR, WESTERN AUSTRALIA=(UTC +08:00) Ulaanbaatar, Western Australia (UTC +09:00) TOKYO, SEOUL, OSAKA, SAPPORO, YAKUTSK=(UTC +09:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk (UTC +09:30) ADELAIDE, DARWIN, YAKUTSK=(UTC +09:30) Adelaide, Darwin, Yakutsk (UTC +10:00) EASTERN AUSTRALIA, GUAM, VLADIVOSTOK=(UTC +10:00) Eastern Australia, Guam, Vladivostok @@ -315,6 +315,7 @@ JOOMLA!=Joomla! JOOMLA! ADMINISTRATION LOGIN=Joomla! Administration Login JOOMLA! LOGO=Joomla! Logo JOOMLA WARNING=Joomla! Warning +JPAGE_CURRENT_OF_TOTAL=Page %s of %s LANGUAGE=Language Name LAST=Last LAST MODIFIED=Last Modified diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_components.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_components.ini index 27fa04b5..c4a44db1 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_components.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_components.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.mod_components.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.mod_components.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_custom.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_custom.ini index 759c6526..1d509f9a 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_custom.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_custom.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.mod_custom.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.mod_custom.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_feed.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_feed.ini index ad1d7f2c..1ea44029 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_feed.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_feed.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.mod_feed.ini 11299 2008-11-22 01:40:44Z ian $ +# $Id: en-GB.mod_feed.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_footer.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_footer.ini index e27afee5..3d705eb7 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_footer.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_footer.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.mod_footer.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.mod_footer.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_latest.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_latest.ini index 7bb91587..15a6d4b2 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_latest.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_latest.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.mod_latest.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.mod_latest.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_logged.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_logged.ini index e98ce03e..2eec030c 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_logged.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_logged.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.mod_logged.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.mod_logged.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_login.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_login.ini index b51c85fc..6aafc8d7 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_login.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_login.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.mod_login.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.mod_login.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_menu.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_menu.ini index c78399c7..c736a7b0 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_menu.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_menu.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.mod_menu.ini 11393 2009-01-05 02:11:06Z ian $ +# $Id: en-GB.mod_menu.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_online.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_online.ini index f600ccb0..27f1bb6b 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_online.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_online.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.mod_online.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.mod_online.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_popular.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_popular.ini index 8fb7e426..c0f8ad43 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_popular.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_popular.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.mod_popular.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.mod_popular.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_quickicon.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_quickicon.ini index 1a31d320..8e8fe4b5 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_quickicon.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_quickicon.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.mod_quickicon.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.mod_quickicon.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_stats.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_stats.ini index 494017d4..34403a6c 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_stats.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_stats.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.mod_stats.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.mod_stats.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_status.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_status.ini index 95dba17b..f8a3ca82 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_status.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_status.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.mod_status.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.mod_status.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_submenu.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_submenu.ini index e9f30acb..d3a66f80 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_submenu.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_submenu.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.mod_submenu.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.mod_submenu.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_title.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_title.ini index c7f5de9d..320f9658 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_title.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_title.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.mod_title.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.mod_title.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_toolbar.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_toolbar.ini index 6bee4307..2c38b3dc 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_toolbar.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_toolbar.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.mod_toolbar.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.mod_toolbar.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_unread.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_unread.ini index 0f0f7eae..426c1db9 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_unread.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.mod_unread.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.mod_unread.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.mod_unread.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_authentication_example.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_authentication_example.ini index 5f49262e..f1704a13 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_authentication_example.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_authentication_example.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_authentication_example.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.plg_authentication_example.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_authentication_gmail.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_authentication_gmail.ini index a23c4c88..5a2ea4b2 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_authentication_gmail.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_authentication_gmail.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_authentication_gmail.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.plg_authentication_gmail.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_authentication_joomla.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_authentication_joomla.ini index a8222d01..4836b105 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_authentication_joomla.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_authentication_joomla.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_authentication_joomla.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.plg_authentication_joomla.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_authentication_ldap.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_authentication_ldap.ini index 16f8317a..2e668ddd 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_authentication_ldap.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_authentication_ldap.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_authentication_ldap.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.plg_authentication_ldap.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_authentication_openid.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_authentication_openid.ini index 2b45ab64..a6cde70d 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_authentication_openid.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_authentication_openid.ini @@ -1,6 +1,6 @@ # $Id: en-GB.plg_authentication_openid.ini # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_code.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_code.ini index 150b95c9..f525741e 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_code.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_code.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_content_code.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.plg_content_code.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_emailcloak.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_emailcloak.ini index 40294c46..e3eb8a6a 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_emailcloak.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_emailcloak.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_content_emailcloak.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.plg_content_emailcloak.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_geshi.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_geshi.ini index 1eea592f..c3e47ab9 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_geshi.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_geshi.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_content_geshi.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.plg_content_geshi.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_image.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_image.ini index 945b05c0..06d8f65e 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_image.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_image.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_content_image.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.plg_content_image.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_loadmodule.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_loadmodule.ini index d675ff4a..549ff490 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_loadmodule.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_loadmodule.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_content_loadmodule.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.plg_content_loadmodule.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_pagebreak.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_pagebreak.ini index 7cb2095f..ad27fa76 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_pagebreak.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_pagebreak.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_content_pagebreak.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.plg_content_pagebreak.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_pagenavigation.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_pagenavigation.ini index d9e8b262..ef488f7a 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_pagenavigation.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_pagenavigation.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_content_pagenavigation.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.plg_content_pagenavigation.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_vote.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_vote.ini index 275f3d0c..38ce3641 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_vote.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_content_vote.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_content_vote.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.plg_content_vote.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_editors-xtd_image.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_editors-xtd_image.ini index 66334559..9e82a663 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_editors-xtd_image.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_editors-xtd_image.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_editors-xtd_image.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.plg_editors-xtd_image.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_editors-xtd_pagebreak.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_editors-xtd_pagebreak.ini index ce197863..887500fe 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_editors-xtd_pagebreak.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_editors-xtd_pagebreak.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_editors-xtd_pagebreak.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.plg_editors-xtd_pagebreak.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_editors-xtd_readmore.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_editors-xtd_readmore.ini index 672bbac8..39722e18 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_editors-xtd_readmore.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_editors-xtd_readmore.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_editors-xtd_readmore.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.plg_editors-xtd_readmore.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_editors_none.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_editors_none.ini index 1489cd13..d016f4af 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_editors_none.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_editors_none.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_editors_none.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.plg_editors_none.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_editors_tinymce.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_editors_tinymce.ini index 04ecbdb6..fc5ff198 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_editors_tinymce.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_editors_tinymce.ini @@ -1,9 +1,10 @@ -# $Id: en-GB.plg_editors_tinymce.ini 12386 2009-06-30 01:15:31Z ian $ +# $Id: en-GB.plg_editors_tinymce.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM + ABILITY TO CHANGE TEXT DIRECTION=Ability to change text direction ABSOLUTE=Absolute ADVANCED=Advanced @@ -14,9 +15,9 @@ CLEANS CODE ON EDITOR LOAD=Cleans code on editor load CODE CLEANUP=Code Cleanup CODE CLEANUP ON SAVE=Code cleanup on save CODE CLEANUP ON STARTUP=Code Cleanup on Startup -CODE CLEANUP UPON SAVING ARTICLE=Code cleaning upon saving article COMPRESSED VERSION=Compressed Version CUSTOM CSS CLASSES=Custom CSS Classes +CUSTOMCSSFILENOTPRESENT=The file name %s was entered in the TinyMCE Custom CSS field. This file could not be found in the default templates folder. No styles are available. DATE FORMAT=Date Format DESCLANGCODE=Editor UI Language. A value here is mandatory if manual language selection is set. DESCLANGMODE=If Yes, editor language will automatically match selected UI language. Do not activate if appropriate editor languages are not installed. @@ -45,9 +46,11 @@ NEVER=Never NEWLINES=New Lines NEWLINES WILL BE MADE INTO THE SELECTED OPTION=New lines will be created using the selected option. P ELEMENTS=P Elements +PARAMBLOCKQUOTE=Insert blockquote tags around the highlighted text. PARAMCODECLEANUP=By default, TinyMCE will clean your code of certain HTML elements like script and center tags and check for security and XHTML compliance. We recommend you do not deactivate this functionality +PARAMCODECLEANUPONSAVE=Recommended setting is 'Always'. Never = Do not clean up code on save. Front End = Clean up code on save when editing from front end only. Always = Cleanup on save when editing from front and back end. PARAMCOMPRESSEDVERSION=Tiny can be run in compressed mode resulting in slightly faster load speeds. However, this mode does not always work (especially in IE) so default for this is Off. Be careful when enabling this to ensure it works on your system. -PARAMCUSTOMCSS=You can specify the loading of a custom CSS file. Simply enter the full URL path to the CSS file you want loaded. If you enter a value in this field, this will overrule the template CSS classes parameter. +PARAMCUSTOMCSS=Optional CSS file that will override the standard editor.css file. Enter a file name to point to a file in the CSS folder of the default template (for example, templates/rhuk_milkyway/css/). Or enter a full URL path to the custom CSS file. If you enter a value in this field, this file will be used instead of the editor.css file. PARAMDIRECTIONALITY=Select whether to display the RTL button. Only Works in Advanced mode PARAMELEMENTPATH=If set to ON, it shows the set classes for the marked text. PARAMENTITIECLEANUP=If set to No, entities are stripped from the code. @@ -86,8 +89,10 @@ SMILIES=Smilies STYLE=Style TABLE=Table TEMPLATE CSS CLASSES=Template CSS classes +TEMPLATECSSFILENOTPRESENT=Could not find the file 'editor.css' in the template or templates/system folder. No styles are available. TEXT DIRECTION=Text Direction TIME FORMAT=Time Format +TOGGLE EDITOR=Toggle editor TOOLBAR=Toolbar URL BEHAVIOUR=URL behaviour URLS=URLs @@ -103,9 +108,9 @@ ADVANCED IMAGE=Advanced image ADVANCED LINK=Advanced link ALIGNMENT OF THE TOOLBAR=Alignment of the toolbar ALL DIALOGS TO OPEN AS FLOATING DIV LAYERS INSTEAD OF POPUP WINDOWS. THIS OPTION CAN BE VERY USEFUL IN ORDER TO GET AROUND POPUP BLOCKERS.=All dialogs to open as floating DIV layers instead of popup windows. This option can be very useful in order to get around popup blockers. +BLOCKQUOTE=Blockquote COLORS=Colors CONTEXT MENU=Context menu -CONTROLS HOW ENTITIES GET PROCESSED BY EDITOR=Controls how entities get processed by editor CUSTOM BUTTON=Custom button CUSTOM PLUGIN=Custom plugin ENTITY ENCODING=Entity Encoding @@ -120,6 +125,7 @@ OFFICE2007 BLACK=Office2007 Black OFFICE2007 BLUE=Office2007 Blue OFFICE2007 SILVER=Office2007 Silver PARAMCOLORS=Show/Hide the Colors control buttons. Only applies in Extended mode +PARAMENTITYENCODING=Controls how HTML entities are encoded. Recommended setting is 'raw'. 'named' = used named entity encoding (for example, '<'). 'numeric' = use numeric HTML encoding (for example, '%03c'). raw = Do not encode HTML entities. Note that searching content may not work properly if setting is not 'raw'. PARAMS EXTENDED MODE=Extended Mode Options
    These options only apply in Extended mode. PARAMFONTS=Show/Hide the Fonts control selectors. Only applies in Extended mode PARAMMEDIA=Show/Hide the Media button. Only applies in Extended mode diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_editors_xstandard.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_editors_xstandard.ini index 854d804d..b9298e92 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_editors_xstandard.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_editors_xstandard.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_editors_xstandard.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.plg_editors_xstandard.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_search_categories.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_search_categories.ini index 7fe567ca..178b3b76 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_search_categories.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_search_categories.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_search_categories.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.plg_search_categories.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_search_contacts.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_search_contacts.ini index dede71ce..cf7b4d37 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_search_contacts.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_search_contacts.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_search_contacts.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.plg_search_contacts.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_search_content.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_search_content.ini index 2e9b63bc..6f2662f7 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_search_content.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_search_content.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_search_content.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.plg_search_content.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_search_newsfeeds.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_search_newsfeeds.ini index 2ea347d5..8241cdb1 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_search_newsfeeds.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_search_newsfeeds.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_search_newsfeeds.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.plg_search_newsfeeds.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_search_sections.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_search_sections.ini index 888188a4..17e4b971 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_search_sections.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_search_sections.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_search_sections.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.plg_search_sections.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_search_weblinks.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_search_weblinks.ini index 14695e2a..1bcb5992 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_search_weblinks.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_search_weblinks.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_search_weblinks.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.plg_search_weblinks.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_system_backlink.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_system_backlink.ini index e3b6f84a..9d16f24f 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_system_backlink.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_system_backlink.ini @@ -1,6 +1,6 @@ # $Id: en-GB.plg_system_backlink.ini 2007-09-29 11:00:25Z humvee $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_system_cache.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_system_cache.ini index 8e1a023a..aa4c3d2e 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_system_cache.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_system_cache.ini @@ -1,6 +1,6 @@ # $Id: en-GB.plg_system_cache.ini # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_system_debug.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_system_debug.ini index 7cf95e30..69687935 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_system_debug.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_system_debug.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_system_debug.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.plg_system_debug.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_system_legacy.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_system_legacy.ini index 94e64dc0..3be55278 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_system_legacy.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_system_legacy.ini @@ -1,6 +1,6 @@ # $Id: en-GB.plg_system_legacy.ini # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_system_sef.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_system_sef.ini index 628e2a17..e2b29406 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_system_sef.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_system_sef.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_system_sef.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.plg_system_sef.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_user_joomla.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_user_joomla.ini index 39b98b7a..904cb666 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_user_joomla.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_user_joomla.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_user_joomla.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.plg_user_joomla.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_xmlrpc_blogger.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_xmlrpc_blogger.ini index f5c45d53..eb10c6a0 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_xmlrpc_blogger.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_xmlrpc_blogger.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_xmlrpc_blogger.ini 10496 2008-07-03 07:08:39Z ircmaxell $ +# $Id: en-GB.plg_xmlrpc_blogger.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_xmlrpc_joomla.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_xmlrpc_joomla.ini index cfc09169..37c7471f 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_xmlrpc_joomla.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.plg_xmlrpc_joomla.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.plg_xmlrpc_joomla.ini 10388 2008-06-03 11:16:20Z pasamio $ +# $Id: en-GB.plg_xmlrpc_joomla.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.tpl_beez.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.tpl_beez.ini index 214706cb..4eab042e 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.tpl_beez.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.tpl_beez.ini @@ -1,6 +1,6 @@ # $Id: en-GB.tpl_beez.ini 1.5.0 2007-04-13 11:55:43 ff 0$ # author Joomla! Project -# copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL # Note : All ini files need to be saved as UTF-8 - No BOM HEADER LEVEL COMPONENT=Header level Component diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.tpl_ja_purity.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.tpl_ja_purity.ini index 0b9838eb..03fc2eee 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.tpl_ja_purity.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.tpl_ja_purity.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.tpl_ja_purity.ini 11403 2009-01-06 06:19:31Z ian $ +# $Id: en-GB.tpl_ja_purity.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2007 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.tpl_khepri.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.tpl_khepri.ini index fbb3ca5e..19958bb7 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.tpl_khepri.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.tpl_khepri.ini @@ -1,6 +1,6 @@ # $Id: en-GB.tpl_khepri.ini 8057 2007-07-18 15:05:56Z humvee $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.tpl_rhuk_milkyway.ini b/oss/joomla/trunk/administrator/language/en-GB/en-GB.tpl_rhuk_milkyway.ini index 30e9d563..98e92123 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.tpl_rhuk_milkyway.ini +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.tpl_rhuk_milkyway.ini @@ -1,6 +1,6 @@ -# $Id: en-GB.tpl_rhuk_milkyway.ini 11394 2009-01-05 15:28:11Z kdevine $ +# $Id: en-GB.tpl_rhuk_milkyway.ini 14401 2010-01-26 14:10:00Z louis $ # Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. +# Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. # License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php # Note : All ini files need to be saved as UTF-8 - No BOM diff --git a/oss/joomla/trunk/administrator/language/en-GB/en-GB.xml b/oss/joomla/trunk/administrator/language/en-GB/en-GB.xml index d5bb4547..37f94d95 100644 --- a/oss/joomla/trunk/administrator/language/en-GB/en-GB.xml +++ b/oss/joomla/trunk/administrator/language/en-GB/en-GB.xml @@ -1,13 +1,13 @@ - + English(United Kingdom) - 1.5.9 - 2008-03-15 + 1.5.15 + 2009-10-27 Joomla! Project admin@joomla.org www.joomla.org - Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.com_admin.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.com_admin.ini index 0451ff7a..4c8162fa 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.com_admin.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.com_admin.ini @@ -1,8 +1,25 @@ -# version 1.5.0 2008-01-14 23:00:17 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL -# Note : All ini files need to be saved as UTF-8 +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ CACHE DIRECTORY=缓存目录 CHANGELOG=更新日志 @@ -23,6 +40,7 @@ INDEX=首页 INFORMATION=系统信息 LATEST VERSION CHECK=检查最新版本 LICENSE=授权协议 +LOG DIRECTORY=日志目录 MAGIC QUOTES=魔术引用(Magic Quotes) MBSTRING ENABLED=Mbstring启用(Mbstring Enabled) JOOMLA! VERSION=Joomla!版本 @@ -46,6 +64,7 @@ STATUS=状态 SUPPORT=支持 SYSTEM INFO=系统信息 SYSTEM INFORMATION=系统信息 +TEMP DIRECTORY=临时目录 USER AGENT=浏览器类型 VALUE=检测到的信息 WEB SERVER=网站服务器 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.com_apoll.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.com_apoll.ini index 14d59dc1..da8aab86 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.com_apoll.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.com_apoll.ini @@ -1,32 +1,24 @@ #/** # * Copyright (C) 2006-2010 YUCHENG HU # * -# * ---------------------------------------------------------------------------------- -# * HA SYSTEMS +# * --------------------------------------------- +# * HA WEBSYSTEMS # * http://www.hawebs.net -# * http://www.hawebs.org -# * http://www.tcivis.com +# * https://www.hawebs.org/forums/computer/ # * -# * Contact +# * CONTACT # * huyuchengus@gmail.com / yuchenghu@hawebs.net # * -# * ---------------------------------------------------------------------------------- -# * This program is free software: you can redistribute it and/or modify -# * it under the terms of the GNU General Public License as published by -# * the Free Software Foundation, either version 3 of the License, or -# * (at your option) any later version. -# * -# * This program is distributed in the hope that it will be useful, -# * but WITHOUT ANY WARRANTY; without even the implied warranty of -# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# * GNU General Public License for more details. +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html # * -# * You should have received a copy of the GNU General Public License -# * along with this program. If not, see +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") # * -# * GNU GENERAL PUBLIC LICENSE -# * -# * ---------------------------------------------------------------------------------- +# * --------------------------------------------- # */ A POLL=投票调查 @@ -46,8 +38,8 @@ APOLL CONFIGURATION COULD NOT BE SAVED!=Apoll 的配置不能被保存! APOLL CONFIGURATION SUCCESSFULLY SAVED!=Apoll 的配置被成功保存! POLLS COULD NOT BE IMPORTED!=投票调查不能被导入! POLLS WERE SUCCESSFULY IMPORTED!=投票调查已经被成功导入了! -APOLL FILES FOR JOOMFISH WERE INSTALLED!=Apoll files for Joomfish were installed! -APOLL FILES FOR JOOMFISH! WERE NOT INSTALLED!=Apoll files for Joomfish! were not installed! +APOLL FILES FOR JOOMFISH WERE INSTALLED!=Joomfish 所使用的 Apoll 文件已经被完全安装了! +APOLL FILES FOR JOOMFISH! WERE NOT INSTALLED!=Joomfish 所使用的 Apoll 文件没有安装了 #install.apoll.php POLLS FROM VERSION 1.2 SUCCESSFULLY IMPORTED=Polls from version 1.2 successfully imported diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.com_apoll.menu.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.com_apoll.menu.ini index 48e8b590..7d3ac5fb 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.com_apoll.menu.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.com_apoll.menu.ini @@ -1,32 +1,24 @@ #/** # * Copyright (C) 2006-2010 YUCHENG HU # * -# * ---------------------------------------------------------------------------------- -# * HA SYSTEMS +# * --------------------------------------------- +# * HA WEBSYSTEMS # * http://www.hawebs.net -# * http://www.hawebs.org -# * http://www.tcivis.com +# * https://www.hawebs.org/forums/computer/ # * -# * Contact +# * CONTACT # * huyuchengus@gmail.com / yuchenghu@hawebs.net # * -# * ---------------------------------------------------------------------------------- -# * This program is free software: you can redistribute it and/or modify -# * it under the terms of the GNU General Public License as published by -# * the Free Software Foundation, either version 3 of the License, or -# * (at your option) any later version. -# * -# * This program is distributed in the hope that it will be useful, -# * but WITHOUT ANY WARRANTY; without even the implied warranty of -# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# * GNU General Public License for more details. +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html # * -# * You should have received a copy of the GNU General Public License -# * along with this program. If not, see +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") # * -# * GNU GENERAL PUBLIC LICENSE -# * -# * ---------------------------------------------------------------------------------- +# * --------------------------------------------- # */ -COM_APOLL=Apoll \ No newline at end of file +COM_APOLL=Apoll 组件 \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.com_cache.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.com_cache.ini index f284561a..5b6c4c7f 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.com_cache.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.com_cache.ini @@ -5,7 +5,14 @@ # Note : All ini files need to be saved as UTF-8 -CACHE MANAGER=缓存管理 +CACHE MANAGER - CLEAN CACHE ADMIN=缓存管理 - 清除缓存 +CACHE MANAGER - PURGE CACHE ADMIN=缓存管理 - 清除过期缓存 +PURGE EXPIRED=清除过期缓存 +PURGE EXPIRED ITEMS=物理清除已过期的缓存文件 +WARNING: THIS CAN BE RESOURCE INTENSIVE ON SITES WITH LARGE NUMBER OF ITEMS!=警告:本操作可能因为涉及大量数据处理而大量消耗服务器资源。 +CLICK ON THE PURGE EXPIRED ICON IN THE TOOLBAR TO DELETE ALL EXPIRED CACHE FILES. NOTE: CACHE FILES THAT ARE STILL CURRENT WILL NOT BE DELETED.=单击工具栏上的 【清除过期缓存】 按钮来清除所有已过期的缓存文件。注意:当前正在使用的缓存文件将会被保留。
    +EXPIRED ITEMS HAVE BEEN PURGED=所有过期的缓存文件已被清除。 +SUCCESS!=操作成功! CACHE DIRECTORY IS UNWRITABLE=缓存目录的访问权限为不可写 CACHE DIRECTORY IS WRITABLE=缓存目录的访问权限为可写 NUM=# diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_feed.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_feed.ini index e90f1f6b..bc0e635f 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_feed.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_feed.ini @@ -1,22 +1,40 @@ -# $Id: en-GB.mod_feed.ini 10554 2008-07-15 17:15:19Z ircmaxell $ -# Joomla! Project -# Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. -# License http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL, see LICENSE.php -# Note : All ini files need to be saved as UTF-8 - No BOM +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ -DISPLAY FEED IN RTL DIRECTION=ÏÔʾÊäÈë FEED RTL µķ½Ïò -DISPLAY NEWS FEED TITLE=ÏÔʾ feed ÐÂÎűêÌâ -ENTER NUMBER OF RSS ITEMS TO DISPLAY=ÊäÈëÐèҪÏÔʾ¶àÉÙ RSS ÌõĿ -ENTER THE URL OF THE RSS/RDF FEED=ÊäÈë URL RSS/RDF feed -FEED DESCRIPTION=Feed ÃèÊö -FEED TITLE=Feed ±êÌâ -FEED URL=Feed URL -ITEM DESCRIPTION=ÌõĿÃèÊö -ITEMS=ÌõĿ -MOD_FEED=mod feed -PARAMITEMDESC=ÏÔʾ¸öÌåÃèÊö»ò½éÉÜÎı¾µÄ RSS ÌõĿ -PARAMWORDCOUNT=ÔÊÐíÄúÏÞÖƶàÉÙÊýÁ¿¿ɿ´¼û£¬ 0 ²»ÏÞÖÆ -RTL FEED=RTL feed -SHOW THE DESCRIPTION TEXT FOR THE WHOLE FEED=ÏÔʾ´Ë Feed Îı¾ÃèÊö -SHOW THE IMAGE ASSOCIATED WITH THE WHOLE FEED=ÏÔʾÓë Feed ÕûÌåÏà¹صÄͼÏñ -WORD COUNT=×Öͳ¼Æ +DISPLAY FEED IN RTL DIRECTION=在 RTL 描述中显示聚合新闻 +DISPLAY NEWS FEED TITLE=显示新聚合新闻的标题 +ENTER NUMBER OF RSS ITEMS TO DISPLAY=输入期望每一个聚合新闻源中显示的聚合新闻条目数量 +ENTER THE URL OF THE RSS/RDF FEED=RSS/RDF 聚合新闻的 URL +ERROR LOADING FEED DATA=载入聚合新闻数据错误 +FEED DESCRIPTION=显示聚合新闻描述 +FEED TITLE=显示聚合新闻标题 +FEED URL=聚合新闻地址 +ITEM DESCRIPTION=显示聚合新闻描述 +ITEMS=聚合新闻显示数量 +MOD_FEED=聚合新闻模块 +PARAMITEMDESC=在单一聚合新闻条目中显示描述或介绍 +PARAMWORDCOUNT=允许你为每一条聚合新闻条目显示描述文本的数量。 0 将会显示所有的文本。 +RTL FEED=RTL 聚合新闻 +SHOW THE DESCRIPTION TEXT FOR THE WHOLE FEED=为所有的聚合新闻显示文本描述 +SHOW THE IMAGE ASSOCIATED WITH THE WHOLE FEED=为所有的聚合新闻显示相关图 +WORD COUNT=字数 \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_menu.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_menu.ini index 472a4573..eefc4d3a 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_menu.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_menu.ini @@ -82,4 +82,5 @@ USER MANAGER=用户管理 UNINSTALL PLUGINS=删除插件 UNINSTALL MODULES=卸载模块 WRITE MESSAGE=撰写短信 -CLEAN CACHE=清空缓存 +CLEAN CACHE=清除缓存 +PURGE EXPIRED CACHE=清除过期缓存 \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_quickicon.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_quickicon.ini index 4389adcb..372144d0 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_quickicon.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_quickicon.ini @@ -1,11 +1,25 @@ -# version 1.5.0 2008-01-14 17:39:03 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ ADD NEW ARTICLE=添加新文章 CATEGORY MANAGER=分类管理 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_stats.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_stats.ini index 8cd0c28c..9705ded4 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_stats.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_stats.ini @@ -1,12 +1,25 @@ -# version 1.5.0 2008-01-14 17:00:17 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - - - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ MENU=菜单 MENU ITEMS=菜单项目 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_status.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_status.ini index 7616cf58..c9d7520e 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_status.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_status.ini @@ -1,11 +1,25 @@ -# version 1.5.0 2008-01-14 17:00:17 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ LEGACY=兼容模式 MOD_STATUS=会员状态模块 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_submenu.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_submenu.ini index 40bef062..dfca74dc 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_submenu.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_submenu.ini @@ -1,11 +1,25 @@ -# version 1.5.0 2008-01-14 17:00:17 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ MOD_SUBMENU=子菜单模块 THIS MODULE SHOWS THE SUBMENU NAVIGATION MODULE=这个模块显示子菜单导航 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_title.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_title.ini index 5dd1f526..c1756047 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_title.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_title.ini @@ -1,11 +1,25 @@ -# version 1.5.0 2008-01-14 17:00:17 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ MOD_TITLE=组件名称模块 THIS MODULE SHOWS THE TOOLBAR COMPONENT TITLE=这个模块显示工具栏的组件的名称 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_toolbar.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_toolbar.ini index 025a6b13..6e31291b 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_toolbar.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_toolbar.ini @@ -1,11 +1,25 @@ -# version 1.5.0 2008-01-14 17:00:17 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ MOD_TOOLBAR=工具栏模块 THIS MODULE SHOWS THE TOOLBAR ICONS USED TO CONTROL ACTIONS THROUGHOUT THE ADMINISTRATOR AREA=该模块显示工具栏图标,用于后台管理 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_unread.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_unread.ini index 80f96eb8..9190604f 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_unread.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.mod_unread.ini @@ -1,11 +1,25 @@ -# version 1.5.0 2008-01-14 17:00:17 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ MOD_UNREAD=未读短信模块 THIS MODULE SHOWS A LIST OF UNREAD ITEMS=该模块显示未阅读的站内短信 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_authentication_example.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_authentication_example.ini index 87f8bb75..3550e71f 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_authentication_example.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_authentication_example.ini @@ -1,9 +1,24 @@ -# version 1.5.0 2008-01-14 17:39:50 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ DESCUSERBOT=提供让Joomla!和第三方程序同步协作的勾子程序(hook) diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_authentication_gmail.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_authentication_gmail.ini index 3a471caa..0ddc8924 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_authentication_gmail.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_authentication_gmail.ini @@ -1,10 +1,24 @@ -# version 1.5.0 2008-01-14 17:00:17 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ HANDLES USER AUTHENTICATION WITH A GMAIL ACCOUNT=处理GMail邮箱的会员认证(需要cURL) diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_authentication_joomla.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_authentication_joomla.ini index 334ff9db..ee77943d 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_authentication_joomla.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_authentication_joomla.ini @@ -1,10 +1,25 @@ -# version 1.5.0 2008-01-14 17:39:58 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ HANDLES JOOMLAS DEFAULT USER AUTHENTICATION=处理Joomla!默认的会员认证 JOOMLA CAN NOT HAVE A BLANK PASSWORD=Joomla!不能有空白密码 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_authentication_ldap.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_authentication_ldap.ini index 809214e3..1befb4e8 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_authentication_ldap.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_authentication_ldap.ini @@ -1,8 +1,25 @@ -# version 1.5.0 2008-01-14 17:40:04 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL -# Note : All ini files need to be saved as UTF-8 +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ AUTHORIZATION METHOD=授权方法 ANONYMOUS COMPARE=匿名比较 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_authentication_openid.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_authentication_openid.ini index afc73e8e..2755881e 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_authentication_openid.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_authentication_openid.ini @@ -1,9 +1,25 @@ -# version 1.5.0 2008-01-14 17:00:17 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ HANDLES USER AUTHENTICATION WITH AN OPENID (REQUIRES PHP5)=以一个OPENID来处理用户的认证(在PHP5中需要) LOGIN_WITH_OPENID=使用OpenID登录 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_code.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_code.ini index 4c06159b..42ee7cc8 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_code.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_code.ini @@ -1,11 +1,25 @@ -# version 1.5.0 2008-01-14 17:00:17 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ MOSCODE=代码 DISPLAYS FORMATTED CODE IN CONTENT ITEMS=显示文章中的格式化的程序代码 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_emailcloak.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_emailcloak.ini index 2d030db7..c26b1c14 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_emailcloak.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_emailcloak.ini @@ -1,11 +1,25 @@ -# version 1.5.0 2008-01-14 17:00:17 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ AS LINKABLE MAILTO ADDRESS=可链接的mailto邮件地址 DESCMOSEMAILCLOAK=使用JavaScript隐藏所有在内容中的E-mail,以防止垃圾邮件机器人的收集 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_geshi.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_geshi.ini index e686df69..26111eb6 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_geshi.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_geshi.ini @@ -1,11 +1,25 @@ -# version 1.5.0 2008-01-14 17:00:17 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ GESHI=GeSHi语法加亮 DESCGESHI=在内容项目中使用GeSHi(高亮显示通用语法代码)格式化过的程序代码 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_image.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_image.ini index a99daf9e..ca6d6313 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_image.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_image.ini @@ -1,10 +1,25 @@ -# version 1.5.0 2008-01-14 17:40:13 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ DESCIMAGE=使用户可以在文章中插入图片,设置图片属性,上传新的图片文件。 MARGIN=边距(Margin) diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_loadmodule.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_loadmodule.ini index 4f590932..b843ff42 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_loadmodule.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_loadmodule.ini @@ -1,10 +1,25 @@ -# version 1.5.0 2008-01-14 17:40:19 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ CODE THAT WILL WRAP MODULES=将会嵌入模块的程序代码 DESCLOADPOSITION=在内容中加载模块位置,语法: {loadposition user1} diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_pagebreak.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_pagebreak.ini index fb264f8e..14f4a580 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_pagebreak.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_pagebreak.ini @@ -1,11 +1,25 @@ -# version 1.5.0 2008-01-14 17:00:17 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ >=> <=< diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_pagenavigation.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_pagenavigation.ini index dcc5c663..5bfe2b0f 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_pagenavigation.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_pagenavigation.ini @@ -1,11 +1,25 @@ -# version 1.5.0 2008-01-14 17:00:17 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ ABOVE=上方 DESCPAGENAVIGATION=让您可以在内容中增加上页 & 下页功能。 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_vote.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_vote.ini index 512864ab..3888ed2e 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_vote.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_content_vote.ini @@ -1,10 +1,25 @@ -# version 1.5.0 2008-01-14 17:41:20 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ ADD THE VOTING FUNCTIONALITY TO ITEMS=在文章中增加投票功能 BEST=好 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_editors-xtd_image.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_editors-xtd_image.ini index 596ff82b..06a2c61e 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_editors-xtd_image.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_editors-xtd_image.ini @@ -1,10 +1,24 @@ -# version 1.5.0 2008-01-14 17:00:17 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ DESCIMAGE=显示可以往文章中插入图片的按钮,并弹出小窗口让您设置图片的属性以及上传新图片。 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_editors-xtd_pagebreak.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_editors-xtd_pagebreak.ini index 6ed46f9b..2dcabcd0 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_editors-xtd_pagebreak.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_editors-xtd_pagebreak.ini @@ -1,7 +1,24 @@ -# version 1.5.0 2008-01-14 17:00:17 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ - -DESCPAGEBREAK=提供一个允许在文章中插入分页标记的按钮——同时弹出一个小窗口让您进行设置。 +DESCPAGEBREAK=提供一个允许在文章中插入 分页标记 的按钮——同时弹出一个小窗口让您进行设置。 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_editors-xtd_readmore.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_editors-xtd_readmore.ini index ff82fc06..688a31f6 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_editors-xtd_readmore.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_editors-xtd_readmore.ini @@ -1,10 +1,24 @@ -# version 1.5.0 2008-01-14 17:00:17 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ -# Note : All ini files need to be saved as UTF-8 - - - -DESCREADMORE=允许使用在文章中插入阅读全文...链接的按钮。 +DESCREADMORE=允许使用在文章中插入 阅读全文... 链接的按钮。 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_editors_none.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_editors_none.ini index a6a03c18..f537e4a5 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_editors_none.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_editors_none.ini @@ -1,10 +1,24 @@ -# version 1.5.0 2008-01-14 17:00:17 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ THIS LOADS A BASIC TEXT ENTRY FIELD=这将载入一个简单的文字输入区域 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_editors_tinymce.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_editors_tinymce.ini index ad5df90f..7b3853fd 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_editors_tinymce.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_editors_tinymce.ini @@ -1,9 +1,25 @@ -# version 1.5.0 2008-01-14 21:33:21 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ ABILITY TO CHANGE TEXT DIRECTION=文字方向的修改功能 ABSOLUTE=绝对路径 @@ -15,9 +31,9 @@ CLEANS CODE ON EDITOR LOAD=载入编辑器时清除代码 CODE CLEANUP=清除代码 CODE CLEANUP ON SAVE=保存时进行代码清理 CODE CLEANUP ON STARTUP=启动时进行代码清理 -CODE CLEANUP UPON SAVING ARTICLE=保存文章时进行代码清理 COMPRESSED VERSION=压缩版本 CUSTOM CSS CLASSES=自定义CSS类 +CUSTOMCSSFILENOTPRESENT=The file name %s was entered in the TinyMCE Custom CSS field. This file could not be found in the default templates folder. No styles are available. DATE FORMAT=日期格式 DESCLANGCODE=编辑器的界面语言。如手动选择了语言,则必须有一个参数值 DESCLANGMODE=如设为“是”,编辑器语言将会自动地转换成所选择的界面语言。当您没有安装所对应的语言时请不要开启该功能。 @@ -46,7 +62,9 @@ NEVER=从不 NEWLINES=新行 NEWLINES WILL BE MADE INTO THE SELECTED OPTION=将依据所选择的条件创建新行 P ELEMENTS=段落元素 +PARAMBLOCKQUOTE=Insert blockquote tags around the highlighted text. PARAMCODECLEANUP=TinyMCE在默认情况下将会清除某些HTML元素中的代码,如script以及center标记,为安全起见及与XHTML兼容,建议您不要关闭这项功能。 +PARAMCODECLEANUPONSAVE=建议设置为 'Always'. Never = 在保持的时候不清除代码。Front End = 当从头到尾进行编辑的时,在保持时候清理代码。 Always = Cleanup on save when editing from front and back end. PARAMCOMPRESSEDVERSION=TinyMCE能够运行于压缩模式下以获得较快的载入速度。但是,这模式不一定总能正常工作,尤其是在IE里,因此默认情况下该模式是未启用的。当需要启用时必须谨慎。 PARAMCUSTOMCSS=您能够指定载入一份自定义的CSS文件——只要简单地输入完整的网址路径来链接到您想要载入的CSS文件。假如您在此区域输入了参数值,则将会取代正在使用的模板的CSS类中的参数值。 PARAMDIRECTIONALITY=选择是否显示RTL按钮——仅在高级模式下有效 @@ -87,6 +105,7 @@ SMILIES=表情图标 STYLE=界面风格 TABLE=表格 TEMPLATE CSS CLASSES=模板CSS类 +TEMPLATECSSFILENOTPRESENT=不能在模板或者模板系统目录中找到 'editor.css' 文件。没有可用的样式表。 TEXT DIRECTION=文字方向 TIME FORMAT=时间格式 TOOLBAR=工具栏 @@ -94,3 +113,50 @@ URL BEHAVIOUR=网址链接行为 URLS=网址 XHTMLXTRAS=XHTMLxtras模式 + +# New definitions +SKIN=皮肤 +SELECT SKIN=选择皮肤 + +ADD CUSTOM BUTTON(S)=添加一个或多个自定义按钮 +ADD CUSTOM PLUGIN(S)=添加一个或多个自定义插件 +ADVANCED IMAGE=高级图片 +ADVANCED LINK=高级链接 +ALIGNMENT OF THE TOOLBAR=对其工具栏 +ALL DIALOGS TO OPEN AS FLOATING DIV LAYERS INSTEAD OF POPUP WINDOWS. THIS OPTION CAN BE VERY USEFUL IN ORDER TO GET AROUND POPUP BLOCKERS.=所有弹出对话框将会使用平铺 DIV 层。这个选项在弹出窗口被阻止的时候非常有用。 +BLOCKQUOTE=引用文字 +COLORS=色彩 +CONTEXT MENU=正文彩带 +CUSTOM BUTTON=自定义一个按钮 +CUSTOM PLUGIN=自定义一个插件 +ENTITY ENCODING=正文编码 +EXTENDED=扩展 +FONTS=字体 +INLINE POPUPS=嵌入式弹出窗口 +INSERT NONBREAKING SPACE ENTITIES=插入不间断空格实体 +NAMED=被命名 +NONBREAKING=不间断空格 +NUMERIC=数字 +OFFICE2007 BLACK=Office 2007 黑色风格 +OFFICE2007 BLUE=Office 2007 蓝色风格 +OFFICE2007 SILVER=Office 2007 银色风格 +PARAMCOLORS=显示 / 关闭 颜色控制按钮。只可用于扩展模式。 +PARAMENTITYENCODING=控制 HTML 实体被编码。建议设置为 'raw'. 'named' = 使用命名来编码 (例如, '<'). 'numeric' = 使用数字进行编码 (例如, '%03c'). raw = 不编码 HTML 实体。注意:如果你没有设置为原生方式,搜索引擎有时候可能不能找到到内容。 +PARAMS EXTENDED MODE=扩展模式
    这些选择仅可用于只可用于扩展模式。 +PARAMFONTS==显示 / 关闭 字体控制选择。只可用于扩展模式。 +PARAMMEDIA==显示 / 关闭 媒体按钮。只可用于扩展模式。 +PARAMPASTE=显示 / 关闭 粘贴按钮。只可用于扩展模式。 +PASTE=粘贴 +POSSIBILITY TO SEE INVISIBLE CHARACTERS=可以看到不可见的字符 +RAW=行 +SAFARI COMPATIBILITY=Safari 兼容 +SEARCH-REPLACE=查找 - 替换 +TEMPLATE=模板 +TINYBROWSER=Tinybrowser +TOOLBAR ALIGN=工具栏对齐 +TURN ON/OFF A MORE ADVANCED IMAGE DIALOG=打开 / 关闭 高级图片对话框 +TURN ON/OFF A MORE ADVANCED LINK DIALOG=T打开 / 关闭 高级链接对话框 +TURN ON/OFF CONTEXT MENU=打开 / 关闭 内容菜单 +TURN ON/OFF SAFARI COMPATIBILITY PLUGIN=打开 / 关闭 Safari 兼容插件 +TURN ON/OFF TINYBROWSER FOR IMAGES/LINKS=为 Tinybrowser 打开 / 关闭 图片链接 +VISUALCHARS=Visualchars diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_editors_xstandard.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_editors_xstandard.ini index d42aa72d..525f6f7b 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_editors_xstandard.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_editors_xstandard.ini @@ -1,11 +1,25 @@ -# version 1.5.0 2008-01-14 17:00:17 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ DESCXSTANDARD=XStandard是可用于Windows应用程序或网页(IE/Mozilla/Firefox/Netscape)的内容管理系统中的,业界领先的所视即所得编辑器插件。 PARAMEDITORMODE=该参数可用于设置默认的编辑器浏览页。 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_search_categories.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_search_categories.ini index c7ed0f67..c40bc18f 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_search_categories.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_search_categories.ini @@ -1,10 +1,25 @@ -# version 1.5.0 2008-01-14 17:41:34 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ ALLOWS SEARCHING OF CATEGORIES INFORMATION=允许搜索分类的信息 CATEGORY BLOG=博客式排版的分类 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_search_contacts.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_search_contacts.ini index 6244b89e..717e3040 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_search_contacts.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_search_contacts.ini @@ -1,10 +1,25 @@ -# version 1.5.0 2008-01-14 17:41:41 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ ALLOWS SEARCHING OF CONTACTS COMPONENT=允许搜索联系人组件中的内容 NUMBER OF SEARCH ITEMS TO RETURN=获得搜索条目的数量 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_search_newsfeeds.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_search_newsfeeds.ini index ae79f18a..947ebd1f 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_search_newsfeeds.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_search_newsfeeds.ini @@ -1,12 +1,27 @@ -# version 1.5.0 2008-01-14 17:41:54 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ -# Note : All ini files need to be saved as UTF-8 - - -ALLOWS SEARCHING OF NEWSFEEDS=允许搜索新闻联播里的信息 -NEWSFEEDS=新闻联播 -NUMBER OF SEARCH ITEMS TO RETURN=获得搜索条目的数量 +ALLOWS SEARCHING OF NEWSFEEDS=允许搜索聚合新闻里的信息 +NEWSFEEDS=聚合新闻 +NUMBER OF SEARCH ITEMS TO RETURN=返回搜索条目的数量 SEARCH LIMIT=搜索限制 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_search_sections.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_search_sections.ini index f593d050..22dfa4ea 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_search_sections.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_search_sections.ini @@ -1,11 +1,25 @@ -# version 1.5.0 2008-01-14 17:42:01 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ ALLOWS SEARCHING OF CONTENT SECTION INFORMATION=允许搜索文章单元的内容 NUMBER OF SEARCH ITEMS TO RETURN=获得搜索条目的数量 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_search_weblinks.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_search_weblinks.ini index 02513507..a9e31b73 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_search_weblinks.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_search_weblinks.ini @@ -1,10 +1,25 @@ -# version 1.5.0 2008-01-14 17:42:07 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ ALLOWS SEARCHING OF WEBLINKS COMPONENT=允许搜索友情链接组件内的内容 NUMBER OF SEARCH ITEMS TO RETURN=获得搜索条目的数量 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_system_backlink.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_system_backlink.ini index 9f6a5741..91224bb9 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_system_backlink.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_system_backlink.ini @@ -1,17 +1,31 @@ -# version 1.5.0 2008-01-14 17:00:17 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ ATTEMPT LEGACY SEF=尝试Legacy SEF -IF YES, IT SEARCHES FOR OLD QUERY STRINGS THAT MIGHT MATCH AND REDIRECTS=如果选择了“是”,系统将搜索可能匹配的旧的字符串,然后重定向它。 -IF YES, IT USES OLD STYLE SEF AND ATTEMPTS TO GENERATE A VALID LINK=如果选择了“是”,系统将使用旧的SEF格式,并且将试图产生一个有效的链接。 -IF YES, IT USES OLD STYLE SEF AND DIRECTS IT TO THE NEW LINK=如果选择了“是”,系统将使用旧的SEF格式,并且将重定向这个新的链接。 -PROVIDES BACKLINK SUPPORT=反向链接( Backlink)插件支持Joomla!1.0.x 链接。它将旧样式的URL和文件链接重定向倒正确的Joomla!1.5目标对象。 +IF YES, IT SEARCHES FOR OLD QUERY STRINGS THAT MIGHT MATCH AND REDIRECTS=若选择 【是】,系统将搜索可能匹配的旧的字符串,然后重定向。 +IF YES, IT USES OLD STYLE SEF AND ATTEMPTS TO GENERATE A VALID LINK=若选择 【是】,系统将使用旧的SEF格式,并且将试图产生一个有效的链接。 +IF YES, IT USES OLD STYLE SEF AND DIRECTS IT TO THE NEW LINK=若选择 【是】,系统将使用旧的 SEF 格式,并且将重定向这个新的链接。 +PROVIDES BACKLINK SUPPORT=反向链接( Backlink)插件支持Joomla!1.0.x 链接。它将旧样式的 URL 和文件链接重定向倒正确的 Joomla!1.5 目标对象。 SEARCH QUERY STRINGS=搜索查询字符串 -SEARCH SEF=搜索SEF -"%s" HAS MOVED TO %s. CLICK THE LINK IF YOUR BROWSER DOES NOT REDIRECT YOU AUTOMATICALLY.=已将“%s”移动到%s。如果您的浏览器并不自动转换页面,请点击该链接。 +SEARCH SEF=搜索引擎 URL 静态化 (SEF) +"%s" HAS MOVED TO %s. CLICK THE LINK IF YOUR BROWSER DOES NOT REDIRECT YOU AUTOMATICALLY.=已将“%s”移动到%s。如果您的浏览器没有将页面重定向,请点击该链接。 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_system_cache.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_system_cache.ini index 91055eb2..c175bf36 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_system_cache.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_system_cache.ini @@ -1,14 +1,28 @@ -# version 1.5.0 2008-01-14 17:00:17 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ PAGE CACHE LIFETIME IN MINUTES=网页缓存的周期(单位:秒) CACHE LIFETIME=缓存的周期 -IF YES, USE MECHANISM FOR STORING PAGE CACHE IN THE BROWSER=如有的话,在浏览器中使用网页缓存机制 +IF YES, USE MECHANISM FOR STORING PAGE CACHE IN THE BROWSER=如果支持,则在浏览器中使用网页缓存机制 PROVIDES PAGE CACHING=提供页面缓存 USE BROWSER CACHING=使用浏览器缓存 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_system_debug.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_system_debug.ini index 8e88f090..d238c9c2 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_system_debug.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_system_debug.ini @@ -1,27 +1,44 @@ -# version 1.5.0 2008-01-14 22:47:35 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL -# Note : All ini files need to be saved as UTF-8 +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ ALL MODES=所有模式 DESIGNER MODE=设计者模式 DIAGNOSTIC MODE=诊断模式 DISPLAY LOADED LANGUAGE FILES=显示已加载的语言文件 DISPLAYS ORPHANED STRINGS IN DIFFERENT WAYS=以不同方式显示未翻译词条 -IF YES, DISPLAY A LIST OF THE LANGUAGE FILES LOADED=若选择“是”,则显示已加载的语言文件列表 +IF YES, DISPLAY A LIST OF THE LANGUAGE FILES LOADED=若选择 【是】,则显示已加载的语言文件列表 STRING FORMAT=字串格式 STRIP STRING PREFIX=去除字串前缀 STRIP STRING PREFIX DESC=在显示给设计者之前从字串中删除此前缀 DISPLAY PROFILING INFORMATION=显示性能跟踪信息 -IF YES, DISPLAY PROFILING INFORMATION=若选择是,则显示性能跟踪信息 +IF YES, DISPLAY PROFILING INFORMATION=若选择 【是】,则显示性能跟踪信息 DISPLAY SQL QUERY LOG=显示SQL查询日志 DISPLAY MEMORY USAGE=显示内存使用情况 DISPLAY UNDEFINED LANGUAGE STRINGS=显示未定义的语言字符串 -IF YES, DISPLAY SQL QUERY LOG=如设为“是”,则显示SQL查询日志 -IF YES, DISPLAY MEMORY USAGE=如设为“是”,则显示内存用量 -IF YES, DISPLAY UNDEFINED LANGUAGE STRINGS=如设为“是”,则显示未定义的语言字符串 +IF YES, DISPLAY SQL QUERY LOG=若选择 【是】,则显示SQL查询日志 +IF YES, DISPLAY MEMORY USAGE=若选择 【是】,则显示内存用量 +IF YES, DISPLAY UNDEFINED LANGUAGE STRINGS=若选择 【是】,则显示未定义的语言字符串 LANGUAGE FILES LOADED=已加载的语言文件 MEMORY USAGE=内存使用情况 PROFILE INFORMATION=配置信息 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_system_legacy.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_system_legacy.ini index 8751b0c0..9ffedb11 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_system_legacy.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_system_legacy.ini @@ -1,12 +1,26 @@ -# version 1.5.0 2008-01-14 17:00:17 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ USE LEGACY URL ROUTING=使用原有的URL路由 -IF YES, USE LEGACY URL ROUTING MECHANISM=如设为“是”,则使用原有的URL路由机制。 -PROVIDES LEGACY SUPPORT FOR OLDER VERSION OF JOOMLA!=提供对老版本的Joomla!的支持 +IF YES, USE LEGACY URL ROUTING MECHANISM=如设为 【是】,则使用原有的URL路由机制。 +PROVIDES LEGACY SUPPORT FOR OLDER VERSION OF JOOMLA!=为老版本的 Joomla 提供支持支持。 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_system_sef.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_system_sef.ini index 2f33c5b0..9bc6fb1c 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_system_sef.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_system_sef.ini @@ -1,9 +1,24 @@ -# $Id: zh-CN.plg_system_sef.ini 113 2008-04-24 06:08:22Z protege $ -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ -# Note : All ini files need to be saved as UTF-8 - - -DESCPLGSYSTEMSEF=为该文档的链接增加SEF支持。它将直接在HTML代码中运作,不需要特殊标记。 +DESCPLGSYSTEMSEF=为该文档的链接增加【搜索引擎 URL 静态化 (SEF)】支持。它将直接在HTML代码中运作,不需要特殊标记。 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_user_joomla.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_user_joomla.ini index 3f16feb9..ca9f7d3a 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_user_joomla.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_user_joomla.ini @@ -1,12 +1,26 @@ -# version 1.5.0 2008-01-14 17:00:17 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 - - +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ AUTO CREATE USERS=自动创建用户 -PARAMAUTOCREATEUSERS=可能时自动创建注册会员 -PLG_USER_JOOMLA=处理Joomla!默认的用户同步机制 +PARAMAUTOCREATEUSERS=可能时自动为新用户注册为会员 +PLG_USER_JOOMLA=处理 Joomla 默认的用户同步机制 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_xmlrpc_blogger.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_xmlrpc_blogger.ini index 86776e45..de78bc31 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_xmlrpc_blogger.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_xmlrpc_blogger.ini @@ -1,27 +1,43 @@ -# version 1.5.0 2008-01-14 17:00:17 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - -# Note : All ini files need to be saved as UTF-8 +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ BLOGGER XML-RPC API=Blogger XML-RPC接口 -EDIT POSTS=编辑帖子 -NEW POSTS=新建帖子 +EDIT POSTS=编辑已发布的文章 +NEW POSTS=新建一篇文章 PARAMCATEGORY=设置放置新文章的分类至 PARAMSECTION=设置取回文章的单元来自 -LOGIN FAILED=The Login Failed -POST CHECK FAILED=Post Check Failed -POST STORE FAILED=Post Store Failed -POST DELETE FAILED=Post delete failed -SORRY, NO SUCH POST=Sorry, no such post -SORRY, POST IS ALREADY BEING EDITED=Sorry, post is already being edited -NO POSTS AVAILABLE, OR AN ERROR HAS OCCURRED=No posts available, or an error has occurred. -METHOD NOT IMPLEMENTED=Method not implemented -RETURNS A LIST OF WEBLOGS TO WHICH AN AUTHOR HAS POSTING PRIVILEGES.=Returns a list of weblogs to which an author has posting privileges. -RETURNS INFORMATION ABOUT AN AUTHOR IN THE SYSTEM.=Returns information about an author in the system. -RETURNS INFORMATION ABOUT A SPECIFIC POST.=Returns information about a specific post. -RETURNS A LIST OF THE MOST RECENT POSTS IN THE SYSTEM.=Returns a list of the most recent posts in the system. -CREATES A NEW POST, AND OPTIONALLY PUBLISHES IT.=Creates a new post, and optionally publishes it. -DELETES A POST.=Deletes a post. -UPDATES THE INFORMATION ABOUT AN EXISTING POST.=Updates the information about an existing post. +LOGIN FAILED=登录失败 +POST CHECK FAILED=文章校验失败 +POST STORE FAILED=文章存储失败 +POST DELETE FAILED=文章删除失败 +SORRY, NO SUCH POST=对不起,没有找到指定的文章 +SORRY, POST IS ALREADY BEING EDITED=对不起, 文章已经被编辑过了。 +NO POSTS AVAILABLE, OR AN ERROR HAS OCCURRED=没有可用的文章 , 或者有错误发生。 +METHOD NOT IMPLEMENTED=方法不能被实例化。 +RETURNS A LIST OF WEBLOGS TO WHICH AN AUTHOR HAS POSTING PRIVILEGES.=返回博客列表,同时返回作者所具有的权限。 +RETURNS INFORMATION ABOUT AN AUTHOR IN THE SYSTEM.=返回系统中指定作者的信息。 +RETURNS INFORMATION ABOUT A SPECIFIC POST.=返回指定文章的信息。 +RETURNS A LIST OF THE MOST RECENT POSTS IN THE SYSTEM.=返回系统中最新创建的文章列表。 +CREATES A NEW POST, AND OPTIONALLY PUBLISHES IT.=创建一条新的文章,并且选择发布。 +DELETES A POST.=删除一篇文章。 +UPDATES THE INFORMATION ABOUT AN EXISTING POST.=更新已经存在文章的信息。 diff --git a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_xmlrpc_joomla.ini b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_xmlrpc_joomla.ini index d9607837..85197ce9 100644 --- a/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_xmlrpc_joomla.ini +++ b/oss/joomla/trunk/administrator/language/zh-CN/zh-CN.plg_xmlrpc_joomla.ini @@ -1,10 +1,24 @@ -# version 1.5.0 2008-01-14 17:00:17 ~0 -# author Joomla! Chinese Translation Team -# copyright (C) 2005 Open Source Matters. All rights reserved. -# license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL +#/** +# * Copyright (C) 2006-2010 YUCHENG HU +# * +# * --------------------------------------------- +# * HA WEBSYSTEMS +# * http://www.hawebs.net +# * https://www.hawebs.org/forums/computer/ +# * +# * CONTACT +# * huyuchengus@gmail.com / yuchenghu@hawebs.net +# * +# * --------------------------------------------- +# * GNU GENERAL PUBLIC LICENSE GNU/LGPL +# * http://www.gnu.org/licenses/lgpl.html +# * +# * --------------------------------------------- +# * NOTE +# * 1. 所有的 ini 文件必须采用 UTF-8 编码 +# * 2. 请不要在语言配置文件中使用单引号或双引号 (' 或 ") +# * +# * --------------------------------------------- +# */ -# Note : All ini files need to be saved as UTF-8 - - - -JOOMLA! XML-RPC API=Joomla! XML-RPC API +JOOMLA! XML-RPC API=Joomla! XML-RPC API 模块 diff --git a/oss/joomla/trunk/administrator/modules/index.html b/oss/joomla/trunk/administrator/modules/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/modules/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/modules/mod_custom/index.html b/oss/joomla/trunk/administrator/modules/mod_custom/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/modules/mod_custom/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/modules/mod_custom/mod_custom.xml b/oss/joomla/trunk/administrator/modules/mod_custom/mod_custom.xml new file mode 100644 index 00000000..5ef33924 --- /dev/null +++ b/oss/joomla/trunk/administrator/modules/mod_custom/mod_custom.xml @@ -0,0 +1,15 @@ + + + Custom HTML + Joomla! Project + July 2004 + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + DESCMODCUSTOM + + + + diff --git a/oss/joomla/trunk/administrator/modules/mod_feed/helper.php b/oss/joomla/trunk/administrator/modules/mod_feed/helper.php new file mode 100644 index 00000000..76084bac --- /dev/null +++ b/oss/joomla/trunk/administrator/modules/mod_feed/helper.php @@ -0,0 +1,168 @@ +get('rssurl', ''); + $rssitems = $params->get('rssitems', 5); + $rssdesc = $params->get('rssdesc', 1); + $rssimage = $params->get('rssimage', 1); + $rssitemdesc = $params->get('rssitemdesc', 1); + $words = $params->def('word_count', 0); + $rsstitle = $params->get('rsstitle', 1); + $rssrtl = $params->get('rssrtl', 0); + $moduleclass_sfx = $params->get('moduleclass_sfx', ''); + + // get RSS parsed object + $options = array(); + $options['rssUrl'] = $rssurl; + if ($params->get('cache')) { + $options['cache_time'] = $params->get('cache_time', 15) ; + $options['cache_time'] *= 60; + } else { + $options['cache_time'] = null; + } + + $rssDoc =& JFactory::getXMLparser('RSS', $options); + + if ($rssDoc != false) + { + // channel header and link + $channel['title'] = $rssDoc->get_title(); + $channel['link'] = $rssDoc->get_link(); + $channel['description'] = $rssDoc->get_description(); + + // channel image if exists + $image['url'] = $rssDoc->get_image_url(); + $image['title'] = $rssDoc->get_image_title(); + + //image handling + $iUrl = isset($image['url']) ? $image['url'] : null; + $iTitle = isset($image['title']) ? $image['title'] : null; + + // items + $items = $rssDoc->get_items(); + + // feed elements + $items = array_slice($items, 0, $rssitems); + ?> + + + + + + + + + + + + + + $actualItems) { + $totalItems = $actualItems; + } else { + $totalItems = $setItems; + } + ?> + + + +
    + + + + +
    + +
    + <?php echo @$iTitle; ?> +
    +
      + +
    • + get_link() ) ) { + ?> + + get_title(); ?> + get_description()); + $text = str_replace(''', "'", $text); + + // word limit check + if ($words) { + $texts = explode(' ', $text); + $count = count($texts); + if ($count > $words) { + $text = ''; + for ($i = 0; $i < $words; $i ++) + { + $text .= ' '.$texts[$i]; + } + $text .= '...'; + } + } + ?> +
      + +
      + +
    • + +
    +
    + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/modules/mod_feed/mod_feed.php b/oss/joomla/trunk/administrator/modules/mod_feed/mod_feed.php new file mode 100644 index 00000000..f99879c7 --- /dev/null +++ b/oss/joomla/trunk/administrator/modules/mod_feed/mod_feed.php @@ -0,0 +1,42 @@ +get('rssurl', ''); +$rssrtl = $params->get('rssrtl', 0); + +//check if cache diretory is writable as cache files will be created for the feed +$cacheDir = JPATH_BASE.DS.'cache'; +if (!is_writable($cacheDir)) +{ + echo '
    '; + echo JText::_('Please make cache directory writable.'); + echo '
    '; + return; +} + +//check if feed URL has been set +if (empty ($rssurl)) +{ + echo '
    '; + echo JText::_('No feed URL specified.'); + echo '
    '; + return; +} + +require(JModuleHelper::getLayoutPath('mod_feed')); diff --git a/oss/joomla/trunk/administrator/modules/mod_feed/mod_feed.xml b/oss/joomla/trunk/administrator/modules/mod_feed/mod_feed.xml new file mode 100644 index 00000000..657e2f09 --- /dev/null +++ b/oss/joomla/trunk/administrator/modules/mod_feed/mod_feed.xml @@ -0,0 +1,48 @@ + + + Feed Display + Joomla! Project + July 2005 + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.5.0 + This module allows the displaying of a syndicated feed + + mod_feed.php + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/oss/joomla/trunk/administrator/modules/mod_feed/tmpl/default.php b/oss/joomla/trunk/administrator/modules/mod_feed/tmpl/default.php new file mode 100644 index 00000000..1eb5f041 --- /dev/null +++ b/oss/joomla/trunk/administrator/modules/mod_feed/tmpl/default.php @@ -0,0 +1,5 @@ + +
    + +
    diff --git a/oss/joomla/trunk/administrator/modules/mod_feed/tmpl/index.html b/oss/joomla/trunk/administrator/modules/mod_feed/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/modules/mod_feed/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/modules/mod_footer/index.html b/oss/joomla/trunk/administrator/modules/mod_footer/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/modules/mod_footer/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/modules/mod_footer/mod_footer.php b/oss/joomla/trunk/administrator/modules/mod_footer/mod_footer.php new file mode 100644 index 00000000..1f40a2b3 --- /dev/null +++ b/oss/joomla/trunk/administrator/modules/mod_footer/mod_footer.php @@ -0,0 +1,30 @@ + +
    + URL; ?> +
    + +
    + getLongVersion(); ?> +
    + +
    + +
    \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/modules/mod_footer/mod_footer.xml b/oss/joomla/trunk/administrator/modules/mod_footer/mod_footer.xml new file mode 100644 index 00000000..946c3352 --- /dev/null +++ b/oss/joomla/trunk/administrator/modules/mod_footer/mod_footer.xml @@ -0,0 +1,21 @@ + + + Footer + Joomla! Project + Nov 2005 + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.0.0 + This module shows the Joomla! Copyright information + + mod_footer.php + + + + + + + + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/modules/mod_latest/index.html b/oss/joomla/trunk/administrator/modules/mod_latest/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/modules/mod_latest/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/modules/mod_latest/mod_latest.php b/oss/joomla/trunk/administrator/modules/mod_latest/mod_latest.php new file mode 100644 index 00000000..f90df109 --- /dev/null +++ b/oss/joomla/trunk/administrator/modules/mod_latest/mod_latest.php @@ -0,0 +1,127 @@ +get('id'); + +$where = 'WHERE a.state <> -2'; + +// User Filter +switch ($params->get( 'user_id' )) +{ + case 'by_me': + $where .= ' AND (created_by = ' . (int) $userId . ' OR modified_by = ' . (int) $userId . ')'; + break; + case 'not_me': + $where .= ' AND (created_by <> ' . (int) $userId . ' AND modified_by <> ' . (int) $userId . ')'; + break; +} + +// Ordering +switch ($params->get( 'ordering' )) +{ + case 'm_dsc': + $ordering = 'modified DESC, created DESC'; + $dateProperty = 'modified'; + break; + case 'c_dsc': + default: + $ordering = 'created DESC'; + $dateProperty = 'created'; + break; +} + +$query = 'SELECT a.id, a.sectionid, a.title, a.created, a.modified, u.name, a.created_by_alias, a.created_by' +. ' FROM #__content AS a' +. ' LEFT JOIN #__users AS u ON u.id = a.created_by' +. ' '. $where +. ' ORDER BY '. $ordering +; +$db->setQuery( $query, 0, 10 ); +$rows = $db->loadObjectList(); +?> + + + + + + + +id; + + if ( $user->authorize( 'administration', 'manage', 'components', 'com_users' ) ) { + if ( $row->created_by_alias ) + { + $author = $row->created_by_alias; + } + else + { + $linkA = 'index.php?option=com_users&task=edit&cid[]='. $row->created_by; + $author = ''. htmlspecialchars( $row->name, ENT_QUOTES, 'UTF-8' ) .''; + } + } + else + { + if ( $row->created_by_alias ) + { + $author = $row->created_by_alias; + } + else + { + $author = htmlspecialchars( $row->name, ENT_QUOTES, 'UTF-8' ); + } + } + ?> + + + + + + + + + + +
    + + + + + +
    + + title, ENT_QUOTES, 'UTF-8');?> + + $dateProperty, '%Y-%m-%d %H:%M:%S'); ?> + + +
    + +
    diff --git a/oss/joomla/trunk/administrator/modules/mod_latest/mod_latest.xml b/oss/joomla/trunk/administrator/modules/mod_latest/mod_latest.xml new file mode 100644 index 00000000..e7e88fc8 --- /dev/null +++ b/oss/joomla/trunk/administrator/modules/mod_latest/mod_latest.xml @@ -0,0 +1,29 @@ + + + Latest News + Joomla! Project + July 2004 + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.0.0 + DESCLATESTNEWS + + mod_latest.php + + + + + + + + + + + + + + + + diff --git a/oss/joomla/trunk/administrator/modules/mod_logged/index.html b/oss/joomla/trunk/administrator/modules/mod_logged/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/modules/mod_logged/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/modules/mod_logged/mod_logged.php b/oss/joomla/trunk/administrator/modules/mod_logged/mod_logged.php new file mode 100644 index 00000000..68d41726 --- /dev/null +++ b/oss/joomla/trunk/administrator/modules/mod_logged/mod_logged.php @@ -0,0 +1,60 @@ +getUserStateFromRequest('limit', 'limit', $mainframe->getCfg('list_limit'), 'int'); +$limitstart = $mainframe->getUserStateFromRequest('mod_logged.limitstart', 'limitstart', 0, 'int'); + +// hides Administrator or Super Administrator from list depending on usertype +$and = ''; +// administrator check +if ( $user->get('gid') == 24 ) { + $and = ' AND gid != "25"'; +} +// manager check +if ( $user->get('gid') == 23 ) { + $and = ' AND gid != "25"'; + $and .= ' AND gid != "24"'; +} + +// get the total number of records +$query = 'SELECT COUNT(*)' + . ' FROM #__session' + . ' WHERE userid != 0' + . $and + . ' ORDER BY usertype, username' + ; +$db->setQuery( $query ); +$total = $db->loadResult(); + +// page navigation +$pageNav = new JPagination( $total, $limitstart, $limit ); + +$query = 'SELECT username, time, userid, usertype, client_id' +. ' FROM #__session' +. ' WHERE userid != 0' +. $and +. ' ORDER BY usertype, username' +; +$db->setQuery( $query ); +$rows = $db->loadObjectList(); + +require( dirname( __FILE__ ).DS.'tmpl'.DS.'default.php' ); diff --git a/oss/joomla/trunk/administrator/modules/mod_logged/mod_logged.xml b/oss/joomla/trunk/administrator/modules/mod_logged/mod_logged.xml new file mode 100644 index 00000000..7c03ac79 --- /dev/null +++ b/oss/joomla/trunk/administrator/modules/mod_logged/mod_logged.xml @@ -0,0 +1,21 @@ + + + Logged in Users + Joomla! Project + January 2005 + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.0.0 + This module shows a list of the currently logged in users + + mod_logged.php + + + + + + + + diff --git a/oss/joomla/trunk/administrator/modules/mod_logged/tmpl/default.php b/oss/joomla/trunk/administrator/modules/mod_logged/tmpl/default.php new file mode 100644 index 00000000..4c5b9f21 --- /dev/null +++ b/oss/joomla/trunk/administrator/modules/mod_logged/tmpl/default.php @@ -0,0 +1,77 @@ + + +
    + + + + + + + + + + + + + authorize( 'com_users', 'manage' ); + if ($auth) : + $link = 'index.php?option=com_users&task=edit&cid[]='. $row->userid; + $name = ''. $row->username .''; + else : + $name = $row->username; + endif; + + $clientInfo =& JApplicationHelper::getClientInfo($row->client_id); + ?> + + + + + + + + + + +
    + + + + + + + + + + + +
    + getRowOffset( $i ); ?> + + + + usertype;?> + + name;?> + + time)/3600.0 );?> + + get('gid') > 24 && $row->userid != $user->get('id')) : ?> + + +
    + + + + +
    diff --git a/oss/joomla/trunk/administrator/modules/mod_logged/tmpl/index.html b/oss/joomla/trunk/administrator/modules/mod_logged/tmpl/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/modules/mod_logged/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/modules/mod_login/index.html b/oss/joomla/trunk/administrator/modules/mod_login/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/modules/mod_login/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/modules/mod_login/mod_login.php b/oss/joomla/trunk/administrator/modules/mod_login/mod_login.php new file mode 100644 index 00000000..2834107a --- /dev/null +++ b/oss/joomla/trunk/administrator/modules/mod_login/mod_login.php @@ -0,0 +1,74 @@ + +load( 'plg_authentication_openid', JPATH_ADMINISTRATOR ); + $langScript = 'var JLanguage = {};'. + ' JLanguage.WHAT_IS_OPENID = \''.JText::_( 'WHAT_IS_OPENID' ).'\';'. + ' JLanguage.LOGIN_WITH_OPENID = \''.JText::_( 'LOGIN_WITH_OPENID' ).'\';'. + ' JLanguage.NORMAL_LOGIN = \''.JText::_( 'NORMAL_LOGIN' ).'\';'. + ' var modlogin = 1;'; + $document = &JFactory::getDocument(); + $document->addScriptDeclaration( $langScript ); + JHTML::_('script', 'openid.js'); +endif; ?> +
    +

    + + +

    + +

    + + +

    + '; + echo $error->get('message'); + echo '

    '; + } + ?> +

    + + +

    +
    +
    + +
    +
    +
    + + + + +
    diff --git a/oss/joomla/trunk/administrator/modules/mod_login/mod_login.xml b/oss/joomla/trunk/administrator/modules/mod_login/mod_login.xml new file mode 100644 index 00000000..048ab7ae --- /dev/null +++ b/oss/joomla/trunk/administrator/modules/mod_login/mod_login.xml @@ -0,0 +1,24 @@ + + + Login Form + Joomla! Project + March 2005 + Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + admin@joomla.org + www.joomla.org + 1.0.0 + DESCLOGINFORM + + mod_login.php + + + + + + + + + + + diff --git a/oss/joomla/trunk/administrator/modules/mod_menu/helper.php b/oss/joomla/trunk/administrator/modules/mod_menu/helper.php new file mode 100644 index 00000000..391b330a --- /dev/null +++ b/oss/joomla/trunk/administrator/modules/mod_menu/helper.php @@ -0,0 +1,304 @@ +get('usertype'); + + // cache some acl checks + $canCheckin = $user->authorize('com_checkin', 'manage'); + $canConfig = $user->authorize('com_config', 'manage'); + $manageTemplates = $user->authorize('com_templates', 'manage'); + $manageTrash = $user->authorize('com_trash', 'manage'); + $manageMenuMan = $user->authorize('com_menus', 'manage'); + $manageLanguages = $user->authorize('com_languages', 'manage'); + $installModules = $user->authorize('com_installer', 'module'); + $editAllModules = $user->authorize('com_modules', 'manage'); + $installPlugins = $user->authorize('com_installer', 'plugin'); + $editAllPlugins = $user->authorize('com_plugins', 'manage'); + $installComponents = $user->authorize('com_installer', 'component'); + $editAllComponents = $user->authorize('com_components', 'manage'); + $canMassMail = $user->authorize('com_massmail', 'manage'); + $canManageUsers = $user->authorize('com_users', 'manage'); + + // Menu Types + require_once( JPATH_ADMINISTRATOR.DS.'components'.DS.'com_menus'.DS.'helpers'.DS.'helper.php' ); + $menuTypes = MenusHelper::getMenuTypelist(); + + /* + * Get the menu object + */ + $menu = new JAdminCSSMenu(); + + /* + * Site SubMenu + */ + $menu->addChild(new JMenuNode(JText::_('Site')), true); + $menu->addChild(new JMenuNode(JText::_('Control Panel'), 'index.php', 'class:cpanel')); + $menu->addSeparator(); + if ($canManageUsers) { + $menu->addChild(new JMenuNode(JText::_('User Manager'), 'index.php?option=com_users&task=view', 'class:user')); + } + $menu->addChild(new JMenuNode(JText::_('Media Manager'), 'index.php?option=com_media', 'class:media')); + $menu->addSeparator(); + if ($canConfig) { + $menu->addChild(new JMenuNode(JText::_('Configuration'), 'index.php?option=com_config', 'class:config')); + $menu->addSeparator(); + } + $menu->addChild(new JMenuNode(JText::_('Logout'), 'index.php?option=com_login&task=logout', 'class:logout')); + + $menu->getParent(); + + /* + * Menus SubMenu + */ + $menu->addChild(new JMenuNode(JText::_('Menus')), true); + if ($manageMenuMan) { + $menu->addChild(new JMenuNode(JText::_('Menu Manager'), 'index.php?option=com_menus', 'class:menu')); + } + if ($manageTrash) { + $menu->addChild(new JMenuNode(JText::_('Menu Trash'), 'index.php?option=com_trash&task=viewMenu', 'class:trash')); + } + + if($manageTrash || $manageMenuMan) { + $menu->addSeparator(); + } + /* + * SPLIT HR + */ + if (count($menuTypes)) { + foreach ($menuTypes as $menuType) { + $menu->addChild(new JMenuNode($menuType->title.($menuType->home ? ' *' : ''), 'index.php?option=com_menus&task=view&menutype='.$menuType->menutype, 'class:menu')); + } + } + + $menu->getParent(); + + /* + * Content SubMenu + */ + $menu->addChild(new JMenuNode(JText::_('Content')), true); + $menu->addChild(new JMenuNode(JText::_('Article Manager'), 'index.php?option=com_content', 'class:article')); + if ($manageTrash) { + $menu->addChild(new JMenuNode(JText::_('Article Trash'), 'index.php?option=com_trash&task=viewContent', 'class:trash')); + } + $menu->addSeparator(); + $menu->addChild(new JMenuNode(JText::_('Section Manager'), 'index.php?option=com_sections&scope=content', 'class:section')); + $menu->addChild(new JMenuNode(JText::_('Category Manager'), 'index.php?option=com_categories§ion=com_content', 'class:category')); + $menu->addSeparator(); + $menu->addChild(new JMenuNode(JText::_('Frontpage Manager'), 'index.php?option=com_frontpage', 'class:frontpage')); + + $menu->getParent(); + + /* + * Components SubMenu + */ + if ($editAllComponents) + { + $menu->addChild(new JMenuNode(JText::_('Components')), true); + + $query = 'SELECT *' . + ' FROM #__components' . + ' WHERE '.$db->NameQuote( 'option' ).' <> "com_frontpage"' . + ' AND '.$db->NameQuote( 'option' ).' <> "com_media"' . + ' AND enabled = 1' . + ' ORDER BY ordering, name'; + $db->setQuery($query); + $comps = $db->loadObjectList(); // component list + $subs = array(); // sub menus + $langs = array(); // additional language files to load + + // first pass to collect sub-menu items + foreach ($comps as $row) + { + if ($row->parent) + { + if (!array_key_exists($row->parent, $subs)) { + $subs[$row->parent] = array (); + } + $subs[$row->parent][] = $row; + $langs[$row->option.'.menu'] = true; + } elseif (trim($row->admin_menu_link)) { + $langs[$row->option.'.menu'] = true; + } + } + + // Load additional language files + if (array_key_exists('.menu', $langs)) { + unset($langs['.menu']); + } + foreach ($langs as $lang_name => $nothing) { + $lang->load($lang_name); + } + + foreach ($comps as $row) + { + if ($editAllComponents | $user->authorize('administration', 'edit', 'components', $row->option)) + { + if ($row->parent == 0 && (trim($row->admin_menu_link) || array_key_exists($row->id, $subs))) + { + $text = $lang->hasKey($row->option) ? JText::_($row->option) : $row->name; + $link = $row->admin_menu_link ? "index.php?$row->admin_menu_link" : "index.php?option=$row->option"; + if (array_key_exists($row->id, $subs)) { + $menu->addChild(new JMenuNode($text, $link, $row->admin_menu_img), true); + foreach ($subs[$row->id] as $sub) { + $key = $row->option.'.'.$sub->name; + $text = $lang->hasKey($key) ? JText::_($key) : $sub->name; + $link = $sub->admin_menu_link ? "index.php?$sub->admin_menu_link" : null; + $menu->addChild(new JMenuNode($text, $link, $sub->admin_menu_img)); + } + $menu->getParent(); + } else { + $menu->addChild(new JMenuNode($text, $link, $row->admin_menu_img)); + } + } + } + } + $menu->getParent(); + } + + /* + * Extensions SubMenu + */ + if ($installModules) + { + $menu->addChild(new JMenuNode(JText::_('Extensions')), true); + + $menu->addChild(new JMenuNode(JText::_('Install/Uninstall'), 'index.php?option=com_installer', 'class:install')); + $menu->addSeparator(); + if ($editAllModules) { + $menu->addChild(new JMenuNode(JText::_('Module Manager'), 'index.php?option=com_modules', 'class:module')); + } + if ($editAllPlugins) { + $menu->addChild(new JMenuNode(JText::_('Plugin Manager'), 'index.php?option=com_plugins', 'class:plugin')); + } + if ($manageTemplates) { + $menu->addChild(new JMenuNode(JText::_('Template Manager'), 'index.php?option=com_templates', 'class:themes')); + } + if ($manageLanguages) { + $menu->addChild(new JMenuNode(JText::_('Language Manager'), 'index.php?option=com_languages', 'class:language')); + } + $menu->getParent(); + } + + /* + * System SubMenu + */ + if ($canConfig || $canCheckin) + { + $menu->addChild(new JMenuNode(JText::_('Tools')), true); + + if ($canConfig) { + $menu->addChild(new JMenuNode(JText::_('Read Messages'), 'index.php?option=com_messages', 'class:messages')); + $menu->addChild(new JMenuNode(JText::_('Write Message'), 'index.php?option=com_messages&task=add', 'class:messages')); + $menu->addSeparator(); + } + if ($canMassMail) { + $menu->addChild(new JMenuNode(JText::_('Mass Mail'), 'index.php?option=com_massmail', 'class:massmail')); + $menu->addSeparator(); + } + if ($canCheckin) { + $menu->addChild(new JMenuNode(JText::_('Global Checkin'), 'index.php?option=com_checkin', 'class:checkin')); + $menu->addSeparator(); + } + $menu->addChild(new JMenuNode(JText::_('Clean Cache'), 'index.php?option=com_cache', 'class:config')); + $menu->addChild(new JMenuNode(JText::_('Purge Expired Cache'), 'index.php?option=com_cache&task=purgeadmin', 'class:config')); + + $menu->getParent(); + } + + /* + * Help SubMenu + */ + $menu->addChild(new JMenuNode(JText::_('Help')), true); + $menu->addChild(new JMenuNode(JText::_('Joomla! Help'), 'index.php?option=com_admin&task=help', 'class:help')); + $menu->addChild(new JMenuNode(JText::_('System Info'), 'index.php?option=com_admin&task=sysinfo', 'class:info')); + + $menu->getParent(); + + $menu->renderMenu('menu', ''); + } + + /** + * Show an disbaled version of the menu, used in edit pages + * + * @param string The current user type + */ + function buildDisabledMenu() + { + $lang =& JFactory::getLanguage(); + $user =& JFactory::getUser(); + $usertype = $user->get('usertype'); + + $canConfig = $user->authorize('com_config', 'manage'); + $installModules = $user->authorize('com_installer', 'module'); + $editAllModules = $user->authorize('com_modules', 'manage'); + $installPlugins = $user->authorize('com_installer', 'plugin'); + $editAllPlugins = $user->authorize('com_plugins', 'manage'); + $installComponents = $user->authorize('com_installer', 'component'); + $editAllComponents = $user->authorize('com_components', 'manage'); + $canMassMail = $user->authorize('com_massmail', 'manage'); + $canManageUsers = $user->authorize('com_users', 'manage'); + + $text = JText::_('Menu inactive for this Page', true); + + // Get the menu object + $menu = new JAdminCSSMenu(); + + // Site SubMenu + $menu->addChild(new JMenuNode(JText::_('Site'), null, 'disabled')); + + // Menus SubMenu + $menu->addChild(new JMenuNode(JText::_('Menus'), null, 'disabled')); + + // Content SubMenu + $menu->addChild(new JMenuNode(JText::_('Content'), null, 'disabled')); + + // Components SubMenu + if ($installComponents) { + $menu->addChild(new JMenuNode(JText::_('Components'), null, 'disabled')); + } + + // Extensions SubMenu + if ($installModules) { + $menu->addChild(new JMenuNode(JText::_('Extensions'), null, 'disabled')); + } + + // System SubMenu + if ($canConfig) { + $menu->addChild(new JMenuNode(JText::_('Tools'), null, 'disabled')); + } + + // Help SubMenu + $menu->addChild(new JMenuNode(JText::_('Help'), null, 'disabled')); + + $menu->renderMenu('menu', 'disabled'); + } +} +?> diff --git a/oss/joomla/trunk/administrator/modules/mod_menu/index.html b/oss/joomla/trunk/administrator/modules/mod_menu/index.html new file mode 100644 index 00000000..fa6d84e8 --- /dev/null +++ b/oss/joomla/trunk/administrator/modules/mod_menu/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/oss/joomla/trunk/administrator/modules/mod_menu/menu.php b/oss/joomla/trunk/administrator/modules/mod_menu/menu.php new file mode 100644 index 00000000..e2ab278b --- /dev/null +++ b/oss/joomla/trunk/administrator/modules/mod_menu/menu.php @@ -0,0 +1,222 @@ +_root = new JMenuNode('ROOT'); + $this->_current = & $this->_root; + } + + function addSeparator() + { + $this->addChild(new JMenuNode(null, null, 'separator', false)); + } + + function renderMenu($id = 'menu', $class = '') + { + global $mainframe; + + $depth = 1; + + if(!empty($id)) { + $id='id="'.$id.'"'; + } + + if(!empty($class)) { + $class='class="'.$class.'"'; + } + + /* + * Recurse through children if they exist + */ + while ($this->_current->hasChildren()) + { + echo "
      \n"; + foreach ($this->_current->getChildren() as $child) + { + $this->_current = & $child; + $this->renderLevel($depth++); + } + echo "
    \n"; + } + + if ($this->_css) { + // Add style to document head + $doc = & JFactory::getDocument(); + $doc->addStyleDeclaration($this->_css); + } + } + + function renderLevel($depth) + { + /* + * Build the CSS class suffix + */ + $class = ''; + if ($this->_current->hasChildren()) { + $class = ' class="node"'; + } + + if($this->_current->class == 'separator') { + $class = ' class="separator"'; + } + + if($this->_current->class == 'disabled') { + $class = ' class="disabled"'; + } + + + /* + * Print the item + */ + echo ""; + + /* + * Print a link if it exists + */ + if ($this->_current->link != null) { + echo "getIconClass($this->_current->class)."\" href=\"".$this->_current->link."\">".$this->_current->title.""; + } elseif ($this->_current->title != null) { + echo "".$this->_current->title."\n"; + } else { + echo ""; + } + + /* + * Recurse through children if they exist + */ + while ($this->_current->hasChildren()) + { + if ($this->_current->class) { + echo ' - * - * Example: - * - * :simple.xml: - * - * - * - * Tom Foo - * Tamara Bar - * - * - * - * --- - * - * // read and write a document - * $xml = new JSimpleXML; - * $xml->loadFile('simple.xml'); - * print $xml->document->toString(); - * - * // access a given node's CDATA - * print $xml->root->node->child[0]->data(); // Tom Foo - * - * // access attributes - * $attr = $xml->root->node->child[1]->attributes(); - * print $attr['gender']; // f - * - * // access children - * foreach( $xml->root->node->children() as $child ) { - * print $child->data(); - * } - * - * - * Note: JSimpleXML cannot be used to access sophisticated XML doctypes - * using datatype ANY (e.g. XHTML). With a DOM implementation you can - * handle this. - * - * @package Joomla.Framework - * @subpackage Utilities - * @since 1.5 - */ -class JSimpleXML extends JObject -{ - /** - * The XML parser - * - * @var resource - */ - var $_parser = null; - - /** - * The XML document - * - * @var string - */ - var $_xml = ''; - - /** - * Document element - * - * @var object - */ - var $document = null; - - /** - * Current object depth - * - * @var array - */ - var $_stack = array(); - - - /** - * Constructor. - * - * @access protected - */ - function __construct($options = null) - { - if(! function_exists('xml_parser_create')) { - return false; //TODO throw warning - } - - //Create the parser resource and make sure both versions of PHP autodetect the format. - $this->_parser = xml_parser_create(''); - - // check parser resource - xml_set_object($this->_parser, $this); - xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, 0); - if( is_array($options) ) - { - foreach( $options as $option => $value ) { - xml_parser_set_option($this->_parser, $option, $value); - } - } - - //Set the handlers - xml_set_element_handler($this->_parser, '_startElement', '_endElement'); - xml_set_character_data_handler($this->_parser, '_characterData'); - } - - /** - * Interprets a string of XML into an object - * - * This function will take the well-formed xml string data and return an object of class - * JSimpleXMLElement with properties containing the data held within the xml document. - * If any errors occur, it returns FALSE. - * - * @param string Well-formed xml string data - * @param string currently ignored - * @return object JSimpleXMLElement - */ - function loadString($string, $classname = null) { - $this->_parse($string); - return true; - } - - /** - * Interprets an XML file into an object - * - * This function will convert the well-formed XML document in the file specified by filename - * to an object of class JSimpleXMLElement. If any errors occur during file access or - * interpretation, the function returns FALSE. - * - * @param string Path to xml file containing a well-formed XML document - * @param string currently ignored - * @return boolean True if successful, false if file empty - */ - function loadFile($path, $classname = null) - { - //Check to see of the path exists - if ( !file_exists( $path ) ) { - return false; - } - - //Get the XML document loaded into a variable - $xml = trim( file_get_contents($path) ); - if ($xml == '') - { - return false; - } - else - { - $this->_parse($xml); - return true; - } - } - - /** - * Get a JSimpleXMLElement object from a DOM node. - * - * This function takes a node of a DOM document and makes it into a JSimpleXML node. - * This new object can then be used as a native JSimpleXML element. If any errors occur, - * it returns FALSE. - * - * @param string DOM document - * @param string currently ignored - * @return object JSimpleXMLElement - */ - function importDOM($node, $classname = null) { - return false; - } - - /** - * Get the parser - * - * @access public - * @return resource XML parser resource handle - */ - function getParser() { - return $this->_parser; - } - - /** - * Set the parser - * - * @access public - * @param resource XML parser resource handle - */ - function setParser($parser) { - $this->_parser = $parser; - } - - /** - * Start parsing an XML document - * - * Parses an XML document. The handlers for the configured events are called as many times as necessary. - * - * @param $xml string data to parse - */ - function _parse($data = '') - { - //Error handling - if (!xml_parse($this->_parser, $data)) { - $this->_handleError( - xml_get_error_code($this->_parser), - xml_get_current_line_number($this->_parser), - xml_get_current_column_number($this->_parser) - ); - } - - //Free the parser - xml_parser_free($this->_parser); - } - - /** - * Handles an XML parsing error - * - * @access protected - * @param int $code XML Error Code - * @param int $line Line on which the error happened - * @param int $col Column on which the error happened - */ - function _handleError($code, $line, $col) - { - JError::raiseWarning( 'SOME_ERROR_CODE' , 'XML Parsing Error at '.$line.':'.$col.'. Error '.$code.': '.xml_error_string($code)); - } - - /** - * Gets the reference to the current direct parent - * - * @return object - */ - function _getStackLocation() - { - $return = ''; - foreach($this->_stack as $stack) { - $return .= $stack.'->'; - } - - return rtrim($return, '->'); - } - - /** - * Handler function for the start of a tag - * - * @access protected - * @param resource $parser - * @param string $name - * @param array $attrs - */ - function _startElement($parser, $name, $attrs = array()) - { - //Check to see if tag is root-level - $count = count($this->_stack); - if ($count == 0) - { - //If so, set the document as the current tag - $classname = get_class( $this ) . 'Element'; - $this->document = new $classname($name, $attrs); - - //And start out the stack with the document tag - $this->_stack = array('document'); - } - //If it isn't root level, use the stack to find the parent - else - { - //Get the name which points to the current direct parent, relative to $this - $parent = $this->_getStackLocation(); - - //Add the child - eval('$this->'.$parent.'->addChild($name, $attrs, '.$count.');'); - - //Update the stack - eval('$this->_stack[] = $name.\'[\'.(count($this->'.$parent.'->'.$name.') - 1).\']\';'); - } - } - - /** - * Handler function for the end of a tag - * - * @access protected - * @param resource $parser - * @param string $name - */ - function _endElement($parser, $name) - { - //Update stack by removing the end value from it as the parent - array_pop($this->_stack); - } - - /** - * Handler function for the character data within a tag - * - * @access protected - * @param resource $parser - * @param string $data - */ - function _characterData($parser, $data) - { - //Get the reference to the current parent object - $tag = $this->_getStackLocation(); - - //Assign data to it - eval('$this->'.$tag.'->_data .= $data;'); - } -} - - -/** - * SimpleXML Element - * - * This object stores all of the direct children of itself in the $children array. - * They are also stored by type as arrays. So, if, for example, this tag had 2 - * tags as children, there would be a class member called $font created as an array. - * $font[0] would be the first font tag, and $font[1] would be the second. - * - * To loop through all of the direct children of this object, the $children member - * should be used. - * - * To loop through all of the direct children of a specific tag for this object, it - * is probably easier to use the arrays of the specific tag names, as explained above. - * - * @package Joomla.Framework - * @subpackage Utilities - * @since 1.5 - */ -class JSimpleXMLElement extends JObject -{ - /** - * Array with the attributes of this XML element - * - * @var array - */ - var $_attributes = array(); - - /** - * The name of the element - * - * @var string - */ - var $_name = ''; - - /** - * The data the element contains - * - * @var string - */ - var $_data = ''; - - /** - * Array of references to the objects of all direct children of this XML object - * - * @var array - */ - var $_children = array(); - - /** - * The level of this XML element - * - * @var int - */ - var $_level = 0; - - /** - * Constructor, sets up all the default values - * - * @param string $name - * @param array $attrs - * @param int $parents - * @return JSimpleXMLElement - */ - function __construct($name, $attrs = array(), $level = 0) - { - //Make the keys of the attr array lower case, and store the value - $this->_attributes = array_change_key_case($attrs, CASE_LOWER); - - //Make the name lower case and store the value - $this->_name = strtolower($name); - - //Set the level - $this->_level = $level; - } - - /** - * Get the name of the element - * - * @access public - * @return string - */ - function name() { - return $this->_name; - } - - /** - * Get the an attribute of the element - * - * @param string $attribute The name of the attribute - * - * @access public - * @return mixed If an attribute is given will return the attribute if it exist. - * If no attribute is given will return the complete attributes array - */ - function attributes($attribute = null) - { - if(!isset($attribute)) { - return $this->_attributes; - } - - return isset($this->_attributes[$attribute]) ? $this->_attributes[$attribute] : null; - } - - /** - * Get the data of the element - * - * @access public - * @return string - */ - function data() { - return $this->_data; - } - - /** - * Set the data of the element - * - * @access public - * @param string $data - * @return string - */ - function setData($data) { - $this->_data = $data; - } - - /** - * Get the children of the element - * - * @access public - * @return array - */ - function children() { - return $this->_children; - } - - /** - * Get the level of the element - * - * @access public - * @return int - */ - function level() { - return $this->_level; - } - - /** - * Adds an attribute to the element - * - * @param string $name - * @param array $attrs - */ - function addAttribute($name, $value) - { - //add the attribute to the element, override if it already exists - $this->_attributes[$name] = $value; - } - - /** - * Removes an attribute from the element - * - * @param string $name - */ - function removeAttribute($name) - { - unset($this->_attributes[$name]); - } - - /** - * Adds a direct child to the element - * - * @param string $name - * @param array $attrs - * @param int $level - * @return JSimpleXMLElement The added child object - */ - function &addChild($name, $attrs = array(), $level = null) - { - //If there is no array already set for the tag name being added, - //create an empty array for it - if(!isset($this->$name)) { - $this->$name = array(); - } - - // set the level if not already specified - if ($level == null) { - $level = ($this->_level + 1); - } - - //Create the child object itself - $classname = get_class( $this ); - $child = new $classname( $name, $attrs, $level ); - - //Add the reference of it to the end of an array member named for the elements name - $this->{$name}[] =& $child; - - //Add the reference to the children array member - $this->_children[] =& $child; - - //return the new child - return $child; - } - - function removeChild(&$child) - { - $name = $child->name(); - for ($i=0,$n=count($this->_children);$i<$n;$i++) - { - if ($this->_children[$i] == $child) { - unset($this->_children[$i]); - } - } - for ($i=0,$n=count($this->{$name});$i<$n;$i++) - { - if ($this->{$name}[$i] == $child) { - unset($this->{$name}[$i]); - } - } - $this->_children = array_values($this->_children); - $this->{$name} = array_values($this->{$name}); - unset($child); - } - - /** - * Get an element in the document by / separated path - * - * @param string $path The / separated path to the element - * @return object JSimpleXMLElement - */ - function &getElementByPath($path) - { - $tmp =& $this; - $false = false; - $parts = explode('/', trim($path, '/')); - - foreach ($parts as $node) - { - $found = false; - foreach ($tmp->_children as $child) - { - if ($child->_name == $node) - { - $tmp =& $child; - $found = true; - break; - } - } - if (!$found) { - break; - } - } - - if ($found) { - $ref =& $tmp; - } else { - $ref =& $false; - } - return $ref; - } - - /** - * traverses the tree calling the $callback( JSimpleXMLElement - * $this, mixed $args=array() ) function with each JSimpleXMLElement. - * - * @param string $callback function name - * @param array $args - */ - function map($callback, $args=array()) - { - $callback($this, $args); - // Map to all children - if ($n = count($this->_children)) { - for($i=0;$i<$n;$i++) - { - $this->_children[$i]->map($callback, $args); - } - } - } - - /** - * Return a well-formed XML string based on SimpleXML element - * - * @return string - */ - function toString($whitespace=true) - { - //Start a new line, indent by the number indicated in $this->level, add a <, and add the name of the tag - if ($whitespace) { - $out = "\n".str_repeat("\t", $this->_level).'<'.$this->_name; - } else { - $out = '<'.$this->_name; - } - - //For each attribute, add attr="value" - foreach($this->_attributes as $attr => $value) { - $out .= ' '.$attr.'="'.htmlspecialchars($value).'"'; - } - - //If there are no children and it contains no data, end it off with a /> - if (empty($this->_children) && empty($this->_data)) { - $out .= " />"; - } - else //Otherwise... - { - //If there are children - if(!empty($this->_children)) - { - //Close off the start tag - $out .= '>'; - - //For each child, call the asXML function (this will ensure that all children are added recursively) - foreach($this->_children as $child) - $out .= $child->toString($whitespace); - - //Add the newline and indentation to go along with the close tag - if ($whitespace) { - $out .= "\n".str_repeat("\t", $this->_level); - } - } - - //If there is data, close off the start tag and add the data - elseif(!empty($this->_data)) - $out .= '>'.htmlspecialchars($this->_data); - - //Add the end tag - $out .= '_name.'>'; - } - - //Return the final output - return $out; - } + + *
  • The access to the root node has to be explicit in + * JSimpleXML, not implicit as with PHP5. Write + * $xml->document->node instead of $xml->node
  • + *
  • You cannot acces CDATA using array syntax. Use the method data() instead
  • + *
  • You cannot access attributes directly with array syntax. use attributes() + * to read them.
  • + *
  • Comments are ignored.
  • + *
  • Last and least, this is not as fast as PHP5 SimpleXML--it is pure PHP4.
  • + * + * + * Example: + * + * :simple.xml: + * + * + * + * Tom Foo + * Tamara Bar + * + * + * + * --- + * + * // read and write a document + * $xml = new JSimpleXML; + * $xml->loadFile('simple.xml'); + * print $xml->document->toString(); + * + * // access a given node's CDATA + * print $xml->root->node->child[0]->data(); // Tom Foo + * + * // access attributes + * $attr = $xml->root->node->child[1]->attributes(); + * print $attr['gender']; // f + * + * // access children + * foreach( $xml->root->node->children() as $child ) { + * print $child->data(); + * } + * + * + * Note: JSimpleXML cannot be used to access sophisticated XML doctypes + * using datatype ANY (e.g. XHTML). With a DOM implementation you can + * handle this. + * + * @package Joomla.Framework + * @subpackage Utilities + * @since 1.5 + */ +class JSimpleXML extends JObject +{ + /** + * The XML parser + * + * @var resource + */ + var $_parser = null; + + /** + * The XML document + * + * @var string + */ + var $_xml = ''; + + /** + * Document element + * + * @var object + */ + var $document = null; + + /** + * Current object depth + * + * @var array + */ + var $_stack = array(); + + + /** + * Constructor. + * + * @access protected + */ + function __construct($options = null) + { + if(! function_exists('xml_parser_create')) { + return false; //TODO throw warning + } + + //Create the parser resource and make sure both versions of PHP autodetect the format. + $this->_parser = xml_parser_create(''); + + // check parser resource + xml_set_object($this->_parser, $this); + xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, 0); + if( is_array($options) ) + { + foreach( $options as $option => $value ) { + xml_parser_set_option($this->_parser, $option, $value); + } + } + + //Set the handlers + xml_set_element_handler($this->_parser, '_startElement', '_endElement'); + xml_set_character_data_handler($this->_parser, '_characterData'); + } + + /** + * Interprets a string of XML into an object + * + * This function will take the well-formed xml string data and return an object of class + * JSimpleXMLElement with properties containing the data held within the xml document. + * If any errors occur, it returns FALSE. + * + * @param string Well-formed xml string data + * @param string currently ignored + * @return object JSimpleXMLElement + */ + function loadString($string, $classname = null) { + $this->_parse($string); + return true; + } + + /** + * Interprets an XML file into an object + * + * This function will convert the well-formed XML document in the file specified by filename + * to an object of class JSimpleXMLElement. If any errors occur during file access or + * interpretation, the function returns FALSE. + * + * @param string Path to xml file containing a well-formed XML document + * @param string currently ignored + * @return boolean True if successful, false if file empty + */ + function loadFile($path, $classname = null) + { + //Check to see of the path exists + if ( !file_exists( $path ) ) { + return false; + } + + //Get the XML document loaded into a variable + $xml = trim( file_get_contents($path) ); + if ($xml == '') + { + return false; + } + else + { + $this->_parse($xml); + return true; + } + } + + /** + * Get a JSimpleXMLElement object from a DOM node. + * + * This function takes a node of a DOM document and makes it into a JSimpleXML node. + * This new object can then be used as a native JSimpleXML element. If any errors occur, + * it returns FALSE. + * + * @param string DOM document + * @param string currently ignored + * @return object JSimpleXMLElement + */ + function importDOM($node, $classname = null) { + return false; + } + + /** + * Get the parser + * + * @access public + * @return resource XML parser resource handle + */ + function getParser() { + return $this->_parser; + } + + /** + * Set the parser + * + * @access public + * @param resource XML parser resource handle + */ + function setParser($parser) { + $this->_parser = $parser; + } + + /** + * Start parsing an XML document + * + * Parses an XML document. The handlers for the configured events are called as many times as necessary. + * + * @param $xml string data to parse + */ + function _parse($data = '') + { + //Error handling + if (!xml_parse($this->_parser, $data)) { + $this->_handleError( + xml_get_error_code($this->_parser), + xml_get_current_line_number($this->_parser), + xml_get_current_column_number($this->_parser) + ); + } + + //Free the parser + xml_parser_free($this->_parser); + } + + /** + * Handles an XML parsing error + * + * @access protected + * @param int $code XML Error Code + * @param int $line Line on which the error happened + * @param int $col Column on which the error happened + */ + function _handleError($code, $line, $col) + { + JError::raiseWarning( 'SOME_ERROR_CODE' , 'XML Parsing Error at '.$line.':'.$col.'. Error '.$code.': '.xml_error_string($code)); + } + + /** + * Gets the reference to the current direct parent + * + * @return object + */ + function _getStackLocation() + { + $return = ''; + foreach($this->_stack as $stack) { + $return .= $stack.'->'; + } + + return rtrim($return, '->'); + } + + /** + * Handler function for the start of a tag + * + * @access protected + * @param resource $parser + * @param string $name + * @param array $attrs + */ + function _startElement($parser, $name, $attrs = array()) + { + //Check to see if tag is root-level + $count = count($this->_stack); + if ($count == 0) + { + //If so, set the document as the current tag + $classname = get_class( $this ) . 'Element'; + $this->document = new $classname($name, $attrs); + + //And start out the stack with the document tag + $this->_stack = array('document'); + } + //If it isn't root level, use the stack to find the parent + else + { + //Get the name which points to the current direct parent, relative to $this + $parent = $this->_getStackLocation(); + + //Add the child + eval('$this->'.$parent.'->addChild($name, $attrs, '.$count.');'); + + //Update the stack + eval('$this->_stack[] = $name.\'[\'.(count($this->'.$parent.'->'.$name.') - 1).\']\';'); + } + } + + /** + * Handler function for the end of a tag + * + * @access protected + * @param resource $parser + * @param string $name + */ + function _endElement($parser, $name) + { + //Update stack by removing the end value from it as the parent + array_pop($this->_stack); + } + + /** + * Handler function for the character data within a tag + * + * @access protected + * @param resource $parser + * @param string $data + */ + function _characterData($parser, $data) + { + //Get the reference to the current parent object + $tag = $this->_getStackLocation(); + + //Assign data to it + eval('$this->'.$tag.'->_data .= $data;'); + } +} + + +/** + * SimpleXML Element + * + * This object stores all of the direct children of itself in the $children array. + * They are also stored by type as arrays. So, if, for example, this tag had 2 + * tags as children, there would be a class member called $font created as an array. + * $font[0] would be the first font tag, and $font[1] would be the second. + * + * To loop through all of the direct children of this object, the $children member + * should be used. + * + * To loop through all of the direct children of a specific tag for this object, it + * is probably easier to use the arrays of the specific tag names, as explained above. + * + * @package Joomla.Framework + * @subpackage Utilities + * @since 1.5 + */ +class JSimpleXMLElement extends JObject +{ + /** + * Array with the attributes of this XML element + * + * @var array + */ + var $_attributes = array(); + + /** + * The name of the element + * + * @var string + */ + var $_name = ''; + + /** + * The data the element contains + * + * @var string + */ + var $_data = ''; + + /** + * Array of references to the objects of all direct children of this XML object + * + * @var array + */ + var $_children = array(); + + /** + * The level of this XML element + * + * @var int + */ + var $_level = 0; + + /** + * Constructor, sets up all the default values + * + * @param string $name + * @param array $attrs + * @param int $parents + * @return JSimpleXMLElement + */ + function __construct($name, $attrs = array(), $level = 0) + { + //Make the keys of the attr array lower case, and store the value + $this->_attributes = array_change_key_case($attrs, CASE_LOWER); + + //Make the name lower case and store the value + $this->_name = strtolower($name); + + //Set the level + $this->_level = $level; + } + + /** + * Get the name of the element + * + * @access public + * @return string + */ + function name() { + return $this->_name; + } + + /** + * Get the an attribute of the element + * + * @param string $attribute The name of the attribute + * + * @access public + * @return mixed If an attribute is given will return the attribute if it exist. + * If no attribute is given will return the complete attributes array + */ + function attributes($attribute = null) + { + if(!isset($attribute)) { + return $this->_attributes; + } + + return isset($this->_attributes[$attribute]) ? $this->_attributes[$attribute] : null; + } + + /** + * Get the data of the element + * + * @access public + * @return string + */ + function data() { + return $this->_data; + } + + /** + * Set the data of the element + * + * @access public + * @param string $data + * @return string + */ + function setData($data) { + $this->_data = $data; + } + + /** + * Get the children of the element + * + * @access public + * @return array + */ + function children() { + return $this->_children; + } + + /** + * Get the level of the element + * + * @access public + * @return int + */ + function level() { + return $this->_level; + } + + /** + * Adds an attribute to the element + * + * @param string $name + * @param array $attrs + */ + function addAttribute($name, $value) + { + //add the attribute to the element, override if it already exists + $this->_attributes[$name] = $value; + } + + /** + * Removes an attribute from the element + * + * @param string $name + */ + function removeAttribute($name) + { + unset($this->_attributes[$name]); + } + + /** + * Adds a direct child to the element + * + * @param string $name + * @param array $attrs + * @param int $level + * @return JSimpleXMLElement The added child object + */ + function &addChild($name, $attrs = array(), $level = null) + { + //If there is no array already set for the tag name being added, + //create an empty array for it + if(!isset($this->$name)) { + $this->$name = array(); + } + + // set the level if not already specified + if ($level == null) { + $level = ($this->_level + 1); + } + + //Create the child object itself + $classname = get_class( $this ); + $child = new $classname( $name, $attrs, $level ); + + //Add the reference of it to the end of an array member named for the elements name + $this->{$name}[] =& $child; + + //Add the reference to the children array member + $this->_children[] =& $child; + + //return the new child + return $child; + } + + function removeChild(&$child) + { + $name = $child->name(); + for ($i=0,$n=count($this->_children);$i<$n;$i++) + { + if ($this->_children[$i] == $child) { + unset($this->_children[$i]); + } + } + for ($i=0,$n=count($this->{$name});$i<$n;$i++) + { + if ($this->{$name}[$i] == $child) { + unset($this->{$name}[$i]); + } + } + $this->_children = array_values($this->_children); + $this->{$name} = array_values($this->{$name}); + unset($child); + } + + /** + * Get an element in the document by / separated path + * + * @param string $path The / separated path to the element + * @return object JSimpleXMLElement + */ + function &getElementByPath($path) + { + $tmp =& $this; + $false = false; + $parts = explode('/', trim($path, '/')); + + foreach ($parts as $node) + { + $found = false; + foreach ($tmp->_children as $child) + { + if ($child->_name == $node) + { + $tmp =& $child; + $found = true; + break; + } + } + if (!$found) { + break; + } + } + + if ($found) { + $ref =& $tmp; + } else { + $ref =& $false; + } + return $ref; + } + + /** + * traverses the tree calling the $callback( JSimpleXMLElement + * $this, mixed $args=array() ) function with each JSimpleXMLElement. + * + * @param string $callback function name + * @param array $args + */ + function map($callback, $args=array()) + { + $callback($this, $args); + // Map to all children + if ($n = count($this->_children)) { + for($i=0;$i<$n;$i++) + { + $this->_children[$i]->map($callback, $args); + } + } + } + + /** + * Return a well-formed XML string based on SimpleXML element + * + * @return string + */ + function toString($whitespace=true) + { + //Start a new line, indent by the number indicated in $this->level, add a <, and add the name of the tag + if ($whitespace) { + $out = "\n".str_repeat("\t", $this->_level).'<'.$this->_name; + } else { + $out = '<'.$this->_name; + } + + //For each attribute, add attr="value" + foreach($this->_attributes as $attr => $value) { + $out .= ' '.$attr.'="'.htmlspecialchars($value).'"'; + } + + //If there are no children and it contains no data, end it off with a /> + if (empty($this->_children) && empty($this->_data)) { + $out .= " />"; + } + else //Otherwise... + { + //If there are children + if(!empty($this->_children)) + { + //Close off the start tag + $out .= '>'; + + //For each child, call the asXML function (this will ensure that all children are added recursively) + foreach($this->_children as $child) + $out .= $child->toString($whitespace); + + //Add the newline and indentation to go along with the close tag + if ($whitespace) { + $out .= "\n".str_repeat("\t", $this->_level); + } + } + + //If there is data, close off the start tag and add the data + elseif(!empty($this->_data)) + $out .= '>'.htmlspecialchars($this->_data); + + //Add the end tag + $out .= '_name.'>'; + } + + //Return the final output + return $out; + } } \ No newline at end of file diff --git a/oss/joomla/trunk/libraries/joomla/utilities/string.php b/oss/joomla/trunk/libraries/joomla/utilities/string.php index 98c90a5f..964b0f75 100644 --- a/oss/joomla/trunk/libraries/joomla/utilities/string.php +++ b/oss/joomla/trunk/libraries/joomla/utilities/string.php @@ -1,445 +1,445 @@ - 0 if str1 is greater than str2, and 0 if they are equal. - * @see http://www.php.net/strcasecmp - */ - function strcasecmp($str1, $str2) - { - jimport('phputf8.strcasecmp'); - return utf8_strcasecmp($str1, $str2); - } - - /** - * UTF-8 aware alternative to strcspn - * Find length of initial segment not matching mask - * - * @static - * @access public - * @param string - * @param string the mask - * @param int Optional starting character position (in characters) - * @param int Optional length - * @return int the length of the initial segment of str1 which does not contain any of the characters in str2 - * @see http://www.php.net/strcspn - */ - function strcspn($str, $mask, $start = NULL, $length = NULL) - { - jimport('phputf8.strcspn'); - if ( $start === FALSE && $length === FALSE ) { - return utf8_strcspn($str, $mask); - } else if ( $length === FALSE ) { - return utf8_strcspn($str, $mask, $start); - } else { - return utf8_strcspn($str, $mask, $start, $length); - } - } - - /** - * UTF-8 aware alternative to stristr - * Returns all of haystack from the first occurrence of needle to the end. - * needle and haystack are examined in a case-insensitive manner - * Find first occurrence of a string using case insensitive comparison - * - * @static - * @access public - * @param string the haystack - * @param string the needle - * @return string the sub string - * @see http://www.php.net/stristr - */ - function stristr($str, $search) - { - jimport('phputf8.stristr'); - return utf8_stristr($str, $search); - } - - /** - * UTF-8 aware alternative to strrev - * Reverse a string - * - * @static - * @access public - * @param string String to be reversed - * @return string The string in reverse character order - * @see http://www.php.net/strrev - */ - function strrev($str) - { - jimport('phputf8.strrev'); - return utf8_strrev($str); - } - - /** - * UTF-8 aware alternative to strspn - * Find length of initial segment matching mask - * - * @static - * @access public - * @param string the haystack - * @param string the mask - * @param int start optional - * @param int length optional - * @see http://www.php.net/strspn - */ - function strspn($str, $mask, $start = NULL, $length = NULL) - { - jimport('phputf8.strspn'); - if ( $start === FALSE && $length === FALSE ) { - return utf8_strspn($str, $mask); - } else if ( $length === FALSE ) { - return utf8_strspn($str, $mask, $start); - } else { - return utf8_strspn($str, $mask, $start, $length); - } - } - - /** - * UTF-8 aware substr_replace - * Replace text within a portion of a string - * - * @static - * @access public - * @param string the haystack - * @param string the replacement string - * @param int start - * @param int length (optional) - * @see http://www.php.net/substr_replace - */ - function substr_replace($str, $repl, $start, $length = NULL ) - { - // loaded by library loader - if ( $length === FALSE ) { - return utf8_substr_replace($str, $repl, $start); - } else { - return utf8_substr_replace($str, $repl, $start, $length); - } - } - - /** - * UTF-8 aware replacement for ltrim() - * Strip whitespace (or other characters) from the beginning of a string - * Note: you only need to use this if you are supplying the charlist - * optional arg and it contains UTF-8 characters. Otherwise ltrim will - * work normally on a UTF-8 string - * - * @static - * @access public - * @param string the string to be trimmed - * @param string the optional charlist of additional characters to trim - * @return string the trimmed string - * @see http://www.php.net/ltrim - */ - function ltrim( $str, $charlist = FALSE ) - { - jimport('phputf8.trim'); - if ( $charlist === FALSE ) { - return utf8_ltrim( $str ); - } else { - return utf8_ltrim( $str, $charlist ); - } - } - - /** - * UTF-8 aware replacement for rtrim() - * Strip whitespace (or other characters) from the end of a string - * Note: you only need to use this if you are supplying the charlist - * optional arg and it contains UTF-8 characters. Otherwise rtrim will - * work normally on a UTF-8 string - * - * @static - * @access public - * @param string the string to be trimmed - * @param string the optional charlist of additional characters to trim - * @return string the trimmed string - * @see http://www.php.net/rtrim - */ - function rtrim( $str, $charlist = FALSE ) - { - jimport('phputf8.trim'); - if ( $charlist === FALSE ) { - return utf8_rtrim($str); - } else { - return utf8_rtrim( $str, $charlist ); - } - } - - /** - * UTF-8 aware replacement for trim() - * Strip whitespace (or other characters) from the beginning and end of a string - * Note: you only need to use this if you are supplying the charlist - * optional arg and it contains UTF-8 characters. Otherwise trim will - * work normally on a UTF-8 string - * - * @static - * @access public - * @param string the string to be trimmed - * @param string the optional charlist of additional characters to trim - * @return string the trimmed string - * @see http://www.php.net/trim - */ - function trim( $str, $charlist = FALSE ) - { - jimport('phputf8.trim'); - if ( $charlist === FALSE ) { - return utf8_trim( $str ); - } else { - return utf8_trim( $str, $charlist ); - } - } - - /** - * UTF-8 aware alternative to ucfirst - * Make a string's first character uppercase - * - * @static - * @access public - * @param string - * @return string with first character as upper case (if applicable) - * @see http://www.php.net/ucfirst - */ - function ucfirst($str) - { - jimport('phputf8.ucfirst'); - return utf8_ucfirst($str); - } - - /** - * UTF-8 aware alternative to ucwords - * Uppercase the first character of each word in a string - * - * @static - * @access public - * @param string - * @return string with first char of each word uppercase - * @see http://www.php.net/ucwords - */ - function ucwords($str) - { - jimport('phputf8.ucwords'); - return utf8_ucwords($str); - } - - /** - * Transcode a string. - * - * @static - * @param string $source The string to transcode. - * @param string $from_encoding The source encoding. - * @param string $to_encoding The target encoding. - * @return string Transcoded string - * @since 1.5 - */ - function transcode($source, $from_encoding, $to_encoding) { - - if (is_string($source)) { - /* - * "//TRANSLIT" is appendd to the $to_encoding to ensure that when iconv comes - * across a character that cannot be represented in the target charset, it can - * be approximated through one or several similarly looking characters. - */ - return iconv($from_encoding, $to_encoding.'//TRANSLIT', $source); - } - } -} + 0 if str1 is greater than str2, and 0 if they are equal. + * @see http://www.php.net/strcasecmp + */ + function strcasecmp($str1, $str2) + { + jimport('phputf8.strcasecmp'); + return utf8_strcasecmp($str1, $str2); + } + + /** + * UTF-8 aware alternative to strcspn + * Find length of initial segment not matching mask + * + * @static + * @access public + * @param string + * @param string the mask + * @param int Optional starting character position (in characters) + * @param int Optional length + * @return int the length of the initial segment of str1 which does not contain any of the characters in str2 + * @see http://www.php.net/strcspn + */ + function strcspn($str, $mask, $start = NULL, $length = NULL) + { + jimport('phputf8.strcspn'); + if ( $start === FALSE && $length === FALSE ) { + return utf8_strcspn($str, $mask); + } else if ( $length === FALSE ) { + return utf8_strcspn($str, $mask, $start); + } else { + return utf8_strcspn($str, $mask, $start, $length); + } + } + + /** + * UTF-8 aware alternative to stristr + * Returns all of haystack from the first occurrence of needle to the end. + * needle and haystack are examined in a case-insensitive manner + * Find first occurrence of a string using case insensitive comparison + * + * @static + * @access public + * @param string the haystack + * @param string the needle + * @return string the sub string + * @see http://www.php.net/stristr + */ + function stristr($str, $search) + { + jimport('phputf8.stristr'); + return utf8_stristr($str, $search); + } + + /** + * UTF-8 aware alternative to strrev + * Reverse a string + * + * @static + * @access public + * @param string String to be reversed + * @return string The string in reverse character order + * @see http://www.php.net/strrev + */ + function strrev($str) + { + jimport('phputf8.strrev'); + return utf8_strrev($str); + } + + /** + * UTF-8 aware alternative to strspn + * Find length of initial segment matching mask + * + * @static + * @access public + * @param string the haystack + * @param string the mask + * @param int start optional + * @param int length optional + * @see http://www.php.net/strspn + */ + function strspn($str, $mask, $start = NULL, $length = NULL) + { + jimport('phputf8.strspn'); + if ( $start === FALSE && $length === FALSE ) { + return utf8_strspn($str, $mask); + } else if ( $length === FALSE ) { + return utf8_strspn($str, $mask, $start); + } else { + return utf8_strspn($str, $mask, $start, $length); + } + } + + /** + * UTF-8 aware substr_replace + * Replace text within a portion of a string + * + * @static + * @access public + * @param string the haystack + * @param string the replacement string + * @param int start + * @param int length (optional) + * @see http://www.php.net/substr_replace + */ + function substr_replace($str, $repl, $start, $length = NULL ) + { + // loaded by library loader + if ( $length === FALSE ) { + return utf8_substr_replace($str, $repl, $start); + } else { + return utf8_substr_replace($str, $repl, $start, $length); + } + } + + /** + * UTF-8 aware replacement for ltrim() + * Strip whitespace (or other characters) from the beginning of a string + * Note: you only need to use this if you are supplying the charlist + * optional arg and it contains UTF-8 characters. Otherwise ltrim will + * work normally on a UTF-8 string + * + * @static + * @access public + * @param string the string to be trimmed + * @param string the optional charlist of additional characters to trim + * @return string the trimmed string + * @see http://www.php.net/ltrim + */ + function ltrim( $str, $charlist = FALSE ) + { + jimport('phputf8.trim'); + if ( $charlist === FALSE ) { + return utf8_ltrim( $str ); + } else { + return utf8_ltrim( $str, $charlist ); + } + } + + /** + * UTF-8 aware replacement for rtrim() + * Strip whitespace (or other characters) from the end of a string + * Note: you only need to use this if you are supplying the charlist + * optional arg and it contains UTF-8 characters. Otherwise rtrim will + * work normally on a UTF-8 string + * + * @static + * @access public + * @param string the string to be trimmed + * @param string the optional charlist of additional characters to trim + * @return string the trimmed string + * @see http://www.php.net/rtrim + */ + function rtrim( $str, $charlist = FALSE ) + { + jimport('phputf8.trim'); + if ( $charlist === FALSE ) { + return utf8_rtrim($str); + } else { + return utf8_rtrim( $str, $charlist ); + } + } + + /** + * UTF-8 aware replacement for trim() + * Strip whitespace (or other characters) from the beginning and end of a string + * Note: you only need to use this if you are supplying the charlist + * optional arg and it contains UTF-8 characters. Otherwise trim will + * work normally on a UTF-8 string + * + * @static + * @access public + * @param string the string to be trimmed + * @param string the optional charlist of additional characters to trim + * @return string the trimmed string + * @see http://www.php.net/trim + */ + function trim( $str, $charlist = FALSE ) + { + jimport('phputf8.trim'); + if ( $charlist === FALSE ) { + return utf8_trim( $str ); + } else { + return utf8_trim( $str, $charlist ); + } + } + + /** + * UTF-8 aware alternative to ucfirst + * Make a string's first character uppercase + * + * @static + * @access public + * @param string + * @return string with first character as upper case (if applicable) + * @see http://www.php.net/ucfirst + */ + function ucfirst($str) + { + jimport('phputf8.ucfirst'); + return utf8_ucfirst($str); + } + + /** + * UTF-8 aware alternative to ucwords + * Uppercase the first character of each word in a string + * + * @static + * @access public + * @param string + * @return string with first char of each word uppercase + * @see http://www.php.net/ucwords + */ + function ucwords($str) + { + jimport('phputf8.ucwords'); + return utf8_ucwords($str); + } + + /** + * Transcode a string. + * + * @static + * @param string $source The string to transcode. + * @param string $from_encoding The source encoding. + * @param string $to_encoding The target encoding. + * @return string Transcoded string + * @since 1.5 + */ + function transcode($source, $from_encoding, $to_encoding) { + + if (is_string($source)) { + /* + * "//TRANSLIT" is appendd to the $to_encoding to ensure that when iconv comes + * across a character that cannot be represented in the target charset, it can + * be approximated through one or several similarly looking characters. + */ + return iconv($from_encoding, $to_encoding.'//TRANSLIT', $source); + } + } +} diff --git a/oss/joomla/trunk/libraries/joomla/utilities/utility.php b/oss/joomla/trunk/libraries/joomla/utilities/utility.php index 984aa7af..e4580764 100644 --- a/oss/joomla/trunk/libraries/joomla/utilities/utility.php +++ b/oss/joomla/trunk/libraries/joomla/utilities/utility.php @@ -1,182 +1,182 @@ -setSender(array($from, $fromname)); - $mail->setSubject($subject); - $mail->setBody($body); - - // Are we sending the email as HTML? - if ( $mode ) { - $mail->IsHTML(true); - } - - $mail->addRecipient($recipient); - $mail->addCC($cc); - $mail->addBCC($bcc); - $mail->addAttachment($attachment); - - // Take care of reply email addresses - if( is_array( $replyto ) ) { - $numReplyTo = count($replyto); - for ( $i=0; $i < $numReplyTo; $i++){ - $mail->addReplyTo( array($replyto[$i], $replytoname[$i]) ); - } - } elseif( isset( $replyto ) ) { - $mail->addReplyTo( array( $replyto, $replytoname ) ); - } - - return $mail->Send(); - } - - /** - * Sends mail to administrator for approval of a user submission - * - * @param string $adminName Name of administrator - * @param string $adminEmail Email address of administrator - * @param string $email [NOT USED TODO: Deprecate?] - * @param string $type Type of item to approve - * @param string $title Title of item to approve - * @param string $author Author of item to approve - * @return boolean True on success - */ - function sendAdminMail( $adminName, $adminEmail, $email, $type, $title, $author, $url = null ) - { - $subject = JText::_( 'User Submitted' ) ." '". $type ."'"; - - $message = sprintf ( JText::_( 'MAIL_MSG_ADMIN' ), $adminName, $type, $title, $author, $url, $url, 'administrator', $type); - $message .= JText::_( 'MAIL_MSG') ."\n"; - - // Get a JMail instance - $mail =& JFactory::getMailer(); - $mail->addRecipient($adminEmail); - $mail->setSubject($subject); - $mail->setBody($message); - - return $mail->Send(); - } - - /** - * Provides a secure hash based on a seed - * - * @param string Seed string - * @return string - */ - function getHash( $seed ) - { - $conf =& JFactory::getConfig(); - return md5( $conf->getValue('config.secret') . $seed ); - } - - /** - * Method to determine a hash for anti-spoofing variable names - * - * @return string Hashed var name - * @since 1.5 - * @static - */ - function getToken($forceNew = false) - { - $user = &JFactory::getUser(); - $session = &JFactory::getSession(); - $hash = JUtility::getHash( $user->get( 'id', 0 ).$session->getToken( $forceNew ) ); - return $hash; - } - - /** - * Method to extract key/value pairs out of a string with xml style attributes - * - * @param string $string String containing xml style attributes - * @return array Key/Value pairs for the attributes - * @since 1.5 - */ - function parseAttributes( $string ) - { - //Initialize variables - $attr = array(); - $retarray = array(); - - // Lets grab all the key/value pairs using a regular expression - preg_match_all( '/([\w:-]+)[\s]?=[\s]?"([^"]*)"/i', $string, $attr ); - - if (is_array($attr)) - { - $numPairs = count($attr[1]); - for($i = 0; $i < $numPairs; $i++ ) - { - $retarray[$attr[1][$i]] = $attr[2][$i]; - } - } - return $retarray; - } - - /** - * Method to determine if the host OS is Windows - * - * @return true if Windows OS - * @since 1.5 - * @static - */ - function isWinOS() { - return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'; - } - - /** - * Method to dump the structure of a variable for debugging purposes - * - * @param mixed A variable - * @param boolean True to ensure all characters are htmlsafe - * @return string - * @since 1.5 - * @static - */ - function dump( &$var, $htmlSafe = true ) - { - $result = var_export( $var, true ); - return '
    '.( $htmlSafe ? htmlspecialchars( $result ) : $result).'
    '; - } +setSender(array($from, $fromname)); + $mail->setSubject($subject); + $mail->setBody($body); + + // Are we sending the email as HTML? + if ( $mode ) { + $mail->IsHTML(true); + } + + $mail->addRecipient($recipient); + $mail->addCC($cc); + $mail->addBCC($bcc); + $mail->addAttachment($attachment); + + // Take care of reply email addresses + if( is_array( $replyto ) ) { + $numReplyTo = count($replyto); + for ( $i=0; $i < $numReplyTo; $i++){ + $mail->addReplyTo( array($replyto[$i], $replytoname[$i]) ); + } + } elseif( isset( $replyto ) ) { + $mail->addReplyTo( array( $replyto, $replytoname ) ); + } + + return $mail->Send(); + } + + /** + * Sends mail to administrator for approval of a user submission + * + * @param string $adminName Name of administrator + * @param string $adminEmail Email address of administrator + * @param string $email [NOT USED TODO: Deprecate?] + * @param string $type Type of item to approve + * @param string $title Title of item to approve + * @param string $author Author of item to approve + * @return boolean True on success + */ + function sendAdminMail( $adminName, $adminEmail, $email, $type, $title, $author, $url = null ) + { + $subject = JText::_( 'User Submitted' ) ." '". $type ."'"; + + $message = sprintf ( JText::_( 'MAIL_MSG_ADMIN' ), $adminName, $type, $title, $author, $url, $url, 'administrator', $type); + $message .= JText::_( 'MAIL_MSG') ."\n"; + + // Get a JMail instance + $mail =& JFactory::getMailer(); + $mail->addRecipient($adminEmail); + $mail->setSubject($subject); + $mail->setBody($message); + + return $mail->Send(); + } + + /** + * Provides a secure hash based on a seed + * + * @param string Seed string + * @return string + */ + function getHash( $seed ) + { + $conf =& JFactory::getConfig(); + return md5( $conf->getValue('config.secret') . $seed ); + } + + /** + * Method to determine a hash for anti-spoofing variable names + * + * @return string Hashed var name + * @since 1.5 + * @static + */ + function getToken($forceNew = false) + { + $user = &JFactory::getUser(); + $session = &JFactory::getSession(); + $hash = JUtility::getHash( $user->get( 'id', 0 ).$session->getToken( $forceNew ) ); + return $hash; + } + + /** + * Method to extract key/value pairs out of a string with xml style attributes + * + * @param string $string String containing xml style attributes + * @return array Key/Value pairs for the attributes + * @since 1.5 + */ + function parseAttributes( $string ) + { + //Initialize variables + $attr = array(); + $retarray = array(); + + // Lets grab all the key/value pairs using a regular expression + preg_match_all( '/([\w:-]+)[\s]?=[\s]?"([^"]*)"/i', $string, $attr ); + + if (is_array($attr)) + { + $numPairs = count($attr[1]); + for($i = 0; $i < $numPairs; $i++ ) + { + $retarray[$attr[1][$i]] = $attr[2][$i]; + } + } + return $retarray; + } + + /** + * Method to determine if the host OS is Windows + * + * @return true if Windows OS + * @since 1.5 + * @static + */ + function isWinOS() { + return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'; + } + + /** + * Method to dump the structure of a variable for debugging purposes + * + * @param mixed A variable + * @param boolean True to ensure all characters are htmlsafe + * @return string + * @since 1.5 + * @static + */ + function dump( &$var, $htmlSafe = true ) + { + $result = var_export( $var, true ); + return '
    '.( $htmlSafe ? htmlspecialchars( $result ) : $result).'
    '; + } } \ No newline at end of file diff --git a/oss/joomla/trunk/libraries/joomla/version.php b/oss/joomla/trunk/libraries/joomla/version.php index c6aca34c..b10ed3bb 100644 --- a/oss/joomla/trunk/libraries/joomla/version.php +++ b/oss/joomla/trunk/libraries/joomla/version.php @@ -1,90 +1,90 @@ -Joomla! is Free Software released under the GNU General Public License.'; - - /** - * - * - * @return string Long format version - */ - function getLongVersion() - { - return $this->PRODUCT .' '. $this->RELEASE .'.'. $this->DEV_LEVEL .' ' - . $this->DEV_STATUS - .' [ '.$this->CODENAME .' ] '. $this->RELDATE .' ' - . $this->RELTIME .' '. $this->RELTZ; - } - - /** - * - * - * @return string Short version format - */ - function getShortVersion() { - return $this->RELEASE .'.'. $this->DEV_LEVEL; - } - - /** - * - * - * @return string Version suffix for help files - */ - function getHelpVersion() - { - if ($this->RELEASE > '1.0') { - return '.' . str_replace( '.', '', $this->RELEASE ); - } else { - return ''; - } - } - - /** - * Compares two "A PHP standardized" version number against the current Joomla! version - * - * @return boolean - * @see http://www.php.net/version_compare - */ - function isCompatible ( $minimum ) { - return (version_compare( JVERSION, $minimum, 'eq' ) == 1); - } -} +Joomla! is Free Software released under the GNU General Public License.'; + + /** + * + * + * @return string Long format version + */ + function getLongVersion() + { + return $this->PRODUCT .' '. $this->RELEASE .'.'. $this->DEV_LEVEL .' ' + . $this->DEV_STATUS + .' [ '.$this->CODENAME .' ] '. $this->RELDATE .' ' + . $this->RELTIME .' '. $this->RELTZ; + } + + /** + * + * + * @return string Short version format + */ + function getShortVersion() { + return $this->RELEASE .'.'. $this->DEV_LEVEL; + } + + /** + * + * + * @return string Version suffix for help files + */ + function getHelpVersion() + { + if ($this->RELEASE > '1.0') { + return '.' . str_replace( '.', '', $this->RELEASE ); + } else { + return ''; + } + } + + /** + * Compares two "A PHP standardized" version number against the current Joomla! version + * + * @return boolean + * @see http://www.php.net/version_compare + */ + function isCompatible ( $minimum ) { + return (version_compare( JVERSION, $minimum, 'eq' ) == 1); + } +} diff --git a/oss/joomla/trunk/libraries/loader.php b/oss/joomla/trunk/libraries/loader.php index 1a969e45..0aa1cea6 100644 --- a/oss/joomla/trunk/libraries/loader.php +++ b/oss/joomla/trunk/libraries/loader.php @@ -1,187 +1,187 @@ - - * @author Sebastian Mordziol - * @author Stephan Schmidt - * @license LGPL - * @link http://www.php-tools.net - */ -class patError -{ - /** - * stores the error level for this error - * - * @access private - * @var string - */ - var $level = null; - - /** - * stores the code of the error - * - * @access private - * @var string - */ - var $code = null; - - /** - * stores the error message - this is the message that can also be shown the - * user if need be. - * - * @access private - * @var string - */ - var $message = null; - - /** - * additional info that is relevant for the developer of the script (e.g. if - * a database connect fails, the dsn used) and that the end-user should not - * see. - * - * @access private - * @var string - */ - var $info = ''; - - /** - * stores the filename of the file the error occurred in. - * - * @access private - * @var string - */ - var $file = ''; - - /** - * stores the line number the error occurred in. - * - * @access private - * @var integer - */ - var $line = 0; - - /** - * stores the name of the method the error occurred in - * - * @access private - * @var string - */ - var $function = ''; - - /** - * stores the name of the class (if any) the error occurred in. - * - * @access private - * @var string - */ - var $class = ''; - - /** - * stores the type of error, as it is listed in the error backtrace - * - * @access private - * @var string - */ - var $type = ''; - - /** - * stores the arguments the method that the error occurred in had received. - * - * @access private - * @var array - */ - var $args = array(); - - /** - * stores the complete debug backtrace (if your PHP version has the - * debug_backtrace function) - * - * @access private - * @var mixed - */ - var $backtrace = false; - - /** - * constructor, wrapper for the upcoming PHP5 constructors for upward - * compatibility. - * - * @access public - * @param int $level The error level (use the PHP constants E_ALL, E_NOTICE etc.). - * @param string $code The error code from the application - * @param string $msg The error message - * @param string $info Optional: The additional error information. - * @see __construct() - */ - function patError( $level, $code, $msg, $info = null ) - { - $this->__construct( $level, $code, $msg, $info ); - } - - /** - * constructor - used to set up the error with all needed error details. - * - * @access public - * @param int $level The error level (use the PHP constants E_ALL, E_NOTICE etc.). - * @param string $code The error code from the application - * @param string $msg The error message - * @param string $info Optional: The additional error information. - * @todo all calls to patErrorManager::raise* should not be included in backtrace - */ - function __construct( $level, $code, $msg, $info = null ) - { - static $raise = array( 'raise', - 'raiseerror', - 'raisewarning', - 'raisenotice' - ); - - $this->level = $level; - $this->code = $code; - $this->message = $msg; - - if( $info != null ) - { - $this->info = $info; - } - - if( function_exists( 'debug_backtrace' ) ) - { - $this->backtrace = debug_backtrace(); - - for( $i = count( $this->backtrace ) - 1; $i >= 0; --$i ) - { - if( in_array( $this->backtrace[$i]['function'], $raise ) ) - { - ++$i; - if( isset( $this->backtrace[$i]['file'] ) ) - $this->file = $this->backtrace[$i]['file']; - if( isset( $this->backtrace[$i]['line'] ) ) - $this->line = $this->backtrace[$i]['line']; - if( isset( $this->backtrace[$i]['class'] ) ) - $this->class = $this->backtrace[$i]['class']; - if( isset( $this->backtrace[$i]['function'] ) ) - $this->function = $this->backtrace[$i]['function']; - if( isset( $this->backtrace[$i]['type'] ) ) - $this->type = $this->backtrace[$i]['type']; - - $this->args = false; - if( isset( $this->backtrace[$i]['args'] ) ) - { - $this->args = $this->backtrace[$i]['args']; - } - break; - } - } - } - } - - /** - * returns the error level of the error - corresponds to the PHP - * error levels (E_ALL, E_NOTICE...) - * - * @access public - * @return int $level The error level - * @see $level - */ - function getLevel() - { - return $this->level; - } - - - /** - * retrieves the error message - * - * @access public - * @return string $msg The stored error message - * @see $message - */ - function getMessage() - { - return $this->message; - } - - /** - * retrieves the additional error information (information usually - * only relevant for developers) - * - * @access public - * @return mixed $info The additional information - * @see $info - */ - function getInfo() - { - return $this->info; - } - - /** - * recieve error code - * - * @access public - * @return string|integer error code (may be a string or an integer) - * @see $code - */ - function getCode() - { - return $this->code; - } - - /** - * get the backtrace - * - * This is only possible, if debug_backtrace() is available. - * - * @access public - * @return array backtrace - * @see $backtrace - */ - function getBacktrace( $formatted=false ) - { - if ($formatted && is_array( $this->backtrace )) { - $result = ''; - foreach( debug_backtrace() as $back) { - if (!eregi( 'patErrorManager.php', $back['file'])) { - $result .= '
    '.$back['file'].':'.$back['line']; - } - } - return $result; - } - return $this->backtrace; - } - - /** - * get the filename in which the error occured - * - * This is only possible, if debug_backtrace() is available. - * - * @access public - * @return string filename - * @see $file - */ - function getFile() - { - return $this->file; - } - - /** - * get the line number in which the error occured - * - * This is only possible, if debug_backtrace() is available. - * - * @access public - * @return integer line number - * @see $line - */ - function getLine() - { - return $this->line; - } -} -?> \ No newline at end of file + + * @author Sebastian Mordziol + * @author Stephan Schmidt + * @license LGPL + * @link http://www.php-tools.net + */ +class patError +{ + /** + * stores the error level for this error + * + * @access private + * @var string + */ + var $level = null; + + /** + * stores the code of the error + * + * @access private + * @var string + */ + var $code = null; + + /** + * stores the error message - this is the message that can also be shown the + * user if need be. + * + * @access private + * @var string + */ + var $message = null; + + /** + * additional info that is relevant for the developer of the script (e.g. if + * a database connect fails, the dsn used) and that the end-user should not + * see. + * + * @access private + * @var string + */ + var $info = ''; + + /** + * stores the filename of the file the error occurred in. + * + * @access private + * @var string + */ + var $file = ''; + + /** + * stores the line number the error occurred in. + * + * @access private + * @var integer + */ + var $line = 0; + + /** + * stores the name of the method the error occurred in + * + * @access private + * @var string + */ + var $function = ''; + + /** + * stores the name of the class (if any) the error occurred in. + * + * @access private + * @var string + */ + var $class = ''; + + /** + * stores the type of error, as it is listed in the error backtrace + * + * @access private + * @var string + */ + var $type = ''; + + /** + * stores the arguments the method that the error occurred in had received. + * + * @access private + * @var array + */ + var $args = array(); + + /** + * stores the complete debug backtrace (if your PHP version has the + * debug_backtrace function) + * + * @access private + * @var mixed + */ + var $backtrace = false; + + /** + * constructor, wrapper for the upcoming PHP5 constructors for upward + * compatibility. + * + * @access public + * @param int $level The error level (use the PHP constants E_ALL, E_NOTICE etc.). + * @param string $code The error code from the application + * @param string $msg The error message + * @param string $info Optional: The additional error information. + * @see __construct() + */ + function patError( $level, $code, $msg, $info = null ) + { + $this->__construct( $level, $code, $msg, $info ); + } + + /** + * constructor - used to set up the error with all needed error details. + * + * @access public + * @param int $level The error level (use the PHP constants E_ALL, E_NOTICE etc.). + * @param string $code The error code from the application + * @param string $msg The error message + * @param string $info Optional: The additional error information. + * @todo all calls to patErrorManager::raise* should not be included in backtrace + */ + function __construct( $level, $code, $msg, $info = null ) + { + static $raise = array( 'raise', + 'raiseerror', + 'raisewarning', + 'raisenotice' + ); + + $this->level = $level; + $this->code = $code; + $this->message = $msg; + + if( $info != null ) + { + $this->info = $info; + } + + if( function_exists( 'debug_backtrace' ) ) + { + $this->backtrace = debug_backtrace(); + + for( $i = count( $this->backtrace ) - 1; $i >= 0; --$i ) + { + if( in_array( $this->backtrace[$i]['function'], $raise ) ) + { + ++$i; + if( isset( $this->backtrace[$i]['file'] ) ) + $this->file = $this->backtrace[$i]['file']; + if( isset( $this->backtrace[$i]['line'] ) ) + $this->line = $this->backtrace[$i]['line']; + if( isset( $this->backtrace[$i]['class'] ) ) + $this->class = $this->backtrace[$i]['class']; + if( isset( $this->backtrace[$i]['function'] ) ) + $this->function = $this->backtrace[$i]['function']; + if( isset( $this->backtrace[$i]['type'] ) ) + $this->type = $this->backtrace[$i]['type']; + + $this->args = false; + if( isset( $this->backtrace[$i]['args'] ) ) + { + $this->args = $this->backtrace[$i]['args']; + } + break; + } + } + } + } + + /** + * returns the error level of the error - corresponds to the PHP + * error levels (E_ALL, E_NOTICE...) + * + * @access public + * @return int $level The error level + * @see $level + */ + function getLevel() + { + return $this->level; + } + + + /** + * retrieves the error message + * + * @access public + * @return string $msg The stored error message + * @see $message + */ + function getMessage() + { + return $this->message; + } + + /** + * retrieves the additional error information (information usually + * only relevant for developers) + * + * @access public + * @return mixed $info The additional information + * @see $info + */ + function getInfo() + { + return $this->info; + } + + /** + * recieve error code + * + * @access public + * @return string|integer error code (may be a string or an integer) + * @see $code + */ + function getCode() + { + return $this->code; + } + + /** + * get the backtrace + * + * This is only possible, if debug_backtrace() is available. + * + * @access public + * @return array backtrace + * @see $backtrace + */ + function getBacktrace( $formatted=false ) + { + if ($formatted && is_array( $this->backtrace )) { + $result = ''; + foreach( debug_backtrace() as $back) { + if (!preg_match( '#patErrorManager.php#i', $back['file'])) { + $result .= '
    '.$back['file'].':'.$back['line']; + } + } + return $result; + } + return $this->backtrace; + } + + /** + * get the filename in which the error occured + * + * This is only possible, if debug_backtrace() is available. + * + * @access public + * @return string filename + * @see $file + */ + function getFile() + { + return $this->file; + } + + /** + * get the line number in which the error occured + * + * This is only possible, if debug_backtrace() is available. + * + * @access public + * @return integer line number + * @see $line + */ + function getLine() + { + return $this->line; + } +} +?> diff --git a/oss/joomla/trunk/libraries/pattemplate/patErrorManager.php b/oss/joomla/trunk/libraries/pattemplate/patErrorManager.php index 8531dd0d..418d93e6 100644 --- a/oss/joomla/trunk/libraries/pattemplate/patErrorManager.php +++ b/oss/joomla/trunk/libraries/pattemplate/patErrorManager.php @@ -1,710 +1,710 @@ - array( 'mode' => 'echo' ), - E_WARNING => array( 'mode' => 'echo' ), - E_ERROR => array( 'mode' => 'die' ) - ); - -/** - * available error levels - * Stored in a variable to keep them flexible - */ -$GLOBALS['_pat_errorLevels'] = array( - E_NOTICE => 'Notice', - E_WARNING => 'Warning', - E_ERROR => 'Error' - ); -/** - * error class names - * Stored in a variable allows to change during runtime - */ -$GLOBALS['_pat_errorClass'] = 'patError'; - -/** - * ignore errors - * Store error-codes that will be ignored forever - */ -$GLOBALS['_pat_errorIgnores'] = array(); - -/** - * expects errors - * Store error-codes that will be ignored once - */ -$GLOBALS['_pat_errorExpects'] = array(); - - -/** - * patErrorManager main error management class used by pat tools for the - * application-internal error management. Creates patError objects for - * any errors for precise error management. - * - * @static - * @package patError - * @version 0.3 - * @author gERD Schaufelberger - * @author Stephan Schmidt - * @license LGPL - * @link http://www.php-tools.net - * @todo implement ignoreError() to ignore errrors with a certain code - * @todo implement expectError() to ignore an error with a certain code only once. - */ -class patErrorManager -{ - /** - * method for checking whether the return value of a pat application method is a pat - * error object. - * - * @static - * @access public - * @param mixed &$object - * @return boolean $result True if argument is a patError-object, false otherwise. - */ - function isError( &$object ) - { - if( !is_object( $object ) ) - { - return false; - } - - - - if( strtolower(get_class( $object )) != strtolower( $GLOBALS['_pat_errorClass'] ) && !is_subclass_of( $object, $GLOBALS['_pat_errorClass'] ) ) - { - return false; - } - - return true; - } - - /** - * wrapper for the {@link raise()} method where you do not have to specify the - * error level - a {@link patError} object with error level E_ERROR will be returned. - * - * @static - * @access public - * @param string $code The application-internal error code for this error - * @param string $msg The error message, which may also be shown the user if need be. - * @param mixed $info Optional: Additional error information (usually only developer-relevant information that the user should never see, like a database DSN). - * @return object $error The configured patError object - * @see raise() - * @see patError - */ - function &raiseError( $code, $msg, $info = null ) - { - return patErrorManager::raise( E_ERROR, $code, $msg, $info ); - } - - /** - * wrapper for the {@link raise()} method where you do not have to specify the - * error level - a {@link patError} object with error level E_WARNING will be returned. - * - * @static - * @access public - * @param string $code The application-internal error code for this error - * @param string $msg The error message, which may also be shown the user if need be. - * @param mixed $info Optional: Additional error information (usually only developer-relevant information that the user should never see, like a database DSN). - * @return object $error The configured patError object - * @see raise() - * @see patError - */ - function &raiseWarning( $code, $msg, $info = null ) - { - return patErrorManager::raise( E_WARNING, $code, $msg, $info ); - } - - /** - * wrapper for the {@link raise()} method where you do not have to specify the - * error level - a {@link patError} object with error level E_NOTICE will be returned. - * - * @static - * @access public - * @param string $code The application-internal error code for this error - * @param string $msg The error message, which may also be shown the user if need be. - * @param mixed $info Optional: Additional error information (usually only developer-relevant information that the user should never see, like a database DSN). - * @return object $error The configured patError object - * @see raise() - * @see patError - */ - function &raiseNotice( $code, $msg, $info = null ) - { - return patErrorManager::raise( E_NOTICE, $code, $msg, $info ); - } - - /** - * creates a new patError object given the specified information. - * - * @access public - * @param int $level The error level - use any of PHP's own error levels for this: E_ERROR, E_WARNING, E_NOTICE, E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE. - * @param string $code The application-internal error code for this error - * @param string $msg The error message, which may also be shown the user if need be. - * @param mixed $info Optional: Additional error information (usually only developer-relevant information that the user should never see, like a database DSN). - * @return mixed $error The configured patError object or false if this error should be ignored - * @see patError - * @todo implement 'simple' mode that returns just false (BC for patConfiguration) - * @todo either remove HTML tags and entities from output or test for enviroment!!! in shell is ugly! - */ - function &raise( $level, $code, $msg, $info = null ) - { - // ignore this error? - if( in_array( $code, $GLOBALS['_pat_errorIgnores'] ) ) - { - return false; - } - - // this error was expected - if( !empty( $GLOBALS['_pat_errorExpects'] ) ) - { - $expected = array_pop( $GLOBALS['_pat_errorExpects'] ); - if( in_array( $code, $expected ) ) - { - return false; - } - } - - // need patError - $class = $GLOBALS['_pat_errorClass']; - if( !class_exists( $class ) ) - { - include_once dirname( __FILE__ ) . '/'. $class .'.php'; - } - - // build error object - $error =& new $class( $level, $code, $msg, $info ); - - // see what to do with this kind of error - $handling = patErrorManager::getErrorHandling( $level ); - - $function = 'handleError' . ucfirst( $handling['mode'] ); - if (is_callable( array( 'patErrorManager', $function ) )) { - return patErrorManager::$function( $error, $handling ); - } else { - // This is required to prevent a very unhelpful white-screen-of-death - jexit( - 'JError::raise -> Static method JError::' . $function . ' does not exist.' . - ' Contact a developer to debug' . - '
    Error was ' . - '
    ' . $error->getMessage() - ); - } - } - - /** - * register a new error level - * - * This allows you to add custom error levels to the built-in - * - E_NOTICE - * - E_WARNING - * - E_NOTICE - * - * You may use this level in subsequent calls to raise(). - * Error handling will be set to 'ignore' for the new level, you - * may change it by using setErrorHandling(). - * - * You could be using PHP's predefined constants for error levels - * or any other integer value. - * - * @access public - * @param integer error level - * @param string human-readable name - * @return boolean true on success; false if the level already has been registered - * @see raise(), setErrorHandling() - * @link http://www.php.net/manual/en/function.error-reporting.php - */ - function registerErrorLevel( $level, $name ) - { - if( isset( $GLOBALS['_pat_errorLevels'][$level] ) ) - { - return false; - } - $GLOBALS['_pat_errorLevels'][$level] = $name; - patErrorManager::setErrorHandling( $level, 'ignore' ); - return true; - } - - /** - * sets the way the patErrorManager will handle teh different error levels. Use this - * if you want to override the default settings. - * - * Error handling modes: - * - ignore - * - trigger - * - verbose - * - echo - * - callback - * - die - * - * You may also set the error handling for several modes at once using PHP's bit operations. - * Examples: - * - E_ALL = Set the handling for all levels - * - E_ERROR | E_WARNING = Set the handling for errors and warnings - * - E_ALL ^ E_ERROR = Set the handling for all levels except errors - * - * @static - * @access public - * @param int $level The error level for which to set the error handling - * @param string $mode The mode to use for the error handling. - * @param mixed $options Optional: Any options needed for the given mode. - * @return mixed $result True on success, or a patError object if failed. - * @see getErrorHandling() - */ - function setErrorHandling( $level, $mode, $options = null ) - { - $levels = $GLOBALS['_pat_errorLevels']; - - $function = 'handleError' . ucfirst( $mode ); - if( !is_callable( array( 'patErrorManager', $function ) ) ) - { - return patErrorManager::raiseError( E_ERROR, - 'patErrorManager:' . PATERRORMANAGER_ERROR_ILLEGAL_MODE, - 'Error Handling mode is not knwon', - 'Mode: ' . $mode . ' is not implemented.' - ); - } - - foreach( $levels as $eLevel => $eTitle ) - { - if( ( $level & $eLevel ) != $eLevel ) - { - continue; - } - - // set callback options - if( $mode == 'callback' ) - { - if( !is_array( $options ) ) - { - return patErrorManager::raiseError( E_ERROR, - 'patErrorManager:' . PATERRORMANAGER_ERROR_ILLEGAL_OPTIONS, - 'Options for callback not valid' - ); - } - - if( !is_callable( $options ) ) - { - $tmp = array( 'GLOBAL' ); - if( is_array( $options ) ) - { - $tmp[0] = $options[0]; - $tmp[1] = $options[1]; - } - else - { - $tmp[1] = $options; - } - - return patErrorManager::raiseError( E_ERROR, - 'patErrorManager:' . PATERRORMANAGER_ERROR_CALLBACK_NOT_CALLABLE, - 'Function is not callable', - 'Function:' . $tmp[1] . ' scope ' . $tmp[0] . '.' - ); - } - } - - - // save settings - $GLOBALS['_pat_errorHandling'][$eLevel] = array( 'mode' => $mode ); - if( $options != null ) - { - $GLOBALS['_pat_errorHandling'][$eLevel]['options'] = $options; - } - } - - return true; - } - - /** - * retrieves the current error handling settings for the specified error level. - * - * @access public - * @param int $level The error level to retrieve. This can be any of PHP's own error levels, e.g. E_ALL, E_NOTICE... - * @return array $handling All error handling details - */ - function getErrorHandling( $level ) - { - return $GLOBALS['_pat_errorHandling'][$level]; - } - - /** - * translate an error level - * - * returns the human-readable name for an error level, - * e.g. E_ERROR will be translated to 'Error'. - * - * @access public - * @param integer error level - * @return string human-readable representation - */ - function translateErrorLevel( $level ) - { - if( isset( $GLOBALS['_pat_errorLevels'][$level] ) ) - { - return $GLOBALS['_pat_errorLevels'][$level]; - } - return 'Unknown error level'; - } - - /** - * setErrorClass - * - * In order to autoload this class, the filename containing that class must be - * named like the class itself; with an appending ".php". Although the file must be stored - * in the same directory as patErrorManager.php (this file) - * - * @access public - * @param string $name classname - * @return boolean $result true on success - */ - function setErrorClass( $name ) - { - // include old error-class - if( $name !== $GLOBALS['_pat_errorClass'] && !class_exists( $GLOBALS['_pat_errorClass'] ) ) - { - include_once dirname( __FILE__ ) . '/' . $GLOBALS['_pat_errorClass'] . '.php'; - } - - $GLOBALS['_pat_errorClass'] = $name; - return true; - } - - /** - * add error codes to be ingored - * - * @static - * @access public - * @param mixed $codes either an array of error code or a single code that will be ignored in future - * @return boolean $result true on success - */ - function addIgnore( $codes ) - { - if( !is_array( $codes ) ) - { - $codes = array( $codes ); - } - - $codes = array_merge( $GLOBALS['_pat_errorIgnores'], $codes ); - $GLOBALS['_pat_errorIgnores'] = array_unique( $codes ); - - return true; - } - - /** - * removeIgnore - * - * - * @static - * @access public - * @return boolean $result true on success - */ - function removeIgnore( $codes ) - { - if( !is_array( $codes ) ) - { - $codes = array( $codes ); - } - - foreach( $codes as $code ) - { - $index = array_search( $code, $GLOBALS['_pat_errorIgnores'] ); - if( $index === false ) - { - continue; - } - - unset( $GLOBALS['_pat_errorIgnores'][$index] ); - } - - // reorder the codes - $GLOBALS['_pat_errorIgnores'] = array_values( $GLOBALS['_pat_errorIgnores'] ); - - return true; - } - - /** - * recieve all registerd error codes that will be ignored - * - * @static - * @access public - * @return array $codes list of error codes - */ - function getIgnore() - { - return $GLOBALS['_pat_errorIgnores']; - } - - /** - * empty list of errors to be ignored - * - * @static - * @access public - * @return boolean $result true on success - */ - function clearIgnore() - { - $GLOBALS['_pat_errorIgnores'] = array(); - return true; - } - - /** - * add expected errors to stack - * - * @static - * @access public - * @param mixed $codes either an array of error code or a single code that will be ignored in future - * @return boolean $result true on success - */ - function pushExpect( $codes ) - { - if( !is_array( $codes ) ) - { - $codes = array( $codes ); - } - - array_push( $GLOBALS['_pat_errorExpects'], $codes ); - - return true; - } - - /** - * remove top of error-codes from stack - * - * @static - * @access public - * @return boolean $result true on success - */ - function popExpect() - { - if( empty( $GLOBALS['_pat_errorExpects'] ) ) - { - return false; - } - - array_pop( $GLOBALS['_pat_errorExpects'] ); - return true; - } - - /** - * recieve all registerd error codes that will be ignored - * - * @static - * @access public - * @return array $codes list of error codes - */ - function getExpect() - { - return $GLOBALS['_pat_errorExpects']; - } - - /** - * empty list of errors to be ignored - * - * @static - * @access public - * @return boolean $result true on success - */ - function clearExpect() - { - $GLOBALS['_pat_errorExpects'] = array(); - return true; - } - - /** - * handleError: Ignore - * Does nothing - * - * @access private - * @param object $error patError-Object - * @param array $options options for handler - * @return object $error error-object - * @see raise() - */ - function &handleErrorIgnore( &$error, $options ) - { - return $error; - } - - /** - * handleError: Echo - * display error message - * - * @access private - * @param object $error patError-Object - * @param array $options options for handler - * @return object $error error-object - * @see raise() - */ - function &handleErrorEcho( &$error, $options ) - { - $level_human = patErrorManager::translateErrorLevel( $error->getLevel() ); - - if( isset( $_SERVER['HTTP_HOST'] ) ) - { - // output as html - echo "
    pat-$level_human: " . $error->getMessage() . "
    \n"; - } - else - { - // output as simple text - if( defined( 'STDERR' ) ) - { - fwrite( STDERR, "pat-$level_human: " . $error->getMessage() . "\n" ); - } - else - { - echo "pat-$level_human: " . $error->getMessage() . "\n"; - } - } - return $error; - } - - /** - * handleError: Verbose - * display verbose output for developing purpose - * - * @access private - * @param object $error patError-Object - * @param array $options options for handler - * @return object $error error-object - * @see raise() - */ - function &handleErrorVerbose( &$error, $options ) - { - $level_human = patErrorManager::translateErrorLevel( $error->getLevel() ); - $info = $error->getInfo(); - - if( isset( $_SERVER['HTTP_HOST'] ) ) - { - // output as html - echo "
    pat-$level_human: " . $error->getMessage() . "
    \n"; - if( $info != null ) - { - echo "   " . $error->getInfo() . "
    \n"; - } - echo $error->getBacktrace( true ); - } - else - { - // output as simple text - echo "pat-$level_human: " . $error->getMessage() . "\n"; - if( $info != null ) - { - echo " " . $error->getInfo() . "\n"; - } - - } - return $error; - } - - /** - * handleError: die - * display error-message and die - * - * @access private - * @param object $error patError-Object - * @param array $options options for handler - * @return object $error error-object - * @see raise() - */ - function &handleErrorDie( &$error, $options ) - { - $level_human = patErrorManager::translateErrorLevel( $error->getLevel() ); - - if( isset( $_SERVER['HTTP_HOST'] ) ) - { - // output as html - jexit( "
    pat-$level_human " . $error->getMessage() . "
    \n" ); - } - else - { - // output as simple text - if( defined( 'STDERR' ) ) - { - fwrite( STDERR, "pat-$level_human " . $error->getMessage() . "\n" ); - } - else - { - jexit( "pat-$level_human " . $error->getMessage() . "\n" ); - } - } - return $error; - } - - /** - * handleError: trigger - * trigger php-error - * - * @access private - * @param object $error patError-Object - * @param array $options options for handler - * @return object $error error-object - * @see raise() - */ - function &handleErrorTrigger( &$error, $options ) - { - switch( $error->getLevel() ) - { - case E_NOTICE: - $level = E_USER_NOTICE; - break; - case E_WARNING: - $level = E_USER_WARNING; - break; - case E_NOTICE: - $level = E_NOTICE; - break; - default: - $level = E_USER_ERROR; - break; - } - - trigger_error( $error->getMessage(), $level ); - return $error; - } - - /** - * handleError: callback - * forward error to custom handler - * - * @access private - * @param object $error patError-Object - * @param array $options options for handler - * @return object $error error-object - * @see raise() - */ - function &handleErrorCallback( &$error, $options ) - { - $opt = $options['options']; - $result = &call_user_func( $opt, $error ); - return $result; - } -} -?> \ No newline at end of file + array( 'mode' => 'echo' ), + E_WARNING => array( 'mode' => 'echo' ), + E_ERROR => array( 'mode' => 'die' ) + ); + +/** + * available error levels + * Stored in a variable to keep them flexible + */ +$GLOBALS['_pat_errorLevels'] = array( + E_NOTICE => 'Notice', + E_WARNING => 'Warning', + E_ERROR => 'Error' + ); +/** + * error class names + * Stored in a variable allows to change during runtime + */ +$GLOBALS['_pat_errorClass'] = 'patError'; + +/** + * ignore errors + * Store error-codes that will be ignored forever + */ +$GLOBALS['_pat_errorIgnores'] = array(); + +/** + * expects errors + * Store error-codes that will be ignored once + */ +$GLOBALS['_pat_errorExpects'] = array(); + + +/** + * patErrorManager main error management class used by pat tools for the + * application-internal error management. Creates patError objects for + * any errors for precise error management. + * + * @static + * @package patError + * @version 0.3 + * @author gERD Schaufelberger + * @author Stephan Schmidt + * @license LGPL + * @link http://www.php-tools.net + * @todo implement ignoreError() to ignore errrors with a certain code + * @todo implement expectError() to ignore an error with a certain code only once. + */ +class patErrorManager +{ + /** + * method for checking whether the return value of a pat application method is a pat + * error object. + * + * @static + * @access public + * @param mixed &$object + * @return boolean $result True if argument is a patError-object, false otherwise. + */ + function isError( &$object ) + { + if( !is_object( $object ) ) + { + return false; + } + + + + if( strtolower(get_class( $object )) != strtolower( $GLOBALS['_pat_errorClass'] ) && !is_subclass_of( $object, $GLOBALS['_pat_errorClass'] ) ) + { + return false; + } + + return true; + } + + /** + * wrapper for the {@link raise()} method where you do not have to specify the + * error level - a {@link patError} object with error level E_ERROR will be returned. + * + * @static + * @access public + * @param string $code The application-internal error code for this error + * @param string $msg The error message, which may also be shown the user if need be. + * @param mixed $info Optional: Additional error information (usually only developer-relevant information that the user should never see, like a database DSN). + * @return object $error The configured patError object + * @see raise() + * @see patError + */ + function &raiseError( $code, $msg, $info = null ) + { + return patErrorManager::raise( E_ERROR, $code, $msg, $info ); + } + + /** + * wrapper for the {@link raise()} method where you do not have to specify the + * error level - a {@link patError} object with error level E_WARNING will be returned. + * + * @static + * @access public + * @param string $code The application-internal error code for this error + * @param string $msg The error message, which may also be shown the user if need be. + * @param mixed $info Optional: Additional error information (usually only developer-relevant information that the user should never see, like a database DSN). + * @return object $error The configured patError object + * @see raise() + * @see patError + */ + function &raiseWarning( $code, $msg, $info = null ) + { + return patErrorManager::raise( E_WARNING, $code, $msg, $info ); + } + + /** + * wrapper for the {@link raise()} method where you do not have to specify the + * error level - a {@link patError} object with error level E_NOTICE will be returned. + * + * @static + * @access public + * @param string $code The application-internal error code for this error + * @param string $msg The error message, which may also be shown the user if need be. + * @param mixed $info Optional: Additional error information (usually only developer-relevant information that the user should never see, like a database DSN). + * @return object $error The configured patError object + * @see raise() + * @see patError + */ + function &raiseNotice( $code, $msg, $info = null ) + { + return patErrorManager::raise( E_NOTICE, $code, $msg, $info ); + } + + /** + * creates a new patError object given the specified information. + * + * @access public + * @param int $level The error level - use any of PHP's own error levels for this: E_ERROR, E_WARNING, E_NOTICE, E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE. + * @param string $code The application-internal error code for this error + * @param string $msg The error message, which may also be shown the user if need be. + * @param mixed $info Optional: Additional error information (usually only developer-relevant information that the user should never see, like a database DSN). + * @return mixed $error The configured patError object or false if this error should be ignored + * @see patError + * @todo implement 'simple' mode that returns just false (BC for patConfiguration) + * @todo either remove HTML tags and entities from output or test for enviroment!!! in shell is ugly! + */ + function &raise( $level, $code, $msg, $info = null ) + { + // ignore this error? + if( in_array( $code, $GLOBALS['_pat_errorIgnores'] ) ) + { + return false; + } + + // this error was expected + if( !empty( $GLOBALS['_pat_errorExpects'] ) ) + { + $expected = array_pop( $GLOBALS['_pat_errorExpects'] ); + if( in_array( $code, $expected ) ) + { + return false; + } + } + + // need patError + $class = $GLOBALS['_pat_errorClass']; + if( !class_exists( $class ) ) + { + include_once dirname( __FILE__ ) . '/'. $class .'.php'; + } + + // build error object + $error = new $class( $level, $code, $msg, $info ); + + // see what to do with this kind of error + $handling = patErrorManager::getErrorHandling( $level ); + + $function = 'handleError' . ucfirst( $handling['mode'] ); + if (is_callable( array( 'patErrorManager', $function ) )) { + return patErrorManager::$function( $error, $handling ); + } else { + // This is required to prevent a very unhelpful white-screen-of-death + jexit( + 'JError::raise -> Static method JError::' . $function . ' does not exist.' . + ' Contact a developer to debug' . + '
    Error was ' . + '
    ' . $error->getMessage() + ); + } + } + + /** + * register a new error level + * + * This allows you to add custom error levels to the built-in + * - E_NOTICE + * - E_WARNING + * - E_NOTICE + * + * You may use this level in subsequent calls to raise(). + * Error handling will be set to 'ignore' for the new level, you + * may change it by using setErrorHandling(). + * + * You could be using PHP's predefined constants for error levels + * or any other integer value. + * + * @access public + * @param integer error level + * @param string human-readable name + * @return boolean true on success; false if the level already has been registered + * @see raise(), setErrorHandling() + * @link http://www.php.net/manual/en/function.error-reporting.php + */ + function registerErrorLevel( $level, $name ) + { + if( isset( $GLOBALS['_pat_errorLevels'][$level] ) ) + { + return false; + } + $GLOBALS['_pat_errorLevels'][$level] = $name; + patErrorManager::setErrorHandling( $level, 'ignore' ); + return true; + } + + /** + * sets the way the patErrorManager will handle teh different error levels. Use this + * if you want to override the default settings. + * + * Error handling modes: + * - ignore + * - trigger + * - verbose + * - echo + * - callback + * - die + * + * You may also set the error handling for several modes at once using PHP's bit operations. + * Examples: + * - E_ALL = Set the handling for all levels + * - E_ERROR | E_WARNING = Set the handling for errors and warnings + * - E_ALL ^ E_ERROR = Set the handling for all levels except errors + * + * @static + * @access public + * @param int $level The error level for which to set the error handling + * @param string $mode The mode to use for the error handling. + * @param mixed $options Optional: Any options needed for the given mode. + * @return mixed $result True on success, or a patError object if failed. + * @see getErrorHandling() + */ + function setErrorHandling( $level, $mode, $options = null ) + { + $levels = $GLOBALS['_pat_errorLevels']; + + $function = 'handleError' . ucfirst( $mode ); + if( !is_callable( array( 'patErrorManager', $function ) ) ) + { + return patErrorManager::raiseError( E_ERROR, + 'patErrorManager:' . PATERRORMANAGER_ERROR_ILLEGAL_MODE, + 'Error Handling mode is not knwon', + 'Mode: ' . $mode . ' is not implemented.' + ); + } + + foreach( $levels as $eLevel => $eTitle ) + { + if( ( $level & $eLevel ) != $eLevel ) + { + continue; + } + + // set callback options + if( $mode == 'callback' ) + { + if( !is_array( $options ) ) + { + return patErrorManager::raiseError( E_ERROR, + 'patErrorManager:' . PATERRORMANAGER_ERROR_ILLEGAL_OPTIONS, + 'Options for callback not valid' + ); + } + + if( !is_callable( $options ) ) + { + $tmp = array( 'GLOBAL' ); + if( is_array( $options ) ) + { + $tmp[0] = $options[0]; + $tmp[1] = $options[1]; + } + else + { + $tmp[1] = $options; + } + + return patErrorManager::raiseError( E_ERROR, + 'patErrorManager:' . PATERRORMANAGER_ERROR_CALLBACK_NOT_CALLABLE, + 'Function is not callable', + 'Function:' . $tmp[1] . ' scope ' . $tmp[0] . '.' + ); + } + } + + + // save settings + $GLOBALS['_pat_errorHandling'][$eLevel] = array( 'mode' => $mode ); + if( $options != null ) + { + $GLOBALS['_pat_errorHandling'][$eLevel]['options'] = $options; + } + } + + return true; + } + + /** + * retrieves the current error handling settings for the specified error level. + * + * @access public + * @param int $level The error level to retrieve. This can be any of PHP's own error levels, e.g. E_ALL, E_NOTICE... + * @return array $handling All error handling details + */ + function getErrorHandling( $level ) + { + return $GLOBALS['_pat_errorHandling'][$level]; + } + + /** + * translate an error level + * + * returns the human-readable name for an error level, + * e.g. E_ERROR will be translated to 'Error'. + * + * @access public + * @param integer error level + * @return string human-readable representation + */ + function translateErrorLevel( $level ) + { + if( isset( $GLOBALS['_pat_errorLevels'][$level] ) ) + { + return $GLOBALS['_pat_errorLevels'][$level]; + } + return 'Unknown error level'; + } + + /** + * setErrorClass + * + * In order to autoload this class, the filename containing that class must be + * named like the class itself; with an appending ".php". Although the file must be stored + * in the same directory as patErrorManager.php (this file) + * + * @access public + * @param string $name classname + * @return boolean $result true on success + */ + function setErrorClass( $name ) + { + // include old error-class + if( $name !== $GLOBALS['_pat_errorClass'] && !class_exists( $GLOBALS['_pat_errorClass'] ) ) + { + include_once dirname( __FILE__ ) . '/' . $GLOBALS['_pat_errorClass'] . '.php'; + } + + $GLOBALS['_pat_errorClass'] = $name; + return true; + } + + /** + * add error codes to be ingored + * + * @static + * @access public + * @param mixed $codes either an array of error code or a single code that will be ignored in future + * @return boolean $result true on success + */ + function addIgnore( $codes ) + { + if( !is_array( $codes ) ) + { + $codes = array( $codes ); + } + + $codes = array_merge( $GLOBALS['_pat_errorIgnores'], $codes ); + $GLOBALS['_pat_errorIgnores'] = array_unique( $codes ); + + return true; + } + + /** + * removeIgnore + * + * + * @static + * @access public + * @return boolean $result true on success + */ + function removeIgnore( $codes ) + { + if( !is_array( $codes ) ) + { + $codes = array( $codes ); + } + + foreach( $codes as $code ) + { + $index = array_search( $code, $GLOBALS['_pat_errorIgnores'] ); + if( $index === false ) + { + continue; + } + + unset( $GLOBALS['_pat_errorIgnores'][$index] ); + } + + // reorder the codes + $GLOBALS['_pat_errorIgnores'] = array_values( $GLOBALS['_pat_errorIgnores'] ); + + return true; + } + + /** + * recieve all registerd error codes that will be ignored + * + * @static + * @access public + * @return array $codes list of error codes + */ + function getIgnore() + { + return $GLOBALS['_pat_errorIgnores']; + } + + /** + * empty list of errors to be ignored + * + * @static + * @access public + * @return boolean $result true on success + */ + function clearIgnore() + { + $GLOBALS['_pat_errorIgnores'] = array(); + return true; + } + + /** + * add expected errors to stack + * + * @static + * @access public + * @param mixed $codes either an array of error code or a single code that will be ignored in future + * @return boolean $result true on success + */ + function pushExpect( $codes ) + { + if( !is_array( $codes ) ) + { + $codes = array( $codes ); + } + + array_push( $GLOBALS['_pat_errorExpects'], $codes ); + + return true; + } + + /** + * remove top of error-codes from stack + * + * @static + * @access public + * @return boolean $result true on success + */ + function popExpect() + { + if( empty( $GLOBALS['_pat_errorExpects'] ) ) + { + return false; + } + + array_pop( $GLOBALS['_pat_errorExpects'] ); + return true; + } + + /** + * recieve all registerd error codes that will be ignored + * + * @static + * @access public + * @return array $codes list of error codes + */ + function getExpect() + { + return $GLOBALS['_pat_errorExpects']; + } + + /** + * empty list of errors to be ignored + * + * @static + * @access public + * @return boolean $result true on success + */ + function clearExpect() + { + $GLOBALS['_pat_errorExpects'] = array(); + return true; + } + + /** + * handleError: Ignore + * Does nothing + * + * @access private + * @param object $error patError-Object + * @param array $options options for handler + * @return object $error error-object + * @see raise() + */ + function &handleErrorIgnore( &$error, $options ) + { + return $error; + } + + /** + * handleError: Echo + * display error message + * + * @access private + * @param object $error patError-Object + * @param array $options options for handler + * @return object $error error-object + * @see raise() + */ + function &handleErrorEcho( &$error, $options ) + { + $level_human = patErrorManager::translateErrorLevel( $error->getLevel() ); + + if( isset( $_SERVER['HTTP_HOST'] ) ) + { + // output as html + echo "
    pat-$level_human: " . $error->getMessage() . "
    \n"; + } + else + { + // output as simple text + if( defined( 'STDERR' ) ) + { + fwrite( STDERR, "pat-$level_human: " . $error->getMessage() . "\n" ); + } + else + { + echo "pat-$level_human: " . $error->getMessage() . "\n"; + } + } + return $error; + } + + /** + * handleError: Verbose + * display verbose output for developing purpose + * + * @access private + * @param object $error patError-Object + * @param array $options options for handler + * @return object $error error-object + * @see raise() + */ + function &handleErrorVerbose( &$error, $options ) + { + $level_human = patErrorManager::translateErrorLevel( $error->getLevel() ); + $info = $error->getInfo(); + + if( isset( $_SERVER['HTTP_HOST'] ) ) + { + // output as html + echo "
    pat-$level_human: " . $error->getMessage() . "
    \n"; + if( $info != null ) + { + echo "   " . $error->getInfo() . "
    \n"; + } + echo $error->getBacktrace( true ); + } + else + { + // output as simple text + echo "pat-$level_human: " . $error->getMessage() . "\n"; + if( $info != null ) + { + echo " " . $error->getInfo() . "\n"; + } + + } + return $error; + } + + /** + * handleError: die + * display error-message and die + * + * @access private + * @param object $error patError-Object + * @param array $options options for handler + * @return object $error error-object + * @see raise() + */ + function &handleErrorDie( &$error, $options ) + { + $level_human = patErrorManager::translateErrorLevel( $error->getLevel() ); + + if( isset( $_SERVER['HTTP_HOST'] ) ) + { + // output as html + jexit( "
    pat-$level_human " . $error->getMessage() . "
    \n" ); + } + else + { + // output as simple text + if( defined( 'STDERR' ) ) + { + fwrite( STDERR, "pat-$level_human " . $error->getMessage() . "\n" ); + } + else + { + jexit( "pat-$level_human " . $error->getMessage() . "\n" ); + } + } + return $error; + } + + /** + * handleError: trigger + * trigger php-error + * + * @access private + * @param object $error patError-Object + * @param array $options options for handler + * @return object $error error-object + * @see raise() + */ + function &handleErrorTrigger( &$error, $options ) + { + switch( $error->getLevel() ) + { + case E_NOTICE: + $level = E_USER_NOTICE; + break; + case E_WARNING: + $level = E_USER_WARNING; + break; + case E_NOTICE: + $level = E_NOTICE; + break; + default: + $level = E_USER_ERROR; + break; + } + + trigger_error( $error->getMessage(), $level ); + return $error; + } + + /** + * handleError: callback + * forward error to custom handler + * + * @access private + * @param object $error patError-Object + * @param array $options options for handler + * @return object $error error-object + * @see raise() + */ + function &handleErrorCallback( &$error, $options ) + { + $opt = $options['options']; + $result = &call_user_func( $opt, $error ); + return $result; + } +} +?> diff --git a/oss/joomla/trunk/libraries/pattemplate/patTemplate.php b/oss/joomla/trunk/libraries/pattemplate/patTemplate.php index f9238ca0..14db34c8 100644 --- a/oss/joomla/trunk/libraries/pattemplate/patTemplate.php +++ b/oss/joomla/trunk/libraries/pattemplate/patTemplate.php @@ -1,2670 +1,2670 @@ - - * @license LGPL - * @link http://www.php-tools.net - */ - -// ** Following line Joomla! specific ** -require_once( dirname( __FILE__ ) . '/patErrorManager.php' ); - -/** - * template already exists - */ -define( 'PATTEMPLATE_ERROR_TEMPLATE_EXISTS', 5010 ); - -/** - * template does not exist - */ -define ( 'PATTEMPLATE_WARNING_NO_TEMPLATE', 5011 ); - -/** - * unknown type - */ -define ( 'PATTEMPLATE_WARNING_UNKNOWN_TYPE', 5012 ); - -/** - * base class for module could not be found - */ -define( 'PATTEMPLATE_ERROR_BASECLASS_NOT_FOUND', 5050 ); - -/** - * module could not be found - */ -define( 'PATTEMPLATE_ERROR_MODULE_NOT_FOUND', 5051 ); - -/** - * array expected - */ -define( 'PATTEMPLATE_ERROR_EXPECTED_ARRAY', 5052 ); - -/** - * No input - */ -define( 'PATTEMPLATE_ERROR_NO_INPUT', 6000 ); -/** - * Recursion - */ -define( 'PATTEMPLATE_ERROR_RECURSION', 6010 ); - -/** - * patTemplate - * - * powerful templating engine - * - * @version 3.1.0 - * @package patTemplate - * @author Stephan Schmidt - * @license LGPL - * @link http://www.php-tools.net - */ -class patTemplate -{ - /** - * standard system vars that identify pat tools - * @var array - */ - var $_systemVars = array( - 'appName' => 'patTemplate', - 'appVersion' => '3.1.0', - 'author' => array( - 'Stephan Schmidt ' - ) - ); - - /** - * default attributes for new templates - * @access private - * @var array - */ - var $_defaultAttributes = array( - 'type' => 'standard', - 'visibility' => 'visible', - 'loop' => 1, - 'unusedvars' => 'strip', - 'whitespace' => 'keep', - 'autoclear' => 'off', - 'autoload' => 'on' - ); - - /** - * options for patTemplate - * - * Currently the following options are implemented: - * - maintainBc defines, whether patTemplate should be backwards compatible. - * This means, that you may use 'default' and 'empty' for subtemplates. - * - * @access private - * @var array - */ - var $_options = array( - 'startTag' => '{', - 'endTag' => '}', - 'root' => array('__default' => '.'), - 'namespace' => 'patTemplate', - 'maintainBc' => true, - 'defaultFunction' => false - ); - - /** - * start tag - * - * @access private - * @var string - */ - var $_startTag = '{'; - - /** - * end tag - * - * @access private - * @var string - */ - var $_endTag = '}'; - - /** - * loaded modules - * - * Modules are: - * - Readers - * - Caches - * - Variable modifiers - * - Filters - * - * @access private - * @var array - */ - var $_modules = array(); - - /** - * directories, where modules can be stored - * @access private - * @var array - */ - var $_moduleDirs = array(); - - /** - * stores all template names - * @access private - * @var array - */ - var $_templateList = array(); - - /** - * stores all template data - * @access private - * @var array - */ - var $_templates = array(); - - /** - * stores all global variables - * @access private - * @var array - */ - var $_globals = array(); - - /** - * stores all local variables - * @access private - * @var array - */ - var $_vars = array(); - - /** - * stores the name of the first template that has been - * found - * - * @access private - * @var string - */ - var $_root; - - /** - * output filters that should be used - * - * @access private - * @var array - */ - var $_outputFilters = array(); - - /** - * input filters that should be used - * - * @access private - * @var array - */ - var $_inputFilters = array(); - - /** - * template cache, that should be used - * - * @access private - * @var array - */ - var $_tmplCache = null; - - /** - * placeholders, that have been discovered - * - * @access private - * @var array - */ - var $_discoveredPlaceholders = array(); - - /** - * Create a new patTemplate instance. - * - * The constructor accepts the type of the templates as sole parameter. - * You may choose one of: - * - html (default) - * - tex - * - * The type influences the tags you are using in your templates. - * - * @access public - * @param string type (either html or tex) - */ - function patTemplate( $type = 'html' ) - { - if( !defined( 'PATTEMPLATE_INCLUDE_PATH' ) ) { - define( 'PATTEMPLATE_INCLUDE_PATH', dirname( __FILE__ ) . '/patTemplate' ); - } - - $this->setType( $type ); - } - - /** - * sets an option - * - * Currently, the following options are supported - * - maintainBc (true|false) - * - namespace (string) - * - * @access public - * @param string option to set - * @param string value of the option - */ - function setOption($option, $value) - { - $this->_options[$option] = $value; - } - - /** - * gets an option - * - * @access public - * @param string option to get - * @return mixed value of the option - */ - function getOption( $option ) - { - if (!isset($this->_options[$option])) { - return null; - } - return $this->_options[$option]; - } - - /** - * sets name of directory where templates are stored - * - * @access public - * @param string dir where templates are stored - * @deprecated please use patTemplate::setRoot() instead - */ - function setBasedir($basedir) - { - $this->setRoot($basedir); - } - - /** - * sets root base for the template - * - * The parameter depends on the reader you are using. - * - * @access public - * @param string root base of the templates - */ - function setRoot($root, $reader = '__default') - { - $this->_options['root'][$reader] = $root; - } - - /** - * gets name of root base for the templates - * - * @access public - * @return mixed root base - */ - function getRoot($reader = '__default') - { - return $this->_options['root'][$reader]; - } - - /** - * sets namespace of patTemplate tags - * - * If you want to use more than one namespace, you may set this to - * an array. All tags in these namespaces will be treated as patTemplate - * tags. - * - * @access public - * @param string|array namespace(s) - */ - function setNamespace($ns) - { - $this->_options['namespace'] = $ns; - } - - /** - * gets namespace of patTemplate tags - * - * @access public - * @return string|array namespace(s) - */ - function getNamespace() - { - return $this->_options['namespace']; - } - - /** - * set default attribute - * - * @access public - * @param string attribute name - * @param mixed attribute value - */ - function setDefaultAttribute( $name, $value ) - { - $this->_defaultAttributes[$name] = $value; - } - - /** - * set default attributes - * - * @access public - * @param array attributes - */ - function setDefaultAttributes( $attributes ) - { - $this->_defaultAttributes = array_merge( $this->_defaultAttributes, $attributes ); - } - - /** - * get default attributes - * - * @access public - * @return return default attributes - */ - function getDefaultAttributes() - { - return $this->_defaultAttributes; - } - - /** - * set the type for the templates - * - * @access public - * @param string type (html or tex) - * @return boolean true on success - */ - function setType( $type ) - { - switch( strtolower( $type ) ) - { - case "tex": - $this->setTags( '<{', '}>' ); - break; - case "html": - $this->setTags( '{', '}' ); - break; - default: - return patErrorManager::raiseWarning( - PATTEMPLATE_WARNING_UNKNOWN_TYPE, - "Unknown type '$type'. Please use 'html' or 'tex'." - ); - } - return true; - } - - /** - * set the start and end tag for variables - * - * @access public - * @param string start tag - * @param string end tag - * @return boolean true on success - */ - function setTags( $startTag, $endTag ) - { - $this->_options['startTag'] = $startTag; - $this->_options['endTag'] = $endTag; - - $this->_startTag = $startTag; - $this->_endTag = $endTag; - return true; - } - - /** - * get start tag for variables - * - * @access public - * @return string start tag - */ - function getStartTag() - { - return $this->_options['startTag']; - } - - /** - * get end tag for variables - * - * @access public - * @return string end tag - */ - function getEndTag() - { - return $this->_options['endTag']; - } - - /** - * add a directory where patTemplate should search for - * modules. - * - * You may either pass a string or an array of directories. - * - * patTemplate will be searching for a module in the same - * order you added them. If the module cannot be found in - * the custom folders, it will look in - * patTemplate/$moduleType. - * - * @access public - * @param string module type - * @param string|array directory or directories to search. - */ - function addModuleDir( $moduleType, $dir ) - { - if( !isset( $this->_moduleDirs[$moduleType] ) ) - $this->_moduleDirs[$moduleType] = array(); - if( is_array( $dir ) ) - $this->_moduleDirs[$moduleType] = array_merge( $this->_moduleDirs[$moduleType], $dir ); - else - array_push( $this->_moduleDirs[$moduleType], $dir ); - } - - /** - * Sets an attribute of a template - * - * supported attributes: visibilty, loop, parse, unusedvars - * - * @param string $template name of the template - * @param string $attribute name of the attribute - * @param mixed $value value of the attribute - * @access public - * @see setAttributes(),getAttribute(), clearAttribute() - */ - function setAttribute( $template, $attribute, $value ) - { - $template = strtolower( $template ); - if( !isset( $this->_templates[$template] ) ) - { - return patErrorManager::raiseWarning( - PATTEMPLATE_WARNING_NO_TEMPLATE, - "Template '$template' does not exist." - ); - } - - $attribute = strtolower( $attribute ); - $this->_templates[$template]['attributes'][$attribute] = $value; - return true; - } - - /** - * Sets several attribute of a template - * - * $attributes has to be a assotiative arrays containing attribute/value pairs - * supported attributes: visibilty, loop, parse, unusedvars - * - * @param string $template name of the template - * @param array $attributes attribute/value pairs - * @access public - * @see setAttribute(), getAttribute(), clearAttribute() - */ - function setAttributes( $template, $attributes ) - { - if( !is_array( $attributes ) ) - { - return patErrorManager::raiseError( PATTEMPLATE_ERROR_EXPECTED_ARRAY, 'patTemplate::setAttributes: Expected array as second parameter, '.gettype( $attributes ).' given' ); - } - - $template = strtolower( $template ); - $attributes = array_change_key_case( $attributes ); - if( !isset( $this->_templates[$template] ) ) - { - return patErrorManager::raiseWarning( - PATTEMPLATE_WARNING_NO_TEMPLATE, - "Template '$template' does not exist." - ); - } - - $this->_templates[$template]['attributes'] = array_merge( $this->_templates[$template]['attributes'], $attributes ); - return true; - } - - /** - * Get all attributes of a template - * - * @param string name of the template - * @return array attributes - * @access public - */ - function getAttributes( $template ) - { - $template = strtolower( $template ); - if( !isset( $this->_templates[$template] ) ) - { - return patErrorManager::raiseWarning( - PATTEMPLATE_WARNING_NO_TEMPLATE, - "Template '$template' does not exist." - ); - } - return $this->_templates[$template]['attributes']; - } - - /** - * Gets an attribute of a template - * - * supported attributes: visibilty, loop, parse, unusedvars - * - * @param string $template name of the template - * @param string $attribute name of the attribute - * @return mixed value of the attribute - * @access public - * @see setAttribute(), setAttributes(), clearAttribute() - */ - function getAttribute( $template, $attribute ) - { - $template = strtolower( $template ); - $attribute = strtolower( $attribute ); - if( !isset( $this->_templates[$template] ) ) - { - return patErrorManager::raiseWarning( - PATTEMPLATE_WARNING_NO_TEMPLATE, - "Template '$template' does not exist." - ); - } - return $this->_templates[$template]['attributes'][$attribute]; - } - - /** - * Clears an attribute of a template - * - * supported attributes: visibilty, loop, parse, unusedvars - * - * @param string $template name of the template - * @param string $attribute name of the attribute - * @access public - * @see setAttribute(), setAttributes(), getAttribute() - */ - function clearAttribute( $template, $attribute ) - { - $template = strtolower( $template ); - $attribute = strtolower( $attribute ); - - if( !isset( $this->_templates[$template] ) ) - { - return patErrorManager::raiseWarning( - PATTEMPLATE_WARNING_NO_TEMPLATE, - "Template '$template' does not exist." - ); - } - $this->_templates[$template]['attributes'][$attribute] = '';; - return true; - } - - /** - * Prepare a template - * - * This can be used if you want to add variables to - * a template, that has not been loaded yet. - * - * @access public - * @param string template name - */ - function prepareTemplate( $name ) - { - $name = strtolower( $name ); - if( !isset( $this->_vars[$name] ) ) - { - $this->_vars[$name] = array( - 'scalar' => array(), - 'rows' => array() - ); - } - } - - /** - * add a variable to a template - * - * A variable may also be an indexed array, but _not_ - * an associative array! - * - * @access public - * @param string $template name of the template - * @param string $varname name of the variable - * @param mixed $value value of the variable - */ - function addVar( $template, $varname, $value ) - { - $template = strtolower( $template ); - $varname = strtoupper( $varname ); - - if( !is_array( $value ) ) { - $this->_vars[$template]['scalar'][$varname] = $value; - return true; - } - - $cnt = count( $value ); - for ($i = 0; $i < $cnt; $i++) { - if (!isset( $this->_vars[$template]['rows'][$i] )) { - $this->_vars[$template]['rows'][$i] = array(); - } - $this->_vars[$template]['rows'][$i][$varname] = $value[$i]; - } - - return true; - } - - /** - * get the value of a variable - * - * @access public - * @param string name of the template - * @param string name of the variable - * @return string value of the variable, null if the variable is not set - */ - function getVar( $template, $varname ) - { - $template = strtolower( $template ); - $varname = strtoupper( $varname ); - - if( isset( $this->_vars[$template]['scalar'][$varname] ) ) - return $this->_vars[$template]['scalar'][$varname]; - - $value = array(); - - if(!isset($this->_vars[$template]['rows'])) - return null; - - $cnt = count( $this->_vars[$template]['rows'] ); - for( $i = 0; $i < $cnt; $i++ ) - { - if( !isset( $this->_vars[$template]['rows'][$i][$varname] ) ) - continue; - array_push( $value, $this->_vars[$template]['rows'][$i][$varname] ); - } - if( !empty( $value ) ) - return $value; - return null; - } - - /** - * clear the value of a variable - * - * @access public - * @param string name of the template - * @param string name of the variable - * @return boolean - * @see clearVars(), clearTemplate() - */ - function clearVar( $template, $varname ) - { - $template = strtolower( $template ); - $varname = strtoupper( $varname ); - - if (isset( $this->_vars[$template]['scalar'][$varname] )) { - unset ($this->_vars[$template]['scalar'][$varname]); - return true; - } - - $result = false; - $cnt = count( $this->_vars[$template]['rows'] ); - for ($i = 0; $i < $cnt; $i++) { - if (!isset($this->_vars[$template]['rows'][$i][$varname])) { - continue; - } - unset($this->_vars[$template]['rows'][$i][$varname]); - $result = true; - } - return $result; - } - - - /** - * Adds several variables to a template - * - * Each Template can have an unlimited amount of its own variables - * $variables has to be an assotiative array containing variable/value pairs - * - * @param string $template name of the template - * @param array $variables assotiative array of the variables - * @param string $prefix prefix for all variable names - * @access public - * @see addVar(), addRows(), addGlobalVar(), addGlobalVars() - */ - function addVars( $template, $variables, $prefix = '' ) - { - $template = strtolower( $template ); - $prefix = strtoupper( $prefix ); - $variables = array_change_key_case( $variables, CASE_UPPER ); - - foreach ($variables as $varname => $value) { - $varname = $prefix.$varname; - - if (!is_array($value)) { - if (!is_scalar($value)) { - continue; - } - $this->_vars[$template]['scalar'][$varname] = $value; - continue; - } - - $cnt = count( $value ); - for( $i = 0; $i < $cnt; $i++ ) { - if( !isset( $this->_vars[$template]['rows'][$i] ) ) - $this->_vars[$template]['rows'][$i] = array(); - - $this->_vars[$template]['rows'][$i][$varname] = $value[$i]; - } - } - } - - /** - * Clear all variables in a template - * - * This clears only variables, but does - * - * @access public - * @param string $template name of the template - * @return boolean - * @see clearVar(), clearTemplate() - */ - function clearVars( $template ) - { - $template = strtolower($template); - $this->_vars[$template] = array( - 'scalar' => array(), - 'rows' => array() - ); - return true; - } - - - /** - * Adds several rows of variables to a template - * - * Each Template can have an unlimited amount of its own variables - * Can be used to add a database result as variables to a template - * - * @param string $template name of the template - * @param array $rows array containing assotiative arrays with variable/value pairs - * @param string $prefix prefix for all variable names - * @access public - * @see addVar(), addVars(), addGlobalVar(), addGlobalVars() - */ - function addRows( $template, $rows, $prefix = '' ) - { - $template = strtolower( $template ); - $prefix = strtoupper( $prefix ); - - $cnt = count( $rows ); - for( $i = 0; $i < $cnt; $i++ ) - { - if( !isset( $this->_vars[$template]['rows'][$i] ) ) - $this->_vars[$template]['rows'][$i] = array(); - - $rows[$i] = array_change_key_case( $rows[$i], CASE_UPPER ); - - foreach( $rows[$i] as $varname => $value ) - { - $this->_vars[$template]['rows'][$i][$prefix.$varname] = $value; - } - } - } - - /** - * Adds an object to a template - * - * All properties of the object will be available as template variables. - * - * @access public - * @param string name of the template - * @param object|array object or array of objects - * @param string prefix for all variable names - * @param boolean ignore private properties (starting with _) - * @see addVar(), addRows(), addGlobalVar(), addGlobalVars() - */ - function addObject( $template, $object, $prefix = '', $ignorePrivate = false ) - { - if( is_array( $object ) ) { - $rows = array(); - foreach($object as $o) { - array_push( $rows, $this->getObjectVars($o, $ignorePrivate) ); - } - - return $this->addRows( $template, $rows, $prefix ); - } elseif (is_object($object)) { - return $this->addVars( $template, $this->getObjectVars($object, $ignorePrivate), $prefix ); - } - return false; - } - - /** - * get the vars from an object - * - * @access private - * @param object - * @param boolean ignore private properties (starting with _) - * @return array - */ - function getObjectVars($obj, $ignorePrivate = false) - { - if (method_exists($obj, 'getVars')) { - return $obj->getVars(); - } - $vars = get_object_vars($obj); - if ($ignorePrivate === false) { - return $vars; - } - foreach ($vars as $var => $value) { - if ($var{0} == '_') { - unset($vars[$var]); - } - } - return $vars; - } - - /** - * Adds a global variable - * - * Global variables are valid in all templates of this object. - * A global variable has to be scalar, it will be converted to a string. - * - * @access public - * @param string $varname name of the global variable - * @param string $value value of the variable - * @return boolean true on success - * @see addGlobalVars(), addVar(), addVars(), addRows() - */ - function addGlobalVar( $varname, $value ) - { - $this->_globals[strtoupper( $varname )] = ( string )$value; - return true; - } - - /** - * Clears a global variable - * - * @access public - * @param string $varname name of the global variable - * @return boolean true on success - * @see clearVar(), clearVars(), clearGlobalVars() - */ - function clearGlobalVar( $varname ) - { - $varname = strtoupper( $varname ); - if (!isset($this->_globals[$varname])) { - return false; - } - unset($this->_globals[$varname]); - return true; - } - - /** - * Clears all global variables - * - * @access public - * @return boolean true on success - * @see clearVar(), clearVars(), clearGlobalVar() - */ - function clearGlobalVars() - { - $this->_globals = array(); - return true; - } - - /** - * Adds several global variables - * - * Global variables are valid in all templates of this object. - * - * $variables is an associative array, containing name/value pairs of the variables. - * - * @access public - * @param array $variables array containing the variables - * @param string $prefix prefix for variable names - * @return boolean true on success - * @see addGlobalVar(), addVar(), addVars(), addRows() - */ - function addGlobalVars( $variables, $prefix = '' ) - { - $variables = array_change_key_case( $variables, CASE_UPPER ); - $prefix = strtoupper( $prefix ); - foreach( $variables as $varname => $value ) - { - $this->_globals[$prefix.$varname] = ( string )$value; - } - - return true; - } - - /** - * get all global variables - * - * @access public - * @return array global variables - */ - function getGlobalVars() - { - return $this->_globals; - } - - /** - * checks wether a template exists - * - * @access public - * @param string name of the template - * @return boolean true, if the template exists, false otherwise - */ - function exists( $name ) - { - return in_array( strtolower( $name ), $this->_templateList ); - } - - /** - * enable a template cache - * - * A template cache will improve performace, as the templates - * do not have to be read on each request. - * - * @access public - * @param string name of the template cache - * @param array parameters for the template cache - * @return boolean true on success, patError otherwise - */ - function useTemplateCache( $cache, $params = array() ) - { - if( !is_object( $cache ) ) - { - $cache = &$this->loadModule( 'TemplateCache', $cache, $params ); - } - if( patErrorManager::isError( $cache ) ) - return $cache; - - $this->_tmplCache = &$cache; - return true; - } - - /** - * enable an output filter - * - * Output filters are used to modify the template - * result before it is sent to the browser. - * - * They are applied, when displayParsedTemplate() is called. - * - * @access public - * @param string name of the output filter - * @param array parameters for the output filter - * @return boolean true on success, patError otherwise - */ - function applyOutputFilter( $filter, $params = array(), $template = null ) - { - if (!is_object($filter)) { - $filter = &$this->loadModule( 'OutputFilter', $filter, $params ); - } - if (patErrorManager::isError($filter)) { - return $filter; - } - - if ($template === null) { - $this->_outputFilters[] = &$filter; - return true; - } - - $template = strtolower($template); - if (!$this->exists($template)) { - return patErrorManager::raiseWarning(PATTEMPLATE_WARNING_NO_TEMPLATE, 'The selected template does not exist'); - } - $this->_templates[$template]['attributes']['outputfilter'] = &$filter; - return true; - } - - /** - * enable an input filter - * - * input filters are used to modify the template - * stream before it is split into smaller templates- - * - * @access public - * @param string name of the input filter - * @param array parameters for the input filter - * @return boolean true on success, patError otherwise - */ - function applyInputFilter( $filter, $params = array() ) - { - if( !is_object( $filter ) ) - { - $filter = &$this->loadModule( 'InputFilter', $filter, $params ); - } - if( patErrorManager::isError( $filter ) ) - return $filter; - - $this->_inputFilters[] = &$filter; - return true; - } - - /** - * open a file and parse for patTemplate tags - * - * @access public - * @param name of the file - * @return true, if the template could be parsed - * @deprecated Use patTemplate::readTemplatesFromInput() instead, as the method name is misleading - * @see readTemplatesFromInput() - */ - function readTemplatesFromFile( $filename ) - { - return $this->readTemplatesFromInput( $filename, 'File' ); - } - - /** - * open any input and parse for patTemplate tags - * - * @access public - * @param string name of the input (filename, shm segment, etc.) - * @param string driver that is used as reader, you may also pass a Reader object - * @param array additional options that will only be used for this template - * @param string name of the template that should be used as a container, should not be used by public - * calls. - * @return boolean true, if the template could be parsed, false otherwise - */ - function readTemplatesFromInput( $input, $reader = 'File', $options = null, $parseInto = null ) - { - if ((string)$input === '') { - return patErrorManager::raiseError(PATTEMPLATE_ERROR_NO_INPUT, 'No input to read has been passed.'); - } - - if (is_array($options)) { - $options = array_merge( $this->_options, $options ); - } else { - $options = $this->_options; - } - - if (!is_null($parseInto)) { - $parseInto = strtolower( $parseInto ); - } - - $templates = false; - if ($this->_tmplCache !== null) { - /** - * get the unique cache key - */ - $key = $this->_tmplCache->getKey($input, $options); - - $templates = $this->_loadTemplatesFromCache( $input, $reader, $options, $key ); - - /** - * check for error returned from cache - */ - if (patErrorManager::isError($templates)) { - return $templates; - } - } - - /** - * templates have not been loaded from cache - */ - if ($templates === false) { - if (!is_object( $reader)) { - $reader = &$this->loadModule('Reader', $reader); - if (patErrorManager::isError($reader)) { - return $reader; - } - } - - if ($reader->isInUse()) { - $reader = &$this->loadModule( 'Reader', $reader->getName(), array(), true); - if( patErrorManager::isError( $reader ) ) { - return $reader; - } - } - - $reader->setOptions($options); - - /** - * set the root attributes - */ - if( !is_null( $parseInto ) ) - { - $attributes = $this->getAttributes( $parseInto ); - if( !patErrorManager::isError( $attributes ) ) - { - $reader->setRootAttributes( $attributes ); - } - } - - $templates = $reader->readTemplates( $input ); - - /** - * check for error returned from reader - */ - if( patErrorManager::isError( $templates ) ) - return $templates; - - /** - * store the - */ - if( $this->_tmplCache !== null ) - { - $this->_tmplCache->write( $key, $templates ); - } - } - - /** - * traverse all templates - */ - foreach( $templates as $name => $spec ) - { - - /** - * root template - */ - if( $name == '__ptroot' ) - { - if( $parseInto === false ) - { - continue; - } - if( !in_array( $parseInto, $this->_templateList ) ) - continue; - - $spec['loaded'] = true; - $spec['attributes'] = $this->_templates[$parseInto]['attributes']; - $name = $parseInto; - } - else - { - /** - * store the name - */ - array_push( $this->_templateList, $name ); - } - - /** - * if this is the first template that has been loaded - * set it as the root template - */ - if( $this->_root === null && is_null( $parseInto ) && isset( $spec['isRoot'] ) && $spec['isRoot'] == true ) - { - $this->_root = $name; - } - - /** - * set some default values - */ - $spec['iteration'] = 0; - $spec['lastMode'] = 'w'; - $spec['result'] = ''; - $spec['modifyVars'] = array(); - $spec['copyVars'] = array(); - $spec['defaultVars'] = array(); - - /** - * store the template - */ - $this->_templates[$name] = $spec; - - $this->prepareTemplate( $name ); - - /** - * store the default values of the variables - */ - foreach( $spec['varspecs'] as $varname => $varspec ) - { - if (isset($varspec['modifier'])) { - $this->_templates[$name]['modifyVars'][$varname] = $varspec['modifier']; - } - - if( isset( $varspec['copyfrom'] ) ) - { - $this->_templates[$name]['copyVars'][$varname] = $varspec['copyfrom']; - } - - if( !isset( $varspec['default'] ) ) - continue; - - $this->_templates[$name]['defaultVars'][$varname] = $varspec['default']; - - if( !is_null( $this->getVar( $name, $varname ) ) ) - continue; - - $this->addVar( $name, $varname, $varspec['default'] ); - } - - unset($this->_templates[$name]['varspecs']); - - /** - * autoload the template - * - * Some error management is needed here... - */ - if( isset( $this->_templates[$name]['attributes']['src'] ) && $this->_templates[$name]['attributes']['autoload'] == 'on' ) - { - if( $this->_templates[$name]['loaded'] !== true ) - { - if( $this->_templates[$name]['attributes']['parse'] == 'on' ) - { - $this->readTemplatesFromInput( $this->_templates[$name]['attributes']['src'], $this->_templates[$name]['attributes']['reader'], $options, $name ); - } - else - { - $this->loadTemplateFromInput( $this->_templates[$name]['attributes']['src'], $this->_templates[$name]['attributes']['reader'], null, $name ); - } - $this->_templates[$name]['loaded'] = true; - } - } - } - - return true; - } - - /** - * load from template cache - * - * @access private - * @param string name of the input (filename, shm segment, etc.) - * @param string driver that is used as reader, you may also pass a Reader object - * @param array options for the reader - * @param string cache key - * @return array|boolean either an array containing the templates, or false - */ - function _loadTemplatesFromCache( $input, &$reader, $options, $key ) - { - if( is_object( $reader ) ) - $statName = $reader->getName(); - else - $statName = $reader; - - $stat = &$this->loadModule( 'Stat', $statName ); - $stat->setOptions( $options ); - - /** - * get modification time - */ - $modTime = $stat->getModificationTime( $input ); - $templates = $this->_tmplCache->load( $key, $modTime ); - - return $templates; - } - - /** - * open any input and load content into template - * - * @access public - * @param string name of the input (filename, shm segment, etc.) - * @param string driver that is used as reader - * @param string name of the template that should be used as a container, - * @return boolean true, if the template could be parsed, false otherwise - */ - function loadTemplateFromInput( $input, $reader = 'File', $options = null, $parseInto = false ) - { - if( is_array( $options ) ) - $options = array_merge( $this->_options, $options ); - else - $options = $this->_options; - - if( !is_null( $parseInto ) ) - $parseInto = strtolower( $parseInto ); - - $reader = &$this->loadModule( 'Reader', $reader ); - if( patErrorManager::isError( $reader ) ) - { - return $reader; - } - $reader->setOptions($options); - - $result = $reader->loadTemplate( $input ); - - if( patErrorManager::isError( $result ) ) - { - return $result; - } - - $this->_templates[$parseInto]['content'] .= $result; - $this->_templates[$parseInto]['loaded'] = true; - return true; - } - - /** - * load a template that had autoload="off" - * - * This is needed, if you change the source of a template and want to - * load it, after changing the attribute. - * - * @access public - * @param string template name - * @return boolean true, if template could be loaded - */ - function loadTemplate( $template ) - { - $template = strtolower( $template ); - if( !isset( $this->_templates[$template] ) ) - { - return patErrorManager::raiseWarning( - PATTEMPLATE_WARNING_NO_TEMPLATE, - "Template '$template' does not exist." - ); - } - - if( $this->_templates[$template]['loaded'] === true ) - return true; - - if( $this->_templates[$template]['attributes']['parse'] == 'on' ) - { - return $this->readTemplatesFromInput( $this->_templates[$template]['attributes']['src'], $this->_templates[$template]['attributes']['reader'], null, $template ); - } - else - { - return $this->loadTemplateFromInput( $this->_templates[$template]['attributes']['src'], $this->_templates[$template]['attributes']['reader'], null, $template ); - } - } - - /** - * loads a patTemplate module - * - * Modules are located in the patTemplate folder and include: - * - Readers - * - Caches - * - Variable Modifiers - * - Filters - * - Functions - * - Stats - * - * @access public - * @param string moduleType (Reader|TemplateCache|Modifier|OutputFilter|InputFilter) - * @param string moduleName - * @param array parameters for the module - * @return object - */ - function &loadModule( $moduleType, $moduleName, $params = array(), $new = false ) - { - if( !isset( $this->_modules[$moduleType] ) ) - $this->_modules[$moduleType] = array(); - - $sig = md5( $moduleName . serialize( $params ) ); - - if( isset( $this->_modules[$moduleType][$sig] ) && $new === false ) { - return $this->_modules[$moduleType][$sig]; - } - - if( !class_exists( 'patTemplate_Module' ) ) - { - $file = sprintf( "%s/Module.php", $this->getIncludePath() ); - if( !file_exists( $file ) or !include_once $file ) - return patErrorManager::raiseError( PATTEMPLATE_ERROR_BASECLASS_NOT_FOUND, 'Could not load module base class.' ); - } - - $baseClass = 'patTemplate_' . $moduleType; - if( !class_exists( $baseClass ) ) - { - $baseFile = sprintf( "%s/%s.php", $this->getIncludePath(), $moduleType ); - if( !file_exists( $baseFile ) or !include_once $baseFile ) - return patErrorManager::raiseError( PATTEMPLATE_ERROR_BASECLASS_NOT_FOUND, "Could not load base class for $moduleType ($baseFile)." ); - } - - $moduleClass = 'patTemplate_' . $moduleType . '_' .$moduleName; - if( !class_exists( $moduleClass ) ) - { - if( isset( $this->_moduleDirs[$moduleType] ) ) - $dirs = $this->_moduleDirs[$moduleType]; - else - $dirs = array(); - array_push( $dirs, $this->getIncludePath() .'/'. $moduleType ); - - $found = false; - foreach( $dirs as $dir ) - { - $moduleFile = sprintf( "%s/%s.php", $dir, str_replace( '_', '/', $moduleName ) ); - - if ( file_exists( $moduleFile ) and include_once $moduleFile) { - $found = true; - break; - } - } - - if( !$found ) { - return patErrorManager::raiseError( PATTEMPLATE_ERROR_MODULE_NOT_FOUND, "Could not load module $moduleClass ($moduleFile)." ); - } - } - - if( !class_exists( $moduleClass ) ) - { - return patErrorManager::raiseError( PATTEMPLATE_ERROR_MODULE_NOT_FOUND, "Module file $moduleFile does not contain class $moduleClass." ); - } - - $this->_modules[$moduleType][$sig] = &new $moduleClass; - if( method_exists( $this->_modules[$moduleType][$sig], 'setTemplateReference' ) ) - { - $this->_modules[$moduleType][$sig]->setTemplateReference( $this ); - } - - $this->_modules[$moduleType][$sig]->setParams( $params ); - - return $this->_modules[$moduleType][$sig]; - } - - /** - * checks whether a module exists. - * - * Modules are located in the patTemplate folder and include: - * - Readers - * - Caches - * - Variable Modifiers - * - Filters - * - Functions - * - Stats - * - * @access public - * @param string moduleType (Reader|TemplateCache|Modifier|OutputFilter|InputFilter) - * @param string moduleName - * @return boolean - */ - function moduleExists( $moduleType, $moduleName ) - { - // !!!JOOMLA VARIATION!!! - // cache checks on files - static $paths; - - if (!$paths) - { - $paths = array(); - } - - if (isset($this->_moduleDirs[$moduleType])) { - $dirs = $this->_moduleDirs[$moduleType]; - } else { - $dirs = array(); - } - array_push($dirs, $this->getIncludePath() .'/'. $moduleType); - - foreach ($dirs as $dir) { - $moduleFile = sprintf( "%s/%s.php", $dir, str_replace( '_', '/', $moduleName ) ); - if (!isset( $paths[$moduleFile] )) - { - if (!file_exists($moduleFile)) { - $paths[$moduleFile] = false; - } - else if (!is_readable($moduleFile)) { - $paths[$moduleFile] = false; - } - else - { - $paths[$moduleFile] = true; - } - } - - if (!$paths[$moduleFile]) { - continue; - } - return true; - } - return false; - } - - /** - * parses a template - * - * Parses a template and stores the parsed content. - * mode can be "w" for write (delete already parsed content) or "a" for append (appends the - * new parsed content to the already parsed content) - * - * @access public - * @param string name of the template - * @param string mode for the parsing - */ - function parseTemplate( $template, $mode = 'w' ) - { - $template = strtolower($template); - - if (!isset($this->_templates[$template])) { - return patErrorManager::raiseWarning( - PATTEMPLATE_WARNING_NO_TEMPLATE, - "Template '$template' does not exist." - ); - } - - /** - * template is not visible - */ - if ($this->_templates[$template]['attributes']['visibility'] == 'hidden') { - $this->_templates[$template]['result'] = ''; - $this->_templates[$template]['parsed'] = true; - return true; - } - - /** - * check, if the template has been loaded - * and load it if necessary. - */ - if ($this->_templates[$template]['loaded'] !== true) { - if ($this->_templates[$template]['attributes']['parse'] == 'on') { - $result = $this->readTemplatesFromInput( $this->_templates[$template]['attributes']['src'], $this->_templates[$template]['attributes']['reader'], null, $template ); - } else { - $result = $this->loadTemplateFromInput( $this->_templates[$template]['attributes']['src'], $this->_templates[$template]['attributes']['reader'], null, $template ); - } - if (patErrorManager::isError($result)) { - return $result; - } - } - - /** - * check for autoclear - */ - if( - isset( $this->_templates[$template]['attributes']['autoclear'] ) && - $this->_templates[$template]['attributes']['autoclear'] == 'yes' && - $mode === 'w' && - $this->_templates[$template]['lastMode'] != 'a' - ) { - $this->_templates[$template]['parsed'] = false; - } - - /** - * template has been parsed and mode is not 'append' - */ - if ($this->_templates[$template]['parsed'] === true && $mode === 'w') { - return true; - } - - $this->_templates[$template]['lastMode'] = $mode; - - $this->_initTemplate( $template ); - - if (!isset($this->_vars[$template]['rows'])) { - $this->_vars[$template]['rows'] = array(); - } - $loop = count( $this->_vars[$template]['rows'] ); - - /** - * loop at least one times - */ - if ($loop < 1) { - $loop = 1; - } - - if (isset($this->_templates[$template]['attributes']['maxloop'])) { - $loop = ceil( $loop / $this->_templates[$template]['attributes']['maxloop'] ) * $this->_templates[$template]['attributes']['maxloop']; - } - - $this->_templates[$template]['loop'] = max( $this->_templates[$template]['attributes']['loop'], $loop ); - - $start = 0; - if (isset($this->_templates[$template]['attributes']['limit'])) { - $p = strpos( $this->_templates[$template]['attributes']['limit'], ',' ); - if ($p === false) { - $this->_templates[$template]['loop'] = min( $this->_templates[$template]['loop'], $this->_templates[$template]['attributes']['limit'] ); - $start = 0; - } else { - $start = substr( $this->_templates[$template]['attributes']['limit'], 0, $p ); - $end = substr( $this->_templates[$template]['attributes']['limit'], $p+1 )+$start; - - $this->_templates[$template]['loop'] = min( $this->_templates[$template]['loop'], $end ); - } - } - - /** - * template should be cleared before parsing - */ - if ($mode == 'w') { - $this->_templates[$template]['result'] = ''; - $this->_templates[$template]['iteration'] = $start; - } - - $loopCount = 0; - for ($i = $start; $i < $this->_templates[$template]['loop']; $i++) { - $finished = false; - - unset( $this->_templates[$template]['vars'] ); - - /** - * fetch the variables - */ - $this->_fetchVariables( $template ); - - /** - * fetch the template - */ - $result = $this->_fetchTemplate($template); - - if ($result === false) { - $this->_templates[$template]['iteration']++; - continue; - } - - /** - * parse - */ - $this->_parseVariables( $template ); - $result = $this->_parseDependencies( $template ); - if (patErrorManager::isError($result)) { - return $result; - } - - /** - * store result - */ - $this->_templates[$template]['result'] .= $this->_templates[$template]['work']; - - $this->_templates[$template]['iteration']++; - - ++$loopCount; - - /** - * check for maximum loops - */ - if (isset($this->_templates[$template]['attributes']['maxloop'])) { - if ($loopCount == $this->_templates[$template]['attributes']['maxloop'] && $i < ($loop-1)) { - $loopCount = 0; - $finished = true; - $this->_templates[$template]['parsed'] = true; - $this->parseTemplate( $this->_templates[$template]['attributes']['parent'], 'a' ); - $this->_templates[$template]['parsed'] = false; - $this->_templates[$template]['result'] = ''; - } - } - } - - if (!$finished && isset($this->_templates[$template]['attributes']['maxloop'])) { - $this->_templates[$template]['parsed'] = true; - $this->parseTemplate( $this->_templates[$template]['attributes']['parent'], 'a', false ); - $this->_templates[$template]['parsed'] = false; - $this->_templates[$template]['result'] = ''; - $this->_templates[$this->_templates[$template]['attributes']['parent']]['work'] = ''; - } - - $this->_parseGlobals($template); - - $this->_handleUnusedVars($template); - - $this->_templates[$template]['parsed'] = true; - - if (isset($this->_templates[$template]['attributes']['autoclear']) && $this->_templates[$template]['attributes']['autoclear'] == 'yes') { - $this->_vars[$template] = array( - 'scalar' => array(), - 'rows' => array() - ); - } - - if (isset($this->_templates[$template]['attributes']['outputfilter'])) { - if (is_object($this->_templates[$template]['attributes']['outputfilter'])) { - $filter = &$this->_templates[$template]['attributes']['outputfilter']; - } else { - $filter = &$this->loadModule('OutputFilter', $this->_templates[$template]['attributes']['outputfilter']); - } - - if (patErrorManager::isError($filter)) { - return $filter; - } - - $this->_templates[$template]['result'] = $filter->apply($this->_templates[$template]['result']); - } - return true; - } - - /** - * Initialize a template - * - * This method checks the variable specifications and - * copys variables from other templates. - * - * @access private - * @param string name of the template - * @return boolean true on success - */ - function _initTemplate( $template ) - { - foreach( $this->_templates[$template]['copyVars'] as $dest => $src ) - { - /** - * copy from the same template - */ - if( !is_array( $src ) ) - { - $srcTemplate = $template; - $srcVar = $src; - } - else - { - $srcTemplate = $src[0]; - $srcVar = $src[1]; - } - - $copied = false; - - /** - * copy from another template - */ - if( isset( $this->_vars[$srcTemplate] ) ) - { - if( isset( $this->_vars[$srcTemplate]['scalar'][$srcVar] ) ) - { - $this->_vars[$template]['scalar'][$dest] = $this->_vars[$srcTemplate]['scalar'][$srcVar]; - continue; - } - - $rows = count( $this->_vars[$srcTemplate]['rows'] ); - - for( $i = 0; $i < $rows; $i++ ) - { - if( !isset( $this->_vars[$srcTemplate]['rows'][$i][$srcVar] ) ) - continue; - if( !isset( $this->_vars[$template]['rows'][$i] ) ) - $this->_vars[$template]['rows'][$i] = array(); - $this->_vars[$template]['rows'][$i][$dest] = $this->_vars[$srcTemplate]['rows'][$i][$srcVar]; - $copied = true; - } - } - if( !$copied && isset( $this->_globals[$srcVar] )) - { - $this->_vars[$template]['scalar'][$dest] = $this->_globals[$srcVar]; - } - - } - return true; - } - - /** - * parse all variables in a template - * - * @access private - * @param string - */ - function _parseVariables( $template ) - { - /** - * modify variables before parsing - */ - $this->_applyModifers($template, $this->_templates[$template]['vars']); - - foreach( $this->_templates[$template]['vars'] as $key => $value ) - { - if( is_array( $value ) ) - { - if( count( $this->_templates[$template]['currentDependencies'] ) == 1 ) - { - $child = $this->_templates[$template]['currentDependencies'][0]; - } - else - { - if( isset( $this->_templates[$template]['attributes']['child'] ) ) - $child = $this->_templates[$template]['attributes']['child']; - else - continue; - } - - $this->setAttribute( $child, 'autoclear', 'yes' ); - $this->addVar( $child, $key, $value ); - continue; - } - - $var = $this->_startTag.$key.$this->_endTag; - $this->_templates[$template]['work'] = str_replace( $var, $value, $this->_templates[$template]['work'] ); - } - return true; - } - - /** - * parse global variables in the template - * - * @access private - * @param string name of the template - * @return boolean - */ - function _parseGlobals($template) - { - $globalVars = $this->_globals; - $this->_applyModifers($template, $globalVars); - - foreach( $globalVars as $key => $value ) - { - if( is_array( $value ) ) - { - continue; - } - - $var = $this->_startTag.$key.$this->_endTag; - $this->_templates[$template]['result'] = str_replace( $var, $value, $this->_templates[$template]['result'] ); - } - return true; - } - - /** - * apply variable modifiers - * - * The variables will be passed by reference. - * - * @access private - * @param string name of the template (use modifiers from this template) - * @param array variables to which the modifiers should be applied - * @return boolean - */ - function _applyModifers($template, &$vars) - { - foreach ($this->_templates[$template]['modifyVars'] as $varname => $modifier) { - if (!isset($vars[$varname])) { - continue; - } - - if (($modifier['type'] === 'php' || $modifier['type'] === 'auto' ) && is_callable($modifier['mod'])) { - $vars[$varname] = call_user_func($modifier['mod'], $vars[$varname]); - continue; - } - - if ($modifier['type'] === 'php') { - continue; - } - - $mod = &$this->loadModule( 'Modifier', ucfirst( $modifier['mod'] ) ); - $vars[$varname] = $mod->modify( $vars[$varname], $modifier['params'] ); - } - - // apply the default modifier - if (isset($this->_templates[$template]['attributes']['defaultmodifier'])) { - - $defaultModifier = $this->_templates[$template]['attributes']['defaultmodifier']; - if (is_callable($defaultModifier)) { - $type = 'php'; - } else { - $type = 'custom'; - $defaultModifier = &$this->loadModule('Modifier', ucfirst($defaultModifier)); - } - - - foreach (array_keys($vars) as $varname) { - if (isset($this->_templates[$template]['modifyVars'][$varname])) { - continue; - } - if ($type === 'php') { - $vars[$varname] = call_user_func($defaultModifier, $vars[$varname]); - } else { - $vars[$varname] = $defaultModifier->modify($vars[$varname], array()); - } - } - } - - return true; - } - - /** - * parse all dependencies in a template - * - * @access private - * @param string - */ - function _parseDependencies($template) - { - $countDep = count( $this->_templates[$template]['currentDependencies'] ); - for ($i = 0; $i < $countDep; $i++) { - $depTemplate = $this->_templates[$template]['currentDependencies'][$i]; - if ($depTemplate == $template) { - return patErrorManager::raiseError(PATTEMPLATE_ERROR_RECURSION, 'You have an error in your template "' . $template . '", which leads to recursion'); - } - $this->parseTemplate($depTemplate); - $var = $this->_startTag.'TMPL:'.strtoupper( $depTemplate) .$this->_endTag; - $this->_templates[$template]['work'] = str_replace( $var, $this->_templates[$depTemplate]['result'], $this->_templates[$template]['work'] ); - } - return true; - } - - /** - * fetch plain template - * - * The template content will be stored in the template - * configuration so it can be used by other - * methods. - * - * @access private - * @param string template name - * @return boolean - */ - function _fetchTemplate( $template ) - { - switch( $this->_templates[$template]['attributes']['type'] ) - { - /** - * condition template - */ - case 'condition': - $value = $this->_getConditionValue($template, $this->_templates[$template]['attributes']['conditionvar']); - if ($value === false) { - $this->_templates[$template]['work'] = ''; - $this->_templates[$template]['currentDependencies'] = array(); - } else { - $this->_templates[$template]['work'] = $this->_templates[$template]['subtemplates'][$value]['data']; - $this->_templates[$template]['currentDependencies'] = $this->_templates[$template]['subtemplates'][$value]['dependencies']; - } - break; - - /** - * condition template - */ - case 'simplecondition': - foreach( $this->_templates[$template]['attributes']['requiredvars'] as $var ) - { - // different template scope - if( $var[0] !== $template ) { - $this->_fetchVariables($var[0]); - } - $value = null; - // fetch the local variable - if( isset( $this->_templates[$var[0]]['vars'][$var[1]] ) - && strlen( $this->_templates[$var[0]]['vars'][$var[1]] ) > 0 ) { - $value = $this->_templates[$var[0]]['vars'][$var[1]]; - } - if (isset($this->_templates[$template]['attributes']['useglobals'])) { - if(isset($this->_globals[$var[1]]) && strlen($this->_globals[$var[1]]) > 1) { - $value = $this->_globals[$var[1]]; - } - } - if ($value !== null) { - if ($var[2] === null) { - continue; - } else { - // Joomla! addition 23-June-2005 - // value wrapped in ## uses regex for comparison - $condition = $var[2]; - if (substr( $condition, 0, 1 ) == '#' && substr( $condition, -1, 1 ) == '#' ) { - if (preg_match( $condition, $value )) { - continue; - } - } else if ($condition == $value) { - continue; - } - /* Pat Original - if ($var[2] == $value) { - continue; - } - */ - } - } - - $this->_templates[$template]['work'] = ''; - $this->_templates[$template]['currentDependencies'] = array(); - break 2; - } - $this->_templates[$template]['work'] = $this->_templates[$template]['content']; - $this->_templates[$template]['currentDependencies'] = $this->_templates[$template]['dependencies']; - break; - - /** - * modulo template - */ - case 'modulo': - // check for empty template - - if ($this->_hasVariables($template)) { - $value = (string)($this->_templates[$template]['iteration'] + 1 ) % $this->_templates[$template]['attributes']['modulo']; - } else { - $value = '__empty'; - } - - $value = $this->_getConditionValue($template, $value, false); - if ($value === false) { - $this->_templates[$template]['work'] = ''; - $this->_templates[$template]['currentDependencies'] = array(); - } else { - $this->_templates[$template]['work'] = $this->_templates[$template]['subtemplates'][$value]['data']; - $this->_templates[$template]['currentDependencies'] = $this->_templates[$template]['subtemplates'][$value]['dependencies']; - } - break; - - /** - * standard template - */ - default: - $this->_templates[$template]['work'] = $this->_templates[$template]['content']; - $this->_templates[$template]['currentDependencies'] = $this->_templates[$template]['dependencies']; - break; - } - return true; - } - - /** - * check, whether a template contains variables - * - * @access private - * @param string template name - * @return boolean - */ - function _hasVariables($template) - { - if (!empty($this->_vars[$template]['scalar'])) { - return true; - } - if (isset($this->_vars[$template]['rows'][$this->_templates[$template]['iteration']])) { - return true; - } - return false; - } - - /** - * fetch the value of a condition variable - * - * _fetchVariables() has to be called before this - * method is being called. - * - * @access private - * @param string template name - * @param string condition value - * @param boolean flag that indicates whether value is the name of the variable that should be resolved - * - * @todo split this method into smaller check methods that will be called according to - * a priority list - */ - function _getConditionValue( $template, $value, $isVar = true ) - { - if ($isVar === true) { - if (isset($this->_templates[$template]['attributes']['conditiontmpl'])) { - $_template = $this->_templates[$template]['attributes']['conditiontmpl']; - $this->_fetchVariables($_template); - } else { - $_template = $template; - } - - /** - * get the value from the template variables - */ - if (!isset($this->_templates[$_template]['vars'][$value]) || strlen($this->_templates[$_template]['vars'][$value]) === 0) { - if ($this->_templates[$template]['attributes']['useglobals'] == 'yes' || $this->_templates[$template]['attributes']['useglobals'] == 'useglobals') { - if (isset( $this->_globals[$value] ) && strlen( $this->_globals[$value] ) > 0) { - $value = $this->_globals[$value]; - } else { - $value = '__empty'; - } - } else { - $value = '__empty'; - } - } else { - $value = $this->_templates[$_template]['vars'][$value]; - } - } else { - $_template = $template; - } - - // if value is empty and a template for empty has been defined, this - // has priority - if ($value === '__empty' && isset($this->_templates[$template]['subtemplates']['__empty'])) { - return $value; - } - - // only one iteration (but not empty), use the __single condition - if ($value !== '__empty' && $this->_templates[$_template]['loop'] === 1) { - if( isset($this->_templates[$template]['subtemplates']['__single'])) { - return '__single'; - } - } else { - - // is __first? - if( $this->_templates[$_template]['iteration'] == 0 ) { - if( isset( $this->_templates[$template]['subtemplates']['__first'] ) ) { - return '__first'; - } - } - - /** - * is __last? - */ - if (isset($this->_templates[$_template]['loop'])) { - $max = $this->_templates[$_template]['loop'] - 1; - if( $this->_templates[$_template]['iteration'] == $max ) { - if( isset( $this->_templates[$template]['subtemplates']['__last'] ) ) { - return '__last'; - } - } - } - } - - // search for exact match - foreach (array_keys($this->_templates[$template]['subtemplates']) as $key) { - if (isset($this->_templates[$template]['subtemplates'][$key]['attributes']['var'])) { - $var = $this->_templates[$template]['subtemplates'][$key]['attributes']['var']; - if (isset($this->_templates[$template]['vars'][$var])) { - $current = $this->_templates[$template]['vars'][$var]; - } else { - $current = null; - } - } else { - $current = $key; - } - - if ((string)$value === (string)$current) { - return $key; - } - } - - /** - * is __default? - */ - if( isset( $this->_templates[$template]['subtemplates']['__default'] ) ) { - return '__default'; - } - - return false; - } - - /** - * fetch variables for a template - * - * The variables will be stored in the template - * configuration so they can be used by other - * methods. - * - * @access private - * @param string template name - * @return boolean - */ - function _fetchVariables( $template ) - { - /** - * variables already have been fetched - */ - if (isset($this->_templates[$template]['vars'])) { - return true; - } - - $iteration = $this->_templates[$template]['iteration']; - - $vars = array(); - if( isset( $this->_templates[$template]['attributes']['varscope'] ) ) - { - if (!is_array($this->_templates[$template]['attributes']['varscope'])) { - $this->_templates[$template]['attributes']['varscope'] = array($this->_templates[$template]['attributes']['varscope']); - } - foreach ($this->_templates[$template]['attributes']['varscope'] as $scopeTemplate) { - if ($this->exists($scopeTemplate)) { - $this->_fetchVariables( $scopeTemplate ); - $vars = array_merge($this->_templates[$scopeTemplate]['vars'], $vars); - } else { - patErrorManager::raiseWarning(PATTEMPLATE_WARNING_NO_TEMPLATE, 'Template \''.$scopeTemplate.'\' does not exist, referenced in varscope attribute of template \''.$template.'\''); - } - } - } else { - $vars = array(); - } - - /** - * get the scalar variables - */ - if( isset( $this->_vars[$template] ) && isset( $this->_vars[$template]['scalar'] ) ) - { - $vars = array_merge( $vars, $this->_vars[$template]['scalar'] ); - } - - /** - * get the row variables - */ - if( isset( $this->_vars[$template]['rows'][$iteration] ) ) - { - $vars = array_merge( $vars, $this->_vars[$template]['rows'][$iteration] ); - } - - /** - * add some system variables - */ - $currentRow = $iteration + $this->_templates[$template]['attributes']['rowoffset']; - $vars['PAT_ROW_VAR'] = $currentRow; - - if( $this->_templates[$template]['attributes']['type'] == 'modulo' ) - { - $vars['PAT_MODULO_REP'] = ceil( $currentRow / $this->_templates[$template]['attributes']['modulo'] ); - $vars['PAT_MODULO'] = ( $this->_templates[$template]['iteration'] + 1 ) % $this->_templates[$template]['attributes']['modulo']; - } - - if( $this->_templates[$template]['attributes']['addsystemvars'] !== false ) - { - $vars['PATTEMPLATE_VERSION'] = $this->_systemVars['appVersion']; - $vars['PAT_LOOPS'] = $this->_templates[$template]['loop']; - - switch ($this->_templates[$template]['attributes']['addsystemvars']) - { - case 'boolean': - $trueValue = 'true'; - $falseValue = 'false'; - break; - case 'integer': - $trueValue = '1'; - $falseValue = '0'; - break; - default: - $trueValue = $this->_templates[$template]['attributes']['addsystemvars']; - $falseValue = ''; - break; - } - - $vars['PAT_IS_ODD'] = ( $currentRow % 2 == 1 ) ? $trueValue : $falseValue; - $vars['PAT_IS_EVEN'] = ( $currentRow % 2 == 0 ) ? $trueValue : $falseValue; - $vars['PAT_IS_FIRST'] = ( $currentRow == 1 ) ? $trueValue : $falseValue; - $vars['PAT_IS_LAST'] = ( $currentRow == $this->_templates[$template]['loop'] ) ? $trueValue : $falseValue; - $vars['PAT_ROW_TYPE'] = ( $currentRow % 2 == 1 ) ? 'odd' : 'even'; - } - - $this->_templates[$template]['vars'] = $vars; - return true; - } - - /** - * handle all unused variables in a template - * - * This is influenced by the 'unusedvars' attribute of the - * template - * - * @access private - * @param string - */ - function _handleUnusedVars( $template ) - { - $regexp = '/([^\\\])('.$this->_startTag.'[^a-z]+[^\\\]'.$this->_endTag.')/U'; - - switch( $this->_templates[$template]['attributes']['unusedvars'] ) - { - case 'comment': - $this->_templates[$template]['result'] = preg_replace( $regexp, '', $this->_templates[$template]['result'] ); - break; - case 'strip': - $this->_templates[$template]['result'] = preg_replace( $regexp, '\\1', $this->_templates[$template]['result'] ); - break; - case 'nbsp': - $this->_templates[$template]['result'] = preg_replace( $regexp, '\\1 ', $this->_templates[$template]['result'] ); - break; - case 'ignore': - break; - default: - $this->_templates[$template]['result'] = preg_replace( $regexp, '\\1'.$this->_templates[$template]['attributes']['unusedvars'], $this->_templates[$template]['result'] ); - break; - } - - // replace quoted variables - $regexp = '/[\\\]'.$this->_startTag.'([^a-z]+)[\\\]'.$this->_endTag.'/U'; - $this->_templates[$template]['result'] = preg_replace( $regexp, $this->_startTag.'\\1'.$this->_endTag, $this->_templates[$template]['result'] ); - - return true; - } - - /** - * returns a parsed Template - * - * If the template already has been parsed, it just returns the parsed template. - * If the template has not been loaded, it will be loaded. - * - * @access public - * @param string name of the template - * @param boolean whether to apply output filters - * @return string Content of the parsed template - * @see displayParsedTemplate() - */ - function getParsedTemplate( $name = null, $applyFilters = false ) - { - if (is_null($name)) { - $name = $this->_root; - } - - $name = strtolower( $name ); - $result = $this->parseTemplate( $name ); - - if (patErrorManager::isError( $result )) { - return $result; - } - - if ($applyFilters === false) { - return $this->_templates[$name]['result']; - } - - $result = $this->_templates[$name]['result']; - - $cnt = count ($this->_outputFilters); - for ($i = 0; $i < $cnt; $i++) { - $result = $this->_outputFilters[$i]->apply( $result ); - } - - return $result; - } - - /** - * displays a parsed Template - * - * If the template has not been loaded, it will be loaded. - * - * @see getParsedTemplate() - * @param string name of the template - * @param boolean whether to apply output filters - * @return boolean true on success - * @access public - */ - function displayParsedTemplate($name = null, $applyFilters = true) - { - $result = $this->getParsedTemplate($name, $applyFilters); - - /** - * error happened - */ - if (patErrorManager::isError($result)) { - return $result; - } - - echo $result; - return true; - } - - /** - * parse a template and push the result into a variable of any other - * template - * - * If the template already has been parsed, it will just be pushed into the variable. - * If the template has not been loaded, it will be loaded. - * - * @access public - * @param string name of the template - * @return string Content of the parsed template - * @param boolean if set to true, the value will be appended to the value already stored. - * @see getParsedTemplate() - * @see addVar() - */ - function parseIntoVar( $srcTmpl, $destTmpl, $var, $append = false ) - { - $srcTmpl = strtolower( $srcTmpl ); - $destTmpl = strtolower( $destTmpl ); - $var = strtoupper($var); - - $result = $this->parseTemplate( $srcTmpl ); - - if( patErrorManager::isError( $result ) ) - return $result; - - if( $append !== true || !isset( $this->_vars[$destTmpl]['scalar'][$var] ) ) - $this->_vars[$destTmpl]['scalar'][$var] = ''; - - $this->_vars[$destTmpl]['scalar'][$var] .= $this->_templates[$srcTmpl]['result']; - - return true; - } - - /** - * clears a parsed Template - * - * Parsed Content, variables and the loop attribute are cleared - * - * If you will not be using this template anymore, then you should - * call freeTemplate() - * - * @access public - * @param string name of the template - * @param boolean set this to true to clear all child templates, too - * @see clearAllTemplates() - * @see freeTemplate() - */ - function clearTemplate( $name, $recursive = false ) - { - $name = strtolower( $name ); - $this->_templates[$name]['parsed'] = false; - $this->_templates[$name]['work'] = ''; - $this->_templates[$name]['iteration'] = 0; - $this->_templates[$name]['result'] = ''; - $this->_vars[$name] = array( - 'scalar' => array(), - 'rows' => array() - ); - - if (!empty($this->_templates[$name]['defaultVars'])) { - foreach ($this->_templates[$name]['defaultVars'] as $varname => $value) { - $this->addVar($name, $varname, $value); - } - } - - /** - * clear child templates as well - */ - if( $recursive === true ) - { - $deps = $this->_getDependencies( $name ); - foreach( $deps as $dep ) - { - $this->clearTemplate( $dep, true ); - } - } - return true; - } - - /** - * clears all templates - * - * @access public - * @uses clearTemplate() - */ - function clearAllTemplates() - { - $templates = array_keys( $this->_templates ); - $cnt = count( $templates ); - for( $i = 0; $i < $cnt; $i++ ) - { - $this->clearTemplate( $templates[$i] ); - } - return true; - } - - /** - * frees a template - * - * All memory consumed by the template - * will be freed. - * - * @access public - * @param string name of the template - * @param boolean clear dependencies of the template - * @see freeAllTemplates() - */ - function freeTemplate( $name, $recursive = false ) - { - $name = strtolower( $name ); - $key = array_search( $name, $this->_templateList ); - if( $key === false ) - { - return patErrorManager::raiseWarning( - PATTEMPLATE_WARNING_NO_TEMPLATE, - "Template '$name' does not exist." - ); - } - - unset( $this->_templateList[$key] ); - $this->_templateList = array_values( $this->_templateList ); - - /** - * free child templates as well - */ - if( $recursive === true ) - { - $deps = $this->_getDependencies( $name ); - foreach( $deps as $dep ) - { - $this->freeTemplate( $dep, true ); - } - } - - unset( $this->_templates[$name] ); - unset( $this->_vars[$name] ); - if (isset($this->_discoveredPlaceholders[$name])) { - unset($this->_discoveredPlaceholders[$name]); - } - - return true; - } - - /** - * frees all templates - * - * All memory consumed by the templates - * will be freed. - * - * @access public - * @see freeTemplate() - */ - function freeAllTemplates() - { - $this->_templates = array(); - $this->_vars = array(); - $this->_templateList = array(); - } - - /** - * get _all_ dependencies of a template, - * regardless of the subtemplates - * - * @access private - * @param string template name - * @return array list of all subtemplates - */ - function _getDependencies( $template ) - { - $deps = array(); - if( isset( $this->_templates[$template]['dependencies'] ) ) - $deps = $this->_templates[$template]['dependencies']; - - if( isset( $this->_templates[$template]['subtemplates'] ) ) - { - foreach( $this->_templates[$template]['subtemplates'] as $sub ) - { - if( isset( $sub['dependencies'] ) ) - $deps = array_merge( $deps, $sub['dependencies'] ); - } - } - $deps = array_unique( $deps ); - return $deps; - } - - /** - * Displays useful information about all or named templates - * - * This method breaks BC, as it now awaits an array instead of - * unlimited parameters. - * - * @param mixed array of templates that should be dumped, or null if you - * want all templates to be dumped - * @param string dumper - * @access public - */ - function dump( $restrict = null, $dumper = 'Html' ) - { - if( is_string( $restrict ) ) - $restrict = array( $restrict ); - - $dumper = &$this->loadModule( 'Dump', $dumper ); - - if( patErrorManager::isError( $dumper ) ) - { - return $dumper; - } - - if( is_null( $restrict ) ) - { - $templates = $this->_templates; - $vars = $this->_vars; - } - else - { - $restrict = array_map( 'strtolower', $restrict ); - - $templates = array(); - $vars = array(); - - foreach( $this->_templates as $name => $spec ) - { - if( !in_array( $name, $restrict ) ) - continue; - $templates[$name] = $spec; - $vars[$name] = $this->_vars[$name]; - } - } - - $dumper->displayHeader(); - $dumper->dumpGlobals( $this->_globals ); - $dumper->dumpTemplates( $templates, $vars ); - $dumper->displayFooter(); - - return true; - } - - /** - * get the include path - * - * @access public - * @return string - */ - function getIncludePath() - { - return PATTEMPLATE_INCLUDE_PATH; - } - - /** - * apply input filters that have been set - * - * This is being called by the readers. - * - * @access public - * @param string template - * @return string filtered templeta - */ - function applyInputFilters( $template ) - { - $cnt = count( $this->_inputFilters ); - for( $i = 0; $i < $cnt; $i++ ) - { - $template = $this->_inputFilters[$i]->apply( $template ); - } - return $template; - } - - /** - * checks, whether a placeholder exists in a template - * - * @access public - * @param string name of the placeholder - * @param string name of the template - * @param boolean whether to use the cached result of a previous call - */ - function placeholderExists($placeholder, $tmpl, $cached = true) - { - $tmpl = strtolower($tmpl); - $placeholder = strtoupper($placeholder); - - if (!$this->exists($tmpl)) { - return false; - } - - if ($cached === true) { - if (isset($this->_discoveredPlaceholders[$tmpl]) && isset($this->_discoveredPlaceholders[$tmpl][$placeholder])) { - return $this->_discoveredPlaceholders[$tmpl][$placeholder]; - } - } - - if (isset($this->_templates[$tmpl]['subtemplates'])) { - $content = ''; - foreach ($this->_templates[$tmpl]['subtemplates'] as $temp) { - if (!isset($temp['data'])) { - continue; - } - $content .= $temp['data']; - } - } else { - $content = $this->_templates[$tmpl]['content']; - } - - $search = $this->_startTag . $placeholder . $this->_endTag; - if (strstr($content, $search) !== false) { - $this->_discoveredPlaceholders[$tmpl][$placeholder] = true; - return true; - } - $this->_discoveredPlaceholders[$tmpl][$placeholder] = false; - return false; - } - - /** - * Convert the template to its string representation. - * - * This method allows you to just echo the patTemplate - * object in order to display the template. - * - * Requires PHP5 - * - * - * $tmpl = new patTemplate(); - * $tmpl->readTemplatesFromFile( 'myfile.tmpl' ); - * echo $tmpl; - * - * - * @access private - * @return string - */ - function __toString() - { - return $this->getParsedTemplate(); - } -} -?> \ No newline at end of file + + * @license LGPL + * @link http://www.php-tools.net + */ + +// ** Following line Joomla! specific ** +require_once( dirname( __FILE__ ) . '/patErrorManager.php' ); + +/** + * template already exists + */ +define( 'PATTEMPLATE_ERROR_TEMPLATE_EXISTS', 5010 ); + +/** + * template does not exist + */ +define ( 'PATTEMPLATE_WARNING_NO_TEMPLATE', 5011 ); + +/** + * unknown type + */ +define ( 'PATTEMPLATE_WARNING_UNKNOWN_TYPE', 5012 ); + +/** + * base class for module could not be found + */ +define( 'PATTEMPLATE_ERROR_BASECLASS_NOT_FOUND', 5050 ); + +/** + * module could not be found + */ +define( 'PATTEMPLATE_ERROR_MODULE_NOT_FOUND', 5051 ); + +/** + * array expected + */ +define( 'PATTEMPLATE_ERROR_EXPECTED_ARRAY', 5052 ); + +/** + * No input + */ +define( 'PATTEMPLATE_ERROR_NO_INPUT', 6000 ); +/** + * Recursion + */ +define( 'PATTEMPLATE_ERROR_RECURSION', 6010 ); + +/** + * patTemplate + * + * powerful templating engine + * + * @version 3.1.0 + * @package patTemplate + * @author Stephan Schmidt + * @license LGPL + * @link http://www.php-tools.net + */ +class patTemplate +{ + /** + * standard system vars that identify pat tools + * @var array + */ + var $_systemVars = array( + 'appName' => 'patTemplate', + 'appVersion' => '3.1.0', + 'author' => array( + 'Stephan Schmidt ' + ) + ); + + /** + * default attributes for new templates + * @access private + * @var array + */ + var $_defaultAttributes = array( + 'type' => 'standard', + 'visibility' => 'visible', + 'loop' => 1, + 'unusedvars' => 'strip', + 'whitespace' => 'keep', + 'autoclear' => 'off', + 'autoload' => 'on' + ); + + /** + * options for patTemplate + * + * Currently the following options are implemented: + * - maintainBc defines, whether patTemplate should be backwards compatible. + * This means, that you may use 'default' and 'empty' for subtemplates. + * + * @access private + * @var array + */ + var $_options = array( + 'startTag' => '{', + 'endTag' => '}', + 'root' => array('__default' => '.'), + 'namespace' => 'patTemplate', + 'maintainBc' => true, + 'defaultFunction' => false + ); + + /** + * start tag + * + * @access private + * @var string + */ + var $_startTag = '{'; + + /** + * end tag + * + * @access private + * @var string + */ + var $_endTag = '}'; + + /** + * loaded modules + * + * Modules are: + * - Readers + * - Caches + * - Variable modifiers + * - Filters + * + * @access private + * @var array + */ + var $_modules = array(); + + /** + * directories, where modules can be stored + * @access private + * @var array + */ + var $_moduleDirs = array(); + + /** + * stores all template names + * @access private + * @var array + */ + var $_templateList = array(); + + /** + * stores all template data + * @access private + * @var array + */ + var $_templates = array(); + + /** + * stores all global variables + * @access private + * @var array + */ + var $_globals = array(); + + /** + * stores all local variables + * @access private + * @var array + */ + var $_vars = array(); + + /** + * stores the name of the first template that has been + * found + * + * @access private + * @var string + */ + var $_root; + + /** + * output filters that should be used + * + * @access private + * @var array + */ + var $_outputFilters = array(); + + /** + * input filters that should be used + * + * @access private + * @var array + */ + var $_inputFilters = array(); + + /** + * template cache, that should be used + * + * @access private + * @var array + */ + var $_tmplCache = null; + + /** + * placeholders, that have been discovered + * + * @access private + * @var array + */ + var $_discoveredPlaceholders = array(); + + /** + * Create a new patTemplate instance. + * + * The constructor accepts the type of the templates as sole parameter. + * You may choose one of: + * - html (default) + * - tex + * + * The type influences the tags you are using in your templates. + * + * @access public + * @param string type (either html or tex) + */ + function patTemplate( $type = 'html' ) + { + if( !defined( 'PATTEMPLATE_INCLUDE_PATH' ) ) { + define( 'PATTEMPLATE_INCLUDE_PATH', dirname( __FILE__ ) . '/patTemplate' ); + } + + $this->setType( $type ); + } + + /** + * sets an option + * + * Currently, the following options are supported + * - maintainBc (true|false) + * - namespace (string) + * + * @access public + * @param string option to set + * @param string value of the option + */ + function setOption($option, $value) + { + $this->_options[$option] = $value; + } + + /** + * gets an option + * + * @access public + * @param string option to get + * @return mixed value of the option + */ + function getOption( $option ) + { + if (!isset($this->_options[$option])) { + return null; + } + return $this->_options[$option]; + } + + /** + * sets name of directory where templates are stored + * + * @access public + * @param string dir where templates are stored + * @deprecated please use patTemplate::setRoot() instead + */ + function setBasedir($basedir) + { + $this->setRoot($basedir); + } + + /** + * sets root base for the template + * + * The parameter depends on the reader you are using. + * + * @access public + * @param string root base of the templates + */ + function setRoot($root, $reader = '__default') + { + $this->_options['root'][$reader] = $root; + } + + /** + * gets name of root base for the templates + * + * @access public + * @return mixed root base + */ + function getRoot($reader = '__default') + { + return $this->_options['root'][$reader]; + } + + /** + * sets namespace of patTemplate tags + * + * If you want to use more than one namespace, you may set this to + * an array. All tags in these namespaces will be treated as patTemplate + * tags. + * + * @access public + * @param string|array namespace(s) + */ + function setNamespace($ns) + { + $this->_options['namespace'] = $ns; + } + + /** + * gets namespace of patTemplate tags + * + * @access public + * @return string|array namespace(s) + */ + function getNamespace() + { + return $this->_options['namespace']; + } + + /** + * set default attribute + * + * @access public + * @param string attribute name + * @param mixed attribute value + */ + function setDefaultAttribute( $name, $value ) + { + $this->_defaultAttributes[$name] = $value; + } + + /** + * set default attributes + * + * @access public + * @param array attributes + */ + function setDefaultAttributes( $attributes ) + { + $this->_defaultAttributes = array_merge( $this->_defaultAttributes, $attributes ); + } + + /** + * get default attributes + * + * @access public + * @return return default attributes + */ + function getDefaultAttributes() + { + return $this->_defaultAttributes; + } + + /** + * set the type for the templates + * + * @access public + * @param string type (html or tex) + * @return boolean true on success + */ + function setType( $type ) + { + switch( strtolower( $type ) ) + { + case "tex": + $this->setTags( '<{', '}>' ); + break; + case "html": + $this->setTags( '{', '}' ); + break; + default: + return patErrorManager::raiseWarning( + PATTEMPLATE_WARNING_UNKNOWN_TYPE, + "Unknown type '$type'. Please use 'html' or 'tex'." + ); + } + return true; + } + + /** + * set the start and end tag for variables + * + * @access public + * @param string start tag + * @param string end tag + * @return boolean true on success + */ + function setTags( $startTag, $endTag ) + { + $this->_options['startTag'] = $startTag; + $this->_options['endTag'] = $endTag; + + $this->_startTag = $startTag; + $this->_endTag = $endTag; + return true; + } + + /** + * get start tag for variables + * + * @access public + * @return string start tag + */ + function getStartTag() + { + return $this->_options['startTag']; + } + + /** + * get end tag for variables + * + * @access public + * @return string end tag + */ + function getEndTag() + { + return $this->_options['endTag']; + } + + /** + * add a directory where patTemplate should search for + * modules. + * + * You may either pass a string or an array of directories. + * + * patTemplate will be searching for a module in the same + * order you added them. If the module cannot be found in + * the custom folders, it will look in + * patTemplate/$moduleType. + * + * @access public + * @param string module type + * @param string|array directory or directories to search. + */ + function addModuleDir( $moduleType, $dir ) + { + if( !isset( $this->_moduleDirs[$moduleType] ) ) + $this->_moduleDirs[$moduleType] = array(); + if( is_array( $dir ) ) + $this->_moduleDirs[$moduleType] = array_merge( $this->_moduleDirs[$moduleType], $dir ); + else + array_push( $this->_moduleDirs[$moduleType], $dir ); + } + + /** + * Sets an attribute of a template + * + * supported attributes: visibilty, loop, parse, unusedvars + * + * @param string $template name of the template + * @param string $attribute name of the attribute + * @param mixed $value value of the attribute + * @access public + * @see setAttributes(),getAttribute(), clearAttribute() + */ + function setAttribute( $template, $attribute, $value ) + { + $template = strtolower( $template ); + if( !isset( $this->_templates[$template] ) ) + { + return patErrorManager::raiseWarning( + PATTEMPLATE_WARNING_NO_TEMPLATE, + "Template '$template' does not exist." + ); + } + + $attribute = strtolower( $attribute ); + $this->_templates[$template]['attributes'][$attribute] = $value; + return true; + } + + /** + * Sets several attribute of a template + * + * $attributes has to be a assotiative arrays containing attribute/value pairs + * supported attributes: visibilty, loop, parse, unusedvars + * + * @param string $template name of the template + * @param array $attributes attribute/value pairs + * @access public + * @see setAttribute(), getAttribute(), clearAttribute() + */ + function setAttributes( $template, $attributes ) + { + if( !is_array( $attributes ) ) + { + return patErrorManager::raiseError( PATTEMPLATE_ERROR_EXPECTED_ARRAY, 'patTemplate::setAttributes: Expected array as second parameter, '.gettype( $attributes ).' given' ); + } + + $template = strtolower( $template ); + $attributes = array_change_key_case( $attributes ); + if( !isset( $this->_templates[$template] ) ) + { + return patErrorManager::raiseWarning( + PATTEMPLATE_WARNING_NO_TEMPLATE, + "Template '$template' does not exist." + ); + } + + $this->_templates[$template]['attributes'] = array_merge( $this->_templates[$template]['attributes'], $attributes ); + return true; + } + + /** + * Get all attributes of a template + * + * @param string name of the template + * @return array attributes + * @access public + */ + function getAttributes( $template ) + { + $template = strtolower( $template ); + if( !isset( $this->_templates[$template] ) ) + { + return patErrorManager::raiseWarning( + PATTEMPLATE_WARNING_NO_TEMPLATE, + "Template '$template' does not exist." + ); + } + return $this->_templates[$template]['attributes']; + } + + /** + * Gets an attribute of a template + * + * supported attributes: visibilty, loop, parse, unusedvars + * + * @param string $template name of the template + * @param string $attribute name of the attribute + * @return mixed value of the attribute + * @access public + * @see setAttribute(), setAttributes(), clearAttribute() + */ + function getAttribute( $template, $attribute ) + { + $template = strtolower( $template ); + $attribute = strtolower( $attribute ); + if( !isset( $this->_templates[$template] ) ) + { + return patErrorManager::raiseWarning( + PATTEMPLATE_WARNING_NO_TEMPLATE, + "Template '$template' does not exist." + ); + } + return $this->_templates[$template]['attributes'][$attribute]; + } + + /** + * Clears an attribute of a template + * + * supported attributes: visibilty, loop, parse, unusedvars + * + * @param string $template name of the template + * @param string $attribute name of the attribute + * @access public + * @see setAttribute(), setAttributes(), getAttribute() + */ + function clearAttribute( $template, $attribute ) + { + $template = strtolower( $template ); + $attribute = strtolower( $attribute ); + + if( !isset( $this->_templates[$template] ) ) + { + return patErrorManager::raiseWarning( + PATTEMPLATE_WARNING_NO_TEMPLATE, + "Template '$template' does not exist." + ); + } + $this->_templates[$template]['attributes'][$attribute] = '';; + return true; + } + + /** + * Prepare a template + * + * This can be used if you want to add variables to + * a template, that has not been loaded yet. + * + * @access public + * @param string template name + */ + function prepareTemplate( $name ) + { + $name = strtolower( $name ); + if( !isset( $this->_vars[$name] ) ) + { + $this->_vars[$name] = array( + 'scalar' => array(), + 'rows' => array() + ); + } + } + + /** + * add a variable to a template + * + * A variable may also be an indexed array, but _not_ + * an associative array! + * + * @access public + * @param string $template name of the template + * @param string $varname name of the variable + * @param mixed $value value of the variable + */ + function addVar( $template, $varname, $value ) + { + $template = strtolower( $template ); + $varname = strtoupper( $varname ); + + if( !is_array( $value ) ) { + $this->_vars[$template]['scalar'][$varname] = $value; + return true; + } + + $cnt = count( $value ); + for ($i = 0; $i < $cnt; $i++) { + if (!isset( $this->_vars[$template]['rows'][$i] )) { + $this->_vars[$template]['rows'][$i] = array(); + } + $this->_vars[$template]['rows'][$i][$varname] = $value[$i]; + } + + return true; + } + + /** + * get the value of a variable + * + * @access public + * @param string name of the template + * @param string name of the variable + * @return string value of the variable, null if the variable is not set + */ + function getVar( $template, $varname ) + { + $template = strtolower( $template ); + $varname = strtoupper( $varname ); + + if( isset( $this->_vars[$template]['scalar'][$varname] ) ) + return $this->_vars[$template]['scalar'][$varname]; + + $value = array(); + + if(!isset($this->_vars[$template]['rows'])) + return null; + + $cnt = count( $this->_vars[$template]['rows'] ); + for( $i = 0; $i < $cnt; $i++ ) + { + if( !isset( $this->_vars[$template]['rows'][$i][$varname] ) ) + continue; + array_push( $value, $this->_vars[$template]['rows'][$i][$varname] ); + } + if( !empty( $value ) ) + return $value; + return null; + } + + /** + * clear the value of a variable + * + * @access public + * @param string name of the template + * @param string name of the variable + * @return boolean + * @see clearVars(), clearTemplate() + */ + function clearVar( $template, $varname ) + { + $template = strtolower( $template ); + $varname = strtoupper( $varname ); + + if (isset( $this->_vars[$template]['scalar'][$varname] )) { + unset ($this->_vars[$template]['scalar'][$varname]); + return true; + } + + $result = false; + $cnt = count( $this->_vars[$template]['rows'] ); + for ($i = 0; $i < $cnt; $i++) { + if (!isset($this->_vars[$template]['rows'][$i][$varname])) { + continue; + } + unset($this->_vars[$template]['rows'][$i][$varname]); + $result = true; + } + return $result; + } + + + /** + * Adds several variables to a template + * + * Each Template can have an unlimited amount of its own variables + * $variables has to be an assotiative array containing variable/value pairs + * + * @param string $template name of the template + * @param array $variables assotiative array of the variables + * @param string $prefix prefix for all variable names + * @access public + * @see addVar(), addRows(), addGlobalVar(), addGlobalVars() + */ + function addVars( $template, $variables, $prefix = '' ) + { + $template = strtolower( $template ); + $prefix = strtoupper( $prefix ); + $variables = array_change_key_case( $variables, CASE_UPPER ); + + foreach ($variables as $varname => $value) { + $varname = $prefix.$varname; + + if (!is_array($value)) { + if (!is_scalar($value)) { + continue; + } + $this->_vars[$template]['scalar'][$varname] = $value; + continue; + } + + $cnt = count( $value ); + for( $i = 0; $i < $cnt; $i++ ) { + if( !isset( $this->_vars[$template]['rows'][$i] ) ) + $this->_vars[$template]['rows'][$i] = array(); + + $this->_vars[$template]['rows'][$i][$varname] = $value[$i]; + } + } + } + + /** + * Clear all variables in a template + * + * This clears only variables, but does + * + * @access public + * @param string $template name of the template + * @return boolean + * @see clearVar(), clearTemplate() + */ + function clearVars( $template ) + { + $template = strtolower($template); + $this->_vars[$template] = array( + 'scalar' => array(), + 'rows' => array() + ); + return true; + } + + + /** + * Adds several rows of variables to a template + * + * Each Template can have an unlimited amount of its own variables + * Can be used to add a database result as variables to a template + * + * @param string $template name of the template + * @param array $rows array containing assotiative arrays with variable/value pairs + * @param string $prefix prefix for all variable names + * @access public + * @see addVar(), addVars(), addGlobalVar(), addGlobalVars() + */ + function addRows( $template, $rows, $prefix = '' ) + { + $template = strtolower( $template ); + $prefix = strtoupper( $prefix ); + + $cnt = count( $rows ); + for( $i = 0; $i < $cnt; $i++ ) + { + if( !isset( $this->_vars[$template]['rows'][$i] ) ) + $this->_vars[$template]['rows'][$i] = array(); + + $rows[$i] = array_change_key_case( $rows[$i], CASE_UPPER ); + + foreach( $rows[$i] as $varname => $value ) + { + $this->_vars[$template]['rows'][$i][$prefix.$varname] = $value; + } + } + } + + /** + * Adds an object to a template + * + * All properties of the object will be available as template variables. + * + * @access public + * @param string name of the template + * @param object|array object or array of objects + * @param string prefix for all variable names + * @param boolean ignore private properties (starting with _) + * @see addVar(), addRows(), addGlobalVar(), addGlobalVars() + */ + function addObject( $template, $object, $prefix = '', $ignorePrivate = false ) + { + if( is_array( $object ) ) { + $rows = array(); + foreach($object as $o) { + array_push( $rows, $this->getObjectVars($o, $ignorePrivate) ); + } + + return $this->addRows( $template, $rows, $prefix ); + } elseif (is_object($object)) { + return $this->addVars( $template, $this->getObjectVars($object, $ignorePrivate), $prefix ); + } + return false; + } + + /** + * get the vars from an object + * + * @access private + * @param object + * @param boolean ignore private properties (starting with _) + * @return array + */ + function getObjectVars($obj, $ignorePrivate = false) + { + if (method_exists($obj, 'getVars')) { + return $obj->getVars(); + } + $vars = get_object_vars($obj); + if ($ignorePrivate === false) { + return $vars; + } + foreach ($vars as $var => $value) { + if ($var{0} == '_') { + unset($vars[$var]); + } + } + return $vars; + } + + /** + * Adds a global variable + * + * Global variables are valid in all templates of this object. + * A global variable has to be scalar, it will be converted to a string. + * + * @access public + * @param string $varname name of the global variable + * @param string $value value of the variable + * @return boolean true on success + * @see addGlobalVars(), addVar(), addVars(), addRows() + */ + function addGlobalVar( $varname, $value ) + { + $this->_globals[strtoupper( $varname )] = ( string )$value; + return true; + } + + /** + * Clears a global variable + * + * @access public + * @param string $varname name of the global variable + * @return boolean true on success + * @see clearVar(), clearVars(), clearGlobalVars() + */ + function clearGlobalVar( $varname ) + { + $varname = strtoupper( $varname ); + if (!isset($this->_globals[$varname])) { + return false; + } + unset($this->_globals[$varname]); + return true; + } + + /** + * Clears all global variables + * + * @access public + * @return boolean true on success + * @see clearVar(), clearVars(), clearGlobalVar() + */ + function clearGlobalVars() + { + $this->_globals = array(); + return true; + } + + /** + * Adds several global variables + * + * Global variables are valid in all templates of this object. + * + * $variables is an associative array, containing name/value pairs of the variables. + * + * @access public + * @param array $variables array containing the variables + * @param string $prefix prefix for variable names + * @return boolean true on success + * @see addGlobalVar(), addVar(), addVars(), addRows() + */ + function addGlobalVars( $variables, $prefix = '' ) + { + $variables = array_change_key_case( $variables, CASE_UPPER ); + $prefix = strtoupper( $prefix ); + foreach( $variables as $varname => $value ) + { + $this->_globals[$prefix.$varname] = ( string )$value; + } + + return true; + } + + /** + * get all global variables + * + * @access public + * @return array global variables + */ + function getGlobalVars() + { + return $this->_globals; + } + + /** + * checks wether a template exists + * + * @access public + * @param string name of the template + * @return boolean true, if the template exists, false otherwise + */ + function exists( $name ) + { + return in_array( strtolower( $name ), $this->_templateList ); + } + + /** + * enable a template cache + * + * A template cache will improve performace, as the templates + * do not have to be read on each request. + * + * @access public + * @param string name of the template cache + * @param array parameters for the template cache + * @return boolean true on success, patError otherwise + */ + function useTemplateCache( $cache, $params = array() ) + { + if( !is_object( $cache ) ) + { + $cache = &$this->loadModule( 'TemplateCache', $cache, $params ); + } + if( patErrorManager::isError( $cache ) ) + return $cache; + + $this->_tmplCache = &$cache; + return true; + } + + /** + * enable an output filter + * + * Output filters are used to modify the template + * result before it is sent to the browser. + * + * They are applied, when displayParsedTemplate() is called. + * + * @access public + * @param string name of the output filter + * @param array parameters for the output filter + * @return boolean true on success, patError otherwise + */ + function applyOutputFilter( $filter, $params = array(), $template = null ) + { + if (!is_object($filter)) { + $filter = &$this->loadModule( 'OutputFilter', $filter, $params ); + } + if (patErrorManager::isError($filter)) { + return $filter; + } + + if ($template === null) { + $this->_outputFilters[] = &$filter; + return true; + } + + $template = strtolower($template); + if (!$this->exists($template)) { + return patErrorManager::raiseWarning(PATTEMPLATE_WARNING_NO_TEMPLATE, 'The selected template does not exist'); + } + $this->_templates[$template]['attributes']['outputfilter'] = &$filter; + return true; + } + + /** + * enable an input filter + * + * input filters are used to modify the template + * stream before it is split into smaller templates- + * + * @access public + * @param string name of the input filter + * @param array parameters for the input filter + * @return boolean true on success, patError otherwise + */ + function applyInputFilter( $filter, $params = array() ) + { + if( !is_object( $filter ) ) + { + $filter = &$this->loadModule( 'InputFilter', $filter, $params ); + } + if( patErrorManager::isError( $filter ) ) + return $filter; + + $this->_inputFilters[] = &$filter; + return true; + } + + /** + * open a file and parse for patTemplate tags + * + * @access public + * @param name of the file + * @return true, if the template could be parsed + * @deprecated Use patTemplate::readTemplatesFromInput() instead, as the method name is misleading + * @see readTemplatesFromInput() + */ + function readTemplatesFromFile( $filename ) + { + return $this->readTemplatesFromInput( $filename, 'File' ); + } + + /** + * open any input and parse for patTemplate tags + * + * @access public + * @param string name of the input (filename, shm segment, etc.) + * @param string driver that is used as reader, you may also pass a Reader object + * @param array additional options that will only be used for this template + * @param string name of the template that should be used as a container, should not be used by public + * calls. + * @return boolean true, if the template could be parsed, false otherwise + */ + function readTemplatesFromInput( $input, $reader = 'File', $options = null, $parseInto = null ) + { + if ((string)$input === '') { + return patErrorManager::raiseError(PATTEMPLATE_ERROR_NO_INPUT, 'No input to read has been passed.'); + } + + if (is_array($options)) { + $options = array_merge( $this->_options, $options ); + } else { + $options = $this->_options; + } + + if (!is_null($parseInto)) { + $parseInto = strtolower( $parseInto ); + } + + $templates = false; + if ($this->_tmplCache !== null) { + /** + * get the unique cache key + */ + $key = $this->_tmplCache->getKey($input, $options); + + $templates = $this->_loadTemplatesFromCache( $input, $reader, $options, $key ); + + /** + * check for error returned from cache + */ + if (patErrorManager::isError($templates)) { + return $templates; + } + } + + /** + * templates have not been loaded from cache + */ + if ($templates === false) { + if (!is_object( $reader)) { + $reader = &$this->loadModule('Reader', $reader); + if (patErrorManager::isError($reader)) { + return $reader; + } + } + + if ($reader->isInUse()) { + $reader = &$this->loadModule( 'Reader', $reader->getName(), array(), true); + if( patErrorManager::isError( $reader ) ) { + return $reader; + } + } + + $reader->setOptions($options); + + /** + * set the root attributes + */ + if( !is_null( $parseInto ) ) + { + $attributes = $this->getAttributes( $parseInto ); + if( !patErrorManager::isError( $attributes ) ) + { + $reader->setRootAttributes( $attributes ); + } + } + + $templates = $reader->readTemplates( $input ); + + /** + * check for error returned from reader + */ + if( patErrorManager::isError( $templates ) ) + return $templates; + + /** + * store the + */ + if( $this->_tmplCache !== null ) + { + $this->_tmplCache->write( $key, $templates ); + } + } + + /** + * traverse all templates + */ + foreach( $templates as $name => $spec ) + { + + /** + * root template + */ + if( $name == '__ptroot' ) + { + if( $parseInto === false ) + { + continue; + } + if( !in_array( $parseInto, $this->_templateList ) ) + continue; + + $spec['loaded'] = true; + $spec['attributes'] = $this->_templates[$parseInto]['attributes']; + $name = $parseInto; + } + else + { + /** + * store the name + */ + array_push( $this->_templateList, $name ); + } + + /** + * if this is the first template that has been loaded + * set it as the root template + */ + if( $this->_root === null && is_null( $parseInto ) && isset( $spec['isRoot'] ) && $spec['isRoot'] == true ) + { + $this->_root = $name; + } + + /** + * set some default values + */ + $spec['iteration'] = 0; + $spec['lastMode'] = 'w'; + $spec['result'] = ''; + $spec['modifyVars'] = array(); + $spec['copyVars'] = array(); + $spec['defaultVars'] = array(); + + /** + * store the template + */ + $this->_templates[$name] = $spec; + + $this->prepareTemplate( $name ); + + /** + * store the default values of the variables + */ + foreach( $spec['varspecs'] as $varname => $varspec ) + { + if (isset($varspec['modifier'])) { + $this->_templates[$name]['modifyVars'][$varname] = $varspec['modifier']; + } + + if( isset( $varspec['copyfrom'] ) ) + { + $this->_templates[$name]['copyVars'][$varname] = $varspec['copyfrom']; + } + + if( !isset( $varspec['default'] ) ) + continue; + + $this->_templates[$name]['defaultVars'][$varname] = $varspec['default']; + + if( !is_null( $this->getVar( $name, $varname ) ) ) + continue; + + $this->addVar( $name, $varname, $varspec['default'] ); + } + + unset($this->_templates[$name]['varspecs']); + + /** + * autoload the template + * + * Some error management is needed here... + */ + if( isset( $this->_templates[$name]['attributes']['src'] ) && $this->_templates[$name]['attributes']['autoload'] == 'on' ) + { + if( $this->_templates[$name]['loaded'] !== true ) + { + if( $this->_templates[$name]['attributes']['parse'] == 'on' ) + { + $this->readTemplatesFromInput( $this->_templates[$name]['attributes']['src'], $this->_templates[$name]['attributes']['reader'], $options, $name ); + } + else + { + $this->loadTemplateFromInput( $this->_templates[$name]['attributes']['src'], $this->_templates[$name]['attributes']['reader'], null, $name ); + } + $this->_templates[$name]['loaded'] = true; + } + } + } + + return true; + } + + /** + * load from template cache + * + * @access private + * @param string name of the input (filename, shm segment, etc.) + * @param string driver that is used as reader, you may also pass a Reader object + * @param array options for the reader + * @param string cache key + * @return array|boolean either an array containing the templates, or false + */ + function _loadTemplatesFromCache( $input, &$reader, $options, $key ) + { + if( is_object( $reader ) ) + $statName = $reader->getName(); + else + $statName = $reader; + + $stat = &$this->loadModule( 'Stat', $statName ); + $stat->setOptions( $options ); + + /** + * get modification time + */ + $modTime = $stat->getModificationTime( $input ); + $templates = $this->_tmplCache->load( $key, $modTime ); + + return $templates; + } + + /** + * open any input and load content into template + * + * @access public + * @param string name of the input (filename, shm segment, etc.) + * @param string driver that is used as reader + * @param string name of the template that should be used as a container, + * @return boolean true, if the template could be parsed, false otherwise + */ + function loadTemplateFromInput( $input, $reader = 'File', $options = null, $parseInto = false ) + { + if( is_array( $options ) ) + $options = array_merge( $this->_options, $options ); + else + $options = $this->_options; + + if( !is_null( $parseInto ) ) + $parseInto = strtolower( $parseInto ); + + $reader = &$this->loadModule( 'Reader', $reader ); + if( patErrorManager::isError( $reader ) ) + { + return $reader; + } + $reader->setOptions($options); + + $result = $reader->loadTemplate( $input ); + + if( patErrorManager::isError( $result ) ) + { + return $result; + } + + $this->_templates[$parseInto]['content'] .= $result; + $this->_templates[$parseInto]['loaded'] = true; + return true; + } + + /** + * load a template that had autoload="off" + * + * This is needed, if you change the source of a template and want to + * load it, after changing the attribute. + * + * @access public + * @param string template name + * @return boolean true, if template could be loaded + */ + function loadTemplate( $template ) + { + $template = strtolower( $template ); + if( !isset( $this->_templates[$template] ) ) + { + return patErrorManager::raiseWarning( + PATTEMPLATE_WARNING_NO_TEMPLATE, + "Template '$template' does not exist." + ); + } + + if( $this->_templates[$template]['loaded'] === true ) + return true; + + if( $this->_templates[$template]['attributes']['parse'] == 'on' ) + { + return $this->readTemplatesFromInput( $this->_templates[$template]['attributes']['src'], $this->_templates[$template]['attributes']['reader'], null, $template ); + } + else + { + return $this->loadTemplateFromInput( $this->_templates[$template]['attributes']['src'], $this->_templates[$template]['attributes']['reader'], null, $template ); + } + } + + /** + * loads a patTemplate module + * + * Modules are located in the patTemplate folder and include: + * - Readers + * - Caches + * - Variable Modifiers + * - Filters + * - Functions + * - Stats + * + * @access public + * @param string moduleType (Reader|TemplateCache|Modifier|OutputFilter|InputFilter) + * @param string moduleName + * @param array parameters for the module + * @return object + */ + function &loadModule( $moduleType, $moduleName, $params = array(), $new = false ) + { + if( !isset( $this->_modules[$moduleType] ) ) + $this->_modules[$moduleType] = array(); + + $sig = md5( $moduleName . serialize( $params ) ); + + if( isset( $this->_modules[$moduleType][$sig] ) && $new === false ) { + return $this->_modules[$moduleType][$sig]; + } + + if( !class_exists( 'patTemplate_Module' ) ) + { + $file = sprintf( "%s/Module.php", $this->getIncludePath() ); + if( !file_exists( $file ) or !include_once $file ) + return patErrorManager::raiseError( PATTEMPLATE_ERROR_BASECLASS_NOT_FOUND, 'Could not load module base class.' ); + } + + $baseClass = 'patTemplate_' . $moduleType; + if( !class_exists( $baseClass ) ) + { + $baseFile = sprintf( "%s/%s.php", $this->getIncludePath(), $moduleType ); + if( !file_exists( $baseFile ) or !include_once $baseFile ) + return patErrorManager::raiseError( PATTEMPLATE_ERROR_BASECLASS_NOT_FOUND, "Could not load base class for $moduleType ($baseFile)." ); + } + + $moduleClass = 'patTemplate_' . $moduleType . '_' .$moduleName; + if( !class_exists( $moduleClass ) ) + { + if( isset( $this->_moduleDirs[$moduleType] ) ) + $dirs = $this->_moduleDirs[$moduleType]; + else + $dirs = array(); + array_push( $dirs, $this->getIncludePath() .'/'. $moduleType ); + + $found = false; + foreach( $dirs as $dir ) + { + $moduleFile = sprintf( "%s/%s.php", $dir, str_replace( '_', '/', $moduleName ) ); + + if ( file_exists( $moduleFile ) and include_once $moduleFile) { + $found = true; + break; + } + } + + if( !$found ) { + return patErrorManager::raiseError( PATTEMPLATE_ERROR_MODULE_NOT_FOUND, "Could not load module $moduleClass ($moduleFile)." ); + } + } + + if( !class_exists( $moduleClass ) ) + { + return patErrorManager::raiseError( PATTEMPLATE_ERROR_MODULE_NOT_FOUND, "Module file $moduleFile does not contain class $moduleClass." ); + } + + $this->_modules[$moduleType][$sig] = new $moduleClass; + if( method_exists( $this->_modules[$moduleType][$sig], 'setTemplateReference' ) ) + { + $this->_modules[$moduleType][$sig]->setTemplateReference( $this ); + } + + $this->_modules[$moduleType][$sig]->setParams( $params ); + + return $this->_modules[$moduleType][$sig]; + } + + /** + * checks whether a module exists. + * + * Modules are located in the patTemplate folder and include: + * - Readers + * - Caches + * - Variable Modifiers + * - Filters + * - Functions + * - Stats + * + * @access public + * @param string moduleType (Reader|TemplateCache|Modifier|OutputFilter|InputFilter) + * @param string moduleName + * @return boolean + */ + function moduleExists( $moduleType, $moduleName ) + { + // !!!JOOMLA VARIATION!!! + // cache checks on files + static $paths; + + if (!$paths) + { + $paths = array(); + } + + if (isset($this->_moduleDirs[$moduleType])) { + $dirs = $this->_moduleDirs[$moduleType]; + } else { + $dirs = array(); + } + array_push($dirs, $this->getIncludePath() .'/'. $moduleType); + + foreach ($dirs as $dir) { + $moduleFile = sprintf( "%s/%s.php", $dir, str_replace( '_', '/', $moduleName ) ); + if (!isset( $paths[$moduleFile] )) + { + if (!file_exists($moduleFile)) { + $paths[$moduleFile] = false; + } + else if (!is_readable($moduleFile)) { + $paths[$moduleFile] = false; + } + else + { + $paths[$moduleFile] = true; + } + } + + if (!$paths[$moduleFile]) { + continue; + } + return true; + } + return false; + } + + /** + * parses a template + * + * Parses a template and stores the parsed content. + * mode can be "w" for write (delete already parsed content) or "a" for append (appends the + * new parsed content to the already parsed content) + * + * @access public + * @param string name of the template + * @param string mode for the parsing + */ + function parseTemplate( $template, $mode = 'w' ) + { + $template = strtolower($template); + + if (!isset($this->_templates[$template])) { + return patErrorManager::raiseWarning( + PATTEMPLATE_WARNING_NO_TEMPLATE, + "Template '$template' does not exist." + ); + } + + /** + * template is not visible + */ + if ($this->_templates[$template]['attributes']['visibility'] == 'hidden') { + $this->_templates[$template]['result'] = ''; + $this->_templates[$template]['parsed'] = true; + return true; + } + + /** + * check, if the template has been loaded + * and load it if necessary. + */ + if ($this->_templates[$template]['loaded'] !== true) { + if ($this->_templates[$template]['attributes']['parse'] == 'on') { + $result = $this->readTemplatesFromInput( $this->_templates[$template]['attributes']['src'], $this->_templates[$template]['attributes']['reader'], null, $template ); + } else { + $result = $this->loadTemplateFromInput( $this->_templates[$template]['attributes']['src'], $this->_templates[$template]['attributes']['reader'], null, $template ); + } + if (patErrorManager::isError($result)) { + return $result; + } + } + + /** + * check for autoclear + */ + if( + isset( $this->_templates[$template]['attributes']['autoclear'] ) && + $this->_templates[$template]['attributes']['autoclear'] == 'yes' && + $mode === 'w' && + $this->_templates[$template]['lastMode'] != 'a' + ) { + $this->_templates[$template]['parsed'] = false; + } + + /** + * template has been parsed and mode is not 'append' + */ + if ($this->_templates[$template]['parsed'] === true && $mode === 'w') { + return true; + } + + $this->_templates[$template]['lastMode'] = $mode; + + $this->_initTemplate( $template ); + + if (!isset($this->_vars[$template]['rows'])) { + $this->_vars[$template]['rows'] = array(); + } + $loop = count( $this->_vars[$template]['rows'] ); + + /** + * loop at least one times + */ + if ($loop < 1) { + $loop = 1; + } + + if (isset($this->_templates[$template]['attributes']['maxloop'])) { + $loop = ceil( $loop / $this->_templates[$template]['attributes']['maxloop'] ) * $this->_templates[$template]['attributes']['maxloop']; + } + + $this->_templates[$template]['loop'] = max( $this->_templates[$template]['attributes']['loop'], $loop ); + + $start = 0; + if (isset($this->_templates[$template]['attributes']['limit'])) { + $p = strpos( $this->_templates[$template]['attributes']['limit'], ',' ); + if ($p === false) { + $this->_templates[$template]['loop'] = min( $this->_templates[$template]['loop'], $this->_templates[$template]['attributes']['limit'] ); + $start = 0; + } else { + $start = substr( $this->_templates[$template]['attributes']['limit'], 0, $p ); + $end = substr( $this->_templates[$template]['attributes']['limit'], $p+1 )+$start; + + $this->_templates[$template]['loop'] = min( $this->_templates[$template]['loop'], $end ); + } + } + + /** + * template should be cleared before parsing + */ + if ($mode == 'w') { + $this->_templates[$template]['result'] = ''; + $this->_templates[$template]['iteration'] = $start; + } + + $loopCount = 0; + for ($i = $start; $i < $this->_templates[$template]['loop']; $i++) { + $finished = false; + + unset( $this->_templates[$template]['vars'] ); + + /** + * fetch the variables + */ + $this->_fetchVariables( $template ); + + /** + * fetch the template + */ + $result = $this->_fetchTemplate($template); + + if ($result === false) { + $this->_templates[$template]['iteration']++; + continue; + } + + /** + * parse + */ + $this->_parseVariables( $template ); + $result = $this->_parseDependencies( $template ); + if (patErrorManager::isError($result)) { + return $result; + } + + /** + * store result + */ + $this->_templates[$template]['result'] .= $this->_templates[$template]['work']; + + $this->_templates[$template]['iteration']++; + + ++$loopCount; + + /** + * check for maximum loops + */ + if (isset($this->_templates[$template]['attributes']['maxloop'])) { + if ($loopCount == $this->_templates[$template]['attributes']['maxloop'] && $i < ($loop-1)) { + $loopCount = 0; + $finished = true; + $this->_templates[$template]['parsed'] = true; + $this->parseTemplate( $this->_templates[$template]['attributes']['parent'], 'a' ); + $this->_templates[$template]['parsed'] = false; + $this->_templates[$template]['result'] = ''; + } + } + } + + if (!$finished && isset($this->_templates[$template]['attributes']['maxloop'])) { + $this->_templates[$template]['parsed'] = true; + $this->parseTemplate( $this->_templates[$template]['attributes']['parent'], 'a', false ); + $this->_templates[$template]['parsed'] = false; + $this->_templates[$template]['result'] = ''; + $this->_templates[$this->_templates[$template]['attributes']['parent']]['work'] = ''; + } + + $this->_parseGlobals($template); + + $this->_handleUnusedVars($template); + + $this->_templates[$template]['parsed'] = true; + + if (isset($this->_templates[$template]['attributes']['autoclear']) && $this->_templates[$template]['attributes']['autoclear'] == 'yes') { + $this->_vars[$template] = array( + 'scalar' => array(), + 'rows' => array() + ); + } + + if (isset($this->_templates[$template]['attributes']['outputfilter'])) { + if (is_object($this->_templates[$template]['attributes']['outputfilter'])) { + $filter = &$this->_templates[$template]['attributes']['outputfilter']; + } else { + $filter = &$this->loadModule('OutputFilter', $this->_templates[$template]['attributes']['outputfilter']); + } + + if (patErrorManager::isError($filter)) { + return $filter; + } + + $this->_templates[$template]['result'] = $filter->apply($this->_templates[$template]['result']); + } + return true; + } + + /** + * Initialize a template + * + * This method checks the variable specifications and + * copys variables from other templates. + * + * @access private + * @param string name of the template + * @return boolean true on success + */ + function _initTemplate( $template ) + { + foreach( $this->_templates[$template]['copyVars'] as $dest => $src ) + { + /** + * copy from the same template + */ + if( !is_array( $src ) ) + { + $srcTemplate = $template; + $srcVar = $src; + } + else + { + $srcTemplate = $src[0]; + $srcVar = $src[1]; + } + + $copied = false; + + /** + * copy from another template + */ + if( isset( $this->_vars[$srcTemplate] ) ) + { + if( isset( $this->_vars[$srcTemplate]['scalar'][$srcVar] ) ) + { + $this->_vars[$template]['scalar'][$dest] = $this->_vars[$srcTemplate]['scalar'][$srcVar]; + continue; + } + + $rows = count( $this->_vars[$srcTemplate]['rows'] ); + + for( $i = 0; $i < $rows; $i++ ) + { + if( !isset( $this->_vars[$srcTemplate]['rows'][$i][$srcVar] ) ) + continue; + if( !isset( $this->_vars[$template]['rows'][$i] ) ) + $this->_vars[$template]['rows'][$i] = array(); + $this->_vars[$template]['rows'][$i][$dest] = $this->_vars[$srcTemplate]['rows'][$i][$srcVar]; + $copied = true; + } + } + if( !$copied && isset( $this->_globals[$srcVar] )) + { + $this->_vars[$template]['scalar'][$dest] = $this->_globals[$srcVar]; + } + + } + return true; + } + + /** + * parse all variables in a template + * + * @access private + * @param string + */ + function _parseVariables( $template ) + { + /** + * modify variables before parsing + */ + $this->_applyModifers($template, $this->_templates[$template]['vars']); + + foreach( $this->_templates[$template]['vars'] as $key => $value ) + { + if( is_array( $value ) ) + { + if( count( $this->_templates[$template]['currentDependencies'] ) == 1 ) + { + $child = $this->_templates[$template]['currentDependencies'][0]; + } + else + { + if( isset( $this->_templates[$template]['attributes']['child'] ) ) + $child = $this->_templates[$template]['attributes']['child']; + else + continue; + } + + $this->setAttribute( $child, 'autoclear', 'yes' ); + $this->addVar( $child, $key, $value ); + continue; + } + + $var = $this->_startTag.$key.$this->_endTag; + $this->_templates[$template]['work'] = str_replace( $var, $value, $this->_templates[$template]['work'] ); + } + return true; + } + + /** + * parse global variables in the template + * + * @access private + * @param string name of the template + * @return boolean + */ + function _parseGlobals($template) + { + $globalVars = $this->_globals; + $this->_applyModifers($template, $globalVars); + + foreach( $globalVars as $key => $value ) + { + if( is_array( $value ) ) + { + continue; + } + + $var = $this->_startTag.$key.$this->_endTag; + $this->_templates[$template]['result'] = str_replace( $var, $value, $this->_templates[$template]['result'] ); + } + return true; + } + + /** + * apply variable modifiers + * + * The variables will be passed by reference. + * + * @access private + * @param string name of the template (use modifiers from this template) + * @param array variables to which the modifiers should be applied + * @return boolean + */ + function _applyModifers($template, &$vars) + { + foreach ($this->_templates[$template]['modifyVars'] as $varname => $modifier) { + if (!isset($vars[$varname])) { + continue; + } + + if (($modifier['type'] === 'php' || $modifier['type'] === 'auto' ) && is_callable($modifier['mod'])) { + $vars[$varname] = call_user_func($modifier['mod'], $vars[$varname]); + continue; + } + + if ($modifier['type'] === 'php') { + continue; + } + + $mod = &$this->loadModule( 'Modifier', ucfirst( $modifier['mod'] ) ); + $vars[$varname] = $mod->modify( $vars[$varname], $modifier['params'] ); + } + + // apply the default modifier + if (isset($this->_templates[$template]['attributes']['defaultmodifier'])) { + + $defaultModifier = $this->_templates[$template]['attributes']['defaultmodifier']; + if (is_callable($defaultModifier)) { + $type = 'php'; + } else { + $type = 'custom'; + $defaultModifier = &$this->loadModule('Modifier', ucfirst($defaultModifier)); + } + + + foreach (array_keys($vars) as $varname) { + if (isset($this->_templates[$template]['modifyVars'][$varname])) { + continue; + } + if ($type === 'php') { + $vars[$varname] = call_user_func($defaultModifier, $vars[$varname]); + } else { + $vars[$varname] = $defaultModifier->modify($vars[$varname], array()); + } + } + } + + return true; + } + + /** + * parse all dependencies in a template + * + * @access private + * @param string + */ + function _parseDependencies($template) + { + $countDep = count( $this->_templates[$template]['currentDependencies'] ); + for ($i = 0; $i < $countDep; $i++) { + $depTemplate = $this->_templates[$template]['currentDependencies'][$i]; + if ($depTemplate == $template) { + return patErrorManager::raiseError(PATTEMPLATE_ERROR_RECURSION, 'You have an error in your template "' . $template . '", which leads to recursion'); + } + $this->parseTemplate($depTemplate); + $var = $this->_startTag.'TMPL:'.strtoupper( $depTemplate) .$this->_endTag; + $this->_templates[$template]['work'] = str_replace( $var, $this->_templates[$depTemplate]['result'], $this->_templates[$template]['work'] ); + } + return true; + } + + /** + * fetch plain template + * + * The template content will be stored in the template + * configuration so it can be used by other + * methods. + * + * @access private + * @param string template name + * @return boolean + */ + function _fetchTemplate( $template ) + { + switch( $this->_templates[$template]['attributes']['type'] ) + { + /** + * condition template + */ + case 'condition': + $value = $this->_getConditionValue($template, $this->_templates[$template]['attributes']['conditionvar']); + if ($value === false) { + $this->_templates[$template]['work'] = ''; + $this->_templates[$template]['currentDependencies'] = array(); + } else { + $this->_templates[$template]['work'] = $this->_templates[$template]['subtemplates'][$value]['data']; + $this->_templates[$template]['currentDependencies'] = $this->_templates[$template]['subtemplates'][$value]['dependencies']; + } + break; + + /** + * condition template + */ + case 'simplecondition': + foreach( $this->_templates[$template]['attributes']['requiredvars'] as $var ) + { + // different template scope + if( $var[0] !== $template ) { + $this->_fetchVariables($var[0]); + } + $value = null; + // fetch the local variable + if( isset( $this->_templates[$var[0]]['vars'][$var[1]] ) + && strlen( $this->_templates[$var[0]]['vars'][$var[1]] ) > 0 ) { + $value = $this->_templates[$var[0]]['vars'][$var[1]]; + } + if (isset($this->_templates[$template]['attributes']['useglobals'])) { + if(isset($this->_globals[$var[1]]) && strlen($this->_globals[$var[1]]) > 1) { + $value = $this->_globals[$var[1]]; + } + } + if ($value !== null) { + if ($var[2] === null) { + continue; + } else { + // Joomla! addition 23-June-2005 + // value wrapped in ## uses regex for comparison + $condition = $var[2]; + if (substr( $condition, 0, 1 ) == '#' && substr( $condition, -1, 1 ) == '#' ) { + if (preg_match( $condition, $value )) { + continue; + } + } else if ($condition == $value) { + continue; + } + /* Pat Original + if ($var[2] == $value) { + continue; + } + */ + } + } + + $this->_templates[$template]['work'] = ''; + $this->_templates[$template]['currentDependencies'] = array(); + break 2; + } + $this->_templates[$template]['work'] = $this->_templates[$template]['content']; + $this->_templates[$template]['currentDependencies'] = $this->_templates[$template]['dependencies']; + break; + + /** + * modulo template + */ + case 'modulo': + // check for empty template + + if ($this->_hasVariables($template)) { + $value = (string)($this->_templates[$template]['iteration'] + 1 ) % $this->_templates[$template]['attributes']['modulo']; + } else { + $value = '__empty'; + } + + $value = $this->_getConditionValue($template, $value, false); + if ($value === false) { + $this->_templates[$template]['work'] = ''; + $this->_templates[$template]['currentDependencies'] = array(); + } else { + $this->_templates[$template]['work'] = $this->_templates[$template]['subtemplates'][$value]['data']; + $this->_templates[$template]['currentDependencies'] = $this->_templates[$template]['subtemplates'][$value]['dependencies']; + } + break; + + /** + * standard template + */ + default: + $this->_templates[$template]['work'] = $this->_templates[$template]['content']; + $this->_templates[$template]['currentDependencies'] = $this->_templates[$template]['dependencies']; + break; + } + return true; + } + + /** + * check, whether a template contains variables + * + * @access private + * @param string template name + * @return boolean + */ + function _hasVariables($template) + { + if (!empty($this->_vars[$template]['scalar'])) { + return true; + } + if (isset($this->_vars[$template]['rows'][$this->_templates[$template]['iteration']])) { + return true; + } + return false; + } + + /** + * fetch the value of a condition variable + * + * _fetchVariables() has to be called before this + * method is being called. + * + * @access private + * @param string template name + * @param string condition value + * @param boolean flag that indicates whether value is the name of the variable that should be resolved + * + * @todo split this method into smaller check methods that will be called according to + * a priority list + */ + function _getConditionValue( $template, $value, $isVar = true ) + { + if ($isVar === true) { + if (isset($this->_templates[$template]['attributes']['conditiontmpl'])) { + $_template = $this->_templates[$template]['attributes']['conditiontmpl']; + $this->_fetchVariables($_template); + } else { + $_template = $template; + } + + /** + * get the value from the template variables + */ + if (!isset($this->_templates[$_template]['vars'][$value]) || strlen($this->_templates[$_template]['vars'][$value]) === 0) { + if ($this->_templates[$template]['attributes']['useglobals'] == 'yes' || $this->_templates[$template]['attributes']['useglobals'] == 'useglobals') { + if (isset( $this->_globals[$value] ) && strlen( $this->_globals[$value] ) > 0) { + $value = $this->_globals[$value]; + } else { + $value = '__empty'; + } + } else { + $value = '__empty'; + } + } else { + $value = $this->_templates[$_template]['vars'][$value]; + } + } else { + $_template = $template; + } + + // if value is empty and a template for empty has been defined, this + // has priority + if ($value === '__empty' && isset($this->_templates[$template]['subtemplates']['__empty'])) { + return $value; + } + + // only one iteration (but not empty), use the __single condition + if ($value !== '__empty' && $this->_templates[$_template]['loop'] === 1) { + if( isset($this->_templates[$template]['subtemplates']['__single'])) { + return '__single'; + } + } else { + + // is __first? + if( $this->_templates[$_template]['iteration'] == 0 ) { + if( isset( $this->_templates[$template]['subtemplates']['__first'] ) ) { + return '__first'; + } + } + + /** + * is __last? + */ + if (isset($this->_templates[$_template]['loop'])) { + $max = $this->_templates[$_template]['loop'] - 1; + if( $this->_templates[$_template]['iteration'] == $max ) { + if( isset( $this->_templates[$template]['subtemplates']['__last'] ) ) { + return '__last'; + } + } + } + } + + // search for exact match + foreach (array_keys($this->_templates[$template]['subtemplates']) as $key) { + if (isset($this->_templates[$template]['subtemplates'][$key]['attributes']['var'])) { + $var = $this->_templates[$template]['subtemplates'][$key]['attributes']['var']; + if (isset($this->_templates[$template]['vars'][$var])) { + $current = $this->_templates[$template]['vars'][$var]; + } else { + $current = null; + } + } else { + $current = $key; + } + + if ((string)$value === (string)$current) { + return $key; + } + } + + /** + * is __default? + */ + if( isset( $this->_templates[$template]['subtemplates']['__default'] ) ) { + return '__default'; + } + + return false; + } + + /** + * fetch variables for a template + * + * The variables will be stored in the template + * configuration so they can be used by other + * methods. + * + * @access private + * @param string template name + * @return boolean + */ + function _fetchVariables( $template ) + { + /** + * variables already have been fetched + */ + if (isset($this->_templates[$template]['vars'])) { + return true; + } + + $iteration = $this->_templates[$template]['iteration']; + + $vars = array(); + if( isset( $this->_templates[$template]['attributes']['varscope'] ) ) + { + if (!is_array($this->_templates[$template]['attributes']['varscope'])) { + $this->_templates[$template]['attributes']['varscope'] = array($this->_templates[$template]['attributes']['varscope']); + } + foreach ($this->_templates[$template]['attributes']['varscope'] as $scopeTemplate) { + if ($this->exists($scopeTemplate)) { + $this->_fetchVariables( $scopeTemplate ); + $vars = array_merge($this->_templates[$scopeTemplate]['vars'], $vars); + } else { + patErrorManager::raiseWarning(PATTEMPLATE_WARNING_NO_TEMPLATE, 'Template \''.$scopeTemplate.'\' does not exist, referenced in varscope attribute of template \''.$template.'\''); + } + } + } else { + $vars = array(); + } + + /** + * get the scalar variables + */ + if( isset( $this->_vars[$template] ) && isset( $this->_vars[$template]['scalar'] ) ) + { + $vars = array_merge( $vars, $this->_vars[$template]['scalar'] ); + } + + /** + * get the row variables + */ + if( isset( $this->_vars[$template]['rows'][$iteration] ) ) + { + $vars = array_merge( $vars, $this->_vars[$template]['rows'][$iteration] ); + } + + /** + * add some system variables + */ + $currentRow = $iteration + $this->_templates[$template]['attributes']['rowoffset']; + $vars['PAT_ROW_VAR'] = $currentRow; + + if( $this->_templates[$template]['attributes']['type'] == 'modulo' ) + { + $vars['PAT_MODULO_REP'] = ceil( $currentRow / $this->_templates[$template]['attributes']['modulo'] ); + $vars['PAT_MODULO'] = ( $this->_templates[$template]['iteration'] + 1 ) % $this->_templates[$template]['attributes']['modulo']; + } + + if( $this->_templates[$template]['attributes']['addsystemvars'] !== false ) + { + $vars['PATTEMPLATE_VERSION'] = $this->_systemVars['appVersion']; + $vars['PAT_LOOPS'] = $this->_templates[$template]['loop']; + + switch ($this->_templates[$template]['attributes']['addsystemvars']) + { + case 'boolean': + $trueValue = 'true'; + $falseValue = 'false'; + break; + case 'integer': + $trueValue = '1'; + $falseValue = '0'; + break; + default: + $trueValue = $this->_templates[$template]['attributes']['addsystemvars']; + $falseValue = ''; + break; + } + + $vars['PAT_IS_ODD'] = ( $currentRow % 2 == 1 ) ? $trueValue : $falseValue; + $vars['PAT_IS_EVEN'] = ( $currentRow % 2 == 0 ) ? $trueValue : $falseValue; + $vars['PAT_IS_FIRST'] = ( $currentRow == 1 ) ? $trueValue : $falseValue; + $vars['PAT_IS_LAST'] = ( $currentRow == $this->_templates[$template]['loop'] ) ? $trueValue : $falseValue; + $vars['PAT_ROW_TYPE'] = ( $currentRow % 2 == 1 ) ? 'odd' : 'even'; + } + + $this->_templates[$template]['vars'] = $vars; + return true; + } + + /** + * handle all unused variables in a template + * + * This is influenced by the 'unusedvars' attribute of the + * template + * + * @access private + * @param string + */ + function _handleUnusedVars( $template ) + { + $regexp = '/([^\\\])('.$this->_startTag.'[^a-z]+[^\\\]'.$this->_endTag.')/U'; + + switch( $this->_templates[$template]['attributes']['unusedvars'] ) + { + case 'comment': + $this->_templates[$template]['result'] = preg_replace( $regexp, '', $this->_templates[$template]['result'] ); + break; + case 'strip': + $this->_templates[$template]['result'] = preg_replace( $regexp, '\\1', $this->_templates[$template]['result'] ); + break; + case 'nbsp': + $this->_templates[$template]['result'] = preg_replace( $regexp, '\\1 ', $this->_templates[$template]['result'] ); + break; + case 'ignore': + break; + default: + $this->_templates[$template]['result'] = preg_replace( $regexp, '\\1'.$this->_templates[$template]['attributes']['unusedvars'], $this->_templates[$template]['result'] ); + break; + } + + // replace quoted variables + $regexp = '/[\\\]'.$this->_startTag.'([^a-z]+)[\\\]'.$this->_endTag.'/U'; + $this->_templates[$template]['result'] = preg_replace( $regexp, $this->_startTag.'\\1'.$this->_endTag, $this->_templates[$template]['result'] ); + + return true; + } + + /** + * returns a parsed Template + * + * If the template already has been parsed, it just returns the parsed template. + * If the template has not been loaded, it will be loaded. + * + * @access public + * @param string name of the template + * @param boolean whether to apply output filters + * @return string Content of the parsed template + * @see displayParsedTemplate() + */ + function getParsedTemplate( $name = null, $applyFilters = false ) + { + if (is_null($name)) { + $name = $this->_root; + } + + $name = strtolower( $name ); + $result = $this->parseTemplate( $name ); + + if (patErrorManager::isError( $result )) { + return $result; + } + + if ($applyFilters === false) { + return $this->_templates[$name]['result']; + } + + $result = $this->_templates[$name]['result']; + + $cnt = count ($this->_outputFilters); + for ($i = 0; $i < $cnt; $i++) { + $result = $this->_outputFilters[$i]->apply( $result ); + } + + return $result; + } + + /** + * displays a parsed Template + * + * If the template has not been loaded, it will be loaded. + * + * @see getParsedTemplate() + * @param string name of the template + * @param boolean whether to apply output filters + * @return boolean true on success + * @access public + */ + function displayParsedTemplate($name = null, $applyFilters = true) + { + $result = $this->getParsedTemplate($name, $applyFilters); + + /** + * error happened + */ + if (patErrorManager::isError($result)) { + return $result; + } + + echo $result; + return true; + } + + /** + * parse a template and push the result into a variable of any other + * template + * + * If the template already has been parsed, it will just be pushed into the variable. + * If the template has not been loaded, it will be loaded. + * + * @access public + * @param string name of the template + * @return string Content of the parsed template + * @param boolean if set to true, the value will be appended to the value already stored. + * @see getParsedTemplate() + * @see addVar() + */ + function parseIntoVar( $srcTmpl, $destTmpl, $var, $append = false ) + { + $srcTmpl = strtolower( $srcTmpl ); + $destTmpl = strtolower( $destTmpl ); + $var = strtoupper($var); + + $result = $this->parseTemplate( $srcTmpl ); + + if( patErrorManager::isError( $result ) ) + return $result; + + if( $append !== true || !isset( $this->_vars[$destTmpl]['scalar'][$var] ) ) + $this->_vars[$destTmpl]['scalar'][$var] = ''; + + $this->_vars[$destTmpl]['scalar'][$var] .= $this->_templates[$srcTmpl]['result']; + + return true; + } + + /** + * clears a parsed Template + * + * Parsed Content, variables and the loop attribute are cleared + * + * If you will not be using this template anymore, then you should + * call freeTemplate() + * + * @access public + * @param string name of the template + * @param boolean set this to true to clear all child templates, too + * @see clearAllTemplates() + * @see freeTemplate() + */ + function clearTemplate( $name, $recursive = false ) + { + $name = strtolower( $name ); + $this->_templates[$name]['parsed'] = false; + $this->_templates[$name]['work'] = ''; + $this->_templates[$name]['iteration'] = 0; + $this->_templates[$name]['result'] = ''; + $this->_vars[$name] = array( + 'scalar' => array(), + 'rows' => array() + ); + + if (!empty($this->_templates[$name]['defaultVars'])) { + foreach ($this->_templates[$name]['defaultVars'] as $varname => $value) { + $this->addVar($name, $varname, $value); + } + } + + /** + * clear child templates as well + */ + if( $recursive === true ) + { + $deps = $this->_getDependencies( $name ); + foreach( $deps as $dep ) + { + $this->clearTemplate( $dep, true ); + } + } + return true; + } + + /** + * clears all templates + * + * @access public + * @uses clearTemplate() + */ + function clearAllTemplates() + { + $templates = array_keys( $this->_templates ); + $cnt = count( $templates ); + for( $i = 0; $i < $cnt; $i++ ) + { + $this->clearTemplate( $templates[$i] ); + } + return true; + } + + /** + * frees a template + * + * All memory consumed by the template + * will be freed. + * + * @access public + * @param string name of the template + * @param boolean clear dependencies of the template + * @see freeAllTemplates() + */ + function freeTemplate( $name, $recursive = false ) + { + $name = strtolower( $name ); + $key = array_search( $name, $this->_templateList ); + if( $key === false ) + { + return patErrorManager::raiseWarning( + PATTEMPLATE_WARNING_NO_TEMPLATE, + "Template '$name' does not exist." + ); + } + + unset( $this->_templateList[$key] ); + $this->_templateList = array_values( $this->_templateList ); + + /** + * free child templates as well + */ + if( $recursive === true ) + { + $deps = $this->_getDependencies( $name ); + foreach( $deps as $dep ) + { + $this->freeTemplate( $dep, true ); + } + } + + unset( $this->_templates[$name] ); + unset( $this->_vars[$name] ); + if (isset($this->_discoveredPlaceholders[$name])) { + unset($this->_discoveredPlaceholders[$name]); + } + + return true; + } + + /** + * frees all templates + * + * All memory consumed by the templates + * will be freed. + * + * @access public + * @see freeTemplate() + */ + function freeAllTemplates() + { + $this->_templates = array(); + $this->_vars = array(); + $this->_templateList = array(); + } + + /** + * get _all_ dependencies of a template, + * regardless of the subtemplates + * + * @access private + * @param string template name + * @return array list of all subtemplates + */ + function _getDependencies( $template ) + { + $deps = array(); + if( isset( $this->_templates[$template]['dependencies'] ) ) + $deps = $this->_templates[$template]['dependencies']; + + if( isset( $this->_templates[$template]['subtemplates'] ) ) + { + foreach( $this->_templates[$template]['subtemplates'] as $sub ) + { + if( isset( $sub['dependencies'] ) ) + $deps = array_merge( $deps, $sub['dependencies'] ); + } + } + $deps = array_unique( $deps ); + return $deps; + } + + /** + * Displays useful information about all or named templates + * + * This method breaks BC, as it now awaits an array instead of + * unlimited parameters. + * + * @param mixed array of templates that should be dumped, or null if you + * want all templates to be dumped + * @param string dumper + * @access public + */ + function dump( $restrict = null, $dumper = 'Html' ) + { + if( is_string( $restrict ) ) + $restrict = array( $restrict ); + + $dumper = &$this->loadModule( 'Dump', $dumper ); + + if( patErrorManager::isError( $dumper ) ) + { + return $dumper; + } + + if( is_null( $restrict ) ) + { + $templates = $this->_templates; + $vars = $this->_vars; + } + else + { + $restrict = array_map( 'strtolower', $restrict ); + + $templates = array(); + $vars = array(); + + foreach( $this->_templates as $name => $spec ) + { + if( !in_array( $name, $restrict ) ) + continue; + $templates[$name] = $spec; + $vars[$name] = $this->_vars[$name]; + } + } + + $dumper->displayHeader(); + $dumper->dumpGlobals( $this->_globals ); + $dumper->dumpTemplates( $templates, $vars ); + $dumper->displayFooter(); + + return true; + } + + /** + * get the include path + * + * @access public + * @return string + */ + function getIncludePath() + { + return PATTEMPLATE_INCLUDE_PATH; + } + + /** + * apply input filters that have been set + * + * This is being called by the readers. + * + * @access public + * @param string template + * @return string filtered templeta + */ + function applyInputFilters( $template ) + { + $cnt = count( $this->_inputFilters ); + for( $i = 0; $i < $cnt; $i++ ) + { + $template = $this->_inputFilters[$i]->apply( $template ); + } + return $template; + } + + /** + * checks, whether a placeholder exists in a template + * + * @access public + * @param string name of the placeholder + * @param string name of the template + * @param boolean whether to use the cached result of a previous call + */ + function placeholderExists($placeholder, $tmpl, $cached = true) + { + $tmpl = strtolower($tmpl); + $placeholder = strtoupper($placeholder); + + if (!$this->exists($tmpl)) { + return false; + } + + if ($cached === true) { + if (isset($this->_discoveredPlaceholders[$tmpl]) && isset($this->_discoveredPlaceholders[$tmpl][$placeholder])) { + return $this->_discoveredPlaceholders[$tmpl][$placeholder]; + } + } + + if (isset($this->_templates[$tmpl]['subtemplates'])) { + $content = ''; + foreach ($this->_templates[$tmpl]['subtemplates'] as $temp) { + if (!isset($temp['data'])) { + continue; + } + $content .= $temp['data']; + } + } else { + $content = $this->_templates[$tmpl]['content']; + } + + $search = $this->_startTag . $placeholder . $this->_endTag; + if (strstr($content, $search) !== false) { + $this->_discoveredPlaceholders[$tmpl][$placeholder] = true; + return true; + } + $this->_discoveredPlaceholders[$tmpl][$placeholder] = false; + return false; + } + + /** + * Convert the template to its string representation. + * + * This method allows you to just echo the patTemplate + * object in order to display the template. + * + * Requires PHP5 + * + * + * $tmpl = new patTemplate(); + * $tmpl->readTemplatesFromFile( 'myfile.tmpl' ); + * echo $tmpl; + * + * + * @access private + * @return string + */ + function __toString() + { + return $this->getParsedTemplate(); + } +} +?> diff --git a/oss/joomla/trunk/libraries/phpinputfilter/inputfilter.php b/oss/joomla/trunk/libraries/phpinputfilter/inputfilter.php index bf85a752..8c2f1709 100644 --- a/oss/joomla/trunk/libraries/phpinputfilter/inputfilter.php +++ b/oss/joomla/trunk/libraries/phpinputfilter/inputfilter.php @@ -1,551 +1,551 @@ -tagsArray = $tagsArray; - $this->attrArray = $attrArray; - $this->tagsMethod = $tagsMethod; - $this->attrMethod = $attrMethod; - $this->xssAuto = $xssAuto; - } - - /** - * 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' - * @return mixed $source 'cleaned' version of input parameter - */ - function process($source) - { - /* - * 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] = $this->remove($this->decode($value)); - } - } - return $source; - } else - /* - * Or a string? - */ - if (is_string($source) && !empty ($source)) - { - // filter source for XSS and other 'bad' code etc. - return $this->remove($this->decode($source)); - } else - { - /* - * Not an array or string.. return the passed parameter - */ - return $source; - } - } - - /** - * Internal method to iteratively remove all unwanted tags and attributes - * - * @access protected - * @param string $source Input string to be 'cleaned' - * @return string $source 'cleaned' version of input parameter - */ - function remove($source) - { - $loopCounter = 0; - /* - * Iteration provides nested tag protection - */ - while ($source != $this->filterTags($source)) - { - $source = $this->filterTags($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 $source 'cleaned' version of input parameter - */ - function filterTags($source) - { - /* - * In the beginning we don't really have a tag, so everything is - * postTag - */ - $preTag = null; - $postTag = $source; - - /* - * 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) - { - $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] - */ - $attr = substr($fromSpace, 0, $nextSpace); - } - - // Last Attribute Pair - if (!$attr) - { - $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->filterAttr($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 $newSet Filtered array of attribute pairs - */ - function filterAttr($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 ((!eregi("^[a-z]*$", $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('/\s+/', '', $attrSubSet[1]); - // strip double quotes - $attrSubSet[1] = str_replace('"', '', $attrSubSet[1]); - // [requested feature] 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 (InputFilter::badAttributeValue($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; - } - - /** - * Function to determine if contents of an attribute is safe - * - * @access protected - * @param array $attrSubSet A 2 element array for attributes name,value - * @return boolean True if bad code is detected - */ - function badAttributeValue($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)); - } - - /** - * Try to convert to plaintext - * - * @access protected - * @param string $source - * @return string Plaintext string - */ - function decode($source) - { - // url decode - $source = html_entity_decode($source, ENT_QUOTES, "ISO-8859-1"); - // convert decimal - $source = preg_replace('/&#(\d+);/me', "chr(\\1)", $source); // decimal notation - // convert hex - $source = preg_replace('/&#x([a-f0-9]+);/mei', "chr(0x\\1)", $source); // hex notation - return $source; - } - - /** - * Method to be called by another php script. Processes for SQL injection - * - * @access public - * @param mixed $source input string/array-of-string to be 'cleaned' - * @param resource $connection - An open MySQL connection - * @return string 'cleaned' version of input parameter - */ - function safeSQL($source, & $connection) - { - // clean all elements in this array - if (is_array($source)) - { - foreach ($source as $key => $value) - { - // filter element for SQL injection - if (is_string($value)) - { - $source[$key] = $this->quoteSmart($this->decode($value), $connection); - } - } - return $source; - // clean this string - } else - if (is_string($source)) - { - // filter source for SQL injection - if (is_string($source)) - { - return $this->quoteSmart($this->decode($source), $connection); - } - // return parameter as given - } else - { - return $source; - } - } - - /** - * Method to escape a string - * - * @author Chris Tobin - * @author Daniel Morris - * - * @access protected - * @param string $source - * @param resource $connection An open MySQL connection - * @return string Escaped string - */ - function quoteSmart($source, & $connection) - { - /* - * Strip escaping slashes if necessary - */ - if (get_magic_quotes_gpc()) - { - $source = stripslashes($source); - } - - /* - * Escape numeric and text values - */ - $source = $this->escapeString($source, $connection); - return $source; - } - - /** - * @author Chris Tobin - * @author Daniel Morris - * - * @access protected - * @param string $source - * @param resource $connection An open MySQL connection - * @return string Escaped string - */ - function escapeString($string, & $connection) { - /* - * Use the appropriate escape string depending upon which version of php - * you are running - */ - if (version_compare(phpversion(), '4.3.0', '<')) { - $string = mysql_escape_string($string); - } else { - $string = mysql_real_escape_string($string); - } - - return $string; - } -} -?> \ No newline at end of file +tagsArray = $tagsArray; + $this->attrArray = $attrArray; + $this->tagsMethod = $tagsMethod; + $this->attrMethod = $attrMethod; + $this->xssAuto = $xssAuto; + } + + /** + * 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' + * @return mixed $source 'cleaned' version of input parameter + */ + function process($source) + { + /* + * 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] = $this->remove($this->decode($value)); + } + } + return $source; + } else + /* + * Or a string? + */ + if (is_string($source) && !empty ($source)) + { + // filter source for XSS and other 'bad' code etc. + return $this->remove($this->decode($source)); + } else + { + /* + * Not an array or string.. return the passed parameter + */ + return $source; + } + } + + /** + * Internal method to iteratively remove all unwanted tags and attributes + * + * @access protected + * @param string $source Input string to be 'cleaned' + * @return string $source 'cleaned' version of input parameter + */ + function remove($source) + { + $loopCounter = 0; + /* + * Iteration provides nested tag protection + */ + while ($source != $this->filterTags($source)) + { + $source = $this->filterTags($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 $source 'cleaned' version of input parameter + */ + function filterTags($source) + { + /* + * In the beginning we don't really have a tag, so everything is + * postTag + */ + $preTag = null; + $postTag = $source; + + /* + * 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) + { + $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] + */ + $attr = substr($fromSpace, 0, $nextSpace); + } + + // Last Attribute Pair + if (!$attr) + { + $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->filterAttr($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 $newSet Filtered array of attribute pairs + */ + function filterAttr($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('/\s+/', '', $attrSubSet[1]); + // strip double quotes + $attrSubSet[1] = str_replace('"', '', $attrSubSet[1]); + // [requested feature] 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 (InputFilter::badAttributeValue($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; + } + + /** + * Function to determine if contents of an attribute is safe + * + * @access protected + * @param array $attrSubSet A 2 element array for attributes name,value + * @return boolean True if bad code is detected + */ + function badAttributeValue($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)); + } + + /** + * Try to convert to plaintext + * + * @access protected + * @param string $source + * @return string Plaintext string + */ + function decode($source) + { + // url decode + $source = html_entity_decode($source, ENT_QUOTES, "ISO-8859-1"); + // convert decimal + $source = preg_replace('/&#(\d+);/me', "chr(\\1)", $source); // decimal notation + // convert hex + $source = preg_replace('/&#x([a-f0-9]+);/mei', "chr(0x\\1)", $source); // hex notation + return $source; + } + + /** + * Method to be called by another php script. Processes for SQL injection + * + * @access public + * @param mixed $source input string/array-of-string to be 'cleaned' + * @param resource $connection - An open MySQL connection + * @return string 'cleaned' version of input parameter + */ + function safeSQL($source, & $connection) + { + // clean all elements in this array + if (is_array($source)) + { + foreach ($source as $key => $value) + { + // filter element for SQL injection + if (is_string($value)) + { + $source[$key] = $this->quoteSmart($this->decode($value), $connection); + } + } + return $source; + // clean this string + } else + if (is_string($source)) + { + // filter source for SQL injection + if (is_string($source)) + { + return $this->quoteSmart($this->decode($source), $connection); + } + // return parameter as given + } else + { + return $source; + } + } + + /** + * Method to escape a string + * + * @author Chris Tobin + * @author Daniel Morris + * + * @access protected + * @param string $source + * @param resource $connection An open MySQL connection + * @return string Escaped string + */ + function quoteSmart($source, & $connection) + { + /* + * Strip escaping slashes if necessary + */ + if (get_magic_quotes_gpc()) + { + $source = stripslashes($source); + } + + /* + * Escape numeric and text values + */ + $source = $this->escapeString($source, $connection); + return $source; + } + + /** + * @author Chris Tobin + * @author Daniel Morris + * + * @access protected + * @param string $source + * @param resource $connection An open MySQL connection + * @return string Escaped string + */ + function escapeString($string, & $connection) { + /* + * Use the appropriate escape string depending upon which version of php + * you are running + */ + if (version_compare(phpversion(), '4.3.0', '<')) { + $string = mysql_escape_string($string); + } else { + $string = mysql_real_escape_string($string); + } + + return $string; + } +} +?> diff --git a/oss/joomla/trunk/libraries/phpmailer/phpmailer.php b/oss/joomla/trunk/libraries/phpmailer/phpmailer.php index 524ff79c..f1da55cb 100644 --- a/oss/joomla/trunk/libraries/phpmailer/phpmailer.php +++ b/oss/joomla/trunk/libraries/phpmailer/phpmailer.php @@ -1,1909 +1,1909 @@ -ContentType = 'text/html'; - } else { - $this->ContentType = 'text/plain'; - } - } - - /** - * Sets Mailer to send message using SMTP. - * @return void - */ - function IsSMTP() { - $this->Mailer = 'smtp'; - } - - /** - * Sets Mailer to send message using PHP mail() function. - * @return void - */ - function IsMail() { - $this->Mailer = 'mail'; - } - - /** - * Sets Mailer to send message using the $Sendmail program. - * @return void - */ - function IsSendmail() { - $this->Mailer = 'sendmail'; - } - - /** - * Sets Mailer to send message using the qmail MTA. - * @return void - */ - function IsQmail() { - $this->Sendmail = '/var/qmail/bin/sendmail'; - $this->Mailer = 'sendmail'; - } - - ///////////////////////////////////////////////// - // METHODS, RECIPIENTS - ///////////////////////////////////////////////// - - /** - * Adds a "To" address. - * @param string $address - * @param string $name - * @return void - */ - function AddAddress($address, $name = '') { - $cur = count($this->to); - $this->to[$cur][0] = trim($address); - $this->to[$cur][1] = $name; - } - - /** - * Adds a "Cc" address. Note: this function works - * with the SMTP mailer on win32, not with the "mail" - * mailer. - * @param string $address - * @param string $name - * @return void - */ - function AddCC($address, $name = '') { - $cur = count($this->cc); - $this->cc[$cur][0] = trim($address); - $this->cc[$cur][1] = $name; - } - - /** - * Adds a "Bcc" address. Note: this function works - * with the SMTP mailer on win32, not with the "mail" - * mailer. - * @param string $address - * @param string $name - * @return void - */ - function AddBCC($address, $name = '') { - $cur = count($this->bcc); - $this->bcc[$cur][0] = trim($address); - $this->bcc[$cur][1] = $name; - } - - /** - * Adds a "Reply-To" address. - * @param string $address - * @param string $name - * @return void - */ - function AddReplyTo($address, $name = '') { - $cur = count($this->ReplyTo); - $this->ReplyTo[$cur][0] = trim($address); - $this->ReplyTo[$cur][1] = $name; - } - - ///////////////////////////////////////////////// - // METHODS, MAIL SENDING - ///////////////////////////////////////////////// - - /** - * Creates message and assigns Mailer. If the message is - * not sent successfully then it returns false. Use the ErrorInfo - * variable to view description of the error. - * @return bool - */ - function Send() { - $header = ''; - $body = ''; - $result = true; - - if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) { - $this->SetError($this->Lang('provide_address')); - return false; - } - - /* Set whether the message is multipart/alternative */ - if(!empty($this->AltBody)) { - $this->ContentType = 'multipart/alternative'; - } - - $this->error_count = 0; // reset errors - $this->SetMessageType(); - $header .= $this->CreateHeader(); - $body = $this->CreateBody(); - - if($body == '') { - return false; - } - - /* Choose the mailer */ - switch($this->Mailer) { - case 'sendmail': - $result = $this->SendmailSend($header, $body); - break; - case 'smtp': - $result = $this->SmtpSend($header, $body); - break; - case 'mail': - $result = $this->MailSend($header, $body); - break; - default: - $result = $this->MailSend($header, $body); - break; - //$this->SetError($this->Mailer . $this->Lang('mailer_not_supported')); - //$result = false; - //break; - } - - return $result; - } - - /** - * Sends mail using the $Sendmail program. - * @access private - * @return bool - */ - function SendmailSend($header, $body) { - if ($this->Sender != '') { - $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender)); - } else { - $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail)); - } - - if(!@$mail = popen($sendmail, 'w')) { - $this->SetError($this->Lang('execute') . $this->Sendmail); - return false; - } - - fputs($mail, $header); - fputs($mail, $body); - - $result = pclose($mail); - if (version_compare(phpversion(), '4.2.3') == -1) { - $result = $result >> 8 & 0xFF; - } - if($result != 0) { - $this->SetError($this->Lang('execute') . $this->Sendmail); - return false; - } - return true; - } - - /** - * Sends mail using the PHP mail() function. - * @access private - * @return bool - */ - function MailSend($header, $body) { - - $to = ''; - for($i = 0; $i < count($this->to); $i++) { - if($i != 0) { $to .= ', '; } - $to .= $this->AddrFormat($this->to[$i]); - } - - $toArr = split(',', $to); - - $params = sprintf("-oi -f %s", $this->Sender); - if ($this->Sender != '' && strlen(ini_get('safe_mode')) < 1) { - $old_from = ini_get('sendmail_from'); - ini_set('sendmail_from', $this->Sender); - if ($this->SingleTo === true && count($toArr) > 1) { - foreach ($toArr as $key => $val) { - $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); - } - } else { - $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); - } - } else { - if ($this->SingleTo === true && count($toArr) > 1) { - foreach ($toArr as $key => $val) { - $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); - } - } else { - $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header); - } - } - - if (isset($old_from)) { - ini_set('sendmail_from', $old_from); - } - - if(!$rt) { - $this->SetError($this->Lang('instantiate')); - return false; - } - - return true; - } - - /** - * Sends mail via SMTP using PhpSMTP (Author: - * Chris Ryan). Returns bool. Returns false if there is a - * bad MAIL FROM, RCPT, or DATA input. - * @access private - * @return bool - */ - function SmtpSend($header, $body) { - include_once($this->PluginDir . 'smtp.php'); - $error = ''; - $bad_rcpt = array(); - - if(!$this->SmtpConnect()) { - return false; - } - - $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender; - if(!$this->smtp->Mail($smtp_from)) { - $error = $this->Lang('from_failed') . $smtp_from; - $this->SetError($error); - $this->smtp->Reset(); - return false; - } - - /* Attempt to send attach all recipients */ - for($i = 0; $i < count($this->to); $i++) { - if(!$this->smtp->Recipient($this->to[$i][0])) { - $bad_rcpt[] = $this->to[$i][0]; - } - } - for($i = 0; $i < count($this->cc); $i++) { - if(!$this->smtp->Recipient($this->cc[$i][0])) { - $bad_rcpt[] = $this->cc[$i][0]; - } - } - for($i = 0; $i < count($this->bcc); $i++) { - if(!$this->smtp->Recipient($this->bcc[$i][0])) { - $bad_rcpt[] = $this->bcc[$i][0]; - } - } - - if(count($bad_rcpt) > 0) { // Create error message - for($i = 0; $i < count($bad_rcpt); $i++) { - if($i != 0) { - $error .= ', '; - } - $error .= $bad_rcpt[$i]; - } - $error = $this->Lang('recipients_failed') . $error; - $this->SetError($error); - $this->smtp->Reset(); - return false; - } - - if(!$this->smtp->Data($header . $body)) { - $this->SetError($this->Lang('data_not_accepted')); - $this->smtp->Reset(); - return false; - } - if($this->SMTPKeepAlive == true) { - $this->smtp->Reset(); - } else { - $this->SmtpClose(); - } - - return true; - } - - /** - * Initiates a connection to an SMTP server. Returns false if the - * operation failed. - * @access private - * @return bool - */ - function SmtpConnect() { - if($this->smtp == NULL) { - $this->smtp = new SMTP(); - } - - $this->smtp->do_debug = $this->SMTPDebug; - $hosts = explode(';', $this->Host); - $index = 0; - $connection = ($this->smtp->Connected()); - - /* Retry while there is no connection */ - while($index < count($hosts) && $connection == false) { - $hostinfo = array(); - if(eregi('^(.+):([0-9]+)$', $hosts[$index], $hostinfo)) { - $host = $hostinfo[1]; - $port = $hostinfo[2]; - } else { - $host = $hosts[$index]; - $port = $this->Port; - } - - if($this->smtp->Connect(((!empty($this->SMTPSecure))?$this->SMTPSecure.'://':'').$host, $port, $this->Timeout)) { - if ($this->Helo != '') { - $this->smtp->Hello($this->Helo); - } else { - $this->smtp->Hello($this->ServerHostname()); - } - - $connection = true; - if($this->SMTPAuth) { - if(!$this->smtp->Authenticate($this->Username, $this->Password)) { - $this->SetError($this->Lang('authenticate')); - $this->smtp->Reset(); - $connection = false; - } - } - } - $index++; - } - if(!$connection) { - $this->SetError($this->Lang('connect_host')); - } - - return $connection; - } - - /** - * Closes the active SMTP session if one exists. - * @return void - */ - function SmtpClose() { - if($this->smtp != NULL) { - if($this->smtp->Connected()) { - $this->smtp->Quit(); - $this->smtp->Close(); - } - } - } - - /** - * Sets the language for all class error messages. Returns false - * if it cannot load the language file. The default language type - * is English. - * @param string $lang_type Type of language (e.g. Portuguese: "br") - * @param string $lang_path Path to the language file directory - * @access public - * @return bool - */ - function SetLanguage($lang_type, $lang_path = 'language/') { - if(file_exists($lang_path.'phpmailer.lang-'.$lang_type.'.php')) { - include($lang_path.'phpmailer.lang-'.$lang_type.'.php'); - } elseif (file_exists($lang_path.'phpmailer.lang-en.php')) { - include($lang_path.'phpmailer.lang-en.php'); - } else { - $PHPMAILER_LANG = array(); - $PHPMAILER_LANG["provide_address"] = 'You must provide at least one ' . - $PHPMAILER_LANG["mailer_not_supported"] = ' mailer is not supported.'; - $PHPMAILER_LANG["execute"] = 'Could not execute: '; - $PHPMAILER_LANG["instantiate"] = 'Could not instantiate mail function.'; - $PHPMAILER_LANG["authenticate"] = 'SMTP Error: Could not authenticate.'; - $PHPMAILER_LANG["from_failed"] = 'The following From address failed: '; - $PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: The following ' . - $PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data not accepted.'; - $PHPMAILER_LANG["connect_host"] = 'SMTP Error: Could not connect to SMTP host.'; - $PHPMAILER_LANG["file_access"] = 'Could not access file: '; - $PHPMAILER_LANG["file_open"] = 'File Error: Could not open file: '; - $PHPMAILER_LANG["encoding"] = 'Unknown encoding: '; - $PHPMAILER_LANG["signing"] = 'Signing Error: '; - } - $this->language = $PHPMAILER_LANG; - - return true; - } - - ///////////////////////////////////////////////// - // METHODS, MESSAGE CREATION - ///////////////////////////////////////////////// - - /** - * Creates recipient headers. - * @access private - * @return string - */ - function AddrAppend($type, $addr) { - $addr_str = $type . ': '; - $addr_str .= $this->AddrFormat($addr[0]); - if(count($addr) > 1) { - for($i = 1; $i < count($addr); $i++) { - $addr_str .= ', ' . $this->AddrFormat($addr[$i]); - } - } - $addr_str .= $this->LE; - - return $addr_str; - } - - /** - * Formats an address correctly. - * @access private - * @return string - */ - function AddrFormat($addr) { - if(empty($addr[1])) { - $formatted = $this->SecureHeader($addr[0]); - } else { - $formatted = $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">"; - } - - return $formatted; - } - - /** - * Wraps message for use with mailers that do not - * automatically perform wrapping and for quoted-printable. - * Original written by philippe. - * @access private - * @return string - */ - function WrapText($message, $length, $qp_mode = false) { - $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE; - // If utf-8 encoding is used, we will need to make sure we don't - // split multibyte characters when we wrap - $is_utf8 = (strtolower($this->CharSet) == "utf-8"); - - $message = $this->FixEOL($message); - if (substr($message, -1) == $this->LE) { - $message = substr($message, 0, -1); - } - - $line = explode($this->LE, $message); - $message = ''; - for ($i=0 ;$i < count($line); $i++) { - $line_part = explode(' ', $line[$i]); - $buf = ''; - for ($e = 0; $e $length)) { - $space_left = $length - strlen($buf) - 1; - if ($e != 0) { - if ($space_left > 20) { - $len = $space_left; - if ($is_utf8) { - $len = $this->UTF8CharBoundary($word, $len); - } elseif (substr($word, $len - 1, 1) == "=") { - $len--; - } elseif (substr($word, $len - 2, 1) == "=") { - $len -= 2; - } - $part = substr($word, 0, $len); - $word = substr($word, $len); - $buf .= ' ' . $part; - $message .= $buf . sprintf("=%s", $this->LE); - } else { - $message .= $buf . $soft_break; - } - $buf = ''; - } - while (strlen($word) > 0) { - $len = $length; - if ($is_utf8) { - $len = $this->UTF8CharBoundary($word, $len); - } elseif (substr($word, $len - 1, 1) == "=") { - $len--; - } elseif (substr($word, $len - 2, 1) == "=") { - $len -= 2; - } - $part = substr($word, 0, $len); - $word = substr($word, $len); - - if (strlen($word) > 0) { - $message .= $part . sprintf("=%s", $this->LE); - } else { - $buf = $part; - } - } - } else { - $buf_o = $buf; - $buf .= ($e == 0) ? $word : (' ' . $word); - - if (strlen($buf) > $length and $buf_o != '') { - $message .= $buf_o . $soft_break; - $buf = $word; - } - } - } - $message .= $buf . $this->LE; - } - - return $message; - } - - /** - * Finds last character boundary prior to maxLength in a utf-8 - * quoted (printable) encoded string. - * Original written by Colin Brown. - * @access private - * @param string $encodedText utf-8 QP text - * @param int $maxLength find last character boundary prior to this length - * @return int - */ - function UTF8CharBoundary($encodedText, $maxLength) { - $foundSplitPos = false; - $lookBack = 3; - while (!$foundSplitPos) { - $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack); - $encodedCharPos = strpos($lastChunk, "="); - if ($encodedCharPos !== false) { - // Found start of encoded character byte within $lookBack block. - // Check the encoded byte value (the 2 chars after the '=') - $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2); - $dec = hexdec($hex); - if ($dec < 128) { // Single byte character. - // If the encoded char was found at pos 0, it will fit - // otherwise reduce maxLength to start of the encoded char - $maxLength = ($encodedCharPos == 0) ? $maxLength : - $maxLength - ($lookBack - $encodedCharPos); - $foundSplitPos = true; - } elseif ($dec >= 192) { // First byte of a multi byte character - // Reduce maxLength to split at start of character - $maxLength = $maxLength - ($lookBack - $encodedCharPos); - $foundSplitPos = true; - } elseif ($dec < 192) { // Middle byte of a multi byte character, look further back - $lookBack += 3; - } - } else { - // No encoded character found - $foundSplitPos = true; - } - } - return $maxLength; - } - - /** - * Set the body wrapping. - * @access private - * @return void - */ - function SetWordWrap() { - if($this->WordWrap < 1) { - return; - } - - switch($this->message_type) { - case 'alt': - /* fall through */ - case 'alt_attachments': - $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap); - break; - default: - $this->Body = $this->WrapText($this->Body, $this->WordWrap); - break; - } - } - - /** - * Assembles message header. - * @access private - * @return string - */ - function CreateHeader() { - $result = ''; - - /* Set the boundaries */ - $uniq_id = md5(uniqid(time())); - $this->boundary[1] = 'b1_' . $uniq_id; - $this->boundary[2] = 'b2_' . $uniq_id; - - $result .= $this->HeaderLine('Date', $this->RFCDate()); - if($this->Sender == '') { - $result .= $this->HeaderLine('Return-Path', trim($this->From)); - } else { - $result .= $this->HeaderLine('Return-Path', trim($this->Sender)); - } - - /* To be created automatically by mail() */ - if($this->Mailer != 'mail') { - if(count($this->to) > 0) { - $result .= $this->AddrAppend('To', $this->to); - } elseif (count($this->cc) == 0) { - $result .= $this->HeaderLine('To', 'undisclosed-recipients:;'); - } - } - - $from = array(); - $from[0][0] = trim($this->From); - $from[0][1] = $this->FromName; - $result .= $this->AddrAppend('From', $from); - - /* sendmail and mail() extract Cc from the header before sending */ - if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->cc) > 0)) { - $result .= $this->AddrAppend('Cc', $this->cc); - } - - /* sendmail and mail() extract Bcc from the header before sending */ - if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) { - $result .= $this->AddrAppend('Bcc', $this->bcc); - } - - if(count($this->ReplyTo) > 0) { - $result .= $this->AddrAppend('Reply-To', $this->ReplyTo); - } - - /* mail() sets the subject itself */ - if($this->Mailer != 'mail') { - $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject))); - } - - if($this->MessageID != '') { - $result .= $this->HeaderLine('Message-ID',$this->MessageID); - } else { - $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE); - } - $result .= $this->HeaderLine('X-Priority', $this->Priority); - $result .= $this->HeaderLine('X-Mailer', 'PHPMailer (phpmailer.sourceforge.net) [version ' . $this->Version . ']'); - - if($this->ConfirmReadingTo != '') { - $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>'); - } - - // Add custom headers - for($index = 0; $index < count($this->CustomHeader); $index++) { - $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1]))); - } - if (!$this->sign_key_file) { - $result .= $this->HeaderLine('MIME-Version', '1.0'); - $result .= $this->GetMailMIME(); - } - - return $result; - } - - /** - * Returns the message MIME. - * @access private - * @return string - */ - function GetMailMIME() { - $result = ''; - switch($this->message_type) { - case 'plain': - $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding); - $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet); - break; - case 'attachments': - /* fall through */ - case 'alt_attachments': - if($this->InlineImageExists()){ - $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE); - } else { - $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;'); - $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); - } - break; - case 'alt': - $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;'); - $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); - break; - } - - if($this->Mailer != 'mail') { - $result .= $this->LE.$this->LE; - } - - return $result; - } - - /** - * Assembles the message body. Returns an empty string on failure. - * @access private - * @return string - */ - function CreateBody() { - $result = ''; - if ($this->sign_key_file) { - $result .= $this->GetMailMIME(); - } - - $this->SetWordWrap(); - - switch($this->message_type) { - case 'alt': - $result .= $this->GetBoundary($this->boundary[1], '', 'text/plain', ''); - $result .= $this->EncodeString($this->AltBody, $this->Encoding); - $result .= $this->LE.$this->LE; - $result .= $this->GetBoundary($this->boundary[1], '', 'text/html', ''); - $result .= $this->EncodeString($this->Body, $this->Encoding); - $result .= $this->LE.$this->LE; - $result .= $this->EndBoundary($this->boundary[1]); - break; - case 'plain': - $result .= $this->EncodeString($this->Body, $this->Encoding); - break; - case 'attachments': - $result .= $this->GetBoundary($this->boundary[1], '', '', ''); - $result .= $this->EncodeString($this->Body, $this->Encoding); - $result .= $this->LE; - $result .= $this->AttachAll(); - break; - case 'alt_attachments': - $result .= sprintf("--%s%s", $this->boundary[1], $this->LE); - $result .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE); - $result .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body - $result .= $this->EncodeString($this->AltBody, $this->Encoding); - $result .= $this->LE.$this->LE; - $result .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body - $result .= $this->EncodeString($this->Body, $this->Encoding); - $result .= $this->LE.$this->LE; - $result .= $this->EndBoundary($this->boundary[2]); - $result .= $this->AttachAll(); - break; - } - - if($this->IsError()) { - $result = ''; - } else if ($this->sign_key_file) { - $file = tempnam("", "mail"); - $fp = fopen($file, "w"); - fwrite($fp, $result); - fclose($fp); - $signed = tempnam("", "signed"); - - if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_cert_file, array("file://".$this->sign_key_file, $this->sign_key_pass), null)) { - $fp = fopen($signed, "r"); - $result = fread($fp, filesize($this->sign_key_file)); - $result = ''; - while(!feof($fp)){ - $result = $result . fread($fp, 1024); - } - fclose($fp); - } else { - $this->SetError($this->Lang("signing").openssl_error_string()); - $result = ''; - } - - unlink($file); - unlink($signed); - } - - return $result; - } - - /** - * Returns the start of a message boundary. - * @access private - */ - function GetBoundary($boundary, $charSet, $contentType, $encoding) { - $result = ''; - if($charSet == '') { - $charSet = $this->CharSet; - } - if($contentType == '') { - $contentType = $this->ContentType; - } - if($encoding == '') { - $encoding = $this->Encoding; - } - $result .= $this->TextLine('--' . $boundary); - $result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet); - $result .= $this->LE; - $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding); - $result .= $this->LE; - - return $result; - } - - /** - * Returns the end of a message boundary. - * @access private - */ - function EndBoundary($boundary) { - return $this->LE . '--' . $boundary . '--' . $this->LE; - } - - /** - * Sets the message type. - * @access private - * @return void - */ - function SetMessageType() { - if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) { - $this->message_type = 'plain'; - } else { - if(count($this->attachment) > 0) { - $this->message_type = 'attachments'; - } - if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) { - $this->message_type = 'alt'; - } - if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) { - $this->message_type = 'alt_attachments'; - } - } - } - - /* Returns a formatted header line. - * @access private - * @return string - */ - function HeaderLine($name, $value) { - return $name . ': ' . $value . $this->LE; - } - - /** - * Returns a formatted mail line. - * @access private - * @return string - */ - function TextLine($value) { - return $value . $this->LE; - } - - ///////////////////////////////////////////////// - // CLASS METHODS, ATTACHMENTS - ///////////////////////////////////////////////// - - /** - * Adds an attachment from a path on the filesystem. - * Returns false if the file could not be found - * or accessed. - * @param string $path Path to the attachment. - * @param string $name Overrides the attachment name. - * @param string $encoding File encoding (see $Encoding). - * @param string $type File extension (MIME) type. - * @return bool - */ - function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') { - if(!@is_file($path)) { - $this->SetError($this->Lang('file_access') . $path); - return false; - } - - $filename = basename($path); - if($name == '') { - $name = $filename; - } - - $cur = count($this->attachment); - $this->attachment[$cur][0] = $path; - $this->attachment[$cur][1] = $filename; - $this->attachment[$cur][2] = $name; - $this->attachment[$cur][3] = $encoding; - $this->attachment[$cur][4] = $type; - $this->attachment[$cur][5] = false; // isStringAttachment - $this->attachment[$cur][6] = 'attachment'; - $this->attachment[$cur][7] = 0; - - return true; - } - - /** - * Attaches all fs, string, and binary attachments to the message. - * Returns an empty string on failure. - * @access private - * @return string - */ - function AttachAll() { - /* Return text of body */ - $mime = array(); - - /* Add all attachments */ - for($i = 0; $i < count($this->attachment); $i++) { - /* Check for string attachment */ - $bString = $this->attachment[$i][5]; - if ($bString) { - $string = $this->attachment[$i][0]; - } else { - $path = $this->attachment[$i][0]; - } - - $filename = $this->attachment[$i][1]; - $name = $this->attachment[$i][2]; - $encoding = $this->attachment[$i][3]; - $type = $this->attachment[$i][4]; - $disposition = $this->attachment[$i][6]; - $cid = $this->attachment[$i][7]; - - $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE); - $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE); - $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE); - - if($disposition == 'inline') { - $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE); - } - - $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE); - - /* Encode as string attachment */ - if($bString) { - $mime[] = $this->EncodeString($string, $encoding); - if($this->IsError()) { - return ''; - } - $mime[] = $this->LE.$this->LE; - } else { - $mime[] = $this->EncodeFile($path, $encoding); - if($this->IsError()) { - return ''; - } - $mime[] = $this->LE.$this->LE; - } - } - - $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE); - - return join('', $mime); - } - - /** - * Encodes attachment in requested format. Returns an - * empty string on failure. - * @access private - * @return string - */ - function EncodeFile ($path, $encoding = 'base64') { - if(!@$fd = fopen($path, 'rb')) { - $this->SetError($this->Lang('file_open') . $path); - return ''; - } - $magic_quotes = get_magic_quotes_runtime(); - set_magic_quotes_runtime(0); - $file_buffer = fread($fd, filesize($path)); - $file_buffer = $this->EncodeString($file_buffer, $encoding); - fclose($fd); - set_magic_quotes_runtime($magic_quotes); - - return $file_buffer; - } - - /** - * Encodes string to requested format. Returns an - * empty string on failure. - * @access private - * @return string - */ - function EncodeString ($str, $encoding = 'base64') { - $encoded = ''; - switch(strtolower($encoding)) { - case 'base64': - /* chunk_split is found in PHP >= 3.0.6 */ - $encoded = chunk_split(base64_encode($str), 76, $this->LE); - break; - case '7bit': - case '8bit': - $encoded = $this->FixEOL($str); - if (substr($encoded, -(strlen($this->LE))) != $this->LE) - $encoded .= $this->LE; - break; - case 'binary': - $encoded = $str; - break; - case 'quoted-printable': - $encoded = $this->EncodeQP($str); - break; - default: - $this->SetError($this->Lang('encoding') . $encoding); - break; - } - return $encoded; - } - - /** - * Encode a header string to best of Q, B, quoted or none. - * @access private - * @return string - */ - function EncodeHeader ($str, $position = 'text') { - $x = 0; - - switch (strtolower($position)) { - case 'phrase': - if (!preg_match('/[\200-\377]/', $str)) { - /* Can't use addslashes as we don't know what value has magic_quotes_sybase. */ - $encoded = addcslashes($str, "\0..\37\177\\\""); - if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) { - return ($encoded); - } else { - return ("\"$encoded\""); - } - } - $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches); - break; - case 'comment': - $x = preg_match_all('/[()"]/', $str, $matches); - /* Fall-through */ - case 'text': - default: - $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches); - break; - } - - if ($x == 0) { - return ($str); - } - - $maxlen = 75 - 7 - strlen($this->CharSet); - /* Try to select the encoding which should produce the shortest output */ - if (strlen($str)/3 < $x) { - $encoding = 'B'; - if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) { - // Use a custom function which correctly encodes and wraps long - // multibyte strings without breaking lines within a character - $encoded = $this->Base64EncodeWrapMB($str); - } else { - $encoded = base64_encode($str); - $maxlen -= $maxlen % 4; - $encoded = trim(chunk_split($encoded, $maxlen, "\n")); - } - } else { - $encoding = 'Q'; - $encoded = $this->EncodeQ($str, $position); - $encoded = $this->WrapText($encoded, $maxlen, true); - $encoded = str_replace('='.$this->LE, "\n", trim($encoded)); - } - - $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded); - $encoded = trim(str_replace("\n", $this->LE, $encoded)); - - return $encoded; - } - - /** - * Checks if a string contains multibyte characters. - * @access private - * @param string $str multi-byte text to wrap encode - * @return bool - */ - function HasMultiBytes($str) { - if (function_exists('mb_strlen')) { - return (strlen($str) > mb_strlen($str, $this->CharSet)); - } else { // Assume no multibytes (we can't handle without mbstring functions anyway) - return False; - } - } - - /** - * Correctly encodes and wraps long multibyte strings for mail headers - * without breaking lines within a character. - * Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php - * @access private - * @param string $str multi-byte text to wrap encode - * @return string - */ - function Base64EncodeWrapMB($str) { - $start = "=?".$this->CharSet."?B?"; - $end = "?="; - $encoded = ""; - - $mb_length = mb_strlen($str, $this->CharSet); - // Each line must have length <= 75, including $start and $end - $length = 75 - strlen($start) - strlen($end); - // Average multi-byte ratio - $ratio = $mb_length / strlen($str); - // Base64 has a 4:3 ratio - $offset = $avgLength = floor($length * $ratio * .75); - - for ($i = 0; $i < $mb_length; $i += $offset) { - $lookBack = 0; - - do { - $offset = $avgLength - $lookBack; - $chunk = mb_substr($str, $i, $offset, $this->CharSet); - $chunk = base64_encode($chunk); - $lookBack++; - } - while (strlen($chunk) > $length); - - $encoded .= $chunk . $this->LE; - } - - // Chomp the last linefeed - $encoded = substr($encoded, 0, -strlen($this->LE)); - return $encoded; - } - - /** - * Encode string to quoted-printable. - * @access private - * @return string - */ - function EncodeQP( $input = '', $line_max = 76, $space_conv = false ) { - $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); - $lines = preg_split('/(?:\r\n|\r|\n)/', $input); - $eol = "\r\n"; - $escape = '='; - $output = ''; - while( list(, $line) = each($lines) ) { - $linlen = strlen($line); - $newline = ''; - for($i = 0; $i < $linlen; $i++) { - $c = substr( $line, $i, 1 ); - $dec = ord( $c ); - if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E - $c = '=2E'; - } - if ( $dec == 32 ) { - if ( $i == ( $linlen - 1 ) ) { // convert space at eol only - $c = '=20'; - } else if ( $space_conv ) { - $c = '=20'; - } - } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required - $h2 = floor($dec/16); - $h1 = floor($dec%16); - $c = $escape.$hex[$h2].$hex[$h1]; - } - if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted - $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay - $newline = ''; - // check if newline first character will be point or not - if ( $dec == 46 ) { - $c = '=2E'; - } - } - $newline .= $c; - } // end of for - $output .= $newline.$eol; - } // end of while - return $output; - } - - /** - * Encode string to q encoding. - * @access private - * @return string - */ - function EncodeQ ($str, $position = 'text') { - /* There should not be any EOL in the string */ - $encoded = preg_replace("[\r\n]", '', $str); - - switch (strtolower($position)) { - case 'phrase': - $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded); - break; - case 'comment': - $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded); - case 'text': - default: - /* Replace every high ascii, control =, ? and _ characters */ - $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e', - "'='.sprintf('%02X', ord('\\1'))", $encoded); - break; - } - - /* Replace every spaces to _ (more readable than =20) */ - $encoded = str_replace(' ', '_', $encoded); - - return $encoded; - } - - /** - * Adds a string or binary attachment (non-filesystem) to the list. - * This method can be used to attach ascii or binary data, - * such as a BLOB record from a database. - * @param string $string String attachment data. - * @param string $filename Name of the attachment. - * @param string $encoding File encoding (see $Encoding). - * @param string $type File extension (MIME) type. - * @return void - */ - function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream') { - /* Append to $attachment array */ - $cur = count($this->attachment); - $this->attachment[$cur][0] = $string; - $this->attachment[$cur][1] = $filename; - $this->attachment[$cur][2] = $filename; - $this->attachment[$cur][3] = $encoding; - $this->attachment[$cur][4] = $type; - $this->attachment[$cur][5] = true; // isString - $this->attachment[$cur][6] = 'attachment'; - $this->attachment[$cur][7] = 0; - } - - /** - * Adds an embedded attachment. This can include images, sounds, and - * just about any other document. Make sure to set the $type to an - * image type. For JPEG images use "image/jpeg" and for GIF images - * use "image/gif". - * @param string $path Path to the attachment. - * @param string $cid Content ID of the attachment. Use this to identify - * the Id for accessing the image in an HTML form. - * @param string $name Overrides the attachment name. - * @param string $encoding File encoding (see $Encoding). - * @param string $type File extension (MIME) type. - * @return bool - */ - function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') { - - if(!@is_file($path)) { - $this->SetError($this->Lang('file_access') . $path); - return false; - } - - $filename = basename($path); - if($name == '') { - $name = $filename; - } - - /* Append to $attachment array */ - $cur = count($this->attachment); - $this->attachment[$cur][0] = $path; - $this->attachment[$cur][1] = $filename; - $this->attachment[$cur][2] = $name; - $this->attachment[$cur][3] = $encoding; - $this->attachment[$cur][4] = $type; - $this->attachment[$cur][5] = false; - $this->attachment[$cur][6] = 'inline'; - $this->attachment[$cur][7] = $cid; - - return true; - } - - /** - * Returns true if an inline attachment is present. - * @access private - * @return bool - */ - function InlineImageExists() { - $result = false; - for($i = 0; $i < count($this->attachment); $i++) { - if($this->attachment[$i][6] == 'inline') { - $result = true; - break; - } - } - - return $result; - } - - ///////////////////////////////////////////////// - // CLASS METHODS, MESSAGE RESET - ///////////////////////////////////////////////// - - /** - * Clears all recipients assigned in the TO array. Returns void. - * @return void - */ - function ClearAddresses() { - $this->to = array(); - } - - /** - * Clears all recipients assigned in the CC array. Returns void. - * @return void - */ - function ClearCCs() { - $this->cc = array(); - } - - /** - * Clears all recipients assigned in the BCC array. Returns void. - * @return void - */ - function ClearBCCs() { - $this->bcc = array(); - } - - /** - * Clears all recipients assigned in the ReplyTo array. Returns void. - * @return void - */ - function ClearReplyTos() { - $this->ReplyTo = array(); - } - - /** - * Clears all recipients assigned in the TO, CC and BCC - * array. Returns void. - * @return void - */ - function ClearAllRecipients() { - $this->to = array(); - $this->cc = array(); - $this->bcc = array(); - } - - /** - * Clears all previously set filesystem, string, and binary - * attachments. Returns void. - * @return void - */ - function ClearAttachments() { - $this->attachment = array(); - } - - /** - * Clears all custom headers. Returns void. - * @return void - */ - function ClearCustomHeaders() { - $this->CustomHeader = array(); - } - - ///////////////////////////////////////////////// - // CLASS METHODS, MISCELLANEOUS - ///////////////////////////////////////////////// - - /** - * Adds the error message to the error container. - * Returns void. - * @access private - * @return void - */ - function SetError($msg) { - $this->error_count++; - $this->ErrorInfo = $msg; - } - - /** - * Returns the proper RFC 822 formatted date. - * @access private - * @return string - */ - function RFCDate() { - $tz = date('Z'); - $tzs = ($tz < 0) ? '-' : '+'; - $tz = abs($tz); - $tz = (int)($tz/3600)*100 + ($tz%3600)/60; - $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz); - - return $result; - } - - /** - * Returns the appropriate server variable. Should work with both - * PHP 4.1.0+ as well as older versions. Returns an empty string - * if nothing is found. - * @access private - * @return mixed - */ - function ServerVar($varName) { - global $HTTP_SERVER_VARS; - global $HTTP_ENV_VARS; - - if(!isset($_SERVER)) { - $_SERVER = $HTTP_SERVER_VARS; - if(!isset($_SERVER['REMOTE_ADDR'])) { - $_SERVER = $HTTP_ENV_VARS; // must be Apache - } - } - - if(isset($_SERVER[$varName])) { - return $_SERVER[$varName]; - } else { - return ''; - } - } - - /** - * Returns the server hostname or 'localhost.localdomain' if unknown. - * @access private - * @return string - */ - function ServerHostname() { - if ($this->Hostname != '') { - $result = $this->Hostname; - } elseif ($this->ServerVar('SERVER_NAME') != '') { - $result = $this->ServerVar('SERVER_NAME'); - } else { - $result = 'localhost.localdomain'; - } - - return $result; - } - - /** - * Returns a message in the appropriate language. - * @access private - * @return string - */ - function Lang($key) { - if(count($this->language) < 1) { - $this->SetLanguage('en'); // set the default language - } - - if(isset($this->language[$key])) { - return $this->language[$key]; - } else { - return 'Language string failed to load: ' . $key; - } - } - - /** - * Returns true if an error occurred. - * @return bool - */ - function IsError() { - return ($this->error_count > 0); - } - - /** - * Changes every end of line from CR or LF to CRLF. - * @access private - * @return string - */ - function FixEOL($str) { - $str = str_replace("\r\n", "\n", $str); - $str = str_replace("\r", "\n", $str); - $str = str_replace("\n", $this->LE, $str); - return $str; - } - - /** - * Adds a custom header. - * @return void - */ - function AddCustomHeader($custom_header) { - $this->CustomHeader[] = explode(':', $custom_header, 2); - } - - /** - * Evaluates the message and returns modifications for inline images and backgrounds - * @access public - * @return $message - */ - function MsgHTML($message,$basedir='') { - preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images); - if(isset($images[2])) { - foreach($images[2] as $i => $url) { - // do not change urls for absolute images (thanks to corvuscorax) - if (!preg_match('/^[A-z][A-z]*:\/\//',$url)) { - $filename = basename($url); - $directory = dirname($url); - ($directory == '.')?$directory='':''; - $cid = 'cid:' . md5($filename); - $fileParts = split("\.", $filename); - $ext = $fileParts[1]; - $mimeType = $this->_mime_types($ext); - if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; } - if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; } - if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) { - $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message); - } - } - } - } - $this->IsHTML(true); - $this->Body = $message; - $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message))); - if ( !empty($textMsg) && empty($this->AltBody) ) { - $this->AltBody = html_entity_decode($textMsg); - } - if ( empty($this->AltBody) ) { - $this->AltBody = 'To view this email message, open the email in with HTML compatibility!' . "\n\n"; - } - } - - /** - * Gets the mime type of the embedded or inline image - * @access private - * @return mime type of ext - */ - function _mime_types($ext = '') { - $mimes = array( - 'ai' => 'application/postscript', - 'aif' => 'audio/x-aiff', - 'aifc' => 'audio/x-aiff', - 'aiff' => 'audio/x-aiff', - 'avi' => 'video/x-msvideo', - 'bin' => 'application/macbinary', - 'bmp' => 'image/bmp', - 'class' => 'application/octet-stream', - 'cpt' => 'application/mac-compactpro', - 'css' => 'text/css', - 'dcr' => 'application/x-director', - 'dir' => 'application/x-director', - 'dll' => 'application/octet-stream', - 'dms' => 'application/octet-stream', - 'doc' => 'application/msword', - 'dvi' => 'application/x-dvi', - 'dxr' => 'application/x-director', - 'eml' => 'message/rfc822', - 'eps' => 'application/postscript', - 'exe' => 'application/octet-stream', - 'gif' => 'image/gif', - 'gtar' => 'application/x-gtar', - 'htm' => 'text/html', - 'html' => 'text/html', - 'jpe' => 'image/jpeg', - 'jpeg' => 'image/jpeg', - 'jpg' => 'image/jpeg', - 'hqx' => 'application/mac-binhex40', - 'js' => 'application/x-javascript', - 'lha' => 'application/octet-stream', - 'log' => 'text/plain', - 'lzh' => 'application/octet-stream', - 'mid' => 'audio/midi', - 'midi' => 'audio/midi', - 'mif' => 'application/vnd.mif', - 'mov' => 'video/quicktime', - 'movie' => 'video/x-sgi-movie', - 'mp2' => 'audio/mpeg', - 'mp3' => 'audio/mpeg', - 'mpe' => 'video/mpeg', - 'mpeg' => 'video/mpeg', - 'mpg' => 'video/mpeg', - 'mpga' => 'audio/mpeg', - 'oda' => 'application/oda', - 'pdf' => 'application/pdf', - 'php' => 'application/x-httpd-php', - 'php3' => 'application/x-httpd-php', - 'php4' => 'application/x-httpd-php', - 'phps' => 'application/x-httpd-php-source', - 'phtml' => 'application/x-httpd-php', - 'png' => 'image/png', - 'ppt' => 'application/vnd.ms-powerpoint', - 'ps' => 'application/postscript', - 'psd' => 'application/octet-stream', - 'qt' => 'video/quicktime', - 'ra' => 'audio/x-realaudio', - 'ram' => 'audio/x-pn-realaudio', - 'rm' => 'audio/x-pn-realaudio', - 'rpm' => 'audio/x-pn-realaudio-plugin', - 'rtf' => 'text/rtf', - 'rtx' => 'text/richtext', - 'rv' => 'video/vnd.rn-realvideo', - 'sea' => 'application/octet-stream', - 'shtml' => 'text/html', - 'sit' => 'application/x-stuffit', - 'so' => 'application/octet-stream', - 'smi' => 'application/smil', - 'smil' => 'application/smil', - 'swf' => 'application/x-shockwave-flash', - 'tar' => 'application/x-tar', - 'text' => 'text/plain', - 'txt' => 'text/plain', - 'tgz' => 'application/x-tar', - 'tif' => 'image/tiff', - 'tiff' => 'image/tiff', - 'wav' => 'audio/x-wav', - 'wbxml' => 'application/vnd.wap.wbxml', - 'wmlc' => 'application/vnd.wap.wmlc', - 'word' => 'application/msword', - 'xht' => 'application/xhtml+xml', - 'xhtml' => 'application/xhtml+xml', - 'xl' => 'application/excel', - 'xls' => 'application/vnd.ms-excel', - 'xml' => 'text/xml', - 'xsl' => 'text/xml', - 'zip' => 'application/zip' - ); - return ( ! isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)]; - } - - /** - * Set (or reset) Class Objects (variables) - * - * Usage Example: - * $page->set('X-Priority', '3'); - * - * @access public - * @param string $name Parameter Name - * @param mixed $value Parameter Value - * NOTE: will not work with arrays, there are no arrays to set/reset - */ - function set ( $name, $value = '' ) { - if ( isset($this->$name) ) { - $this->$name = $value; - } else { - $this->SetError('Cannot set or reset variable ' . $name); - return false; - } - } - - /** - * Read a file from a supplied filename and return it. - * - * @access public - * @param string $filename Parameter File Name - */ - function getFile($filename) { - $return = ''; - if ($fp = fopen($filename, 'rb')) { - while (!feof($fp)) { - $return .= fread($fp, 1024); - } - fclose($fp); - return $return; - } else { - return false; - } - } - - /** - * Strips newlines to prevent header injection. - * @access private - * @param string $str String - * @return string - */ - function SecureHeader($str) { - $str = trim($str); - $str = str_replace("\r", "", $str); - $str = str_replace("\n", "", $str); - return $str; - } - - /** - * Set the private key file and password to sign the message. - * - * @access public - * @param string $key_filename Parameter File Name - * @param string $key_pass Password for private key - */ - function Sign($cert_filename, $key_filename, $key_pass) { - $this->sign_cert_file = $cert_filename; - $this->sign_key_file = $key_filename; - $this->sign_key_pass = $key_pass; - } - -} - -?> +ContentType = 'text/html'; + } else { + $this->ContentType = 'text/plain'; + } + } + + /** + * Sets Mailer to send message using SMTP. + * @return void + */ + function IsSMTP() { + $this->Mailer = 'smtp'; + } + + /** + * Sets Mailer to send message using PHP mail() function. + * @return void + */ + function IsMail() { + $this->Mailer = 'mail'; + } + + /** + * Sets Mailer to send message using the $Sendmail program. + * @return void + */ + function IsSendmail() { + $this->Mailer = 'sendmail'; + } + + /** + * Sets Mailer to send message using the qmail MTA. + * @return void + */ + function IsQmail() { + $this->Sendmail = '/var/qmail/bin/sendmail'; + $this->Mailer = 'sendmail'; + } + + ///////////////////////////////////////////////// + // METHODS, RECIPIENTS + ///////////////////////////////////////////////// + + /** + * Adds a "To" address. + * @param string $address + * @param string $name + * @return void + */ + function AddAddress($address, $name = '') { + $cur = count($this->to); + $this->to[$cur][0] = trim($address); + $this->to[$cur][1] = $name; + } + + /** + * Adds a "Cc" address. Note: this function works + * with the SMTP mailer on win32, not with the "mail" + * mailer. + * @param string $address + * @param string $name + * @return void + */ + function AddCC($address, $name = '') { + $cur = count($this->cc); + $this->cc[$cur][0] = trim($address); + $this->cc[$cur][1] = $name; + } + + /** + * Adds a "Bcc" address. Note: this function works + * with the SMTP mailer on win32, not with the "mail" + * mailer. + * @param string $address + * @param string $name + * @return void + */ + function AddBCC($address, $name = '') { + $cur = count($this->bcc); + $this->bcc[$cur][0] = trim($address); + $this->bcc[$cur][1] = $name; + } + + /** + * Adds a "Reply-To" address. + * @param string $address + * @param string $name + * @return void + */ + function AddReplyTo($address, $name = '') { + $cur = count($this->ReplyTo); + $this->ReplyTo[$cur][0] = trim($address); + $this->ReplyTo[$cur][1] = $name; + } + + ///////////////////////////////////////////////// + // METHODS, MAIL SENDING + ///////////////////////////////////////////////// + + /** + * Creates message and assigns Mailer. If the message is + * not sent successfully then it returns false. Use the ErrorInfo + * variable to view description of the error. + * @return bool + */ + function Send() { + $header = ''; + $body = ''; + $result = true; + + if((count($this->to) + count($this->cc) + count($this->bcc)) < 1) { + $this->SetError($this->Lang('provide_address')); + return false; + } + + /* Set whether the message is multipart/alternative */ + if(!empty($this->AltBody)) { + $this->ContentType = 'multipart/alternative'; + } + + $this->error_count = 0; // reset errors + $this->SetMessageType(); + $header .= $this->CreateHeader(); + $body = $this->CreateBody(); + + if($body == '') { + return false; + } + + /* Choose the mailer */ + switch($this->Mailer) { + case 'sendmail': + $result = $this->SendmailSend($header, $body); + break; + case 'smtp': + $result = $this->SmtpSend($header, $body); + break; + case 'mail': + $result = $this->MailSend($header, $body); + break; + default: + $result = $this->MailSend($header, $body); + break; + //$this->SetError($this->Mailer . $this->Lang('mailer_not_supported')); + //$result = false; + //break; + } + + return $result; + } + + /** + * Sends mail using the $Sendmail program. + * @access private + * @return bool + */ + function SendmailSend($header, $body) { + if ($this->Sender != '') { + $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender)); + } else { + $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail)); + } + + if(!@$mail = popen($sendmail, 'w')) { + $this->SetError($this->Lang('execute') . $this->Sendmail); + return false; + } + + fputs($mail, $header); + fputs($mail, $body); + + $result = pclose($mail); + if (version_compare(phpversion(), '4.2.3') == -1) { + $result = $result >> 8 & 0xFF; + } + if($result != 0) { + $this->SetError($this->Lang('execute') . $this->Sendmail); + return false; + } + return true; + } + + /** + * Sends mail using the PHP mail() function. + * @access private + * @return bool + */ + function MailSend($header, $body) { + + $to = ''; + for($i = 0; $i < count($this->to); $i++) { + if($i != 0) { $to .= ', '; } + $to .= $this->AddrFormat($this->to[$i]); + } + + $toArr = split(',', $to); + + $params = sprintf("-oi -f %s", $this->Sender); + if ($this->Sender != '' && strlen(ini_get('safe_mode')) < 1) { + $old_from = ini_get('sendmail_from'); + ini_set('sendmail_from', $this->Sender); + if ($this->SingleTo === true && count($toArr) > 1) { + foreach ($toArr as $key => $val) { + $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); + } + } else { + $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); + } + } else { + if ($this->SingleTo === true && count($toArr) > 1) { + foreach ($toArr as $key => $val) { + $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); + } + } else { + $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header); + } + } + + if (isset($old_from)) { + ini_set('sendmail_from', $old_from); + } + + if(!$rt) { + $this->SetError($this->Lang('instantiate')); + return false; + } + + return true; + } + + /** + * Sends mail via SMTP using PhpSMTP (Author: + * Chris Ryan). Returns bool. Returns false if there is a + * bad MAIL FROM, RCPT, or DATA input. + * @access private + * @return bool + */ + function SmtpSend($header, $body) { + include_once($this->PluginDir . 'smtp.php'); + $error = ''; + $bad_rcpt = array(); + + if(!$this->SmtpConnect()) { + return false; + } + + $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender; + if(!$this->smtp->Mail($smtp_from)) { + $error = $this->Lang('from_failed') . $smtp_from; + $this->SetError($error); + $this->smtp->Reset(); + return false; + } + + /* Attempt to send attach all recipients */ + for($i = 0; $i < count($this->to); $i++) { + if(!$this->smtp->Recipient($this->to[$i][0])) { + $bad_rcpt[] = $this->to[$i][0]; + } + } + for($i = 0; $i < count($this->cc); $i++) { + if(!$this->smtp->Recipient($this->cc[$i][0])) { + $bad_rcpt[] = $this->cc[$i][0]; + } + } + for($i = 0; $i < count($this->bcc); $i++) { + if(!$this->smtp->Recipient($this->bcc[$i][0])) { + $bad_rcpt[] = $this->bcc[$i][0]; + } + } + + if(count($bad_rcpt) > 0) { // Create error message + for($i = 0; $i < count($bad_rcpt); $i++) { + if($i != 0) { + $error .= ', '; + } + $error .= $bad_rcpt[$i]; + } + $error = $this->Lang('recipients_failed') . $error; + $this->SetError($error); + $this->smtp->Reset(); + return false; + } + + if(!$this->smtp->Data($header . $body)) { + $this->SetError($this->Lang('data_not_accepted')); + $this->smtp->Reset(); + return false; + } + if($this->SMTPKeepAlive == true) { + $this->smtp->Reset(); + } else { + $this->SmtpClose(); + } + + return true; + } + + /** + * Initiates a connection to an SMTP server. Returns false if the + * operation failed. + * @access private + * @return bool + */ + function SmtpConnect() { + if($this->smtp == NULL) { + $this->smtp = new SMTP(); + } + + $this->smtp->do_debug = $this->SMTPDebug; + $hosts = explode(';', $this->Host); + $index = 0; + $connection = ($this->smtp->Connected()); + + /* Retry while there is no connection */ + while($index < count($hosts) && $connection == false) { + $hostinfo = array(); + if(preg_match('#^(.+):([0-9]+)$#i', $hosts[$index], $hostinfo)) { + $host = $hostinfo[1]; + $port = $hostinfo[2]; + } else { + $host = $hosts[$index]; + $port = $this->Port; + } + + if($this->smtp->Connect(((!empty($this->SMTPSecure))?$this->SMTPSecure.'://':'').$host, $port, $this->Timeout)) { + if ($this->Helo != '') { + $this->smtp->Hello($this->Helo); + } else { + $this->smtp->Hello($this->ServerHostname()); + } + + $connection = true; + if($this->SMTPAuth) { + if(!$this->smtp->Authenticate($this->Username, $this->Password)) { + $this->SetError($this->Lang('authenticate')); + $this->smtp->Reset(); + $connection = false; + } + } + } + $index++; + } + if(!$connection) { + $this->SetError($this->Lang('connect_host')); + } + + return $connection; + } + + /** + * Closes the active SMTP session if one exists. + * @return void + */ + function SmtpClose() { + if($this->smtp != NULL) { + if($this->smtp->Connected()) { + $this->smtp->Quit(); + $this->smtp->Close(); + } + } + } + + /** + * Sets the language for all class error messages. Returns false + * if it cannot load the language file. The default language type + * is English. + * @param string $lang_type Type of language (e.g. Portuguese: "br") + * @param string $lang_path Path to the language file directory + * @access public + * @return bool + */ + function SetLanguage($lang_type, $lang_path = 'language/') { + if(file_exists($lang_path.'phpmailer.lang-'.$lang_type.'.php')) { + include($lang_path.'phpmailer.lang-'.$lang_type.'.php'); + } elseif (file_exists($lang_path.'phpmailer.lang-en.php')) { + include($lang_path.'phpmailer.lang-en.php'); + } else { + $PHPMAILER_LANG = array(); + $PHPMAILER_LANG["provide_address"] = 'You must provide at least one ' . + $PHPMAILER_LANG["mailer_not_supported"] = ' mailer is not supported.'; + $PHPMAILER_LANG["execute"] = 'Could not execute: '; + $PHPMAILER_LANG["instantiate"] = 'Could not instantiate mail function.'; + $PHPMAILER_LANG["authenticate"] = 'SMTP Error: Could not authenticate.'; + $PHPMAILER_LANG["from_failed"] = 'The following From address failed: '; + $PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: The following ' . + $PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data not accepted.'; + $PHPMAILER_LANG["connect_host"] = 'SMTP Error: Could not connect to SMTP host.'; + $PHPMAILER_LANG["file_access"] = 'Could not access file: '; + $PHPMAILER_LANG["file_open"] = 'File Error: Could not open file: '; + $PHPMAILER_LANG["encoding"] = 'Unknown encoding: '; + $PHPMAILER_LANG["signing"] = 'Signing Error: '; + } + $this->language = $PHPMAILER_LANG; + + return true; + } + + ///////////////////////////////////////////////// + // METHODS, MESSAGE CREATION + ///////////////////////////////////////////////// + + /** + * Creates recipient headers. + * @access private + * @return string + */ + function AddrAppend($type, $addr) { + $addr_str = $type . ': '; + $addr_str .= $this->AddrFormat($addr[0]); + if(count($addr) > 1) { + for($i = 1; $i < count($addr); $i++) { + $addr_str .= ', ' . $this->AddrFormat($addr[$i]); + } + } + $addr_str .= $this->LE; + + return $addr_str; + } + + /** + * Formats an address correctly. + * @access private + * @return string + */ + function AddrFormat($addr) { + if(empty($addr[1])) { + $formatted = $this->SecureHeader($addr[0]); + } else { + $formatted = $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">"; + } + + return $formatted; + } + + /** + * Wraps message for use with mailers that do not + * automatically perform wrapping and for quoted-printable. + * Original written by philippe. + * @access private + * @return string + */ + function WrapText($message, $length, $qp_mode = false) { + $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE; + // If utf-8 encoding is used, we will need to make sure we don't + // split multibyte characters when we wrap + $is_utf8 = (strtolower($this->CharSet) == "utf-8"); + + $message = $this->FixEOL($message); + if (substr($message, -1) == $this->LE) { + $message = substr($message, 0, -1); + } + + $line = explode($this->LE, $message); + $message = ''; + for ($i=0 ;$i < count($line); $i++) { + $line_part = explode(' ', $line[$i]); + $buf = ''; + for ($e = 0; $e $length)) { + $space_left = $length - strlen($buf) - 1; + if ($e != 0) { + if ($space_left > 20) { + $len = $space_left; + if ($is_utf8) { + $len = $this->UTF8CharBoundary($word, $len); + } elseif (substr($word, $len - 1, 1) == "=") { + $len--; + } elseif (substr($word, $len - 2, 1) == "=") { + $len -= 2; + } + $part = substr($word, 0, $len); + $word = substr($word, $len); + $buf .= ' ' . $part; + $message .= $buf . sprintf("=%s", $this->LE); + } else { + $message .= $buf . $soft_break; + } + $buf = ''; + } + while (strlen($word) > 0) { + $len = $length; + if ($is_utf8) { + $len = $this->UTF8CharBoundary($word, $len); + } elseif (substr($word, $len - 1, 1) == "=") { + $len--; + } elseif (substr($word, $len - 2, 1) == "=") { + $len -= 2; + } + $part = substr($word, 0, $len); + $word = substr($word, $len); + + if (strlen($word) > 0) { + $message .= $part . sprintf("=%s", $this->LE); + } else { + $buf = $part; + } + } + } else { + $buf_o = $buf; + $buf .= ($e == 0) ? $word : (' ' . $word); + + if (strlen($buf) > $length and $buf_o != '') { + $message .= $buf_o . $soft_break; + $buf = $word; + } + } + } + $message .= $buf . $this->LE; + } + + return $message; + } + + /** + * Finds last character boundary prior to maxLength in a utf-8 + * quoted (printable) encoded string. + * Original written by Colin Brown. + * @access private + * @param string $encodedText utf-8 QP text + * @param int $maxLength find last character boundary prior to this length + * @return int + */ + function UTF8CharBoundary($encodedText, $maxLength) { + $foundSplitPos = false; + $lookBack = 3; + while (!$foundSplitPos) { + $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack); + $encodedCharPos = strpos($lastChunk, "="); + if ($encodedCharPos !== false) { + // Found start of encoded character byte within $lookBack block. + // Check the encoded byte value (the 2 chars after the '=') + $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2); + $dec = hexdec($hex); + if ($dec < 128) { // Single byte character. + // If the encoded char was found at pos 0, it will fit + // otherwise reduce maxLength to start of the encoded char + $maxLength = ($encodedCharPos == 0) ? $maxLength : + $maxLength - ($lookBack - $encodedCharPos); + $foundSplitPos = true; + } elseif ($dec >= 192) { // First byte of a multi byte character + // Reduce maxLength to split at start of character + $maxLength = $maxLength - ($lookBack - $encodedCharPos); + $foundSplitPos = true; + } elseif ($dec < 192) { // Middle byte of a multi byte character, look further back + $lookBack += 3; + } + } else { + // No encoded character found + $foundSplitPos = true; + } + } + return $maxLength; + } + + /** + * Set the body wrapping. + * @access private + * @return void + */ + function SetWordWrap() { + if($this->WordWrap < 1) { + return; + } + + switch($this->message_type) { + case 'alt': + /* fall through */ + case 'alt_attachments': + $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap); + break; + default: + $this->Body = $this->WrapText($this->Body, $this->WordWrap); + break; + } + } + + /** + * Assembles message header. + * @access private + * @return string + */ + function CreateHeader() { + $result = ''; + + /* Set the boundaries */ + $uniq_id = md5(uniqid(time())); + $this->boundary[1] = 'b1_' . $uniq_id; + $this->boundary[2] = 'b2_' . $uniq_id; + + $result .= $this->HeaderLine('Date', $this->RFCDate()); + if($this->Sender == '') { + $result .= $this->HeaderLine('Return-Path', trim($this->From)); + } else { + $result .= $this->HeaderLine('Return-Path', trim($this->Sender)); + } + + /* To be created automatically by mail() */ + if($this->Mailer != 'mail') { + if(count($this->to) > 0) { + $result .= $this->AddrAppend('To', $this->to); + } elseif (count($this->cc) == 0) { + $result .= $this->HeaderLine('To', 'undisclosed-recipients:;'); + } + } + + $from = array(); + $from[0][0] = trim($this->From); + $from[0][1] = $this->FromName; + $result .= $this->AddrAppend('From', $from); + + /* sendmail and mail() extract Cc from the header before sending */ + if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->cc) > 0)) { + $result .= $this->AddrAppend('Cc', $this->cc); + } + + /* sendmail and mail() extract Bcc from the header before sending */ + if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) { + $result .= $this->AddrAppend('Bcc', $this->bcc); + } + + if(count($this->ReplyTo) > 0) { + $result .= $this->AddrAppend('Reply-To', $this->ReplyTo); + } + + /* mail() sets the subject itself */ + if($this->Mailer != 'mail') { + $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject))); + } + + if($this->MessageID != '') { + $result .= $this->HeaderLine('Message-ID',$this->MessageID); + } else { + $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE); + } + $result .= $this->HeaderLine('X-Priority', $this->Priority); + $result .= $this->HeaderLine('X-Mailer', 'PHPMailer (phpmailer.sourceforge.net) [version ' . $this->Version . ']'); + + if($this->ConfirmReadingTo != '') { + $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>'); + } + + // Add custom headers + for($index = 0; $index < count($this->CustomHeader); $index++) { + $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1]))); + } + if (!$this->sign_key_file) { + $result .= $this->HeaderLine('MIME-Version', '1.0'); + $result .= $this->GetMailMIME(); + } + + return $result; + } + + /** + * Returns the message MIME. + * @access private + * @return string + */ + function GetMailMIME() { + $result = ''; + switch($this->message_type) { + case 'plain': + $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding); + $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet); + break; + case 'attachments': + /* fall through */ + case 'alt_attachments': + if($this->InlineImageExists()){ + $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE); + } else { + $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;'); + $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); + } + break; + case 'alt': + $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;'); + $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); + break; + } + + if($this->Mailer != 'mail') { + $result .= $this->LE.$this->LE; + } + + return $result; + } + + /** + * Assembles the message body. Returns an empty string on failure. + * @access private + * @return string + */ + function CreateBody() { + $result = ''; + if ($this->sign_key_file) { + $result .= $this->GetMailMIME(); + } + + $this->SetWordWrap(); + + switch($this->message_type) { + case 'alt': + $result .= $this->GetBoundary($this->boundary[1], '', 'text/plain', ''); + $result .= $this->EncodeString($this->AltBody, $this->Encoding); + $result .= $this->LE.$this->LE; + $result .= $this->GetBoundary($this->boundary[1], '', 'text/html', ''); + $result .= $this->EncodeString($this->Body, $this->Encoding); + $result .= $this->LE.$this->LE; + $result .= $this->EndBoundary($this->boundary[1]); + break; + case 'plain': + $result .= $this->EncodeString($this->Body, $this->Encoding); + break; + case 'attachments': + $result .= $this->GetBoundary($this->boundary[1], '', '', ''); + $result .= $this->EncodeString($this->Body, $this->Encoding); + $result .= $this->LE; + $result .= $this->AttachAll(); + break; + case 'alt_attachments': + $result .= sprintf("--%s%s", $this->boundary[1], $this->LE); + $result .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE); + $result .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body + $result .= $this->EncodeString($this->AltBody, $this->Encoding); + $result .= $this->LE.$this->LE; + $result .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body + $result .= $this->EncodeString($this->Body, $this->Encoding); + $result .= $this->LE.$this->LE; + $result .= $this->EndBoundary($this->boundary[2]); + $result .= $this->AttachAll(); + break; + } + + if($this->IsError()) { + $result = ''; + } else if ($this->sign_key_file) { + $file = tempnam("", "mail"); + $fp = fopen($file, "w"); + fwrite($fp, $result); + fclose($fp); + $signed = tempnam("", "signed"); + + if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_cert_file, array("file://".$this->sign_key_file, $this->sign_key_pass), null)) { + $fp = fopen($signed, "r"); + $result = fread($fp, filesize($this->sign_key_file)); + $result = ''; + while(!feof($fp)){ + $result = $result . fread($fp, 1024); + } + fclose($fp); + } else { + $this->SetError($this->Lang("signing").openssl_error_string()); + $result = ''; + } + + unlink($file); + unlink($signed); + } + + return $result; + } + + /** + * Returns the start of a message boundary. + * @access private + */ + function GetBoundary($boundary, $charSet, $contentType, $encoding) { + $result = ''; + if($charSet == '') { + $charSet = $this->CharSet; + } + if($contentType == '') { + $contentType = $this->ContentType; + } + if($encoding == '') { + $encoding = $this->Encoding; + } + $result .= $this->TextLine('--' . $boundary); + $result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet); + $result .= $this->LE; + $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding); + $result .= $this->LE; + + return $result; + } + + /** + * Returns the end of a message boundary. + * @access private + */ + function EndBoundary($boundary) { + return $this->LE . '--' . $boundary . '--' . $this->LE; + } + + /** + * Sets the message type. + * @access private + * @return void + */ + function SetMessageType() { + if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) { + $this->message_type = 'plain'; + } else { + if(count($this->attachment) > 0) { + $this->message_type = 'attachments'; + } + if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) { + $this->message_type = 'alt'; + } + if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) { + $this->message_type = 'alt_attachments'; + } + } + } + + /* Returns a formatted header line. + * @access private + * @return string + */ + function HeaderLine($name, $value) { + return $name . ': ' . $value . $this->LE; + } + + /** + * Returns a formatted mail line. + * @access private + * @return string + */ + function TextLine($value) { + return $value . $this->LE; + } + + ///////////////////////////////////////////////// + // CLASS METHODS, ATTACHMENTS + ///////////////////////////////////////////////// + + /** + * Adds an attachment from a path on the filesystem. + * Returns false if the file could not be found + * or accessed. + * @param string $path Path to the attachment. + * @param string $name Overrides the attachment name. + * @param string $encoding File encoding (see $Encoding). + * @param string $type File extension (MIME) type. + * @return bool + */ + function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') { + if(!@is_file($path)) { + $this->SetError($this->Lang('file_access') . $path); + return false; + } + + $filename = basename($path); + if($name == '') { + $name = $filename; + } + + $cur = count($this->attachment); + $this->attachment[$cur][0] = $path; + $this->attachment[$cur][1] = $filename; + $this->attachment[$cur][2] = $name; + $this->attachment[$cur][3] = $encoding; + $this->attachment[$cur][4] = $type; + $this->attachment[$cur][5] = false; // isStringAttachment + $this->attachment[$cur][6] = 'attachment'; + $this->attachment[$cur][7] = 0; + + return true; + } + + /** + * Attaches all fs, string, and binary attachments to the message. + * Returns an empty string on failure. + * @access private + * @return string + */ + function AttachAll() { + /* Return text of body */ + $mime = array(); + + /* Add all attachments */ + for($i = 0; $i < count($this->attachment); $i++) { + /* Check for string attachment */ + $bString = $this->attachment[$i][5]; + if ($bString) { + $string = $this->attachment[$i][0]; + } else { + $path = $this->attachment[$i][0]; + } + + $filename = $this->attachment[$i][1]; + $name = $this->attachment[$i][2]; + $encoding = $this->attachment[$i][3]; + $type = $this->attachment[$i][4]; + $disposition = $this->attachment[$i][6]; + $cid = $this->attachment[$i][7]; + + $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE); + $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE); + $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE); + + if($disposition == 'inline') { + $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE); + } + + $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE); + + /* Encode as string attachment */ + if($bString) { + $mime[] = $this->EncodeString($string, $encoding); + if($this->IsError()) { + return ''; + } + $mime[] = $this->LE.$this->LE; + } else { + $mime[] = $this->EncodeFile($path, $encoding); + if($this->IsError()) { + return ''; + } + $mime[] = $this->LE.$this->LE; + } + } + + $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE); + + return join('', $mime); + } + + /** + * Encodes attachment in requested format. Returns an + * empty string on failure. + * @access private + * @return string + */ + function EncodeFile ($path, $encoding = 'base64') { + if(!@$fd = fopen($path, 'rb')) { + $this->SetError($this->Lang('file_open') . $path); + return ''; + } + $magic_quotes = get_magic_quotes_runtime(); + set_magic_quotes_runtime(0); + $file_buffer = fread($fd, filesize($path)); + $file_buffer = $this->EncodeString($file_buffer, $encoding); + fclose($fd); + set_magic_quotes_runtime($magic_quotes); + + return $file_buffer; + } + + /** + * Encodes string to requested format. Returns an + * empty string on failure. + * @access private + * @return string + */ + function EncodeString ($str, $encoding = 'base64') { + $encoded = ''; + switch(strtolower($encoding)) { + case 'base64': + /* chunk_split is found in PHP >= 3.0.6 */ + $encoded = chunk_split(base64_encode($str), 76, $this->LE); + break; + case '7bit': + case '8bit': + $encoded = $this->FixEOL($str); + if (substr($encoded, -(strlen($this->LE))) != $this->LE) + $encoded .= $this->LE; + break; + case 'binary': + $encoded = $str; + break; + case 'quoted-printable': + $encoded = $this->EncodeQP($str); + break; + default: + $this->SetError($this->Lang('encoding') . $encoding); + break; + } + return $encoded; + } + + /** + * Encode a header string to best of Q, B, quoted or none. + * @access private + * @return string + */ + function EncodeHeader ($str, $position = 'text') { + $x = 0; + + switch (strtolower($position)) { + case 'phrase': + if (!preg_match('/[\200-\377]/', $str)) { + /* Can't use addslashes as we don't know what value has magic_quotes_sybase. */ + $encoded = addcslashes($str, "\0..\37\177\\\""); + if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) { + return ($encoded); + } else { + return ("\"$encoded\""); + } + } + $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches); + break; + case 'comment': + $x = preg_match_all('/[()"]/', $str, $matches); + /* Fall-through */ + case 'text': + default: + $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches); + break; + } + + if ($x == 0) { + return ($str); + } + + $maxlen = 75 - 7 - strlen($this->CharSet); + /* Try to select the encoding which should produce the shortest output */ + if (strlen($str)/3 < $x) { + $encoding = 'B'; + if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) { + // Use a custom function which correctly encodes and wraps long + // multibyte strings without breaking lines within a character + $encoded = $this->Base64EncodeWrapMB($str); + } else { + $encoded = base64_encode($str); + $maxlen -= $maxlen % 4; + $encoded = trim(chunk_split($encoded, $maxlen, "\n")); + } + } else { + $encoding = 'Q'; + $encoded = $this->EncodeQ($str, $position); + $encoded = $this->WrapText($encoded, $maxlen, true); + $encoded = str_replace('='.$this->LE, "\n", trim($encoded)); + } + + $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded); + $encoded = trim(str_replace("\n", $this->LE, $encoded)); + + return $encoded; + } + + /** + * Checks if a string contains multibyte characters. + * @access private + * @param string $str multi-byte text to wrap encode + * @return bool + */ + function HasMultiBytes($str) { + if (function_exists('mb_strlen')) { + return (strlen($str) > mb_strlen($str, $this->CharSet)); + } else { // Assume no multibytes (we can't handle without mbstring functions anyway) + return False; + } + } + + /** + * Correctly encodes and wraps long multibyte strings for mail headers + * without breaking lines within a character. + * Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php + * @access private + * @param string $str multi-byte text to wrap encode + * @return string + */ + function Base64EncodeWrapMB($str) { + $start = "=?".$this->CharSet."?B?"; + $end = "?="; + $encoded = ""; + + $mb_length = mb_strlen($str, $this->CharSet); + // Each line must have length <= 75, including $start and $end + $length = 75 - strlen($start) - strlen($end); + // Average multi-byte ratio + $ratio = $mb_length / strlen($str); + // Base64 has a 4:3 ratio + $offset = $avgLength = floor($length * $ratio * .75); + + for ($i = 0; $i < $mb_length; $i += $offset) { + $lookBack = 0; + + do { + $offset = $avgLength - $lookBack; + $chunk = mb_substr($str, $i, $offset, $this->CharSet); + $chunk = base64_encode($chunk); + $lookBack++; + } + while (strlen($chunk) > $length); + + $encoded .= $chunk . $this->LE; + } + + // Chomp the last linefeed + $encoded = substr($encoded, 0, -strlen($this->LE)); + return $encoded; + } + + /** + * Encode string to quoted-printable. + * @access private + * @return string + */ + function EncodeQP( $input = '', $line_max = 76, $space_conv = false ) { + $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); + $lines = preg_split('/(?:\r\n|\r|\n)/', $input); + $eol = "\r\n"; + $escape = '='; + $output = ''; + while( list(, $line) = each($lines) ) { + $linlen = strlen($line); + $newline = ''; + for($i = 0; $i < $linlen; $i++) { + $c = substr( $line, $i, 1 ); + $dec = ord( $c ); + if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E + $c = '=2E'; + } + if ( $dec == 32 ) { + if ( $i == ( $linlen - 1 ) ) { // convert space at eol only + $c = '=20'; + } else if ( $space_conv ) { + $c = '=20'; + } + } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required + $h2 = floor($dec/16); + $h1 = floor($dec%16); + $c = $escape.$hex[$h2].$hex[$h1]; + } + if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted + $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay + $newline = ''; + // check if newline first character will be point or not + if ( $dec == 46 ) { + $c = '=2E'; + } + } + $newline .= $c; + } // end of for + $output .= $newline.$eol; + } // end of while + return $output; + } + + /** + * Encode string to q encoding. + * @access private + * @return string + */ + function EncodeQ ($str, $position = 'text') { + /* There should not be any EOL in the string */ + $encoded = preg_replace("[\r\n]", '', $str); + + switch (strtolower($position)) { + case 'phrase': + $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded); + break; + case 'comment': + $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded); + case 'text': + default: + /* Replace every high ascii, control =, ? and _ characters */ + $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e', + "'='.sprintf('%02X', ord('\\1'))", $encoded); + break; + } + + /* Replace every spaces to _ (more readable than =20) */ + $encoded = str_replace(' ', '_', $encoded); + + return $encoded; + } + + /** + * Adds a string or binary attachment (non-filesystem) to the list. + * This method can be used to attach ascii or binary data, + * such as a BLOB record from a database. + * @param string $string String attachment data. + * @param string $filename Name of the attachment. + * @param string $encoding File encoding (see $Encoding). + * @param string $type File extension (MIME) type. + * @return void + */ + function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream') { + /* Append to $attachment array */ + $cur = count($this->attachment); + $this->attachment[$cur][0] = $string; + $this->attachment[$cur][1] = $filename; + $this->attachment[$cur][2] = $filename; + $this->attachment[$cur][3] = $encoding; + $this->attachment[$cur][4] = $type; + $this->attachment[$cur][5] = true; // isString + $this->attachment[$cur][6] = 'attachment'; + $this->attachment[$cur][7] = 0; + } + + /** + * Adds an embedded attachment. This can include images, sounds, and + * just about any other document. Make sure to set the $type to an + * image type. For JPEG images use "image/jpeg" and for GIF images + * use "image/gif". + * @param string $path Path to the attachment. + * @param string $cid Content ID of the attachment. Use this to identify + * the Id for accessing the image in an HTML form. + * @param string $name Overrides the attachment name. + * @param string $encoding File encoding (see $Encoding). + * @param string $type File extension (MIME) type. + * @return bool + */ + function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') { + + if(!@is_file($path)) { + $this->SetError($this->Lang('file_access') . $path); + return false; + } + + $filename = basename($path); + if($name == '') { + $name = $filename; + } + + /* Append to $attachment array */ + $cur = count($this->attachment); + $this->attachment[$cur][0] = $path; + $this->attachment[$cur][1] = $filename; + $this->attachment[$cur][2] = $name; + $this->attachment[$cur][3] = $encoding; + $this->attachment[$cur][4] = $type; + $this->attachment[$cur][5] = false; + $this->attachment[$cur][6] = 'inline'; + $this->attachment[$cur][7] = $cid; + + return true; + } + + /** + * Returns true if an inline attachment is present. + * @access private + * @return bool + */ + function InlineImageExists() { + $result = false; + for($i = 0; $i < count($this->attachment); $i++) { + if($this->attachment[$i][6] == 'inline') { + $result = true; + break; + } + } + + return $result; + } + + ///////////////////////////////////////////////// + // CLASS METHODS, MESSAGE RESET + ///////////////////////////////////////////////// + + /** + * Clears all recipients assigned in the TO array. Returns void. + * @return void + */ + function ClearAddresses() { + $this->to = array(); + } + + /** + * Clears all recipients assigned in the CC array. Returns void. + * @return void + */ + function ClearCCs() { + $this->cc = array(); + } + + /** + * Clears all recipients assigned in the BCC array. Returns void. + * @return void + */ + function ClearBCCs() { + $this->bcc = array(); + } + + /** + * Clears all recipients assigned in the ReplyTo array. Returns void. + * @return void + */ + function ClearReplyTos() { + $this->ReplyTo = array(); + } + + /** + * Clears all recipients assigned in the TO, CC and BCC + * array. Returns void. + * @return void + */ + function ClearAllRecipients() { + $this->to = array(); + $this->cc = array(); + $this->bcc = array(); + } + + /** + * Clears all previously set filesystem, string, and binary + * attachments. Returns void. + * @return void + */ + function ClearAttachments() { + $this->attachment = array(); + } + + /** + * Clears all custom headers. Returns void. + * @return void + */ + function ClearCustomHeaders() { + $this->CustomHeader = array(); + } + + ///////////////////////////////////////////////// + // CLASS METHODS, MISCELLANEOUS + ///////////////////////////////////////////////// + + /** + * Adds the error message to the error container. + * Returns void. + * @access private + * @return void + */ + function SetError($msg) { + $this->error_count++; + $this->ErrorInfo = $msg; + } + + /** + * Returns the proper RFC 822 formatted date. + * @access private + * @return string + */ + function RFCDate() { + $tz = date('Z'); + $tzs = ($tz < 0) ? '-' : '+'; + $tz = abs($tz); + $tz = (int)($tz/3600)*100 + ($tz%3600)/60; + $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz); + + return $result; + } + + /** + * Returns the appropriate server variable. Should work with both + * PHP 4.1.0+ as well as older versions. Returns an empty string + * if nothing is found. + * @access private + * @return mixed + */ + function ServerVar($varName) { + global $HTTP_SERVER_VARS; + global $HTTP_ENV_VARS; + + if(!isset($_SERVER)) { + $_SERVER = $HTTP_SERVER_VARS; + if(!isset($_SERVER['REMOTE_ADDR'])) { + $_SERVER = $HTTP_ENV_VARS; // must be Apache + } + } + + if(isset($_SERVER[$varName])) { + return $_SERVER[$varName]; + } else { + return ''; + } + } + + /** + * Returns the server hostname or 'localhost.localdomain' if unknown. + * @access private + * @return string + */ + function ServerHostname() { + if ($this->Hostname != '') { + $result = $this->Hostname; + } elseif ($this->ServerVar('SERVER_NAME') != '') { + $result = $this->ServerVar('SERVER_NAME'); + } else { + $result = 'localhost.localdomain'; + } + + return $result; + } + + /** + * Returns a message in the appropriate language. + * @access private + * @return string + */ + function Lang($key) { + if(count($this->language) < 1) { + $this->SetLanguage('en'); // set the default language + } + + if(isset($this->language[$key])) { + return $this->language[$key]; + } else { + return 'Language string failed to load: ' . $key; + } + } + + /** + * Returns true if an error occurred. + * @return bool + */ + function IsError() { + return ($this->error_count > 0); + } + + /** + * Changes every end of line from CR or LF to CRLF. + * @access private + * @return string + */ + function FixEOL($str) { + $str = str_replace("\r\n", "\n", $str); + $str = str_replace("\r", "\n", $str); + $str = str_replace("\n", $this->LE, $str); + return $str; + } + + /** + * Adds a custom header. + * @return void + */ + function AddCustomHeader($custom_header) { + $this->CustomHeader[] = explode(':', $custom_header, 2); + } + + /** + * Evaluates the message and returns modifications for inline images and backgrounds + * @access public + * @return $message + */ + function MsgHTML($message,$basedir='') { + preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images); + if(isset($images[2])) { + foreach($images[2] as $i => $url) { + // do not change urls for absolute images (thanks to corvuscorax) + if (!preg_match('/^[A-z][A-z]*:\/\//',$url)) { + $filename = basename($url); + $directory = dirname($url); + ($directory == '.')?$directory='':''; + $cid = 'cid:' . md5($filename); + $fileParts = split("\.", $filename); + $ext = $fileParts[1]; + $mimeType = $this->_mime_types($ext); + if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; } + if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; } + if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) { + $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message); + } + } + } + } + $this->IsHTML(true); + $this->Body = $message; + $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message))); + if ( !empty($textMsg) && empty($this->AltBody) ) { + $this->AltBody = html_entity_decode($textMsg); + } + if ( empty($this->AltBody) ) { + $this->AltBody = 'To view this email message, open the email in with HTML compatibility!' . "\n\n"; + } + } + + /** + * Gets the mime type of the embedded or inline image + * @access private + * @return mime type of ext + */ + function _mime_types($ext = '') { + $mimes = array( + 'ai' => 'application/postscript', + 'aif' => 'audio/x-aiff', + 'aifc' => 'audio/x-aiff', + 'aiff' => 'audio/x-aiff', + 'avi' => 'video/x-msvideo', + 'bin' => 'application/macbinary', + 'bmp' => 'image/bmp', + 'class' => 'application/octet-stream', + 'cpt' => 'application/mac-compactpro', + 'css' => 'text/css', + 'dcr' => 'application/x-director', + 'dir' => 'application/x-director', + 'dll' => 'application/octet-stream', + 'dms' => 'application/octet-stream', + 'doc' => 'application/msword', + 'dvi' => 'application/x-dvi', + 'dxr' => 'application/x-director', + 'eml' => 'message/rfc822', + 'eps' => 'application/postscript', + 'exe' => 'application/octet-stream', + 'gif' => 'image/gif', + 'gtar' => 'application/x-gtar', + 'htm' => 'text/html', + 'html' => 'text/html', + 'jpe' => 'image/jpeg', + 'jpeg' => 'image/jpeg', + 'jpg' => 'image/jpeg', + 'hqx' => 'application/mac-binhex40', + 'js' => 'application/x-javascript', + 'lha' => 'application/octet-stream', + 'log' => 'text/plain', + 'lzh' => 'application/octet-stream', + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mif' => 'application/vnd.mif', + 'mov' => 'video/quicktime', + 'movie' => 'video/x-sgi-movie', + 'mp2' => 'audio/mpeg', + 'mp3' => 'audio/mpeg', + 'mpe' => 'video/mpeg', + 'mpeg' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'mpga' => 'audio/mpeg', + 'oda' => 'application/oda', + 'pdf' => 'application/pdf', + 'php' => 'application/x-httpd-php', + 'php3' => 'application/x-httpd-php', + 'php4' => 'application/x-httpd-php', + 'phps' => 'application/x-httpd-php-source', + 'phtml' => 'application/x-httpd-php', + 'png' => 'image/png', + 'ppt' => 'application/vnd.ms-powerpoint', + 'ps' => 'application/postscript', + 'psd' => 'application/octet-stream', + 'qt' => 'video/quicktime', + 'ra' => 'audio/x-realaudio', + 'ram' => 'audio/x-pn-realaudio', + 'rm' => 'audio/x-pn-realaudio', + 'rpm' => 'audio/x-pn-realaudio-plugin', + 'rtf' => 'text/rtf', + 'rtx' => 'text/richtext', + 'rv' => 'video/vnd.rn-realvideo', + 'sea' => 'application/octet-stream', + 'shtml' => 'text/html', + 'sit' => 'application/x-stuffit', + 'so' => 'application/octet-stream', + 'smi' => 'application/smil', + 'smil' => 'application/smil', + 'swf' => 'application/x-shockwave-flash', + 'tar' => 'application/x-tar', + 'text' => 'text/plain', + 'txt' => 'text/plain', + 'tgz' => 'application/x-tar', + 'tif' => 'image/tiff', + 'tiff' => 'image/tiff', + 'wav' => 'audio/x-wav', + 'wbxml' => 'application/vnd.wap.wbxml', + 'wmlc' => 'application/vnd.wap.wmlc', + 'word' => 'application/msword', + 'xht' => 'application/xhtml+xml', + 'xhtml' => 'application/xhtml+xml', + 'xl' => 'application/excel', + 'xls' => 'application/vnd.ms-excel', + 'xml' => 'text/xml', + 'xsl' => 'text/xml', + 'zip' => 'application/zip' + ); + return ( ! isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)]; + } + + /** + * Set (or reset) Class Objects (variables) + * + * Usage Example: + * $page->set('X-Priority', '3'); + * + * @access public + * @param string $name Parameter Name + * @param mixed $value Parameter Value + * NOTE: will not work with arrays, there are no arrays to set/reset + */ + function set ( $name, $value = '' ) { + if ( isset($this->$name) ) { + $this->$name = $value; + } else { + $this->SetError('Cannot set or reset variable ' . $name); + return false; + } + } + + /** + * Read a file from a supplied filename and return it. + * + * @access public + * @param string $filename Parameter File Name + */ + function getFile($filename) { + $return = ''; + if ($fp = fopen($filename, 'rb')) { + while (!feof($fp)) { + $return .= fread($fp, 1024); + } + fclose($fp); + return $return; + } else { + return false; + } + } + + /** + * Strips newlines to prevent header injection. + * @access private + * @param string $str String + * @return string + */ + function SecureHeader($str) { + $str = trim($str); + $str = str_replace("\r", "", $str); + $str = str_replace("\n", "", $str); + return $str; + } + + /** + * Set the private key file and password to sign the message. + * + * @access public + * @param string $key_filename Parameter File Name + * @param string $key_pass Password for private key + */ + function Sign($cert_filename, $key_filename, $key_pass) { + $this->sign_cert_file = $cert_filename; + $this->sign_key_file = $key_filename; + $this->sign_key_pass = $key_pass; + } + +} + +?> diff --git a/oss/joomla/trunk/libraries/phputf8/utils/ascii.php b/oss/joomla/trunk/libraries/phputf8/utils/ascii.php index e7649f78..205fbb0b 100644 --- a/oss/joomla/trunk/libraries/phputf8/utils/ascii.php +++ b/oss/joomla/trunk/libraries/phputf8/utils/ascii.php @@ -1,212 +1,220 @@ - -* @see utf8_deaccent() -* @package utf8 -* @subpackage ascii -*/ -$GLOBALS['UTF8_LOWER_ACCENTS'] = array( - 'à ' => 'a', 'ô' => 'o', 'ÄÂ?' => 'd', 'ḟ' => 'f', 'ë' => 'e', 'Å¡' => 's', 'Æ¡' => 'o', - 'ß' => 'ss', 'ă' => 'a', 'Å™' => 'r', 'È›' => 't', 'ň' => 'n', 'ÄÂ?' => 'a', 'Ä·' => 'k', - 'ÅÂ?' => 's', 'ỳ' => 'y', 'ņ' => 'n', 'ĺ' => 'l', 'ħ' => 'h', 'á¹—' => 'p', 'ó' => 'o', - 'ú' => 'u', 'Ä›' => 'e', 'é' => 'e', 'ç' => 'c', 'áºÂ?' => 'w', 'Ä‹' => 'c', 'õ' => 'o', - 'ṡ' => 's', 'ø' => 'o', 'Ä£' => 'g', 'ŧ' => 't', 'È™' => 's', 'Ä—' => 'e', 'ĉ' => 'c', - 'Å›' => 's', 'î' => 'i', 'ű' => 'u', 'ć' => 'c', 'Ä™' => 'e', 'ŵ' => 'w', 'ṫ' => 't', - 'Å«' => 'u', 'ÄÂ?' => 'c', 'ö' => 'oe', 'è' => 'e', 'Å·' => 'y', 'Ä…' => 'a', 'Å‚' => 'l', - 'ų' => 'u', 'ů' => 'u', 'ÅŸ' => 's', 'ÄŸ' => 'g', 'ļ' => 'l', 'Æ’' => 'f', 'ž' => 'z', - 'ẃ' => 'w', 'ḃ' => 'b', 'Ã¥' => 'a', 'ì' => 'i', 'ï' => 'i', 'ḋ' => 'd', 'Å¥' => 't', - 'Å—' => 'r', 'ä' => 'ae', 'í' => 'i', 'Å•' => 'r', 'ê' => 'e', 'ü' => 'ue', 'ò' => 'o', - 'Ä“' => 'e', 'ñ' => 'n', 'Å„' => 'n', 'Ä¥' => 'h', 'ÄÂ?' => 'g', 'Ä‘' => 'd', 'ĵ' => 'j', - 'ÿ' => 'y', 'Å©' => 'u', 'Å­' => 'u', 'ư' => 'u', 'Å£' => 't', 'ý' => 'y', 'Å‘' => 'o', - 'â' => 'a', 'ľ' => 'l', 'ẅ' => 'w', 'ż' => 'z', 'Ä«' => 'i', 'ã' => 'a', 'Ä¡' => 'g', - 'á¹Â?' => 'm', 'ÅÂ?' => 'o', 'Ä©' => 'i', 'ù' => 'u', 'į' => 'i', 'ź' => 'z', 'á' => 'a', - 'û' => 'u', 'þ' => 'th', 'ð' => 'dh', 'æ' => 'ae', 'µ' => 'u', -); - - -//--------------------------------------------------------------- -/** -* UTF-8 lookup table for upper case accented letters -* This lookuptable defines replacements for accented characters from the ASCII-7 -* range. This are upper case letters only. -* @author Andreas Gohr -* @see utf8_deaccent() -* @package utf8 -* @subpackage ascii - */ - -$GLOBALS['UTF8_UPPER_ACCENTS'] = array( - 'à ' => 'A', 'ô' => 'O', 'ÄÂ?' => 'D', 'ḟ' => 'F', 'ë' => 'E', 'Å¡' => 'S', 'Æ¡' => 'O', - 'ß' => 'Ss', 'ă' => 'A', 'Å™' => 'R', 'È›' => 'T', 'ň' => 'N', 'ÄÂ?' => 'A', 'Ä·' => 'K', - 'ÅÂ?' => 'S', 'ỳ' => 'Y', 'ņ' => 'N', 'ĺ' => 'L', 'ħ' => 'H', 'á¹—' => 'P', 'ó' => 'O', - 'ú' => 'U', 'Ä›' => 'E', 'é' => 'E', 'ç' => 'C', 'áºÂ?' => 'W', 'Ä‹' => 'C', 'õ' => 'O', - 'ṡ' => 'S', 'ø' => 'O', 'Ä£' => 'G', 'ŧ' => 'T', 'È™' => 'S', 'Ä—' => 'E', 'ĉ' => 'C', - 'Å›' => 'S', 'î' => 'I', 'ű' => 'U', 'ć' => 'C', 'Ä™' => 'E', 'ŵ' => 'W', 'ṫ' => 'T', - 'Å«' => 'U', 'ÄÂ?' => 'C', 'ö' => 'Oe', 'è' => 'E', 'Å·' => 'Y', 'Ä…' => 'A', 'Å‚' => 'L', - 'ų' => 'U', 'ů' => 'U', 'ÅŸ' => 'S', 'ÄŸ' => 'G', 'ļ' => 'L', 'Æ’' => 'F', 'ž' => 'Z', - 'ẃ' => 'W', 'ḃ' => 'B', 'Ã¥' => 'A', 'ì' => 'I', 'ï' => 'I', 'ḋ' => 'D', 'Å¥' => 'T', - 'Å—' => 'R', 'ä' => 'Ae', 'í' => 'I', 'Å•' => 'R', 'ê' => 'E', 'ü' => 'Ue', 'ò' => 'O', - 'Ä“' => 'E', 'ñ' => 'N', 'Å„' => 'N', 'Ä¥' => 'H', 'ÄÂ?' => 'G', 'Ä‘' => 'D', 'ĵ' => 'J', - 'ÿ' => 'Y', 'Å©' => 'U', 'Å­' => 'U', 'ư' => 'U', 'Å£' => 'T', 'ý' => 'Y', 'Å‘' => 'O', - 'â' => 'A', 'ľ' => 'L', 'ẅ' => 'W', 'ż' => 'Z', 'Ä«' => 'I', 'ã' => 'A', 'Ä¡' => 'G', - 'á¹Â?' => 'M', 'ÅÂ?' => 'O', 'Ä©' => 'I', 'ù' => 'U', 'į' => 'I', 'ź' => 'Z', 'á' => 'A', - 'û' => 'U', 'Þ' => 'Th', 'ÃÂ?' => 'Dh', 'Æ' => 'Ae', -); - -//-------------------------------------------------------------------- -/** -* Tests whether a string contains only 7bit ASCII bytes. -* You might use this to conditionally check whether a string -* needs handling as UTF-8 or not, potentially offering performance -* benefits by using the native PHP equivalent if it's just ASCII e.g.; -* -* -* -* -* -* @param string -* @return boolean TRUE if it's all ASCII -* @package utf8 -* @subpackage ascii -* @see utf8_is_ascii_ctrl -*/ -function utf8_is_ascii($str) { - if ( strlen($str) > 0 ) { - // Search for any bytes which are outside the ASCII range... - return (preg_match('/[^\x00-\x7F]/',$str) !== 1); - } - return FALSE; -} - -//-------------------------------------------------------------------- -/** -* Tests whether a string contains only 7bit ASCII bytes with device -* control codes omitted. The device control codes can be found on the -* second table here: http://www.w3schools.com/tags/ref_ascii.asp -* -* @param string -* @return boolean TRUE if it's all ASCII without device control codes -* @package utf8 -* @subpackage ascii -* @see utf8_is_ascii -*/ -function utf8_is_ascii_ctrl($str) { - if ( strlen($str) > 0 ) { - // Search for any bytes which are outside the ASCII range, - // or are device control codes - return (preg_match('/[^\x09\x0A\x0D\x20-\x7E]/',$str) !== 1); - } - return FALSE; -} - -//-------------------------------------------------------------------- -/** -* Strip out all non-7bit ASCII bytes -* If you need to transmit a string to system which you know can only -* support 7bit ASCII, you could use this function. -* @param string -* @return string with non ASCII bytes removed -* @package utf8 -* @subpackage ascii -* @see utf8_strip_non_ascii_ctrl -*/ -function utf8_strip_non_ascii($str) { - ob_start(); - while ( preg_match( - '/^([\x00-\x7F]+)|([^\x00-\x7F]+)/S', - $str, $matches) ) { - if ( !isset($matches[2]) ) { - echo $matches[0]; - } - $str = substr($str, strlen($matches[0])); - } - $result = ob_get_contents(); - ob_end_clean(); - return $result; -} - -//-------------------------------------------------------------------- -/** -* Strip out all non 7bit ASCII bytes and ASCII device control codes. -* For a list of ASCII device control codes see the 2nd table here: -* http://www.w3schools.com/tags/ref_ascii.asp -* -* @param string -* @return boolean TRUE if it's all ASCII -* @package utf8 -* @subpackage ascii -*/ -function utf8_strip_non_ascii_ctrl($str) { - ob_start(); - while ( preg_match( - '/^([\x09\x0A\x0D\x20-\x7E]+)|([^\x09\x0A\x0D\x20-\x7E]+)/S', - $str, $matches) ) { - if ( !isset($matches[2]) ) { - echo $matches[0]; - } - $str = substr($str, strlen($matches[0])); - } - $result = ob_get_contents(); - ob_end_clean(); - return $result; -} - -//--------------------------------------------------------------- -/** -* Replace accented UTF-8 characters by unaccented ASCII-7 "equivalents". -* The purpose of this function is to replace characters commonly found in Latin -* alphabets with something more or less equivalent from the ASCII range. This can -* be useful for converting a UTF-8 to something ready for a filename, for example. -* Following the use of this function, you would probably also pass the string -* through utf8_strip_non_ascii to clean out any other non-ASCII chars -* Use the optional parameter to just deaccent lower ($case = -1) or upper ($case = 1) -* letters. Default is to deaccent both cases ($case = 0) -* @param string UTF-8 string -* @param int (optional) -1 lowercase only, +1 uppercase only, 1 both cases -* @param string UTF-8 with accented characters replaced by ASCII chars -* @return string accented chars replaced with ascii equivalents -* @author Andreas Gohr -* @package utf8 -* @subpackage ascii -*/ -function utf8_accents_to_ascii( $str, $case=0 ){ - - if($case <= 0){ - global $UTF8_LOWER_ACCENTS; - $string = str_replace( - array_keys($UTF8_LOWER_ACCENTS), - array_values($UTF8_LOWER_ACCENTS), - $str - ); - } - - if($case >= 0){ - global $UTF8_UPPER_ACCENTS; - $string = str_replace( - array_keys($UTF8_UPPER_ACCENTS), - array_values($UTF8_UPPER_ACCENTS), - $str - ); - } - - return $str; - -} \ No newline at end of file + +* if ( utf8_is_ascii($someString) ) { +* // It's just ASCII - use the native PHP version +* $someString = strtolower($someString); +* } else { +* $someString = utf8_strtolower($someString); +* } +* +* +* @param string +* @return boolean TRUE if it's all ASCII +* @package utf8 +* @subpackage ascii +* @see utf8_is_ascii_ctrl +*/ +function utf8_is_ascii($str) { + // Search for any bytes which are outside the ASCII range... + return (preg_match('/(?:[^\x00-\x7F])/',$str) !== 1); +} + +//-------------------------------------------------------------------- +/** +* Tests whether a string contains only 7bit ASCII bytes with device +* control codes omitted. The device control codes can be found on the +* second table here: http://www.w3schools.com/tags/ref_ascii.asp +* +* @param string +* @return boolean TRUE if it's all ASCII without device control codes +* @package utf8 +* @subpackage ascii +* @see utf8_is_ascii +*/ +function utf8_is_ascii_ctrl($str) { + if ( strlen($str) > 0 ) { + // Search for any bytes which are outside the ASCII range, + // or are device control codes + return (preg_match('/[^\x09\x0A\x0D\x20-\x7E]/',$str) !== 1); + } + return FALSE; +} + +//-------------------------------------------------------------------- +/** +* Strip out all non-7bit ASCII bytes +* If you need to transmit a string to system which you know can only +* support 7bit ASCII, you could use this function. +* @param string +* @return string with non ASCII bytes removed +* @package utf8 +* @subpackage ascii +* @see utf8_strip_non_ascii_ctrl +*/ +function utf8_strip_non_ascii($str) { + ob_start(); + while ( preg_match( + '/^([\x00-\x7F]+)|([^\x00-\x7F]+)/S', + $str, $matches) ) { + if ( !isset($matches[2]) ) { + echo $matches[0]; + } + $str = substr($str, strlen($matches[0])); + } + $result = ob_get_contents(); + ob_end_clean(); + return $result; +} + +//-------------------------------------------------------------------- +/** +* Strip out device control codes in the ASCII range +* which are not permitted in XML. Note that this leaves +* multi-byte characters untouched - it only removes device +* control codes +* @see http://hsivonen.iki.fi/producing-xml/#controlchar +* @param string +* @return string control codes removed +*/ +function utf8_strip_ascii_ctrl($str) { + ob_start(); + while ( preg_match( + '/^([^\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+)|([\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+)/S', + $str, $matches) ) { + if ( !isset($matches[2]) ) { + echo $matches[0]; + } + $str = substr($str, strlen($matches[0])); + } + $result = ob_get_contents(); + ob_end_clean(); + return $result; +} + +//-------------------------------------------------------------------- +/** +* Strip out all non 7bit ASCII bytes and ASCII device control codes. +* For a list of ASCII device control codes see the 2nd table here: +* http://www.w3schools.com/tags/ref_ascii.asp +* +* @param string +* @return boolean TRUE if it's all ASCII +* @package utf8 +* @subpackage ascii +*/ +function utf8_strip_non_ascii_ctrl($str) { + ob_start(); + while ( preg_match( + '/^([\x09\x0A\x0D\x20-\x7E]+)|([^\x09\x0A\x0D\x20-\x7E]+)/S', + $str, $matches) ) { + if ( !isset($matches[2]) ) { + echo $matches[0]; + } + $str = substr($str, strlen($matches[0])); + } + $result = ob_get_contents(); + ob_end_clean(); + return $result; +} + +//--------------------------------------------------------------- +/** +* Replace accented UTF-8 characters by unaccented ASCII-7 "equivalents". +* The purpose of this function is to replace characters commonly found in Latin +* alphabets with something more or less equivalent from the ASCII range. This can +* be useful for converting a UTF-8 to something ready for a filename, for example. +* Following the use of this function, you would probably also pass the string +* through utf8_strip_non_ascii to clean out any other non-ASCII chars +* Use the optional parameter to just deaccent lower ($case = -1) or upper ($case = 1) +* letters. Default is to deaccent both cases ($case = 0) +* +* For a more complete implementation of transliteration, see the utf8_to_ascii package +* available from the phputf8 project downloads: +* http://prdownloads.sourceforge.net/phputf8 +* +* @param string UTF-8 string +* @param int (optional) -1 lowercase only, +1 uppercase only, 1 both cases +* @param string UTF-8 with accented characters replaced by ASCII chars +* @return string accented chars replaced with ascii equivalents +* @author Andreas Gohr +* @package utf8 +* @subpackage ascii +*/ +function utf8_accents_to_ascii( $str, $case=0 ){ + + static $UTF8_LOWER_ACCENTS = NULL; + static $UTF8_UPPER_ACCENTS = NULL; + + if($case <= 0){ + + if ( is_null($UTF8_LOWER_ACCENTS) ) { + $UTF8_LOWER_ACCENTS = array( + 'à' => 'a', 'ô' => 'o', 'ď' => 'd', 'ḟ' => 'f', 'ë' => 'e', 'š' => 's', 'ơ' => 'o', + 'ß' => 'ss', 'ă' => 'a', 'ř' => 'r', 'ț' => 't', 'ň' => 'n', 'ā' => 'a', 'ķ' => 'k', + 'ŝ' => 's', 'ỳ' => 'y', 'ņ' => 'n', 'ĺ' => 'l', 'ħ' => 'h', 'ṗ' => 'p', 'ó' => 'o', + 'ú' => 'u', 'ě' => 'e', 'é' => 'e', 'ç' => 'c', 'ẁ' => 'w', 'ċ' => 'c', 'õ' => 'o', + 'ṡ' => 's', 'ø' => 'o', 'ģ' => 'g', 'ŧ' => 't', 'ș' => 's', 'ė' => 'e', 'ĉ' => 'c', + 'ś' => 's', 'î' => 'i', 'ű' => 'u', 'ć' => 'c', 'ę' => 'e', 'ŵ' => 'w', 'ṫ' => 't', + 'ū' => 'u', 'č' => 'c', 'ö' => 'oe', 'è' => 'e', 'ŷ' => 'y', 'ą' => 'a', 'ł' => 'l', + 'ų' => 'u', 'ů' => 'u', 'ş' => 's', 'ğ' => 'g', 'ļ' => 'l', 'ƒ' => 'f', 'ž' => 'z', + 'ẃ' => 'w', 'ḃ' => 'b', 'å' => 'a', 'ì' => 'i', 'ï' => 'i', 'ḋ' => 'd', 'ť' => 't', + 'ŗ' => 'r', 'ä' => 'ae', 'í' => 'i', 'ŕ' => 'r', 'ê' => 'e', 'ü' => 'ue', 'ò' => 'o', + 'ē' => 'e', 'ñ' => 'n', 'ń' => 'n', 'ĥ' => 'h', 'ĝ' => 'g', 'đ' => 'd', 'ĵ' => 'j', + 'ÿ' => 'y', 'ũ' => 'u', 'ŭ' => 'u', 'ư' => 'u', 'ţ' => 't', 'ý' => 'y', 'ő' => 'o', + 'â' => 'a', 'ľ' => 'l', 'ẅ' => 'w', 'ż' => 'z', 'ī' => 'i', 'ã' => 'a', 'ġ' => 'g', + 'ṁ' => 'm', 'ō' => 'o', 'ĩ' => 'i', 'ù' => 'u', 'į' => 'i', 'ź' => 'z', 'á' => 'a', + 'û' => 'u', 'þ' => 'th', 'ð' => 'dh', 'æ' => 'ae', 'µ' => 'u', 'ĕ' => 'e', + ); + } + + $str = str_replace( + array_keys($UTF8_LOWER_ACCENTS), + array_values($UTF8_LOWER_ACCENTS), + $str + ); + } + + if($case >= 0){ + if ( is_null($UTF8_UPPER_ACCENTS) ) { + $UTF8_UPPER_ACCENTS = array( + 'À' => 'A', 'Ô' => 'O', 'Ď' => 'D', 'Ḟ' => 'F', 'Ë' => 'E', 'Š' => 'S', 'Ơ' => 'O', + 'Ă' => 'A', 'Ř' => 'R', 'Ț' => 'T', 'Ň' => 'N', 'Ā' => 'A', 'Ķ' => 'K', + 'Ŝ' => 'S', 'Ỳ' => 'Y', 'Ņ' => 'N', 'Ĺ' => 'L', 'Ħ' => 'H', 'Ṗ' => 'P', 'Ó' => 'O', + 'Ú' => 'U', 'Ě' => 'E', 'É' => 'E', 'Ç' => 'C', 'Ẁ' => 'W', 'Ċ' => 'C', 'Õ' => 'O', + 'Ṡ' => 'S', 'Ø' => 'O', 'Ģ' => 'G', 'Ŧ' => 'T', 'Ș' => 'S', 'Ė' => 'E', 'Ĉ' => 'C', + 'Ś' => 'S', 'Î' => 'I', 'Ű' => 'U', 'Ć' => 'C', 'Ę' => 'E', 'Ŵ' => 'W', 'Ṫ' => 'T', + 'Ū' => 'U', 'Č' => 'C', 'Ö' => 'Oe', 'È' => 'E', 'Ŷ' => 'Y', 'Ą' => 'A', 'Ł' => 'L', + 'Ų' => 'U', 'Ů' => 'U', 'Ş' => 'S', 'Ğ' => 'G', 'Ļ' => 'L', 'Ƒ' => 'F', 'Ž' => 'Z', + 'Ẃ' => 'W', 'Ḃ' => 'B', 'Å' => 'A', 'Ì' => 'I', 'Ï' => 'I', 'Ḋ' => 'D', 'Ť' => 'T', + 'Ŗ' => 'R', 'Ä' => 'Ae', 'Í' => 'I', 'Ŕ' => 'R', 'Ê' => 'E', 'Ü' => 'Ue', 'Ò' => 'O', + 'Ē' => 'E', 'Ñ' => 'N', 'Ń' => 'N', 'Ĥ' => 'H', 'Ĝ' => 'G', 'Đ' => 'D', 'Ĵ' => 'J', + 'Ÿ' => 'Y', 'Ũ' => 'U', 'Ŭ' => 'U', 'Ư' => 'U', 'Ţ' => 'T', 'Ý' => 'Y', 'Ő' => 'O', + 'Â' => 'A', 'Ľ' => 'L', 'Ẅ' => 'W', 'Ż' => 'Z', 'Ī' => 'I', 'Ã' => 'A', 'Ġ' => 'G', + 'Ṁ' => 'M', 'Ō' => 'O', 'Ĩ' => 'I', 'Ù' => 'U', 'Į' => 'I', 'Ź' => 'Z', 'Á' => 'A', + 'Û' => 'U', 'Þ' => 'Th', 'Ð' => 'Dh', 'Æ' => 'Ae', 'Ĕ' => 'E', + ); + } + $str = str_replace( + array_keys($UTF8_UPPER_ACCENTS), + array_values($UTF8_UPPER_ACCENTS), + $str + ); + } + + return $str; + +} diff --git a/oss/joomla/trunk/libraries/simplepie/simplepie.php b/oss/joomla/trunk/libraries/simplepie/simplepie.php index d5d4464d..8c2430a7 100644 --- a/oss/joomla/trunk/libraries/simplepie/simplepie.php +++ b/oss/joomla/trunk/libraries/simplepie/simplepie.php @@ -1,10841 +1,15001 @@ -' . SIMPLEPIE_NAME . ''); - -/** - * No Autodiscovery - * @see SimplePie::set_autodiscovery_level() - */ -define('SIMPLEPIE_LOCATOR_NONE', 0); - -/** - * Feed Link Element Autodiscovery - * @see SimplePie::set_autodiscovery_level() - */ -define('SIMPLEPIE_LOCATOR_AUTODISCOVERY', 1); - -/** - * Local Feed Extension Autodiscovery - * @see SimplePie::set_autodiscovery_level() - */ -define('SIMPLEPIE_LOCATOR_LOCAL_EXTENSION', 2); - -/** - * Local Feed Body Autodiscovery - * @see SimplePie::set_autodiscovery_level() - */ -define('SIMPLEPIE_LOCATOR_LOCAL_BODY', 4); - -/** - * Remote Feed Extension Autodiscovery - * @see SimplePie::set_autodiscovery_level() - */ -define('SIMPLEPIE_LOCATOR_REMOTE_EXTENSION', 8); - -/** - * Remote Feed Body Autodiscovery - * @see SimplePie::set_autodiscovery_level() - */ -define('SIMPLEPIE_LOCATOR_REMOTE_BODY', 16); - -/** - * All Feed Autodiscovery - * @see SimplePie::set_autodiscovery_level() - */ -define('SIMPLEPIE_LOCATOR_ALL', 31); - -/** - * No known feed type - */ -define('SIMPLEPIE_TYPE_NONE', 0); - -/** - * RSS 0.90 - */ -define('SIMPLEPIE_TYPE_RSS_090', 1); - -/** - * RSS 0.91 (Netscape) - */ -define('SIMPLEPIE_TYPE_RSS_091_NETSCAPE', 2); - -/** - * RSS 0.91 (Userland) - */ -define('SIMPLEPIE_TYPE_RSS_091_USERLAND', 4); - -/** - * RSS 0.91 (both Netscape and Userland) - */ -define('SIMPLEPIE_TYPE_RSS_091', 6); - -/** - * RSS 0.92 - */ -define('SIMPLEPIE_TYPE_RSS_092', 8); - -/** - * RSS 0.93 - */ -define('SIMPLEPIE_TYPE_RSS_093', 16); - -/** - * RSS 0.94 - */ -define('SIMPLEPIE_TYPE_RSS_094', 32); - -/** - * RSS 1.0 - */ -define('SIMPLEPIE_TYPE_RSS_10', 64); - -/** - * RSS 2.0 - */ -define('SIMPLEPIE_TYPE_RSS_20', 128); - -/** - * RDF-based RSS - */ -define('SIMPLEPIE_TYPE_RSS_RDF', 65); - -/** - * Non-RDF-based RSS (truly intended as syndication format) - */ -define('SIMPLEPIE_TYPE_RSS_SYNDICATION', 190); - -/** - * All RSS - */ -define('SIMPLEPIE_TYPE_RSS_ALL', 255); - -/** - * Atom 0.3 - */ -define('SIMPLEPIE_TYPE_ATOM_03', 256); - -/** - * Atom 1.0 - */ -define('SIMPLEPIE_TYPE_ATOM_10', 512); - -/** - * All Atom - */ -define('SIMPLEPIE_TYPE_ATOM_ALL', 768); - -/** - * All feed types - */ -define('SIMPLEPIE_TYPE_ALL', 1023); - -/** - * No construct - */ -define('SIMPLEPIE_CONSTRUCT_NONE', 0); - -/** - * Text construct - */ -define('SIMPLEPIE_CONSTRUCT_TEXT', 1); - -/** - * HTML construct - */ -define('SIMPLEPIE_CONSTRUCT_HTML', 2); - -/** - * XHTML construct - */ -define('SIMPLEPIE_CONSTRUCT_XHTML', 4); - -/** - * base64-encoded construct - */ -define('SIMPLEPIE_CONSTRUCT_BASE64', 8); - -/** - * IRI construct - */ -define('SIMPLEPIE_CONSTRUCT_IRI', 16); - -/** - * A construct that might be HTML - */ -define('SIMPLEPIE_CONSTRUCT_MAYBE_HTML', 32); - -/** - * All constructs - */ -define('SIMPLEPIE_CONSTRUCT_ALL', 63); - -/** - * PCRE for HTML attributes - */ -define('SIMPLEPIE_PCRE_HTML_ATTRIBUTE', '((?:\s+(?:(?:[^\s:]+:)?[^\s:]+)(?:\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'|(?:[a-z0-9\-._:]*)))?)*)\s*'); - -/** - * PCRE for XML attributes - */ -define('SIMPLEPIE_PCRE_XML_ATTRIBUTE', '((?:\s+(?:(?:[^\s:]+:)?[^\s:]+)\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'))*)\s*'); - -/** - * XML Namespace - */ -define('SIMPLEPIE_NAMESPACE_XML', 'http://www.w3.org/XML/1998/namespace'); - -/** - * Atom 1.0 Namespace - */ -define('SIMPLEPIE_NAMESPACE_ATOM_10', 'http://www.w3.org/2005/Atom'); - -/** - * Atom 0.3 Namespace - */ -define('SIMPLEPIE_NAMESPACE_ATOM_03', 'http://purl.org/atom/ns#'); - -/** - * RDF Namespace - */ -define('SIMPLEPIE_NAMESPACE_RDF', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'); - -/** - * RSS 0.90 Namespace - */ -define('SIMPLEPIE_NAMESPACE_RSS_090', 'http://my.netscape.com/rdf/simple/0.9/'); - -/** - * RSS 1.0 Namespace - */ -define('SIMPLEPIE_NAMESPACE_RSS_10', 'http://purl.org/rss/1.0/'); - -/** - * RSS 1.0 Content Module Namespace - */ -define('SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT', 'http://purl.org/rss/1.0/modules/content/'); - -/** - * DC 1.0 Namespace - */ -define('SIMPLEPIE_NAMESPACE_DC_10', 'http://purl.org/dc/elements/1.0/'); - -/** - * DC 1.1 Namespace - */ -define('SIMPLEPIE_NAMESPACE_DC_11', 'http://purl.org/dc/elements/1.1/'); - -/** - * W3C Basic Geo (WGS84 lat/long) Vocabulary Namespace - */ -define('SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO', 'http://www.w3.org/2003/01/geo/wgs84_pos#'); - -/** - * GeoRSS Namespace - */ -define('SIMPLEPIE_NAMESPACE_GEORSS', 'http://www.georss.org/georss'); - -/** - * Media RSS Namespace - */ -define('SIMPLEPIE_NAMESPACE_MEDIARSS', 'http://search.yahoo.com/mrss/'); - -/** - * iTunes RSS Namespace - */ -define('SIMPLEPIE_NAMESPACE_ITUNES', 'http://www.itunes.com/dtds/podcast-1.0.dtd'); - -/** - * XHTML Namespace - */ -define('SIMPLEPIE_NAMESPACE_XHTML', 'http://www.w3.org/1999/xhtml'); - -/** - * IANA Link Relations Registry - */ -define('SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY', 'http://www.iana.org/assignments/relation/'); - -/** - * Whether we're running on PHP5 - */ -define('SIMPLEPIE_PHP5', version_compare(PHP_VERSION, '5.0.0', '>=')); - -/** - * SimplePie - * - * @package SimplePie - * @version "Razzleberry" - * @copyright 2004-2007 Ryan Parman, Geoffrey Sneddon - * @author Ryan Parman - * @author Geoffrey Sneddon - * @todo Option for type of fetching (cache, not modified header, fetch, etc.) - */ -class SimplePie -{ - /** - * @var array Raw data - * @access private - */ - var $data = array(); - - /** - * @var mixed Error string - * @access private - */ - var $error; - - /** - * @var object Instance of SimplePie_Sanitize (or other class) - * @see SimplePie::set_sanitize_class() - * @access private - */ - var $sanitize; - - /** - * @var string SimplePie Useragent - * @see SimplePie::set_useragent() - * @access private - */ - var $useragent = SIMPLEPIE_USERAGENT; - - /** - * @var string Feed URL - * @see SimplePie::set_feed_url() - * @access private - */ - var $feed_url; - - /** - * @var object Instance of SimplePie_File to use as a feed - * @see SimplePie::set_file() - * @access private - */ - var $file; - - /** - * @var string Raw feed data - * @see SimplePie::set_raw_data() - * @access private - */ - var $raw_data; - - /** - * @var int Timeout for fetching remote files - * @see SimplePie::set_timeout() - * @access private - */ - var $timeout = 10; - - /** - * @var bool Forces fsockopen() to be used for remote files instead - * of cURL, even if a new enough version is installed - * @see SimplePie::force_fsockopen() - * @access private - */ - var $force_fsockopen = false; - - /** - * @var bool Enable/Disable XML dump - * @see SimplePie::enable_xml_dump() - * @access private - */ - var $xml_dump = false; - - /** - * @var bool Enable/Disable Caching - * @see SimplePie::enable_cache() - * @access private - */ - var $cache = true; - - /** - * @var int Cache duration (in seconds) - * @see SimplePie::set_cache_duration() - * @access private - */ - var $cache_duration = 3600; - - /** - * @var int Auto-discovery cache duration (in seconds) - * @see SimplePie::set_autodiscovery_cache_duration() - * @access private - */ - var $autodiscovery_cache_duration = 604800; // 7 Days. - - /** - * @var string Cache location (relative to executing script) - * @see SimplePie::set_cache_location() - * @access private - */ - var $cache_location = './cache'; - - /** - * @var string Function that creates the cache filename - * @see SimplePie::set_cache_name_function() - * @access private - */ - var $cache_name_function = 'md5'; - - /** - * @var bool Reorder feed by date descending - * @see SimplePie::enable_order_by_date() - * @access private - */ - var $order_by_date = true; - - /** - * @var mixed Force input encoding to be set to the follow value - * (false, or anything type-cast to false, disables this feature) - * @see SimplePie::set_input_encoding() - * @access private - */ - var $input_encoding = false; - - /** - * @var int Feed Autodiscovery Level - * @see SimplePie::set_autodiscovery_level() - * @access private - */ - var $autodiscovery = SIMPLEPIE_LOCATOR_ALL; - - /** - * @var string Class used for caching feeds - * @see SimplePie::set_cache_class() - * @access private - */ - var $cache_class = 'SimplePie_Cache'; - - /** - * @var string Class used for locating feeds - * @see SimplePie::set_locator_class() - * @access private - */ - var $locator_class = 'SimplePie_Locator'; - - /** - * @var string Class used for parsing feeds - * @see SimplePie::set_parser_class() - * @access private - */ - var $parser_class = 'SimplePie_Parser'; - - /** - * @var string Class used for fetching feeds - * @see SimplePie::set_file_class() - * @access private - */ - var $file_class = 'SimplePie_File'; - - /** - * @var string Class used for items - * @see SimplePie::set_item_class() - * @access private - */ - var $item_class = 'SimplePie_Item'; - - /** - * @var string Class used for authors - * @see SimplePie::set_author_class() - * @access private - */ - var $author_class = 'SimplePie_Author'; - - /** - * @var string Class used for categories - * @see SimplePie::set_category_class() - * @access private - */ - var $category_class = 'SimplePie_Category'; - - /** - * @var string Class used for enclosures - * @see SimplePie::set_enclosures_class() - * @access private - */ - var $enclosure_class = 'SimplePie_Enclosure'; - - /** - * @var string Class used for Media RSS captions - * @see SimplePie::set_caption_class() - * @access private - */ - var $caption_class = 'SimplePie_Caption'; - - /** - * @var string Class used for Media RSS - * @see SimplePie::set_copyright_class() - * @access private - */ - var $copyright_class = 'SimplePie_Copyright'; - - /** - * @var string Class used for Media RSS - * @see SimplePie::set_credit_class() - * @access private - */ - var $credit_class = 'SimplePie_Credit'; - - /** - * @var string Class used for Media RSS - * @see SimplePie::set_rating_class() - * @access private - */ - var $rating_class = 'SimplePie_Rating'; - - /** - * @var string Class used for Media RSS - * @see SimplePie::set_restriction_class() - * @access private - */ - var $restriction_class = 'SimplePie_Restriction'; - - /** - * @var mixed Set javascript query string parameter (false, or - * anything type-cast to false, disables this feature) - * @see SimplePie::set_javascript() - * @access private - */ - var $javascript = 'js'; - - /** - * @var int Maximum number of feeds to check with autodiscovery - * @see SimplePie::set_max_checked_feeds() - * @access private - */ - var $max_checked_feeds = 10; - - /** - * @var string Web-accessible path to the handler_favicon.php file. - * @see SimplePie::set_favicon_handler() - * @access private - */ - var $favicon_handler = ''; - - /** - * @var string Web-accessible path to the handler_image.php file. - * @see SimplePie::set_image_handler() - * @access private - */ - var $image_handler = ''; - - /** - * @var array Stores the URLs when multiple feeds are being initialized. - * @see SimplePie::set_feed_url() - * @access private - */ - var $multifeed_url = array(); - - /** - * @var array Stores SimplePie objects when multiple feeds initialized. - * @access private - */ - var $multifeed_objects = array(); - - /** - * @var array Stores the get_object_vars() array for use with multifeeds. - * @see SimplePie::set_feed_url() - * @access private - */ - var $config_settings = null; - - /** - * @var array Stores the default attributes to be stripped by strip_attributes(). - * @see SimplePie::strip_attributes() - * @access private - */ - var $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'); - - /** - * @var array Stores the default tags to be stripped by strip_htmltags(). - * @see SimplePie::strip_htmltags() - * @access private - */ - var $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'); - - /** - * The SimplePie class contains feed level data and options - * - * There are two ways that you can create a new SimplePie object. The first - * is by passing a feed URL as a parameter to the SimplePie constructor - * (as well as optionally setting the cache location and cache expiry). This - * will initialise the whole feed with all of the default settings, and you - * can begin accessing methods and properties immediately. - * - * The second way is to create the SimplePie object with no parameters - * at all. This will enable you to set configuration options. After setting - * them, you must initialise the feed using $feed->init(). At that point the - * object's methods and properties will be available to you. This format is - * what is used throughout this documentation. - * - * @access public - * @since 1.0 Preview Release - * @param string $feed_url This is the URL you want to parse. - * @param string $cache_location This is where you want the cache to be stored. - * @param int $cache_duration This is the number of seconds that you want to store the cache file for. - */ - function SimplePie($feed_url = null, $cache_location = null, $cache_duration = null) - { - // Other objects, instances created here so we can set options on them - $this->sanitize =& new SimplePie_Sanitize; - - // Set options if they're passed to the constructor - if ($cache_location !== null) - { - $this->set_cache_location($cache_location); - } - - if ($cache_duration !== null) - { - $this->set_cache_duration($cache_duration); - } - - // Only init the script if we're passed a feed URL - if ($feed_url !== null) - { - $this->set_feed_url($feed_url); - $this->init(); - } - } - - /** - * Used for converting object to a string - */ - function __toString() - { - return md5(serialize($this->data)); - } - - /** - * This is the URL of the feed you want to parse. - * - * This allows you to enter the URL of the feed you want to parse, or the - * website you want to try to use auto-discovery on. This takes priority - * over any set raw data. - * - * You can set multiple feeds to mash together by passing an array instead - * of a string for the $url. Remember that with each additional feed comes - * additional processing and resources. - * - * @access public - * @since 1.0 Preview Release - * @param mixed $url This is the URL (or array of URLs) that you want to parse. - * @see SimplePie::set_raw_data() - */ - function set_feed_url($url) - { - if (is_array($url)) - { - $this->multifeed_url = array(); - foreach ($url as $value) - { - $this->multifeed_url[] = SimplePie_Misc::fix_protocol($value, 1); - } - } - else - { - $this->feed_url = SimplePie_Misc::fix_protocol($url, 1); - } - } - - /** - * Provides an instance of SimplePie_File to use as a feed - * - * @access public - * @param object &$file Instance of SimplePie_File (or subclass) - * @return bool True on success, false on failure - */ - function set_file(&$file) - { - if (SimplePie_Misc::is_a($file, 'SimplePie_File')) - { - $this->feed_url = $file->url; - $this->file =& $file; - return true; - } - return false; - } - - /** - * Allows you to use a string of RSS/Atom data instead of a remote feed. - * - * If you have a feed available as a string in PHP, you can tell SimplePie - * to parse that data string instead of a remote feed. Any set feed URL - * takes precedence. - * - * @access public - * @since 1.0 Beta 3 - * @param string $data RSS or Atom data as a string. - * @see SimplePie::set_feed_url() - */ - function set_raw_data($data) - { - $this->raw_data = trim($data); - } - - /** - * Allows you to override the default timeout for fetching remote feeds. - * - * This allows you to change the maximum time the feed's server to respond - * and send the feed back. - * - * @access public - * @since 1.0 Beta 3 - * @param int $timeout The maximum number of seconds to spend waiting to retrieve a feed. - */ - function set_timeout($timeout = 10) - { - $this->timeout = (int) $timeout; - } - - /** - * Forces SimplePie to use fsockopen() instead of the preferred cURL - * functions. - * - * @access public - * @since 1.0 Beta 3 - * @param bool $enable Force fsockopen() to be used - */ - function force_fsockopen($enable = false) - { - $this->force_fsockopen = (bool) $enable; - } - - /** - * Outputs the raw XML content of the feed, after it has gone through - * SimplePie's filters. - * - * Used only for debugging, this function will output the XML content as - * text/xml. When SimplePie reads in a feed, it does a bit of cleaning up - * before trying to parse it. Many parts of the feed are re-written in - * memory, and in the end, you have a parsable feed. XML dump shows you the - * actual XML that SimplePie tries to parse, which may or may not be very - * different from the original feed. - * - * @access public - * @since 1.0 Preview Release - * @param bool $enable Enable XML dump - */ - function enable_xml_dump($enable = false) - { - $this->xml_dump = (bool) $enable; - } - - /** - * Enables/disables caching in SimplePie. - * - * This option allows you to disable caching all-together in SimplePie. - * However, disabling the cache can lead to longer load times. - * - * @access public - * @since 1.0 Preview Release - * @param bool $enable Enable caching - */ - function enable_cache($enable = true) - { - $this->cache = (bool) $enable; - } - - /** - * Set the length of time (in seconds) that the contents of a feed - * will be cached. - * - * @access public - * @param int $seconds The feed content cache duration. - */ - function set_cache_duration($seconds = 3600) - { - $this->cache_duration = (int) $seconds; - } - - /** - * Set the length of time (in seconds) that the autodiscovered feed - * URL will be cached. - * - * @access public - * @param int $seconds The autodiscovered feed URL cache duration. - */ - function set_autodiscovery_cache_duration($seconds = 604800) - { - $this->autodiscovery_cache_duration = (int) $seconds; - } - - /** - * Set the file system location where the cached files should be stored. - * - * @access public - * @param string $location The file system location. - */ - function set_cache_location($location = './cache') - { - $this->cache_location = (string) $location; - } - - /** - * Determines whether feed items should be sorted into reverse chronological order. - * - * @access public - * @param bool $enable Sort as reverse chronological order. - */ - function enable_order_by_date($enable = true) - { - $this->order_by_date = (bool) $enable; - } - - /** - * Allows you to override the character encoding reported by the feed. - * - * @access public - * @param string $encoding Character encoding. - */ - function set_input_encoding($encoding = false) - { - if ($encoding) - { - $this->input_encoding = (string) $encoding; - } - else - { - $this->input_encoding = false; - } - } - - /** - * Set how much feed autodiscovery to do - * - * @access public - * @see SIMPLEPIE_LOCATOR_NONE - * @see SIMPLEPIE_LOCATOR_AUTODISCOVERY - * @see SIMPLEPIE_LOCATOR_LOCAL_EXTENSION - * @see SIMPLEPIE_LOCATOR_LOCAL_BODY - * @see SIMPLEPIE_LOCATOR_REMOTE_EXTENSION - * @see SIMPLEPIE_LOCATOR_REMOTE_BODY - * @see SIMPLEPIE_LOCATOR_ALL - * @param int $level Feed Autodiscovery Level (level can be a - * combination of the above constants, see bitwise OR operator) - */ - function set_autodiscovery_level($level = SIMPLEPIE_LOCATOR_ALL) - { - $this->autodiscovery = (int) $level; - } - - /** - * Allows you to change which class SimplePie uses for caching. - * Useful when you are overloading or extending SimplePie's default classes. - * - * @access public - * @param string $class Name of custom class. - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation - */ - function set_cache_class($class = 'SimplePie_Cache') - { - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Cache')) - { - $this->cache_class = $class; - return true; - } - return false; - } - - /** - * Allows you to change which class SimplePie uses for auto-discovery. - * Useful when you are overloading or extending SimplePie's default classes. - * - * @access public - * @param string $class Name of custom class. - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation - */ - function set_locator_class($class = 'SimplePie_Locator') - { - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Locator')) - { - $this->locator_class = $class; - return true; - } - return false; - } - - /** - * Allows you to change which class SimplePie uses for XML parsing. - * Useful when you are overloading or extending SimplePie's default classes. - * - * @access public - * @param string $class Name of custom class. - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation - */ - function set_parser_class($class = 'SimplePie_Parser') - { - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Parser')) - { - $this->parser_class = $class; - return true; - } - return false; - } - - /** - * Allows you to change which class SimplePie uses for remote file fetching. - * Useful when you are overloading or extending SimplePie's default classes. - * - * @access public - * @param string $class Name of custom class. - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation - */ - function set_file_class($class = 'SimplePie_File') - { - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_File')) - { - $this->file_class = $class; - return true; - } - return false; - } - - /** - * Allows you to change which class SimplePie uses for data sanitization. - * Useful when you are overloading or extending SimplePie's default classes. - * - * @access public - * @param string $class Name of custom class. - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation - */ - function set_sanitize_class($class = 'SimplePie_Sanitize') - { - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Sanitize')) - { - $this->sanitize =& new $class; - return true; - } - return false; - } - - /** - * Allows you to change which class SimplePie uses for handling feed items. - * Useful when you are overloading or extending SimplePie's default classes. - * - * @access public - * @param string $class Name of custom class. - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation - */ - function set_item_class($class = 'SimplePie_Item') - { - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Item')) - { - $this->item_class = $class; - return true; - } - return false; - } - - /** - * Allows you to change which class SimplePie uses for handling author data. - * Useful when you are overloading or extending SimplePie's default classes. - * - * @access public - * @param string $class Name of custom class. - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation - */ - function set_author_class($class = 'SimplePie_Author') - { - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Author')) - { - $this->author_class = $class; - return true; - } - return false; - } - - /** - * Allows you to change which class SimplePie uses for handling category data. - * Useful when you are overloading or extending SimplePie's default classes. - * - * @access public - * @param string $class Name of custom class. - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation - */ - function set_category_class($class = 'SimplePie_Category') - { - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Category')) - { - $this->category_class = $class; - return true; - } - return false; - } - - /** - * Allows you to change which class SimplePie uses for feed enclosures. - * Useful when you are overloading or extending SimplePie's default classes. - * - * @access public - * @param string $class Name of custom class. - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation - */ - function set_enclosure_class($class = 'SimplePie_Enclosure') - { - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Enclosure')) - { - $this->enclosure_class = $class; - return true; - } - return false; - } - - /** - * Allows you to change which class SimplePie uses for captions - * Useful when you are overloading or extending SimplePie's default classes. - * - * @access public - * @param string $class Name of custom class. - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation - */ - function set_caption_class($class = 'SimplePie_Caption') - { - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Caption')) - { - $this->caption_class = $class; - return true; - } - return false; - } - - /** - * Allows you to change which class SimplePie uses for - * Useful when you are overloading or extending SimplePie's default classes. - * - * @access public - * @param string $class Name of custom class. - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation - */ - function set_copyright_class($class = 'SimplePie_Copyright') - { - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Copyright')) - { - $this->copyright_class = $class; - return true; - } - return false; - } - - /** - * Allows you to change which class SimplePie uses for - * Useful when you are overloading or extending SimplePie's default classes. - * - * @access public - * @param string $class Name of custom class. - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation - */ - function set_credit_class($class = 'SimplePie_Credit') - { - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Credit')) - { - $this->credit_class = $class; - return true; - } - return false; - } - - /** - * Allows you to change which class SimplePie uses for - * Useful when you are overloading or extending SimplePie's default classes. - * - * @access public - * @param string $class Name of custom class. - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation - */ - function set_rating_class($class = 'SimplePie_Rating') - { - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Rating')) - { - $this->rating_class = $class; - return true; - } - return false; - } - - /** - * Allows you to change which class SimplePie uses for - * Useful when you are overloading or extending SimplePie's default classes. - * - * @access public - * @param string $class Name of custom class. - * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation - * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation - */ - function set_restriction_class($class = 'SimplePie_Restriction') - { - if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Restriction')) - { - $this->restriction_class = $class; - return true; - } - return false; - } - - /** - * Allows you to override the default user agent string. - * - * @access public - * @param string $ua New user agent string. - */ - function set_useragent($ua = SIMPLEPIE_USERAGENT) - { - $this->useragent = (string) $ua; - } - - /** - * Set callback function to create cache filename with - * - * @access public - * @param mixed $function Callback function - */ - function set_cache_name_function($function = 'md5') - { - if (is_callable($function)) - { - $this->cache_name_function = $function; - } - } - - /** - * Set javascript query string parameter - * - * @access public - * @param mixed $get Javascript query string parameter - */ - function set_javascript($get = 'js') - { - if ($get) - { - $this->javascript = (string) $get; - } - else - { - $this->javascript = false; - } - } - - /** - * Set options to make SP as fast as possible. Forgoes a - * substantial amount of data sanitization in favor of speed. - * - * @access public - * @param bool $set Whether to set them or not - */ - function set_stupidly_fast($set = false) - { - if ($set) - { - $this->enable_order_by_date(false); - $this->remove_div(false); - $this->strip_comments(false); - $this->strip_htmltags(false); - $this->strip_attributes(false); - $this->set_image_handler(false); - } - } - - /** - * Set maximum number of feeds to check with autodiscovery - * - * @access public - * @param int $max Maximum number of feeds to check - */ - function set_max_checked_feeds($max = 10) - { - $this->max_checked_feeds = (int) $max; - } - - function remove_div($enable = true) - { - $this->sanitize->remove_div($enable); - } - - function strip_htmltags($tags = '', $encode = null) - { - if ($tags === '') - { - $tags = $this->strip_htmltags; - } - $this->sanitize->strip_htmltags($tags); - if ($encode !== null) - { - $this->sanitize->encode_instead_of_strip($tags); - } - } - - function encode_instead_of_strip($enable = true) - { - $this->sanitize->encode_instead_of_strip($enable); - } - - function strip_attributes($attribs = '') - { - if ($attribs === '') - { - $attribs = $this->strip_attributes; - } - $this->sanitize->strip_attributes($attribs); - } - - function set_output_encoding($encoding = 'UTF-8') - { - $this->sanitize->set_output_encoding($encoding); - } - - function strip_comments($strip = false) - { - $this->sanitize->strip_comments($strip); - } - - /** - * Set element/attribute key/value pairs of HTML attributes - * containing URLs that need to be resolved relative to the feed - * - * @access public - * @since 1.0 - * @param array $element_attribute Element/attribute key/value pairs - */ - function set_url_replacements($element_attribute = array('a' => 'href', 'area' => 'href', 'blockquote' => 'cite', 'del' => 'cite', 'form' => 'action', 'img' => array('longdesc', 'src'), 'input' => 'src', 'ins' => 'cite', 'q' => 'cite')) - { - $this->sanitize->set_url_replacements($element_attribute); - } - - /** - * Set the handler to enable the display of cached favicons. - * - * @access public - * @param str $page Web-accessible path to the handler_favicon.php file. - * @param str $qs The query string that the value should be passed to. - */ - function set_favicon_handler($page = false, $qs = 'i') - { - if ($page != false) - { - $this->favicon_handler = $page . '?' . $qs . '='; - } - else - { - $this->favicon_handler = ''; - } - } - - /** - * Set the handler to enable the display of cached images. - * - * @access public - * @param str $page Web-accessible path to the handler_image.php file. - * @param str $qs The query string that the value should be passed to. - */ - function set_image_handler($page = false, $qs = 'i') - { - if ($page != false) - { - $this->sanitize->set_image_handler($page . '?' . $qs . '='); - } - else - { - $this->image_handler = ''; - } - } - - function init() - { - if ((function_exists('version_compare') && version_compare(PHP_VERSION, '4.1.0', '<')) || !extension_loaded('xml') || !extension_loaded('pcre')) - { - return false; - } - if (isset($_GET[$this->javascript])) - { - if (function_exists('ob_gzhandler')) - { - ob_start('ob_gzhandler'); - } - header('Content-type: text/javascript; charset: UTF-8'); - header('Cache-Control: must-revalidate'); - header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days - ?> -function embed_odeo(link) { - document.writeln(''); -} - -function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) { - if (placeholder != '') { - document.writeln(''); - } - else { - document.writeln(''); - } -} - -function embed_flash(bgcolor, width, height, link, loop, type) { - document.writeln(''); -} - -function embed_flv(width, height, link, placeholder, loop, player) { - document.writeln(''); -} - -function embed_wmedia(width, height, link) { - document.writeln(''); -} - sanitize->pass_cache_data($this->cache, $this->cache_location, $this->cache_name_function, $this->cache_class); - $this->sanitize->pass_file_data($this->file_class, $this->timeout, $this->useragent, $this->force_fsockopen); - - if ($this->feed_url !== null || $this->raw_data !== null) - { - $this->data = array(); - $this->multifeed_objects = array(); - $cache = false; - - if ($this->feed_url !== null) - { - $parsed_feed_url = SimplePie_Misc::parse_url($this->feed_url); - // Decide whether to enable caching - if ($this->cache && $parsed_feed_url['scheme'] !== '') - { - $cache =& new $this->cache_class($this->cache_location, call_user_func($this->cache_name_function, $this->feed_url), 'spc'); - } - // If it's enabled and we don't want an XML dump, use the cache - if ($cache && !$this->xml_dump) - { - // Load the Cache - $this->data = $cache->load(); - if (!empty($this->data)) - { - // If the cache is for an outdated build of SimplePie - if (!isset($this->data['build']) || $this->data['build'] != SIMPLEPIE_BUILD) - { - $cache->unlink(); - $this->data = array(); - } - // If we've hit a collision just rerun it with caching disabled - elseif (isset($this->data['url']) && $this->data['url'] != $this->feed_url) - { - $cache = false; - $this->data = array(); - } - // If we've got a non feed_url stored (if the page isn't actually a feed, or is a redirect) use that URL. - elseif (isset($this->data['feed_url'])) - { - // If the autodiscovery cache is still valid use it. - if ($cache->mtime() + $this->autodiscovery_cache_duration > time()) - { - // Do not need to do feed autodiscovery yet. - if ($this->data['feed_url'] == $this->data['url']) - { - $cache->unlink(); - $this->data = array(); - } - else - { - $this->set_feed_url($this->data['feed_url']); - return $this->init(); - } - } - } - // Check if the cache has been updated - elseif ($cache->mtime() + $this->cache_duration < time()) - { - // If we have last-modified and/or etag set - if (isset($this->data['headers']['last-modified']) || isset($this->data['headers']['etag'])) - { - $headers = array(); - if (isset($this->data['headers']['last-modified'])) - { - $headers['if-modified-since'] = $this->data['headers']['last-modified']; - } - if (isset($this->data['headers']['etag'])) - { - $headers['if-none-match'] = $this->data['headers']['etag']; - } - $file =& new $this->file_class($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen); - if ($file->success) - { - if ($file->status_code == 304) - { - $cache->touch(); - return true; - } - else - { - $headers = $file->headers; - } - } - else - { - unset($file); - } - } - } - // If the cache is still valid, just return true - else - { - return true; - } - } - // If the cache is empty, delete it - else - { - $cache->unlink(); - $this->data = array(); - } - } - // If we don't already have the file (it'll only exist if we've opened it to check if the cache has been modified), open it. - if (!isset($file)) - { - if (SimplePie_Misc::is_a($this->file, 'SimplePie_File') && $this->file->url == $this->feed_url) - { - $file =& $this->file; - } - else - { - $file =& new $this->file_class($this->feed_url, $this->timeout, 5, null, $this->useragent, $this->force_fsockopen); - } - } - // If the file connection has an error, set SimplePie::error to that and quit - if (!$file->success) - { - $this->error = $file->error; - if (!empty($this->data)) - { - return true; - } - else - { - return false; - } - } - - // Check if the supplied URL is a feed, if it isn't, look for it. - $locate =& new $this->locator_class($file, $this->timeout, $this->useragent, $this->file_class, $this->max_checked_feeds); - if (!$locate->is_feed($file)) - { - // We need to unset this so that if SimplePie::set_file() has been called that object is untouched - unset($file); - if ($file = $locate->find($this->autodiscovery)) - { - if ($cache) - { - if (!$cache->save(array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD))) - { - trigger_error("$cache->name is not writeable", E_USER_WARNING); - } - $cache =& new $this->cache_class($this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc'); - } - $this->feed_url = $file->url; - } - else - { - $this->error = "A feed could not be found at $this->feed_url"; - SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__); - return false; - } - } - $locate = null; - - $headers = $file->headers; - $data = trim($file->body); - unset($file); - } - else - { - $data = $this->raw_data; - } - - // First check to see if input has been overridden. - if ($this->input_encoding !== false) - { - $encoding = $this->input_encoding; - } - // Second try HTTP headers - elseif (isset($headers['content-type']) && preg_match('/;[\x09\x20]*charset=([^;]*)/i', $headers['content-type'], $charset)) - { - $encoding = $charset[1]; - } - // Then prolog, if at the very start of the document - elseif (preg_match("/^<\?xml[\x20\x9\xD\xA]+version([\x20\x9\xD\xA]+)?=([\x20\x9\xD\xA]+)?(\"1.0\"|'1.0'|\"1.1\"|'1.1')[\x20\x9\xD\xA]+encoding([\x20\x9\xD\xA]+)?=([\x20\x9\xD\xA]+)?(\"[A-Za-z][A-Za-z0-9._\-]*\"|'[A-Za-z][A-Za-z0-9._\-]*')([\x20\x9\xD\xA]+standalone([\x20\x9\xD\xA]+)?=([\x20\x9\xD\xA]+)?(\"(yes|no)\"|'(yes|no)'))?([\x20\x9\xD\xA]+)?\?>/", $data, $prolog)) - { - $encoding = substr($prolog[6], 1, -1); - } - // UTF-32 Big Endian BOM - elseif (strpos($data, "\x0\x0\xFE\xFF") === 0) - { - $encoding = 'UTF-32be'; - } - // UTF-32 Little Endian BOM - elseif (strpos($data, "\xFF\xFE\x0\x0") === 0) - { - $encoding = 'UTF-32'; - } - // UTF-16 Big Endian BOM - elseif (strpos($data, "\xFE\xFF") === 0) - { - $encoding = 'UTF-16be'; - } - // UTF-16 Little Endian BOM - elseif (strpos($data, "\xFF\xFE") === 0) - { - $encoding = 'UTF-16le'; - } - // UTF-8 BOM - elseif (strpos($data, "\xEF\xBB\xBF") === 0) - { - $encoding = 'UTF-8'; - } - // Fallback to the default (US-ASCII for text/xml, ISO-8859-1 for text/* MIME types, UTF-8 otherwise) - elseif (isset($headers['content-type']) && strtolower(SimplePie_Misc::parse_mime($headers['content-type'])) == 'text/xml') - { - $encoding = 'US-ASCII'; - } - elseif (isset($headers['content-type']) && SimplePie_Misc::stripos(SimplePie_Misc::parse_mime($headers['content-type']), 'text/') === 0) - { - $encoding = 'ISO-8859-1'; - } - else - { - $encoding = 'UTF-8'; - } - - // Change the encoding to UTF-8 (as we always use UTF-8 internally) - if ($encoding != 'UTF-8') - { - $data = SimplePie_Misc::change_encoding($data, $encoding, 'UTF-8'); - } - - // Strip illegal characters - //$data = SimplePie_Misc::utf8_bad_replace($data); - - $parser =& new $this->parser_class(); - $parser->pre_process($data, 'UTF-8'); - // If we want the XML, just output that and quit - if ($this->xml_dump) - { - header('Content-type: text/xml; charset=UTF-8'); - echo $data; - exit; - } - // If it's parsed fine - elseif ($parser->parse($data)) - { - unset($data); - $this->data = $parser->get_data(); - if (isset($this->data['child'])) - { - if (isset($headers)) - { - $this->data['headers'] = $headers; - } - $this->data['build'] = SIMPLEPIE_BUILD; - - // Cache the file if caching is enabled - if ($cache && !$cache->save($this->data)) - { - trigger_error("$cache->name is not writeable", E_USER_WARNING); - } - return true; - } - else - { - $this->error = "A feed could not be found at $this->feed_url"; - SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__); - return false; - } - } - // If we have an error, just set SimplePie::error to it and quit - else - { - $this->error = sprintf('XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column()); - SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__); - return false; - } - } - elseif (!empty($this->multifeed_url)) - { - $i = 0; - $success = 0; - $this->multifeed_objects = array(); - foreach ($this->multifeed_url as $url) - { - if (SIMPLEPIE_PHP5) - { - // This keyword needs to defy coding standards for PHP4 compatibility - $this->multifeed_objects[$i] = clone($this); - } - else - { - $this->multifeed_objects[$i] = $this; - } - $this->multifeed_objects[$i]->set_feed_url($url); - $success |= $this->multifeed_objects[$i]->init(); - $i++; - } - return (bool) $success; - } - else - { - return false; - } - } - - /** - * Return the error message for the occured error - * - * @access public - * @return string Error message - */ - function error() - { - return $this->error; - } - - function get_encoding() - { - return $this->sanitize->output_encoding; - } - - function handle_content_type($mime = 'text/html') - { - if (!headers_sent()) - { - $header = "Content-type: $mime;"; - if ($this->get_encoding()) - { - $header .= ' charset=' . $this->get_encoding(); - } - else - { - $header .= ' charset=UTF-8'; - } - header($header); - } - } - - function get_type() - { - if (!isset($this->data['type'])) - { - $this->data['type'] = SIMPLEPIE_TYPE_ALL; - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'])) - { - $this->data['type'] &= SIMPLEPIE_TYPE_ATOM_10; - } - elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'])) - { - $this->data['type'] &= SIMPLEPIE_TYPE_ATOM_03; - } - elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'])) - { - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['channel']) - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['image']) - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item']) - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['textinput'])) - { - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_10; - } - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['channel']) - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['image']) - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item']) - || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['textinput'])) - { - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_090; - } - } - elseif (isset($this->data['child']['']['rss'])) - { - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_ALL; - if (isset($this->data['child']['']['rss'][0]['attribs']['']['version'])) - { - switch (trim($this->data['child']['']['rss'][0]['attribs']['']['version'])) - { - case '0.91': - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091; - if (isset($this->data['child']['']['rss'][0]['child']['']['skiphours']['hour'][0]['data'])) - { - switch (trim($this->data['child']['']['rss'][0]['child']['']['skiphours']['hour'][0]['data'])) - { - case '0': - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_NETSCAPE; - break; - - case '24': - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_USERLAND; - break; - } - } - break; - - case '0.92': - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_092; - break; - - case '0.93': - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_093; - break; - - case '0.94': - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_094; - break; - - case '2.0': - $this->data['type'] &= SIMPLEPIE_TYPE_RSS_20; - break; - } - } - } - else - { - $this->data['type'] = SIMPLEPIE_TYPE_NONE; - } - } - return $this->data['type']; - } - - /** - * Returns the URL for the favicon of the feed's website. - * - * @access public - * @since 1.0 - */ - function get_favicon() - { - if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); - } - elseif (($url = $this->get_link()) !== null && preg_match('/^http(s)?:\/\//i', $url)) - { - $favicon = SimplePie_Misc::absolutize_url('/favicon.ico', $url); - - if ($this->cache && $this->favicon_handler) - { - $cache =& new $this->cache_class($this->cache_location, call_user_func($this->cache_name_function, $favicon), 'spi'); - - if ($cache->load()) - { - return $this->sanitize($this->favicon_handler . rawurlencode($favicon), SIMPLEPIE_CONSTRUCT_IRI); - } - else - { - $file =& new $this->file_class($favicon, $this->timeout / 10, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen); - - if ($file->success && ($file->status_code == 200 || ($file->status_code > 206 && $file->status_code < 300)) && strlen($file->body) > 0) - { - if ($cache->save(array('headers' => $file->headers, 'body' => $file->body))) - { - return $this->sanitize($this->favicon_handler . rawurlencode($favicon), SIMPLEPIE_CONSTRUCT_IRI); - } - else - { - trigger_error("$cache->name is not writeable", E_USER_WARNING); - return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI); - } - } - } - } - else - { - return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI); - } - } - return false; - } - - /** - * @todo If we have a perm redirect we should return the new URL - * @todo When we make the above change, let's support as well - * @todo Also, |atom:link|@rel=self - */ - function subscribe_url() - { - if ($this->feed_url !== null) - { - return $this->sanitize($this->feed_url, SIMPLEPIE_CONSTRUCT_IRI); - } - else - { - return null; - } - } - - function subscribe_feed() - { - if ($this->feed_url !== null) - { - return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI); - } - else - { - return null; - } - } - - function subscribe_outlook() - { - if ($this->feed_url !== null) - { - return 'outlook' . $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI); - } - else - { - return null; - } - } - - function subscribe_podcast() - { - if ($this->feed_url !== null) - { - return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 3), SIMPLEPIE_CONSTRUCT_IRI); - } - else - { - return null; - } - } - - function subscribe_itunes() - { - if ($this->feed_url !== null) - { - return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 4), SIMPLEPIE_CONSTRUCT_IRI); - } - else - { - return null; - } - } - - /** - * Creates the subscribe_* methods' return data - * - * @access private - * @param string $feed_url String to prefix to the feed URL - * @param string $site_url String to prefix to the site URL (and - * suffix to the feed URL) - * @return mixed URL if feed exists, false otherwise - */ - function subscribe_service($feed_url, $site_url = null) - { - if ($this->subscribe_url()) - { - $return = $this->sanitize($feed_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->subscribe_url()); - if ($site_url !== null && $this->get_link() !== null) - { - $return .= $this->sanitize($site_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_link()); - } - return $return; - } - else - { - return null; - } - } - - function subscribe_aol() - { - return $this->subscribe_service('http://feeds.my.aol.com/add.jsp?url='); - } - - function subscribe_bloglines() - { - return urldecode($this->subscribe_service('http://www.bloglines.com/sub/')); - } - - function subscribe_eskobo() - { - return $this->subscribe_service('http://www.eskobo.com/?AddToMyPage='); - } - - function subscribe_feedfeeds() - { - return $this->subscribe_service('http://www.feedfeeds.com/add?feed='); - } - - function subscribe_feedster() - { - return $this->subscribe_service('http://www.feedster.com/myfeedster.php?action=addrss&confirm=no&rssurl='); - } - - function subscribe_google() - { - return $this->subscribe_service('http://fusion.google.com/add?feedurl='); - } - - function subscribe_gritwire() - { - return $this->subscribe_service('http://my.gritwire.com/feeds/addExternalFeed.aspx?FeedUrl='); - } - - function subscribe_msn() - { - return $this->subscribe_service('http://my.msn.com/addtomymsn.armx?id=rss&ut=', '&ru='); - } - - function subscribe_netvibes() - { - return $this->subscribe_service('http://www.netvibes.com/subscribe.php?url='); - } - - function subscribe_newsburst() - { - return $this->subscribe_service('http://www.newsburst.com/Source/?add='); - } - - function subscribe_newsgator() - { - return $this->subscribe_service('http://www.newsgator.com/ngs/subscriber/subext.aspx?url='); - } - - function subscribe_odeo() - { - return $this->subscribe_service('http://www.odeo.com/listen/subscribe?feed='); - } - - function subscribe_podnova() - { - return $this->subscribe_service('http://www.podnova.com/index_your_podcasts.srf?action=add&url='); - } - - function subscribe_rojo() - { - return $this->subscribe_service('http://www.rojo.com/add-subscription?resource='); - } - - function subscribe_yahoo() - { - return $this->subscribe_service('http://add.my.yahoo.com/rss?url='); - } - - function get_feed_tags($namespace, $tag) - { - $type = $this->get_type(); - if ($type & SIMPLEPIE_TYPE_ATOM_10) - { - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag])) - { - return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag]; - } - } - if ($type & SIMPLEPIE_TYPE_ATOM_03) - { - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag])) - { - return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag]; - } - } - if ($type & SIMPLEPIE_TYPE_RSS_RDF) - { - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag])) - { - return $this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag]; - } - } - if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) - { - if (isset($this->data['child']['']['rss'][0]['child'][$namespace][$tag])) - { - return $this->data['child']['']['rss'][0]['child'][$namespace][$tag]; - } - } - return null; - } - - function get_channel_tags($namespace, $tag) - { - $type = $this->get_type(); - if ($type & SIMPLEPIE_TYPE_ATOM_ALL) - { - if ($return = $this->get_feed_tags($namespace, $tag)) - { - return $return; - } - } - if ($type & SIMPLEPIE_TYPE_RSS_10) - { - if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'channel')) - { - if (isset($channel[0]['child'][$namespace][$tag])) - { - return $channel[0]['child'][$namespace][$tag]; - } - } - } - if ($type & SIMPLEPIE_TYPE_RSS_090) - { - if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'channel')) - { - if (isset($channel[0]['child'][$namespace][$tag])) - { - return $channel[0]['child'][$namespace][$tag]; - } - } - } - if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) - { - if ($channel = $this->get_feed_tags('', 'channel')) - { - if (isset($channel[0]['child'][$namespace][$tag])) - { - return $channel[0]['child'][$namespace][$tag]; - } - } - } - return null; - } - - function get_image_tags($namespace, $tag) - { - $type = $this->get_type(); - if ($type & SIMPLEPIE_TYPE_RSS_10) - { - if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'image')) - { - if (isset($image[0]['child'][$namespace][$tag])) - { - return $image[0]['child'][$namespace][$tag]; - } - } - } - if ($type & SIMPLEPIE_TYPE_RSS_090) - { - if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'image')) - { - if (isset($image[0]['child'][$namespace][$tag])) - { - return $image[0]['child'][$namespace][$tag]; - } - } - } - if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) - { - if ($image = $this->get_channel_tags('', 'image')) - { - if (isset($image[0]['child'][$namespace][$tag])) - { - return $image[0]['child'][$namespace][$tag]; - } - } - } - return null; - } - - function get_base($element = array()) - { - if (!($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION) && !empty($element['xml_base_explicit']) && isset($element['xml_base'])) - { - return $element['xml_base']; - } - elseif ($this->get_link() !== null) - { - return $this->get_link(); - } - elseif (isset($this->data['headers']['content-location'])) - { - return SimplePie_Misc::absolutize_url($this->data['headers']['content-location'], $this->subscribe_url()); - } - else - { - return $this->subscribe_url(); - } - } - - function sanitize($data, $type, $base = '') - { - return $this->sanitize->sanitize($data, $type, $base); - } - - function get_title() - { - if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) - { - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); - } - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) - { - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); - } - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); - } - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); - } - elseif ($return = $this->get_channel_tags('', 'title')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); - } - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - return null; - } - } - - function get_link($key = 0, $rel = 'alternate') - { - $links = $this->get_links($rel); - if (isset($links[$key])) - { - return $links[$key]; - } - else - { - return null; - } - } - - /** - * Added for parity between the parent-level and the item/entry-level. - */ - function get_permalink() - { - return $this->get_link(0); - } - - function get_links($rel = 'alternate') - { - if (!isset($this->data['links'])) - { - $this->data['links'] = array(); - if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link')) - { - foreach ($links as $link) - { - if (isset($link['attribs']['']['href'])) - { - $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; - $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); - } - } - } - if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link')) - { - foreach ($links as $link) - { - if (isset($link['attribs']['']['href'])) - { - $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; - $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); - - } - } - } - if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) - { - $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); - } - if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) - { - $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); - } - if ($links = $this->get_channel_tags('', 'link')) - { - $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); - } - - $keys = array_keys($this->data['links']); - foreach ($keys as $key) - { - if (SimplePie_Misc::is_isegment_nz_nc($key)) - { - if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key])) - { - $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]); - $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]; - } - else - { - $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; - } - } - elseif (substr($key, 0, 41) == SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) - { - $this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; - } - $this->data['links'][$key] = array_unique($this->data['links'][$key]); - } - } - - if (isset($this->data['links'][$rel])) - { - return $this->data['links'][$rel]; - } - else - { - return null; - } - } - - function get_description() - { - if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle')) - { - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); - } - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline')) - { - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); - } - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); - } - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); - } - elseif ($return = $this->get_channel_tags('', 'description')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); - } - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); - } - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); - } - else - { - return null; - } - } - - function get_copyright() - { - if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) - { - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); - } - elseif ($return = $this->get_channel_tags('', 'copyright')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - return null; - } - } - - function get_language() - { - if ($return = $this->get_channel_tags('', 'language')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang'])) - { - return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang'])) - { - return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang'])) - { - return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif (isset($this->data['headers']['content-language'])) - { - return $this->sanitize($this->data['headers']['content-language'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - return null; - } - } - - function get_latitude() - { - if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) - { - return (float) $return[0]['data']; - } - elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match)) - { - return (float) $match[1]; - } - else - { - return null; - } - } - - function get_longitude() - { - if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) - { - return (float) $return[0]['data']; - } - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon')) - { - return (float) $return[0]['data']; - } - elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match)) - { - return (float) $match[2]; - } - else - { - return null; - } - } - - function get_image_title() - { - if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif ($return = $this->get_image_tags('', 'title')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - return null; - } - } - - function get_image_url() - { - if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image')) - { - return $this->sanitize($return[0]['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI); - } - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); - } - elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); - } - elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'url')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); - } - elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'url')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); - } - elseif ($return = $this->get_image_tags('', 'url')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); - } - else - { - return null; - } - } - - function get_image_link() - { - if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); - } - elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); - } - elseif ($return = $this->get_image_tags('', 'link')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); - } - else - { - return null; - } - } - - function get_image_width() - { - if ($return = $this->get_image_tags('', 'width')) - { - return round($return[0]['data']); - } - elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags('', 'url')) - { - return 88.0; - } - else - { - return null; - } - } - - function get_image_height() - { - if ($return = $this->get_image_tags('', 'height')) - { - return round($return[0]['data']); - } - elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags('', 'url')) - { - return 31.0; - } - else - { - return null; - } - } - - function get_item_quantity($max = 0) - { - $qty = count($this->get_items()); - if ($max == 0) - { - return $qty; - } - else - { - return ($qty > $max) ? $max : $qty; - } - } - - function get_item($key = 0) - { - $items = $this->get_items(); - if (isset($items[$key])) - { - return $items[$key]; - } - else - { - return null; - } - } - - function get_items($start = 0, $end = 0) - { - if (!empty($this->multifeed_objects)) - { - return SimplePie::merge_items($this->multifeed_objects, $start, $end); - } - elseif (!isset($this->data['items'])) - { - if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry')) - { - $keys = array_keys($items); - foreach ($keys as $key) - { - $this->data['items'][] =& new $this->item_class($this, $items[$key]); - } - } - if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry')) - { - $keys = array_keys($items); - foreach ($keys as $key) - { - $this->data['items'][] =& new $this->item_class($this, $items[$key]); - } - } - if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item')) - { - $keys = array_keys($items); - foreach ($keys as $key) - { - $this->data['items'][] =& new $this->item_class($this, $items[$key]); - } - } - if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item')) - { - $keys = array_keys($items); - foreach ($keys as $key) - { - $this->data['items'][] =& new $this->item_class($this, $items[$key]); - } - } - if ($items = $this->get_channel_tags('', 'item')) - { - $keys = array_keys($items); - foreach ($keys as $key) - { - $this->data['items'][] =& new $this->item_class($this, $items[$key]); - } - } - } - - if (!empty($this->data['items'])) - { - // If we want to order it by date, check if all items have a date, and then sort it - if ($this->order_by_date) - { - if (!isset($this->data['ordered_items'])) - { - $do_sort = true; - foreach ($this->data['items'] as $item) - { - if (!$item->get_date('U')) - { - $do_sort = false; - break; - } - } - $item = null; - $this->data['ordered_items'] = $this->data['items']; - if ($do_sort) - { - usort($this->data['ordered_items'], array(&$this, 'sort_items')); - } - } - $items = $this->data['ordered_items']; - } - else - { - $items = $this->data['items']; - } - - // Slice the data as desired - if ($end == 0) - { - return array_slice($items, $start); - } - else - { - return array_slice($items, $start, $end); - } - } - else - { - return array(); - } - } - - function sort_items($a, $b) - { - return $a->get_date('U') <= $b->get_date('U'); - } - - function merge_items($urls, $start = 0, $end = 0) - { - if (is_array($urls) && sizeof($urls) > 0) - { - $items = array(); - foreach ($urls as $arg) - { - if (SimplePie_Misc::is_a($arg, 'SimplePie')) - { - $items = array_merge($items, $arg->get_items()); - } - else - { - trigger_error('Arguments must be SimplePie objects', E_USER_WARNING); - } - } - - $do_sort = true; - foreach ($items as $item) - { - if (!$item->get_date('U')) - { - $do_sort = false; - break; - } - } - $item = null; - if ($do_sort) - { - usort($items, array('SimplePie', 'sort_items')); - } - - if ($end == 0) - { - return array_slice($items, $start); - } - else - { - return array_slice($items, $start, $end); - } - } - else - { - trigger_error('Cannot merge zero SimplePie objects', E_USER_WARNING); - return array(); - } - } -} - -class SimplePie_Item -{ - var $feed; - var $data = array(); - - function SimplePie_Item($feed, $data) - { - $this->feed = $feed; - $this->data = $data; - } - - function __toString() - { - return md5(serialize($this->data)); - } - - function get_item_tags($namespace, $tag) - { - if (isset($this->data['child'][$namespace][$tag])) - { - return $this->data['child'][$namespace][$tag]; - } - else - { - return null; - } - } - - function get_base($element = array()) - { - return $this->feed->get_base($element); - } - - function sanitize($data, $type, $base = '') - { - return $this->feed->sanitize($data, $type, $base); - } - - function get_feed() - { - return $this->feed; - } - - function get_id($hash = false) - { - if ($hash) - { - return $this->__toString(); - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'id')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'id')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif ($return = $this->get_item_tags('', 'guid')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'identifier')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'identifier')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif (($return = $this->get_permalink()) !== null) - { - return $return; - } - elseif (($return = $this->get_title()) !== null) - { - return $return; - } - else - { - return $this->__toString(); - } - } - - function get_title() - { - if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) - { - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) - { - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); - } - elseif ($return = $this->get_item_tags('', 'title')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - return null; - } - } - - function get_description($description_only = false) - { - if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary')) - { - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary')) - { - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); - } - elseif ($return = $this->get_item_tags('', 'description')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif (!$description_only) - { - return $this->get_content(true); - } - else - { - return null; - } - } - - function get_content($content_only = false) - { - if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content')) - { - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_content_construct_type($return[0]['attribs']), $this->get_base($return[0])); - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content')) - { - return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded')) - { - return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); - } - elseif (!$content_only) - { - return $this->get_description(true); - } - else - { - return null; - } - } - - function get_category($key = 0) - { - $categories = $this->get_categories(); - if (isset($categories[$key])) - { - return $categories[$key]; - } - else - { - return null; - } - } - - function get_categories() - { - $categories = array(); - - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) - { - $term = null; - $scheme = null; - $label = null; - if (isset($category['attribs']['']['term'])) - { - $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($category['attribs']['']['scheme'])) - { - $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($category['attribs']['']['label'])) - { - $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $categories[] =& new $this->feed->category_class($term, $scheme, $label); - } - foreach ((array) $this->get_item_tags('', 'category') as $category) - { - $categories[] =& new $this->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); - } - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) - { - $categories[] =& new $this->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); - } - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category) - { - $categories[] =& new $this->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); - } - - if (!empty($categories)) - { - return SimplePie_Misc::array_unique($categories); - } - else - { - return null; - } - } - - function get_author($key = 0) - { - $authors = $this->get_authors(); - if (isset($authors[$key])) - { - return $authors[$key]; - } - else - { - return null; - } - } - - /** - * @todo Atom inheritance (item author, source author, feed author) - */ - function get_authors() - { - $authors = array(); - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author) - { - $name = null; - $uri = null; - $email = null; - if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) - { - $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) - { - $uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); - } - if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) - { - $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if ($name !== null || $email !== null || $uri !== null) - { - $authors[] =& new $this->feed->author_class($name, $uri, $email); - } - } - if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author')) - { - $name = null; - $url = null; - $email = null; - if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) - { - $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) - { - $uri = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); - } - if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) - { - $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if ($name !== null || $email !== null || $uri !== null) - { - $authors[] =& new $this->feed->author_class($name, $url, $email); - } - } - if ($author = $this->get_item_tags('', 'author')) - { - $authors[] =& new $this->feed->author_class(null, null, $this->sanitize($author[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); - } - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author) - { - $authors[] =& new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); - } - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author) - { - $authors[] =& new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); - } - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author) - { - $authors[] =& new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); - } - - if (!empty($authors)) - { - return SimplePie_Misc::array_unique($authors); - } - else - { - return null; - } - } - - function get_date($date_format = 'j F Y, g:i a') - { - if (!isset($this->data['date'])) - { - if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'published')) - { - $this->data['date']['raw'] = $return[0]['data']; - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated')) - { - $this->data['date']['raw'] = $return[0]['data']; - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'issued')) - { - $this->data['date']['raw'] = $return[0]['data']; - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'created')) - { - $this->data['date']['raw'] = $return[0]['data']; - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'modified')) - { - $this->data['date']['raw'] = $return[0]['data']; - } - elseif ($return = $this->get_item_tags('', 'pubDate')) - { - $this->data['date']['raw'] = $return[0]['data']; - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'date')) - { - $this->data['date']['raw'] = $return[0]['data']; - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'date')) - { - $this->data['date']['raw'] = $return[0]['data']; - } - - if (!empty($this->data['date']['raw'])) - { - $this->data['date']['parsed'] = SimplePie_Misc::parse_date($this->data['date']['raw']); - } - else - { - $this->data['date'] = null; - } - } - if ($this->data['date']) - { - $date_format = (string) $date_format; - switch ($date_format) - { - case '': - return $this->sanitize($this->data['date']['raw'], SIMPLEPIE_CONSTRUCT_TEXT); - - case 'U': - return $this->data['date']['parsed']; - - default: - return date($date_format, $this->data['date']['parsed']); - } - } - else - { - return null; - } - } - - function get_local_date($date_format = '%c') - { - if (!$date_format) - { - return $this->sanitize($this->get_date(''), SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif (($date = $this->get_date('U')) !== null) - { - return strftime($date_format, $date); - } - else - { - return null; - } - } - - function get_permalink() - { - $link = $this->get_link(); - $enclosure = $this->get_enclosure(0); - if ($link !== null) - { - return $link; - } - elseif ($enclosure !== null) - { - return $enclosure->get_link(); - } - else - { - return null; - } - } - - function get_link($key = 0, $rel = 'alternate') - { - $links = $this->get_links($rel); - if ($links[$key] !== null) - { - return $links[$key]; - } - else - { - return null; - } - } - - function get_links($rel = 'alternate') - { - if (!isset($this->data['links'])) - { - $this->data['links'] = array(); - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link) - { - if (isset($link['attribs']['']['href'])) - { - $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; - $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); - - } - } - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link) - { - if (isset($link['attribs']['']['href'])) - { - $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; - $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); - } - } - if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) - { - $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); - } - if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) - { - $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); - } - if ($links = $this->get_item_tags('', 'link')) - { - $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); - } - if ($links = $this->get_item_tags('', 'guid')) - { - if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) == 'true') - { - $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); - } - } - - $keys = array_keys($this->data['links']); - foreach ($keys as $key) - { - if (SimplePie_Misc::is_isegment_nz_nc($key)) - { - if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key])) - { - $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]); - $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]; - } - else - { - $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; - } - } - elseif (substr($key, 0, 41) == SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) - { - $this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; - } - $this->data['links'][$key] = array_unique($this->data['links'][$key]); - } - } - if (isset($this->data['links'][$rel])) - { - return $this->data['links'][$rel]; - } - else - { - return null; - } - } - - /** - * @todo Add ability to prefer one type of content over another (in a media group). - */ - function get_enclosure($key = 0, $prefer = null) - { - $enclosures = $this->get_enclosures(); - if (isset($enclosures[$key])) - { - return $enclosures[$key]; - } - else - { - return null; - } - } - - /** - * Grabs all available enclosures (podcasts, etc.) - * - * Supports the RSS tag, as well as Media RSS and iTunes RSS. - * - * At this point, we're pretty much assuming that all enclosures for an item are the same content. Anything else is too complicated to properly support. - * - * @todo Add support for end-user defined sorting of enclosures by type/handler (so we can prefer the faster-loading FLV over MP4). - * @todo Add support for itunes: tags. These should be relatively simple compared to media:. - * @todo If an element exists at a level, but it's value is empty, we should fall back to the value from the parent (if it exists). - */ - function get_enclosures() - { - if (!isset($this->data['enclosures'])) - { - $this->data['enclosures'] = array(); - - // Elements - $captions_parent = null; - $categories_parent = null; - $copyrights_parent = null; - $credits_parent = null; - $description_parent = null; - $duration_parent = null; - $hashes_parent = null; - $keywords_parent = null; - $player_parent = null; - $ratings_parent = null; - $restrictions_parent = null; - $thumbnails_parent = null; - $title_parent = null; - - // Let's do the channel and item-level ones first, and just re-use them if we need to. - $parent = $this->get_feed(); - - // CAPTIONS - if ($captions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text')) - { - foreach ($captions as $caption) - { - $caption_type = null; - $caption_lang = null; - $caption_startTime = null; - $caption_endTime = null; - $caption_text = null; - if (isset($caption['attribs']['']['type'])) - { - $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['attribs']['']['lang'])) - { - $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['attribs']['']['start'])) - { - $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['attribs']['']['end'])) - { - $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['data'])) - { - $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $captions_parent[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); - } - } - elseif ($captions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text')) - { - foreach ($captions as $caption) - { - $caption_type = null; - $caption_lang = null; - $caption_startTime = null; - $caption_endTime = null; - $caption_text = null; - if (isset($caption['attribs']['']['type'])) - { - $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['attribs']['']['lang'])) - { - $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['attribs']['']['start'])) - { - $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['attribs']['']['end'])) - { - $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['data'])) - { - $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $captions_parent[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); - } - } - if (is_array($captions_parent)) - { - $captions_parent = array_values(SimplePie_Misc::array_unique($captions_parent)); - } - - // CATEGORIES - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category) - { - $term = null; - $scheme = null; - $label = null; - if (isset($category['data'])) - { - $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($category['attribs']['']['scheme'])) - { - $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $scheme = 'http://search.yahoo.com/mrss/category_schema'; - } - if (isset($category['attribs']['']['label'])) - { - $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $categories_parent[] =& new $this->feed->category_class($term, $scheme, $label); - } - foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category) - { - $term = null; - $scheme = null; - $label = null; - if (isset($category['data'])) - { - $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($category['attribs']['']['scheme'])) - { - $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $scheme = 'http://search.yahoo.com/mrss/category_schema'; - } - if (isset($category['attribs']['']['label'])) - { - $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $categories_parent[] =& new $this->feed->category_class($term, $scheme, $label); - } - foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'category') as $category) - { - $term = null; - $scheme = 'http://www.itunes.com/dtds/podcast-1.0.dtd'; - $label = null; - if (isset($category['attribs']['']['text'])) - { - $label = $this->sanitize($category['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $categories_parent[] =& new $this->feed->category_class($term, $scheme, $label); - - if (isset($category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'])) - { - foreach ((array) $category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'] as $subcategory) - { - if (isset($subcategory['attribs']['']['text'])) - { - $label = $this->sanitize($subcategory['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $categories_parent[] =& new $this->feed->category_class($term, $scheme, $label); - } - } - } - if (is_array($categories_parent)) - { - $categories_parent = array_values(SimplePie_Misc::array_unique($categories_parent)); - } - - // COPYRIGHT - if ($copyright = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright')) - { - $copyright_url = null; - $copyright_label = null; - if (isset($copyright[0]['attribs']['']['url'])) - { - $copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($copyright[0]['data'])) - { - $copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $copyrights_parent =& new $this->feed->copyright_class($copyright_url, $copyright_label); - } - elseif ($copyright = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright')) - { - $copyright_url = null; - $copyright_label = null; - if (isset($copyright[0]['attribs']['']['url'])) - { - $copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($copyright[0]['data'])) - { - $copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $copyrights_parent =& new $this->feed->copyright_class($copyright_url, $copyright_label); - } - - // CREDITS - if ($credits = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit')) - { - foreach ($credits as $credit) - { - $credit_role = null; - $credit_scheme = null; - $credit_name = null; - if (isset($credit['attribs']['']['role'])) - { - $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($credit['attribs']['']['scheme'])) - { - $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $credit_scheme = 'urn:ebu'; - } - if (isset($credit['data'])) - { - $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $credits_parent[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); - } - } - elseif ($credits = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit')) - { - foreach ($credits as $credit) - { - $credit_role = null; - $credit_scheme = null; - $credit_name = null; - if (isset($credit['attribs']['']['role'])) - { - $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($credit['attribs']['']['scheme'])) - { - $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $credit_scheme = 'urn:ebu'; - } - if (isset($credit['data'])) - { - $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $credits_parent[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); - } - } - if (is_array($credits_parent)) - { - $credits_parent = array_values(SimplePie_Misc::array_unique($credits_parent)); - } - - // DESCRIPTION - if ($description_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description')) - { - if (isset($description_parent[0]['data'])) - { - $description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - } - elseif ($description_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description')) - { - if (isset($description_parent[0]['data'])) - { - $description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - } - - // DURATION - if ($duration_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'duration')) - { - $seconds = null; - $minutes = null; - $hours = null; - if (isset($duration_parent[0]['data'])) - { - $temp = explode(':', $this->sanitize($duration_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); - if (sizeof($temp) > 0) - { - (int) $seconds = array_pop($temp); - } - if (sizeof($temp) > 0) - { - (int) $minutes = array_pop($temp); - $seconds += $minutes * 60; - } - if (sizeof($temp) > 0) - { - (int) $hours = array_pop($temp); - $seconds += $hours * 3600; - } - unset($temp); - $duration_parent = $seconds; - } - } - - // HASHES - if ($hashes_iterator = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash')) - { - foreach ($hashes_iterator as $hash) - { - $value = null; - $algo = null; - if (isset($hash['data'])) - { - $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($hash['attribs']['']['algo'])) - { - $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $algo = 'md5'; - } - $hashes_parent[] = $algo.':'.$value; - } - } - elseif ($hashes_iterator = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash')) - { - foreach ($hashes_iterator as $hash) - { - $value = null; - $algo = null; - if (isset($hash['data'])) - { - $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($hash['attribs']['']['algo'])) - { - $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $algo = 'md5'; - } - $hashes_parent[] = $algo.':'.$value; - } - } - if (is_array($hashes_parent)) - { - $hashes_parent = array_values(SimplePie_Misc::array_unique($hashes_parent)); - } - - // KEYWORDS - if ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords')) - { - if (isset($keywords[0]['data'])) - { - $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); - foreach ($temp as $word) - { - $keywords_parent[] = trim($word); - } - } - unset($temp); - } - elseif ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords')) - { - if (isset($keywords[0]['data'])) - { - $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); - foreach ($temp as $word) - { - $keywords_parent[] = trim($word); - } - } - unset($temp); - } - elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords')) - { - if (isset($keywords[0]['data'])) - { - $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); - foreach ($temp as $word) - { - $keywords_parent[] = trim($word); - } - } - unset($temp); - } - elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords')) - { - if (isset($keywords[0]['data'])) - { - $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); - foreach ($temp as $word) - { - $keywords_parent[] = trim($word); - } - } - unset($temp); - } - if (is_array($keywords_parent)) - { - $keywords_parent = array_values(SimplePie_Misc::array_unique($keywords_parent)); - } - - // PLAYER - if ($player_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player')) - { - if (isset($player_parent[0]['attribs']['']['url'])) - { - $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); - } - } - elseif ($player_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player')) - { - if (isset($player_parent[0]['attribs']['']['url'])) - { - $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); - } - } - - // RATINGS - if ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating')) - { - foreach ($ratings as $rating) - { - $rating_scheme = null; - $rating_value = null; - if (isset($rating['attribs']['']['scheme'])) - { - $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $rating_scheme = 'urn:simple'; - } - if (isset($rating['data'])) - { - $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $ratings_parent[] =& new $this->feed->rating_class($rating_scheme, $rating_value); - } - } - elseif ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit')) - { - foreach ($ratings as $rating) - { - $rating_scheme = 'urn:itunes'; - $rating_value = null; - if (isset($rating['data'])) - { - $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $ratings_parent[] =& new $this->feed->rating_class($rating_scheme, $rating_value); - } - } - elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating')) - { - foreach ($ratings as $rating) - { - $rating_scheme = null; - $rating_value = null; - if (isset($rating['attribs']['']['scheme'])) - { - $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $rating_scheme = 'urn:simple'; - } - if (isset($rating['data'])) - { - $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $ratings_parent[] =& new $this->feed->rating_class($rating_scheme, $rating_value); - } - } - elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit')) - { - foreach ($ratings as $rating) - { - $rating_scheme = 'urn:itunes'; - $rating_value = null; - if (isset($rating['data'])) - { - $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $ratings_parent[] =& new $this->feed->rating_class($rating_scheme, $rating_value); - } - } - if (is_array($ratings_parent)) - { - $ratings_parent = array_values(SimplePie_Misc::array_unique($ratings_parent)); - } - - // RESTRICTIONS - if ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction')) - { - foreach ($restrictions as $restriction) - { - $restriction_relationship = null; - $restriction_type = null; - $restriction_value = null; - if (isset($restriction['attribs']['']['relationship'])) - { - $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($restriction['attribs']['']['type'])) - { - $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($restriction['data'])) - { - $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $restrictions_parent[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); - } - } - elseif ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block')) - { - foreach ($restrictions as $restriction) - { - $restriction_relationship = 'allow'; - $restriction_type = null; - $restriction_value = 'itunes'; - if (isset($restriction['data']) && strtolower($restriction['data']) == 'yes') - { - $restriction_relationship = 'deny'; - } - $restrictions_parent[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); - } - } - elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction')) - { - foreach ($restrictions as $restriction) - { - $restriction_relationship = null; - $restriction_type = null; - $restriction_value = null; - if (isset($restriction['attribs']['']['relationship'])) - { - $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($restriction['attribs']['']['type'])) - { - $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($restriction['data'])) - { - $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $restrictions_parent[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); - } - } - elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block')) - { - foreach ($restrictions as $restriction) - { - $restriction_relationship = 'allow'; - $restriction_type = null; - $restriction_value = 'itunes'; - if (isset($restriction['data']) && strtolower($restriction['data']) == 'yes') - { - $restriction_relationship = 'deny'; - } - $restrictions_parent[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); - } - } - if (is_array($restrictions_parent)) - { - $restrictions_parent = array_values(SimplePie_Misc::array_unique($restrictions_parent)); - } - - // THUMBNAILS - if ($thumbnails = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail')) - { - foreach ($thumbnails as $thumbnail) - { - if (isset($thumbnail['attribs']['']['url'])) - { - $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); - } - } - } - elseif ($thumbnails = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail')) - { - foreach ($thumbnails as $thumbnail) - { - if (isset($thumbnail['attribs']['']['url'])) - { - $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); - } - } - } - - // TITLES - if ($title_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title')) - { - if (isset($title_parent[0]['data'])) - { - $title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - } - elseif ($title_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title')) - { - if (isset($title_parent[0]['data'])) - { - $title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - } - - // Clear the memory - unset($parent); - - // If we have media:group tags, loop through them. - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group') as $group) - { - // If we have media:content tags, loop through them. - foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content) - { - if (isset($content['attribs']['']['url'])) - { - // Attributes - $bitrate = null; - $channels = null; - $duration = null; - $expression = null; - $framerate = null; - $height = null; - $javascript = null; - $lang = null; - $length = null; - $medium = null; - $samplingrate = null; - $type = null; - $url = null; - $width = null; - - // Elements - $captions = null; - $categories = null; - $copyrights = null; - $credits = null; - $description = null; - $hashes = null; - $keywords = null; - $player = null; - $ratings = null; - $restrictions = null; - $thumbnails = null; - $title = null; - - // Start checking the attributes of media:content - if (isset($content['attribs']['']['bitrate'])) - { - $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['channels'])) - { - $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['duration'])) - { - $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $duration = $duration_parent; - } - if (isset($content['attribs']['']['expression'])) - { - $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['framerate'])) - { - $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['height'])) - { - $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['lang'])) - { - $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['fileSize'])) - { - $length = ceil($content['attribs']['']['fileSize']); - } - if (isset($content['attribs']['']['medium'])) - { - $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['samplingrate'])) - { - $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['type'])) - { - $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['width'])) - { - $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); - - // Checking the other optional media: elements. Priority: media:content, media:group, item, channel - - // CAPTIONS - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) - { - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) - { - $caption_type = null; - $caption_lang = null; - $caption_startTime = null; - $caption_endTime = null; - $caption_text = null; - if (isset($caption['attribs']['']['type'])) - { - $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['attribs']['']['lang'])) - { - $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['attribs']['']['start'])) - { - $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['attribs']['']['end'])) - { - $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['data'])) - { - $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); - } - if (is_array($captions)) - { - $captions = array_values(SimplePie_Misc::array_unique($captions)); - } - } - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) - { - foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) - { - $caption_type = null; - $caption_lang = null; - $caption_startTime = null; - $caption_endTime = null; - $caption_text = null; - if (isset($caption['attribs']['']['type'])) - { - $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['attribs']['']['lang'])) - { - $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['attribs']['']['start'])) - { - $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['attribs']['']['end'])) - { - $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['data'])) - { - $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); - } - if (is_array($captions)) - { - $captions = array_values(SimplePie_Misc::array_unique($captions)); - } - } - else - { - $captions = $captions_parent; - } - - // CATEGORIES - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) - { - foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) - { - $term = null; - $scheme = null; - $label = null; - if (isset($category['data'])) - { - $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($category['attribs']['']['scheme'])) - { - $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $scheme = 'http://search.yahoo.com/mrss/category_schema'; - } - if (isset($category['attribs']['']['label'])) - { - $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $categories[] =& new $this->feed->category_class($term, $scheme, $label); - } - } - if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) - { - foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) - { - $term = null; - $scheme = null; - $label = null; - if (isset($category['data'])) - { - $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($category['attribs']['']['scheme'])) - { - $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $scheme = 'http://search.yahoo.com/mrss/category_schema'; - } - if (isset($category['attribs']['']['label'])) - { - $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $categories[] =& new $this->feed->category_class($term, $scheme, $label); - } - } - if (is_array($categories) && is_array($categories_parent)) - { - $categories = array_values(SimplePie_Misc::array_unique(array_merge($categories, $categories_parent))); - } - elseif (is_array($categories)) - { - $categories = array_values(SimplePie_Misc::array_unique($categories)); - } - elseif (is_array($categories_parent)) - { - $categories = array_values(SimplePie_Misc::array_unique($categories_parent)); - } - - // COPYRIGHTS - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) - { - $copyright_url = null; - $copyright_label = null; - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) - { - $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) - { - $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label); - } - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) - { - $copyright_url = null; - $copyright_label = null; - if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) - { - $copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) - { - $copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label); - } - else - { - $copyrights = $copyrights_parent; - } - - // CREDITS - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) - { - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) - { - $credit_role = null; - $credit_scheme = null; - $credit_name = null; - if (isset($credit['attribs']['']['role'])) - { - $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($credit['attribs']['']['scheme'])) - { - $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $credit_scheme = 'urn:ebu'; - } - if (isset($credit['data'])) - { - $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); - } - if (is_array($credits)) - { - $credits = array_values(SimplePie_Misc::array_unique($credits)); - } - } - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) - { - foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) - { - $credit_role = null; - $credit_scheme = null; - $credit_name = null; - if (isset($credit['attribs']['']['role'])) - { - $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($credit['attribs']['']['scheme'])) - { - $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $credit_scheme = 'urn:ebu'; - } - if (isset($credit['data'])) - { - $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); - } - if (is_array($credits)) - { - $credits = array_values(SimplePie_Misc::array_unique($credits)); - } - } - else - { - $credits = $credits_parent; - } - - // DESCRIPTION - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) - { - $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) - { - $description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $description = $description_parent; - } - - // HASHES - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) - { - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) - { - $value = null; - $algo = null; - if (isset($hash['data'])) - { - $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($hash['attribs']['']['algo'])) - { - $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $algo = 'md5'; - } - $hashes[] = $algo.':'.$value; - } - if (is_array($hashes)) - { - $hashes = array_values(SimplePie_Misc::array_unique($hashes)); - } - } - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) - { - foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) - { - $value = null; - $algo = null; - if (isset($hash['data'])) - { - $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($hash['attribs']['']['algo'])) - { - $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $algo = 'md5'; - } - $hashes[] = $algo.':'.$value; - } - if (is_array($hashes)) - { - $hashes = array_values(SimplePie_Misc::array_unique($hashes)); - } - } - else - { - $hashes = $hashes_parent; - } - - // KEYWORDS - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) - { - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) - { - $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); - foreach ($temp as $word) - { - $keywords[] = trim($word); - } - unset($temp); - } - if (is_array($keywords)) - { - $keywords = array_values(SimplePie_Misc::array_unique($keywords)); - } - } - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) - { - if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) - { - $temp = explode(',', $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); - foreach ($temp as $word) - { - $keywords[] = trim($word); - } - unset($temp); - } - if (is_array($keywords)) - { - $keywords = array_values(SimplePie_Misc::array_unique($keywords)); - } - } - else - { - $keywords = $keywords_parent; - } - - // PLAYER - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) - { - $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); - } - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) - { - $player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); - } - else - { - $player = $player_parent; - } - - // RATINGS - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) - { - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) - { - $rating_scheme = null; - $rating_value = null; - if (isset($rating['attribs']['']['scheme'])) - { - $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $rating_scheme = 'urn:simple'; - } - if (isset($rating['data'])) - { - $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value); - } - if (is_array($ratings)) - { - $ratings = array_values(SimplePie_Misc::array_unique($ratings)); - } - } - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) - { - foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) - { - $rating_scheme = null; - $rating_value = null; - if (isset($rating['attribs']['']['scheme'])) - { - $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $rating_scheme = 'urn:simple'; - } - if (isset($rating['data'])) - { - $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value); - } - if (is_array($ratings)) - { - $ratings = array_values(SimplePie_Misc::array_unique($ratings)); - } - } - else - { - $ratings = $ratings_parent; - } - - // RESTRICTIONS - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) - { - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) - { - $restriction_relationship = null; - $restriction_type = null; - $restriction_value = null; - if (isset($restriction['attribs']['']['relationship'])) - { - $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($restriction['attribs']['']['type'])) - { - $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($restriction['data'])) - { - $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); - } - if (is_array($restrictions)) - { - $restrictions = array_values(SimplePie_Misc::array_unique($restrictions)); - } - } - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) - { - foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) - { - $restriction_relationship = null; - $restriction_type = null; - $restriction_value = null; - if (isset($restriction['attribs']['']['relationship'])) - { - $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($restriction['attribs']['']['type'])) - { - $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($restriction['data'])) - { - $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); - } - if (is_array($restrictions)) - { - $restrictions = array_values(SimplePie_Misc::array_unique($restrictions)); - } - } - else - { - $restrictions = $restrictions_parent; - } - - // THUMBNAILS - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) - { - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) - { - $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); - } - if (is_array($thumbnails)) - { - $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails)); - } - } - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) - { - foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) - { - $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); - } - if (is_array($thumbnails)) - { - $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails)); - } - } - else - { - $thumbnails = $thumbnails_parent; - } - - // TITLES - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) - { - $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) - { - $title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $title = $title_parent; - } - - $this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width); - } - } - } - - // If we have standalone media:content tags, loop through them. - if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'])) - { - foreach ((array) $this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content) - { - if (isset($content['attribs']['']['url'])) - { - // Attributes - $bitrate = null; - $channels = null; - $duration = null; - $expression = null; - $framerate = null; - $height = null; - $javascript = null; - $lang = null; - $length = null; - $medium = null; - $samplingrate = null; - $type = null; - $url = null; - $width = null; - - // Elements - $captions = null; - $categories = null; - $copyrights = null; - $credits = null; - $description = null; - $hashes = null; - $keywords = null; - $player = null; - $ratings = null; - $restrictions = null; - $thumbnails = null; - $title = null; - - // Start checking the attributes of media:content - if (isset($content['attribs']['']['bitrate'])) - { - $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['channels'])) - { - $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['duration'])) - { - $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $duration = $duration_parent; - } - if (isset($content['attribs']['']['expression'])) - { - $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['framerate'])) - { - $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['height'])) - { - $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['lang'])) - { - $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['fileSize'])) - { - $length = ceil($content['attribs']['']['fileSize']); - } - if (isset($content['attribs']['']['medium'])) - { - $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['samplingrate'])) - { - $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['type'])) - { - $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['attribs']['']['width'])) - { - $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); - - // Checking the other optional media: elements. Priority: media:content, media:group, item, channel - - // CAPTIONS - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) - { - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) - { - $caption_type = null; - $caption_lang = null; - $caption_startTime = null; - $caption_endTime = null; - $caption_text = null; - if (isset($caption['attribs']['']['type'])) - { - $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['attribs']['']['lang'])) - { - $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['attribs']['']['start'])) - { - $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['attribs']['']['end'])) - { - $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($caption['data'])) - { - $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); - } - if (is_array($captions)) - { - $captions = array_values(SimplePie_Misc::array_unique($captions)); - } - } - else - { - $captions = $captions_parent; - } - - // CATEGORIES - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) - { - foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) - { - $term = null; - $scheme = null; - $label = null; - if (isset($category['data'])) - { - $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($category['attribs']['']['scheme'])) - { - $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $scheme = 'http://search.yahoo.com/mrss/category_schema'; - } - if (isset($category['attribs']['']['label'])) - { - $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $categories[] =& new $this->feed->category_class($term, $scheme, $label); - } - } - if (is_array($categories) && is_array($categories_parent)) - { - $categories = array_values(SimplePie_Misc::array_unique(array_merge($categories, $categories_parent))); - } - elseif (is_array($categories)) - { - $categories = array_values(SimplePie_Misc::array_unique($categories)); - } - elseif (is_array($categories_parent)) - { - $categories = array_values(SimplePie_Misc::array_unique($categories_parent)); - } - else - { - $categories = null; - } - - // COPYRIGHTS - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) - { - $copyright_url = null; - $copyright_label = null; - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) - { - $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) - { - $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label); - } - else - { - $copyrights = $copyrights_parent; - } - - // CREDITS - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) - { - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) - { - $credit_role = null; - $credit_scheme = null; - $credit_name = null; - if (isset($credit['attribs']['']['role'])) - { - $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($credit['attribs']['']['scheme'])) - { - $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $credit_scheme = 'urn:ebu'; - } - if (isset($credit['data'])) - { - $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); - } - if (is_array($credits)) - { - $credits = array_values(SimplePie_Misc::array_unique($credits)); - } - } - else - { - $credits = $credits_parent; - } - - // DESCRIPTION - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) - { - $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $description = $description_parent; - } - - // HASHES - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) - { - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) - { - $value = null; - $algo = null; - if (isset($hash['data'])) - { - $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($hash['attribs']['']['algo'])) - { - $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $algo = 'md5'; - } - $hashes[] = $algo.':'.$value; - } - if (is_array($hashes)) - { - $hashes = array_values(SimplePie_Misc::array_unique($hashes)); - } - } - else - { - $hashes = $hashes_parent; - } - - // KEYWORDS - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) - { - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) - { - $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); - foreach ($temp as $word) - { - $keywords[] = trim($word); - } - unset($temp); - } - if (is_array($keywords)) - { - $keywords = array_values(SimplePie_Misc::array_unique($keywords)); - } - } - else - { - $keywords = $keywords_parent; - } - - // PLAYER - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) - { - $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); - } - else - { - $player = $player_parent; - } - - // RATINGS - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) - { - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) - { - $rating_scheme = null; - $rating_value = null; - if (isset($rating['attribs']['']['scheme'])) - { - $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $rating_scheme = 'urn:simple'; - } - if (isset($rating['data'])) - { - $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value); - } - if (is_array($ratings)) - { - $ratings = array_values(SimplePie_Misc::array_unique($ratings)); - } - } - else - { - $ratings = $ratings_parent; - } - - // RESTRICTIONS - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) - { - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) - { - $restriction_relationship = null; - $restriction_type = null; - $restriction_value = null; - if (isset($restriction['attribs']['']['relationship'])) - { - $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($restriction['attribs']['']['type'])) - { - $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($restriction['data'])) - { - $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - $restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); - } - if (is_array($restrictions)) - { - $restrictions = array_values(SimplePie_Misc::array_unique($restrictions)); - } - } - else - { - $restrictions = $restrictions_parent; - } - - // THUMBNAILS - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) - { - foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) - { - $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); - } - if (is_array($thumbnails)) - { - $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails)); - } - } - else - { - $thumbnails = $thumbnails_parent; - } - - // TITLES - if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) - { - $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); - } - else - { - $title = $title_parent; - } - - $this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width); - } - } - } - - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link) - { - if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] == 'enclosure') - { - // Attributes - $bitrate = null; - $channels = null; - $duration = null; - $expression = null; - $framerate = null; - $height = null; - $javascript = null; - $lang = null; - $length = null; - $medium = null; - $samplingrate = null; - $type = null; - $url = null; - $width = null; - - $url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); - if (isset($link['attribs']['']['type'])) - { - $type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($link['attribs']['']['length'])) - { - $length = ceil($link['attribs']['']['length']); - } - - // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor - $this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width); - } - } - - foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link) - { - if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] == 'enclosure') - { - // Attributes - $bitrate = null; - $channels = null; - $duration = null; - $expression = null; - $framerate = null; - $height = null; - $javascript = null; - $lang = null; - $length = null; - $medium = null; - $samplingrate = null; - $type = null; - $url = null; - $width = null; - - $url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); - if (isset($link['attribs']['']['type'])) - { - $type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($link['attribs']['']['length'])) - { - $length = ceil($link['attribs']['']['length']); - } - - // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor - $this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width); - } - } - - if ($enclosure = $this->get_item_tags('', 'enclosure')) - { - if (isset($enclosure[0]['attribs']['']['url'])) - { - // Attributes - $bitrate = null; - $channels = null; - $duration = null; - $expression = null; - $framerate = null; - $height = null; - $javascript = null; - $lang = null; - $length = null; - $medium = null; - $samplingrate = null; - $type = null; - $url = null; - $width = null; - - $url = $this->sanitize($enclosure[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($enclosure[0])); - if (isset($enclosure[0]['attribs']['']['type'])) - { - $type = $this->sanitize($enclosure[0]['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); - } - if (isset($enclosure[0]['attribs']['']['length'])) - { - $length = ceil($enclosure[0]['attribs']['']['length']); - } - - // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor - $this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width); - } - } - $this->data['enclosures'] = array_values(SimplePie_Misc::array_unique($this->data['enclosures'])); - } - if (!empty($this->data['enclosures'])) - { - return $this->data['enclosures']; - } - else - { - return null; - } - } - - function get_latitude() - { - if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) - { - return (float) $return[0]['data']; - } - elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match)) - { - return (float) $match[1]; - } - else - { - return null; - } - } - - function get_longitude() - { - if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) - { - return (float) $return[0]['data']; - } - elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon')) - { - return (float) $return[0]['data']; - } - elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match)) - { - return (float) $match[2]; - } - else - { - return null; - } - } - - /** - * Creates the add_to_* methods' return data - * - * @access private - * @param string $item_url String to prefix to the item permalink - * @param string $title_url String to prefix to the item title - * (and suffix to the item permalink) - * @return mixed URL if feed exists, false otherwise - */ - function add_to_service($item_url, $title_url = null) - { - if ($this->get_permalink() !== null) - { - $return = $this->sanitize($item_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_permalink()); - if ($title_url !== null && $this->get_title() !== null) - { - $return .= $this->sanitize($title_url, SIMPLEPIE_CONSTRUCT_IRI) . rawurlencode($this->get_title()); - } - return $return; - } - else - { - return null; - } - } - - function add_to_blinklist() - { - return $this->add_to_service('http://www.blinklist.com/index.php?Action=Blink/addblink.php&Description=&Url=', '&Title='); - } - - function add_to_blogmarks() - { - return $this->add_to_service('http://blogmarks.net/my/new.php?mini=1&simple=1&url=', '&title='); - } - - function add_to_delicious() - { - return $this->add_to_service('http://del.icio.us/post/?v=3&url=', '&title='); - } - - function add_to_digg() - { - return $this->add_to_service('http://digg.com/submit?phase=2&URL='); - } - - function add_to_furl() - { - return $this->add_to_service('http://www.furl.net/storeIt.jsp?u=', '&t='); - } - - function add_to_magnolia() - { - return $this->add_to_service('http://ma.gnolia.com/bookmarklet/add?url=', '&title='); - } - - function add_to_myweb20() - { - return $this->add_to_service('http://myweb2.search.yahoo.com/myresults/bookmarklet?u=', '&t='); - } - - function add_to_newsvine() - { - return $this->add_to_service('http://www.newsvine.com/_wine/save?u=', '&h='); - } - - function add_to_reddit() - { - return $this->add_to_service('http://reddit.com/submit?url=', '&title='); - } - - function add_to_segnalo() - { - return $this->add_to_service('http://segnalo.com/post.html.php?url=', '&title='); - } - - function add_to_simpy() - { - return $this->add_to_service('http://www.simpy.com/simpy/LinkAdd.do?href=', '&title='); - } - - function add_to_spurl() - { - return $this->add_to_service('http://www.spurl.net/spurl.php?v=3&url=', '&title='); - } - - function add_to_wists() - { - return $this->add_to_service('http://wists.com/r.php?c=&r=', '&title='); - } - - function search_technorati() - { - return $this->add_to_service('http://www.technorati.com/search/'); - } -} - -class SimplePie_Author -{ - var $name; - var $link; - var $email; - - // Constructor, used to input the data - function SimplePie_Author($name = null, $link = null, $email = null) - { - $this->name = $name; - $this->link = $link; - $this->email = $email; - } - - function __toString() - { - // There is no $this->data here - return md5(serialize($this)); - } - - function get_name() - { - if ($this->name !== null) - { - return $this->name; - } - else - { - return null; - } - } - - function get_link() - { - if ($this->link !== null) - { - return $this->link; - } - else - { - return null; - } - } - - function get_email() - { - if ($this->email !== null) - { - return $this->email; - } - else - { - return null; - } - } -} - -class SimplePie_Category -{ - var $term; - var $scheme; - var $label; - - // Constructor, used to input the data - function SimplePie_Category($term = null, $scheme = null, $label = null) - { - $this->term = $term; - $this->scheme = $scheme; - $this->label = $label; - } - - function __toString() - { - // There is no $this->data here - return md5(serialize($this)); - } - - function get_term() - { - if ($this->term !== null) - { - return $this->term; - } - else - { - return null; - } - } - - function get_scheme() - { - if ($this->scheme !== null) - { - return $this->scheme; - } - else - { - return null; - } - } - - function get_label() - { - if ($this->label !== null) - { - return $this->label; - } - else - { - return $this->get_term(); - } - } -} - -class SimplePie_Enclosure -{ - var $bitrate; - var $captions; - var $categories; - var $channels; - var $copyright; - var $credits; - var $description; - var $duration; - var $expression; - var $framerate; - var $handler; - var $hashes; - var $height; - var $javascript; - var $keywords; - var $lang; - var $length; - var $link; - var $medium; - var $player; - var $ratings; - var $restrictions; - var $samplingrate; - var $thumbnails; - var $title; - var $type; - var $width; - - // Constructor, used to input the data - function SimplePie_Enclosure($link = null, $type = null, $length = null, $javascript = null, $bitrate = null, $captions = null, $categories = null, $channels = null, $copyright = null, $credits = null, $description = null, $duration = null, $expression = null, $framerate = null, $hashes = null, $height = null, $keywords = null, $lang = null, $medium = null, $player = null, $ratings = null, $restrictions = null, $samplingrate = null, $thumbnails = null, $title = null, $width = null) - { - $this->bitrate = $bitrate; - $this->captions = $captions; - $this->categories = $categories; - $this->channels = $channels; - $this->copyright = $copyright; - $this->credits = $credits; - $this->description = $description; - $this->duration = $duration; - $this->expression = $expression; - $this->framerate = $framerate; - $this->hashes = $hashes; - $this->height = $height; - $this->javascript = $javascript; - $this->keywords = $keywords; - $this->lang = $lang; - $this->length = $length; - $this->link = $link; - $this->medium = $medium; - $this->player = $player; - $this->ratings = $ratings; - $this->restrictions = $restrictions; - $this->samplingrate = $samplingrate; - $this->thumbnails = $thumbnails; - $this->title = $title; - $this->type = $type; - $this->width = $width; - if (class_exists('idna_convert')) - { - $idn =& new idna_convert; - $parsed = SimplePie_Misc::parse_url($link); - $this->link = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']); - } - $this->handler = $this->get_handler(); // Needs to load last - } - - function __toString() - { - // There is no $this->data here - return md5(serialize($this)); - } - - function get_bitrate() - { - if ($this->bitrate !== null) - { - return $this->bitrate; - } - else - { - return null; - } - } - - function get_caption($key = 0) - { - $captions = $this->get_captions(); - if (isset($captions[$key])) - { - return $captions[$key]; - } - else - { - return null; - } - } - - function get_captions() - { - if ($this->captions !== null) - { - return $this->captions; - } - else - { - return null; - } - } - - function get_category($key = 0) - { - $categories = $this->get_categories(); - if (isset($categories[$key])) - { - return $categories[$key]; - } - else - { - return null; - } - } - - function get_categories() - { - if ($this->categories !== null) - { - return $this->categories; - } - else - { - return null; - } - } - - function get_channels() - { - if ($this->channels !== null) - { - return $this->channels; - } - else - { - return null; - } - } - - function get_copyright() - { - if ($this->copyright !== null) - { - return $this->copyright; - } - else - { - return null; - } - } - - function get_credit($key = 0) - { - $credits = $this->get_credits(); - if (isset($credits[$key])) - { - return $credits[$key]; - } - else - { - return null; - } - } - - function get_credits() - { - if ($this->credits !== null) - { - return $this->credits; - } - else - { - return null; - } - } - - function get_description() - { - if ($this->description !== null) - { - return $this->description; - } - else - { - return null; - } - } - - function get_duration($convert = false) - { - if ($this->duration !== null) - { - if ($convert) - { - $time = SimplePie_Misc::time_hms($this->duration); - return $time; - } - else - { - return $this->duration; - } - } - else - { - return null; - } - } - - function get_expression() - { - if ($this->expression !== null) - { - return $this->expression; - } - else - { - return 'full'; - } - } - - function get_extension() - { - if ($this->link !== null) - { - $url = SimplePie_Misc::parse_url($this->link); - if ($url['path'] !== '') - { - return pathinfo($url['path'], PATHINFO_EXTENSION); - } - } - return null; - } - - function get_framerate() - { - if ($this->framerate !== null) - { - return $this->framerate; - } - else - { - return null; - } - } - - function get_handler() - { - return $this->get_real_type(true); - } - - function get_hash($key = 0) - { - $hashes = $this->get_hashes(); - if (isset($hashes[$key])) - { - return $hashes[$key]; - } - else - { - return null; - } - } - - function get_hashes() - { - if ($this->hashes !== null) - { - return $this->hashes; - } - else - { - return null; - } - } - - function get_height() - { - if ($this->height !== null) - { - return $this->height; - } - else - { - return null; - } - } - - function get_language() - { - if ($this->lang !== null) - { - return $this->lang; - } - else - { - return null; - } - } - - function get_keyword($key = 0) - { - $keywords = $this->get_keywords(); - if (isset($keywords[$key])) - { - return $keywords[$key]; - } - else - { - return null; - } - } - - function get_keywords() - { - if ($this->keywords !== null) - { - return $this->keywords; - } - else - { - return null; - } - } - - function get_length() - { - if ($this->length !== null) - { - return $this->length; - } - else - { - return null; - } - } - - function get_link() - { - if ($this->link !== null) - { - return urldecode($this->link); - } - else - { - return null; - } - } - - function get_medium() - { - if ($this->medium !== null) - { - return $this->medium; - } - else - { - return null; - } - } - - function get_player() - { - if ($this->player !== null) - { - return $this->player; - } - else - { - return null; - } - } - - function get_rating($key = 0) - { - $ratings = $this->get_ratings(); - if (isset($ratings[$key])) - { - return $ratings[$key]; - } - else - { - return null; - } - } - - function get_ratings() - { - if ($this->ratings !== null) - { - return $this->ratings; - } - else - { - return null; - } - } - - function get_restriction($key = 0) - { - $restrictions = $this->get_restrictions(); - if (isset($restrictions[$key])) - { - return $restrictions[$key]; - } - else - { - return null; - } - } - - function get_restrictions() - { - if ($this->restrictions !== null) - { - return $this->restrictions; - } - else - { - return null; - } - } - - function get_sampling_rate() - { - if ($this->samplingrate !== null) - { - return $this->samplingrate; - } - else - { - return null; - } - } - - function get_size() - { - $length = $this->get_length(); - if ($length !== null) - { - return round($length/1048576, 2); - } - else - { - return null; - } - } - - function get_thumbnail($key = 0) - { - $thumbnails = $this->get_thumbnails(); - if (isset($thumbnails[$key])) - { - return $thumbnails[$key]; - } - else - { - return null; - } - } - - function get_thumbnails() - { - if ($this->thumbnails !== null) - { - return $this->thumbnails; - } - else - { - return null; - } - } - - function get_title() - { - if ($this->title !== null) - { - return $this->title; - } - else - { - return null; - } - } - - function get_type() - { - if ($this->type !== null) - { - return $this->type; - } - else - { - return null; - } - } - - function get_width() - { - if ($this->width !== null) - { - return $this->width; - } - else - { - return null; - } - } - - function native_embed($options='') - { - return $this->embed($options, true); - } - - /** - * @todo If the dimensions for media:content are defined, use them when width/height are set to 'auto'. - */ - function embed($options = '', $native = false) - { - // Set up defaults - $audio = ''; - $video = ''; - $alt = ''; - $altclass = ''; - $loop = 'false'; - $width = 'auto'; - $height = 'auto'; - $bgcolor = '#ffffff'; - $mediaplayer = ''; - $widescreen = false; - $handler = $this->get_handler(); - $type = $this->get_real_type(); - - // Process options and reassign values as necessary - if (is_array($options)) - { - extract($options); - } - else - { - $options = explode(',', $options); - foreach($options as $option) - { - $opt = explode(':', $option, 2); - if (isset($opt[0], $opt[1])) - { - $opt[0] = trim($opt[0]); - $opt[1] = trim($opt[1]); - switch ($opt[0]) - { - case 'audio': - $audio = $opt[1]; - break; - - case 'video': - $video = $opt[1]; - break; - - case 'alt': - $alt = $opt[1]; - break; - - case 'altclass': - $altclass = $opt[1]; - break; - - case 'loop': - $loop = $opt[1]; - break; - - case 'width': - $width = $opt[1]; - break; - - case 'height': - $height = $opt[1]; - break; - - case 'bgcolor': - $bgcolor = $opt[1]; - break; - - case 'mediaplayer': - $mediaplayer = $opt[1]; - break; - - case 'widescreen': - $widescreen = $opt[1]; - break; - } - } - } - } - - $mime = explode('/', $type, 2); - $mime = $mime[0]; - - // Process values for 'auto' - if ($width == 'auto') - { - if ($mime == 'video') - { - if ($height == 'auto') - { - $width = 480; - } - elseif ($widescreen) - { - $width = round((intval($height)/9)*16); - } - else - { - $width = round((intval($height)/3)*4); - } - } - else - { - $width = '100%'; - } - } - - if ($height == 'auto') - { - if ($mime == 'audio') - { - $height = 0; - } - elseif ($mime == 'video') - { - if ($width == 'auto') - { - if ($widescreen) - { - $height = 270; - } - else - { - $height = 360; - } - } - elseif ($widescreen) - { - $height = round((intval($width)/16)*9); - } - else - { - $height = round((intval($width)/4)*3); - } - } - else - { - $height = 376; - } - } - elseif ($mime == 'audio') - { - $height = 0; - } - - // Set proper placeholder value - if ($mime == 'audio') - { - $placeholder = $audio; - } - elseif ($mime == 'video') - { - $placeholder = $video; - } - - $embed = ''; - - // Make sure the JS library is included - if (!$native) - { - static $javascript_outputted = null; - if (!$javascript_outputted && $this->javascript) - { - $embed .= ''; - $javascript_outputted = true; - } - } - - // Odeo Feed MP3's - if ($handler == 'odeo') - { - if ($native) - { - $embed .= ''; - } - else - { - $embed .= ''; - } - } - - // Flash - elseif ($handler == 'flash') - { - if ($native) - { - $embed .= "get_link() . "\" pluginspage=\"http://adobe.com/go/getflashplayer\" type=\"$type\" quality=\"high\" width=\"$width\" height=\"$height\" bgcolor=\"$bgcolor\" loop=\"$loop\">"; - } - else - { - $embed .= ""; - } - } - - // Flash Media Player file types. - // Preferred handler for MP3 file types. - elseif ($handler == 'fmedia' || ($handler == 'mp3' && $mediaplayer != '')) - { - $height += 20; - if ($native) - { - $embed .= "get_link().'?file_extension=.'.$this->get_extension()) . "&autostart=false&repeat=$loop&showdigits=true&showfsbutton=false\">"; - } - else - { - $embed .= ""; - } - } - - // QuickTime 7 file types. Need to test with QuickTime 6. - // Only handle MP3's if the Flash Media Player is not present. - elseif ($handler == 'quicktime' || ($handler == 'mp3' && $mediaplayer == '')) - { - $height += 16; - if ($native) - { - if ($placeholder != ""){ - $embed .= "get_link() . "\" src=\"$placeholder\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"false\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\">"; - } - else { - $embed .= "get_link() . "\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"true\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\">"; - } - } - else - { - $embed .= ""; - } - } - - // Windows Media - elseif ($handler == 'wmedia') - { - $height += 45; - if ($native) - { - $embed .= "get_link() . "\" autosize=\"1\" width=\"$width\" height=\"$height\" showcontrols=\"1\" showstatusbar=\"0\" showdisplay=\"0\" autostart=\"0\">"; - } - else - { - $embed .= ""; - } - } - - // Everything else - else $embed .= '' . $alt . ''; - - return $embed; - } - - function get_real_type($find_handler = false) - { - // If it's Odeo, let's get it out of the way. - if (substr(strtolower($this->get_link()), 0, 15) == 'http://odeo.com') - { - return 'odeo'; - } - - // Mime-types by handler. - $types_flash = array('application/x-shockwave-flash', 'application/futuresplash'); // Flash - $types_fmedia = array('video/flv', 'video/x-flv'); // Flash Media Player - $types_quicktime = array('audio/3gpp', 'audio/3gpp2', 'audio/aac', 'audio/x-aac', 'audio/aiff', 'audio/x-aiff', 'audio/mid', 'audio/midi', 'audio/x-midi', 'audio/mp4', 'audio/m4a', 'audio/x-m4a', 'audio/wav', 'audio/x-wav', 'video/3gpp', 'video/3gpp2', 'video/m4v', 'video/x-m4v', 'video/mp4', 'video/mpeg', 'video/x-mpeg', 'video/quicktime', 'video/sd-video'); // QuickTime - $types_wmedia = array('application/asx', 'application/x-mplayer2', 'audio/x-ms-wma', 'audio/x-ms-wax', 'video/x-ms-asf-plugin', 'video/x-ms-asf', 'video/x-ms-wm', 'video/x-ms-wmv', 'video/x-ms-wvx'); // Windows Media - $types_mp3 = array('audio/mp3', 'audio/x-mp3', 'audio/mpeg', 'audio/x-mpeg'); // MP3 - - if ($this->get_type() !== null) - { - $type = strtolower($this->type); - } - else - { - $type = null; - } - - // If we encounter an unsupported mime-type, check the file extension and guess intelligently. - if (!in_array($type, array_merge($types_flash, $types_fmedia, $types_quicktime, $types_wmedia, $types_mp3))) - { - switch (strtolower($this->get_extension())) - { - // Audio mime-types - case 'aac': - case 'adts': - $type = 'audio/acc'; - break; - - case 'aif': - case 'aifc': - case 'aiff': - case 'cdda': - $type = 'audio/aiff'; - break; - - case 'bwf': - $type = 'audio/wav'; - break; - - case 'kar': - case 'mid': - case 'midi': - case 'smf': - $type = 'audio/midi'; - break; - - case 'm4a': - $type = 'audio/x-m4a'; - break; - - case 'mp3': - case 'swa': - $type = 'audio/mp3'; - break; - - case 'wav': - $type = 'audio/wav'; - break; - - case 'wax': - $type = 'audio/x-ms-wax'; - break; - - case 'wma': - $type = 'audio/x-ms-wma'; - break; - - // Video mime-types - case '3gp': - case '3gpp': - $type = 'video/3gpp'; - break; - - case '3g2': - case '3gp2': - $type = 'video/3gpp2'; - break; - - case 'asf': - $type = 'video/x-ms-asf'; - break; - - case 'flv': - $type = 'video/x-flv'; - break; - - case 'm1a': - case 'm1s': - case 'm1v': - case 'm15': - case 'm75': - case 'mp2': - case 'mpa': - case 'mpeg': - case 'mpg': - case 'mpm': - case 'mpv': - $type = 'video/mpeg'; - break; - - case 'm4v': - $type = 'video/x-m4v'; - break; - - case 'mov': - case 'qt': - $type = 'video/quicktime'; - break; - - case 'mp4': - case 'mpg4': - $type = 'video/mp4'; - break; - - case 'sdv': - $type = 'video/sd-video'; - break; - - case 'wm': - $type = 'video/x-ms-wm'; - break; - - case 'wmv': - $type = 'video/x-ms-wmv'; - break; - - case 'wvx': - $type = 'video/x-ms-wvx'; - break; - - // Flash mime-types - case 'spl': - $type = 'application/futuresplash'; - break; - - case 'swf': - $type = 'application/x-shockwave-flash'; - break; - } - } - - if ($find_handler) - { - if (in_array($type, $types_flash)) - { - return 'flash'; - } - elseif (in_array($type, $types_fmedia)) - { - return 'fmedia'; - } - elseif (in_array($type, $types_quicktime)) - { - return 'quicktime'; - } - elseif (in_array($type, $types_wmedia)) - { - return 'wmedia'; - } - elseif (in_array($type, $types_mp3)) - { - return 'mp3'; - } - else - { - return null; - } - } - else - { - return $type; - } - } -} - -class SimplePie_Caption -{ - var $type; - var $lang; - var $startTime; - var $endTime; - var $text; - - // Constructor, used to input the data - function SimplePie_Caption($type = null, $lang = null, $startTime = null, $endTime = null, $text = null) - { - $this->type = $type; - $this->lang = $lang; - $this->startTime = $startTime; - $this->endTime = $endTime; - $this->text = $text; - } - - function __toString() - { - // There is no $this->data here - return md5(serialize($this)); - } - - function get_endtime() - { - if ($this->endTime !== null) - { - return $this->endTime; - } - else - { - return null; - } - } - - function get_language() - { - if ($this->language !== null) - { - return $this->language; - } - else - { - return null; - } - } - - function get_starttime() - { - if ($this->startTime !== null) - { - return $this->startTime; - } - else - { - return null; - } - } - - function get_text() - { - if ($this->text !== null) - { - return $this->text; - } - else - { - return null; - } - } - - function get_type() - { - if ($this->type !== null) - { - return $this->type; - } - else - { - return null; - } - } -} - -class SimplePie_Credit -{ - var $role; - var $scheme; - var $name; - - // Constructor, used to input the data - function SimplePie_Credit($role = null, $scheme = null, $name = null) - { - $this->role = $role; - $this->scheme = $scheme; - $this->name = $name; - } - - function __toString() - { - // There is no $this->data here - return md5(serialize($this)); - } - - function get_role() - { - if ($this->role !== null) - { - return $this->role; - } - else - { - return null; - } - } - - function get_scheme() - { - if ($this->scheme !== null) - { - return $this->scheme; - } - else - { - return null; - } - } - - function get_name() - { - if ($this->name !== null) - { - return $this->name; - } - else - { - return null; - } - } -} - -class SimplePie_Copyright -{ - var $url; - var $label; - - // Constructor, used to input the data - function SimplePie_Copyright($url = null, $label = null) - { - $this->url = $url; - $this->label = $label; - } - - function __toString() - { - // There is no $this->data here - return md5(serialize($this)); - } - - function get_url() - { - if ($this->url !== null) - { - return $this->url; - } - else - { - return null; - } - } - - function get_attribution() - { - if ($this->label !== null) - { - return $this->label; - } - else - { - return null; - } - } -} - -class SimplePie_Rating -{ - var $scheme; - var $value; - - // Constructor, used to input the data - function SimplePie_Rating($scheme = null, $value = null) - { - $this->scheme = $scheme; - $this->value = $value; - } - - function __toString() - { - // There is no $this->data here - return md5(serialize($this)); - } - - function get_scheme() - { - if ($this->scheme !== null) - { - return $this->scheme; - } - else - { - return null; - } - } - - function get_value() - { - if ($this->value !== null) - { - return $this->value; - } - else - { - return null; - } - } -} - -class SimplePie_Restriction -{ - var $relationship; - var $type; - var $value; - - // Constructor, used to input the data - function SimplePie_Restriction($relationship = null, $type = null, $value = null) - { - $this->relationship = $relationship; - $this->type = $type; - $this->value = $value; - } - - function __toString() - { - // There is no $this->data here - return md5(serialize($this)); - } - - function get_relationship() - { - if ($this->relationship !== null) - { - return $this->relationship; - } - else - { - return null; - } - } - - function get_type() - { - if ($this->type !== null) - { - return $this->type; - } - else - { - return null; - } - } - - function get_value() - { - if ($this->value !== null) - { - return $this->value; - } - else - { - return null; - } - } -} - -/** - * @todo Move to properly supporting RFC2616 (HTTP/1.1) - */ -class SimplePie_File -{ - var $url; - var $useragent; - var $success = true; - var $headers = array(); - var $body; - var $status_code; - var $redirects = 0; - var $error; - var $method; - - function SimplePie_File($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) - { - if (class_exists('idna_convert')) - { - $idn =& new idna_convert; - $parsed = SimplePie_Misc::parse_url($url); - $url = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']); - } - $this->url = $url; - $this->useragent = $useragent; - if (preg_match('/^http(s)?:\/\//i', $url)) - { - if ($useragent === null) - { - $useragent = ini_get('user_agent'); - $this->useragent = $useragent; - } - if (!is_array($headers)) - { - $headers = array(); - } - if (!$force_fsockopen && extension_loaded('curl')) - { - $this->method = 'curl'; - $fp = curl_init(); - $headers2 = array(); - foreach ($headers as $key => $value) - { - $headers2[] = "$key: $value"; - } - if (version_compare(SimplePie_Misc::get_curl_version(), '7.10.5', '>=')) - { - curl_setopt($fp, CURLOPT_ENCODING, ''); - } - curl_setopt($fp, CURLOPT_URL, $url); - curl_setopt($fp, CURLOPT_HEADER, 1); - curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($fp, CURLOPT_TIMEOUT, $timeout); - curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, $timeout); - curl_setopt($fp, CURLOPT_REFERER, $url); - curl_setopt($fp, CURLOPT_USERAGENT, $useragent); - curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2); - if (!ini_get('open_basedir') && !ini_get('safe_mode') && version_compare(SimplePie_Misc::get_curl_version(), '7.15.2', '>=')) - { - curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1); - curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects); - } - - $this->headers = curl_exec($fp); - if (curl_errno($fp) == 23 || curl_errno($fp) == 61) - { - curl_setopt($fp, CURLOPT_ENCODING, 'none'); - $this->headers = curl_exec($fp); - } - if (curl_errno($fp)) - { - $this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp); - $this->success = false; - } - else - { - $info = curl_getinfo($fp); - curl_close($fp); - $this->headers = explode("\r\n\r\n", $this->headers, $info['redirect_count'] + 1); - $this->headers = array_pop($this->headers); - $parser =& new SimplePie_HTTP_Parser($this->headers); - if ($parser->parse()) - { - $this->headers = $parser->headers; - $this->body = $parser->body; - $this->status_code = $parser->status_code; - if (($this->status_code == 300 || $this->status_code == 301 || $this->status_code == 302 || $this->status_code == 303 || $this->status_code == 307 || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) - { - $this->redirects++; - if (isset($this->headers['content-location'])) - { - $location = SimplePie_Misc::absolutize_url($this->headers['location'], SimplePie_Misc::absolutize_url($this->headers['content-location'], $url)); - } - else - { - $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url); - } - return $this->SimplePie_File($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen); - } - } - } - } - else - { - $this->method = 'fsockopen'; - $url_parts = parse_url($url); - if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) == 'https') - { - $url_parts['host'] = "ssl://$url_parts[host]"; - $url_parts['port'] = 443; - } - if (!isset($url_parts['port'])) - { - $url_parts['port'] = 80; - } - $fp = fsockopen($url_parts['host'], $url_parts['port'], $errno, $errstr, $timeout); - if (!$fp) - { - $this->error = 'fsockopen error: ' . $errstr; - $this->success = false; - } - else - { - if (function_exists('stream_set_timeout')) - { - stream_set_timeout($fp, $timeout); - } - else - { - socket_set_timeout($fp, $timeout); - } - if (isset($url_parts['path'])) - { - if (isset($url_parts['query'])) - { - $get = "$url_parts[path]?$url_parts[query]"; - } - else - { - $get = $url_parts['path']; - } - } - else - { - $get = '/'; - } - $out = "GET $get HTTP/1.0\r\n"; - $out .= "Host: $url_parts[host]\r\n"; - $out .= "User-Agent: $useragent\r\n"; - if (function_exists('gzinflate')) - { - $out .= "Accept-Encoding: gzip,deflate\r\n"; - } - - if (isset($url_parts['user']) && isset($url_parts['pass'])) - { - $out .= "Authorization: Basic " . base64_encode("$url_parts[user]:$url_parts[pass]") . "\r\n"; - } - foreach ($headers as $key => $value) - { - $out .= "$key: $value\r\n"; - } - $out .= "Connection: Close\r\n\r\n"; - fwrite($fp, $out); - - if (function_exists('stream_get_meta_data')) - { - $info = stream_get_meta_data($fp); - } - else - { - $info = socket_get_status($fp); - } - - $this->headers = ''; - while (!$info['eof'] && !$info['timed_out']) - { - $this->headers .= fread($fp, 1160); - if (function_exists('stream_get_meta_data')) - { - $info = stream_get_meta_data($fp); - } - else - { - $info = socket_get_status($fp); - } - } - if (!$info['timed_out']) - { - $parser =& new SimplePie_HTTP_Parser($this->headers); - if ($parser->parse()) - { - $this->headers = $parser->headers; - $this->body = $parser->body; - $this->status_code = $parser->status_code; - if (($this->status_code == 300 || $this->status_code == 301 || $this->status_code == 302 || $this->status_code == 303 || $this->status_code == 307 || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) - { - $this->redirects++; - if (isset($this->headers['content-location'])) - { - $location = SimplePie_Misc::absolutize_url($this->headers['location'], SimplePie_Misc::absolutize_url($this->headers['content-location'], $url)); - } - else - { - $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url); - } - return $this->SimplePie_File($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen); - } - if (isset($this->headers['content-encoding']) && ($this->headers['content-encoding'] == 'gzip' || $this->headers['content-encoding'] == 'deflate')) - { - if (substr($this->body, 0, 8) == "\x1f\x8b\x08\x00\x00\x00\x00\x00") - { - $this->body = substr($this->body, 10); - } - $this->body = gzinflate($this->body); - } - } - } - else - { - $this->error = 'fsocket timed out'; - $this->success = false; - } - fclose($fp); - } - } - } - elseif (function_exists('file_get_contents')) - { - $this->method = 'file_get_contents'; - if (!$this->body = file_get_contents($url)) - { - $this->error = 'file_get_contents could not read the file'; - $this->success = false; - } - } - else - { - $this->method = 'fopen'; - if (($fp = fopen($url, 'rb')) === false) - { - $this->error = 'failed to open stream: No such file or directory'; - $this->success = false; - } - else - { - $this->body = ''; - while (!feof($fp)) - { - $this->body .= fread($fp, 8192); - } - fclose($fp); - } - } - } -} - -/** - * HTTP Response Parser - * - * @package SimplePie - * @todo Support HTTP Requests - */ -class SimplePie_HTTP_Parser -{ - /** - * HTTP Version - * - * @access public - * @var string - */ - var $http_version = ''; - - /** - * Status code - * - * @access public - * @var string - */ - var $status_code = ''; - - /** - * Reason phrase - * - * @access public - * @var string - */ - var $reason = ''; - - /** - * Key/value pairs of the headers - * - * @access public - * @var array - */ - var $headers = array(); - - /** - * Body of the response - * - * @access public - * @var string - */ - var $body = ''; - - /** - * Current state of the state machine - * - * @access private - * @var string - */ - var $state = 'start'; - - /** - * Input data - * - * @access private - * @var string - */ - var $data = ''; - - /** - * Input data length (to avoid calling strlen() everytime this is needed) - * - * @access private - * @var int - */ - var $data_length = 0; - - /** - * Current position of the pointer - * - * @access private - * @var int - */ - var $position = 0; - - /** - * Name of the hedaer currently being parsed - * - * @access private - * @var string - */ - var $name = ''; - - /** - * Value of the hedaer currently being parsed - * - * @access private - * @var string - */ - var $value = ''; - - /** - * Create an instance of the class with the input data - * - * @access public - * @param string $data Input data - */ - function SimplePie_HTTP_Parser($data) - { - $this->data = $data; - $this->data_length = strlen($this->data); - } - - /** - * Parse the input data - * - * @access public - * @return bool true on success, false on failure - */ - function parse() - { - while ($this->state && $this->state != 'emit' && $this->has_data()) - { - $state = $this->state; - $this->$state(); - } - $this->data = ''; - if ($this->state == 'emit') - { - return true; - } - else - { - $this->http_version = ''; - $this->status_code = ''; - $this->headers = array(); - $this->body = ''; - return false; - } - } - - /** - * Check whether there is data beyond the pointer - * - * @access private - * @return bool true if there is further data, false if not - */ - function has_data() - { - return (bool) ($this->position < $this->data_length); - } - - /** - * See if the next character is LWS - * - * @access private - * @return bool true if the next character is LWS, false if not - */ - function is_linear_whitespace() - { - return (bool) (strspn($this->data, "\x09\x20", $this->position, 1) - || (substr($this->data, $this->position, 2) == "\r\n" && strspn($this->data, "\x09\x20", $this->position + 2, 1)) - || (strspn($this->data, "\r\n", $this->position, 1) && strspn($this->data, "\x09\x20", $this->position + 1, 1))); - } - - /** - * The starting state of the state machine, see if the data is a response or request - * - * @access private - */ - function start() - { - $this->state = 'http_version_response'; - } - - /** - * Parse an HTTP-version string - * - * @access private - */ - function http_version() - { - if (preg_match('/^HTTP\/([0-9]+\.[0-9]+)/i', substr($this->data, $this->position, strcspn($this->data, "\r\n", $this->position)), $match)) - { - $this->position += strlen($match[0]); - $this->http_version = $match[1]; - return true; - } - else - { - return false; - } - } - - /** - * Parse LWS, replacing consecutive characters with a single space - * - * @access private - */ - function linear_whitespace() - { - do - { - if (substr($this->data, $this->position, 2) == "\r\n") - { - $this->position += 2; - } - elseif (strspn($this->data, "\r\n", $this->position, 1)) - { - $this->position++; - } - $this->position += strspn($this->data, "\x09\x20", $this->position); - } while ($this->is_linear_whitespace()); - $this->value .= "\x20"; - } - - /** - * Parse an HTTP-version string within a response - * - * @access private - */ - function http_version_response() - { - if ($this->http_version() && $this->data[$this->position] == "\x20") - { - $this->state = 'status_code'; - $this->position++; - } - else - { - $this->state = false; - } - } - - /** - * Parse a status code - * - * @access private - */ - function status_code() - { - if (strspn($this->data, '1234567890', $this->position, 3) == 3) - { - $this->status_code = substr($this->data, $this->position, 3); - $this->state = 'reason_phrase'; - $this->position += 3; - } - else - { - $this->state = false; - } - } - - /** - * Skip over the reason phrase (it has no normative value, and you can send absolutely anything here) - * - * @access private - */ - function reason_phrase() - { - $len = strcspn($this->data, "\r\n", $this->position); - $this->reason = substr($this->data, $this->position, $len); - $this->position += $len; - if ($this->has_data()) - { - if (substr($this->data, $this->position, 2) == "\r\n") - { - $this->position += 2; - } - elseif (strspn($this->data, "\r\n", $this->position, 1)) - { - $this->position++; - } - $this->state = 'name'; - } - } - - /** - * Parse a header name - * - * @access private - */ - function name() - { - $len = strcspn($this->data, ':', $this->position); - $this->name = substr($this->data, $this->position, $len); - $this->position += $len; - - if ($this->has_data() && $this->data[$this->position] == ':') - { - $this->state = 'value_next'; - $this->position++; - } - else - { - $this->state = false; - } - } - - /** - * See what state to move the state machine to while within non-quoted header values - * - * @access private - */ - function value_next() - { - if ($this->is_linear_whitespace()) - { - $this->state = 'value_linear_whitespace'; - } - elseif ($this->data[$this->position] == '"') - { - $this->state = 'value_quote_next'; - $this->position++; - } - elseif (substr($this->data, $this->position, 2) == "\r\n") - { - $this->state = 'end_crlf'; - $this->position += 2; - } - elseif (strspn($this->data, "\r\n", $this->position, 1)) - { - $this->state = 'end_crlf'; - $this->position++; - } - else - { - $this->state = 'value_no_quote'; - } - } - - /** - * Parse a header value while outside quotes - * - * @access private - */ - function value_no_quote() - { - $len = strcspn($this->data, "\x09\x20\r\n\"", $this->position); - $this->value .= substr($this->data, $this->position, $len); - $this->state = 'value_next'; - $this->position += $len; - } - - /** - * Parse LWS outside quotes - * - * @access private - */ - function value_linear_whitespace() - { - $this->linear_whitespace(); - $this->state = 'value_next'; - } - - /** - * See what state to move the state machine to while within quoted header values - * - * @access private - */ - function value_quote_next() - { - if ($this->is_linear_whitespace()) - { - $this->state = 'value_linear_whitespace_quote'; - } - else - { - switch ($this->data[$this->position]) - { - case '"': - $this->state = 'value_next'; - $this->position++; - break; - - case '\\': - $this->state = 'value_quote_char'; - $this->position++; - break; - - default: - $this->state = 'value_quote'; - break; - } - } - } - - /** - * Parse a header value while within quotes - * - * @access private - */ - function value_quote() - { - $len = strcspn($this->data, "\x09\x20\r\n\"\\", $this->position); - $this->value .= substr($this->data, $this->position, $len); - $this->position += $len; - $this->state = 'value_quote_next'; - } - - /** - * Parse an escaped character within quotes - * - * @access private - */ - function value_quote_char() - { - $this->value .= $this->data[$this->position]; - $this->state = 'value_quote_next'; - $this->position++; - } - - /** - * Parse LWS within quotes - * - * @access private - */ - function value_linear_whitespace_quote() - { - $this->linear_whitespace(); - $this->state = 'value_quote_next'; - } - - /** - * Parse a CRLF, and see whether we have a further header, or whether we are followed by the body - * - * @access private - */ - function end_crlf() - { - $this->name = strtolower($this->name); - $this->value = trim($this->value, "\x20"); - if (isset($this->headers[$this->name])) - { - $this->headers[$this->name] .= ', ' . $this->value; - } - else - { - $this->headers[$this->name] = $this->value; - } - - if (substr($this->data, $this->position, 2) == "\r\n") - { - $this->body = substr($this->data, $this->position + 2); - $this->state = 'emit'; - } - elseif (strspn($this->data, "\r\n", $this->position, 1)) - { - $this->body = substr($this->data, $this->position + 1); - $this->state = 'emit'; - } - else - { - $this->name = ''; - $this->value = ''; - $this->state = 'name'; - } - } -} - -class SimplePie_Cache -{ - var $location; - var $filename; - var $extension; - var $name; - - function SimplePie_Cache($location, $filename, $extension) - { - $this->location = $location; - $this->filename = rawurlencode($filename); - $this->extension = rawurlencode($extension); - $this->name = "$location/$this->filename.$this->extension"; - } - - function save($data) - { - if (file_exists($this->name) && is_writeable($this->name) || file_exists($this->location) && is_writeable($this->location)) - { - if (function_exists('file_put_contents')) - { - return (bool) file_put_contents($this->name, serialize($data)); - } - else - { - $fp = fopen($this->name, 'wb'); - if ($fp) - { - fwrite($fp, serialize($data)); - fclose($fp); - return true; - } - } - } - return false; - } - - function load() - { - if (file_exists($this->name) && is_readable($this->name)) - { - if (function_exists('file_get_contents')) - { - return unserialize(file_get_contents($this->name)); - } - elseif (($fp = fopen($this->name, 'rb')) !== false) - { - $data = ''; - while (!feof($fp)) - { - $data .= fread($fp, 8192); - } - fclose($fp); - return unserialize($data); - } - } - return false; - } - - function mtime() - { - if (file_exists($this->name)) - { - return filemtime($this->name); - } - return false; - } - - function touch() - { - if (file_exists($this->name)) - { - return touch($this->name); - } - return false; - } - - function unlink() - { - if (file_exists($this->name)) - { - return unlink($this->name); - } - return false; - } -} - -class SimplePie_Misc -{ - function time_hms($seconds) - { - $time = ''; - - $hours = floor($seconds / 3600); - $remainder = $seconds % 3600; - if ($hours > 0) - { - $time .= $hours.':'; - } - - $minutes = floor($remainder / 60); - $seconds = $remainder % 60; - if ($minutes < 10 && $hours > 0) - { - $minutes = '0' . $minutes; - } - if ($seconds < 10) - { - $seconds = '0' . $seconds; - } - - $time .= $minutes.':'; - $time .= $seconds; - - return $time; - } - - function absolutize_url($relative, $base) - { - if ($relative !== '') - { - $relative = SimplePie_Misc::parse_url($relative); - if ($relative['scheme'] !== '') - { - $target = $relative; - } - elseif ($base !== '') - { - $base = SimplePie_Misc::parse_url($base); - $target = SimplePie_Misc::parse_url(''); - if ($relative['authority'] !== '') - { - $target = $relative; - $target['scheme'] = $base['scheme']; - } - else - { - $target['scheme'] = $base['scheme']; - $target['authority'] = $base['authority']; - if ($relative['path'] !== '') - { - if (strpos($relative['path'], '/') === 0) - { - $target['path'] = $relative['path']; - } - elseif (($target['path'] = dirname("$base[path].")) == '/') - { - $target['path'] .= $relative['path']; - } - else - { - $target['path'] .= '/' . $relative['path']; - } - if ($relative['query'] !== '') - { - $target['query'] = $relative['query']; - } - } - else - { - if ($base['path'] !== '') - { - $target['path'] = $base['path']; - } - else - { - $target['path'] = '/'; - } - if ($relative['query'] !== '') - { - $target['query'] = $relative['query']; - } - elseif ($base['query'] !== '') - { - $target['query'] = $base['query']; - } - } - } - if ($relative['fragment'] !== '') - { - $target['fragment'] = $relative['fragment']; - } - } - else - { - // No base URL, just return the relative URL - $target = $relative; - } - $return = SimplePie_Misc::compress_parse_url($target['scheme'], $target['authority'], $target['path'], $target['query'], $target['fragment']); - } - else - { - $return = $base; - } - $return = SimplePie_Misc::normalize_url($return); - return $return; - } - - function remove_dot_segments($input) - { - $output = ''; - while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input == '.' || $input == '..') - { - // A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise, - if (strpos($input, '../') === 0) - { - $input = substr($input, 3); - } - elseif (strpos($input, './') === 0) - { - $input = substr($input, 2); - } - // B: if the input buffer begins with a prefix of "/./" or "/.", where "." is a complete path segment, then replace that prefix with "/" in the input buffer; otherwise, - elseif (strpos($input, '/./') === 0) - { - $input = substr_replace($input, '/', 0, 3); - } - elseif ($input == '/.') - { - $input = '/'; - } - // C: if the input buffer begins with a prefix of "/../" or "/..", where ".." is a complete path segment, then replace that prefix with "/" in the input buffer and remove the last segment and its preceding "/" (if any) from the output buffer; otherwise, - elseif (strpos($input, '/../') === 0) - { - $input = substr_replace($input, '/', 0, 4); - $output = substr_replace($output, '', strrpos($output, '/')); - } - elseif ($input == '/..') - { - $input = '/'; - $output = substr_replace($output, '', strrpos($output, '/')); - } - // D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise, - elseif ($input == '.' || $input == '..') - { - $input = ''; - } - // E: move the first path segment in the input buffer to the end of the output buffer, including the initial "/" character (if any) and any subsequent characters up to, but not including, the next "/" character or the end of the input buffer - elseif (($pos = strpos($input, '/', 1)) !== false) - { - $output .= substr($input, 0, $pos); - $input = substr_replace($input, '', 0, $pos); - } - else - { - $output .= $input; - $input = ''; - } - } - return $output . $input; - } - - function get_element($realname, $string) - { - $return = array(); - $name = preg_quote($realname, '/'); - if (preg_match_all("/<($name)" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . "(>(.*)<\/$name>|(\/)?>)/siU", $string, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) - { - for ($i = 0, $total_matches = count($matches); $i < $total_matches; $i++) - { - $return[$i]['tag'] = $realname; - $return[$i]['full'] = $matches[$i][0][0]; - $return[$i]['offset'] = $matches[$i][0][1]; - if (strlen($matches[$i][3][0]) <= 2) - { - $return[$i]['self_closing'] = true; - } - else - { - $return[$i]['self_closing'] = false; - $return[$i]['content'] = $matches[$i][4][0]; - } - $return[$i]['attribs'] = array(); - if (isset($matches[$i][2][0]) && preg_match_all('/((?:[^\s:]+:)?[^\s:]+)(?:\s*=\s*(?:"([^"]*)"|\'([^\']*)\'|([a-z0-9\-._:]*)))?\s/U', ' ' . $matches[$i][2][0] . ' ', $attribs, PREG_SET_ORDER)) - { - for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++) - { - if (count($attribs[$j]) == 2) - { - $attribs[$j][2] = $attribs[$j][1]; - } - $return[$i]['attribs'][strtolower($attribs[$j][1])]['data'] = SimplePie_Misc::entities_decode(end($attribs[$j]), 'UTF-8'); - } - } - } - } - return $return; - } - - function element_implode($element) - { - $full = "<$element[tag]"; - foreach ($element['attribs'] as $key => $value) - { - $key = strtolower($key); - $full .= " $key=\"" . htmlspecialchars($value['data']) . '"'; - } - if ($element['self_closing']) - { - $full .= ' />'; - } - else - { - $full .= ">$element[content]"; - } - return $full; - } - - function error($message, $level, $file, $line) - { - switch ($level) - { - case E_USER_ERROR: - $note = 'PHP Error'; - break; - case E_USER_WARNING: - $note = 'PHP Warning'; - break; - case E_USER_NOTICE: - $note = 'PHP Notice'; - break; - default: - $note = 'Unknown Error'; - break; - } - error_log("$note: $message in $file on line $line", 0); - return $message; - } - - /** - * If a file has been cached, retrieve and display it. - * - * This is most useful for caching images (get_favicon(), etc.), - * however it works for all cached files. This WILL NOT display ANY - * file/image/page/whatever, but rather only display what has already - * been cached by SimplePie. - * - * @access public - * @see SimplePie::get_favicon() - * @param str $identifier_url URL that is used to identify the content. - * This may or may not be the actual URL of the live content. - * @param str $cache_location Location of SimplePie's cache. Defaults - * to './cache'. - * @param str $cache_extension The file extension that the file was - * cached with. Defaults to 'spc'. - * @param str $cache_class Name of the cache-handling class being used - * in SimplePie. Defaults to 'SimplePie_Cache', and should be left - * as-is unless you've overloaded the class. - * @param str $cache_name_function Function that converts the filename - * for saving. Defaults to 'md5'. - */ - function display_cached_file($identifier_url, $cache_location = './cache', $cache_extension = 'spc', $cache_class = 'SimplePie_Cache', $cache_name_function = 'md5') - { - $cache =& new $cache_class($cache_location, call_user_func($cache_name_function, $identifier_url), $cache_extension); - - if ($file = $cache->load()) - { - header('Content-type:' . $file['headers']['content-type']); - header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days - echo $file['body']; - exit; - } - - die('Cached file for ' . $identifier_url . ' cannot be found.'); - } - - function fix_protocol($url, $http = 1) - { - $url = SimplePie_Misc::normalize_url($url); - $parsed = SimplePie_Misc::parse_url($url); - if ($parsed['scheme'] !== '' && $parsed['scheme'] != 'http' && $parsed['scheme'] != 'https') - { - return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['authority'], $parsed['path'], $parsed['query'], $parsed['fragment']), $http); - } - - if ($parsed['scheme'] === '' && $parsed['authority'] === '' && !file_exists($url)) - { - return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['path'], '', $parsed['query'], $parsed['fragment']), $http); - } - - if ($http == 2 && $parsed['scheme'] !== '') - { - return "feed:$url"; - } - elseif ($http == 3 && strtolower($parsed['scheme']) == 'http') - { - return substr_replace($url, 'podcast', 0, 4); - } - elseif ($http == 4 && strtolower($parsed['scheme']) == 'http') - { - return substr_replace($url, 'itpc', 0, 4); - } - else - { - return $url; - } - } - - function parse_url($url) - { - static $cache = array(); - if (isset($cache[$url])) - { - return $cache[$url]; - } - elseif (preg_match('/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/', $url, $match)) - { - for ($i = count($match); $i <= 9; $i++) - { - $match[$i] = ''; - } - return $cache[$url] = array('scheme' => $match[2], 'authority' => $match[4], 'path' => $match[5], 'query' => $match[7], 'fragment' => $match[9]); - } - else - { - return $cache[$url] = array('scheme' => '', 'authority' => '', 'path' => '', 'query' => '', 'fragment' => ''); - } - } - - function compress_parse_url($scheme = '', $authority = '', $path = '', $query = '', $fragment = '') - { - $return = ''; - if ($scheme !== '') - { - $return .= "$scheme:"; - } - if ($authority !== '') - { - $return .= "//$authority"; - } - if ($path !== '') - { - $return .= $path; - } - if ($query !== '') - { - $return .= "?$query"; - } - if ($fragment !== '') - { - $return .= "#$fragment"; - } - return $return; - } - - function normalize_url($url) - { - $url = preg_replace_callback('/%([0-9A-Fa-f]{2})/', array('SimplePie_Misc', 'percent_encoding_normalization'), $url); - $url = SimplePie_Misc::parse_url($url); - $url['scheme'] = strtolower($url['scheme']); - if ($url['authority'] !== '') - { - $url['authority'] = strtolower($url['authority']); - $url['path'] = SimplePie_Misc::remove_dot_segments($url['path']); - } - return SimplePie_Misc::compress_parse_url($url['scheme'], $url['authority'], $url['path'], $url['query'], $url['fragment']); - } - - function percent_encoding_normalization($match) - { - $integer = hexdec($match[1]); - if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer == 0x2D || $integer == 0x2E || $integer == 0x5F || $integer == 0x7E) - { - return chr($integer); - } - else - { - return strtoupper($match[0]); - } - } - - /** - * Remove bad UTF-8 bytes - * - * PCRE Pattern to locate bad bytes in a UTF-8 string comes from W3C - * FAQ: Multilingual Forms (modified to include full ASCII range) - * - * @author Geoffrey Sneddon - * @see http://www.w3.org/International/questions/qa-forms-utf-8 - * @param string $str String to remove bad UTF-8 bytes from - * @return string UTF-8 string - */ - function utf8_bad_replace($str) - { - if (function_exists('iconv')) - { - return iconv('UTF-8', 'UTF-8//IGNORE', $str); - } - elseif (function_exists('mb_convert_encoding')) - { - return mb_convert_encoding($str, 'UTF-8', 'UTF-8'); - } - elseif (preg_match_all('/([\x00-\x7F]|[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})/', $str, $matches)) - { - return implode("\xEF\xBF\xBD", $matches[0]); - } - elseif ($str !== '') - { - return "\xEF\xBF\xBD"; - } - else - { - return ''; - } - } - - function change_encoding($data, $input, $output) - { - $input = SimplePie_Misc::encoding($input); - $output = SimplePie_Misc::encoding($output); - - if (function_exists('iconv') && ($return = @iconv($input, "$output//IGNORE", $data))) - { - return $return; - } - elseif (function_exists('iconv') && ($return = @iconv($input, $output, $data))) - { - return $return; - } - elseif (function_exists('mb_convert_encoding') && ($return = @mb_convert_encoding($data, $output, $input))) - { - return $return; - } - elseif ($input == 'ISO-8859-1' && $output == 'UTF-8') - { - return utf8_encode($data); - } - elseif ($input == 'UTF-8' && $output == 'ISO-8859-1') - { - return utf8_decode($data); - } - return $data; - } - - function encoding($encoding) - { - // Character sets are case-insensitive (though we'll return them in the form given in their registration) - switch (strtoupper($encoding)) - { - case 'ANSI_X3.4-1968': - case 'ISO-IR-6': - case 'ANSI_X3.4-1986': - case 'ISO_646.IRV:1991': - case 'ASCII': - case 'ISO646-US': - case 'US-ASCII': - case 'US': - case 'IBM367': - case 'CP367': - case 'CSASCII': - return 'US-ASCII'; - - case 'ISO_8859-1:1987': - case 'ISO-IR-100': - case 'ISO_8859-1': - case 'ISO-8859-1': - case 'LATIN1': - case 'L1': - case 'IBM819': - case 'CP819': - case 'CSISOLATIN1': - return 'ISO-8859-1'; - - case 'ISO_8859-2:1987': - case 'ISO-IR-101': - case 'ISO_8859-2': - case 'ISO-8859-2': - case 'LATIN2': - case 'L2': - case 'CSISOLATIN2': - return 'ISO-8859-2'; - - case 'ISO_8859-3:1988': - case 'ISO-IR-109': - case 'ISO_8859-3': - case 'ISO-8859-3': - case 'LATIN3': - case 'L3': - case 'CSISOLATIN3': - return 'ISO-8859-3'; - - case 'ISO_8859-4:1988': - case 'ISO-IR-110': - case 'ISO_8859-4': - case 'ISO-8859-4': - case 'LATIN4': - case 'L4': - case 'CSISOLATIN4': - return 'ISO-8859-4'; - - case 'ISO_8859-5:1988': - case 'ISO-IR-144': - case 'ISO_8859-5': - case 'ISO-8859-5': - case 'CYRILLIC': - case 'CSISOLATINCYRILLIC': - return 'ISO-8859-5'; - - case 'ISO_8859-6:1987': - case 'ISO-IR-127': - case 'ISO_8859-6': - case 'ISO-8859-6': - case 'ECMA-114': - case 'ASMO-708': - case 'ARABIC': - case 'CSISOLATINARABIC': - return 'ISO-8859-6'; - - case 'ISO_8859-7:1987': - case 'ISO-IR-126': - case 'ISO_8859-7': - case 'ISO-8859-7': - case 'ELOT_928': - case 'ECMA-118': - case 'GREEK': - case 'GREEK8': - case 'CSISOLATINGREEK': - return 'ISO-8859-7'; - - case 'ISO_8859-8:1988': - case 'ISO-IR-138': - case 'ISO_8859-8': - case 'ISO-8859-8': - case 'HEBREW': - case 'CSISOLATINHEBREW': - return 'ISO-8859-8'; - - case 'ISO_8859-9:1989': - case 'ISO-IR-148': - case 'ISO_8859-9': - case 'ISO-8859-9': - case 'LATIN5': - case 'L5': - case 'CSISOLATIN5': - return 'ISO-8859-9'; - - case 'ISO-8859-10': - case 'ISO-IR-157': - case 'L6': - case 'ISO_8859-10:1992': - case 'CSISOLATIN6': - case 'LATIN6': - return 'ISO-8859-10'; - - case 'ISO_6937-2-ADD': - case 'ISO-IR-142': - case 'CSISOTEXTCOMM': - return 'ISO_6937-2-add'; - - case 'JIS_X0201': - case 'X0201': - case 'CSHALFWIDTHKATAKANA': - return 'JIS_X0201'; - - case 'JIS_ENCODING': - case 'CSJISENCODING': - return 'JIS_Encoding'; - - case 'SHIFT_JIS': - case 'MS_KANJI': - case 'CSSHIFTJIS': - return 'Shift_JIS'; - - case 'EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE': - case 'CSEUCPKDFMTJAPANESE': - case 'EUC-JP': - return 'EUC-JP'; - - case 'EXTENDED_UNIX_CODE_FIXED_WIDTH_FOR_JAPANESE': - case 'CSEUCFIXWIDJAPANESE': - return 'Extended_UNIX_Code_Fixed_Width_for_Japanese'; - - case 'BS_4730': - case 'ISO-IR-4': - case 'ISO646-GB': - case 'GB': - case 'UK': - case 'CSISO4UNITEDKINGDOM': - return 'BS_4730'; - - case 'SEN_850200_C': - case 'ISO-IR-11': - case 'ISO646-SE2': - case 'SE2': - case 'CSISO11SWEDISHFORNAMES': - return 'SEN_850200_C'; - - case 'IT': - case 'ISO-IR-15': - case 'ISO646-IT': - case 'CSISO15ITALIAN': - return 'IT'; - - case 'ES': - case 'ISO-IR-17': - case 'ISO646-ES': - case 'CSISO17SPANISH': - return 'ES'; - - case 'DIN_66003': - case 'ISO-IR-21': - case 'DE': - case 'ISO646-DE': - case 'CSISO21GERMAN': - return 'DIN_66003'; - - case 'NS_4551-1': - case 'ISO-IR-60': - case 'ISO646-NO': - case 'NO': - case 'CSISO60DANISHNORWEGIAN': - case 'CSISO60NORWEGIAN1': - return 'NS_4551-1'; - - case 'NF_Z_62-010': - case 'ISO-IR-69': - case 'ISO646-FR': - case 'FR': - case 'CSISO69FRENCH': - return 'NF_Z_62-010'; - - case 'ISO-10646-UTF-1': - case 'CSISO10646UTF1': - return 'ISO-10646-UTF-1'; - - case 'ISO_646.BASIC:1983': - case 'REF': - case 'CSISO646BASIC1983': - return 'ISO_646.basic:1983'; - - case 'INVARIANT': - case 'CSINVARIANT': - return 'INVARIANT'; - - case 'ISO_646.IRV:1983': - case 'ISO-IR-2': - case 'IRV': - case 'CSISO2INTLREFVERSION': - return 'ISO_646.irv:1983'; - - case 'NATS-SEFI': - case 'ISO-IR-8-1': - case 'CSNATSSEFI': - return 'NATS-SEFI'; - - case 'NATS-SEFI-ADD': - case 'ISO-IR-8-2': - case 'CSNATSSEFIADD': - return 'NATS-SEFI-ADD'; - - case 'NATS-DANO': - case 'ISO-IR-9-1': - case 'CSNATSDANO': - return 'NATS-DANO'; - - case 'NATS-DANO-ADD': - case 'ISO-IR-9-2': - case 'CSNATSDANOADD': - return 'NATS-DANO-ADD'; - - case 'SEN_850200_B': - case 'ISO-IR-10': - case 'FI': - case 'ISO646-FI': - case 'ISO646-SE': - case 'SE': - case 'CSISO10SWEDISH': - return 'SEN_850200_B'; - - case 'KS_C_5601-1987': - case 'ISO-IR-149': - case 'KS_C_5601-1989': - case 'KSC_5601': - case 'KOREAN': - case 'CSKSC56011987': - return 'KS_C_5601-1987'; - - case 'ISO-2022-KR': - case 'CSISO2022KR': - return 'ISO-2022-KR'; - - case 'EUC-KR': - case 'CSEUCKR': - return 'EUC-KR'; - - case 'ISO-2022-JP': - case 'CSISO2022JP': - return 'ISO-2022-JP'; - - case 'ISO-2022-JP-2': - case 'CSISO2022JP2': - return 'ISO-2022-JP-2'; - - case 'JIS_C6220-1969-JP': - case 'JIS_C6220-1969': - case 'ISO-IR-13': - case 'KATAKANA': - case 'X0201-7': - case 'CSISO13JISC6220JP': - return 'JIS_C6220-1969-jp'; - - case 'JIS_C6220-1969-RO': - case 'ISO-IR-14': - case 'JP': - case 'ISO646-JP': - case 'CSISO14JISC6220RO': - return 'JIS_C6220-1969-ro'; - - case 'PT': - case 'ISO-IR-16': - case 'ISO646-PT': - case 'CSISO16PORTUGUESE': - return 'PT'; - - case 'GREEK7-OLD': - case 'ISO-IR-18': - case 'CSISO18GREEK7OLD': - return 'greek7-old'; - - case 'LATIN-GREEK': - case 'ISO-IR-19': - case 'CSISO19LATINGREEK': - return 'latin-greek'; - - case 'NF_Z_62-010_(1973)': - case 'ISO-IR-25': - case 'ISO646-FR1': - case 'CSISO25FRENCH': - return 'NF_Z_62-010_(1973)'; - - case 'LATIN-GREEK-1': - case 'ISO-IR-27': - case 'CSISO27LATINGREEK1': - return 'Latin-greek-1'; - - case 'ISO_5427': - case 'ISO-IR-37': - case 'CSISO5427CYRILLIC': - return 'ISO_5427'; - - case 'JIS_C6226-1978': - case 'ISO-IR-42': - case 'CSISO42JISC62261978': - return 'JIS_C6226-1978'; - - case 'BS_VIEWDATA': - case 'ISO-IR-47': - case 'CSISO47BSVIEWDATA': - return 'BS_viewdata'; - - case 'INIS': - case 'ISO-IR-49': - case 'CSISO49INIS': - return 'INIS'; - - case 'INIS-8': - case 'ISO-IR-50': - case 'CSISO50INIS8': - return 'INIS-8'; - - case 'INIS-CYRILLIC': - case 'ISO-IR-51': - case 'CSISO51INISCYRILLIC': - return 'INIS-cyrillic'; - - case 'ISO_5427:1981': - case 'ISO-IR-54': - case 'ISO5427CYRILLIC1981': - return 'ISO_5427:1981'; - - case 'ISO_5428:1980': - case 'ISO-IR-55': - case 'CSISO5428GREEK': - return 'ISO_5428:1980'; - - case 'GB_1988-80': - case 'ISO-IR-57': - case 'CN': - case 'ISO646-CN': - case 'CSISO57GB1988': - return 'GB_1988-80'; - - case 'GB_2312-80': - case 'ISO-IR-58': - case 'CHINESE': - case 'CSISO58GB231280': - return 'GB_2312-80'; - - case 'NS_4551-2': - case 'ISO646-NO2': - case 'ISO-IR-61': - case 'NO2': - case 'CSISO61NORWEGIAN2': - return 'NS_4551-2'; - - case 'VIDEOTEX-SUPPL': - case 'ISO-IR-70': - case 'CSISO70VIDEOTEXSUPP1': - return 'videotex-suppl'; - - case 'PT2': - case 'ISO-IR-84': - case 'ISO646-PT2': - case 'CSISO84PORTUGUESE2': - return 'PT2'; - - case 'ES2': - case 'ISO-IR-85': - case 'ISO646-ES2': - case 'CSISO85SPANISH2': - return 'ES2'; - - case 'MSZ_7795.3': - case 'ISO-IR-86': - case 'ISO646-HU': - case 'HU': - case 'CSISO86HUNGARIAN': - return 'MSZ_7795.3'; - - case 'JIS_C6226-1983': - case 'ISO-IR-87': - case 'X0208': - case 'JIS_X0208-1983': - case 'CSISO87JISX0208': - return 'JIS_C6226-1983'; - - case 'GREEK7': - case 'ISO-IR-88': - case 'CSISO88GREEK7': - return 'greek7'; - - case 'ASMO_449': - case 'ISO_9036': - case 'ARABIC7': - case 'ISO-IR-89': - case 'CSISO89ASMO449': - return 'ASMO_449'; - - case 'ISO-IR-90': - case 'CSISO90': - return 'iso-ir-90'; - - case 'JIS_C6229-1984-A': - case 'ISO-IR-91': - case 'JP-OCR-A': - case 'CSISO91JISC62291984A': - return 'JIS_C6229-1984-a'; - - case 'JIS_C6229-1984-B': - case 'ISO-IR-92': - case 'ISO646-JP-OCR-B': - case 'JP-OCR-B': - case 'CSISO92JISC62991984B': - return 'JIS_C6229-1984-b'; - - case 'JIS_C6229-1984-B-ADD': - case 'ISO-IR-93': - case 'JP-OCR-B-ADD': - case 'CSISO93JIS62291984BADD': - return 'JIS_C6229-1984-b-add'; - - case 'JIS_C6229-1984-HAND': - case 'ISO-IR-94': - case 'JP-OCR-HAND': - case 'CSISO94JIS62291984HAND': - return 'JIS_C6229-1984-hand'; - - case 'JIS_C6229-1984-HAND-ADD': - case 'ISO-IR-95': - case 'JP-OCR-HAND-ADD': - case 'CSISO95JIS62291984HANDADD': - return 'JIS_C6229-1984-hand-add'; - - case 'JIS_C6229-1984-KANA': - case 'ISO-IR-96': - case 'CSISO96JISC62291984KANA': - return 'JIS_C6229-1984-kana'; - - case 'ISO_2033-1983': - case 'ISO-IR-98': - case 'E13B': - case 'CSISO2033': - return 'ISO_2033-1983'; - - case 'ANSI_X3.110-1983': - case 'ISO-IR-99': - case 'CSA_T500-1983': - case 'NAPLPS': - case 'CSISO99NAPLPS': - return 'ANSI_X3.110-1983'; - - case 'T.61-7BIT': - case 'ISO-IR-102': - case 'CSISO102T617BIT': - return 'T.61-7bit'; - - case 'T.61-8BIT': - case 'T.61': - case 'ISO-IR-103': - case 'CSISO103T618BIT': - return 'T.61-8bit'; - - case 'ECMA-CYRILLIC': - case 'ISO-IR-111': - case 'KOI8-E': - case 'CSISO111ECMACYRILLIC': - return 'ECMA-cyrillic'; - - case 'CSA_Z243.4-1985-1': - case 'ISO-IR-121': - case 'ISO646-CA': - case 'CSA7-1': - case 'CA': - case 'CSISO121CANADIAN1': - return 'CSA_Z243.4-1985-1'; - - case 'CSA_Z243.4-1985-2': - case 'ISO-IR-122': - case 'ISO646-CA2': - case 'CSA7-2': - case 'CSISO122CANADIAN2': - return 'CSA_Z243.4-1985-2'; - - case 'CSA_Z243.4-1985-GR': - case 'ISO-IR-123': - case 'CSISO123CSAZ24341985GR': - return 'CSA_Z243.4-1985-gr'; - - case 'ISO_8859-6-E': - case 'CSISO88596E': - case 'ISO-8859-6-E': - return 'ISO-8859-6-E'; - - case 'ISO_8859-6-I': - case 'CSISO88596I': - case 'ISO-8859-6-I': - return 'ISO-8859-6-I'; - - case 'T.101-G2': - case 'ISO-IR-128': - case 'CSISO128T101G2': - return 'T.101-G2'; - - case 'ISO_8859-8-E': - case 'CSISO88598E': - case 'ISO-8859-8-E': - return 'ISO-8859-8-E'; - - case 'ISO_8859-8-I': - case 'CSISO88598I': - case 'ISO-8859-8-I': - return 'ISO-8859-8-I'; - - case 'CSN_369103': - case 'ISO-IR-139': - case 'CSISO139CSN369103': - return 'CSN_369103'; - - case 'JUS_I.B1.002': - case 'ISO-IR-141': - case 'ISO646-YU': - case 'JS': - case 'YU': - case 'CSISO141JUSIB1002': - return 'JUS_I.B1.002'; - - case 'IEC_P27-1': - case 'ISO-IR-143': - case 'CSISO143IECP271': - return 'IEC_P27-1'; - - case 'JUS_I.B1.003-SERB': - case 'ISO-IR-146': - case 'SERBIAN': - case 'CSISO146SERBIAN': - return 'JUS_I.B1.003-serb'; - - case 'JUS_I.B1.003-MAC': - case 'MACEDONIAN': - case 'ISO-IR-147': - case 'CSISO147MACEDONIAN': - return 'JUS_I.B1.003-mac'; - - case 'GREEK-CCITT': - case 'ISO-IR-150': - case 'CSISO150': - case 'CSISO150GREEKCCITT': - return 'greek-ccitt'; - - case 'NC_NC00-10:81': - case 'CUBA': - case 'ISO-IR-151': - case 'ISO646-CU': - case 'CSISO151CUBA': - return 'NC_NC00-10:81'; - - case 'ISO_6937-2-25': - case 'ISO-IR-152': - case 'CSISO6937ADD': - return 'ISO_6937-2-25'; - - case 'GOST_19768-74': - case 'ST_SEV_358-88': - case 'ISO-IR-153': - case 'CSISO153GOST1976874': - return 'GOST_19768-74'; - - case 'ISO_8859-SUPP': - case 'ISO-IR-154': - case 'LATIN1-2-5': - case 'CSISO8859SUPP': - return 'ISO_8859-supp'; - - case 'ISO_10367-BOX': - case 'ISO-IR-155': - case 'CSISO10367BOX': - return 'ISO_10367-box'; - - case 'LATIN-LAP': - case 'LAP': - case 'ISO-IR-158': - case 'CSISO158LAP': - return 'latin-lap'; - - case 'JIS_X0212-1990': - case 'X0212': - case 'ISO-IR-159': - case 'CSISO159JISX02121990': - return 'JIS_X0212-1990'; - - case 'DS_2089': - case 'DS2089': - case 'ISO646-DK': - case 'DK': - case 'CSISO646DANISH': - return 'DS_2089'; - - case 'US-DK': - case 'CSUSDK': - return 'us-dk'; - - case 'DK-US': - case 'CSDKUS': - return 'dk-us'; - - case 'KSC5636': - case 'ISO646-KR': - case 'CSKSC5636': - return 'KSC5636'; - - case 'UNICODE-1-1-UTF-7': - case 'CSUNICODE11UTF7': - return 'UNICODE-1-1-UTF-7'; - - case 'ISO-2022-CN': - return 'ISO-2022-CN'; - - case 'ISO-2022-CN-EXT': - return 'ISO-2022-CN-EXT'; - - case 'UTF-8': - return 'UTF-8'; - - case 'ISO-8859-13': - return 'ISO-8859-13'; - - case 'ISO-8859-14': - case 'ISO-IR-199': - case 'ISO_8859-14:1998': - case 'ISO_8859-14': - case 'LATIN8': - case 'ISO-CELTIC': - case 'L8': - return 'ISO-8859-14'; - - case 'ISO-8859-15': - case 'ISO_8859-15': - case 'LATIN-9': - return 'ISO-8859-15'; - - case 'ISO-8859-16': - case 'ISO-IR-226': - case 'ISO_8859-16:2001': - case 'ISO_8859-16': - case 'LATIN10': - case 'L10': - return 'ISO-8859-16'; - - case 'GBK': - case 'CP936': - case 'MS936': - case 'WINDOWS-936': - return 'GBK'; - - case 'GB18030': - return 'GB18030'; - - case 'OSD_EBCDIC_DF04_15': - return 'OSD_EBCDIC_DF04_15'; - - case 'OSD_EBCDIC_DF03_IRV': - return 'OSD_EBCDIC_DF03_IRV'; - - case 'OSD_EBCDIC_DF04_1': - return 'OSD_EBCDIC_DF04_1'; - - case 'ISO-11548-1': - case 'ISO_11548-1': - case 'ISO_TR_11548-1': - case 'CSISO115481': - return 'ISO-11548-1'; - - case 'KZ-1048': - case 'STRK1048-2002': - case 'RK1048': - case 'CSKZ1048': - return 'KZ-1048'; - - case 'ISO-10646-UCS-2': - case 'CSUNICODE': - return 'ISO-10646-UCS-2'; - - case 'ISO-10646-UCS-4': - case 'CSUCS4': - return 'ISO-10646-UCS-4'; - - case 'ISO-10646-UCS-BASIC': - case 'CSUNICODEASCII': - return 'ISO-10646-UCS-Basic'; - - case 'ISO-10646-UNICODE-LATIN1': - case 'CSUNICODELATIN1': - case 'ISO-10646': - return 'ISO-10646-Unicode-Latin1'; - - case 'ISO-10646-J-1': - return 'ISO-10646-J-1'; - - case 'ISO-UNICODE-IBM-1261': - case 'CSUNICODEIBM1261': - return 'ISO-Unicode-IBM-1261'; - - case 'ISO-UNICODE-IBM-1268': - case 'CSUNICODEIBM1268': - return 'ISO-Unicode-IBM-1268'; - - case 'ISO-UNICODE-IBM-1276': - case 'CSUNICODEIBM1276': - return 'ISO-Unicode-IBM-1276'; - - case 'ISO-UNICODE-IBM-1264': - case 'CSUNICODEIBM1264': - return 'ISO-Unicode-IBM-1264'; - - case 'ISO-UNICODE-IBM-1265': - case 'CSUNICODEIBM1265': - return 'ISO-Unicode-IBM-1265'; - - case 'UNICODE-1-1': - case 'CSUNICODE11': - return 'UNICODE-1-1'; - - case 'SCSU': - return 'SCSU'; - - case 'UTF-7': - return 'UTF-7'; - - case 'UTF-16BE': - return 'UTF-16BE'; - - case 'UTF-16LE': - return 'UTF-16LE'; - - case 'UTF-16': - return 'UTF-16'; - - case 'CESU-8': - case 'CSCESU-8': - return 'CESU-8'; - - case 'UTF-32': - return 'UTF-32'; - - case 'UTF-32BE': - return 'UTF-32BE'; - - case 'UTF-32LE': - return 'UTF-32LE'; - - case 'BOCU-1': - case 'CSBOCU-1': - return 'BOCU-1'; - - case 'ISO-8859-1-WINDOWS-3.0-LATIN-1': - case 'CSWINDOWS30LATIN1': - return 'ISO-8859-1-Windows-3.0-Latin-1'; - - case 'ISO-8859-1-WINDOWS-3.1-LATIN-1': - case 'CSWINDOWS31LATIN1': - return 'ISO-8859-1-Windows-3.1-Latin-1'; - - case 'ISO-8859-2-WINDOWS-LATIN-2': - case 'CSWINDOWS31LATIN2': - return 'ISO-8859-2-Windows-Latin-2'; - - case 'ISO-8859-9-WINDOWS-LATIN-5': - case 'CSWINDOWS31LATIN5': - return 'ISO-8859-9-Windows-Latin-5'; - - case 'HP-ROMAN8': - case 'ROMAN8': - case 'R8': - case 'CSHPROMAN8': - return 'hp-roman8'; - - case 'ADOBE-STANDARD-ENCODING': - case 'CSADOBESTANDARDENCODING': - return 'Adobe-Standard-Encoding'; - - case 'VENTURA-US': - case 'CSVENTURAUS': - return 'Ventura-US'; - - case 'VENTURA-INTERNATIONAL': - case 'CSVENTURAINTERNATIONAL': - return 'Ventura-International'; - - case 'DEC-MCS': - case 'DEC': - case 'CSDECMCS': - return 'DEC-MCS'; - - case 'IBM850': - case 'CP850': - case '850': - case 'CSPC850MULTILINGUAL': - return 'IBM850'; - - case 'PC8-DANISH-NORWEGIAN': - case 'CSPC8DANISHNORWEGIAN': - return 'PC8-Danish-Norwegian'; - - case 'IBM862': - case 'CP862': - case '862': - case 'CSPC862LATINHEBREW': - return 'IBM862'; - - case 'PC8-TURKISH': - case 'CSPC8TURKISH': - return 'PC8-Turkish'; - - case 'IBM-SYMBOLS': - case 'CSIBMSYMBOLS': - return 'IBM-Symbols'; - - case 'IBM-THAI': - case 'CSIBMTHAI': - return 'IBM-Thai'; - - case 'HP-LEGAL': - case 'CSHPLEGAL': - return 'HP-Legal'; - - case 'HP-PI-FONT': - case 'CSHPPIFONT': - return 'HP-Pi-font'; - - case 'HP-MATH8': - case 'CSHPMATH8': - return 'HP-Math8'; - - case 'ADOBE-SYMBOL-ENCODING': - case 'CSHPPSMATH': - return 'Adobe-Symbol-Encoding'; - - case 'HP-DESKTOP': - case 'CSHPDESKTOP': - return 'HP-DeskTop'; - - case 'VENTURA-MATH': - case 'CSVENTURAMATH': - return 'Ventura-Math'; - - case 'MICROSOFT-PUBLISHING': - case 'CSMICROSOFTPUBLISHING': - return 'Microsoft-Publishing'; - - case 'WINDOWS-31J': - case 'CSWINDOWS31J': - return 'Windows-31J'; - - case 'GB2312': - case 'CSGB2312': - return 'GB2312'; - - case 'BIG5': - case 'CSBIG5': - return 'Big5'; - - case 'MACINTOSH': - case 'MAC': - case 'CSMACINTOSH': - return 'macintosh'; - - case 'IBM037': - case 'CP037': - case 'EBCDIC-CP-US': - case 'EBCDIC-CP-CA': - case 'EBCDIC-CP-WT': - case 'EBCDIC-CP-NL': - case 'CSIBM037': - return 'IBM037'; - - case 'IBM038': - case 'EBCDIC-INT': - case 'CP038': - case 'CSIBM038': - return 'IBM038'; - - case 'IBM273': - case 'CP273': - case 'CSIBM273': - return 'IBM273'; - - case 'IBM274': - case 'EBCDIC-BE': - case 'CP274': - case 'CSIBM274': - return 'IBM274'; - - case 'IBM275': - case 'EBCDIC-BR': - case 'CP275': - case 'CSIBM275': - return 'IBM275'; - - case 'IBM277': - case 'EBCDIC-CP-DK': - case 'EBCDIC-CP-NO': - case 'CSIBM277': - return 'IBM277'; - - case 'IBM278': - case 'CP278': - case 'EBCDIC-CP-FI': - case 'EBCDIC-CP-SE': - case 'CSIBM278': - return 'IBM278'; - - case 'IBM280': - case 'CP280': - case 'EBCDIC-CP-IT': - case 'CSIBM280': - return 'IBM280'; - - case 'IBM281': - case 'EBCDIC-JP-E': - case 'CP281': - case 'CSIBM281': - return 'IBM281'; - - case 'IBM284': - case 'CP284': - case 'EBCDIC-CP-ES': - case 'CSIBM284': - return 'IBM284'; - - case 'IBM285': - case 'CP285': - case 'EBCDIC-CP-GB': - case 'CSIBM285': - return 'IBM285'; - - case 'IBM290': - case 'CP290': - case 'EBCDIC-JP-KANA': - case 'CSIBM290': - return 'IBM290'; - - case 'IBM297': - case 'CP297': - case 'EBCDIC-CP-FR': - case 'CSIBM297': - return 'IBM297'; - - case 'IBM420': - case 'CP420': - case 'EBCDIC-CP-AR1': - case 'CSIBM420': - return 'IBM420'; - - case 'IBM423': - case 'CP423': - case 'EBCDIC-CP-GR': - case 'CSIBM423': - return 'IBM423'; - - case 'IBM424': - case 'CP424': - case 'EBCDIC-CP-HE': - case 'CSIBM424': - return 'IBM424'; - - case 'IBM437': - case 'CP437': - case '437': - case 'CSPC8CODEPAGE437': - return 'IBM437'; - - case 'IBM500': - case 'CP500': - case 'EBCDIC-CP-BE': - case 'EBCDIC-CP-CH': - case 'CSIBM500': - return 'IBM500'; - - case 'IBM851': - case 'CP851': - case '851': - case 'CSIBM851': - return 'IBM851'; - - case 'IBM852': - case 'CP852': - case '852': - case 'CSPCP852': - return 'IBM852'; - - case 'IBM855': - case 'CP855': - case '855': - case 'CSIBM855': - return 'IBM855'; - - case 'IBM857': - case 'CP857': - case '857': - case 'CSIBM857': - return 'IBM857'; - - case 'IBM860': - case 'CP860': - case '860': - case 'CSIBM860': - return 'IBM860'; - - case 'IBM861': - case 'CP861': - case '861': - case 'CP-IS': - case 'CSIBM861': - return 'IBM861'; - - case 'IBM863': - case 'CP863': - case '863': - case 'CSIBM863': - return 'IBM863'; - - case 'IBM864': - case 'CP864': - case 'CSIBM864': - return 'IBM864'; - - case 'IBM865': - case 'CP865': - case '865': - case 'CSIBM865': - return 'IBM865'; - - case 'IBM868': - case 'CP868': - case 'CP-AR': - case 'CSIBM868': - return 'IBM868'; - - case 'IBM869': - case 'CP869': - case '869': - case 'CP-GR': - case 'CSIBM869': - return 'IBM869'; - - case 'IBM870': - case 'CP870': - case 'EBCDIC-CP-ROECE': - case 'EBCDIC-CP-YU': - case 'CSIBM870': - return 'IBM870'; - - case 'IBM871': - case 'CP871': - case 'EBCDIC-CP-IS': - case 'CSIBM871': - return 'IBM871'; - - case 'IBM880': - case 'CP880': - case 'EBCDIC-CYRILLIC': - case 'CSIBM880': - return 'IBM880'; - - case 'IBM891': - case 'CP891': - case 'CSIBM891': - return 'IBM891'; - - case 'IBM903': - case 'CP903': - case 'CSIBM903': - return 'IBM903'; - - case 'IBM904': - case 'CP904': - case '904': - case 'CSIBBM904': - return 'IBM904'; - - case 'IBM905': - case 'CP905': - case 'EBCDIC-CP-TR': - case 'CSIBM905': - return 'IBM905'; - - case 'IBM918': - case 'CP918': - case 'EBCDIC-CP-AR2': - case 'CSIBM918': - return 'IBM918'; - - case 'IBM1026': - case 'CP1026': - case 'CSIBM1026': - return 'IBM1026'; - - case 'EBCDIC-AT-DE': - case 'CSIBMEBCDICATDE': - return 'EBCDIC-AT-DE'; - - case 'EBCDIC-AT-DE-A': - case 'CSEBCDICATDEA': - return 'EBCDIC-AT-DE-A'; - - case 'EBCDIC-CA-FR': - case 'CSEBCDICCAFR': - return 'EBCDIC-CA-FR'; - - case 'EBCDIC-DK-NO': - case 'CSEBCDICDKNO': - return 'EBCDIC-DK-NO'; - - case 'EBCDIC-DK-NO-A': - case 'CSEBCDICDKNOA': - return 'EBCDIC-DK-NO-A'; - - case 'EBCDIC-FI-SE': - case 'CSEBCDICFISE': - return 'EBCDIC-FI-SE'; - - case 'EBCDIC-FI-SE-A': - case 'CSEBCDICFISEA': - return 'EBCDIC-FI-SE-A'; - - case 'EBCDIC-FR': - case 'CSEBCDICFR': - return 'EBCDIC-FR'; - - case 'EBCDIC-IT': - case 'CSEBCDICIT': - return 'EBCDIC-IT'; - - case 'EBCDIC-PT': - case 'CSEBCDICPT': - return 'EBCDIC-PT'; - - case 'EBCDIC-ES': - case 'CSEBCDICES': - return 'EBCDIC-ES'; - - case 'EBCDIC-ES-A': - case 'CSEBCDICESA': - return 'EBCDIC-ES-A'; - - case 'EBCDIC-ES-S': - case 'CSEBCDICESS': - return 'EBCDIC-ES-S'; - - case 'EBCDIC-UK': - case 'CSEBCDICUK': - return 'EBCDIC-UK'; - - case 'EBCDIC-US': - case 'CSEBCDICUS': - return 'EBCDIC-US'; - - case 'UNKNOWN-8BIT': - case 'CSUNKNOWN8BIT': - return 'UNKNOWN-8BIT'; - - case 'MNEMONIC': - case 'CSMNEMONIC': - return 'MNEMONIC'; - - case 'MNEM': - case 'CSMNEM': - return 'MNEM'; - - case 'VISCII': - case 'CSVISCII': - return 'VISCII'; - - case 'VIQR': - case 'CSVIQR': - return 'VIQR'; - - case 'KOI8-R': - case 'CSKOI8R': - return 'KOI8-R'; - - case 'HZ-GB-2312': - return 'HZ-GB-2312'; - - case 'IBM866': - case 'CP866': - case '866': - case 'CSIBM866': - return 'IBM866'; - - case 'IBM775': - case 'CP775': - case 'CSPC775BALTIC': - return 'IBM775'; - - case 'KOI8-U': - return 'KOI8-U'; - - case 'IBM00858': - case 'CCSID00858': - case 'CP00858': - case 'PC-MULTILINGUAL-850+EURO': - return 'IBM00858'; - - case 'IBM00924': - case 'CCSID00924': - case 'CP00924': - case 'EBCDIC-LATIN9--EURO': - return 'IBM00924'; - - case 'IBM01140': - case 'CCSID01140': - case 'CP01140': - case 'EBCDIC-US-37+EURO': - return 'IBM01140'; - - case 'IBM01141': - case 'CCSID01141': - case 'CP01141': - case 'EBCDIC-DE-273+EURO': - return 'IBM01141'; - - case 'IBM01142': - case 'CCSID01142': - case 'CP01142': - case 'EBCDIC-DK-277+EURO': - case 'EBCDIC-NO-277+EURO': - return 'IBM01142'; - - case 'IBM01143': - case 'CCSID01143': - case 'CP01143': - case 'EBCDIC-FI-278+EURO': - case 'EBCDIC-SE-278+EURO': - return 'IBM01143'; - - case 'IBM01144': - case 'CCSID01144': - case 'CP01144': - case 'EBCDIC-IT-280+EURO': - return 'IBM01144'; - - case 'IBM01145': - case 'CCSID01145': - case 'CP01145': - case 'EBCDIC-ES-284+EURO': - return 'IBM01145'; - - case 'IBM01146': - case 'CCSID01146': - case 'CP01146': - case 'EBCDIC-GB-285+EURO': - return 'IBM01146'; - - case 'IBM01147': - case 'CCSID01147': - case 'CP01147': - case 'EBCDIC-FR-297+EURO': - return 'IBM01147'; - - case 'IBM01148': - case 'CCSID01148': - case 'CP01148': - case 'EBCDIC-INTERNATIONAL-500+EURO': - return 'IBM01148'; - - case 'IBM01149': - case 'CCSID01149': - case 'CP01149': - case 'EBCDIC-IS-871+EURO': - return 'IBM01149'; - - case 'BIG5-HKSCS': - return 'Big5-HKSCS'; - - case 'IBM1047': - case 'IBM-1047': - return 'IBM1047'; - - case 'PTCP154': - case 'CSPTCP154': - case 'PT154': - case 'CP154': - case 'CYRILLIC-ASIAN': - return 'PTCP154'; - - case 'AMIGA-1251': - case 'AMI1251': - case 'AMIGA1251': - case 'AMI-1251': - return 'Amiga-1251'; - - case 'KOI7-SWITCHED': - return 'KOI7-switched'; - - case 'BRF': - case 'CSBRF': - return 'BRF'; - - case 'TSCII': - case 'CSTSCII': - return 'TSCII'; - - case 'WINDOWS-1250': - return 'windows-1250'; - - case 'WINDOWS-1251': - return 'windows-1251'; - - case 'WINDOWS-1252': - return 'windows-1252'; - - case 'WINDOWS-1253': - return 'windows-1253'; - - case 'WINDOWS-1254': - return 'windows-1254'; - - case 'WINDOWS-1255': - return 'windows-1255'; - - case 'WINDOWS-1256': - return 'windows-1256'; - - case 'WINDOWS-1257': - return 'windows-1257'; - - case 'WINDOWS-1258': - return 'windows-1258'; - - default: - return (string) $encoding; - } - } - - function get_curl_version() - { - if (is_array($curl = curl_version())) - { - $curl = $curl['version']; - } - elseif (substr($curl, 0, 5) == 'curl/') - { - $curl = substr($curl, 5, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 5)); - } - elseif (substr($curl, 0, 8) == 'libcurl/') - { - $curl = substr($curl, 8, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 8)); - } - else - { - $curl = 0; - } - return $curl; - } - - function is_subclass_of($class1, $class2) - { - if (func_num_args() != 2) - { - trigger_error('Wrong parameter count for SimplePie_Misc::is_subclass_of()', E_USER_WARNING); - } - elseif (version_compare(PHP_VERSION, '5.0.3', '>=') || is_object($class1)) - { - return is_subclass_of($class1, $class2); - } - elseif (is_string($class1) && is_string($class2)) - { - if (class_exists($class1)) - { - if (class_exists($class2)) - { - $class2 = strtolower($class2); - while ($class1 = strtolower(get_parent_class($class1))) - { - if ($class1 == $class2) - { - return true; - } - } - } - } - else - { - trigger_error('Unknown class passed as parameter', E_USER_WARNNG); - } - } - return false; - } - - /** - * Strip HTML comments - * - * @access public - * @param string $data Data to strip comments from - * @return string Comment stripped string - */ - function strip_comments($data) - { - $output = ''; - while (($start = strpos($data, '', $start)) !== false) - { - $data = substr_replace($data, '', 0, $end + 3); - } - else - { - $data = ''; - } - } - return $output . $data; - } - - function parse_date($dt, $rfc822_tz = true) - { - static $cache = array(); - if (!isset($cache[$dt][$rfc822_tz])) - { - $dt = SimplePie_Misc::uncomment_rfc822($dt); - /* - Capturing subpatterns: - 1: RFC 822 date - 2: RFC 822 day - 3: RFC 822 month - 4: RFC 822 year - 5: ISO 8601 date - 6: ISO 8601 century - 7: ISO 8601 year - 8: ISO 8601 month - 9: ISO 8601 day - 10: ISO 8601 ordinal day - 11: ISO 8601 month - 12: ISO 8601 day - 13: ISO 8601 week - 14: ISO 8601 day of week - 15: Time - 16: Hour - 17: Hour Decimal - 18: Minute - 19: Minute Decimal - 20: Second - 21: Second Decimal - 22: Timezone - 23: Diff ± - 24: Hour - 25: Hour Decimal - 26: Minute - 27: Minute Decimal - 28: Alphabetic Timezone - */ - if (preg_match('/^(?:(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)[,\s]+)?(([0-9]{1,2})\s*(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s*([0-9]{4}|[0-9]{2}))|(([0-9]{2})(?:([0-9]{2})(?:(?:-|\s)*(?:([0-9]{2})([0-9]{2})|([0-9]{3})|([0-9]{2})(?:(?:-|\s)*([0-9]{2}))?|W([0-9]{2})(?:(?:-|\s)*([0-9]))?))?)?))((?:T|\s)+([0-9]{2})(?:(?:,|\.)([0-9]*)|(?:\:|\s)*([0-9]{2})(?:(?:,|\.)([0-9]*)|(?:\:|\s)*([0-9]{2})(?:(?:,|\.)([0-9]*))?)?)?(?:\s)*((?:(\+|-)([0-9]{2})(?:(?:,|\.)([0-9]*)|(?:\:|\s)*(?:([0-9]{2})(?:(?:,|\.)([0-9]*))?))?)|(UTC|GMT|EST|CST|MST|PST|EDT|CDT|MDT|PDT|UT|[A-IK-Z]))?)?$/i', $dt, $match)) - { - // Fill all matches - for ($i = count($match); $i <= 28; $i++) - { - $match[$i] = ''; - } - - // Set blank vars - $year = 1970; - $month = 1; - $day = 1; - $hour = 0; - $minute = 0; - $second = 0; - $timezone = false; - - // RFC 822 - if ($match[1] !== '') - { - if (strlen($match[4]) == 2) - { - $year = ($match[4] < 70) ? "20$match[4]" : "19$match[4]"; - } - else - { - $year = $match[4]; - } - switch (strtolower($match[3])) - { - case 'jan': - $month = 1; - break; - - case 'feb': - $month = 2; - break; - - case 'mar': - $month = 3; - break; - - case 'apr': - $month = 4; - break; - - case 'may': - $month = 5; - break; - - case 'jun': - $month = 6; - break; - - case 'jul': - $month = 7; - break; - - case 'aug': - $month = 8; - break; - - case 'sep': - $month = 9; - break; - - case 'oct': - $month = 10; - break; - - case 'nov': - $month = 11; - break; - - case 'dec': - $month = 12; - break; - } - $day = $match[2]; - } - // ISO 8601 - else - { - // Year - if ($match[7] !== '') - { - $year = "$match[6]$match[7]"; - - // Two Digit Month/Day - if ($match[11] !== '') - { - $month = $match[11]; - if ($match[12] !== '') - { - $day = $match[12]; - } - } - - // Four Digit Month/Day - elseif ($match[8] !== '') - { - $month = $match[8]; - $day = $match[9]; - } - - // Ordinal Day - elseif ($match[10] !== '') - { - $day = $match[10]; - } - - // Week Date - elseif ($match[13] !== '') - { - // Week Day - if ($match[14] !== '') - { - $day = $match[14]; - } - - $first_day_of_year = date('w', mktime(0, 0, 0, 1, 1, $year)); - if ($first_day_of_year == 0) - { - $first_day_of_year = 7; - } - - $day = 7 * ($match[13] - 1) + $day - ($first_day_of_year - 1); - } - } - else - { - $year = "$match[6]00"; - } - } - // Time - if ($match[15] !== '') - { - $time = 0; - $time += ($match[16] + ('.' . $match[17])) * 3600; - $time += ($match[18] + ('.' . $match[19])) * 60; - $time += $match[20] + ('.' . $match[21]); - $hour = floor($time / 3600); - $time -= $hour * 3600; - $minute = floor($time / 60); - $time -= $minute * 60; - $second = round($time); - - // Timezone - if ($match[22] !== '') - { - // Alphabetic Timezone - if ($match[28] !== '') - { - // Military - if (strlen($match[28]) == 1) - { - if ($match[28] == 'Z' || $match[28] == 'z' || !$rfc822_tz) - { - $timezone = 0; - } - else - { - $timezone = ord(strtoupper($match[28])); - - if ($timezone > 74) - { - $timezone--; - } - - if ($timezone <= 76) - { - $timezone = -($timezone - 64); - } - else - { - $timezone -= 76; - } - - $timezone *= 3600; - } - } - // Code - else - { - switch (strtoupper($match[28])) - { - case 'UT': - case 'UTC': - case 'GMT': - $timezone = 0; - break; - - case 'EST': - $timezone = -18000; - break; - - case 'CST': - $timezone = -21600; - break; - - case 'MST': - $timezone = -25200; - break; - - case 'PST': - $timezone = -28800; - break; - - case 'EDT': - $timezone = -14400; - break; - - case 'CDT': - $timezone = -18000; - break; - - case 'MDT': - $timezone = -21600; - break; - - case 'PDT': - $timezone = -25200; - break; - } - } - } - // Timezone difference from UTC - else - { - $timezone = 0; - $timezone += ($match[24] + ('.' . $match[25])) * 3600; - $timezone += ($match[26] + ('.' . $match[27])) * 60; - $timezone = (int) round($timezone); - - if ($match[23] == '-') - { - $timezone = -$timezone; - } - } - } - } - if ($timezone === false) - { - $cache[$dt][$rfc822_tz] = mktime($hour, $minute, $second, $month, $day, $year); - } - else - { - $cache[$dt][$rfc822_tz] = gmmktime($hour, $minute, $second, $month, $day, $year) - $timezone; - } - } - elseif (($time = strtotime($dt)) > 0) - { - $cache[$dt][$rfc822_tz] = $time; - } - else - { - $cache[$dt][$rfc822_tz] = false; - } - } - return $cache[$dt][$rfc822_tz]; - } - - /** - * Decode HTML entities - * - * @static - * @access public - * @param string $data Input data - * @return string Output data - */ - function entities_decode($data) - { - $decoder = new SimplePie_Decode_HTML_Entities($data); - return $decoder->parse(); - } - - /** - * Remove RFC822 comments - * - * @author Tomas V.V.Cox - * @author Pierre-Alain Joye - * @author Amir Mohammad Saied - * @copyright 1997-2006 Pierre-Alain Joye,Tomas V.V.Cox,Amir Mohammad Saied - * @license http://www.opensource.org/licenses/bsd-license.php New BSD License - * @version CVS: $Id: simplepie.php 10381 2008-06-01 03:35:53Z pasamio $ - * @link http://pear.php.net/package/Validate - * @access public - * @param string $data Data to strip comments from - * @return string Comment stripped string - */ - function uncomment_rfc822($data) - { - if ((version_compare(PHP_VERSION, '4.4.6', '>=') && version_compare(PHP_VERSION, '5', '<')) || version_compare(PHP_VERSION, '5.2.2', '>=')) - { - return $data; - } - else - { - return preg_replace('/((?:(?:\\\\"|[^("])*(?:"(?:[^"\\\\\r]|\\\\.)*"\s*)?)*)((?=')) - { - return array_unique($array); - } - else - { - $array = (array) $array; - $new_array = array(); - $new_array_strings = array(); - foreach ($array as $key => $value) - { - if (is_object($value)) - { - if (method_exists($value, '__toString')) - { - $cmp = $value->__toString(); - } - else - { - trigger_error('Object of class ' . get_class($value) . ' could not be converted to string', E_USER_ERROR); - } - } - elseif (is_array($value)) - { - $cmp = (string) reset($value); - } - else - { - $cmp = (string) $value; - } - if (!in_array($cmp, $new_array_strings)) - { - $new_array[$key] = $value; - $new_array_strings[] = $cmp; - } - } - return $new_array; - } - } - - /** - * Converts a unicode codepoint to a UTF-8 character - * - * @static - * @access public - * @param int $codepoint Unicode codepoint - * @return string UTF-8 character - */ - function codepoint_to_utf8($codepoint) - { - static $cache = array(); - $codepoint = (int) $codepoint; - if (isset($cache[$codepoint])) - { - return $cache[$codepoint]; - } - elseif ($codepoint < 0) - { - return $cache[$codepoint] = false; - } - else if ($codepoint <= 0x7f) - { - return $cache[$codepoint] = chr($codepoint); - } - else if ($codepoint <= 0x7ff) - { - return $cache[$codepoint] = chr(0xc0 | ($codepoint >> 6)) . chr(0x80 | ($codepoint & 0x3f)); - } - else if ($codepoint <= 0xffff) - { - return $cache[$codepoint] = chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); - } - else if ($codepoint <= 0x10ffff) - { - return $cache[$codepoint] = chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); - } - else - { - // U+FFFD REPLACEMENT CHARACTER - return $cache[$codepoint] = "\xEF\xBF\xBD"; - } - } - - /** - * Re-implementation of PHP 4.2.0's is_a() - * - * @static - * @access public - * @param object $object The tested object - * @param string $class_name The class name - * @return bool Returns true if the object is of this class or has this class as one of its parents, false otherwise - */ - function is_a($object, $class_name) - { - if (function_exists('is_a')) - { - return is_a($object, $class_name); - } - elseif (!is_object($object)) - { - return false; - } - elseif (get_class($object) == strtolower($class_name)) - { - return true; - } - else - { - return is_subclass_of($object, $class_name); - } - } - - /** - * Re-implementation of PHP 5's stripos() - * - * Returns the numeric position of the first occurrence of needle in the - * haystack string. - * - * @static - * @access string - * @param object $haystack - * @param string $needle Note that the needle may be a string of one or more - * characters. If needle is not a string, it is converted to an integer - * and applied as the ordinal value of a character. - * @param int $offset The optional offset parameter allows you to specify which - * character in haystack to start searching. The position returned is still - * relative to the beginning of haystack. - * @return bool If needle is not found, stripos() will return boolean false. - */ - function stripos($haystack, $needle, $offset = 0) - { - if (function_exists('stripos')) - { - return stripos($haystack, $needle, $offset); - } - else - { - if (is_string($needle)) - { - $needle = strtolower($needle); - } - elseif (is_int($needle) || is_bool($needle) || is_double($needle)) - { - $needle = strtolower(chr($needle)); - } - else - { - trigger_error('needle is not a string or an integer', E_USER_WARNING); - return false; - } - - return strpos(strtolower($haystack), $needle, $offset); - } - } -} - -/** - * Decode HTML Entities - * - * This implements HTML5 as of revision 967 (2007-06-28) - * - * @package SimplePie - */ -class SimplePie_Decode_HTML_Entities -{ - /** - * Data to be parsed - * - * @access private - * @var string - */ - var $data = ''; - - /** - * Currently consumed bytes - * - * @access private - * @var string - */ - var $consumed = ''; - - /** - * Position of the current byte being parsed - * - * @access private - * @var int - */ - var $position = 0; - - /** - * Create an instance of the class with the input data - * - * @access public - * @param string $data Input data - */ - function SimplePie_Decode_HTML_Entities($data) - { - $this->data = $data; - } - - /** - * Parse the input data - * - * @access public - * @return string Output data - */ - function parse() - { - while (($this->position = strpos($this->data, '&', $this->position)) !== false) - { - $this->consume(); - $this->entity(); - $this->consumed = ''; - } - return $this->data; - } - - /** - * Consume the next byte - * - * @access private - * @return mixed The next byte, or false, if there is no more data - */ - function consume() - { - if (isset($this->data[$this->position])) - { - $this->consumed .= $this->data[$this->position]; - return $this->data[$this->position++]; - } - else - { - $this->consumed = false; - return false; - } - } - - /** - * Consume a range of characters - * - * @access private - * @param string $chars Characters to consume - * @return mixed A series of characters that match the range, or false - */ - function consume_range($chars) - { - if ($len = strspn($this->data, $chars, $this->position)) - { - $data = substr($this->data, $this->position, $len); - $this->consumed .= $data; - $this->position += $len; - return $data; - } - else - { - $this->consumed = false; - return false; - } - } - - /** - * Unconsume one byte - * - * @access private - */ - function unconsume() - { - $this->consumed = substr($this->consumed, 0, -1); - $this->position--; - } - - /** - * Decode an entity - * - * @access private - */ - function entity() - { - switch ($this->consume()) - { - case "\x09": - case "\x0A": - case "\x0B": - case "\x0B": - case "\x0C": - case "\x20": - case "\x3C": - case "\x26": - case false: - break; - - case "\x23": - switch ($this->consume()) - { - case "\x78": - case "\x58": - $range = '0123456789ABCDEFabcdef'; - $hex = true; - break; - - default: - $range = '0123456789'; - $hex = false; - $this->unconsume(); - break; - } - - if ($codepoint = $this->consume_range($range)) - { - static $windows_1252_specials = array(0x0D => "\x0A", 0x80 => "\xE2\x82\xAC", 0x81 => "\xEF\xBF\xBD", 0x82 => "\xE2\x80\x9A", 0x83 => "\xC6\x92", 0x84 => "\xE2\x80\x9E", 0x85 => "\xE2\x80\xA6", 0x86 => "\xE2\x80\xA0", 0x87 => "\xE2\x80\xA1", 0x88 => "\xCB\x86", 0x89 => "\xE2\x80\xB0", 0x8A => "\xC5\xA0", 0x8B => "\xE2\x80\xB9", 0x8C => "\xC5\x92", 0x8D => "\xEF\xBF\xBD", 0x8E => "\xC5\xBD", 0x8F => "\xEF\xBF\xBD", 0x90 => "\xEF\xBF\xBD", 0x91 => "\xE2\x80\x98", 0x92 => "\xE2\x80\x99", 0x93 => "\xE2\x80\x9C", 0x94 => "\xE2\x80\x9D", 0x95 => "\xE2\x80\xA2", 0x96 => "\xE2\x80\x93", 0x97 => "\xE2\x80\x94", 0x98 => "\xCB\x9C", 0x99 => "\xE2\x84\xA2", 0x9A => "\xC5\xA1", 0x9B => "\xE2\x80\xBA", 0x9C => "\xC5\x93", 0x9D => "\xEF\xBF\xBD", 0x9E => "\xC5\xBE", 0x9F => "\xC5\xB8"); - - if ($hex) - { - $codepoint = hexdec($codepoint); - } - else - { - $codepoint = intval($codepoint); - } - - if (isset($windows_1252_specials[$codepoint])) - { - $replacement = $windows_1252_specials[$codepoint]; - } - else - { - $replacement = SimplePie_Misc::codepoint_to_utf8($codepoint); - } - - if ($this->consume() != ';') - { - $this->unconsume(); - } - - $consumed_length = strlen($this->consumed); - $this->data = substr_replace($this->data, $replacement, $this->position - $consumed_length, $consumed_length); - $this->position += strlen($replacement) - $consumed_length; - } - break; - - default: - static $entities = array('Aacute' => "\xC3\x81", 'aacute' => "\xC3\xA1", 'Aacute;' => "\xC3\x81", 'aacute;' => "\xC3\xA1", 'Acirc' => "\xC3\x82", 'acirc' => "\xC3\xA2", 'Acirc;' => "\xC3\x82", 'acirc;' => "\xC3\xA2", 'acute' => "\xC2\xB4", 'acute;' => "\xC2\xB4", 'AElig' => "\xC3\x86", 'aelig' => "\xC3\xA6", 'AElig;' => "\xC3\x86", 'aelig;' => "\xC3\xA6", 'Agrave' => "\xC3\x80", 'agrave' => "\xC3\xA0", 'Agrave;' => "\xC3\x80", 'agrave;' => "\xC3\xA0", 'alefsym;' => "\xE2\x84\xB5", 'Alpha;' => "\xCE\x91", 'alpha;' => "\xCE\xB1", 'AMP' => "\x26", 'amp' => "\x26", 'AMP;' => "\x26", 'amp;' => "\x26", 'and;' => "\xE2\x88\xA7", 'ang;' => "\xE2\x88\xA0", 'apos;' => "\x27", 'Aring' => "\xC3\x85", 'aring' => "\xC3\xA5", 'Aring;' => "\xC3\x85", 'aring;' => "\xC3\xA5", 'asymp;' => "\xE2\x89\x88", 'Atilde' => "\xC3\x83", 'atilde' => "\xC3\xA3", 'Atilde;' => "\xC3\x83", 'atilde;' => "\xC3\xA3", 'Auml' => "\xC3\x84", 'auml' => "\xC3\xA4", 'Auml;' => "\xC3\x84", 'auml;' => "\xC3\xA4", 'bdquo;' => "\xE2\x80\x9E", 'Beta;' => "\xCE\x92", 'beta;' => "\xCE\xB2", 'brvbar' => "\xC2\xA6", 'brvbar;' => "\xC2\xA6", 'bull;' => "\xE2\x80\xA2", 'cap;' => "\xE2\x88\xA9", 'Ccedil' => "\xC3\x87", 'ccedil' => "\xC3\xA7", 'Ccedil;' => "\xC3\x87", 'ccedil;' => "\xC3\xA7", 'cedil' => "\xC2\xB8", 'cedil;' => "\xC2\xB8", 'cent' => "\xC2\xA2", 'cent;' => "\xC2\xA2", 'Chi;' => "\xCE\xA7", 'chi;' => "\xCF\x87", 'circ;' => "\xCB\x86", 'clubs;' => "\xE2\x99\xA3", 'cong;' => "\xE2\x89\x85", 'COPY' => "\xC2\xA9", 'copy' => "\xC2\xA9", 'COPY;' => "\xC2\xA9", 'copy;' => "\xC2\xA9", 'crarr;' => "\xE2\x86\xB5", 'cup;' => "\xE2\x88\xAA", 'curren' => "\xC2\xA4", 'curren;' => "\xC2\xA4", 'Dagger;' => "\xE2\x80\xA1", 'dagger;' => "\xE2\x80\xA0", 'dArr;' => "\xE2\x87\x93", 'darr;' => "\xE2\x86\x93", 'deg' => "\xC2\xB0", 'deg;' => "\xC2\xB0", 'Delta;' => "\xCE\x94", 'delta;' => "\xCE\xB4", 'diams;' => "\xE2\x99\xA6", 'divide' => "\xC3\xB7", 'divide;' => "\xC3\xB7", 'Eacute' => "\xC3\x89", 'eacute' => "\xC3\xA9", 'Eacute;' => "\xC3\x89", 'eacute;' => "\xC3\xA9", 'Ecirc' => "\xC3\x8A", 'ecirc' => "\xC3\xAA", 'Ecirc;' => "\xC3\x8A", 'ecirc;' => "\xC3\xAA", 'Egrave' => "\xC3\x88", 'egrave' => "\xC3\xA8", 'Egrave;' => "\xC3\x88", 'egrave;' => "\xC3\xA8", 'empty;' => "\xE2\x88\x85", 'emsp;' => "\xE2\x80\x83", 'ensp;' => "\xE2\x80\x82", 'Epsilon;' => "\xCE\x95", 'epsilon;' => "\xCE\xB5", 'equiv;' => "\xE2\x89\xA1", 'Eta;' => "\xCE\x97", 'eta;' => "\xCE\xB7", 'ETH' => "\xC3\x90", 'eth' => "\xC3\xB0", 'ETH;' => "\xC3\x90", 'eth;' => "\xC3\xB0", 'Euml' => "\xC3\x8B", 'euml' => "\xC3\xAB", 'Euml;' => "\xC3\x8B", 'euml;' => "\xC3\xAB", 'euro;' => "\xE2\x82\xAC", 'exist;' => "\xE2\x88\x83", 'fnof;' => "\xC6\x92", 'forall;' => "\xE2\x88\x80", 'frac12' => "\xC2\xBD", 'frac12;' => "\xC2\xBD", 'frac14' => "\xC2\xBC", 'frac14;' => "\xC2\xBC", 'frac34' => "\xC2\xBE", 'frac34;' => "\xC2\xBE", 'frasl;' => "\xE2\x81\x84", 'Gamma;' => "\xCE\x93", 'gamma;' => "\xCE\xB3", 'ge;' => "\xE2\x89\xA5", 'GT' => "\x3E", 'gt' => "\x3E", 'GT;' => "\x3E", 'gt;' => "\x3E", 'hArr;' => "\xE2\x87\x94", 'harr;' => "\xE2\x86\x94", 'hearts;' => "\xE2\x99\xA5", 'hellip;' => "\xE2\x80\xA6", 'Iacute' => "\xC3\x8D", 'iacute' => "\xC3\xAD", 'Iacute;' => "\xC3\x8D", 'iacute;' => "\xC3\xAD", 'Icirc' => "\xC3\x8E", 'icirc' => "\xC3\xAE", 'Icirc;' => "\xC3\x8E", 'icirc;' => "\xC3\xAE", 'iexcl' => "\xC2\xA1", 'iexcl;' => "\xC2\xA1", 'Igrave' => "\xC3\x8C", 'igrave' => "\xC3\xAC", 'Igrave;' => "\xC3\x8C", 'igrave;' => "\xC3\xAC", 'image;' => "\xE2\x84\x91", 'infin;' => "\xE2\x88\x9E", 'int;' => "\xE2\x88\xAB", 'Iota;' => "\xCE\x99", 'iota;' => "\xCE\xB9", 'iquest' => "\xC2\xBF", 'iquest;' => "\xC2\xBF", 'isin;' => "\xE2\x88\x88", 'Iuml' => "\xC3\x8F", 'iuml' => "\xC3\xAF", 'Iuml;' => "\xC3\x8F", 'iuml;' => "\xC3\xAF", 'Kappa;' => "\xCE\x9A", 'kappa;' => "\xCE\xBA", 'Lambda;' => "\xCE\x9B", 'lambda;' => "\xCE\xBB", 'lang;' => "\xE3\x80\x88", 'laquo' => "\xC2\xAB", 'laquo;' => "\xC2\xAB", 'lArr;' => "\xE2\x87\x90", 'larr;' => "\xE2\x86\x90", 'lceil;' => "\xE2\x8C\x88", 'ldquo;' => "\xE2\x80\x9C", 'le;' => "\xE2\x89\xA4", 'lfloor;' => "\xE2\x8C\x8A", 'lowast;' => "\xE2\x88\x97", 'loz;' => "\xE2\x97\x8A", 'lrm;' => "\xE2\x80\x8E", 'lsaquo;' => "\xE2\x80\xB9", 'lsquo;' => "\xE2\x80\x98", 'LT' => "\x3C", 'lt' => "\x3C", 'LT;' => "\x3C", 'lt;' => "\x3C", 'macr' => "\xC2\xAF", 'macr;' => "\xC2\xAF", 'mdash;' => "\xE2\x80\x94", 'micro' => "\xC2\xB5", 'micro;' => "\xC2\xB5", 'middot' => "\xC2\xB7", 'middot;' => "\xC2\xB7", 'minus;' => "\xE2\x88\x92", 'Mu;' => "\xCE\x9C", 'mu;' => "\xCE\xBC", 'nabla;' => "\xE2\x88\x87", 'nbsp' => "\xC2\xA0", 'nbsp;' => "\xC2\xA0", 'ndash;' => "\xE2\x80\x93", 'ne;' => "\xE2\x89\xA0", 'ni;' => "\xE2\x88\x8B", 'not' => "\xC2\xAC", 'not;' => "\xC2\xAC", 'notin;' => "\xE2\x88\x89", 'nsub;' => "\xE2\x8A\x84", 'Ntilde' => "\xC3\x91", 'ntilde' => "\xC3\xB1", 'Ntilde;' => "\xC3\x91", 'ntilde;' => "\xC3\xB1", 'Nu;' => "\xCE\x9D", 'nu;' => "\xCE\xBD", 'Oacute' => "\xC3\x93", 'oacute' => "\xC3\xB3", 'Oacute;' => "\xC3\x93", 'oacute;' => "\xC3\xB3", 'Ocirc' => "\xC3\x94", 'ocirc' => "\xC3\xB4", 'Ocirc;' => "\xC3\x94", 'ocirc;' => "\xC3\xB4", 'OElig;' => "\xC5\x92", 'oelig;' => "\xC5\x93", 'Ograve' => "\xC3\x92", 'ograve' => "\xC3\xB2", 'Ograve;' => "\xC3\x92", 'ograve;' => "\xC3\xB2", 'oline;' => "\xE2\x80\xBE", 'Omega;' => "\xCE\xA9", 'omega;' => "\xCF\x89", 'Omicron;' => "\xCE\x9F", 'omicron;' => "\xCE\xBF", 'oplus;' => "\xE2\x8A\x95", 'or;' => "\xE2\x88\xA8", 'ordf' => "\xC2\xAA", 'ordf;' => "\xC2\xAA", 'ordm' => "\xC2\xBA", 'ordm;' => "\xC2\xBA", 'Oslash' => "\xC3\x98", 'oslash' => "\xC3\xB8", 'Oslash;' => "\xC3\x98", 'oslash;' => "\xC3\xB8", 'Otilde' => "\xC3\x95", 'otilde' => "\xC3\xB5", 'Otilde;' => "\xC3\x95", 'otilde;' => "\xC3\xB5", 'otimes;' => "\xE2\x8A\x97", 'Ouml' => "\xC3\x96", 'ouml' => "\xC3\xB6", 'Ouml;' => "\xC3\x96", 'ouml;' => "\xC3\xB6", 'para' => "\xC2\xB6", 'para;' => "\xC2\xB6", 'part;' => "\xE2\x88\x82", 'permil;' => "\xE2\x80\xB0", 'perp;' => "\xE2\x8A\xA5", 'Phi;' => "\xCE\xA6", 'phi;' => "\xCF\x86", 'Pi;' => "\xCE\xA0", 'pi;' => "\xCF\x80", 'piv;' => "\xCF\x96", 'plusmn' => "\xC2\xB1", 'plusmn;' => "\xC2\xB1", 'pound' => "\xC2\xA3", 'pound;' => "\xC2\xA3", 'Prime;' => "\xE2\x80\xB3", 'prime;' => "\xE2\x80\xB2", 'prod;' => "\xE2\x88\x8F", 'prop;' => "\xE2\x88\x9D", 'Psi;' => "\xCE\xA8", 'psi;' => "\xCF\x88", 'QUOT' => "\x22", 'quot' => "\x22", 'QUOT;' => "\x22", 'quot;' => "\x22", 'radic;' => "\xE2\x88\x9A", 'rang;' => "\xE3\x80\x89", 'raquo' => "\xC2\xBB", 'raquo;' => "\xC2\xBB", 'rArr;' => "\xE2\x87\x92", 'rarr;' => "\xE2\x86\x92", 'rceil;' => "\xE2\x8C\x89", 'rdquo;' => "\xE2\x80\x9D", 'real;' => "\xE2\x84\x9C", 'REG' => "\xC2\xAE", 'reg' => "\xC2\xAE", 'REG;' => "\xC2\xAE", 'reg;' => "\xC2\xAE", 'rfloor;' => "\xE2\x8C\x8B", 'Rho;' => "\xCE\xA1", 'rho;' => "\xCF\x81", 'rlm;' => "\xE2\x80\x8F", 'rsaquo;' => "\xE2\x80\xBA", 'rsquo;' => "\xE2\x80\x99", 'sbquo;' => "\xE2\x80\x9A", 'Scaron;' => "\xC5\xA0", 'scaron;' => "\xC5\xA1", 'sdot;' => "\xE2\x8B\x85", 'sect' => "\xC2\xA7", 'sect;' => "\xC2\xA7", 'shy' => "\xC2\xAD", 'shy;' => "\xC2\xAD", 'Sigma;' => "\xCE\xA3", 'sigma;' => "\xCF\x83", 'sigmaf;' => "\xCF\x82", 'sim;' => "\xE2\x88\xBC", 'spades;' => "\xE2\x99\xA0", 'sub;' => "\xE2\x8A\x82", 'sube;' => "\xE2\x8A\x86", 'sum;' => "\xE2\x88\x91", 'sup;' => "\xE2\x8A\x83", 'sup1' => "\xC2\xB9", 'sup1;' => "\xC2\xB9", 'sup2' => "\xC2\xB2", 'sup2;' => "\xC2\xB2", 'sup3' => "\xC2\xB3", 'sup3;' => "\xC2\xB3", 'supe;' => "\xE2\x8A\x87", 'szlig' => "\xC3\x9F", 'szlig;' => "\xC3\x9F", 'Tau;' => "\xCE\xA4", 'tau;' => "\xCF\x84", 'there4;' => "\xE2\x88\xB4", 'Theta;' => "\xCE\x98", 'theta;' => "\xCE\xB8", 'thetasym;' => "\xCF\x91", 'thinsp;' => "\xE2\x80\x89", 'THORN' => "\xC3\x9E", 'thorn' => "\xC3\xBE", 'THORN;' => "\xC3\x9E", 'thorn;' => "\xC3\xBE", 'tilde;' => "\xCB\x9C", 'times' => "\xC3\x97", 'times;' => "\xC3\x97", 'TRADE;' => "\xE2\x84\xA2", 'trade;' => "\xE2\x84\xA2", 'Uacute' => "\xC3\x9A", 'uacute' => "\xC3\xBA", 'Uacute;' => "\xC3\x9A", 'uacute;' => "\xC3\xBA", 'uArr;' => "\xE2\x87\x91", 'uarr;' => "\xE2\x86\x91", 'Ucirc' => "\xC3\x9B", 'ucirc' => "\xC3\xBB", 'Ucirc;' => "\xC3\x9B", 'ucirc;' => "\xC3\xBB", 'Ugrave' => "\xC3\x99", 'ugrave' => "\xC3\xB9", 'Ugrave;' => "\xC3\x99", 'ugrave;' => "\xC3\xB9", 'uml' => "\xC2\xA8", 'uml;' => "\xC2\xA8", 'upsih;' => "\xCF\x92", 'Upsilon;' => "\xCE\xA5", 'upsilon;' => "\xCF\x85", 'Uuml' => "\xC3\x9C", 'uuml' => "\xC3\xBC", 'Uuml;' => "\xC3\x9C", 'uuml;' => "\xC3\xBC", 'weierp;' => "\xE2\x84\x98", 'Xi;' => "\xCE\x9E", 'xi;' => "\xCE\xBE", 'Yacute' => "\xC3\x9D", 'yacute' => "\xC3\xBD", 'Yacute;' => "\xC3\x9D", 'yacute;' => "\xC3\xBD", 'yen' => "\xC2\xA5", 'yen;' => "\xC2\xA5", 'yuml' => "\xC3\xBF", 'Yuml;' => "\xC5\xB8", 'yuml;' => "\xC3\xBF", 'Zeta;' => "\xCE\x96", 'zeta;' => "\xCE\xB6", 'zwj;' => "\xE2\x80\x8D", 'zwnj;' => "\xE2\x80\x8C"); - - for ($i = 0, $match = null; $i < 9 && $this->consume(); $i++) - { - $consumed = substr($this->consumed, 1); - if (isset($entities[$consumed])) - { - $match = $consumed; - } - } - - if ($match !== null) - { - $this->data = substr_replace($this->data, $entities[$match], $this->position - strlen($consumed) - 1, strlen($match) + 1); - $this->position += strlen($entities[$match]) - strlen($consumed) - 1; - } - break; - } - } -} - -class SimplePie_Locator -{ - var $useragent; - var $timeout; - var $file; - var $local = array(); - var $elsewhere = array(); - var $file_class = 'SimplePie_File'; - var $cached_entities = array(); - var $http_base; - var $base; - var $base_location = 0; - var $checked_feeds = 0; - var $max_checked_feeds = 10; - - function SimplePie_Locator(&$file, $timeout = 10, $useragent = null, $file_class = 'SimplePie_File', $max_checked_feeds = 10) - { - $this->file =& $file; - $this->file_class = $file_class; - $this->useragent = $useragent; - $this->timeout = $timeout; - $this->max_checked_feeds = $max_checked_feeds; - } - - function find($type = SIMPLEPIE_LOCATOR_ALL) - { - if ($this->is_feed($this->file)) - { - return $this->file; - } - - if ($type & ~SIMPLEPIE_LOCATOR_NONE) - { - $this->get_base(); - } - - if ($type & SIMPLEPIE_LOCATOR_AUTODISCOVERY && $working = $this->autodiscovery()) - { - return $working; - } - - if ($type & (SIMPLEPIE_LOCATOR_LOCAL_EXTENSION | SIMPLEPIE_LOCATOR_LOCAL_BODY | SIMPLEPIE_LOCATOR_REMOTE_EXTENSION | SIMPLEPIE_LOCATOR_REMOTE_BODY) && $this->get_links()) - { - if ($type & SIMPLEPIE_LOCATOR_LOCAL_EXTENSION && $working = $this->extension($this->local)) - { - return $working; - } - - if ($type & SIMPLEPIE_LOCATOR_LOCAL_BODY && $working = $this->body($this->local)) - { - return $working; - } - - if ($type & SIMPLEPIE_LOCATOR_REMOTE_EXTENSION && $working = $this->extension($this->elsewhere)) - { - return $working; - } - - if ($type & SIMPLEPIE_LOCATOR_REMOTE_BODY && $working = $this->body($this->elsewhere)) - { - return $working; - } - } - return null; - } - - function is_feed(&$file) - { - $body = SimplePie_Misc::strip_comments($file->body); - if (preg_match('/<([^\s:]+:)?(rss|RDF|feed)' . SIMPLEPIE_PCRE_XML_ATTRIBUTE . '>/i', $body)) - { - return true; - } - return false; - } - - function get_base() - { - if (isset($this->file->headers['content-location'])) - { - $this->http_base = SimplePie_Misc::absolutize_url(trim($this->file->headers['content-location']), $this->file->url); - } - else - { - $this->http_base = $this->file->url; - } - $this->base = $this->http_base; - $elements = SimplePie_Misc::get_element('base', $this->file->body); - foreach ($elements as $element) - { - if ($element['attribs']['href']['data'] !== '') - { - $this->base = SimplePie_Misc::absolutize_url(trim($element['attribs']['href']['data']), $this->http_base); - $this->base_location = $element['offset']; - break; - } - } - } - - function autodiscovery() - { - $links = array_merge(SimplePie_Misc::get_element('link', $this->file->body), SimplePie_Misc::get_element('a', $this->file->body), SimplePie_Misc::get_element('area', $this->file->body)); - $done = array(); - foreach ($links as $link) - { - if ($this->checked_feeds == $this->max_checked_feeds) - { - break; - } - if (isset($link['attribs']['href']['data']) && isset($link['attribs']['rel']['data'])) - { - $rel = array_unique(SimplePie_Misc::space_seperated_tokens(strtolower($link['attribs']['rel']['data']))); - - if ($this->base_location < $link['offset']) - { - $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->base); - } - else - { - $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->http_base); - } - - if (!in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && !empty($link['attribs']['type']['data']) && in_array(strtolower(SimplePie_Misc::parse_mime($link['attribs']['type']['data'])), array('application/rss+xml', 'application/atom+xml')))) - { - $this->checked_feeds++; - $feed =& new $this->file_class($href, $this->timeout, 5, null, $this->useragent); - if ($this->is_feed($feed)) - { - return $feed; - } - } - $done[] = $href; - } - } - return null; - } - - function get_links() - { - $links = SimplePie_Misc::get_element('a', $this->file->body); - foreach ($links as $link) - { - if (isset($link['attribs']['href']['data'])) - { - $href = trim($link['attribs']['href']['data']); - $parsed = SimplePie_Misc::parse_url($href); - if ($parsed['scheme'] === '' || preg_match('/^(http(s)|feed)?$/i', $parsed['scheme'])) - { - if ($this->base_location < $link['offset']) - { - $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->base); - } - else - { - $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->http_base); - } - - $current = SimplePie_Misc::parse_url($this->file->url); - - if ($parsed['authority'] === '' || $parsed['authority'] == $current['authority']) - { - $this->local[] = $href; - } - else - { - $this->elsewhere[] = $href; - } - } - } - } - $this->local = array_unique($this->local); - $this->elsewhere = array_unique($this->elsewhere); - if (!empty($this->local) || !empty($this->elsewhere)) - { - return true; - } - return null; - } - - function extension(&$array) - { - foreach ($array as $key => $value) - { - if ($this->checked_feeds == $this->max_checked_feeds) - { - break; - } - if (in_array(strtolower(strrchr($value, '.')), array('.rss', '.rdf', '.atom', '.xml'))) - { - $this->checked_feeds++; - $feed =& new $this->file_class($value, $this->timeout, 5, null, $this->useragent); - if ($this->is_feed($feed)) - { - return $feed; - } - else - { - unset($array[$key]); - } - } - } - return null; - } - - function body(&$array) - { - foreach ($array as $key => $value) - { - if ($this->checked_feeds == $this->max_checked_feeds) - { - break; - } - if (preg_match('/(rss|rdf|atom|xml)/i', $value)) - { - $this->checked_feeds++; - $feed =& new $this->file_class($value, $this->timeout, 5, null, $this->useragent); - if ($this->is_feed($feed)) - { - return $feed; - } - else - { - unset($array[$key]); - } - } - } - return null; - } -} - -class SimplePie_Parser -{ - var $xml; - var $error_code; - var $error_string; - var $current_line; - var $current_column; - var $current_byte; - var $separator = ' '; - var $feed = false; - var $namespace = array(''); - var $element = array(''); - var $xml_base = array(''); - var $xml_base_explicit = array(false); - var $xml_lang = array(''); - var $data = array(); - var $datas = array(array()); - var $current_xhtml_construct = -1; - var $encoding; - - function pre_process(&$data, $encoding) - { - // Use UTF-8 if we get passed US-ASCII, as every US-ASCII character is a UTF-8 character - if (strtoupper($encoding) == 'US-ASCII') - { - $this->encoding = 'UTF-8'; - } - else - { - $this->encoding = $encoding; - } - - // Strip BOM: - // UTF-32 Big Endian BOM - if (strpos($data, "\x0\x0\xFE\xFF") === 0) - { - $data = substr($data, 4); - } - // UTF-32 Little Endian BOM - elseif (strpos($data, "\xFF\xFE\x0\x0") === 0) - { - $data = substr($data, 4); - } - // UTF-16 Big Endian BOM - elseif (strpos($data, "\xFE\xFF") === 0) - { - $data = substr($data, 2); - } - // UTF-16 Little Endian BOM - elseif (strpos($data, "\xFF\xFE") === 0) - { - $data = substr($data, 2); - } - // UTF-8 BOM - elseif (strpos($data, "\xEF\xBB\xBF") === 0) - { - $data = substr($data, 3); - } - - // Make sure the XML prolog is sane and has the correct encoding - $data = preg_replace("/^<\?xml[\x20\x9\xD\xA]+version([\x20\x9\xD\xA]+)?=([\x20\x9\xD\xA]+)?(\"1.0\"|'1.0'|\"1.1\"|'1.1')([\x20\x9\xD\xA]+encoding([\x20\x9\xD\xA]+)?=([\x20\x9\xD\xA]+)?(\"[A-Za-z][A-Za-z0-9._\-]*\"|'[A-Za-z][A-Za-z0-9._\-]*'))?([\x20\x9\xD\xA]+standalone([\x20\x9\xD\xA]+)?=([\x20\x9\xD\xA]+)?(\"(yes|no)\"|'(yes|no)'))?([\x20\x9\xD\xA]+)?\?>/", '', $data); - $data = "\n" . $data; - } - - function parse(&$data) - { - $return = true; - - // Create the parser - $this->xml = xml_parser_create_ns($this->encoding, $this->separator); - xml_parser_set_option($this->xml, XML_OPTION_SKIP_WHITE, 1); - xml_parser_set_option($this->xml, XML_OPTION_CASE_FOLDING, 0); - xml_set_object($this->xml, $this); - xml_set_character_data_handler($this->xml, 'cdata'); - xml_set_element_handler($this->xml, 'tag_open', 'tag_close'); - - // Parse! - if (!xml_parse($this->xml, $data, true)) - { - $this->data = null; - $this->error_code = xml_get_error_code($this->xml); - $this->error_string = xml_error_string($this->error_code); - $return = false; - } - $this->current_line = xml_get_current_line_number($this->xml); - $this->current_column = xml_get_current_column_number($this->xml); - $this->current_byte = xml_get_current_byte_index($this->xml); - xml_parser_free($this->xml); - return $return; - } - - function get_error_code() - { - return $this->error_code; - } - - function get_error_string() - { - return $this->error_string; - } - - function get_current_line() - { - return $this->current_line; - } - - function get_current_column() - { - return $this->current_column; - } - - function get_current_byte() - { - return $this->current_byte; - } - - function get_data() - { - return $this->data; - } - - function tag_open($parser, $tag, $attributes) - { - if ($this->feed === 0) - { - return; - } - elseif ($this->feed == false) - { - if (in_array($tag, array( - SIMPLEPIE_NAMESPACE_ATOM_10 . $this->separator . 'feed', - SIMPLEPIE_NAMESPACE_ATOM_03 . $this->separator . 'feed', - 'rss', - SIMPLEPIE_NAMESPACE_RDF . $this->separator . 'RDF' - ))) - { - $this->feed = 1; - } - } - else - { - $this->feed++; - } - - list($this->namespace[], $this->element[]) = $this->split_ns($tag); - - $attribs = array(); - foreach ($attributes as $name => $value) - { - list($attrib_namespace, $attribute) = $this->split_ns($name); - $attribs[$attrib_namespace][$attribute] = $value; - } - - if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['base'])) - { - $this->xml_base[] = SimplePie_Misc::absolutize_url($attribs[SIMPLEPIE_NAMESPACE_XML]['base'], end($this->xml_base)); - $this->xml_base_explicit[] = true; - } - else - { - $this->xml_base[] = end($this->xml_base); - $this->xml_base_explicit[] = end($this->xml_base_explicit); - } - - if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['lang'])) - { - $this->xml_lang[] = $attribs[SIMPLEPIE_NAMESPACE_XML]['lang']; - } - else - { - $this->xml_lang[] = end($this->xml_lang); - } - - if ($this->current_xhtml_construct >= 0) - { - $this->current_xhtml_construct++; - if (end($this->namespace) == SIMPLEPIE_NAMESPACE_XHTML) - { - $this->data['data'] .= '<' . end($this->element); - if (isset($attribs[''])) - { - foreach ($attribs[''] as $name => $value) - { - $this->data['data'] .= ' ' . $name . '="' . htmlspecialchars($value, ENT_COMPAT, $this->encoding) . '"'; - } - } - $this->data['data'] .= '>'; - } - } - else - { - $this->datas[] =& $this->data; - $this->data =& $this->data['child'][end($this->namespace)][end($this->element)][]; - $this->data = array('data' => '', 'attribs' => $attribs, 'xml_base' => end($this->xml_base), 'xml_base_explicit' => end($this->xml_base_explicit), 'xml_lang' => end($this->xml_lang)); - if ((end($this->namespace) == SIMPLEPIE_NAMESPACE_ATOM_03 && in_array(end($this->element), array('title', 'tagline', 'copyright', 'info', 'summary', 'content')) && isset($attribs['']['mode']) && $attribs['']['mode'] == 'xml') - || (end($this->namespace) == SIMPLEPIE_NAMESPACE_ATOM_10 && in_array(end($this->element), array('rights', 'subtitle', 'summary', 'info', 'title', 'content')) && isset($attribs['']['type']) && $attribs['']['type'] == 'xhtml')) - { - $this->current_xhtml_construct = 0; - } - } - } - - function cdata($parser, $cdata) - { - if ($this->current_xhtml_construct >= 0) - { - $this->data['data'] .= htmlspecialchars($cdata, ENT_QUOTES, $this->encoding); - } - elseif ($this->feed > 1) - { - $this->data['data'] .= $cdata; - } - } - - function tag_close($parser, $tag) - { - if (!$this->feed) - { - return; - } - - if ($this->current_xhtml_construct >= 0) - { - $this->current_xhtml_construct--; - if (end($this->namespace) == SIMPLEPIE_NAMESPACE_XHTML && !in_array(end($this->element), array('area', 'base', 'basefont', 'br', 'col', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param'))) - { - $this->data['data'] .= 'element) . '>'; - } - } - if ($this->current_xhtml_construct == -1) - { - $this->data =& $this->datas[$this->feed]; - array_pop($this->datas); - } - - array_pop($this->element); - array_pop($this->namespace); - array_pop($this->xml_base); - array_pop($this->xml_base_explicit); - array_pop($this->xml_lang); - $this->feed--; - } - - function split_ns($string) - { - static $cache = array(); - if (!isset($cache[$string])) - { - if ($pos = strpos($string, $this->separator)) - { - static $separator_length; - if (!$separator_length) - { - $separator_length = strlen($this->separator); - } - $cache[$string] = array(substr($string, 0, $pos), substr($string, $pos + $separator_length)); - } - else - { - $cache[$string] = array('', $string); - } - } - return $cache[$string]; - } -} - -/** - * @todo Move to using an actual HTML parser (this will allow tags to be properly stripped, and to switch between HTML and XHTML), this will also make it easier to shortern a string while preserving HTML tags - */ -class SimplePie_Sanitize -{ - // Private vars - var $base; - - // Options - var $remove_div = true; - var $image_handler = ''; - var $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'); - var $encode_instead_of_strip = false; - var $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'); - var $strip_comments = false; - var $output_encoding = 'UTF-8'; - var $enable_cache = true; - var $cache_location = './cache'; - var $cache_name_function = 'md5'; - var $cache_class = 'SimplePie_Cache'; - var $file_class = 'SimplePie_File'; - var $timeout = 10; - var $useragent = ''; - var $force_fsockopen = false; - - var $replace_url_attributes = array( - 'a' => 'href', - 'area' => 'href', - 'blockquote' => 'cite', - 'del' => 'cite', - 'form' => 'action', - 'img' => array('longdesc', 'src'), - 'input' => 'src', - 'ins' => 'cite', - 'q' => 'cite' - ); - - function remove_div($enable = true) - { - $this->remove_div = (bool) $enable; - } - - function set_image_handler($page = false) - { - if ($page) - { - $this->image_handler = (string) $page; - } - else - { - $this->image_handler = false; - } - } - - function pass_cache_data($enable_cache = true, $cache_location = './cache', $cache_name_function = 'md5', $cache_class = 'SimplePie_Cache') - { - if (isset($enable_cache)) - { - $this->enable_cache = (bool) $enable_cache; - } - - if ($cache_location) - { - $this->cache_location = (string) $cache_location; - } - - if ($cache_name_function) - { - $this->cache_name_function = (string) $cache_name_function; - } - - if ($cache_class) - { - $this->cache_class = (string) $cache_class; - } - } - - function pass_file_data($file_class = 'SimplePie_File', $timeout = 10, $useragent = '', $force_fsockopen = false) - { - if ($file_class) - { - $this->file_class = (string) $file_class; - } - - if ($timeout) - { - $this->timeout = (string) $timeout; - } - - if ($useragent) - { - $this->useragent = (string) $useragent; - } - - if ($force_fsockopen) - { - $this->force_fsockopen = (string) $force_fsockopen; - } - } - - function strip_htmltags($tags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style')) - { - if ($tags) - { - if (is_array($tags)) - { - $this->strip_htmltags = $tags; - } - else - { - $this->strip_htmltags = explode(',', $tags); - } - } - else - { - $this->strip_htmltags = false; - } - } - - function encode_instead_of_strip($encode = false) - { - $this->encode_instead_of_strip = (bool) $encode; - } - - function strip_attributes($attribs = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc')) - { - if ($attribs) - { - if (is_array($attribs)) - { - $this->strip_attributes = $attribs; - } - else - { - $this->strip_attributes = explode(',', $attribs); - } - } - else - { - $this->strip_attributes = false; - } - } - - function strip_comments($strip = false) - { - $this->strip_comments = (bool) $strip; - } - - function set_output_encoding($encoding = 'UTF-8') - { - $this->output_encoding = (string) $encoding; - } - - /** - * Set element/attribute key/value pairs of HTML attributes - * containing URLs that need to be resolved relative to the feed - * - * @access public - * @since 1.0 - * @param array $element_attribute Element/attribute key/value pairs - */ - function set_url_replacements($element_attribute = array('a' => 'href', 'area' => 'href', 'blockquote' => 'cite', 'del' => 'cite', 'form' => 'action', 'img' => array('longdesc', 'src'), 'input' => 'src', 'ins' => 'cite', 'q' => 'cite')) - { - $this->replace_url_attributes = (array) $element_attribute; - } - - function sanitize($data, $type, $base = '') - { - $data = trim($data); - if ($data !== '' || $type & SIMPLEPIE_CONSTRUCT_IRI) - { - if ($type & SIMPLEPIE_CONSTRUCT_MAYBE_HTML) - { - if (preg_match('/(&(#(x[0-9a-fA-F]+|[0-9]+)|[a-zA-Z0-9]+)|<\/(\w+)' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>)/', $data)) - { - $type |= SIMPLEPIE_CONSTRUCT_HTML; - } - else - { - $type |= SIMPLEPIE_CONSTRUCT_TEXT; - } - } - - if ($type & SIMPLEPIE_CONSTRUCT_BASE64) - { - $data = base64_decode($data); - } - - if ($type & SIMPLEPIE_CONSTRUCT_XHTML) - { - if ($this->remove_div) - { - $data = preg_replace('/^/', '', $data); - $data = preg_replace('/<\/div>$/', '', $data); - } - else - { - $data = preg_replace('/^/', '
    ', $data); - } - } - - if ($type & (SIMPLEPIE_CONSTRUCT_HTML | SIMPLEPIE_CONSTRUCT_XHTML)) - { - // Strip comments - if ($this->strip_comments) - { - $data = SimplePie_Misc::strip_comments($data); - } - - // Strip out HTML tags and attributes that might cause various security problems. - // Based on recommendations by Mark Pilgrim at: - // http://diveintomark.org/archives/2003/06/12/how_to_consume_rss_safely - if ($this->strip_htmltags) - { - foreach ($this->strip_htmltags as $tag) - { - $pcre = "/<($tag)" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . "(>(.*)<\/$tag" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>|(\/)?>)/siU'; - while (preg_match($pcre, $data)) - { - $data = preg_replace_callback($pcre, array(&$this, 'do_strip_htmltags'), $data); - } - } - } - - if ($this->strip_attributes) - { - foreach ($this->strip_attributes as $attrib) - { - $data = preg_replace('/ '. trim($attrib) .'=("|")(\w|\s|=|-|:|;|\/|\.|\?|&|,|#|!|\(|\)|\'|'|<|>|\+|{|})*("|")/i', '', $data); - $data = preg_replace('/ '. trim($attrib) .'=(\'|')(\w|\s|=|-|:|;|\/|\.|\?|&|,|#|!|\(|\)|"|"|<|>|\+|{|})*(\'|')/i', '', $data); - $data = preg_replace('/ '. trim($attrib) .'=(\w|\s|=|-|:|;|\/|\.|\?|&|,|#|!|\(|\)|\+|{|})*/i', '', $data); - } - } - - // Replace relative URLs - $this->base = $base; - foreach ($this->replace_url_attributes as $element => $attributes) - { - $data = $this->replace_urls($data, $element, $attributes); - } - - // If image handling (caching, etc.) is enabled, cache and rewrite all the image tags. - if (isset($this->image_handler) && ((string) $this->image_handler) !== '' && $this->enable_cache) - { - $images = SimplePie_Misc::get_element('img', $data); - foreach ($images as $img) - { - if (isset($img['attribs']['src']['data'])) - { - $image_url = $img['attribs']['src']['data']; - $cache =& new $this->cache_class($this->cache_location, call_user_func($this->cache_name_function, $image_url), 'spi'); - - if ($cache->load()) - { - $img['attribs']['src']['data'] = $this->image_handler . rawurlencode($img['attribs']['src']['data']); - $data = str_replace($img['full'], SimplePie_Misc::element_implode($img), $data); - } - else - { - $file =& new $this->file_class($image_url, $this->timeout, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen); - $headers = $file->headers; - - if ($file->success && ($file->status_code == 200 || ($file->status_code > 206 && $file->status_code < 300))) - { - if (!$cache->save(array('headers' => $file->headers, 'body' => $file->body))) - { - trigger_error("$cache->name is not writeable", E_USER_WARNING); - } - $img['attribs']['src']['data'] = $this->image_handler . rawurlencode($img['attribs']['src']['data']); - $data = str_replace($img['full'], SimplePie_Misc::element_implode($img), $data); - } - } - } - } - } - - // Having (possibly) taken stuff out, there may now be whitespace at the beginning/end of the data - $data = trim($data); - } - - if ($type & SIMPLEPIE_CONSTRUCT_IRI) - { - $data = SimplePie_Misc::absolutize_url($data, $base); - } - - if ($type & (SIMPLEPIE_CONSTRUCT_TEXT | SIMPLEPIE_CONSTRUCT_IRI)) - { - $data = htmlspecialchars($data, ENT_COMPAT, 'UTF-8'); - } - - if ($this->output_encoding != 'UTF-8') - { - $data = SimplePie_Misc::change_encoding($data, 'UTF-8', $this->output_encoding); - } - } - return $data; - } - - function replace_urls($data, $tag, $attributes) - { - if (!is_array($this->strip_htmltags) || !in_array($tag, $this->strip_htmltags)) - { - $elements = SimplePie_Misc::get_element($tag, $data); - foreach ($elements as $element) - { - if (is_array($attributes)) - { - foreach ($attributes as $attribute) - { - if (isset($element['attribs'][$attribute]['data'])) - { - $element['attribs'][$attribute]['data'] = SimplePie_Misc::absolutize_url($element['attribs'][$attribute]['data'], $this->base); - $data = str_replace($element['full'], SimplePie_Misc::element_implode($element), $data); - } - } - } - elseif (isset($element['attribs'][$attributes]['data'])) - { - $element['attribs'][$attributes]['data'] = SimplePie_Misc::absolutize_url($element['attribs'][$attributes]['data'], $this->base); - $data = str_replace($element['full'], SimplePie_Misc::element_implode($element), $data); - } - } - } - return $data; - } - - function do_strip_htmltags($match) - { - if ($this->encode_instead_of_strip) - { - if (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style'))) - { - $match[1] = htmlspecialchars($match[1], ENT_COMPAT, 'UTF-8'); - $match[2] = htmlspecialchars($match[2], ENT_COMPAT, 'UTF-8'); - return "<$match[1]$match[2]>$match[3]</$match[1]>"; - } - else - { - return htmlspecialchars($match[0], ENT_COMPAT, 'UTF-8'); - } - } - elseif (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style'))) - { - return $match[4]; - } - else - { - return ''; - } - } -} - -?> \ No newline at end of file +' . SIMPLEPIE_NAME . ''); + +/** + * No Autodiscovery + * @see SimplePie::set_autodiscovery_level() + */ +define('SIMPLEPIE_LOCATOR_NONE', 0); + +/** + * Feed Link Element Autodiscovery + * @see SimplePie::set_autodiscovery_level() + */ +define('SIMPLEPIE_LOCATOR_AUTODISCOVERY', 1); + +/** + * Local Feed Extension Autodiscovery + * @see SimplePie::set_autodiscovery_level() + */ +define('SIMPLEPIE_LOCATOR_LOCAL_EXTENSION', 2); + +/** + * Local Feed Body Autodiscovery + * @see SimplePie::set_autodiscovery_level() + */ +define('SIMPLEPIE_LOCATOR_LOCAL_BODY', 4); + +/** + * Remote Feed Extension Autodiscovery + * @see SimplePie::set_autodiscovery_level() + */ +define('SIMPLEPIE_LOCATOR_REMOTE_EXTENSION', 8); + +/** + * Remote Feed Body Autodiscovery + * @see SimplePie::set_autodiscovery_level() + */ +define('SIMPLEPIE_LOCATOR_REMOTE_BODY', 16); + +/** + * All Feed Autodiscovery + * @see SimplePie::set_autodiscovery_level() + */ +define('SIMPLEPIE_LOCATOR_ALL', 31); + +/** + * No known feed type + */ +define('SIMPLEPIE_TYPE_NONE', 0); + +/** + * RSS 0.90 + */ +define('SIMPLEPIE_TYPE_RSS_090', 1); + +/** + * RSS 0.91 (Netscape) + */ +define('SIMPLEPIE_TYPE_RSS_091_NETSCAPE', 2); + +/** + * RSS 0.91 (Userland) + */ +define('SIMPLEPIE_TYPE_RSS_091_USERLAND', 4); + +/** + * RSS 0.91 (both Netscape and Userland) + */ +define('SIMPLEPIE_TYPE_RSS_091', 6); + +/** + * RSS 0.92 + */ +define('SIMPLEPIE_TYPE_RSS_092', 8); + +/** + * RSS 0.93 + */ +define('SIMPLEPIE_TYPE_RSS_093', 16); + +/** + * RSS 0.94 + */ +define('SIMPLEPIE_TYPE_RSS_094', 32); + +/** + * RSS 1.0 + */ +define('SIMPLEPIE_TYPE_RSS_10', 64); + +/** + * RSS 2.0 + */ +define('SIMPLEPIE_TYPE_RSS_20', 128); + +/** + * RDF-based RSS + */ +define('SIMPLEPIE_TYPE_RSS_RDF', 65); + +/** + * Non-RDF-based RSS (truly intended as syndication format) + */ +define('SIMPLEPIE_TYPE_RSS_SYNDICATION', 190); + +/** + * All RSS + */ +define('SIMPLEPIE_TYPE_RSS_ALL', 255); + +/** + * Atom 0.3 + */ +define('SIMPLEPIE_TYPE_ATOM_03', 256); + +/** + * Atom 1.0 + */ +define('SIMPLEPIE_TYPE_ATOM_10', 512); + +/** + * All Atom + */ +define('SIMPLEPIE_TYPE_ATOM_ALL', 768); + +/** + * All feed types + */ +define('SIMPLEPIE_TYPE_ALL', 1023); + +/** + * No construct + */ +define('SIMPLEPIE_CONSTRUCT_NONE', 0); + +/** + * Text construct + */ +define('SIMPLEPIE_CONSTRUCT_TEXT', 1); + +/** + * HTML construct + */ +define('SIMPLEPIE_CONSTRUCT_HTML', 2); + +/** + * XHTML construct + */ +define('SIMPLEPIE_CONSTRUCT_XHTML', 4); + +/** + * base64-encoded construct + */ +define('SIMPLEPIE_CONSTRUCT_BASE64', 8); + +/** + * IRI construct + */ +define('SIMPLEPIE_CONSTRUCT_IRI', 16); + +/** + * A construct that might be HTML + */ +define('SIMPLEPIE_CONSTRUCT_MAYBE_HTML', 32); + +/** + * All constructs + */ +define('SIMPLEPIE_CONSTRUCT_ALL', 63); + +/** + * Don't change case + */ +define('SIMPLEPIE_SAME_CASE', 1); + +/** + * Change to lowercase + */ +define('SIMPLEPIE_LOWERCASE', 2); + +/** + * Change to uppercase + */ +define('SIMPLEPIE_UPPERCASE', 4); + +/** + * PCRE for HTML attributes + */ +define('SIMPLEPIE_PCRE_HTML_ATTRIBUTE', '((?:[\x09\x0A\x0B\x0C\x0D\x20]+[^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"(?:[^"]*)"|\'(?:[^\']*)\'|(?:[^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?)*)[\x09\x0A\x0B\x0C\x0D\x20]*'); + +/** + * PCRE for XML attributes + */ +define('SIMPLEPIE_PCRE_XML_ATTRIBUTE', '((?:\s+(?:(?:[^\s:]+:)?[^\s:]+)\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'))*)\s*'); + +/** + * XML Namespace + */ +define('SIMPLEPIE_NAMESPACE_XML', 'http://www.w3.org/XML/1998/namespace'); + +/** + * Atom 1.0 Namespace + */ +define('SIMPLEPIE_NAMESPACE_ATOM_10', 'http://www.w3.org/2005/Atom'); + +/** + * Atom 0.3 Namespace + */ +define('SIMPLEPIE_NAMESPACE_ATOM_03', 'http://purl.org/atom/ns#'); + +/** + * RDF Namespace + */ +define('SIMPLEPIE_NAMESPACE_RDF', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'); + +/** + * RSS 0.90 Namespace + */ +define('SIMPLEPIE_NAMESPACE_RSS_090', 'http://my.netscape.com/rdf/simple/0.9/'); + +/** + * RSS 1.0 Namespace + */ +define('SIMPLEPIE_NAMESPACE_RSS_10', 'http://purl.org/rss/1.0/'); + +/** + * RSS 1.0 Content Module Namespace + */ +define('SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT', 'http://purl.org/rss/1.0/modules/content/'); + +/** + * RSS 2.0 Namespace + * (Stupid, I know, but I'm certain it will confuse people less with support.) + */ +define('SIMPLEPIE_NAMESPACE_RSS_20', ''); + +/** + * DC 1.0 Namespace + */ +define('SIMPLEPIE_NAMESPACE_DC_10', 'http://purl.org/dc/elements/1.0/'); + +/** + * DC 1.1 Namespace + */ +define('SIMPLEPIE_NAMESPACE_DC_11', 'http://purl.org/dc/elements/1.1/'); + +/** + * W3C Basic Geo (WGS84 lat/long) Vocabulary Namespace + */ +define('SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO', 'http://www.w3.org/2003/01/geo/wgs84_pos#'); + +/** + * GeoRSS Namespace + */ +define('SIMPLEPIE_NAMESPACE_GEORSS', 'http://www.georss.org/georss'); + +/** + * Media RSS Namespace + */ +define('SIMPLEPIE_NAMESPACE_MEDIARSS', 'http://search.yahoo.com/mrss/'); + +/** + * Wrong Media RSS Namespace + */ +define('SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG', 'http://search.yahoo.com/mrss'); + +/** + * iTunes RSS Namespace + */ +define('SIMPLEPIE_NAMESPACE_ITUNES', 'http://www.itunes.com/dtds/podcast-1.0.dtd'); + +/** + * XHTML Namespace + */ +define('SIMPLEPIE_NAMESPACE_XHTML', 'http://www.w3.org/1999/xhtml'); + +/** + * IANA Link Relations Registry + */ +define('SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY', 'http://www.iana.org/assignments/relation/'); + +/** + * Whether we're running on PHP5 + */ +define('SIMPLEPIE_PHP5', version_compare(PHP_VERSION, '5.0.0', '>=')); + +/** + * No file source + */ +define('SIMPLEPIE_FILE_SOURCE_NONE', 0); + +/** + * Remote file source + */ +define('SIMPLEPIE_FILE_SOURCE_REMOTE', 1); + +/** + * Local file source + */ +define('SIMPLEPIE_FILE_SOURCE_LOCAL', 2); + +/** + * fsockopen() file source + */ +define('SIMPLEPIE_FILE_SOURCE_FSOCKOPEN', 4); + +/** + * cURL file source + */ +define('SIMPLEPIE_FILE_SOURCE_CURL', 8); + +/** + * file_get_contents() file source + */ +define('SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS', 16); + +/** + * SimplePie + * + * @package SimplePie + */ +class SimplePie +{ + /** + * @var array Raw data + * @access private + */ + var $data = array(); + + /** + * @var mixed Error string + * @access private + */ + var $error; + + /** + * @var object Instance of SimplePie_Sanitize (or other class) + * @see SimplePie::set_sanitize_class() + * @access private + */ + var $sanitize; + + /** + * @var string SimplePie Useragent + * @see SimplePie::set_useragent() + * @access private + */ + var $useragent = SIMPLEPIE_USERAGENT; + + /** + * @var string Feed URL + * @see SimplePie::set_feed_url() + * @access private + */ + var $feed_url; + + /** + * @var object Instance of SimplePie_File to use as a feed + * @see SimplePie::set_file() + * @access private + */ + var $file; + + /** + * @var string Raw feed data + * @see SimplePie::set_raw_data() + * @access private + */ + var $raw_data; + + /** + * @var int Timeout for fetching remote files + * @see SimplePie::set_timeout() + * @access private + */ + var $timeout = 10; + + /** + * @var bool Forces fsockopen() to be used for remote files instead + * of cURL, even if a new enough version is installed + * @see SimplePie::force_fsockopen() + * @access private + */ + var $force_fsockopen = false; + + /** + * @var bool Force the given data/URL to be treated as a feed no matter what + * it appears like + * @see SimplePie::force_feed() + * @access private + */ + var $force_feed = false; + + /** + * @var bool Enable/Disable XML dump + * @see SimplePie::enable_xml_dump() + * @access private + */ + var $xml_dump = false; + + /** + * @var bool Enable/Disable Caching + * @see SimplePie::enable_cache() + * @access private + */ + var $cache = true; + + /** + * @var int Cache duration (in seconds) + * @see SimplePie::set_cache_duration() + * @access private + */ + var $cache_duration = 3600; + + /** + * @var int Auto-discovery cache duration (in seconds) + * @see SimplePie::set_autodiscovery_cache_duration() + * @access private + */ + var $autodiscovery_cache_duration = 604800; // 7 Days. + + /** + * @var string Cache location (relative to executing script) + * @see SimplePie::set_cache_location() + * @access private + */ + var $cache_location = './cache'; + + /** + * @var string Function that creates the cache filename + * @see SimplePie::set_cache_name_function() + * @access private + */ + var $cache_name_function = 'md5'; + + /** + * @var bool Reorder feed by date descending + * @see SimplePie::enable_order_by_date() + * @access private + */ + var $order_by_date = true; + + /** + * @var mixed Force input encoding to be set to the follow value + * (false, or anything type-cast to false, disables this feature) + * @see SimplePie::set_input_encoding() + * @access private + */ + var $input_encoding = false; + + /** + * @var int Feed Autodiscovery Level + * @see SimplePie::set_autodiscovery_level() + * @access private + */ + var $autodiscovery = SIMPLEPIE_LOCATOR_ALL; + + /** + * @var string Class used for caching feeds + * @see SimplePie::set_cache_class() + * @access private + */ + var $cache_class = 'SimplePie_Cache'; + + /** + * @var string Class used for locating feeds + * @see SimplePie::set_locator_class() + * @access private + */ + var $locator_class = 'SimplePie_Locator'; + + /** + * @var string Class used for parsing feeds + * @see SimplePie::set_parser_class() + * @access private + */ + var $parser_class = 'SimplePie_Parser'; + + /** + * @var string Class used for fetching feeds + * @see SimplePie::set_file_class() + * @access private + */ + var $file_class = 'SimplePie_File'; + + /** + * @var string Class used for items + * @see SimplePie::set_item_class() + * @access private + */ + var $item_class = 'SimplePie_Item'; + + /** + * @var string Class used for authors + * @see SimplePie::set_author_class() + * @access private + */ + var $author_class = 'SimplePie_Author'; + + /** + * @var string Class used for categories + * @see SimplePie::set_category_class() + * @access private + */ + var $category_class = 'SimplePie_Category'; + + /** + * @var string Class used for enclosures + * @see SimplePie::set_enclosures_class() + * @access private + */ + var $enclosure_class = 'SimplePie_Enclosure'; + + /** + * @var string Class used for Media RSS captions + * @see SimplePie::set_caption_class() + * @access private + */ + var $caption_class = 'SimplePie_Caption'; + + /** + * @var string Class used for Media RSS + * @see SimplePie::set_copyright_class() + * @access private + */ + var $copyright_class = 'SimplePie_Copyright'; + + /** + * @var string Class used for Media RSS + * @see SimplePie::set_credit_class() + * @access private + */ + var $credit_class = 'SimplePie_Credit'; + + /** + * @var string Class used for Media RSS + * @see SimplePie::set_rating_class() + * @access private + */ + var $rating_class = 'SimplePie_Rating'; + + /** + * @var string Class used for Media RSS + * @see SimplePie::set_restriction_class() + * @access private + */ + var $restriction_class = 'SimplePie_Restriction'; + + /** + * @var string Class used for content-type sniffing + * @see SimplePie::set_content_type_sniffer_class() + * @access private + */ + var $content_type_sniffer_class = 'SimplePie_Content_Type_Sniffer'; + + /** + * @var string Class used for item sources. + * @see SimplePie::set_source_class() + * @access private + */ + var $source_class = 'SimplePie_Source'; + + /** + * @var mixed Set javascript query string parameter (false, or + * anything type-cast to false, disables this feature) + * @see SimplePie::set_javascript() + * @access private + */ + var $javascript = 'js'; + + /** + * @var int Maximum number of feeds to check with autodiscovery + * @see SimplePie::set_max_checked_feeds() + * @access private + */ + var $max_checked_feeds = 10; + + /** + * @var array All the feeds found during the autodiscovery process + * @see SimplePie::get_all_discovered_feeds() + * @access private + */ + var $all_discovered_feeds = array(); + + /** + * @var string Web-accessible path to the handler_favicon.php file. + * @see SimplePie::set_favicon_handler() + * @access private + */ + var $favicon_handler = ''; + + /** + * @var string Web-accessible path to the handler_image.php file. + * @see SimplePie::set_image_handler() + * @access private + */ + var $image_handler = ''; + + /** + * @var array Stores the URLs when multiple feeds are being initialized. + * @see SimplePie::set_feed_url() + * @access private + */ + var $multifeed_url = array(); + + /** + * @var array Stores SimplePie objects when multiple feeds initialized. + * @access private + */ + var $multifeed_objects = array(); + + /** + * @var array Stores the get_object_vars() array for use with multifeeds. + * @see SimplePie::set_feed_url() + * @access private + */ + var $config_settings = null; + + /** + * @var integer Stores the number of items to return per-feed with multifeeds. + * @see SimplePie::set_item_limit() + * @access private + */ + var $item_limit = 0; + + /** + * @var array Stores the default attributes to be stripped by strip_attributes(). + * @see SimplePie::strip_attributes() + * @access private + */ + var $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'); + + /** + * @var array Stores the default tags to be stripped by strip_htmltags(). + * @see SimplePie::strip_htmltags() + * @access private + */ + var $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'); + + /** + * The SimplePie class contains feed level data and options + * + * There are two ways that you can create a new SimplePie object. The first + * is by passing a feed URL as a parameter to the SimplePie constructor + * (as well as optionally setting the cache location and cache expiry). This + * will initialise the whole feed with all of the default settings, and you + * can begin accessing methods and properties immediately. + * + * The second way is to create the SimplePie object with no parameters + * at all. This will enable you to set configuration options. After setting + * them, you must initialise the feed using $feed->init(). At that point the + * object's methods and properties will be available to you. This format is + * what is used throughout this documentation. + * + * @access public + * @since 1.0 Preview Release + * @param string $feed_url This is the URL you want to parse. + * @param string $cache_location This is where you want the cache to be stored. + * @param int $cache_duration This is the number of seconds that you want to store the cache file for. + */ + function SimplePie($feed_url = null, $cache_location = null, $cache_duration = null) + { + // Other objects, instances created here so we can set options on them + $this->sanitize = new SimplePie_Sanitize; + + // Set options if they're passed to the constructor + if ($cache_location !== null) + { + $this->set_cache_location($cache_location); + } + + if ($cache_duration !== null) + { + $this->set_cache_duration($cache_duration); + } + + // Only init the script if we're passed a feed URL + if ($feed_url !== null) + { + $this->set_feed_url($feed_url); + $this->init(); + } + } + + /** + * Used for converting object to a string + */ + function __toString() + { + return md5(serialize($this->data)); + } + + /** + * Remove items that link back to this before destroying this object + */ + function __destruct() + { + if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode')) + { + if (!empty($this->data['items'])) + { + foreach ($this->data['items'] as $item) + { + $item->__destruct(); + } + unset($item, $this->data['items']); + } + if (!empty($this->data['ordered_items'])) + { + foreach ($this->data['ordered_items'] as $item) + { + $item->__destruct(); + } + unset($item, $this->data['ordered_items']); + } + } + } + + /** + * Force the given data/URL to be treated as a feed no matter what it + * appears like + * + * @access public + * @since 1.1 + * @param bool $enable Force the given data/URL to be treated as a feed + */ + function force_feed($enable = false) + { + $this->force_feed = (bool) $enable; + } + + /** + * This is the URL of the feed you want to parse. + * + * This allows you to enter the URL of the feed you want to parse, or the + * website you want to try to use auto-discovery on. This takes priority + * over any set raw data. + * + * You can set multiple feeds to mash together by passing an array instead + * of a string for the $url. Remember that with each additional feed comes + * additional processing and resources. + * + * @access public + * @since 1.0 Preview Release + * @param mixed $url This is the URL (or array of URLs) that you want to parse. + * @see SimplePie::set_raw_data() + */ + function set_feed_url($url) + { + if (is_array($url)) + { + $this->multifeed_url = array(); + foreach ($url as $value) + { + $this->multifeed_url[] = SimplePie_Misc::fix_protocol($value, 1); + } + } + else + { + $this->feed_url = SimplePie_Misc::fix_protocol($url, 1); + } + } + + /** + * Provides an instance of SimplePie_File to use as a feed + * + * @access public + * @param object &$file Instance of SimplePie_File (or subclass) + * @return bool True on success, false on failure + */ + function set_file(&$file) + { + if (is_a($file, 'SimplePie_File')) + { + $this->feed_url = $file->url; + $this->file =& $file; + return true; + } + return false; + } + + /** + * Allows you to use a string of RSS/Atom data instead of a remote feed. + * + * If you have a feed available as a string in PHP, you can tell SimplePie + * to parse that data string instead of a remote feed. Any set feed URL + * takes precedence. + * + * @access public + * @since 1.0 Beta 3 + * @param string $data RSS or Atom data as a string. + * @see SimplePie::set_feed_url() + */ + function set_raw_data($data) + { + $this->raw_data = $data; + } + + /** + * Allows you to override the default timeout for fetching remote feeds. + * + * This allows you to change the maximum time the feed's server to respond + * and send the feed back. + * + * @access public + * @since 1.0 Beta 3 + * @param int $timeout The maximum number of seconds to spend waiting to retrieve a feed. + */ + function set_timeout($timeout = 10) + { + $this->timeout = (int) $timeout; + } + + /** + * Forces SimplePie to use fsockopen() instead of the preferred cURL + * functions. + * + * @access public + * @since 1.0 Beta 3 + * @param bool $enable Force fsockopen() to be used + */ + function force_fsockopen($enable = false) + { + $this->force_fsockopen = (bool) $enable; + } + + /** + * Outputs the raw XML content of the feed, after it has gone through + * SimplePie's filters. + * + * Used only for debugging, this function will output the XML content as + * text/xml. When SimplePie reads in a feed, it does a bit of cleaning up + * before trying to parse it. Many parts of the feed are re-written in + * memory, and in the end, you have a parsable feed. XML dump shows you the + * actual XML that SimplePie tries to parse, which may or may not be very + * different from the original feed. + * + * @access public + * @since 1.0 Preview Release + * @param bool $enable Enable XML dump + */ + function enable_xml_dump($enable = false) + { + $this->xml_dump = (bool) $enable; + } + + /** + * Enables/disables caching in SimplePie. + * + * This option allows you to disable caching all-together in SimplePie. + * However, disabling the cache can lead to longer load times. + * + * @access public + * @since 1.0 Preview Release + * @param bool $enable Enable caching + */ + function enable_cache($enable = true) + { + $this->cache = (bool) $enable; + } + + /** + * Set the length of time (in seconds) that the contents of a feed + * will be cached. + * + * @access public + * @param int $seconds The feed content cache duration. + */ + function set_cache_duration($seconds = 3600) + { + $this->cache_duration = (int) $seconds; + } + + /** + * Set the length of time (in seconds) that the autodiscovered feed + * URL will be cached. + * + * @access public + * @param int $seconds The autodiscovered feed URL cache duration. + */ + function set_autodiscovery_cache_duration($seconds = 604800) + { + $this->autodiscovery_cache_duration = (int) $seconds; + } + + /** + * Set the file system location where the cached files should be stored. + * + * @access public + * @param string $location The file system location. + */ + function set_cache_location($location = './cache') + { + $this->cache_location = (string) $location; + } + + /** + * Determines whether feed items should be sorted into reverse chronological order. + * + * @access public + * @param bool $enable Sort as reverse chronological order. + */ + function enable_order_by_date($enable = true) + { + $this->order_by_date = (bool) $enable; + } + + /** + * Allows you to override the character encoding reported by the feed. + * + * @access public + * @param string $encoding Character encoding. + */ + function set_input_encoding($encoding = false) + { + if ($encoding) + { + $this->input_encoding = (string) $encoding; + } + else + { + $this->input_encoding = false; + } + } + + /** + * Set how much feed autodiscovery to do + * + * @access public + * @see SIMPLEPIE_LOCATOR_NONE + * @see SIMPLEPIE_LOCATOR_AUTODISCOVERY + * @see SIMPLEPIE_LOCATOR_LOCAL_EXTENSION + * @see SIMPLEPIE_LOCATOR_LOCAL_BODY + * @see SIMPLEPIE_LOCATOR_REMOTE_EXTENSION + * @see SIMPLEPIE_LOCATOR_REMOTE_BODY + * @see SIMPLEPIE_LOCATOR_ALL + * @param int $level Feed Autodiscovery Level (level can be a + * combination of the above constants, see bitwise OR operator) + */ + function set_autodiscovery_level($level = SIMPLEPIE_LOCATOR_ALL) + { + $this->autodiscovery = (int) $level; + } + + /** + * Allows you to change which class SimplePie uses for caching. + * Useful when you are overloading or extending SimplePie's default classes. + * + * @access public + * @param string $class Name of custom class. + * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation + * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation + */ + function set_cache_class($class = 'SimplePie_Cache') + { + if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Cache')) + { + $this->cache_class = $class; + return true; + } + return false; + } + + /** + * Allows you to change which class SimplePie uses for auto-discovery. + * Useful when you are overloading or extending SimplePie's default classes. + * + * @access public + * @param string $class Name of custom class. + * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation + * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation + */ + function set_locator_class($class = 'SimplePie_Locator') + { + if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Locator')) + { + $this->locator_class = $class; + return true; + } + return false; + } + + /** + * Allows you to change which class SimplePie uses for XML parsing. + * Useful when you are overloading or extending SimplePie's default classes. + * + * @access public + * @param string $class Name of custom class. + * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation + * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation + */ + function set_parser_class($class = 'SimplePie_Parser') + { + if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Parser')) + { + $this->parser_class = $class; + return true; + } + return false; + } + + /** + * Allows you to change which class SimplePie uses for remote file fetching. + * Useful when you are overloading or extending SimplePie's default classes. + * + * @access public + * @param string $class Name of custom class. + * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation + * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation + */ + function set_file_class($class = 'SimplePie_File') + { + if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_File')) + { + $this->file_class = $class; + return true; + } + return false; + } + + /** + * Allows you to change which class SimplePie uses for data sanitization. + * Useful when you are overloading or extending SimplePie's default classes. + * + * @access public + * @param string $class Name of custom class. + * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation + * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation + */ + function set_sanitize_class($class = 'SimplePie_Sanitize') + { + if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Sanitize')) + { + $this->sanitize = new $class; + return true; + } + return false; + } + + /** + * Allows you to change which class SimplePie uses for handling feed items. + * Useful when you are overloading or extending SimplePie's default classes. + * + * @access public + * @param string $class Name of custom class. + * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation + * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation + */ + function set_item_class($class = 'SimplePie_Item') + { + if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Item')) + { + $this->item_class = $class; + return true; + } + return false; + } + + /** + * Allows you to change which class SimplePie uses for handling author data. + * Useful when you are overloading or extending SimplePie's default classes. + * + * @access public + * @param string $class Name of custom class. + * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation + * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation + */ + function set_author_class($class = 'SimplePie_Author') + { + if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Author')) + { + $this->author_class = $class; + return true; + } + return false; + } + + /** + * Allows you to change which class SimplePie uses for handling category data. + * Useful when you are overloading or extending SimplePie's default classes. + * + * @access public + * @param string $class Name of custom class. + * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation + * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation + */ + function set_category_class($class = 'SimplePie_Category') + { + if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Category')) + { + $this->category_class = $class; + return true; + } + return false; + } + + /** + * Allows you to change which class SimplePie uses for feed enclosures. + * Useful when you are overloading or extending SimplePie's default classes. + * + * @access public + * @param string $class Name of custom class. + * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation + * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation + */ + function set_enclosure_class($class = 'SimplePie_Enclosure') + { + if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Enclosure')) + { + $this->enclosure_class = $class; + return true; + } + return false; + } + + /** + * Allows you to change which class SimplePie uses for captions + * Useful when you are overloading or extending SimplePie's default classes. + * + * @access public + * @param string $class Name of custom class. + * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation + * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation + */ + function set_caption_class($class = 'SimplePie_Caption') + { + if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Caption')) + { + $this->caption_class = $class; + return true; + } + return false; + } + + /** + * Allows you to change which class SimplePie uses for + * Useful when you are overloading or extending SimplePie's default classes. + * + * @access public + * @param string $class Name of custom class. + * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation + * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation + */ + function set_copyright_class($class = 'SimplePie_Copyright') + { + if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Copyright')) + { + $this->copyright_class = $class; + return true; + } + return false; + } + + /** + * Allows you to change which class SimplePie uses for + * Useful when you are overloading or extending SimplePie's default classes. + * + * @access public + * @param string $class Name of custom class. + * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation + * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation + */ + function set_credit_class($class = 'SimplePie_Credit') + { + if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Credit')) + { + $this->credit_class = $class; + return true; + } + return false; + } + + /** + * Allows you to change which class SimplePie uses for + * Useful when you are overloading or extending SimplePie's default classes. + * + * @access public + * @param string $class Name of custom class. + * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation + * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation + */ + function set_rating_class($class = 'SimplePie_Rating') + { + if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Rating')) + { + $this->rating_class = $class; + return true; + } + return false; + } + + /** + * Allows you to change which class SimplePie uses for + * Useful when you are overloading or extending SimplePie's default classes. + * + * @access public + * @param string $class Name of custom class. + * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation + * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation + */ + function set_restriction_class($class = 'SimplePie_Restriction') + { + if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Restriction')) + { + $this->restriction_class = $class; + return true; + } + return false; + } + + /** + * Allows you to change which class SimplePie uses for content-type sniffing. + * Useful when you are overloading or extending SimplePie's default classes. + * + * @access public + * @param string $class Name of custom class. + * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation + * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation + */ + function set_content_type_sniffer_class($class = 'SimplePie_Content_Type_Sniffer') + { + if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Content_Type_Sniffer')) + { + $this->content_type_sniffer_class = $class; + return true; + } + return false; + } + + /** + * Allows you to change which class SimplePie uses item sources. + * Useful when you are overloading or extending SimplePie's default classes. + * + * @access public + * @param string $class Name of custom class. + * @link http://php.net/manual/en/keyword.extends.php PHP4 extends documentation + * @link http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.extends PHP5 extends documentation + */ + function set_source_class($class = 'SimplePie_Source') + { + if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Source')) + { + $this->source_class = $class; + return true; + } + return false; + } + + /** + * Allows you to override the default user agent string. + * + * @access public + * @param string $ua New user agent string. + */ + function set_useragent($ua = SIMPLEPIE_USERAGENT) + { + $this->useragent = (string) $ua; + } + + /** + * Set callback function to create cache filename with + * + * @access public + * @param mixed $function Callback function + */ + function set_cache_name_function($function = 'md5') + { + if (is_callable($function)) + { + $this->cache_name_function = $function; + } + } + + /** + * Set javascript query string parameter + * + * @access public + * @param mixed $get Javascript query string parameter + */ + function set_javascript($get = 'js') + { + if ($get) + { + $this->javascript = (string) $get; + } + else + { + $this->javascript = false; + } + } + + /** + * Set options to make SP as fast as possible. Forgoes a + * substantial amount of data sanitization in favor of speed. + * + * @access public + * @param bool $set Whether to set them or not + */ + function set_stupidly_fast($set = false) + { + if ($set) + { + $this->enable_order_by_date(false); + $this->remove_div(false); + $this->strip_comments(false); + $this->strip_htmltags(false); + $this->strip_attributes(false); + $this->set_image_handler(false); + } + } + + /** + * Set maximum number of feeds to check with autodiscovery + * + * @access public + * @param int $max Maximum number of feeds to check + */ + function set_max_checked_feeds($max = 10) + { + $this->max_checked_feeds = (int) $max; + } + + function remove_div($enable = true) + { + $this->sanitize->remove_div($enable); + } + + function strip_htmltags($tags = '', $encode = null) + { + if ($tags === '') + { + $tags = $this->strip_htmltags; + } + $this->sanitize->strip_htmltags($tags); + if ($encode !== null) + { + $this->sanitize->encode_instead_of_strip($tags); + } + } + + function encode_instead_of_strip($enable = true) + { + $this->sanitize->encode_instead_of_strip($enable); + } + + function strip_attributes($attribs = '') + { + if ($attribs === '') + { + $attribs = $this->strip_attributes; + } + $this->sanitize->strip_attributes($attribs); + } + + function set_output_encoding($encoding = 'UTF-8') + { + $this->sanitize->set_output_encoding($encoding); + } + + function strip_comments($strip = false) + { + $this->sanitize->strip_comments($strip); + } + + /** + * Set element/attribute key/value pairs of HTML attributes + * containing URLs that need to be resolved relative to the feed + * + * @access public + * @since 1.0 + * @param array $element_attribute Element/attribute key/value pairs + */ + function set_url_replacements($element_attribute = array('a' => 'href', 'area' => 'href', 'blockquote' => 'cite', 'del' => 'cite', 'form' => 'action', 'img' => array('longdesc', 'src'), 'input' => 'src', 'ins' => 'cite', 'q' => 'cite')) + { + $this->sanitize->set_url_replacements($element_attribute); + } + + /** + * Set the handler to enable the display of cached favicons. + * + * @access public + * @param str $page Web-accessible path to the handler_favicon.php file. + * @param str $qs The query string that the value should be passed to. + */ + function set_favicon_handler($page = false, $qs = 'i') + { + if ($page !== false) + { + $this->favicon_handler = $page . '?' . $qs . '='; + } + else + { + $this->favicon_handler = ''; + } + } + + /** + * Set the handler to enable the display of cached images. + * + * @access public + * @param str $page Web-accessible path to the handler_image.php file. + * @param str $qs The query string that the value should be passed to. + */ + function set_image_handler($page = false, $qs = 'i') + { + if ($page !== false) + { + $this->sanitize->set_image_handler($page . '?' . $qs . '='); + } + else + { + $this->image_handler = ''; + } + } + + /** + * Set the limit for items returned per-feed with multifeeds. + * + * @access public + * @param integer $limit The maximum number of items to return. + */ + function set_item_limit($limit = 0) + { + $this->item_limit = (int) $limit; + } + + function init() + { + // Check absolute bare minimum requirements. + if ((function_exists('version_compare') && version_compare(PHP_VERSION, '4.3.0', '<')) || !extension_loaded('xml') || !extension_loaded('pcre')) + { + return false; + } + // Then check the xml extension is sane (i.e., libxml 2.7.x issue on PHP < 5.2.9 and libxml 2.7.0 to 2.7.2 on any version) if we don't have xmlreader. + elseif (!extension_loaded('xmlreader')) + { + static $xml_is_sane = null; + if ($xml_is_sane === null) + { + $parser_check = xml_parser_create(); + xml_parse_into_struct($parser_check, '&', $values); + xml_parser_free($parser_check); + $xml_is_sane = isset($values[0]['value']); + } + if (!$xml_is_sane) + { + return false; + } + } + + if (isset($_GET[$this->javascript])) + { + SimplePie_Misc::output_javascript(); + exit; + } + + // Pass whatever was set with config options over to the sanitizer. + $this->sanitize->pass_cache_data($this->cache, $this->cache_location, $this->cache_name_function, $this->cache_class); + $this->sanitize->pass_file_data($this->file_class, $this->timeout, $this->useragent, $this->force_fsockopen); + + if ($this->feed_url !== null || $this->raw_data !== null) + { + $this->data = array(); + $this->multifeed_objects = array(); + $cache = false; + + if ($this->feed_url !== null) + { + $parsed_feed_url = SimplePie_Misc::parse_url($this->feed_url); + // Decide whether to enable caching + if ($this->cache && $parsed_feed_url['scheme'] !== '') + { + $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $this->feed_url), 'spc'); + } + // If it's enabled and we don't want an XML dump, use the cache + if ($cache && !$this->xml_dump) + { + // Load the Cache + $this->data = $cache->load(); + if (!empty($this->data)) + { + // If the cache is for an outdated build of SimplePie + if (!isset($this->data['build']) || $this->data['build'] !== SIMPLEPIE_BUILD) + { + $cache->unlink(); + $this->data = array(); + } + // If we've hit a collision just rerun it with caching disabled + elseif (isset($this->data['url']) && $this->data['url'] !== $this->feed_url) + { + $cache = false; + $this->data = array(); + } + // If we've got a non feed_url stored (if the page isn't actually a feed, or is a redirect) use that URL. + elseif (isset($this->data['feed_url'])) + { + // If the autodiscovery cache is still valid use it. + if ($cache->mtime() + $this->autodiscovery_cache_duration > time()) + { + // Do not need to do feed autodiscovery yet. + if ($this->data['feed_url'] === $this->data['url']) + { + $cache->unlink(); + $this->data = array(); + } + else + { + $this->set_feed_url($this->data['feed_url']); + return $this->init(); + } + } + } + // Check if the cache has been updated + elseif ($cache->mtime() + $this->cache_duration < time()) + { + // If we have last-modified and/or etag set + if (isset($this->data['headers']['last-modified']) || isset($this->data['headers']['etag'])) + { + $headers = array(); + if (isset($this->data['headers']['last-modified'])) + { + $headers['if-modified-since'] = $this->data['headers']['last-modified']; + } + if (isset($this->data['headers']['etag'])) + { + $headers['if-none-match'] = '"' . $this->data['headers']['etag'] . '"'; + } + $file = new $this->file_class($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen); + if ($file->success) + { + if ($file->status_code === 304) + { + $cache->touch(); + return true; + } + else + { + $headers = $file->headers; + } + } + else + { + unset($file); + } + } + } + // If the cache is still valid, just return true + else + { + return true; + } + } + // If the cache is empty, delete it + else + { + $cache->unlink(); + $this->data = array(); + } + } + // If we don't already have the file (it'll only exist if we've opened it to check if the cache has been modified), open it. + if (!isset($file)) + { + if (is_a($this->file, 'SimplePie_File') && $this->file->url === $this->feed_url) + { + $file =& $this->file; + } + else + { + $file = new $this->file_class($this->feed_url, $this->timeout, 5, null, $this->useragent, $this->force_fsockopen); + } + } + // If the file connection has an error, set SimplePie::error to that and quit + if (!$file->success && !($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300))) + { + $this->error = $file->error; + if (!empty($this->data)) + { + return true; + } + else + { + return false; + } + } + + if (!$this->force_feed) + { + // Check if the supplied URL is a feed, if it isn't, look for it. + $locate = new $this->locator_class($file, $this->timeout, $this->useragent, $this->file_class, $this->max_checked_feeds, $this->content_type_sniffer_class); + if (!$locate->is_feed($file)) + { + // We need to unset this so that if SimplePie::set_file() has been called that object is untouched + unset($file); + if ($file = $locate->find($this->autodiscovery, $this->all_discovered_feeds)) + { + if ($cache) + { + $this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD); + if (!$cache->save($this)) + { + trigger_error("$this->cache_location is not writeable", E_USER_WARNING); + } + $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc'); + } + $this->feed_url = $file->url; + } + else + { + $this->error = "A feed could not be found at $this->feed_url"; + SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__); + return false; + } + } + $locate = null; + } + + $headers = $file->headers; + $data = $file->body; + $sniffer = new $this->content_type_sniffer_class($file); + $sniffed = $sniffer->get_type(); + } + else + { + $data = $this->raw_data; + } + + // Set up array of possible encodings + $encodings = array(); + + // First check to see if input has been overridden. + if ($this->input_encoding !== false) + { + $encodings[] = $this->input_encoding; + } + + $application_types = array('application/xml', 'application/xml-dtd', 'application/xml-external-parsed-entity'); + $text_types = array('text/xml', 'text/xml-external-parsed-entity'); + + // RFC 3023 (only applies to sniffed content) + if (isset($sniffed)) + { + if (in_array($sniffed, $application_types) || substr($sniffed, 0, 12) === 'application/' && substr($sniffed, -4) === '+xml') + { + if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset)) + { + $encodings[] = strtoupper($charset[1]); + } + $encodings = array_merge($encodings, SimplePie_Misc::xml_encoding($data)); + $encodings[] = 'UTF-8'; + } + elseif (in_array($sniffed, $text_types) || substr($sniffed, 0, 5) === 'text/' && substr($sniffed, -4) === '+xml') + { + if (isset($headers['content-type']) && preg_match('/;\x20?charset=([^;]*)/i', $headers['content-type'], $charset)) + { + $encodings[] = $charset[1]; + } + $encodings[] = 'US-ASCII'; + } + // Text MIME-type default + elseif (substr($sniffed, 0, 5) === 'text/') + { + $encodings[] = 'US-ASCII'; + } + } + + // Fallback to XML 1.0 Appendix F.1/UTF-8/ISO-8859-1 + $encodings = array_merge($encodings, SimplePie_Misc::xml_encoding($data)); + $encodings[] = 'UTF-8'; + $encodings[] = 'ISO-8859-1'; + + // There's no point in trying an encoding twice + $encodings = array_unique($encodings); + + // If we want the XML, just output that with the most likely encoding and quit + if ($this->xml_dump) + { + header('Content-type: text/xml; charset=' . $encodings[0]); + echo $data; + exit; + } + + // Loop through each possible encoding, till we return something, or run out of possibilities + foreach ($encodings as $encoding) + { + // Change the encoding to UTF-8 (as we always use UTF-8 internally) + if ($utf8_data = SimplePie_Misc::change_encoding($data, $encoding, 'UTF-8')) + { + // Create new parser + $parser = new $this->parser_class(); + + // If it's parsed fine + if ($parser->parse($utf8_data, 'UTF-8')) + { + $this->data = $parser->get_data(); + if ($this->get_type() & ~SIMPLEPIE_TYPE_NONE) + { + if (isset($headers)) + { + $this->data['headers'] = $headers; + } + $this->data['build'] = SIMPLEPIE_BUILD; + + // Cache the file if caching is enabled + if ($cache && !$cache->save($this)) + { + trigger_error("$cache->name is not writeable", E_USER_WARNING); + } + return true; + } + else + { + $this->error = "A feed could not be found at $this->feed_url"; + SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__); + return false; + } + } + } + } + if(isset($parser)) + { + // We have an error, just set SimplePie_Misc::error to it and quit + $this->error = sprintf('XML error: %s at line %d, column %d', $parser->get_error_string(), $parser->get_current_line(), $parser->get_current_column()); + } + else + { + $this->error = 'The data could not be converted to UTF-8'; + } + SimplePie_Misc::error($this->error, E_USER_NOTICE, __FILE__, __LINE__); + return false; + } + elseif (!empty($this->multifeed_url)) + { + $i = 0; + $success = 0; + $this->multifeed_objects = array(); + foreach ($this->multifeed_url as $url) + { + if (SIMPLEPIE_PHP5) + { + // This keyword needs to defy coding standards for PHP4 compatibility + $this->multifeed_objects[$i] = clone($this); + } + else + { + $this->multifeed_objects[$i] = $this; + } + $this->multifeed_objects[$i]->set_feed_url($url); + $success |= $this->multifeed_objects[$i]->init(); + $i++; + } + return (bool) $success; + } + else + { + return false; + } + } + + /** + * Return the error message for the occured error + * + * @access public + * @return string Error message + */ + function error() + { + return $this->error; + } + + function get_encoding() + { + return $this->sanitize->output_encoding; + } + + function handle_content_type($mime = 'text/html') + { + if (!headers_sent()) + { + $header = "Content-type: $mime;"; + if ($this->get_encoding()) + { + $header .= ' charset=' . $this->get_encoding(); + } + else + { + $header .= ' charset=UTF-8'; + } + header($header); + } + } + + function get_type() + { + if (!isset($this->data['type'])) + { + $this->data['type'] = SIMPLEPIE_TYPE_ALL; + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'])) + { + $this->data['type'] &= SIMPLEPIE_TYPE_ATOM_10; + } + elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'])) + { + $this->data['type'] &= SIMPLEPIE_TYPE_ATOM_03; + } + elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'])) + { + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['channel']) + || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['image']) + || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item']) + || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_10]['textinput'])) + { + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_10; + } + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['channel']) + || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['image']) + || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item']) + || isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_090]['textinput'])) + { + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_090; + } + } + elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'])) + { + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_ALL; + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version'])) + { + switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version'])) + { + case '0.91': + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091; + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data'])) + { + switch (trim($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['skiphours']['hour'][0]['data'])) + { + case '0': + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_NETSCAPE; + break; + + case '24': + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_091_USERLAND; + break; + } + } + break; + + case '0.92': + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_092; + break; + + case '0.93': + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_093; + break; + + case '0.94': + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_094; + break; + + case '2.0': + $this->data['type'] &= SIMPLEPIE_TYPE_RSS_20; + break; + } + } + } + else + { + $this->data['type'] = SIMPLEPIE_TYPE_NONE; + } + } + return $this->data['type']; + } + + /** + * Returns the URL for the favicon of the feed's website. + * + * @todo Cache atom:icon + * @access public + * @since 1.0 + */ + function get_favicon() + { + if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); + } + elseif (($url = $this->get_link()) !== null && preg_match('/^http(s)?:\/\//i', $url)) + { + $favicon = SimplePie_Misc::absolutize_url('/favicon.ico', $url); + + if ($this->cache && $this->favicon_handler) + { + $favicon_filename = call_user_func($this->cache_name_function, $favicon); + $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, $favicon_filename, 'spi'); + + if ($cache->load()) + { + return $this->sanitize($this->favicon_handler . $favicon_filename, SIMPLEPIE_CONSTRUCT_IRI); + } + else + { + $file = new $this->file_class($favicon, $this->timeout / 10, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen); + + if ($file->success && ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)) && strlen($file->body) > 0) + { + $sniffer = new $this->content_type_sniffer_class($file); + if (substr($sniffer->get_type(), 0, 6) === 'image/') + { + if ($cache->save(array('headers' => $file->headers, 'body' => $file->body))) + { + return $this->sanitize($this->favicon_handler . $favicon_filename, SIMPLEPIE_CONSTRUCT_IRI); + } + else + { + trigger_error("$cache->name is not writeable", E_USER_WARNING); + return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI); + } + } + // not an image + else + { + return false; + } + } + } + } + else + { + return $this->sanitize($favicon, SIMPLEPIE_CONSTRUCT_IRI); + } + } + return false; + } + + /** + * @todo If we have a perm redirect we should return the new URL + * @todo When we make the above change, let's support as well + * @todo Also, |atom:link|@rel=self + */ + function subscribe_url() + { + if ($this->feed_url !== null) + { + return $this->sanitize($this->feed_url, SIMPLEPIE_CONSTRUCT_IRI); + } + else + { + return null; + } + } + + function subscribe_feed() + { + if ($this->feed_url !== null) + { + return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI); + } + else + { + return null; + } + } + + function subscribe_outlook() + { + if ($this->feed_url !== null) + { + return $this->sanitize('outlook' . SimplePie_Misc::fix_protocol($this->feed_url, 2), SIMPLEPIE_CONSTRUCT_IRI); + } + else + { + return null; + } + } + + function subscribe_podcast() + { + if ($this->feed_url !== null) + { + return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 3), SIMPLEPIE_CONSTRUCT_IRI); + } + else + { + return null; + } + } + + function subscribe_itunes() + { + if ($this->feed_url !== null) + { + return $this->sanitize(SimplePie_Misc::fix_protocol($this->feed_url, 4), SIMPLEPIE_CONSTRUCT_IRI); + } + else + { + return null; + } + } + + /** + * Creates the subscribe_* methods' return data + * + * @access private + * @param string $feed_url String to prefix to the feed URL + * @param string $site_url String to prefix to the site URL (and + * suffix to the feed URL) + * @return mixed URL if feed exists, false otherwise + */ + function subscribe_service($feed_url, $site_url = null) + { + if ($this->subscribe_url()) + { + $return = $feed_url . rawurlencode($this->feed_url); + if ($site_url !== null && $this->get_link() !== null) + { + $return .= $site_url . rawurlencode($this->get_link()); + } + return $this->sanitize($return, SIMPLEPIE_CONSTRUCT_IRI); + } + else + { + return null; + } + } + + function subscribe_aol() + { + return $this->subscribe_service('http://feeds.my.aol.com/add.jsp?url='); + } + + function subscribe_bloglines() + { + return $this->subscribe_service('http://www.bloglines.com/sub/'); + } + + function subscribe_eskobo() + { + return $this->subscribe_service('http://www.eskobo.com/?AddToMyPage='); + } + + function subscribe_feedfeeds() + { + return $this->subscribe_service('http://www.feedfeeds.com/add?feed='); + } + + function subscribe_feedster() + { + return $this->subscribe_service('http://www.feedster.com/myfeedster.php?action=addrss&confirm=no&rssurl='); + } + + function subscribe_google() + { + return $this->subscribe_service('http://fusion.google.com/add?feedurl='); + } + + function subscribe_gritwire() + { + return $this->subscribe_service('http://my.gritwire.com/feeds/addExternalFeed.aspx?FeedUrl='); + } + + function subscribe_msn() + { + return $this->subscribe_service('http://my.msn.com/addtomymsn.armx?id=rss&ut=', '&ru='); + } + + function subscribe_netvibes() + { + return $this->subscribe_service('http://www.netvibes.com/subscribe.php?url='); + } + + function subscribe_newsburst() + { + return $this->subscribe_service('http://www.newsburst.com/Source/?add='); + } + + function subscribe_newsgator() + { + return $this->subscribe_service('http://www.newsgator.com/ngs/subscriber/subext.aspx?url='); + } + + function subscribe_odeo() + { + return $this->subscribe_service('http://www.odeo.com/listen/subscribe?feed='); + } + + function subscribe_podnova() + { + return $this->subscribe_service('http://www.podnova.com/index_your_podcasts.srf?action=add&url='); + } + + function subscribe_rojo() + { + return $this->subscribe_service('http://www.rojo.com/add-subscription?resource='); + } + + function subscribe_yahoo() + { + return $this->subscribe_service('http://add.my.yahoo.com/rss?url='); + } + + function get_feed_tags($namespace, $tag) + { + $type = $this->get_type(); + if ($type & SIMPLEPIE_TYPE_ATOM_10) + { + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag])) + { + return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag]; + } + } + if ($type & SIMPLEPIE_TYPE_ATOM_03) + { + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag])) + { + return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag]; + } + } + if ($type & SIMPLEPIE_TYPE_RSS_RDF) + { + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag])) + { + return $this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag]; + } + } + if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) + { + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag])) + { + return $this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag]; + } + } + return null; + } + + function get_channel_tags($namespace, $tag) + { + $type = $this->get_type(); + if ($type & SIMPLEPIE_TYPE_ATOM_ALL) + { + if ($return = $this->get_feed_tags($namespace, $tag)) + { + return $return; + } + } + if ($type & SIMPLEPIE_TYPE_RSS_10) + { + if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'channel')) + { + if (isset($channel[0]['child'][$namespace][$tag])) + { + return $channel[0]['child'][$namespace][$tag]; + } + } + } + if ($type & SIMPLEPIE_TYPE_RSS_090) + { + if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'channel')) + { + if (isset($channel[0]['child'][$namespace][$tag])) + { + return $channel[0]['child'][$namespace][$tag]; + } + } + } + if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) + { + if ($channel = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'channel')) + { + if (isset($channel[0]['child'][$namespace][$tag])) + { + return $channel[0]['child'][$namespace][$tag]; + } + } + } + return null; + } + + function get_image_tags($namespace, $tag) + { + $type = $this->get_type(); + if ($type & SIMPLEPIE_TYPE_RSS_10) + { + if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'image')) + { + if (isset($image[0]['child'][$namespace][$tag])) + { + return $image[0]['child'][$namespace][$tag]; + } + } + } + if ($type & SIMPLEPIE_TYPE_RSS_090) + { + if ($image = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'image')) + { + if (isset($image[0]['child'][$namespace][$tag])) + { + return $image[0]['child'][$namespace][$tag]; + } + } + } + if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION) + { + if ($image = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'image')) + { + if (isset($image[0]['child'][$namespace][$tag])) + { + return $image[0]['child'][$namespace][$tag]; + } + } + } + return null; + } + + function get_base($element = array()) + { + if (!($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION) && !empty($element['xml_base_explicit']) && isset($element['xml_base'])) + { + return $element['xml_base']; + } + elseif ($this->get_link() !== null) + { + return $this->get_link(); + } + else + { + return $this->subscribe_url(); + } + } + + function sanitize($data, $type, $base = '') + { + return $this->sanitize->sanitize($data, $type, $base); + } + + function get_title() + { + if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) + { + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) + { + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + return null; + } + } + + function get_category($key = 0) + { + $categories = $this->get_categories(); + if (isset($categories[$key])) + { + return $categories[$key]; + } + else + { + return null; + } + } + + function get_categories() + { + $categories = array(); + + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) + { + $term = null; + $scheme = null; + $label = null; + if (isset($category['attribs']['']['term'])) + { + $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['scheme'])) + { + $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['label'])) + { + $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $categories[] = new $this->category_class($term, $scheme, $label); + } + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) + { + // This is really the label, but keep this as the term also for BC. + // Label will also work on retrieving because that falls back to term. + $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + if (isset($category['attribs']['']['domain'])) + { + $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $scheme = null; + } + $categories[] = new $this->category_class($term, $scheme, null); + } + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) + { + $categories[] = new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + } + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category) + { + $categories[] = new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + } + + if (!empty($categories)) + { + return SimplePie_Misc::array_unique($categories); + } + else + { + return null; + } + } + + function get_author($key = 0) + { + $authors = $this->get_authors(); + if (isset($authors[$key])) + { + return $authors[$key]; + } + else + { + return null; + } + } + + function get_authors() + { + $authors = array(); + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author) + { + $name = null; + $uri = null; + $email = null; + if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) + { + $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) + { + $uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); + } + if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) + { + $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $uri !== null) + { + $authors[] = new $this->author_class($name, $uri, $email); + } + } + if ($author = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author')) + { + $name = null; + $url = null; + $email = null; + if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) + { + $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) + { + $url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); + } + if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) + { + $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $url !== null) + { + $authors[] = new $this->author_class($name, $url, $email); + } + } + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author) + { + $authors[] = new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + } + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author) + { + $authors[] = new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + } + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author) + { + $authors[] = new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + } + + if (!empty($authors)) + { + return SimplePie_Misc::array_unique($authors); + } + else + { + return null; + } + } + + function get_contributor($key = 0) + { + $contributors = $this->get_contributors(); + if (isset($contributors[$key])) + { + return $contributors[$key]; + } + else + { + return null; + } + } + + function get_contributors() + { + $contributors = array(); + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor) + { + $name = null; + $uri = null; + $email = null; + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) + { + $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) + { + $uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) + { + $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $uri !== null) + { + $contributors[] = new $this->author_class($name, $uri, $email); + } + } + foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor) + { + $name = null; + $url = null; + $email = null; + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) + { + $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) + { + $url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) + { + $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $url !== null) + { + $contributors[] = new $this->author_class($name, $url, $email); + } + } + + if (!empty($contributors)) + { + return SimplePie_Misc::array_unique($contributors); + } + else + { + return null; + } + } + + function get_link($key = 0, $rel = 'alternate') + { + $links = $this->get_links($rel); + if (isset($links[$key])) + { + return $links[$key]; + } + else + { + return null; + } + } + + /** + * Added for parity between the parent-level and the item/entry-level. + */ + function get_permalink() + { + return $this->get_link(0); + } + + function get_links($rel = 'alternate') + { + if (!isset($this->data['links'])) + { + $this->data['links'] = array(); + if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link')) + { + foreach ($links as $link) + { + if (isset($link['attribs']['']['href'])) + { + $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; + $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); + } + } + } + if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link')) + { + foreach ($links as $link) + { + if (isset($link['attribs']['']['href'])) + { + $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; + $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); + + } + } + } + if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) + { + $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); + } + if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) + { + $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); + } + if ($links = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) + { + $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); + } + + $keys = array_keys($this->data['links']); + foreach ($keys as $key) + { + if (SimplePie_Misc::is_isegment_nz_nc($key)) + { + if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key])) + { + $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]); + $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]; + } + else + { + $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; + } + } + elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) + { + $this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; + } + $this->data['links'][$key] = array_unique($this->data['links'][$key]); + } + } + + if (isset($this->data['links'][$rel])) + { + return $this->data['links'][$rel]; + } + else + { + return null; + } + } + + function get_all_discovered_feeds() + { + return $this->all_discovered_feeds; + } + + function get_description() + { + if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle')) + { + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline')) + { + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); + } + else + { + return null; + } + } + + function get_copyright() + { + if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) + { + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright')) + { + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + return null; + } + } + + function get_language() + { + if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang'])) + { + return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang'])) + { + return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang'])) + { + return $this->sanitize($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif (isset($this->data['headers']['content-language'])) + { + return $this->sanitize($this->data['headers']['content-language'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + return null; + } + } + + function get_latitude() + { + if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) + { + return (float) $return[0]['data']; + } + elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match)) + { + return (float) $match[1]; + } + else + { + return null; + } + } + + function get_longitude() + { + if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) + { + return (float) $return[0]['data']; + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon')) + { + return (float) $return[0]['data']; + } + elseif (($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match)) + { + return (float) $match[2]; + } + else + { + return null; + } + } + + function get_image_title() + { + if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + return null; + } + } + + function get_image_url() + { + if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image')) + { + return $this->sanitize($return[0]['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); + } + elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); + } + elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'url')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); + } + elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'url')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); + } + elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); + } + else + { + return null; + } + } + + function get_image_link() + { + if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); + } + elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); + } + elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); + } + else + { + return null; + } + } + + function get_image_width() + { + if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'width')) + { + return round($return[0]['data']); + } + elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) + { + return 88.0; + } + else + { + return null; + } + } + + function get_image_height() + { + if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'height')) + { + return round($return[0]['data']); + } + elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url')) + { + return 31.0; + } + else + { + return null; + } + } + + function get_item_quantity($max = 0) + { + $max = (int) $max; + $qty = count($this->get_items()); + if ($max === 0) + { + return $qty; + } + else + { + return ($qty > $max) ? $max : $qty; + } + } + + function get_item($key = 0) + { + $items = $this->get_items(); + if (isset($items[$key])) + { + return $items[$key]; + } + else + { + return null; + } + } + + function get_items($start = 0, $end = 0) + { + if (!isset($this->data['items'])) + { + if (!empty($this->multifeed_objects)) + { + $this->data['items'] = SimplePie::merge_items($this->multifeed_objects, $start, $end, $this->item_limit); + } + else + { + $this->data['items'] = array(); + if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry')) + { + $keys = array_keys($items); + foreach ($keys as $key) + { + $this->data['items'][] = new $this->item_class($this, $items[$key]); + } + } + if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry')) + { + $keys = array_keys($items); + foreach ($keys as $key) + { + $this->data['items'][] = new $this->item_class($this, $items[$key]); + } + } + if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item')) + { + $keys = array_keys($items); + foreach ($keys as $key) + { + $this->data['items'][] = new $this->item_class($this, $items[$key]); + } + } + if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item')) + { + $keys = array_keys($items); + foreach ($keys as $key) + { + $this->data['items'][] = new $this->item_class($this, $items[$key]); + } + } + if ($items = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'item')) + { + $keys = array_keys($items); + foreach ($keys as $key) + { + $this->data['items'][] = new $this->item_class($this, $items[$key]); + } + } + } + } + + if (!empty($this->data['items'])) + { + // If we want to order it by date, check if all items have a date, and then sort it + if ($this->order_by_date && empty($this->multifeed_objects)) + { + if (!isset($this->data['ordered_items'])) + { + $do_sort = true; + foreach ($this->data['items'] as $item) + { + if (!$item->get_date('U')) + { + $do_sort = false; + break; + } + } + $item = null; + $this->data['ordered_items'] = $this->data['items']; + if ($do_sort) + { + usort($this->data['ordered_items'], array(&$this, 'sort_items')); + } + } + $items = $this->data['ordered_items']; + } + else + { + $items = $this->data['items']; + } + + // Slice the data as desired + if ($end === 0) + { + return array_slice($items, $start); + } + else + { + return array_slice($items, $start, $end); + } + } + else + { + return array(); + } + } + + /** + * @static + */ + function sort_items($a, $b) + { + return $a->get_date('U') <= $b->get_date('U'); + } + + /** + * @static + */ + function merge_items($urls, $start = 0, $end = 0, $limit = 0) + { + if (is_array($urls) && sizeof($urls) > 0) + { + $items = array(); + foreach ($urls as $arg) + { + if (is_a($arg, 'SimplePie')) + { + $items = array_merge($items, $arg->get_items(0, $limit)); + } + else + { + trigger_error('Arguments must be SimplePie objects', E_USER_WARNING); + } + } + + $do_sort = true; + foreach ($items as $item) + { + if (!$item->get_date('U')) + { + $do_sort = false; + break; + } + } + $item = null; + if ($do_sort) + { + usort($items, array('SimplePie', 'sort_items')); + } + + if ($end === 0) + { + return array_slice($items, $start); + } + else + { + return array_slice($items, $start, $end); + } + } + else + { + trigger_error('Cannot merge zero SimplePie objects', E_USER_WARNING); + return array(); + } + } +} + +class SimplePie_Item +{ + var $feed; + var $data = array(); + + function SimplePie_Item($feed, $data) + { + $this->feed = $feed; + $this->data = $data; + } + + function __toString() + { + return md5(serialize($this->data)); + } + + /** + * Remove items that link back to this before destroying this object + */ + function __destruct() + { + if ((version_compare(PHP_VERSION, '5.3', '<') || !gc_enabled()) && !ini_get('zend.ze1_compatibility_mode')) + { + unset($this->feed); + } + } + + function get_item_tags($namespace, $tag) + { + if (isset($this->data['child'][$namespace][$tag])) + { + return $this->data['child'][$namespace][$tag]; + } + else + { + return null; + } + } + + function get_base($element = array()) + { + return $this->feed->get_base($element); + } + + function sanitize($data, $type, $base = '') + { + return $this->feed->sanitize($data, $type, $base); + } + + function get_feed() + { + return $this->feed; + } + + function get_id($hash = false) + { + if (!$hash) + { + if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'id')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'id')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'identifier')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'identifier')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif (($return = $this->get_permalink()) !== null) + { + return $return; + } + elseif (($return = $this->get_title()) !== null) + { + return $return; + } + } + if ($this->get_permalink() !== null || $this->get_title() !== null) + { + return md5($this->get_permalink() . $this->get_title()); + } + else + { + return md5(serialize($this->data)); + } + } + + function get_title() + { + if (!isset($this->data['title'])) + { + if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) + { + $this->data['title'] = $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) + { + $this->data['title'] = $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) + { + $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) + { + $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) + { + $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) + { + $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) + { + $this->data['title'] = $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $this->data['title'] = null; + } + } + return $this->data['title']; + } + + function get_description($description_only = false) + { + if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary')) + { + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary')) + { + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif (!$description_only) + { + return $this->get_content(true); + } + else + { + return null; + } + } + + function get_content($content_only = false) + { + if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content')) + { + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_content_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content')) + { + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); + } + elseif (!$content_only) + { + return $this->get_description(true); + } + else + { + return null; + } + } + + function get_category($key = 0) + { + $categories = $this->get_categories(); + if (isset($categories[$key])) + { + return $categories[$key]; + } + else + { + return null; + } + } + + function get_categories() + { + $categories = array(); + + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) + { + $term = null; + $scheme = null; + $label = null; + if (isset($category['attribs']['']['term'])) + { + $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['scheme'])) + { + $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['label'])) + { + $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $categories[] = new $this->feed->category_class($term, $scheme, $label); + } + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) + { + // This is really the label, but keep this as the term also for BC. + // Label will also work on retrieving because that falls back to term. + $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + if (isset($category['attribs']['']['domain'])) + { + $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $scheme = null; + } + $categories[] = new $this->feed->category_class($term, $scheme, null); + } + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) + { + $categories[] = new $this->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + } + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category) + { + $categories[] = new $this->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + } + + if (!empty($categories)) + { + return SimplePie_Misc::array_unique($categories); + } + else + { + return null; + } + } + + function get_author($key = 0) + { + $authors = $this->get_authors(); + if (isset($authors[$key])) + { + return $authors[$key]; + } + else + { + return null; + } + } + + function get_contributor($key = 0) + { + $contributors = $this->get_contributors(); + if (isset($contributors[$key])) + { + return $contributors[$key]; + } + else + { + return null; + } + } + + function get_contributors() + { + $contributors = array(); + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor) + { + $name = null; + $uri = null; + $email = null; + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) + { + $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) + { + $uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) + { + $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $uri !== null) + { + $contributors[] = new $this->feed->author_class($name, $uri, $email); + } + } + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor) + { + $name = null; + $url = null; + $email = null; + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) + { + $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) + { + $url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) + { + $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $url !== null) + { + $contributors[] = new $this->feed->author_class($name, $url, $email); + } + } + + if (!empty($contributors)) + { + return SimplePie_Misc::array_unique($contributors); + } + else + { + return null; + } + } + + function get_authors() + { + $authors = array(); + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author) + { + $name = null; + $uri = null; + $email = null; + if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) + { + $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) + { + $uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); + } + if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) + { + $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $uri !== null) + { + $authors[] = new $this->feed->author_class($name, $uri, $email); + } + } + if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author')) + { + $name = null; + $url = null; + $email = null; + if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) + { + $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) + { + $url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); + } + if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) + { + $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $url !== null) + { + $authors[] = new $this->feed->author_class($name, $url, $email); + } + } + if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'author')) + { + $authors[] = new $this->feed->author_class(null, null, $this->sanitize($author[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); + } + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author) + { + $authors[] = new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + } + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author) + { + $authors[] = new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + } + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author) + { + $authors[] = new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + } + + if (!empty($authors)) + { + return SimplePie_Misc::array_unique($authors); + } + elseif (($source = $this->get_source()) && ($authors = $source->get_authors())) + { + return $authors; + } + elseif ($authors = $this->feed->get_authors()) + { + return $authors; + } + else + { + return null; + } + } + + function get_copyright() + { + if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) + { + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + return null; + } + } + + function get_date($date_format = 'j F Y, g:i a') + { + if (!isset($this->data['date'])) + { + if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'published')) + { + $this->data['date']['raw'] = $return[0]['data']; + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'updated')) + { + $this->data['date']['raw'] = $return[0]['data']; + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'issued')) + { + $this->data['date']['raw'] = $return[0]['data']; + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'created')) + { + $this->data['date']['raw'] = $return[0]['data']; + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'modified')) + { + $this->data['date']['raw'] = $return[0]['data']; + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'pubDate')) + { + $this->data['date']['raw'] = $return[0]['data']; + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'date')) + { + $this->data['date']['raw'] = $return[0]['data']; + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'date')) + { + $this->data['date']['raw'] = $return[0]['data']; + } + + if (!empty($this->data['date']['raw'])) + { + $parser = SimplePie_Parse_Date::get(); + $this->data['date']['parsed'] = $parser->parse($this->data['date']['raw']); + } + else + { + $this->data['date'] = null; + } + } + if ($this->data['date']) + { + $date_format = (string) $date_format; + switch ($date_format) + { + case '': + return $this->sanitize($this->data['date']['raw'], SIMPLEPIE_CONSTRUCT_TEXT); + + case 'U': + return $this->data['date']['parsed']; + + default: + return date($date_format, $this->data['date']['parsed']); + } + } + else + { + return null; + } + } + + function get_local_date($date_format = '%c') + { + if (!$date_format) + { + return $this->sanitize($this->get_date(''), SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif (($date = $this->get_date('U')) !== null) + { + return strftime($date_format, $date); + } + else + { + return null; + } + } + + function get_permalink() + { + $link = $this->get_link(); + $enclosure = $this->get_enclosure(0); + if ($link !== null) + { + return $link; + } + elseif ($enclosure !== null) + { + return $enclosure->get_link(); + } + else + { + return null; + } + } + + function get_link($key = 0, $rel = 'alternate') + { + $links = $this->get_links($rel); + if ($links[$key] !== null) + { + return $links[$key]; + } + else + { + return null; + } + } + + function get_links($rel = 'alternate') + { + if (!isset($this->data['links'])) + { + $this->data['links'] = array(); + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link) + { + if (isset($link['attribs']['']['href'])) + { + $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; + $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); + + } + } + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link) + { + if (isset($link['attribs']['']['href'])) + { + $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; + $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); + } + } + if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) + { + $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); + } + if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) + { + $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); + } + if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) + { + $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); + } + if ($links = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'guid')) + { + if (!isset($links[0]['attribs']['']['isPermaLink']) || strtolower(trim($links[0]['attribs']['']['isPermaLink'])) === 'true') + { + $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); + } + } + + $keys = array_keys($this->data['links']); + foreach ($keys as $key) + { + if (SimplePie_Misc::is_isegment_nz_nc($key)) + { + if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key])) + { + $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]); + $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]; + } + else + { + $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; + } + } + elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) + { + $this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; + } + $this->data['links'][$key] = array_unique($this->data['links'][$key]); + } + } + if (isset($this->data['links'][$rel])) + { + return $this->data['links'][$rel]; + } + else + { + return null; + } + } + + /** + * @todo Add ability to prefer one type of content over another (in a media group). + */ + function get_enclosure($key = 0, $prefer = null) + { + $enclosures = $this->get_enclosures(); + if (isset($enclosures[$key])) + { + return $enclosures[$key]; + } + else + { + return null; + } + } + + /** + * Grabs all available enclosures (podcasts, etc.) + * + * Supports the RSS tag, as well as Media RSS and iTunes RSS. + * + * At this point, we're pretty much assuming that all enclosures for an item are the same content. Anything else is too complicated to properly support. + * + * @todo Add support for end-user defined sorting of enclosures by type/handler (so we can prefer the faster-loading FLV over MP4). + * @todo If an element exists at a level, but it's value is empty, we should fall back to the value from the parent (if it exists). + */ + function get_enclosures() + { + if (!isset($this->data['enclosures'])) + { + $this->data['enclosures'] = array(); + + // Elements + $captions_parent = null; + $categories_parent = null; + $copyrights_parent = null; + $credits_parent = null; + $description_parent = null; + $duration_parent = null; + $hashes_parent = null; + $keywords_parent = null; + $player_parent = null; + $ratings_parent = null; + $restrictions_parent = null; + $thumbnails_parent = null; + $title_parent = null; + + // Let's do the channel and item-level ones first, and just re-use them if we need to. + $parent = $this->get_feed(); + + // CAPTIONS + if ($captions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text')) + { + foreach ($captions as $caption) + { + $caption_type = null; + $caption_lang = null; + $caption_startTime = null; + $caption_endTime = null; + $caption_text = null; + if (isset($caption['attribs']['']['type'])) + { + $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['lang'])) + { + $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['start'])) + { + $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['end'])) + { + $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['data'])) + { + $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $captions_parent[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); + } + } + elseif ($captions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text')) + { + foreach ($captions as $caption) + { + $caption_type = null; + $caption_lang = null; + $caption_startTime = null; + $caption_endTime = null; + $caption_text = null; + if (isset($caption['attribs']['']['type'])) + { + $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['lang'])) + { + $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['start'])) + { + $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['end'])) + { + $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['data'])) + { + $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $captions_parent[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); + } + } + if (is_array($captions_parent)) + { + $captions_parent = array_values(SimplePie_Misc::array_unique($captions_parent)); + } + + // CATEGORIES + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category) + { + $term = null; + $scheme = null; + $label = null; + if (isset($category['data'])) + { + $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['scheme'])) + { + $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $scheme = 'http://search.yahoo.com/mrss/category_schema'; + } + if (isset($category['attribs']['']['label'])) + { + $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $categories_parent[] = new $this->feed->category_class($term, $scheme, $label); + } + foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category) + { + $term = null; + $scheme = null; + $label = null; + if (isset($category['data'])) + { + $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['scheme'])) + { + $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $scheme = 'http://search.yahoo.com/mrss/category_schema'; + } + if (isset($category['attribs']['']['label'])) + { + $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $categories_parent[] = new $this->feed->category_class($term, $scheme, $label); + } + foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'category') as $category) + { + $term = null; + $scheme = 'http://www.itunes.com/dtds/podcast-1.0.dtd'; + $label = null; + if (isset($category['attribs']['']['text'])) + { + $label = $this->sanitize($category['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $categories_parent[] = new $this->feed->category_class($term, $scheme, $label); + + if (isset($category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'])) + { + foreach ((array) $category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'] as $subcategory) + { + if (isset($subcategory['attribs']['']['text'])) + { + $label = $this->sanitize($subcategory['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $categories_parent[] = new $this->feed->category_class($term, $scheme, $label); + } + } + } + if (is_array($categories_parent)) + { + $categories_parent = array_values(SimplePie_Misc::array_unique($categories_parent)); + } + + // COPYRIGHT + if ($copyright = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright')) + { + $copyright_url = null; + $copyright_label = null; + if (isset($copyright[0]['attribs']['']['url'])) + { + $copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($copyright[0]['data'])) + { + $copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $copyrights_parent = new $this->feed->copyright_class($copyright_url, $copyright_label); + } + elseif ($copyright = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright')) + { + $copyright_url = null; + $copyright_label = null; + if (isset($copyright[0]['attribs']['']['url'])) + { + $copyright_url = $this->sanitize($copyright[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($copyright[0]['data'])) + { + $copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $copyrights_parent = new $this->feed->copyright_class($copyright_url, $copyright_label); + } + + // CREDITS + if ($credits = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit')) + { + foreach ($credits as $credit) + { + $credit_role = null; + $credit_scheme = null; + $credit_name = null; + if (isset($credit['attribs']['']['role'])) + { + $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($credit['attribs']['']['scheme'])) + { + $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $credit_scheme = 'urn:ebu'; + } + if (isset($credit['data'])) + { + $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $credits_parent[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); + } + } + elseif ($credits = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit')) + { + foreach ($credits as $credit) + { + $credit_role = null; + $credit_scheme = null; + $credit_name = null; + if (isset($credit['attribs']['']['role'])) + { + $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($credit['attribs']['']['scheme'])) + { + $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $credit_scheme = 'urn:ebu'; + } + if (isset($credit['data'])) + { + $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $credits_parent[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); + } + } + if (is_array($credits_parent)) + { + $credits_parent = array_values(SimplePie_Misc::array_unique($credits_parent)); + } + + // DESCRIPTION + if ($description_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description')) + { + if (isset($description_parent[0]['data'])) + { + $description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + } + elseif ($description_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'description')) + { + if (isset($description_parent[0]['data'])) + { + $description_parent = $this->sanitize($description_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + } + + // DURATION + if ($duration_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'duration')) + { + $seconds = null; + $minutes = null; + $hours = null; + if (isset($duration_parent[0]['data'])) + { + $temp = explode(':', $this->sanitize($duration_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); + if (sizeof($temp) > 0) + { + (int) $seconds = array_pop($temp); + } + if (sizeof($temp) > 0) + { + (int) $minutes = array_pop($temp); + $seconds += $minutes * 60; + } + if (sizeof($temp) > 0) + { + (int) $hours = array_pop($temp); + $seconds += $hours * 3600; + } + unset($temp); + $duration_parent = $seconds; + } + } + + // HASHES + if ($hashes_iterator = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash')) + { + foreach ($hashes_iterator as $hash) + { + $value = null; + $algo = null; + if (isset($hash['data'])) + { + $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($hash['attribs']['']['algo'])) + { + $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $algo = 'md5'; + } + $hashes_parent[] = $algo.':'.$value; + } + } + elseif ($hashes_iterator = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'hash')) + { + foreach ($hashes_iterator as $hash) + { + $value = null; + $algo = null; + if (isset($hash['data'])) + { + $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($hash['attribs']['']['algo'])) + { + $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $algo = 'md5'; + } + $hashes_parent[] = $algo.':'.$value; + } + } + if (is_array($hashes_parent)) + { + $hashes_parent = array_values(SimplePie_Misc::array_unique($hashes_parent)); + } + + // KEYWORDS + if ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords')) + { + if (isset($keywords[0]['data'])) + { + $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); + foreach ($temp as $word) + { + $keywords_parent[] = trim($word); + } + } + unset($temp); + } + elseif ($keywords = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords')) + { + if (isset($keywords[0]['data'])) + { + $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); + foreach ($temp as $word) + { + $keywords_parent[] = trim($word); + } + } + unset($temp); + } + elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'keywords')) + { + if (isset($keywords[0]['data'])) + { + $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); + foreach ($temp as $word) + { + $keywords_parent[] = trim($word); + } + } + unset($temp); + } + elseif ($keywords = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'keywords')) + { + if (isset($keywords[0]['data'])) + { + $temp = explode(',', $this->sanitize($keywords[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); + foreach ($temp as $word) + { + $keywords_parent[] = trim($word); + } + } + unset($temp); + } + if (is_array($keywords_parent)) + { + $keywords_parent = array_values(SimplePie_Misc::array_unique($keywords_parent)); + } + + // PLAYER + if ($player_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player')) + { + if (isset($player_parent[0]['attribs']['']['url'])) + { + $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + } + } + elseif ($player_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'player')) + { + if (isset($player_parent[0]['attribs']['']['url'])) + { + $player_parent = $this->sanitize($player_parent[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + } + } + + // RATINGS + if ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating')) + { + foreach ($ratings as $rating) + { + $rating_scheme = null; + $rating_value = null; + if (isset($rating['attribs']['']['scheme'])) + { + $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $rating_scheme = 'urn:simple'; + } + if (isset($rating['data'])) + { + $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $ratings_parent[] = new $this->feed->rating_class($rating_scheme, $rating_value); + } + } + elseif ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit')) + { + foreach ($ratings as $rating) + { + $rating_scheme = 'urn:itunes'; + $rating_value = null; + if (isset($rating['data'])) + { + $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $ratings_parent[] = new $this->feed->rating_class($rating_scheme, $rating_value); + } + } + elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating')) + { + foreach ($ratings as $rating) + { + $rating_scheme = null; + $rating_value = null; + if (isset($rating['attribs']['']['scheme'])) + { + $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $rating_scheme = 'urn:simple'; + } + if (isset($rating['data'])) + { + $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $ratings_parent[] = new $this->feed->rating_class($rating_scheme, $rating_value); + } + } + elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit')) + { + foreach ($ratings as $rating) + { + $rating_scheme = 'urn:itunes'; + $rating_value = null; + if (isset($rating['data'])) + { + $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $ratings_parent[] = new $this->feed->rating_class($rating_scheme, $rating_value); + } + } + if (is_array($ratings_parent)) + { + $ratings_parent = array_values(SimplePie_Misc::array_unique($ratings_parent)); + } + + // RESTRICTIONS + if ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction')) + { + foreach ($restrictions as $restriction) + { + $restriction_relationship = null; + $restriction_type = null; + $restriction_value = null; + if (isset($restriction['attribs']['']['relationship'])) + { + $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($restriction['attribs']['']['type'])) + { + $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($restriction['data'])) + { + $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $restrictions_parent[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); + } + } + elseif ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block')) + { + foreach ($restrictions as $restriction) + { + $restriction_relationship = 'allow'; + $restriction_type = null; + $restriction_value = 'itunes'; + if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes') + { + $restriction_relationship = 'deny'; + } + $restrictions_parent[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); + } + } + elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction')) + { + foreach ($restrictions as $restriction) + { + $restriction_relationship = null; + $restriction_type = null; + $restriction_value = null; + if (isset($restriction['attribs']['']['relationship'])) + { + $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($restriction['attribs']['']['type'])) + { + $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($restriction['data'])) + { + $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $restrictions_parent[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); + } + } + elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block')) + { + foreach ($restrictions as $restriction) + { + $restriction_relationship = 'allow'; + $restriction_type = null; + $restriction_value = 'itunes'; + if (isset($restriction['data']) && strtolower($restriction['data']) === 'yes') + { + $restriction_relationship = 'deny'; + } + $restrictions_parent[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); + } + } + if (is_array($restrictions_parent)) + { + $restrictions_parent = array_values(SimplePie_Misc::array_unique($restrictions_parent)); + } + + // THUMBNAILS + if ($thumbnails = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail')) + { + foreach ($thumbnails as $thumbnail) + { + if (isset($thumbnail['attribs']['']['url'])) + { + $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + } + } + } + elseif ($thumbnails = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'thumbnail')) + { + foreach ($thumbnails as $thumbnail) + { + if (isset($thumbnail['attribs']['']['url'])) + { + $thumbnails_parent[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + } + } + } + + // TITLES + if ($title_parent = $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title')) + { + if (isset($title_parent[0]['data'])) + { + $title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + } + elseif ($title_parent = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'title')) + { + if (isset($title_parent[0]['data'])) + { + $title_parent = $this->sanitize($title_parent[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + } + + // Clear the memory + unset($parent); + + // Attributes + $bitrate = null; + $channels = null; + $duration = null; + $expression = null; + $framerate = null; + $height = null; + $javascript = null; + $lang = null; + $length = null; + $medium = null; + $samplingrate = null; + $type = null; + $url = null; + $width = null; + + // Elements + $captions = null; + $categories = null; + $copyrights = null; + $credits = null; + $description = null; + $hashes = null; + $keywords = null; + $player = null; + $ratings = null; + $restrictions = null; + $thumbnails = null; + $title = null; + + // If we have media:group tags, loop through them. + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group') as $group) + { + // If we have media:content tags, loop through them. + foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content) + { + if (isset($content['attribs']['']['url'])) + { + // Attributes + $bitrate = null; + $channels = null; + $duration = null; + $expression = null; + $framerate = null; + $height = null; + $javascript = null; + $lang = null; + $length = null; + $medium = null; + $samplingrate = null; + $type = null; + $url = null; + $width = null; + + // Elements + $captions = null; + $categories = null; + $copyrights = null; + $credits = null; + $description = null; + $hashes = null; + $keywords = null; + $player = null; + $ratings = null; + $restrictions = null; + $thumbnails = null; + $title = null; + + // Start checking the attributes of media:content + if (isset($content['attribs']['']['bitrate'])) + { + $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['channels'])) + { + $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['duration'])) + { + $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $duration = $duration_parent; + } + if (isset($content['attribs']['']['expression'])) + { + $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['framerate'])) + { + $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['height'])) + { + $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['lang'])) + { + $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['fileSize'])) + { + $length = ceil($content['attribs']['']['fileSize']); + } + if (isset($content['attribs']['']['medium'])) + { + $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['samplingrate'])) + { + $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['type'])) + { + $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['width'])) + { + $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + + // Checking the other optional media: elements. Priority: media:content, media:group, item, channel + + // CAPTIONS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) + { + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) + { + $caption_type = null; + $caption_lang = null; + $caption_startTime = null; + $caption_endTime = null; + $caption_text = null; + if (isset($caption['attribs']['']['type'])) + { + $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['lang'])) + { + $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['start'])) + { + $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['end'])) + { + $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['data'])) + { + $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $captions[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); + } + if (is_array($captions)) + { + $captions = array_values(SimplePie_Misc::array_unique($captions)); + } + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) + { + foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) + { + $caption_type = null; + $caption_lang = null; + $caption_startTime = null; + $caption_endTime = null; + $caption_text = null; + if (isset($caption['attribs']['']['type'])) + { + $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['lang'])) + { + $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['start'])) + { + $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['end'])) + { + $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['data'])) + { + $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $captions[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); + } + if (is_array($captions)) + { + $captions = array_values(SimplePie_Misc::array_unique($captions)); + } + } + else + { + $captions = $captions_parent; + } + + // CATEGORIES + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) + { + foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) + { + $term = null; + $scheme = null; + $label = null; + if (isset($category['data'])) + { + $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['scheme'])) + { + $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $scheme = 'http://search.yahoo.com/mrss/category_schema'; + } + if (isset($category['attribs']['']['label'])) + { + $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $categories[] = new $this->feed->category_class($term, $scheme, $label); + } + } + if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) + { + foreach ((array) $group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) + { + $term = null; + $scheme = null; + $label = null; + if (isset($category['data'])) + { + $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['scheme'])) + { + $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $scheme = 'http://search.yahoo.com/mrss/category_schema'; + } + if (isset($category['attribs']['']['label'])) + { + $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $categories[] = new $this->feed->category_class($term, $scheme, $label); + } + } + if (is_array($categories) && is_array($categories_parent)) + { + $categories = array_values(SimplePie_Misc::array_unique(array_merge($categories, $categories_parent))); + } + elseif (is_array($categories)) + { + $categories = array_values(SimplePie_Misc::array_unique($categories)); + } + elseif (is_array($categories_parent)) + { + $categories = array_values(SimplePie_Misc::array_unique($categories_parent)); + } + + // COPYRIGHTS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) + { + $copyright_url = null; + $copyright_label = null; + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) + { + $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) + { + $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $copyrights = new $this->feed->copyright_class($copyright_url, $copyright_label); + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) + { + $copyright_url = null; + $copyright_label = null; + if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) + { + $copyright_url = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) + { + $copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $copyrights = new $this->feed->copyright_class($copyright_url, $copyright_label); + } + else + { + $copyrights = $copyrights_parent; + } + + // CREDITS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) + { + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) + { + $credit_role = null; + $credit_scheme = null; + $credit_name = null; + if (isset($credit['attribs']['']['role'])) + { + $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($credit['attribs']['']['scheme'])) + { + $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $credit_scheme = 'urn:ebu'; + } + if (isset($credit['data'])) + { + $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $credits[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); + } + if (is_array($credits)) + { + $credits = array_values(SimplePie_Misc::array_unique($credits)); + } + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) + { + foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) + { + $credit_role = null; + $credit_scheme = null; + $credit_name = null; + if (isset($credit['attribs']['']['role'])) + { + $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($credit['attribs']['']['scheme'])) + { + $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $credit_scheme = 'urn:ebu'; + } + if (isset($credit['data'])) + { + $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $credits[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); + } + if (is_array($credits)) + { + $credits = array_values(SimplePie_Misc::array_unique($credits)); + } + } + else + { + $credits = $credits_parent; + } + + // DESCRIPTION + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) + { + $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) + { + $description = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $description = $description_parent; + } + + // HASHES + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) + { + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) + { + $value = null; + $algo = null; + if (isset($hash['data'])) + { + $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($hash['attribs']['']['algo'])) + { + $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $algo = 'md5'; + } + $hashes[] = $algo.':'.$value; + } + if (is_array($hashes)) + { + $hashes = array_values(SimplePie_Misc::array_unique($hashes)); + } + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) + { + foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) + { + $value = null; + $algo = null; + if (isset($hash['data'])) + { + $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($hash['attribs']['']['algo'])) + { + $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $algo = 'md5'; + } + $hashes[] = $algo.':'.$value; + } + if (is_array($hashes)) + { + $hashes = array_values(SimplePie_Misc::array_unique($hashes)); + } + } + else + { + $hashes = $hashes_parent; + } + + // KEYWORDS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) + { + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) + { + $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); + foreach ($temp as $word) + { + $keywords[] = trim($word); + } + unset($temp); + } + if (is_array($keywords)) + { + $keywords = array_values(SimplePie_Misc::array_unique($keywords)); + } + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) + { + if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) + { + $temp = explode(',', $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); + foreach ($temp as $word) + { + $keywords[] = trim($word); + } + unset($temp); + } + if (is_array($keywords)) + { + $keywords = array_values(SimplePie_Misc::array_unique($keywords)); + } + } + else + { + $keywords = $keywords_parent; + } + + // PLAYER + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) + { + $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) + { + $player = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + } + else + { + $player = $player_parent; + } + + // RATINGS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) + { + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) + { + $rating_scheme = null; + $rating_value = null; + if (isset($rating['attribs']['']['scheme'])) + { + $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $rating_scheme = 'urn:simple'; + } + if (isset($rating['data'])) + { + $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $ratings[] = new $this->feed->rating_class($rating_scheme, $rating_value); + } + if (is_array($ratings)) + { + $ratings = array_values(SimplePie_Misc::array_unique($ratings)); + } + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) + { + foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) + { + $rating_scheme = null; + $rating_value = null; + if (isset($rating['attribs']['']['scheme'])) + { + $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $rating_scheme = 'urn:simple'; + } + if (isset($rating['data'])) + { + $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $ratings[] = new $this->feed->rating_class($rating_scheme, $rating_value); + } + if (is_array($ratings)) + { + $ratings = array_values(SimplePie_Misc::array_unique($ratings)); + } + } + else + { + $ratings = $ratings_parent; + } + + // RESTRICTIONS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) + { + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) + { + $restriction_relationship = null; + $restriction_type = null; + $restriction_value = null; + if (isset($restriction['attribs']['']['relationship'])) + { + $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($restriction['attribs']['']['type'])) + { + $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($restriction['data'])) + { + $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $restrictions[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); + } + if (is_array($restrictions)) + { + $restrictions = array_values(SimplePie_Misc::array_unique($restrictions)); + } + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) + { + foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) + { + $restriction_relationship = null; + $restriction_type = null; + $restriction_value = null; + if (isset($restriction['attribs']['']['relationship'])) + { + $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($restriction['attribs']['']['type'])) + { + $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($restriction['data'])) + { + $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $restrictions[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); + } + if (is_array($restrictions)) + { + $restrictions = array_values(SimplePie_Misc::array_unique($restrictions)); + } + } + else + { + $restrictions = $restrictions_parent; + } + + // THUMBNAILS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) + { + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) + { + $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + } + if (is_array($thumbnails)) + { + $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails)); + } + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) + { + foreach ($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) + { + $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + } + if (is_array($thumbnails)) + { + $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails)); + } + } + else + { + $thumbnails = $thumbnails_parent; + } + + // TITLES + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) + { + $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) + { + $title = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $title = $title_parent; + } + + $this->data['enclosures'][] = new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width); + } + } + } + + // If we have standalone media:content tags, loop through them. + if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'])) + { + foreach ((array) $this->data['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'] as $content) + { + if (isset($content['attribs']['']['url'])) + { + // Attributes + $bitrate = null; + $channels = null; + $duration = null; + $expression = null; + $framerate = null; + $height = null; + $javascript = null; + $lang = null; + $length = null; + $medium = null; + $samplingrate = null; + $type = null; + $url = null; + $width = null; + + // Elements + $captions = null; + $categories = null; + $copyrights = null; + $credits = null; + $description = null; + $hashes = null; + $keywords = null; + $player = null; + $ratings = null; + $restrictions = null; + $thumbnails = null; + $title = null; + + // Start checking the attributes of media:content + if (isset($content['attribs']['']['bitrate'])) + { + $bitrate = $this->sanitize($content['attribs']['']['bitrate'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['channels'])) + { + $channels = $this->sanitize($content['attribs']['']['channels'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['duration'])) + { + $duration = $this->sanitize($content['attribs']['']['duration'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $duration = $duration_parent; + } + if (isset($content['attribs']['']['expression'])) + { + $expression = $this->sanitize($content['attribs']['']['expression'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['framerate'])) + { + $framerate = $this->sanitize($content['attribs']['']['framerate'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['height'])) + { + $height = $this->sanitize($content['attribs']['']['height'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['lang'])) + { + $lang = $this->sanitize($content['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['fileSize'])) + { + $length = ceil($content['attribs']['']['fileSize']); + } + if (isset($content['attribs']['']['medium'])) + { + $medium = $this->sanitize($content['attribs']['']['medium'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['samplingrate'])) + { + $samplingrate = $this->sanitize($content['attribs']['']['samplingrate'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['type'])) + { + $type = $this->sanitize($content['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['attribs']['']['width'])) + { + $width = $this->sanitize($content['attribs']['']['width'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $url = $this->sanitize($content['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + + // Checking the other optional media: elements. Priority: media:content, media:group, item, channel + + // CAPTIONS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'])) + { + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['text'] as $caption) + { + $caption_type = null; + $caption_lang = null; + $caption_startTime = null; + $caption_endTime = null; + $caption_text = null; + if (isset($caption['attribs']['']['type'])) + { + $caption_type = $this->sanitize($caption['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['lang'])) + { + $caption_lang = $this->sanitize($caption['attribs']['']['lang'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['start'])) + { + $caption_startTime = $this->sanitize($caption['attribs']['']['start'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['attribs']['']['end'])) + { + $caption_endTime = $this->sanitize($caption['attribs']['']['end'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($caption['data'])) + { + $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $captions[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); + } + if (is_array($captions)) + { + $captions = array_values(SimplePie_Misc::array_unique($captions)); + } + } + else + { + $captions = $captions_parent; + } + + // CATEGORIES + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) + { + foreach ((array) $content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'] as $category) + { + $term = null; + $scheme = null; + $label = null; + if (isset($category['data'])) + { + $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['scheme'])) + { + $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $scheme = 'http://search.yahoo.com/mrss/category_schema'; + } + if (isset($category['attribs']['']['label'])) + { + $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $categories[] = new $this->feed->category_class($term, $scheme, $label); + } + } + if (is_array($categories) && is_array($categories_parent)) + { + $categories = array_values(SimplePie_Misc::array_unique(array_merge($categories, $categories_parent))); + } + elseif (is_array($categories)) + { + $categories = array_values(SimplePie_Misc::array_unique($categories)); + } + elseif (is_array($categories_parent)) + { + $categories = array_values(SimplePie_Misc::array_unique($categories_parent)); + } + else + { + $categories = null; + } + + // COPYRIGHTS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) + { + $copyright_url = null; + $copyright_label = null; + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'])) + { + $copyright_url = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'])) + { + $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $copyrights = new $this->feed->copyright_class($copyright_url, $copyright_label); + } + else + { + $copyrights = $copyrights_parent; + } + + // CREDITS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'])) + { + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['credit'] as $credit) + { + $credit_role = null; + $credit_scheme = null; + $credit_name = null; + if (isset($credit['attribs']['']['role'])) + { + $credit_role = $this->sanitize($credit['attribs']['']['role'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($credit['attribs']['']['scheme'])) + { + $credit_scheme = $this->sanitize($credit['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $credit_scheme = 'urn:ebu'; + } + if (isset($credit['data'])) + { + $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $credits[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); + } + if (is_array($credits)) + { + $credits = array_values(SimplePie_Misc::array_unique($credits)); + } + } + else + { + $credits = $credits_parent; + } + + // DESCRIPTION + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'])) + { + $description = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['description'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $description = $description_parent; + } + + // HASHES + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'])) + { + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['hash'] as $hash) + { + $value = null; + $algo = null; + if (isset($hash['data'])) + { + $value = $this->sanitize($hash['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($hash['attribs']['']['algo'])) + { + $algo = $this->sanitize($hash['attribs']['']['algo'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $algo = 'md5'; + } + $hashes[] = $algo.':'.$value; + } + if (is_array($hashes)) + { + $hashes = array_values(SimplePie_Misc::array_unique($hashes)); + } + } + else + { + $hashes = $hashes_parent; + } + + // KEYWORDS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'])) + { + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'])) + { + $temp = explode(',', $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['keywords'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); + foreach ($temp as $word) + { + $keywords[] = trim($word); + } + unset($temp); + } + if (is_array($keywords)) + { + $keywords = array_values(SimplePie_Misc::array_unique($keywords)); + } + } + else + { + $keywords = $keywords_parent; + } + + // PLAYER + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'])) + { + $player = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['player'][0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + } + else + { + $player = $player_parent; + } + + // RATINGS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'])) + { + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['rating'] as $rating) + { + $rating_scheme = null; + $rating_value = null; + if (isset($rating['attribs']['']['scheme'])) + { + $rating_scheme = $this->sanitize($rating['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $rating_scheme = 'urn:simple'; + } + if (isset($rating['data'])) + { + $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $ratings[] = new $this->feed->rating_class($rating_scheme, $rating_value); + } + if (is_array($ratings)) + { + $ratings = array_values(SimplePie_Misc::array_unique($ratings)); + } + } + else + { + $ratings = $ratings_parent; + } + + // RESTRICTIONS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'])) + { + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['restriction'] as $restriction) + { + $restriction_relationship = null; + $restriction_type = null; + $restriction_value = null; + if (isset($restriction['attribs']['']['relationship'])) + { + $restriction_relationship = $this->sanitize($restriction['attribs']['']['relationship'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($restriction['attribs']['']['type'])) + { + $restriction_type = $this->sanitize($restriction['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($restriction['data'])) + { + $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $restrictions[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); + } + if (is_array($restrictions)) + { + $restrictions = array_values(SimplePie_Misc::array_unique($restrictions)); + } + } + else + { + $restrictions = $restrictions_parent; + } + + // THUMBNAILS + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'])) + { + foreach ($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['thumbnail'] as $thumbnail) + { + $thumbnails[] = $this->sanitize($thumbnail['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI); + } + if (is_array($thumbnails)) + { + $thumbnails = array_values(SimplePie_Misc::array_unique($thumbnails)); + } + } + else + { + $thumbnails = $thumbnails_parent; + } + + // TITLES + if (isset($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'])) + { + $title = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['title'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $title = $title_parent; + } + + $this->data['enclosures'][] = new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width); + } + } + } + + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link') as $link) + { + if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure') + { + // Attributes + $bitrate = null; + $channels = null; + $duration = null; + $expression = null; + $framerate = null; + $height = null; + $javascript = null; + $lang = null; + $length = null; + $medium = null; + $samplingrate = null; + $type = null; + $url = null; + $width = null; + + $url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); + if (isset($link['attribs']['']['type'])) + { + $type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($link['attribs']['']['length'])) + { + $length = ceil($link['attribs']['']['length']); + } + + // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor + $this->data['enclosures'][] = new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width); + } + } + + foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link') as $link) + { + if (isset($link['attribs']['']['href']) && !empty($link['attribs']['']['rel']) && $link['attribs']['']['rel'] === 'enclosure') + { + // Attributes + $bitrate = null; + $channels = null; + $duration = null; + $expression = null; + $framerate = null; + $height = null; + $javascript = null; + $lang = null; + $length = null; + $medium = null; + $samplingrate = null; + $type = null; + $url = null; + $width = null; + + $url = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); + if (isset($link['attribs']['']['type'])) + { + $type = $this->sanitize($link['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($link['attribs']['']['length'])) + { + $length = ceil($link['attribs']['']['length']); + } + + // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor + $this->data['enclosures'][] = new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width); + } + } + + if ($enclosure = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'enclosure')) + { + if (isset($enclosure[0]['attribs']['']['url'])) + { + // Attributes + $bitrate = null; + $channels = null; + $duration = null; + $expression = null; + $framerate = null; + $height = null; + $javascript = null; + $lang = null; + $length = null; + $medium = null; + $samplingrate = null; + $type = null; + $url = null; + $width = null; + + $url = $this->sanitize($enclosure[0]['attribs']['']['url'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($enclosure[0])); + if (isset($enclosure[0]['attribs']['']['type'])) + { + $type = $this->sanitize($enclosure[0]['attribs']['']['type'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($enclosure[0]['attribs']['']['length'])) + { + $length = ceil($enclosure[0]['attribs']['']['length']); + } + + // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor + $this->data['enclosures'][] = new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width); + } + } + + if (sizeof($this->data['enclosures']) === 0 && ($url || $type || $length || $bitrate || $captions_parent || $categories_parent || $channels || $copyrights_parent || $credits_parent || $description_parent || $duration_parent || $expression || $framerate || $hashes_parent || $height || $keywords_parent || $lang || $medium || $player_parent || $ratings_parent || $restrictions_parent || $samplingrate || $thumbnails_parent || $title_parent || $width)) + { + // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor + $this->data['enclosures'][] = new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width); + } + + $this->data['enclosures'] = array_values(SimplePie_Misc::array_unique($this->data['enclosures'])); + } + if (!empty($this->data['enclosures'])) + { + return $this->data['enclosures']; + } + else + { + return null; + } + } + + function get_latitude() + { + if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) + { + return (float) $return[0]['data']; + } + elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match)) + { + return (float) $match[1]; + } + else + { + return null; + } + } + + function get_longitude() + { + if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) + { + return (float) $return[0]['data']; + } + elseif ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon')) + { + return (float) $return[0]['data']; + } + elseif (($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match)) + { + return (float) $match[2]; + } + else + { + return null; + } + } + + function get_source() + { + if ($return = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'source')) + { + return new $this->feed->source_class($this, $return[0]); + } + else + { + return null; + } + } + + /** + * Creates the add_to_* methods' return data + * + * @access private + * @param string $item_url String to prefix to the item permalink + * @param string $title_url String to prefix to the item title + * (and suffix to the item permalink) + * @return mixed URL if feed exists, false otherwise + */ + function add_to_service($item_url, $title_url = null, $summary_url = null) + { + if ($this->get_permalink() !== null) + { + $return = $item_url . rawurlencode($this->get_permalink()); + if ($title_url !== null && $this->get_title() !== null) + { + $return .= $title_url . rawurlencode($this->get_title()); + } + if ($summary_url !== null && $this->get_description() !== null) + { + $return .= $summary_url . rawurlencode($this->get_description()); + } + return $this->sanitize($return, SIMPLEPIE_CONSTRUCT_IRI); + } + else + { + return null; + } + } + + function add_to_blinklist() + { + return $this->add_to_service('http://www.blinklist.com/index.php?Action=Blink/addblink.php&Description=&Url=', '&Title='); + } + + function add_to_blogmarks() + { + return $this->add_to_service('http://blogmarks.net/my/new.php?mini=1&simple=1&url=', '&title='); + } + + function add_to_delicious() + { + return $this->add_to_service('http://del.icio.us/post/?v=4&url=', '&title='); + } + + function add_to_digg() + { + return $this->add_to_service('http://digg.com/submit?url=', '&title=', '&bodytext='); + } + + function add_to_furl() + { + return $this->add_to_service('http://www.furl.net/storeIt.jsp?u=', '&t='); + } + + function add_to_magnolia() + { + return $this->add_to_service('http://ma.gnolia.com/bookmarklet/add?url=', '&title='); + } + + function add_to_myweb20() + { + return $this->add_to_service('http://myweb2.search.yahoo.com/myresults/bookmarklet?u=', '&t='); + } + + function add_to_newsvine() + { + return $this->add_to_service('http://www.newsvine.com/_wine/save?u=', '&h='); + } + + function add_to_reddit() + { + return $this->add_to_service('http://reddit.com/submit?url=', '&title='); + } + + function add_to_segnalo() + { + return $this->add_to_service('http://segnalo.com/post.html.php?url=', '&title='); + } + + function add_to_simpy() + { + return $this->add_to_service('http://www.simpy.com/simpy/LinkAdd.do?href=', '&title='); + } + + function add_to_spurl() + { + return $this->add_to_service('http://www.spurl.net/spurl.php?v=3&url=', '&title='); + } + + function add_to_wists() + { + return $this->add_to_service('http://wists.com/r.php?c=&r=', '&title='); + } + + function search_technorati() + { + return $this->add_to_service('http://www.technorati.com/search/'); + } +} + +class SimplePie_Source +{ + var $item; + var $data = array(); + + function SimplePie_Source($item, $data) + { + $this->item = $item; + $this->data = $data; + } + + function __toString() + { + return md5(serialize($this->data)); + } + + function get_source_tags($namespace, $tag) + { + if (isset($this->data['child'][$namespace][$tag])) + { + return $this->data['child'][$namespace][$tag]; + } + else + { + return null; + } + } + + function get_base($element = array()) + { + return $this->item->get_base($element); + } + + function sanitize($data, $type, $base = '') + { + return $this->item->sanitize($data, $type, $base); + } + + function get_item() + { + return $this->item; + } + + function get_title() + { + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'title')) + { + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'title')) + { + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'title')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + return null; + } + } + + function get_category($key = 0) + { + $categories = $this->get_categories(); + if (isset($categories[$key])) + { + return $categories[$key]; + } + else + { + return null; + } + } + + function get_categories() + { + $categories = array(); + + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'category') as $category) + { + $term = null; + $scheme = null; + $label = null; + if (isset($category['attribs']['']['term'])) + { + $term = $this->sanitize($category['attribs']['']['term'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['scheme'])) + { + $scheme = $this->sanitize($category['attribs']['']['scheme'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($category['attribs']['']['label'])) + { + $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); + } + $categories[] = new $this->item->feed->category_class($term, $scheme, $label); + } + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) + { + // This is really the label, but keep this as the term also for BC. + // Label will also work on retrieving because that falls back to term. + $term = $this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT); + if (isset($category['attribs']['']['domain'])) + { + $scheme = $this->sanitize($category['attribs']['']['domain'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + $scheme = null; + } + $categories[] = new $this->item->feed->category_class($term, $scheme, null); + } + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) + { + $categories[] = new $this->item->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + } + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category) + { + $categories[] = new $this->item->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + } + + if (!empty($categories)) + { + return SimplePie_Misc::array_unique($categories); + } + else + { + return null; + } + } + + function get_author($key = 0) + { + $authors = $this->get_authors(); + if (isset($authors[$key])) + { + return $authors[$key]; + } + else + { + return null; + } + } + + function get_authors() + { + $authors = array(); + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'author') as $author) + { + $name = null; + $uri = null; + $email = null; + if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) + { + $name = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) + { + $uri = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); + } + if (isset($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) + { + $email = $this->sanitize($author['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $uri !== null) + { + $authors[] = new $this->item->feed->author_class($name, $uri, $email); + } + } + if ($author = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author')) + { + $name = null; + $url = null; + $email = null; + if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) + { + $name = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) + { + $url = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); + } + if (isset($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) + { + $email = $this->sanitize($author[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $url !== null) + { + $authors[] = new $this->item->feed->author_class($name, $url, $email); + } + } + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author) + { + $authors[] = new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + } + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author) + { + $authors[] = new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + } + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author) + { + $authors[] = new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + } + + if (!empty($authors)) + { + return SimplePie_Misc::array_unique($authors); + } + else + { + return null; + } + } + + function get_contributor($key = 0) + { + $contributors = $this->get_contributors(); + if (isset($contributors[$key])) + { + return $contributors[$key]; + } + else + { + return null; + } + } + + function get_contributors() + { + $contributors = array(); + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'contributor') as $contributor) + { + $name = null; + $uri = null; + $email = null; + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'])) + { + $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'])) + { + $uri = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['uri'][0])); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'])) + { + $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $uri !== null) + { + $contributors[] = new $this->item->feed->author_class($name, $uri, $email); + } + } + foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor) + { + $name = null; + $url = null; + $email = null; + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'])) + { + $name = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['name'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'])) + { + $url = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['url'][0])); + } + if (isset($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'])) + { + $email = $this->sanitize($contributor['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['email'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + if ($name !== null || $email !== null || $url !== null) + { + $contributors[] = new $this->item->feed->author_class($name, $url, $email); + } + } + + if (!empty($contributors)) + { + return SimplePie_Misc::array_unique($contributors); + } + else + { + return null; + } + } + + function get_link($key = 0, $rel = 'alternate') + { + $links = $this->get_links($rel); + if (isset($links[$key])) + { + return $links[$key]; + } + else + { + return null; + } + } + + /** + * Added for parity between the parent-level and the item/entry-level. + */ + function get_permalink() + { + return $this->get_link(0); + } + + function get_links($rel = 'alternate') + { + if (!isset($this->data['links'])) + { + $this->data['links'] = array(); + if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'link')) + { + foreach ($links as $link) + { + if (isset($link['attribs']['']['href'])) + { + $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; + $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); + } + } + } + if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'link')) + { + foreach ($links as $link) + { + if (isset($link['attribs']['']['href'])) + { + $link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate'; + $this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($link)); + + } + } + } + if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'link')) + { + $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); + } + if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'link')) + { + $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); + } + if ($links = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'link')) + { + $this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($links[0])); + } + + $keys = array_keys($this->data['links']); + foreach ($keys as $key) + { + if (SimplePie_Misc::is_isegment_nz_nc($key)) + { + if (isset($this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key])) + { + $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]); + $this->data['links'][$key] =& $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key]; + } + else + { + $this->data['links'][SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY . $key] =& $this->data['links'][$key]; + } + } + elseif (substr($key, 0, 41) === SIMPLEPIE_IANA_LINK_RELATIONS_REGISTRY) + { + $this->data['links'][substr($key, 41)] =& $this->data['links'][$key]; + } + $this->data['links'][$key] = array_unique($this->data['links'][$key]); + } + } + + if (isset($this->data['links'][$rel])) + { + return $this->data['links'][$rel]; + } + else + { + return null; + } + } + + function get_description() + { + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'subtitle')) + { + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'tagline')) + { + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($return[0])); + } + else + { + return null; + } + } + + function get_copyright() + { + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'rights')) + { + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_10_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'copyright')) + { + return $this->sanitize($return[0]['data'], SimplePie_Misc::atom_03_construct_type($return[0]['attribs']), $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'copyright')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'rights')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'rights')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + return null; + } + } + + function get_language() + { + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'language')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'language')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'language')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); + } + elseif (isset($this->data['xml_lang'])) + { + return $this->sanitize($this->data['xml_lang'], SIMPLEPIE_CONSTRUCT_TEXT); + } + else + { + return null; + } + } + + function get_latitude() + { + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lat')) + { + return (float) $return[0]['data']; + } + elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match)) + { + return (float) $match[1]; + } + else + { + return null; + } + } + + function get_longitude() + { + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'long')) + { + return (float) $return[0]['data']; + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_W3C_BASIC_GEO, 'lon')) + { + return (float) $return[0]['data']; + } + elseif (($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', $return[0]['data'], $match)) + { + return (float) $match[2]; + } + else + { + return null; + } + } + + function get_image_url() + { + if ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image')) + { + return $this->sanitize($return[0]['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); + } + elseif ($return = $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon')) + { + return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0])); + } + else + { + return null; + } + } +} + +class SimplePie_Author +{ + var $name; + var $link; + var $email; + + // Constructor, used to input the data + function SimplePie_Author($name = null, $link = null, $email = null) + { + $this->name = $name; + $this->link = $link; + $this->email = $email; + } + + function __toString() + { + // There is no $this->data here + return md5(serialize($this)); + } + + function get_name() + { + if ($this->name !== null) + { + return $this->name; + } + else + { + return null; + } + } + + function get_link() + { + if ($this->link !== null) + { + return $this->link; + } + else + { + return null; + } + } + + function get_email() + { + if ($this->email !== null) + { + return $this->email; + } + else + { + return null; + } + } +} + +class SimplePie_Category +{ + var $term; + var $scheme; + var $label; + + // Constructor, used to input the data + function SimplePie_Category($term = null, $scheme = null, $label = null) + { + $this->term = $term; + $this->scheme = $scheme; + $this->label = $label; + } + + function __toString() + { + // There is no $this->data here + return md5(serialize($this)); + } + + function get_term() + { + if ($this->term !== null) + { + return $this->term; + } + else + { + return null; + } + } + + function get_scheme() + { + if ($this->scheme !== null) + { + return $this->scheme; + } + else + { + return null; + } + } + + function get_label() + { + if ($this->label !== null) + { + return $this->label; + } + else + { + return $this->get_term(); + } + } +} + +class SimplePie_Enclosure +{ + var $bitrate; + var $captions; + var $categories; + var $channels; + var $copyright; + var $credits; + var $description; + var $duration; + var $expression; + var $framerate; + var $handler; + var $hashes; + var $height; + var $javascript; + var $keywords; + var $lang; + var $length; + var $link; + var $medium; + var $player; + var $ratings; + var $restrictions; + var $samplingrate; + var $thumbnails; + var $title; + var $type; + var $width; + + // Constructor, used to input the data + function SimplePie_Enclosure($link = null, $type = null, $length = null, $javascript = null, $bitrate = null, $captions = null, $categories = null, $channels = null, $copyright = null, $credits = null, $description = null, $duration = null, $expression = null, $framerate = null, $hashes = null, $height = null, $keywords = null, $lang = null, $medium = null, $player = null, $ratings = null, $restrictions = null, $samplingrate = null, $thumbnails = null, $title = null, $width = null) + { + $this->bitrate = $bitrate; + $this->captions = $captions; + $this->categories = $categories; + $this->channels = $channels; + $this->copyright = $copyright; + $this->credits = $credits; + $this->description = $description; + $this->duration = $duration; + $this->expression = $expression; + $this->framerate = $framerate; + $this->hashes = $hashes; + $this->height = $height; + $this->javascript = $javascript; + $this->keywords = $keywords; + $this->lang = $lang; + $this->length = $length; + $this->link = $link; + $this->medium = $medium; + $this->player = $player; + $this->ratings = $ratings; + $this->restrictions = $restrictions; + $this->samplingrate = $samplingrate; + $this->thumbnails = $thumbnails; + $this->title = $title; + $this->type = $type; + $this->width = $width; + if (class_exists('idna_convert')) + { + $idn = new idna_convert; + $parsed = SimplePie_Misc::parse_url($link); + $this->link = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']); + } + $this->handler = $this->get_handler(); // Needs to load last + } + + function __toString() + { + // There is no $this->data here + return md5(serialize($this)); + } + + function get_bitrate() + { + if ($this->bitrate !== null) + { + return $this->bitrate; + } + else + { + return null; + } + } + + function get_caption($key = 0) + { + $captions = $this->get_captions(); + if (isset($captions[$key])) + { + return $captions[$key]; + } + else + { + return null; + } + } + + function get_captions() + { + if ($this->captions !== null) + { + return $this->captions; + } + else + { + return null; + } + } + + function get_category($key = 0) + { + $categories = $this->get_categories(); + if (isset($categories[$key])) + { + return $categories[$key]; + } + else + { + return null; + } + } + + function get_categories() + { + if ($this->categories !== null) + { + return $this->categories; + } + else + { + return null; + } + } + + function get_channels() + { + if ($this->channels !== null) + { + return $this->channels; + } + else + { + return null; + } + } + + function get_copyright() + { + if ($this->copyright !== null) + { + return $this->copyright; + } + else + { + return null; + } + } + + function get_credit($key = 0) + { + $credits = $this->get_credits(); + if (isset($credits[$key])) + { + return $credits[$key]; + } + else + { + return null; + } + } + + function get_credits() + { + if ($this->credits !== null) + { + return $this->credits; + } + else + { + return null; + } + } + + function get_description() + { + if ($this->description !== null) + { + return $this->description; + } + else + { + return null; + } + } + + function get_duration($convert = false) + { + if ($this->duration !== null) + { + if ($convert) + { + $time = SimplePie_Misc::time_hms($this->duration); + return $time; + } + else + { + return $this->duration; + } + } + else + { + return null; + } + } + + function get_expression() + { + if ($this->expression !== null) + { + return $this->expression; + } + else + { + return 'full'; + } + } + + function get_extension() + { + if ($this->link !== null) + { + $url = SimplePie_Misc::parse_url($this->link); + if ($url['path'] !== '') + { + return pathinfo($url['path'], PATHINFO_EXTENSION); + } + } + return null; + } + + function get_framerate() + { + if ($this->framerate !== null) + { + return $this->framerate; + } + else + { + return null; + } + } + + function get_handler() + { + return $this->get_real_type(true); + } + + function get_hash($key = 0) + { + $hashes = $this->get_hashes(); + if (isset($hashes[$key])) + { + return $hashes[$key]; + } + else + { + return null; + } + } + + function get_hashes() + { + if ($this->hashes !== null) + { + return $this->hashes; + } + else + { + return null; + } + } + + function get_height() + { + if ($this->height !== null) + { + return $this->height; + } + else + { + return null; + } + } + + function get_language() + { + if ($this->lang !== null) + { + return $this->lang; + } + else + { + return null; + } + } + + function get_keyword($key = 0) + { + $keywords = $this->get_keywords(); + if (isset($keywords[$key])) + { + return $keywords[$key]; + } + else + { + return null; + } + } + + function get_keywords() + { + if ($this->keywords !== null) + { + return $this->keywords; + } + else + { + return null; + } + } + + function get_length() + { + if ($this->length !== null) + { + return $this->length; + } + else + { + return null; + } + } + + function get_link() + { + if ($this->link !== null) + { + return urldecode($this->link); + } + else + { + return null; + } + } + + function get_medium() + { + if ($this->medium !== null) + { + return $this->medium; + } + else + { + return null; + } + } + + function get_player() + { + if ($this->player !== null) + { + return $this->player; + } + else + { + return null; + } + } + + function get_rating($key = 0) + { + $ratings = $this->get_ratings(); + if (isset($ratings[$key])) + { + return $ratings[$key]; + } + else + { + return null; + } + } + + function get_ratings() + { + if ($this->ratings !== null) + { + return $this->ratings; + } + else + { + return null; + } + } + + function get_restriction($key = 0) + { + $restrictions = $this->get_restrictions(); + if (isset($restrictions[$key])) + { + return $restrictions[$key]; + } + else + { + return null; + } + } + + function get_restrictions() + { + if ($this->restrictions !== null) + { + return $this->restrictions; + } + else + { + return null; + } + } + + function get_sampling_rate() + { + if ($this->samplingrate !== null) + { + return $this->samplingrate; + } + else + { + return null; + } + } + + function get_size() + { + $length = $this->get_length(); + if ($length !== null) + { + return round($length/1048576, 2); + } + else + { + return null; + } + } + + function get_thumbnail($key = 0) + { + $thumbnails = $this->get_thumbnails(); + if (isset($thumbnails[$key])) + { + return $thumbnails[$key]; + } + else + { + return null; + } + } + + function get_thumbnails() + { + if ($this->thumbnails !== null) + { + return $this->thumbnails; + } + else + { + return null; + } + } + + function get_title() + { + if ($this->title !== null) + { + return $this->title; + } + else + { + return null; + } + } + + function get_type() + { + if ($this->type !== null) + { + return $this->type; + } + else + { + return null; + } + } + + function get_width() + { + if ($this->width !== null) + { + return $this->width; + } + else + { + return null; + } + } + + function native_embed($options='') + { + return $this->embed($options, true); + } + + /** + * @todo If the dimensions for media:content are defined, use them when width/height are set to 'auto'. + */ + function embed($options = '', $native = false) + { + // Set up defaults + $audio = ''; + $video = ''; + $alt = ''; + $altclass = ''; + $loop = 'false'; + $width = 'auto'; + $height = 'auto'; + $bgcolor = '#ffffff'; + $mediaplayer = ''; + $widescreen = false; + $handler = $this->get_handler(); + $type = $this->get_real_type(); + + // Process options and reassign values as necessary + if (is_array($options)) + { + extract($options); + } + else + { + $options = explode(',', $options); + foreach($options as $option) + { + $opt = explode(':', $option, 2); + if (isset($opt[0], $opt[1])) + { + $opt[0] = trim($opt[0]); + $opt[1] = trim($opt[1]); + switch ($opt[0]) + { + case 'audio': + $audio = $opt[1]; + break; + + case 'video': + $video = $opt[1]; + break; + + case 'alt': + $alt = $opt[1]; + break; + + case 'altclass': + $altclass = $opt[1]; + break; + + case 'loop': + $loop = $opt[1]; + break; + + case 'width': + $width = $opt[1]; + break; + + case 'height': + $height = $opt[1]; + break; + + case 'bgcolor': + $bgcolor = $opt[1]; + break; + + case 'mediaplayer': + $mediaplayer = $opt[1]; + break; + + case 'widescreen': + $widescreen = $opt[1]; + break; + } + } + } + } + + $mime = explode('/', $type, 2); + $mime = $mime[0]; + + // Process values for 'auto' + if ($width === 'auto') + { + if ($mime === 'video') + { + if ($height === 'auto') + { + $width = 480; + } + elseif ($widescreen) + { + $width = round((intval($height)/9)*16); + } + else + { + $width = round((intval($height)/3)*4); + } + } + else + { + $width = '100%'; + } + } + + if ($height === 'auto') + { + if ($mime === 'audio') + { + $height = 0; + } + elseif ($mime === 'video') + { + if ($width === 'auto') + { + if ($widescreen) + { + $height = 270; + } + else + { + $height = 360; + } + } + elseif ($widescreen) + { + $height = round((intval($width)/16)*9); + } + else + { + $height = round((intval($width)/4)*3); + } + } + else + { + $height = 376; + } + } + elseif ($mime === 'audio') + { + $height = 0; + } + + // Set proper placeholder value + if ($mime === 'audio') + { + $placeholder = $audio; + } + elseif ($mime === 'video') + { + $placeholder = $video; + } + + $embed = ''; + + // Make sure the JS library is included + if (!$native) + { + static $javascript_outputted = null; + if (!$javascript_outputted && $this->javascript) + { + $embed .= ''; + $javascript_outputted = true; + } + } + + // Odeo Feed MP3's + if ($handler === 'odeo') + { + if ($native) + { + $embed .= ''; + } + else + { + $embed .= ''; + } + } + + // Flash + elseif ($handler === 'flash') + { + if ($native) + { + $embed .= "get_link() . "\" pluginspage=\"http://adobe.com/go/getflashplayer\" type=\"$type\" quality=\"high\" width=\"$width\" height=\"$height\" bgcolor=\"$bgcolor\" loop=\"$loop\">"; + } + else + { + $embed .= ""; + } + } + + // Flash Media Player file types. + // Preferred handler for MP3 file types. + elseif ($handler === 'fmedia' || ($handler === 'mp3' && $mediaplayer !== '')) + { + $height += 20; + if ($native) + { + $embed .= "get_link().'?file_extension=.'.$this->get_extension()) . "&autostart=false&repeat=$loop&showdigits=true&showfsbutton=false\">"; + } + else + { + $embed .= ""; + } + } + + // QuickTime 7 file types. Need to test with QuickTime 6. + // Only handle MP3's if the Flash Media Player is not present. + elseif ($handler === 'quicktime' || ($handler === 'mp3' && $mediaplayer === '')) + { + $height += 16; + if ($native) + { + if ($placeholder !== '') + { + $embed .= "get_link() . "\" src=\"$placeholder\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"false\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\">"; + } + else + { + $embed .= "get_link() . "\" width=\"$width\" height=\"$height\" autoplay=\"false\" target=\"myself\" controller=\"true\" loop=\"$loop\" scale=\"aspect\" bgcolor=\"$bgcolor\" pluginspage=\"http://apple.com/quicktime/download/\">"; + } + } + else + { + $embed .= ""; + } + } + + // Windows Media + elseif ($handler === 'wmedia') + { + $height += 45; + if ($native) + { + $embed .= "get_link() . "\" autosize=\"1\" width=\"$width\" height=\"$height\" showcontrols=\"1\" showstatusbar=\"0\" showdisplay=\"0\" autostart=\"0\">"; + } + else + { + $embed .= ""; + } + } + + // Everything else + else $embed .= '' . $alt . ''; + + return $embed; + } + + function get_real_type($find_handler = false) + { + // If it's Odeo, let's get it out of the way. + if (substr(strtolower($this->get_link()), 0, 15) === 'http://odeo.com') + { + return 'odeo'; + } + + // Mime-types by handler. + $types_flash = array('application/x-shockwave-flash', 'application/futuresplash'); // Flash + $types_fmedia = array('video/flv', 'video/x-flv','flv-application/octet-stream'); // Flash Media Player + $types_quicktime = array('audio/3gpp', 'audio/3gpp2', 'audio/aac', 'audio/x-aac', 'audio/aiff', 'audio/x-aiff', 'audio/mid', 'audio/midi', 'audio/x-midi', 'audio/mp4', 'audio/m4a', 'audio/x-m4a', 'audio/wav', 'audio/x-wav', 'video/3gpp', 'video/3gpp2', 'video/m4v', 'video/x-m4v', 'video/mp4', 'video/mpeg', 'video/x-mpeg', 'video/quicktime', 'video/sd-video'); // QuickTime + $types_wmedia = array('application/asx', 'application/x-mplayer2', 'audio/x-ms-wma', 'audio/x-ms-wax', 'video/x-ms-asf-plugin', 'video/x-ms-asf', 'video/x-ms-wm', 'video/x-ms-wmv', 'video/x-ms-wvx'); // Windows Media + $types_mp3 = array('audio/mp3', 'audio/x-mp3', 'audio/mpeg', 'audio/x-mpeg'); // MP3 + + if ($this->get_type() !== null) + { + $type = strtolower($this->type); + } + else + { + $type = null; + } + + // If we encounter an unsupported mime-type, check the file extension and guess intelligently. + if (!in_array($type, array_merge($types_flash, $types_fmedia, $types_quicktime, $types_wmedia, $types_mp3))) + { + switch (strtolower($this->get_extension())) + { + // Audio mime-types + case 'aac': + case 'adts': + $type = 'audio/acc'; + break; + + case 'aif': + case 'aifc': + case 'aiff': + case 'cdda': + $type = 'audio/aiff'; + break; + + case 'bwf': + $type = 'audio/wav'; + break; + + case 'kar': + case 'mid': + case 'midi': + case 'smf': + $type = 'audio/midi'; + break; + + case 'm4a': + $type = 'audio/x-m4a'; + break; + + case 'mp3': + case 'swa': + $type = 'audio/mp3'; + break; + + case 'wav': + $type = 'audio/wav'; + break; + + case 'wax': + $type = 'audio/x-ms-wax'; + break; + + case 'wma': + $type = 'audio/x-ms-wma'; + break; + + // Video mime-types + case '3gp': + case '3gpp': + $type = 'video/3gpp'; + break; + + case '3g2': + case '3gp2': + $type = 'video/3gpp2'; + break; + + case 'asf': + $type = 'video/x-ms-asf'; + break; + + case 'flv': + $type = 'video/x-flv'; + break; + + case 'm1a': + case 'm1s': + case 'm1v': + case 'm15': + case 'm75': + case 'mp2': + case 'mpa': + case 'mpeg': + case 'mpg': + case 'mpm': + case 'mpv': + $type = 'video/mpeg'; + break; + + case 'm4v': + $type = 'video/x-m4v'; + break; + + case 'mov': + case 'qt': + $type = 'video/quicktime'; + break; + + case 'mp4': + case 'mpg4': + $type = 'video/mp4'; + break; + + case 'sdv': + $type = 'video/sd-video'; + break; + + case 'wm': + $type = 'video/x-ms-wm'; + break; + + case 'wmv': + $type = 'video/x-ms-wmv'; + break; + + case 'wvx': + $type = 'video/x-ms-wvx'; + break; + + // Flash mime-types + case 'spl': + $type = 'application/futuresplash'; + break; + + case 'swf': + $type = 'application/x-shockwave-flash'; + break; + } + } + + if ($find_handler) + { + if (in_array($type, $types_flash)) + { + return 'flash'; + } + elseif (in_array($type, $types_fmedia)) + { + return 'fmedia'; + } + elseif (in_array($type, $types_quicktime)) + { + return 'quicktime'; + } + elseif (in_array($type, $types_wmedia)) + { + return 'wmedia'; + } + elseif (in_array($type, $types_mp3)) + { + return 'mp3'; + } + else + { + return null; + } + } + else + { + return $type; + } + } +} + +class SimplePie_Caption +{ + var $type; + var $lang; + var $startTime; + var $endTime; + var $text; + + // Constructor, used to input the data + function SimplePie_Caption($type = null, $lang = null, $startTime = null, $endTime = null, $text = null) + { + $this->type = $type; + $this->lang = $lang; + $this->startTime = $startTime; + $this->endTime = $endTime; + $this->text = $text; + } + + function __toString() + { + // There is no $this->data here + return md5(serialize($this)); + } + + function get_endtime() + { + if ($this->endTime !== null) + { + return $this->endTime; + } + else + { + return null; + } + } + + function get_language() + { + if ($this->lang !== null) + { + return $this->lang; + } + else + { + return null; + } + } + + function get_starttime() + { + if ($this->startTime !== null) + { + return $this->startTime; + } + else + { + return null; + } + } + + function get_text() + { + if ($this->text !== null) + { + return $this->text; + } + else + { + return null; + } + } + + function get_type() + { + if ($this->type !== null) + { + return $this->type; + } + else + { + return null; + } + } +} + +class SimplePie_Credit +{ + var $role; + var $scheme; + var $name; + + // Constructor, used to input the data + function SimplePie_Credit($role = null, $scheme = null, $name = null) + { + $this->role = $role; + $this->scheme = $scheme; + $this->name = $name; + } + + function __toString() + { + // There is no $this->data here + return md5(serialize($this)); + } + + function get_role() + { + if ($this->role !== null) + { + return $this->role; + } + else + { + return null; + } + } + + function get_scheme() + { + if ($this->scheme !== null) + { + return $this->scheme; + } + else + { + return null; + } + } + + function get_name() + { + if ($this->name !== null) + { + return $this->name; + } + else + { + return null; + } + } +} + +class SimplePie_Copyright +{ + var $url; + var $label; + + // Constructor, used to input the data + function SimplePie_Copyright($url = null, $label = null) + { + $this->url = $url; + $this->label = $label; + } + + function __toString() + { + // There is no $this->data here + return md5(serialize($this)); + } + + function get_url() + { + if ($this->url !== null) + { + return $this->url; + } + else + { + return null; + } + } + + function get_attribution() + { + if ($this->label !== null) + { + return $this->label; + } + else + { + return null; + } + } +} + +class SimplePie_Rating +{ + var $scheme; + var $value; + + // Constructor, used to input the data + function SimplePie_Rating($scheme = null, $value = null) + { + $this->scheme = $scheme; + $this->value = $value; + } + + function __toString() + { + // There is no $this->data here + return md5(serialize($this)); + } + + function get_scheme() + { + if ($this->scheme !== null) + { + return $this->scheme; + } + else + { + return null; + } + } + + function get_value() + { + if ($this->value !== null) + { + return $this->value; + } + else + { + return null; + } + } +} + +class SimplePie_Restriction +{ + var $relationship; + var $type; + var $value; + + // Constructor, used to input the data + function SimplePie_Restriction($relationship = null, $type = null, $value = null) + { + $this->relationship = $relationship; + $this->type = $type; + $this->value = $value; + } + + function __toString() + { + // There is no $this->data here + return md5(serialize($this)); + } + + function get_relationship() + { + if ($this->relationship !== null) + { + return $this->relationship; + } + else + { + return null; + } + } + + function get_type() + { + if ($this->type !== null) + { + return $this->type; + } + else + { + return null; + } + } + + function get_value() + { + if ($this->value !== null) + { + return $this->value; + } + else + { + return null; + } + } +} + +/** + * @todo Move to properly supporting RFC2616 (HTTP/1.1) + */ +class SimplePie_File +{ + var $url; + var $useragent; + var $success = true; + var $headers = array(); + var $body; + var $status_code; + var $redirects = 0; + var $error; + var $method = SIMPLEPIE_FILE_SOURCE_NONE; + + function SimplePie_File($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) + { + if (class_exists('idna_convert')) + { + $idn = new idna_convert; + $parsed = SimplePie_Misc::parse_url($url); + $url = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']); + } + $this->url = $url; + $this->useragent = $useragent; + if (preg_match('/^http(s)?:\/\//i', $url)) + { + if ($useragent === null) + { + $useragent = ini_get('user_agent'); + $this->useragent = $useragent; + } + if (!is_array($headers)) + { + $headers = array(); + } + if (!$force_fsockopen && function_exists('curl_exec')) + { + $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_CURL; + $fp = curl_init(); + $headers2 = array(); + foreach ($headers as $key => $value) + { + $headers2[] = "$key: $value"; + } + if (version_compare(SimplePie_Misc::get_curl_version(), '7.10.5', '>=')) + { + curl_setopt($fp, CURLOPT_ENCODING, ''); + } + curl_setopt($fp, CURLOPT_URL, $url); + curl_setopt($fp, CURLOPT_HEADER, 1); + curl_setopt($fp, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($fp, CURLOPT_TIMEOUT, $timeout); + curl_setopt($fp, CURLOPT_CONNECTTIMEOUT, $timeout); + curl_setopt($fp, CURLOPT_REFERER, $url); + curl_setopt($fp, CURLOPT_USERAGENT, $useragent); + curl_setopt($fp, CURLOPT_HTTPHEADER, $headers2); + if (!ini_get('open_basedir') && !ini_get('safe_mode') && version_compare(SimplePie_Misc::get_curl_version(), '7.15.2', '>=')) + { + curl_setopt($fp, CURLOPT_FOLLOWLOCATION, 1); + curl_setopt($fp, CURLOPT_MAXREDIRS, $redirects); + } + + $this->headers = curl_exec($fp); + if (curl_errno($fp) === 23 || curl_errno($fp) === 61) + { + curl_setopt($fp, CURLOPT_ENCODING, 'none'); + $this->headers = curl_exec($fp); + } + if (curl_errno($fp)) + { + $this->error = 'cURL error ' . curl_errno($fp) . ': ' . curl_error($fp); + $this->success = false; + } + else + { + $info = curl_getinfo($fp); + curl_close($fp); + $this->headers = explode("\r\n\r\n", $this->headers, $info['redirect_count'] + 1); + $this->headers = array_pop($this->headers); + $parser = new SimplePie_HTTP_Parser($this->headers); + if ($parser->parse()) + { + $this->headers = $parser->headers; + $this->body = $parser->body; + $this->status_code = $parser->status_code; + if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) + { + $this->redirects++; + $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url); + return $this->SimplePie_File($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen); + } + } + } + } + else + { + $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN; + $url_parts = parse_url($url); + if (isset($url_parts['scheme']) && strtolower($url_parts['scheme']) === 'https') + { + $url_parts['host'] = "ssl://$url_parts[host]"; + $url_parts['port'] = 443; + } + if (!isset($url_parts['port'])) + { + $url_parts['port'] = 80; + } + $fp = @fsockopen($url_parts['host'], $url_parts['port'], $errno, $errstr, $timeout); + if (!$fp) + { + $this->error = 'fsockopen error: ' . $errstr; + $this->success = false; + } + else + { + stream_set_timeout($fp, $timeout); + if (isset($url_parts['path'])) + { + if (isset($url_parts['query'])) + { + $get = "$url_parts[path]?$url_parts[query]"; + } + else + { + $get = $url_parts['path']; + } + } + else + { + $get = '/'; + } + $out = "GET $get HTTP/1.0\r\n"; + $out .= "Host: $url_parts[host]\r\n"; + $out .= "User-Agent: $useragent\r\n"; + if (extension_loaded('zlib')) + { + $out .= "Accept-Encoding: x-gzip,gzip,deflate\r\n"; + } + + if (isset($url_parts['user']) && isset($url_parts['pass'])) + { + $out .= "Authorization: Basic " . base64_encode("$url_parts[user]:$url_parts[pass]") . "\r\n"; + } + foreach ($headers as $key => $value) + { + $out .= "$key: $value\r\n"; + } + $out .= "Connection: Close\r\n\r\n"; + fwrite($fp, $out); + + $info = stream_get_meta_data($fp); + + $this->headers = ''; + while (!$info['eof'] && !$info['timed_out']) + { + $this->headers .= fread($fp, 1160); + $info = stream_get_meta_data($fp); + } + if (!$info['timed_out']) + { + $parser = new SimplePie_HTTP_Parser($this->headers); + if ($parser->parse()) + { + $this->headers = $parser->headers; + $this->body = $parser->body; + $this->status_code = $parser->status_code; + if ((in_array($this->status_code, array(300, 301, 302, 303, 307)) || $this->status_code > 307 && $this->status_code < 400) && isset($this->headers['location']) && $this->redirects < $redirects) + { + $this->redirects++; + $location = SimplePie_Misc::absolutize_url($this->headers['location'], $url); + return $this->SimplePie_File($location, $timeout, $redirects, $headers, $useragent, $force_fsockopen); + } + if (isset($this->headers['content-encoding'])) + { + // Hey, we act dumb elsewhere, so let's do that here too + switch (strtolower(trim($this->headers['content-encoding'], "\x09\x0A\x0D\x20"))) + { + case 'gzip': + case 'x-gzip': + $decoder = new SimplePie_gzdecode($this->body); + if (!$decoder->parse()) + { + $this->error = 'Unable to decode HTTP "gzip" stream'; + $this->success = false; + } + else + { + $this->body = $decoder->data; + } + break; + + case 'deflate': + if (($body = gzuncompress($this->body)) === false) + { + if (($body = gzinflate($this->body)) === false) + { + $this->error = 'Unable to decode HTTP "deflate" stream'; + $this->success = false; + } + } + $this->body = $body; + break; + + default: + $this->error = 'Unknown content coding'; + $this->success = false; + } + } + } + } + else + { + $this->error = 'fsocket timed out'; + $this->success = false; + } + fclose($fp); + } + } + } + else + { + $this->method = SIMPLEPIE_FILE_SOURCE_LOCAL | SIMPLEPIE_FILE_SOURCE_FILE_GET_CONTENTS; + if (!$this->body = file_get_contents($url)) + { + $this->error = 'file_get_contents could not read the file'; + $this->success = false; + } + } + } +} + +/** + * HTTP Response Parser + * + * @package SimplePie + */ +class SimplePie_HTTP_Parser +{ + /** + * HTTP Version + * + * @access public + * @var float + */ + var $http_version = 0.0; + + /** + * Status code + * + * @access public + * @var int + */ + var $status_code = 0; + + /** + * Reason phrase + * + * @access public + * @var string + */ + var $reason = ''; + + /** + * Key/value pairs of the headers + * + * @access public + * @var array + */ + var $headers = array(); + + /** + * Body of the response + * + * @access public + * @var string + */ + var $body = ''; + + /** + * Current state of the state machine + * + * @access private + * @var string + */ + var $state = 'http_version'; + + /** + * Input data + * + * @access private + * @var string + */ + var $data = ''; + + /** + * Input data length (to avoid calling strlen() everytime this is needed) + * + * @access private + * @var int + */ + var $data_length = 0; + + /** + * Current position of the pointer + * + * @var int + * @access private + */ + var $position = 0; + + /** + * Name of the hedaer currently being parsed + * + * @access private + * @var string + */ + var $name = ''; + + /** + * Value of the hedaer currently being parsed + * + * @access private + * @var string + */ + var $value = ''; + + /** + * Create an instance of the class with the input data + * + * @access public + * @param string $data Input data + */ + function SimplePie_HTTP_Parser($data) + { + $this->data = $data; + $this->data_length = strlen($this->data); + } + + /** + * Parse the input data + * + * @access public + * @return bool true on success, false on failure + */ + function parse() + { + while ($this->state && $this->state !== 'emit' && $this->has_data()) + { + $state = $this->state; + $this->$state(); + } + $this->data = ''; + if ($this->state === 'emit' || $this->state === 'body') + { + return true; + } + else + { + $this->http_version = ''; + $this->status_code = ''; + $this->reason = ''; + $this->headers = array(); + $this->body = ''; + return false; + } + } + + /** + * Check whether there is data beyond the pointer + * + * @access private + * @return bool true if there is further data, false if not + */ + function has_data() + { + return (bool) ($this->position < $this->data_length); + } + + /** + * See if the next character is LWS + * + * @access private + * @return bool true if the next character is LWS, false if not + */ + function is_linear_whitespace() + { + return (bool) ($this->data[$this->position] === "\x09" + || $this->data[$this->position] === "\x20" + || ($this->data[$this->position] === "\x0A" + && isset($this->data[$this->position + 1]) + && ($this->data[$this->position + 1] === "\x09" || $this->data[$this->position + 1] === "\x20"))); + } + + /** + * Parse the HTTP version + * + * @access private + */ + function http_version() + { + if (strpos($this->data, "\x0A") !== false && strtoupper(substr($this->data, 0, 5)) === 'HTTP/') + { + $len = strspn($this->data, '0123456789.', 5); + $this->http_version = substr($this->data, 5, $len); + $this->position += 5 + $len; + if (substr_count($this->http_version, '.') <= 1) + { + $this->http_version = (float) $this->http_version; + $this->position += strspn($this->data, "\x09\x20", $this->position); + $this->state = 'status'; + } + else + { + $this->state = false; + } + } + else + { + $this->state = false; + } + } + + /** + * Parse the status code + * + * @access private + */ + function status() + { + if ($len = strspn($this->data, '0123456789', $this->position)) + { + $this->status_code = (int) substr($this->data, $this->position, $len); + $this->position += $len; + $this->state = 'reason'; + } + else + { + $this->state = false; + } + } + + /** + * Parse the reason phrase + * + * @access private + */ + function reason() + { + $len = strcspn($this->data, "\x0A", $this->position); + $this->reason = trim(substr($this->data, $this->position, $len), "\x09\x0D\x20"); + $this->position += $len + 1; + $this->state = 'new_line'; + } + + /** + * Deal with a new line, shifting data around as needed + * + * @access private + */ + function new_line() + { + $this->value = trim($this->value, "\x0D\x20"); + if ($this->name !== '' && $this->value !== '') + { + $this->name = strtolower($this->name); + if (isset($this->headers[$this->name])) + { + $this->headers[$this->name] .= ', ' . $this->value; + } + else + { + $this->headers[$this->name] = $this->value; + } + } + $this->name = ''; + $this->value = ''; + if (substr($this->data[$this->position], 0, 2) === "\x0D\x0A") + { + $this->position += 2; + $this->state = 'body'; + } + elseif ($this->data[$this->position] === "\x0A") + { + $this->position++; + $this->state = 'body'; + } + else + { + $this->state = 'name'; + } + } + + /** + * Parse a header name + * + * @access private + */ + function name() + { + $len = strcspn($this->data, "\x0A:", $this->position); + if (isset($this->data[$this->position + $len])) + { + if ($this->data[$this->position + $len] === "\x0A") + { + $this->position += $len; + $this->state = 'new_line'; + } + else + { + $this->name = substr($this->data, $this->position, $len); + $this->position += $len + 1; + $this->state = 'value'; + } + } + else + { + $this->state = false; + } + } + + /** + * Parse LWS, replacing consecutive LWS characters with a single space + * + * @access private + */ + function linear_whitespace() + { + do + { + if (substr($this->data, $this->position, 2) === "\x0D\x0A") + { + $this->position += 2; + } + elseif ($this->data[$this->position] === "\x0A") + { + $this->position++; + } + $this->position += strspn($this->data, "\x09\x20", $this->position); + } while ($this->has_data() && $this->is_linear_whitespace()); + $this->value .= "\x20"; + } + + /** + * See what state to move to while within non-quoted header values + * + * @access private + */ + function value() + { + if ($this->is_linear_whitespace()) + { + $this->linear_whitespace(); + } + else + { + switch ($this->data[$this->position]) + { + case '"': + $this->position++; + $this->state = 'quote'; + break; + + case "\x0A": + $this->position++; + $this->state = 'new_line'; + break; + + default: + $this->state = 'value_char'; + break; + } + } + } + + /** + * Parse a header value while outside quotes + * + * @access private + */ + function value_char() + { + $len = strcspn($this->data, "\x09\x20\x0A\"", $this->position); + $this->value .= substr($this->data, $this->position, $len); + $this->position += $len; + $this->state = 'value'; + } + + /** + * See what state to move to while within quoted header values + * + * @access private + */ + function quote() + { + if ($this->is_linear_whitespace()) + { + $this->linear_whitespace(); + } + else + { + switch ($this->data[$this->position]) + { + case '"': + $this->position++; + $this->state = 'value'; + break; + + case "\x0A": + $this->position++; + $this->state = 'new_line'; + break; + + case '\\': + $this->position++; + $this->state = 'quote_escaped'; + break; + + default: + $this->state = 'quote_char'; + break; + } + } + } + + /** + * Parse a header value while within quotes + * + * @access private + */ + function quote_char() + { + $len = strcspn($this->data, "\x09\x20\x0A\"\\", $this->position); + $this->value .= substr($this->data, $this->position, $len); + $this->position += $len; + $this->state = 'value'; + } + + /** + * Parse an escaped character within quotes + * + * @access private + */ + function quote_escaped() + { + $this->value .= $this->data[$this->position]; + $this->position++; + $this->state = 'quote'; + } + + /** + * Parse the body + * + * @access private + */ + function body() + { + $this->body = substr($this->data, $this->position); + $this->state = 'emit'; + } +} + +/** + * gzdecode + * + * @package SimplePie + */ +class SimplePie_gzdecode +{ + /** + * Compressed data + * + * @access private + * @see gzdecode::$data + */ + var $compressed_data; + + /** + * Size of compressed data + * + * @access private + */ + var $compressed_size; + + /** + * Minimum size of a valid gzip string + * + * @access private + */ + var $min_compressed_size = 18; + + /** + * Current position of pointer + * + * @access private + */ + var $position = 0; + + /** + * Flags (FLG) + * + * @access private + */ + var $flags; + + /** + * Uncompressed data + * + * @access public + * @see gzdecode::$compressed_data + */ + var $data; + + /** + * Modified time + * + * @access public + */ + var $MTIME; + + /** + * Extra Flags + * + * @access public + */ + var $XFL; + + /** + * Operating System + * + * @access public + */ + var $OS; + + /** + * Subfield ID 1 + * + * @access public + * @see gzdecode::$extra_field + * @see gzdecode::$SI2 + */ + var $SI1; + + /** + * Subfield ID 2 + * + * @access public + * @see gzdecode::$extra_field + * @see gzdecode::$SI1 + */ + var $SI2; + + /** + * Extra field content + * + * @access public + * @see gzdecode::$SI1 + * @see gzdecode::$SI2 + */ + var $extra_field; + + /** + * Original filename + * + * @access public + */ + var $filename; + + /** + * Human readable comment + * + * @access public + */ + var $comment; + + /** + * Don't allow anything to be set + * + * @access public + */ + function __set($name, $value) + { + trigger_error("Cannot write property $name", E_USER_ERROR); + } + + /** + * Set the compressed string and related properties + * + * @access public + */ + function SimplePie_gzdecode($data) + { + $this->compressed_data = $data; + $this->compressed_size = strlen($data); + } + + /** + * Decode the GZIP stream + * + * @access public + */ + function parse() + { + if ($this->compressed_size >= $this->min_compressed_size) + { + // Check ID1, ID2, and CM + if (substr($this->compressed_data, 0, 3) !== "\x1F\x8B\x08") + { + return false; + } + + // Get the FLG (FLaGs) + $this->flags = ord($this->compressed_data[3]); + + // FLG bits above (1 << 4) are reserved + if ($this->flags > 0x1F) + { + return false; + } + + // Advance the pointer after the above + $this->position += 4; + + // MTIME + $mtime = substr($this->compressed_data, $this->position, 4); + // Reverse the string if we're on a big-endian arch because l is the only signed long and is machine endianness + if (current(unpack('S', "\x00\x01")) === 1) + { + $mtime = strrev($mtime); + } + $this->MTIME = current(unpack('l', $mtime)); + $this->position += 4; + + // Get the XFL (eXtra FLags) + $this->XFL = ord($this->compressed_data[$this->position++]); + + // Get the OS (Operating System) + $this->OS = ord($this->compressed_data[$this->position++]); + + // Parse the FEXTRA + if ($this->flags & 4) + { + // Read subfield IDs + $this->SI1 = $this->compressed_data[$this->position++]; + $this->SI2 = $this->compressed_data[$this->position++]; + + // SI2 set to zero is reserved for future use + if ($this->SI2 === "\x00") + { + return false; + } + + // Get the length of the extra field + $len = current(unpack('v', substr($this->compressed_data, $this->position, 2))); + $position += 2; + + // Check the length of the string is still valid + $this->min_compressed_size += $len + 4; + if ($this->compressed_size >= $this->min_compressed_size) + { + // Set the extra field to the given data + $this->extra_field = substr($this->compressed_data, $this->position, $len); + $this->position += $len; + } + else + { + return false; + } + } + + // Parse the FNAME + if ($this->flags & 8) + { + // Get the length of the filename + $len = strcspn($this->compressed_data, "\x00", $this->position); + + // Check the length of the string is still valid + $this->min_compressed_size += $len + 1; + if ($this->compressed_size >= $this->min_compressed_size) + { + // Set the original filename to the given string + $this->filename = substr($this->compressed_data, $this->position, $len); + $this->position += $len + 1; + } + else + { + return false; + } + } + + // Parse the FCOMMENT + if ($this->flags & 16) + { + // Get the length of the comment + $len = strcspn($this->compressed_data, "\x00", $this->position); + + // Check the length of the string is still valid + $this->min_compressed_size += $len + 1; + if ($this->compressed_size >= $this->min_compressed_size) + { + // Set the original comment to the given string + $this->comment = substr($this->compressed_data, $this->position, $len); + $this->position += $len + 1; + } + else + { + return false; + } + } + + // Parse the FHCRC + if ($this->flags & 2) + { + // Check the length of the string is still valid + $this->min_compressed_size += $len + 2; + if ($this->compressed_size >= $this->min_compressed_size) + { + // Read the CRC + $crc = current(unpack('v', substr($this->compressed_data, $this->position, 2))); + + // Check the CRC matches + if ((crc32(substr($this->compressed_data, 0, $this->position)) & 0xFFFF) === $crc) + { + $this->position += 2; + } + else + { + return false; + } + } + else + { + return false; + } + } + + // Decompress the actual data + if (($this->data = gzinflate(substr($this->compressed_data, $this->position, -8))) === false) + { + return false; + } + else + { + $this->position = $this->compressed_size - 8; + } + + // Check CRC of data + $crc = current(unpack('V', substr($this->compressed_data, $this->position, 4))); + $this->position += 4; + /*if (extension_loaded('hash') && sprintf('%u', current(unpack('V', hash('crc32b', $this->data)))) !== sprintf('%u', $crc)) + { + return false; + }*/ + + // Check ISIZE of data + $isize = current(unpack('V', substr($this->compressed_data, $this->position, 4))); + $this->position += 4; + if (sprintf('%u', strlen($this->data) & 0xFFFFFFFF) !== sprintf('%u', $isize)) + { + return false; + } + + // Wow, against all odds, we've actually got a valid gzip string + return true; + } + else + { + return false; + } + } +} + +class SimplePie_Cache +{ + /** + * Don't call the constructor. Please. + * + * @access private + */ + function SimplePie_Cache() + { + trigger_error('Please call SimplePie_Cache::create() instead of the constructor', E_USER_ERROR); + } + + /** + * Create a new SimplePie_Cache object + * + * @static + * @access public + */ + function create($location, $filename, $extension) + { + $location_iri = new SimplePie_IRI($location); + switch ($location_iri->get_scheme()) + { + case 'mysql': + if (extension_loaded('mysql')) + { + return new SimplePie_Cache_MySQL($location_iri, $filename, $extension); + } + break; + + default: + return new SimplePie_Cache_File($location, $filename, $extension); + } + } +} + +class SimplePie_Cache_File +{ + var $location; + var $filename; + var $extension; + var $name; + + function SimplePie_Cache_File($location, $filename, $extension) + { + $this->location = $location; + $this->filename = $filename; + $this->extension = $extension; + $this->name = "$this->location/$this->filename.$this->extension"; + } + + function save($data) + { + if (file_exists($this->name) && is_writeable($this->name) || file_exists($this->location) && is_writeable($this->location)) + { + if (is_a($data, 'SimplePie')) + { + $data = $data->data; + } + + $data = serialize($data); + + if (function_exists('file_put_contents')) + { + return (bool) file_put_contents($this->name, $data); + } + else + { + $fp = fopen($this->name, 'wb'); + if ($fp) + { + fwrite($fp, $data); + fclose($fp); + return true; + } + } + } + return false; + } + + function load() + { + if (file_exists($this->name) && is_readable($this->name)) + { + return unserialize(file_get_contents($this->name)); + } + return false; + } + + function mtime() + { + if (file_exists($this->name)) + { + return filemtime($this->name); + } + return false; + } + + function touch() + { + if (file_exists($this->name)) + { + return touch($this->name); + } + return false; + } + + function unlink() + { + if (file_exists($this->name)) + { + return unlink($this->name); + } + return false; + } +} + +class SimplePie_Cache_DB +{ + function prepare_simplepie_object_for_cache($data) + { + $items = $data->get_items(); + $items_by_id = array(); + + if (!empty($items)) + { + foreach ($items as $item) + { + $items_by_id[$item->get_id()] = $item; + } + + if (count($items_by_id) !== count($items)) + { + $items_by_id = array(); + foreach ($items as $item) + { + $items_by_id[$item->get_id(true)] = $item; + } + } + + if (isset($data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0])) + { + $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]; + } + elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0])) + { + $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]; + } + elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0])) + { + $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]; + } + elseif (isset($data->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['channel'][0])) + { + $channel =& $data->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][SIMPLEPIE_NAMESPACE_RSS_20]['channel'][0]; + } + else + { + $channel = null; + } + + if ($channel !== null) + { + if (isset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry'])) + { + unset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry']); + } + if (isset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['entry'])) + { + unset($channel['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['entry']); + } + if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item'])) + { + unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_10]['item']); + } + if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item'])) + { + unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_090]['item']); + } + if (isset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_20]['item'])) + { + unset($channel['child'][SIMPLEPIE_NAMESPACE_RSS_20]['item']); + } + } + if (isset($data->data['items'])) + { + unset($data->data['items']); + } + if (isset($data->data['ordered_items'])) + { + unset($data->data['ordered_items']); + } + } + return array(serialize($data->data), $items_by_id); + } +} + +class SimplePie_Cache_MySQL extends SimplePie_Cache_DB +{ + var $mysql; + var $options; + var $id; + + function SimplePie_Cache_MySQL($mysql_location, $name, $extension) + { + $host = $mysql_location->get_host(); + if (SimplePie_Misc::stripos($host, 'unix(') === 0 && substr($host, -1) === ')') + { + $server = ':' . substr($host, 5, -1); + } + else + { + $server = $host; + if ($mysql_location->get_port() !== null) + { + $server .= ':' . $mysql_location->get_port(); + } + } + + if (strpos($mysql_location->get_userinfo(), ':') !== false) + { + list($username, $password) = explode(':', $mysql_location->get_userinfo(), 2); + } + else + { + $username = $mysql_location->get_userinfo(); + $password = null; + } + + if ($this->mysql = mysql_connect($server, $username, $password)) + { + $this->id = $name . $extension; + $this->options = SimplePie_Misc::parse_str($mysql_location->get_query()); + if (!isset($this->options['prefix'][0])) + { + $this->options['prefix'][0] = ''; + } + + if (mysql_select_db(ltrim($mysql_location->get_path(), '/')) + && mysql_query('SET NAMES utf8') + && ($query = mysql_unbuffered_query('SHOW TABLES'))) + { + $db = array(); + while ($row = mysql_fetch_row($query)) + { + $db[] = $row[0]; + } + + if (!in_array($this->options['prefix'][0] . 'cache_data', $db)) + { + if (!mysql_query('CREATE TABLE `' . $this->options['prefix'][0] . 'cache_data` (`id` TEXT CHARACTER SET utf8 NOT NULL, `items` SMALLINT NOT NULL DEFAULT 0, `data` BLOB NOT NULL, `mtime` INT UNSIGNED NOT NULL, UNIQUE (`id`(125)))')) + { + $this->mysql = null; + } + } + + if (!in_array($this->options['prefix'][0] . 'items', $db)) + { + if (!mysql_query('CREATE TABLE `' . $this->options['prefix'][0] . 'items` (`feed_id` TEXT CHARACTER SET utf8 NOT NULL, `id` TEXT CHARACTER SET utf8 NOT NULL, `data` TEXT CHARACTER SET utf8 NOT NULL, `posted` INT UNSIGNED NOT NULL, INDEX `feed_id` (`feed_id`(125)))')) + { + $this->mysql = null; + } + } + } + else + { + $this->mysql = null; + } + } + } + + function save($data) + { + if ($this->mysql) + { + $feed_id = "'" . mysql_real_escape_string($this->id) . "'"; + + if (is_a($data, 'SimplePie')) + { + if (SIMPLEPIE_PHP5) + { + // This keyword needs to defy coding standards for PHP4 compatibility + $data = clone($data); + } + + $prepared = $this->prepare_simplepie_object_for_cache($data); + + if ($query = mysql_query('SELECT `id` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = ' . $feed_id, $this->mysql)) + { + if (mysql_num_rows($query)) + { + $items = count($prepared[1]); + if ($items) + { + $sql = 'UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `items` = ' . $items . ', `data` = \'' . mysql_real_escape_string($prepared[0]) . '\', `mtime` = ' . time() . ' WHERE `id` = ' . $feed_id; + } + else + { + $sql = 'UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `data` = \'' . mysql_real_escape_string($prepared[0]) . '\', `mtime` = ' . time() . ' WHERE `id` = ' . $feed_id; + } + + if (!mysql_query($sql, $this->mysql)) + { + return false; + } + } + elseif (!mysql_query('INSERT INTO `' . $this->options['prefix'][0] . 'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(' . $feed_id . ', ' . count($prepared[1]) . ', \'' . mysql_real_escape_string($prepared[0]) . '\', ' . time() . ')', $this->mysql)) + { + return false; + } + + $ids = array_keys($prepared[1]); + if (!empty($ids)) + { + foreach ($ids as $id) + { + $database_ids[] = mysql_real_escape_string($id); + } + + if ($query = mysql_unbuffered_query('SELECT `id` FROM `' . $this->options['prefix'][0] . 'items` WHERE `id` = \'' . implode('\' OR `id` = \'', $database_ids) . '\' AND `feed_id` = ' . $feed_id, $this->mysql)) + { + $existing_ids = array(); + while ($row = mysql_fetch_row($query)) + { + $existing_ids[] = $row[0]; + } + + $new_ids = array_diff($ids, $existing_ids); + + foreach ($new_ids as $new_id) + { + if (!($date = $prepared[1][$new_id]->get_date('U'))) + { + $date = time(); + } + + if (!mysql_query('INSERT INTO `' . $this->options['prefix'][0] . 'items` (`feed_id`, `id`, `data`, `posted`) VALUES(' . $feed_id . ', \'' . mysql_real_escape_string($new_id) . '\', \'' . mysql_real_escape_string(serialize($prepared[1][$new_id]->data)) . '\', ' . $date . ')', $this->mysql)) + { + return false; + } + } + return true; + } + } + else + { + return true; + } + } + } + elseif ($query = mysql_query('SELECT `id` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = ' . $feed_id, $this->mysql)) + { + if (mysql_num_rows($query)) + { + if (mysql_query('UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `items` = 0, `data` = \'' . mysql_real_escape_string(serialize($data)) . '\', `mtime` = ' . time() . ' WHERE `id` = ' . $feed_id, $this->mysql)) + { + return true; + } + } + elseif (mysql_query('INSERT INTO `' . $this->options['prefix'][0] . 'cache_data` (`id`, `items`, `data`, `mtime`) VALUES(\'' . mysql_real_escape_string($this->id) . '\', 0, \'' . mysql_real_escape_string(serialize($data)) . '\', ' . time() . ')', $this->mysql)) + { + return true; + } + } + } + return false; + } + + function load() + { + if ($this->mysql && ($query = mysql_query('SELECT `items`, `data` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && ($row = mysql_fetch_row($query))) + { + $data = unserialize($row[1]); + + if (isset($this->options['items'][0])) + { + $items = (int) $this->options['items'][0]; + } + else + { + $items = (int) $row[0]; + } + + if ($items !== 0) + { + if (isset($data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0])) + { + $feed =& $data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]; + } + elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0])) + { + $feed =& $data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]; + } + elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0])) + { + $feed =& $data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]; + } + elseif (isset($data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0])) + { + $feed =& $data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]; + } + else + { + $feed = null; + } + + if ($feed !== null) + { + $sql = 'SELECT `data` FROM `' . $this->options['prefix'][0] . 'items` WHERE `feed_id` = \'' . mysql_real_escape_string($this->id) . '\' ORDER BY `posted` DESC'; + if ($items > 0) + { + $sql .= ' LIMIT ' . $items; + } + + if ($query = mysql_unbuffered_query($sql, $this->mysql)) + { + while ($row = mysql_fetch_row($query)) + { + $feed['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['entry'][] = unserialize($row[0]); + } + } + else + { + return false; + } + } + } + return $data; + } + return false; + } + + function mtime() + { + if ($this->mysql && ($query = mysql_query('SELECT `mtime` FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && ($row = mysql_fetch_row($query))) + { + return $row[0]; + } + else + { + return false; + } + } + + function touch() + { + if ($this->mysql && ($query = mysql_query('UPDATE `' . $this->options['prefix'][0] . 'cache_data` SET `mtime` = ' . time() . ' WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && mysql_affected_rows($this->mysql)) + { + return true; + } + else + { + return false; + } + } + + function unlink() + { + if ($this->mysql && ($query = mysql_query('DELETE FROM `' . $this->options['prefix'][0] . 'cache_data` WHERE `id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql)) && ($query2 = mysql_query('DELETE FROM `' . $this->options['prefix'][0] . 'items` WHERE `feed_id` = \'' . mysql_real_escape_string($this->id) . "'", $this->mysql))) + { + return true; + } + else + { + return false; + } + } +} + +class SimplePie_Misc +{ + function time_hms($seconds) + { + $time = ''; + + $hours = floor($seconds / 3600); + $remainder = $seconds % 3600; + if ($hours > 0) + { + $time .= $hours.':'; + } + + $minutes = floor($remainder / 60); + $seconds = $remainder % 60; + if ($minutes < 10 && $hours > 0) + { + $minutes = '0' . $minutes; + } + if ($seconds < 10) + { + $seconds = '0' . $seconds; + } + + $time .= $minutes.':'; + $time .= $seconds; + + return $time; + } + + function absolutize_url($relative, $base) + { + $iri = SimplePie_IRI::absolutize(new SimplePie_IRI($base), $relative); + return $iri->get_iri(); + } + + function remove_dot_segments($input) + { + $output = ''; + while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..') + { + // A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise, + if (strpos($input, '../') === 0) + { + $input = substr($input, 3); + } + elseif (strpos($input, './') === 0) + { + $input = substr($input, 2); + } + // B: if the input buffer begins with a prefix of "/./" or "/.", where "." is a complete path segment, then replace that prefix with "/" in the input buffer; otherwise, + elseif (strpos($input, '/./') === 0) + { + $input = substr_replace($input, '/', 0, 3); + } + elseif ($input === '/.') + { + $input = '/'; + } + // C: if the input buffer begins with a prefix of "/../" or "/..", where ".." is a complete path segment, then replace that prefix with "/" in the input buffer and remove the last segment and its preceding "/" (if any) from the output buffer; otherwise, + elseif (strpos($input, '/../') === 0) + { + $input = substr_replace($input, '/', 0, 4); + $output = substr_replace($output, '', strrpos($output, '/')); + } + elseif ($input === '/..') + { + $input = '/'; + $output = substr_replace($output, '', strrpos($output, '/')); + } + // D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise, + elseif ($input === '.' || $input === '..') + { + $input = ''; + } + // E: move the first path segment in the input buffer to the end of the output buffer, including the initial "/" character (if any) and any subsequent characters up to, but not including, the next "/" character or the end of the input buffer + elseif (($pos = strpos($input, '/', 1)) !== false) + { + $output .= substr($input, 0, $pos); + $input = substr_replace($input, '', 0, $pos); + } + else + { + $output .= $input; + $input = ''; + } + } + return $output . $input; + } + + function get_element($realname, $string) + { + $return = array(); + $name = preg_quote($realname, '/'); + if (preg_match_all("/<($name)" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . "(>(.*)<\/$name>|(\/)?>)/siU", $string, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) + { + for ($i = 0, $total_matches = count($matches); $i < $total_matches; $i++) + { + $return[$i]['tag'] = $realname; + $return[$i]['full'] = $matches[$i][0][0]; + $return[$i]['offset'] = $matches[$i][0][1]; + if (strlen($matches[$i][3][0]) <= 2) + { + $return[$i]['self_closing'] = true; + } + else + { + $return[$i]['self_closing'] = false; + $return[$i]['content'] = $matches[$i][4][0]; + } + $return[$i]['attribs'] = array(); + if (isset($matches[$i][2][0]) && preg_match_all('/[\x09\x0A\x0B\x0C\x0D\x20]+([^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*)(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"([^"]*)"|\'([^\']*)\'|([^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?/', ' ' . $matches[$i][2][0] . ' ', $attribs, PREG_SET_ORDER)) + { + for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++) + { + if (count($attribs[$j]) === 2) + { + $attribs[$j][2] = $attribs[$j][1]; + } + $return[$i]['attribs'][strtolower($attribs[$j][1])]['data'] = SimplePie_Misc::entities_decode(end($attribs[$j]), 'UTF-8'); + } + } + } + } + return $return; + } + + function element_implode($element) + { + $full = "<$element[tag]"; + foreach ($element['attribs'] as $key => $value) + { + $key = strtolower($key); + $full .= " $key=\"" . htmlspecialchars($value['data']) . '"'; + } + if ($element['self_closing']) + { + $full .= ' />'; + } + else + { + $full .= ">$element[content]"; + } + return $full; + } + + function error($message, $level, $file, $line) + { + if ((ini_get('error_reporting') & $level) > 0) + { + switch ($level) + { + case E_USER_ERROR: + $note = 'PHP Error'; + break; + case E_USER_WARNING: + $note = 'PHP Warning'; + break; + case E_USER_NOTICE: + $note = 'PHP Notice'; + break; + default: + $note = 'Unknown Error'; + break; + } + error_log("$note: $message in $file on line $line", 0); + } + return $message; + } + + /** + * If a file has been cached, retrieve and display it. + * + * This is most useful for caching images (get_favicon(), etc.), + * however it works for all cached files. This WILL NOT display ANY + * file/image/page/whatever, but rather only display what has already + * been cached by SimplePie. + * + * @access public + * @see SimplePie::get_favicon() + * @param str $identifier_url URL that is used to identify the content. + * This may or may not be the actual URL of the live content. + * @param str $cache_location Location of SimplePie's cache. Defaults + * to './cache'. + * @param str $cache_extension The file extension that the file was + * cached with. Defaults to 'spc'. + * @param str $cache_class Name of the cache-handling class being used + * in SimplePie. Defaults to 'SimplePie_Cache', and should be left + * as-is unless you've overloaded the class. + * @param str $cache_name_function Obsolete. Exists for backwards + * compatibility reasons only. + */ + function display_cached_file($identifier_url, $cache_location = './cache', $cache_extension = 'spc', $cache_class = 'SimplePie_Cache', $cache_name_function = 'md5') + { + $cache = call_user_func(array($cache_class, 'create'), $cache_location, $identifier_url, $cache_extension); + + if ($file = $cache->load()) + { + if (isset($file['headers']['content-type'])) + { + header('Content-type:' . $file['headers']['content-type']); + } + else + { + header('Content-type: application/octet-stream'); + } + header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days + echo $file['body']; + exit; + } + + die('Cached file for ' . $identifier_url . ' cannot be found.'); + } + + function fix_protocol($url, $http = 1) + { + $url = SimplePie_Misc::normalize_url($url); + $parsed = SimplePie_Misc::parse_url($url); + if ($parsed['scheme'] !== '' && $parsed['scheme'] !== 'http' && $parsed['scheme'] !== 'https') + { + return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['authority'], $parsed['path'], $parsed['query'], $parsed['fragment']), $http); + } + + if ($parsed['scheme'] === '' && $parsed['authority'] === '' && !file_exists($url)) + { + return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['path'], '', $parsed['query'], $parsed['fragment']), $http); + } + + if ($http === 2 && $parsed['scheme'] !== '') + { + return "feed:$url"; + } + elseif ($http === 3 && strtolower($parsed['scheme']) === 'http') + { + return substr_replace($url, 'podcast', 0, 4); + } + elseif ($http === 4 && strtolower($parsed['scheme']) === 'http') + { + return substr_replace($url, 'itpc', 0, 4); + } + else + { + return $url; + } + } + + function parse_url($url) + { + $iri = new SimplePie_IRI($url); + return array( + 'scheme' => (string) $iri->get_scheme(), + 'authority' => (string) $iri->get_authority(), + 'path' => (string) $iri->get_path(), + 'query' => (string) $iri->get_query(), + 'fragment' => (string) $iri->get_fragment() + ); + } + + function compress_parse_url($scheme = '', $authority = '', $path = '', $query = '', $fragment = '') + { + $iri = new SimplePie_IRI(''); + $iri->set_scheme($scheme); + $iri->set_authority($authority); + $iri->set_path($path); + $iri->set_query($query); + $iri->set_fragment($fragment); + return $iri->get_iri(); + } + + function normalize_url($url) + { + $iri = new SimplePie_IRI($url); + return $iri->get_iri(); + } + + function percent_encoding_normalization($match) + { + $integer = hexdec($match[1]); + if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer === 0x2D || $integer === 0x2E || $integer === 0x5F || $integer === 0x7E) + { + return chr($integer); + } + else + { + return strtoupper($match[0]); + } + } + + /** + * Remove bad UTF-8 bytes + * + * PCRE Pattern to locate bad bytes in a UTF-8 string comes from W3C + * FAQ: Multilingual Forms (modified to include full ASCII range) + * + * @author Geoffrey Sneddon + * @see http://www.w3.org/International/questions/qa-forms-utf-8 + * @param string $str String to remove bad UTF-8 bytes from + * @return string UTF-8 string + */ + function utf8_bad_replace($str) + { + if (function_exists('iconv') && ($return = @iconv('UTF-8', 'UTF-8//IGNORE', $str))) + { + return $return; + } + elseif (function_exists('mb_convert_encoding') && ($return = @mb_convert_encoding($str, 'UTF-8', 'UTF-8'))) + { + return $return; + } + elseif (preg_match_all('/(?:[\x00-\x7F]|[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})+/', $str, $matches)) + { + return implode("\xEF\xBF\xBD", $matches[0]); + } + elseif ($str !== '') + { + return "\xEF\xBF\xBD"; + } + else + { + return ''; + } + } + + /** + * Converts a Windows-1252 encoded string to a UTF-8 encoded string + * + * @static + * @access public + * @param string $string Windows-1252 encoded string + * @return string UTF-8 encoded string + */ + function windows_1252_to_utf8($string) + { + static $convert_table = array("\x80" => "\xE2\x82\xAC", "\x81" => "\xEF\xBF\xBD", "\x82" => "\xE2\x80\x9A", "\x83" => "\xC6\x92", "\x84" => "\xE2\x80\x9E", "\x85" => "\xE2\x80\xA6", "\x86" => "\xE2\x80\xA0", "\x87" => "\xE2\x80\xA1", "\x88" => "\xCB\x86", "\x89" => "\xE2\x80\xB0", "\x8A" => "\xC5\xA0", "\x8B" => "\xE2\x80\xB9", "\x8C" => "\xC5\x92", "\x8D" => "\xEF\xBF\xBD", "\x8E" => "\xC5\xBD", "\x8F" => "\xEF\xBF\xBD", "\x90" => "\xEF\xBF\xBD", "\x91" => "\xE2\x80\x98", "\x92" => "\xE2\x80\x99", "\x93" => "\xE2\x80\x9C", "\x94" => "\xE2\x80\x9D", "\x95" => "\xE2\x80\xA2", "\x96" => "\xE2\x80\x93", "\x97" => "\xE2\x80\x94", "\x98" => "\xCB\x9C", "\x99" => "\xE2\x84\xA2", "\x9A" => "\xC5\xA1", "\x9B" => "\xE2\x80\xBA", "\x9C" => "\xC5\x93", "\x9D" => "\xEF\xBF\xBD", "\x9E" => "\xC5\xBE", "\x9F" => "\xC5\xB8", "\xA0" => "\xC2\xA0", "\xA1" => "\xC2\xA1", "\xA2" => "\xC2\xA2", "\xA3" => "\xC2\xA3", "\xA4" => "\xC2\xA4", "\xA5" => "\xC2\xA5", "\xA6" => "\xC2\xA6", "\xA7" => "\xC2\xA7", "\xA8" => "\xC2\xA8", "\xA9" => "\xC2\xA9", "\xAA" => "\xC2\xAA", "\xAB" => "\xC2\xAB", "\xAC" => "\xC2\xAC", "\xAD" => "\xC2\xAD", "\xAE" => "\xC2\xAE", "\xAF" => "\xC2\xAF", "\xB0" => "\xC2\xB0", "\xB1" => "\xC2\xB1", "\xB2" => "\xC2\xB2", "\xB3" => "\xC2\xB3", "\xB4" => "\xC2\xB4", "\xB5" => "\xC2\xB5", "\xB6" => "\xC2\xB6", "\xB7" => "\xC2\xB7", "\xB8" => "\xC2\xB8", "\xB9" => "\xC2\xB9", "\xBA" => "\xC2\xBA", "\xBB" => "\xC2\xBB", "\xBC" => "\xC2\xBC", "\xBD" => "\xC2\xBD", "\xBE" => "\xC2\xBE", "\xBF" => "\xC2\xBF", "\xC0" => "\xC3\x80", "\xC1" => "\xC3\x81", "\xC2" => "\xC3\x82", "\xC3" => "\xC3\x83", "\xC4" => "\xC3\x84", "\xC5" => "\xC3\x85", "\xC6" => "\xC3\x86", "\xC7" => "\xC3\x87", "\xC8" => "\xC3\x88", "\xC9" => "\xC3\x89", "\xCA" => "\xC3\x8A", "\xCB" => "\xC3\x8B", "\xCC" => "\xC3\x8C", "\xCD" => "\xC3\x8D", "\xCE" => "\xC3\x8E", "\xCF" => "\xC3\x8F", "\xD0" => "\xC3\x90", "\xD1" => "\xC3\x91", "\xD2" => "\xC3\x92", "\xD3" => "\xC3\x93", "\xD4" => "\xC3\x94", "\xD5" => "\xC3\x95", "\xD6" => "\xC3\x96", "\xD7" => "\xC3\x97", "\xD8" => "\xC3\x98", "\xD9" => "\xC3\x99", "\xDA" => "\xC3\x9A", "\xDB" => "\xC3\x9B", "\xDC" => "\xC3\x9C", "\xDD" => "\xC3\x9D", "\xDE" => "\xC3\x9E", "\xDF" => "\xC3\x9F", "\xE0" => "\xC3\xA0", "\xE1" => "\xC3\xA1", "\xE2" => "\xC3\xA2", "\xE3" => "\xC3\xA3", "\xE4" => "\xC3\xA4", "\xE5" => "\xC3\xA5", "\xE6" => "\xC3\xA6", "\xE7" => "\xC3\xA7", "\xE8" => "\xC3\xA8", "\xE9" => "\xC3\xA9", "\xEA" => "\xC3\xAA", "\xEB" => "\xC3\xAB", "\xEC" => "\xC3\xAC", "\xED" => "\xC3\xAD", "\xEE" => "\xC3\xAE", "\xEF" => "\xC3\xAF", "\xF0" => "\xC3\xB0", "\xF1" => "\xC3\xB1", "\xF2" => "\xC3\xB2", "\xF3" => "\xC3\xB3", "\xF4" => "\xC3\xB4", "\xF5" => "\xC3\xB5", "\xF6" => "\xC3\xB6", "\xF7" => "\xC3\xB7", "\xF8" => "\xC3\xB8", "\xF9" => "\xC3\xB9", "\xFA" => "\xC3\xBA", "\xFB" => "\xC3\xBB", "\xFC" => "\xC3\xBC", "\xFD" => "\xC3\xBD", "\xFE" => "\xC3\xBE", "\xFF" => "\xC3\xBF"); + + return strtr($string, $convert_table); + } + + function change_encoding($data, $input, $output) + { + $input = SimplePie_Misc::encoding($input); + $output = SimplePie_Misc::encoding($output); + + // We fail to fail on non US-ASCII bytes + if ($input === 'US-ASCII') + { + static $non_ascii_octects = ''; + if (!$non_ascii_octects) + { + for ($i = 0x80; $i <= 0xFF; $i++) + { + $non_ascii_octects .= chr($i); + } + } + $data = substr($data, 0, strcspn($data, $non_ascii_octects)); + } + + // This is first, as behaviour of this is completely predictable + if ($input === 'Windows-1252' && $output === 'UTF-8') + { + return SimplePie_Misc::windows_1252_to_utf8($data); + } + // This is second, as behaviour of this varies only with PHP version (the middle part of this expression checks the encoding is supported). + elseif (function_exists('mb_convert_encoding') && @mb_convert_encoding("\x80", 'UTF-16BE', $input) !== "\x00\x80" && ($return = @mb_convert_encoding($data, $output, $input))) + { + return $return; + } + // This is last, as behaviour of this varies with OS userland and PHP version + elseif (function_exists('iconv') && ($return = @iconv($input, $output, $data))) + { + return $return; + } + // If we can't do anything, just fail + else + { + return false; + } + } + + function encoding($charset) + { + // Normalization from UTS #22 + switch (strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset))) + { + case 'adobestandardencoding': + case 'csadobestandardencoding': + return 'Adobe-Standard-Encoding'; + + case 'adobesymbolencoding': + case 'cshppsmath': + return 'Adobe-Symbol-Encoding'; + + case 'ami1251': + case 'amiga1251': + return 'Amiga-1251'; + + case 'ansix31101983': + case 'csat5001983': + case 'csiso99naplps': + case 'isoir99': + case 'naplps': + return 'ANSI_X3.110-1983'; + + case 'arabic7': + case 'asmo449': + case 'csiso89asmo449': + case 'iso9036': + case 'isoir89': + return 'ASMO_449'; + + case 'big5': + case 'csbig5': + case 'xxbig5': + return 'Big5'; + + case 'big5hkscs': + return 'Big5-HKSCS'; + + case 'bocu1': + case 'csbocu1': + return 'BOCU-1'; + + case 'brf': + case 'csbrf': + return 'BRF'; + + case 'bs4730': + case 'csiso4unitedkingdom': + case 'gb': + case 'iso646gb': + case 'isoir4': + case 'uk': + return 'BS_4730'; + + case 'bsviewdata': + case 'csiso47bsviewdata': + case 'isoir47': + return 'BS_viewdata'; + + case 'cesu8': + case 'cscesu8': + return 'CESU-8'; + + case 'ca': + case 'csa71': + case 'csaz243419851': + case 'csiso121canadian1': + case 'iso646ca': + case 'isoir121': + return 'CSA_Z243.4-1985-1'; + + case 'csa72': + case 'csaz243419852': + case 'csiso122canadian2': + case 'iso646ca2': + case 'isoir122': + return 'CSA_Z243.4-1985-2'; + + case 'csaz24341985gr': + case 'csiso123csaz24341985gr': + case 'isoir123': + return 'CSA_Z243.4-1985-gr'; + + case 'csiso139csn369103': + case 'csn369103': + case 'isoir139': + return 'CSN_369103'; + + case 'csdecmcs': + case 'dec': + case 'decmcs': + return 'DEC-MCS'; + + case 'csiso21german': + case 'de': + case 'din66003': + case 'iso646de': + case 'isoir21': + return 'DIN_66003'; + + case 'csdkus': + case 'dkus': + return 'dk-us'; + + case 'csiso646danish': + case 'dk': + case 'ds2089': + case 'iso646dk': + return 'DS_2089'; + + case 'csibmebcdicatde': + case 'ebcdicatde': + return 'EBCDIC-AT-DE'; + + case 'csebcdicatdea': + case 'ebcdicatdea': + return 'EBCDIC-AT-DE-A'; + + case 'csebcdiccafr': + case 'ebcdiccafr': + return 'EBCDIC-CA-FR'; + + case 'csebcdicdkno': + case 'ebcdicdkno': + return 'EBCDIC-DK-NO'; + + case 'csebcdicdknoa': + case 'ebcdicdknoa': + return 'EBCDIC-DK-NO-A'; + + case 'csebcdices': + case 'ebcdices': + return 'EBCDIC-ES'; + + case 'csebcdicesa': + case 'ebcdicesa': + return 'EBCDIC-ES-A'; + + case 'csebcdicess': + case 'ebcdicess': + return 'EBCDIC-ES-S'; + + case 'csebcdicfise': + case 'ebcdicfise': + return 'EBCDIC-FI-SE'; + + case 'csebcdicfisea': + case 'ebcdicfisea': + return 'EBCDIC-FI-SE-A'; + + case 'csebcdicfr': + case 'ebcdicfr': + return 'EBCDIC-FR'; + + case 'csebcdicit': + case 'ebcdicit': + return 'EBCDIC-IT'; + + case 'csebcdicpt': + case 'ebcdicpt': + return 'EBCDIC-PT'; + + case 'csebcdicuk': + case 'ebcdicuk': + return 'EBCDIC-UK'; + + case 'csebcdicus': + case 'ebcdicus': + return 'EBCDIC-US'; + + case 'csiso111ecmacyrillic': + case 'ecmacyrillic': + case 'isoir111': + case 'koi8e': + return 'ECMA-cyrillic'; + + case 'csiso17spanish': + case 'es': + case 'iso646es': + case 'isoir17': + return 'ES'; + + case 'csiso85spanish2': + case 'es2': + case 'iso646es2': + case 'isoir85': + return 'ES2'; + + case 'cseucfixwidjapanese': + case 'extendedunixcodefixedwidthforjapanese': + return 'Extended_UNIX_Code_Fixed_Width_for_Japanese'; + + case 'cseucpkdfmtjapanese': + case 'eucjp': + case 'extendedunixcodepackedformatforjapanese': + return 'Extended_UNIX_Code_Packed_Format_for_Japanese'; + + case 'gb18030': + return 'GB18030'; + + case 'chinese': + case 'cp936': + case 'csgb2312': + case 'csiso58gb231280': + case 'gb2312': + case 'gb231280': + case 'gbk': + case 'isoir58': + case 'ms936': + case 'windows936': + return 'GBK'; + + case 'cn': + case 'csiso57gb1988': + case 'gb198880': + case 'iso646cn': + case 'isoir57': + return 'GB_1988-80'; + + case 'csiso153gost1976874': + case 'gost1976874': + case 'isoir153': + case 'stsev35888': + return 'GOST_19768-74'; + + case 'csiso150': + case 'csiso150greekccitt': + case 'greekccitt': + case 'isoir150': + return 'greek-ccitt'; + + case 'csiso88greek7': + case 'greek7': + case 'isoir88': + return 'greek7'; + + case 'csiso18greek7old': + case 'greek7old': + case 'isoir18': + return 'greek7-old'; + + case 'cshpdesktop': + case 'hpdesktop': + return 'HP-DeskTop'; + + case 'cshplegal': + case 'hplegal': + return 'HP-Legal'; + + case 'cshpmath8': + case 'hpmath8': + return 'HP-Math8'; + + case 'cshppifont': + case 'hppifont': + return 'HP-Pi-font'; + + case 'cshproman8': + case 'hproman8': + case 'r8': + case 'roman8': + return 'hp-roman8'; + + case 'hzgb2312': + return 'HZ-GB-2312'; + + case 'csibmsymbols': + case 'ibmsymbols': + return 'IBM-Symbols'; + + case 'csibmthai': + case 'ibmthai': + return 'IBM-Thai'; + + case 'ccsid858': + case 'cp858': + case 'ibm858': + case 'pcmultilingual850euro': + return 'IBM00858'; + + case 'ccsid924': + case 'cp924': + case 'ebcdiclatin9euro': + case 'ibm924': + return 'IBM00924'; + + case 'ccsid1140': + case 'cp1140': + case 'ebcdicus37euro': + case 'ibm1140': + return 'IBM01140'; + + case 'ccsid1141': + case 'cp1141': + case 'ebcdicde273euro': + case 'ibm1141': + return 'IBM01141'; + + case 'ccsid1142': + case 'cp1142': + case 'ebcdicdk277euro': + case 'ebcdicno277euro': + case 'ibm1142': + return 'IBM01142'; + + case 'ccsid1143': + case 'cp1143': + case 'ebcdicfi278euro': + case 'ebcdicse278euro': + case 'ibm1143': + return 'IBM01143'; + + case 'ccsid1144': + case 'cp1144': + case 'ebcdicit280euro': + case 'ibm1144': + return 'IBM01144'; + + case 'ccsid1145': + case 'cp1145': + case 'ebcdices284euro': + case 'ibm1145': + return 'IBM01145'; + + case 'ccsid1146': + case 'cp1146': + case 'ebcdicgb285euro': + case 'ibm1146': + return 'IBM01146'; + + case 'ccsid1147': + case 'cp1147': + case 'ebcdicfr297euro': + case 'ibm1147': + return 'IBM01147'; + + case 'ccsid1148': + case 'cp1148': + case 'ebcdicinternational500euro': + case 'ibm1148': + return 'IBM01148'; + + case 'ccsid1149': + case 'cp1149': + case 'ebcdicis871euro': + case 'ibm1149': + return 'IBM01149'; + + case 'cp37': + case 'csibm37': + case 'ebcdiccpca': + case 'ebcdiccpnl': + case 'ebcdiccpus': + case 'ebcdiccpwt': + case 'ibm37': + return 'IBM037'; + + case 'cp38': + case 'csibm38': + case 'ebcdicint': + case 'ibm38': + return 'IBM038'; + + case 'cp273': + case 'csibm273': + case 'ibm273': + return 'IBM273'; + + case 'cp274': + case 'csibm274': + case 'ebcdicbe': + case 'ibm274': + return 'IBM274'; + + case 'cp275': + case 'csibm275': + case 'ebcdicbr': + case 'ibm275': + return 'IBM275'; + + case 'csibm277': + case 'ebcdiccpdk': + case 'ebcdiccpno': + case 'ibm277': + return 'IBM277'; + + case 'cp278': + case 'csibm278': + case 'ebcdiccpfi': + case 'ebcdiccpse': + case 'ibm278': + return 'IBM278'; + + case 'cp280': + case 'csibm280': + case 'ebcdiccpit': + case 'ibm280': + return 'IBM280'; + + case 'cp281': + case 'csibm281': + case 'ebcdicjpe': + case 'ibm281': + return 'IBM281'; + + case 'cp284': + case 'csibm284': + case 'ebcdiccpes': + case 'ibm284': + return 'IBM284'; + + case 'cp285': + case 'csibm285': + case 'ebcdiccpgb': + case 'ibm285': + return 'IBM285'; + + case 'cp290': + case 'csibm290': + case 'ebcdicjpkana': + case 'ibm290': + return 'IBM290'; + + case 'cp297': + case 'csibm297': + case 'ebcdiccpfr': + case 'ibm297': + return 'IBM297'; + + case 'cp420': + case 'csibm420': + case 'ebcdiccpar1': + case 'ibm420': + return 'IBM420'; + + case 'cp423': + case 'csibm423': + case 'ebcdiccpgr': + case 'ibm423': + return 'IBM423'; + + case 'cp424': + case 'csibm424': + case 'ebcdiccphe': + case 'ibm424': + return 'IBM424'; + + case '437': + case 'cp437': + case 'cspc8codepage437': + case 'ibm437': + return 'IBM437'; + + case 'cp500': + case 'csibm500': + case 'ebcdiccpbe': + case 'ebcdiccpch': + case 'ibm500': + return 'IBM500'; + + case 'cp775': + case 'cspc775baltic': + case 'ibm775': + return 'IBM775'; + + case '850': + case 'cp850': + case 'cspc850multilingual': + case 'ibm850': + return 'IBM850'; + + case '851': + case 'cp851': + case 'csibm851': + case 'ibm851': + return 'IBM851'; + + case '852': + case 'cp852': + case 'cspcp852': + case 'ibm852': + return 'IBM852'; + + case '855': + case 'cp855': + case 'csibm855': + case 'ibm855': + return 'IBM855'; + + case '857': + case 'cp857': + case 'csibm857': + case 'ibm857': + return 'IBM857'; + + case '860': + case 'cp860': + case 'csibm860': + case 'ibm860': + return 'IBM860'; + + case '861': + case 'cp861': + case 'cpis': + case 'csibm861': + case 'ibm861': + return 'IBM861'; + + case '862': + case 'cp862': + case 'cspc862latinhebrew': + case 'ibm862': + return 'IBM862'; + + case '863': + case 'cp863': + case 'csibm863': + case 'ibm863': + return 'IBM863'; + + case 'cp864': + case 'csibm864': + case 'ibm864': + return 'IBM864'; + + case '865': + case 'cp865': + case 'csibm865': + case 'ibm865': + return 'IBM865'; + + case '866': + case 'cp866': + case 'csibm866': + case 'ibm866': + return 'IBM866'; + + case 'cp868': + case 'cpar': + case 'csibm868': + case 'ibm868': + return 'IBM868'; + + case '869': + case 'cp869': + case 'cpgr': + case 'csibm869': + case 'ibm869': + return 'IBM869'; + + case 'cp870': + case 'csibm870': + case 'ebcdiccproece': + case 'ebcdiccpyu': + case 'ibm870': + return 'IBM870'; + + case 'cp871': + case 'csibm871': + case 'ebcdiccpis': + case 'ibm871': + return 'IBM871'; + + case 'cp880': + case 'csibm880': + case 'ebcdiccyrillic': + case 'ibm880': + return 'IBM880'; + + case 'cp891': + case 'csibm891': + case 'ibm891': + return 'IBM891'; + + case 'cp903': + case 'csibm903': + case 'ibm903': + return 'IBM903'; + + case '904': + case 'cp904': + case 'csibbm904': + case 'ibm904': + return 'IBM904'; + + case 'cp905': + case 'csibm905': + case 'ebcdiccptr': + case 'ibm905': + return 'IBM905'; + + case 'cp918': + case 'csibm918': + case 'ebcdiccpar2': + case 'ibm918': + return 'IBM918'; + + case 'cp1026': + case 'csibm1026': + case 'ibm1026': + return 'IBM1026'; + + case 'ibm1047': + return 'IBM1047'; + + case 'csiso143iecp271': + case 'iecp271': + case 'isoir143': + return 'IEC_P27-1'; + + case 'csiso49inis': + case 'inis': + case 'isoir49': + return 'INIS'; + + case 'csiso50inis8': + case 'inis8': + case 'isoir50': + return 'INIS-8'; + + case 'csiso51iniscyrillic': + case 'iniscyrillic': + case 'isoir51': + return 'INIS-cyrillic'; + + case 'csinvariant': + case 'invariant': + return 'INVARIANT'; + + case 'iso2022cn': + return 'ISO-2022-CN'; + + case 'iso2022cnext': + return 'ISO-2022-CN-EXT'; + + case 'csiso2022jp': + case 'iso2022jp': + return 'ISO-2022-JP'; + + case 'csiso2022jp2': + case 'iso2022jp2': + return 'ISO-2022-JP-2'; + + case 'csiso2022kr': + case 'iso2022kr': + return 'ISO-2022-KR'; + + case 'cswindows30latin1': + case 'iso88591windows30latin1': + return 'ISO-8859-1-Windows-3.0-Latin-1'; + + case 'cswindows31latin1': + case 'iso88591windows31latin1': + return 'ISO-8859-1-Windows-3.1-Latin-1'; + + case 'csisolatin2': + case 'iso88592': + case 'iso885921987': + case 'isoir101': + case 'l2': + case 'latin2': + return 'ISO-8859-2'; + + case 'cswindows31latin2': + case 'iso88592windowslatin2': + return 'ISO-8859-2-Windows-Latin-2'; + + case 'csisolatin3': + case 'iso88593': + case 'iso885931988': + case 'isoir109': + case 'l3': + case 'latin3': + return 'ISO-8859-3'; + + case 'csisolatin4': + case 'iso88594': + case 'iso885941988': + case 'isoir110': + case 'l4': + case 'latin4': + return 'ISO-8859-4'; + + case 'csisolatincyrillic': + case 'cyrillic': + case 'iso88595': + case 'iso885951988': + case 'isoir144': + return 'ISO-8859-5'; + + case 'arabic': + case 'asmo708': + case 'csisolatinarabic': + case 'ecma114': + case 'iso88596': + case 'iso885961987': + case 'isoir127': + return 'ISO-8859-6'; + + case 'csiso88596e': + case 'iso88596e': + return 'ISO-8859-6-E'; + + case 'csiso88596i': + case 'iso88596i': + return 'ISO-8859-6-I'; + + case 'csisolatingreek': + case 'ecma118': + case 'elot928': + case 'greek': + case 'greek8': + case 'iso88597': + case 'iso885971987': + case 'isoir126': + return 'ISO-8859-7'; + + case 'csisolatinhebrew': + case 'hebrew': + case 'iso88598': + case 'iso885981988': + case 'isoir138': + return 'ISO-8859-8'; + + case 'csiso88598e': + case 'iso88598e': + return 'ISO-8859-8-E'; + + case 'csiso88598i': + case 'iso88598i': + return 'ISO-8859-8-I'; + + case 'cswindows31latin5': + case 'iso88599windowslatin5': + return 'ISO-8859-9-Windows-Latin-5'; + + case 'csisolatin6': + case 'iso885910': + case 'iso8859101992': + case 'isoir157': + case 'l6': + case 'latin6': + return 'ISO-8859-10'; + + case 'iso885913': + return 'ISO-8859-13'; + + case 'iso885914': + case 'iso8859141998': + case 'isoceltic': + case 'isoir199': + case 'l8': + case 'latin8': + return 'ISO-8859-14'; + + case 'iso885915': + case 'latin9': + return 'ISO-8859-15'; + + case 'iso885916': + case 'iso8859162001': + case 'isoir226': + case 'l10': + case 'latin10': + return 'ISO-8859-16'; + + case 'iso10646j1': + return 'ISO-10646-J-1'; + + case 'csunicode': + case 'iso10646ucs2': + return 'ISO-10646-UCS-2'; + + case 'csucs4': + case 'iso10646ucs4': + return 'ISO-10646-UCS-4'; + + case 'csunicodeascii': + case 'iso10646ucsbasic': + return 'ISO-10646-UCS-Basic'; + + case 'csunicodelatin1': + case 'iso10646': + case 'iso10646unicodelatin1': + return 'ISO-10646-Unicode-Latin1'; + + case 'csiso10646utf1': + case 'iso10646utf1': + return 'ISO-10646-UTF-1'; + + case 'csiso115481': + case 'iso115481': + case 'isotr115481': + return 'ISO-11548-1'; + + case 'csiso90': + case 'isoir90': + return 'iso-ir-90'; + + case 'csunicodeibm1261': + case 'isounicodeibm1261': + return 'ISO-Unicode-IBM-1261'; + + case 'csunicodeibm1264': + case 'isounicodeibm1264': + return 'ISO-Unicode-IBM-1264'; + + case 'csunicodeibm1265': + case 'isounicodeibm1265': + return 'ISO-Unicode-IBM-1265'; + + case 'csunicodeibm1268': + case 'isounicodeibm1268': + return 'ISO-Unicode-IBM-1268'; + + case 'csunicodeibm1276': + case 'isounicodeibm1276': + return 'ISO-Unicode-IBM-1276'; + + case 'csiso646basic1983': + case 'iso646basic1983': + case 'ref': + return 'ISO_646.basic:1983'; + + case 'csiso2intlrefversion': + case 'irv': + case 'iso646irv1983': + case 'isoir2': + return 'ISO_646.irv:1983'; + + case 'csiso2033': + case 'e13b': + case 'iso20331983': + case 'isoir98': + return 'ISO_2033-1983'; + + case 'csiso5427cyrillic': + case 'iso5427': + case 'isoir37': + return 'ISO_5427'; + + case 'iso5427cyrillic1981': + case 'iso54271981': + case 'isoir54': + return 'ISO_5427:1981'; + + case 'csiso5428greek': + case 'iso54281980': + case 'isoir55': + return 'ISO_5428:1980'; + + case 'csiso6937add': + case 'iso6937225': + case 'isoir152': + return 'ISO_6937-2-25'; + + case 'csisotextcomm': + case 'iso69372add': + case 'isoir142': + return 'ISO_6937-2-add'; + + case 'csiso8859supp': + case 'iso8859supp': + case 'isoir154': + case 'latin125': + return 'ISO_8859-supp'; + + case 'csiso10367box': + case 'iso10367box': + case 'isoir155': + return 'ISO_10367-box'; + + case 'csiso15italian': + case 'iso646it': + case 'isoir15': + case 'it': + return 'IT'; + + case 'csiso13jisc6220jp': + case 'isoir13': + case 'jisc62201969': + case 'jisc62201969jp': + case 'katakana': + case 'x2017': + return 'JIS_C6220-1969-jp'; + + case 'csiso14jisc6220ro': + case 'iso646jp': + case 'isoir14': + case 'jisc62201969ro': + case 'jp': + return 'JIS_C6220-1969-ro'; + + case 'csiso42jisc62261978': + case 'isoir42': + case 'jisc62261978': + return 'JIS_C6226-1978'; + + case 'csiso87jisx208': + case 'isoir87': + case 'jisc62261983': + case 'jisx2081983': + case 'x208': + return 'JIS_C6226-1983'; + + case 'csiso91jisc62291984a': + case 'isoir91': + case 'jisc62291984a': + case 'jpocra': + return 'JIS_C6229-1984-a'; + + case 'csiso92jisc62991984b': + case 'iso646jpocrb': + case 'isoir92': + case 'jisc62291984b': + case 'jpocrb': + return 'JIS_C6229-1984-b'; + + case 'csiso93jis62291984badd': + case 'isoir93': + case 'jisc62291984badd': + case 'jpocrbadd': + return 'JIS_C6229-1984-b-add'; + + case 'csiso94jis62291984hand': + case 'isoir94': + case 'jisc62291984hand': + case 'jpocrhand': + return 'JIS_C6229-1984-hand'; + + case 'csiso95jis62291984handadd': + case 'isoir95': + case 'jisc62291984handadd': + case 'jpocrhandadd': + return 'JIS_C6229-1984-hand-add'; + + case 'csiso96jisc62291984kana': + case 'isoir96': + case 'jisc62291984kana': + return 'JIS_C6229-1984-kana'; + + case 'csjisencoding': + case 'jisencoding': + return 'JIS_Encoding'; + + case 'cshalfwidthkatakana': + case 'jisx201': + case 'x201': + return 'JIS_X0201'; + + case 'csiso159jisx2121990': + case 'isoir159': + case 'jisx2121990': + case 'x212': + return 'JIS_X0212-1990'; + + case 'csiso141jusib1002': + case 'iso646yu': + case 'isoir141': + case 'js': + case 'jusib1002': + case 'yu': + return 'JUS_I.B1.002'; + + case 'csiso147macedonian': + case 'isoir147': + case 'jusib1003mac': + case 'macedonian': + return 'JUS_I.B1.003-mac'; + + case 'csiso146serbian': + case 'isoir146': + case 'jusib1003serb': + case 'serbian': + return 'JUS_I.B1.003-serb'; + + case 'koi7switched': + return 'KOI7-switched'; + + case 'cskoi8r': + case 'koi8r': + return 'KOI8-R'; + + case 'koi8u': + return 'KOI8-U'; + + case 'csksc5636': + case 'iso646kr': + case 'ksc5636': + return 'KSC5636'; + + case 'cskz1048': + case 'kz1048': + case 'rk1048': + case 'strk10482002': + return 'KZ-1048'; + + case 'csiso19latingreek': + case 'isoir19': + case 'latingreek': + return 'latin-greek'; + + case 'csiso27latingreek1': + case 'isoir27': + case 'latingreek1': + return 'Latin-greek-1'; + + case 'csiso158lap': + case 'isoir158': + case 'lap': + case 'latinlap': + return 'latin-lap'; + + case 'csmacintosh': + case 'mac': + case 'macintosh': + return 'macintosh'; + + case 'csmicrosoftpublishing': + case 'microsoftpublishing': + return 'Microsoft-Publishing'; + + case 'csmnem': + case 'mnem': + return 'MNEM'; + + case 'csmnemonic': + case 'mnemonic': + return 'MNEMONIC'; + + case 'csiso86hungarian': + case 'hu': + case 'iso646hu': + case 'isoir86': + case 'msz77953': + return 'MSZ_7795.3'; + + case 'csnatsdano': + case 'isoir91': + case 'natsdano': + return 'NATS-DANO'; + + case 'csnatsdanoadd': + case 'isoir92': + case 'natsdanoadd': + return 'NATS-DANO-ADD'; + + case 'csnatssefi': + case 'isoir81': + case 'natssefi': + return 'NATS-SEFI'; + + case 'csnatssefiadd': + case 'isoir82': + case 'natssefiadd': + return 'NATS-SEFI-ADD'; + + case 'csiso151cuba': + case 'cuba': + case 'iso646cu': + case 'isoir151': + case 'ncnc1081': + return 'NC_NC00-10:81'; + + case 'csiso69french': + case 'fr': + case 'iso646fr': + case 'isoir69': + case 'nfz62010': + return 'NF_Z_62-010'; + + case 'csiso25french': + case 'iso646fr1': + case 'isoir25': + case 'nfz620101973': + return 'NF_Z_62-010_(1973)'; + + case 'csiso60danishnorwegian': + case 'csiso60norwegian1': + case 'iso646no': + case 'isoir60': + case 'no': + case 'ns45511': + return 'NS_4551-1'; + + case 'csiso61norwegian2': + case 'iso646no2': + case 'isoir61': + case 'no2': + case 'ns45512': + return 'NS_4551-2'; + + case 'osdebcdicdf3irv': + return 'OSD_EBCDIC_DF03_IRV'; + + case 'osdebcdicdf41': + return 'OSD_EBCDIC_DF04_1'; + + case 'osdebcdicdf415': + return 'OSD_EBCDIC_DF04_15'; + + case 'cspc8danishnorwegian': + case 'pc8danishnorwegian': + return 'PC8-Danish-Norwegian'; + + case 'cspc8turkish': + case 'pc8turkish': + return 'PC8-Turkish'; + + case 'csiso16portuguese': + case 'iso646pt': + case 'isoir16': + case 'pt': + return 'PT'; + + case 'csiso84portuguese2': + case 'iso646pt2': + case 'isoir84': + case 'pt2': + return 'PT2'; + + case 'cp154': + case 'csptcp154': + case 'cyrillicasian': + case 'pt154': + case 'ptcp154': + return 'PTCP154'; + + case 'scsu': + return 'SCSU'; + + case 'csiso10swedish': + case 'fi': + case 'iso646fi': + case 'iso646se': + case 'isoir10': + case 'se': + case 'sen850200b': + return 'SEN_850200_B'; + + case 'csiso11swedishfornames': + case 'iso646se2': + case 'isoir11': + case 'se2': + case 'sen850200c': + return 'SEN_850200_C'; + + case 'csshiftjis': + case 'mskanji': + case 'shiftjis': + return 'Shift_JIS'; + + case 'csiso102t617bit': + case 'isoir102': + case 't617bit': + return 'T.61-7bit'; + + case 'csiso103t618bit': + case 'isoir103': + case 't61': + case 't618bit': + return 'T.61-8bit'; + + case 'csiso128t101g2': + case 'isoir128': + case 't101g2': + return 'T.101-G2'; + + case 'cstscii': + case 'tscii': + return 'TSCII'; + + case 'csunicode11': + case 'unicode11': + return 'UNICODE-1-1'; + + case 'csunicode11utf7': + case 'unicode11utf7': + return 'UNICODE-1-1-UTF-7'; + + case 'csunknown8bit': + case 'unknown8bit': + return 'UNKNOWN-8BIT'; + + case 'ansix341968': + case 'ansix341986': + case 'ascii': + case 'cp367': + case 'csascii': + case 'ibm367': + case 'iso646irv1991': + case 'iso646us': + case 'isoir6': + case 'us': + case 'usascii': + return 'US-ASCII'; + + case 'csusdk': + case 'usdk': + return 'us-dk'; + + case 'utf7': + return 'UTF-7'; + + case 'utf8': + return 'UTF-8'; + + case 'utf16': + return 'UTF-16'; + + case 'utf16be': + return 'UTF-16BE'; + + case 'utf16le': + return 'UTF-16LE'; + + case 'utf32': + return 'UTF-32'; + + case 'utf32be': + return 'UTF-32BE'; + + case 'utf32le': + return 'UTF-32LE'; + + case 'csventurainternational': + case 'venturainternational': + return 'Ventura-International'; + + case 'csventuramath': + case 'venturamath': + return 'Ventura-Math'; + + case 'csventuraus': + case 'venturaus': + return 'Ventura-US'; + + case 'csiso70videotexsupp1': + case 'isoir70': + case 'videotexsuppl': + return 'videotex-suppl'; + + case 'csviqr': + case 'viqr': + return 'VIQR'; + + case 'csviscii': + case 'viscii': + return 'VISCII'; + + case 'cswindows31j': + case 'windows31j': + return 'Windows-31J'; + + case 'iso885911': + case 'tis620': + return 'windows-874'; + + case 'cseuckr': + case 'csksc56011987': + case 'euckr': + case 'isoir149': + case 'korean': + case 'ksc5601': + case 'ksc56011987': + case 'ksc56011989': + case 'windows949': + return 'windows-949'; + + case 'windows1250': + return 'windows-1250'; + + case 'windows1251': + return 'windows-1251'; + + case 'cp819': + case 'csisolatin1': + case 'ibm819': + case 'iso88591': + case 'iso885911987': + case 'isoir100': + case 'l1': + case 'latin1': + case 'windows1252': + return 'windows-1252'; + + case 'windows1253': + return 'windows-1253'; + + case 'csisolatin5': + case 'iso88599': + case 'iso885991989': + case 'isoir148': + case 'l5': + case 'latin5': + case 'windows1254': + return 'windows-1254'; + + case 'windows1255': + return 'windows-1255'; + + case 'windows1256': + return 'windows-1256'; + + case 'windows1257': + return 'windows-1257'; + + case 'windows1258': + return 'windows-1258'; + + default: + return $charset; + } + } + + function get_curl_version() + { + if (is_array($curl = curl_version())) + { + $curl = $curl['version']; + } + elseif (substr($curl, 0, 5) === 'curl/') + { + $curl = substr($curl, 5, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 5)); + } + elseif (substr($curl, 0, 8) === 'libcurl/') + { + $curl = substr($curl, 8, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 8)); + } + else + { + $curl = 0; + } + return $curl; + } + + function is_subclass_of($class1, $class2) + { + if (func_num_args() !== 2) + { + trigger_error('Wrong parameter count for SimplePie_Misc::is_subclass_of()', E_USER_WARNING); + } + elseif (version_compare(PHP_VERSION, '5.0.3', '>=') || is_object($class1)) + { + return is_subclass_of($class1, $class2); + } + elseif (is_string($class1) && is_string($class2)) + { + if (class_exists($class1)) + { + if (class_exists($class2)) + { + $class2 = strtolower($class2); + while ($class1 = strtolower(get_parent_class($class1))) + { + if ($class1 === $class2) + { + return true; + } + } + } + } + else + { + trigger_error('Unknown class passed as parameter', E_USER_WARNNG); + } + } + return false; + } + + /** + * Strip HTML comments + * + * @access public + * @param string $data Data to strip comments from + * @return string Comment stripped string + */ + function strip_comments($data) + { + $output = ''; + while (($start = strpos($data, '', $start)) !== false) + { + $data = substr_replace($data, '', 0, $end + 3); + } + else + { + $data = ''; + } + } + return $output . $data; + } + + function parse_date($dt) + { + $parser = SimplePie_Parse_Date::get(); + return $parser->parse($dt); + } + + /** + * Decode HTML entities + * + * @static + * @access public + * @param string $data Input data + * @return string Output data + */ + function entities_decode($data) + { + $decoder = new SimplePie_Decode_HTML_Entities($data); + return $decoder->parse(); + } + + /** + * Remove RFC822 comments + * + * @access public + * @param string $data Data to strip comments from + * @return string Comment stripped string + */ + function uncomment_rfc822($string) + { + $string = (string) $string; + $position = 0; + $length = strlen($string); + $depth = 0; + + $output = ''; + + while ($position < $length && ($pos = strpos($string, '(', $position)) !== false) + { + $output .= substr($string, $position, $pos - $position); + $position = $pos + 1; + if ($string[$pos - 1] !== '\\') + { + $depth++; + while ($depth && $position < $length) + { + $position += strcspn($string, '()', $position); + if ($string[$position - 1] === '\\') + { + $position++; + continue; + } + elseif (isset($string[$position])) + { + switch ($string[$position]) + { + case '(': + $depth++; + break; + + case ')': + $depth--; + break; + } + $position++; + } + else + { + break; + } + } + } + else + { + $output .= '('; + } + } + $output .= substr($string, $position); + + return $output; + } + + function parse_mime($mime) + { + if (($pos = strpos($mime, ';')) === false) + { + return trim($mime); + } + else + { + return trim(substr($mime, 0, $pos)); + } + } + + function htmlspecialchars_decode($string, $quote_style) + { + if (function_exists('htmlspecialchars_decode')) + { + return htmlspecialchars_decode($string, $quote_style); + } + else + { + return strtr($string, array_flip(get_html_translation_table(HTML_SPECIALCHARS, $quote_style))); + } + } + + function atom_03_construct_type($attribs) + { + if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode']) === 'base64')) + { + $mode = SIMPLEPIE_CONSTRUCT_BASE64; + } + else + { + $mode = SIMPLEPIE_CONSTRUCT_NONE; + } + if (isset($attribs['']['type'])) + { + switch (strtolower(trim($attribs['']['type']))) + { + case 'text': + case 'text/plain': + return SIMPLEPIE_CONSTRUCT_TEXT | $mode; + + case 'html': + case 'text/html': + return SIMPLEPIE_CONSTRUCT_HTML | $mode; + + case 'xhtml': + case 'application/xhtml+xml': + return SIMPLEPIE_CONSTRUCT_XHTML | $mode; + + default: + return SIMPLEPIE_CONSTRUCT_NONE | $mode; + } + } + else + { + return SIMPLEPIE_CONSTRUCT_TEXT | $mode; + } + } + + function atom_10_construct_type($attribs) + { + if (isset($attribs['']['type'])) + { + switch (strtolower(trim($attribs['']['type']))) + { + case 'text': + return SIMPLEPIE_CONSTRUCT_TEXT; + + case 'html': + return SIMPLEPIE_CONSTRUCT_HTML; + + case 'xhtml': + return SIMPLEPIE_CONSTRUCT_XHTML; + + default: + return SIMPLEPIE_CONSTRUCT_NONE; + } + } + return SIMPLEPIE_CONSTRUCT_TEXT; + } + + function atom_10_content_construct_type($attribs) + { + if (isset($attribs['']['type'])) + { + $type = strtolower(trim($attribs['']['type'])); + switch ($type) + { + case 'text': + return SIMPLEPIE_CONSTRUCT_TEXT; + + case 'html': + return SIMPLEPIE_CONSTRUCT_HTML; + + case 'xhtml': + return SIMPLEPIE_CONSTRUCT_XHTML; + } + if (in_array(substr($type, -4), array('+xml', '/xml')) || substr($type, 0, 5) === 'text/') + { + return SIMPLEPIE_CONSTRUCT_NONE; + } + else + { + return SIMPLEPIE_CONSTRUCT_BASE64; + } + } + else + { + return SIMPLEPIE_CONSTRUCT_TEXT; + } + } + + function is_isegment_nz_nc($string) + { + return (bool) preg_match('/^([A-Za-z0-9\-._~\x{A0}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{10000}-\x{1FFFD}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}\x{40000}-\x{4FFFD}\x{50000}-\x{5FFFD}\x{60000}-\x{6FFFD}\x{70000}-\x{7FFFD}\x{80000}-\x{8FFFD}\x{90000}-\x{9FFFD}\x{A0000}-\x{AFFFD}\x{B0000}-\x{BFFFD}\x{C0000}-\x{CFFFD}\x{D0000}-\x{DFFFD}\x{E1000}-\x{EFFFD}!$&\'()*+,;=@]|(%[0-9ABCDEF]{2}))+$/u', $string); + } + + function space_seperated_tokens($string) + { + $space_characters = "\x20\x09\x0A\x0B\x0C\x0D"; + $string_length = strlen($string); + + $position = strspn($string, $space_characters); + $tokens = array(); + + while ($position < $string_length) + { + $len = strcspn($string, $space_characters, $position); + $tokens[] = substr($string, $position, $len); + $position += $len; + $position += strspn($string, $space_characters, $position); + } + + return $tokens; + } + + function array_unique($array) + { + if (version_compare(PHP_VERSION, '5.2', '>=')) + { + return array_unique($array); + } + else + { + $array = (array) $array; + $new_array = array(); + $new_array_strings = array(); + foreach ($array as $key => $value) + { + if (is_object($value)) + { + if (method_exists($value, '__toString')) + { + $cmp = $value->__toString(); + } + else + { + trigger_error('Object of class ' . get_class($value) . ' could not be converted to string', E_USER_ERROR); + } + } + elseif (is_array($value)) + { + $cmp = (string) reset($value); + } + else + { + $cmp = (string) $value; + } + if (!in_array($cmp, $new_array_strings)) + { + $new_array[$key] = $value; + $new_array_strings[] = $cmp; + } + } + return $new_array; + } + } + + /** + * Converts a unicode codepoint to a UTF-8 character + * + * @static + * @access public + * @param int $codepoint Unicode codepoint + * @return string UTF-8 character + */ + function codepoint_to_utf8($codepoint) + { + $codepoint = (int) $codepoint; + if ($codepoint < 0) + { + return false; + } + else if ($codepoint <= 0x7f) + { + return chr($codepoint); + } + else if ($codepoint <= 0x7ff) + { + return chr(0xc0 | ($codepoint >> 6)) . chr(0x80 | ($codepoint & 0x3f)); + } + else if ($codepoint <= 0xffff) + { + return chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); + } + else if ($codepoint <= 0x10ffff) + { + return chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f)); + } + else + { + // U+FFFD REPLACEMENT CHARACTER + return "\xEF\xBF\xBD"; + } + } + + /** + * Re-implementation of PHP 5's stripos() + * + * Returns the numeric position of the first occurrence of needle in the + * haystack string. + * + * @static + * @access string + * @param object $haystack + * @param string $needle Note that the needle may be a string of one or more + * characters. If needle is not a string, it is converted to an integer + * and applied as the ordinal value of a character. + * @param int $offset The optional offset parameter allows you to specify which + * character in haystack to start searching. The position returned is still + * relative to the beginning of haystack. + * @return bool If needle is not found, stripos() will return boolean false. + */ + function stripos($haystack, $needle, $offset = 0) + { + if (function_exists('stripos')) + { + return stripos($haystack, $needle, $offset); + } + else + { + if (is_string($needle)) + { + $needle = strtolower($needle); + } + elseif (is_int($needle) || is_bool($needle) || is_double($needle)) + { + $needle = strtolower(chr($needle)); + } + else + { + trigger_error('needle is not a string or an integer', E_USER_WARNING); + return false; + } + + return strpos(strtolower($haystack), $needle, $offset); + } + } + + /** + * Similar to parse_str() + * + * Returns an associative array of name/value pairs, where the value is an + * array of values that have used the same name + * + * @static + * @access string + * @param string $str The input string. + * @return array + */ + function parse_str($str) + { + $return = array(); + $str = explode('&', $str); + + foreach ($str as $section) + { + if (strpos($section, '=') !== false) + { + list($name, $value) = explode('=', $section, 2); + $return[urldecode($name)][] = urldecode($value); + } + else + { + $return[urldecode($section)][] = null; + } + } + + return $return; + } + + /** + * Detect XML encoding, as per XML 1.0 Appendix F.1 + * + * @todo Add support for EBCDIC + * @param string $data XML data + * @return array Possible encodings + */ + function xml_encoding($data) + { + // UTF-32 Big Endian BOM + if (substr($data, 0, 4) === "\x00\x00\xFE\xFF") + { + $encoding[] = 'UTF-32BE'; + } + // UTF-32 Little Endian BOM + elseif (substr($data, 0, 4) === "\xFF\xFE\x00\x00") + { + $encoding[] = 'UTF-32LE'; + } + // UTF-16 Big Endian BOM + elseif (substr($data, 0, 2) === "\xFE\xFF") + { + $encoding[] = 'UTF-16BE'; + } + // UTF-16 Little Endian BOM + elseif (substr($data, 0, 2) === "\xFF\xFE") + { + $encoding[] = 'UTF-16LE'; + } + // UTF-8 BOM + elseif (substr($data, 0, 3) === "\xEF\xBB\xBF") + { + $encoding[] = 'UTF-8'; + } + // UTF-32 Big Endian Without BOM + elseif (substr($data, 0, 20) === "\x00\x00\x00\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C") + { + if ($pos = strpos($data, "\x00\x00\x00\x3F\x00\x00\x00\x3E")) + { + $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32BE', 'UTF-8')); + if ($parser->parse()) + { + $encoding[] = $parser->encoding; + } + } + $encoding[] = 'UTF-32BE'; + } + // UTF-32 Little Endian Without BOM + elseif (substr($data, 0, 20) === "\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C\x00\x00\x00") + { + if ($pos = strpos($data, "\x3F\x00\x00\x00\x3E\x00\x00\x00")) + { + $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32LE', 'UTF-8')); + if ($parser->parse()) + { + $encoding[] = $parser->encoding; + } + } + $encoding[] = 'UTF-32LE'; + } + // UTF-16 Big Endian Without BOM + elseif (substr($data, 0, 10) === "\x00\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C") + { + if ($pos = strpos($data, "\x00\x3F\x00\x3E")) + { + $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16BE', 'UTF-8')); + if ($parser->parse()) + { + $encoding[] = $parser->encoding; + } + } + $encoding[] = 'UTF-16BE'; + } + // UTF-16 Little Endian Without BOM + elseif (substr($data, 0, 10) === "\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C\x00") + { + if ($pos = strpos($data, "\x3F\x00\x3E\x00")) + { + $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16LE', 'UTF-8')); + if ($parser->parse()) + { + $encoding[] = $parser->encoding; + } + } + $encoding[] = 'UTF-16LE'; + } + // US-ASCII (or superset) + elseif (substr($data, 0, 5) === "\x3C\x3F\x78\x6D\x6C") + { + if ($pos = strpos($data, "\x3F\x3E")) + { + $parser = new SimplePie_XML_Declaration_Parser(substr($data, 5, $pos - 5)); + if ($parser->parse()) + { + $encoding[] = $parser->encoding; + } + } + $encoding[] = 'UTF-8'; + } + // Fallback to UTF-8 + else + { + $encoding[] = 'UTF-8'; + } + return $encoding; + } + + function output_javascript() + { + if (function_exists('ob_gzhandler')) + { + ob_start('ob_gzhandler'); + } + header('Content-type: text/javascript; charset: UTF-8'); + header('Cache-Control: must-revalidate'); + header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days + ?> +function embed_odeo(link) { + document.writeln(''); +} + +function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) { + if (placeholder != '') { + document.writeln(''); + } + else { + document.writeln(''); + } +} + +function embed_flash(bgcolor, width, height, link, loop, type) { + document.writeln(''); +} + +function embed_flv(width, height, link, placeholder, loop, player) { + document.writeln(''); +} + +function embed_wmedia(width, height, link) { + document.writeln(''); +} + data = $data; + } + + /** + * Parse the input data + * + * @access public + * @return string Output data + */ + function parse() + { + while (($this->position = strpos($this->data, '&', $this->position)) !== false) + { + $this->consume(); + $this->entity(); + $this->consumed = ''; + } + return $this->data; + } + + /** + * Consume the next byte + * + * @access private + * @return mixed The next byte, or false, if there is no more data + */ + function consume() + { + if (isset($this->data[$this->position])) + { + $this->consumed .= $this->data[$this->position]; + return $this->data[$this->position++]; + } + else + { + return false; + } + } + + /** + * Consume a range of characters + * + * @access private + * @param string $chars Characters to consume + * @return mixed A series of characters that match the range, or false + */ + function consume_range($chars) + { + if ($len = strspn($this->data, $chars, $this->position)) + { + $data = substr($this->data, $this->position, $len); + $this->consumed .= $data; + $this->position += $len; + return $data; + } + else + { + return false; + } + } + + /** + * Unconsume one byte + * + * @access private + */ + function unconsume() + { + $this->consumed = substr($this->consumed, 0, -1); + $this->position--; + } + + /** + * Decode an entity + * + * @access private + */ + function entity() + { + switch ($this->consume()) + { + case "\x09": + case "\x0A": + case "\x0B": + case "\x0B": + case "\x0C": + case "\x20": + case "\x3C": + case "\x26": + case false: + break; + + case "\x23": + switch ($this->consume()) + { + case "\x78": + case "\x58": + $range = '0123456789ABCDEFabcdef'; + $hex = true; + break; + + default: + $range = '0123456789'; + $hex = false; + $this->unconsume(); + break; + } + + if ($codepoint = $this->consume_range($range)) + { + static $windows_1252_specials = array(0x0D => "\x0A", 0x80 => "\xE2\x82\xAC", 0x81 => "\xEF\xBF\xBD", 0x82 => "\xE2\x80\x9A", 0x83 => "\xC6\x92", 0x84 => "\xE2\x80\x9E", 0x85 => "\xE2\x80\xA6", 0x86 => "\xE2\x80\xA0", 0x87 => "\xE2\x80\xA1", 0x88 => "\xCB\x86", 0x89 => "\xE2\x80\xB0", 0x8A => "\xC5\xA0", 0x8B => "\xE2\x80\xB9", 0x8C => "\xC5\x92", 0x8D => "\xEF\xBF\xBD", 0x8E => "\xC5\xBD", 0x8F => "\xEF\xBF\xBD", 0x90 => "\xEF\xBF\xBD", 0x91 => "\xE2\x80\x98", 0x92 => "\xE2\x80\x99", 0x93 => "\xE2\x80\x9C", 0x94 => "\xE2\x80\x9D", 0x95 => "\xE2\x80\xA2", 0x96 => "\xE2\x80\x93", 0x97 => "\xE2\x80\x94", 0x98 => "\xCB\x9C", 0x99 => "\xE2\x84\xA2", 0x9A => "\xC5\xA1", 0x9B => "\xE2\x80\xBA", 0x9C => "\xC5\x93", 0x9D => "\xEF\xBF\xBD", 0x9E => "\xC5\xBE", 0x9F => "\xC5\xB8"); + + if ($hex) + { + $codepoint = hexdec($codepoint); + } + else + { + $codepoint = intval($codepoint); + } + + if (isset($windows_1252_specials[$codepoint])) + { + $replacement = $windows_1252_specials[$codepoint]; + } + else + { + $replacement = SimplePie_Misc::codepoint_to_utf8($codepoint); + } + + if (!in_array($this->consume(), array(';', false), true)) + { + $this->unconsume(); + } + + $consumed_length = strlen($this->consumed); + $this->data = substr_replace($this->data, $replacement, $this->position - $consumed_length, $consumed_length); + $this->position += strlen($replacement) - $consumed_length; + } + break; + + default: + static $entities = array('Aacute' => "\xC3\x81", 'aacute' => "\xC3\xA1", 'Aacute;' => "\xC3\x81", 'aacute;' => "\xC3\xA1", 'Acirc' => "\xC3\x82", 'acirc' => "\xC3\xA2", 'Acirc;' => "\xC3\x82", 'acirc;' => "\xC3\xA2", 'acute' => "\xC2\xB4", 'acute;' => "\xC2\xB4", 'AElig' => "\xC3\x86", 'aelig' => "\xC3\xA6", 'AElig;' => "\xC3\x86", 'aelig;' => "\xC3\xA6", 'Agrave' => "\xC3\x80", 'agrave' => "\xC3\xA0", 'Agrave;' => "\xC3\x80", 'agrave;' => "\xC3\xA0", 'alefsym;' => "\xE2\x84\xB5", 'Alpha;' => "\xCE\x91", 'alpha;' => "\xCE\xB1", 'AMP' => "\x26", 'amp' => "\x26", 'AMP;' => "\x26", 'amp;' => "\x26", 'and;' => "\xE2\x88\xA7", 'ang;' => "\xE2\x88\xA0", 'apos;' => "\x27", 'Aring' => "\xC3\x85", 'aring' => "\xC3\xA5", 'Aring;' => "\xC3\x85", 'aring;' => "\xC3\xA5", 'asymp;' => "\xE2\x89\x88", 'Atilde' => "\xC3\x83", 'atilde' => "\xC3\xA3", 'Atilde;' => "\xC3\x83", 'atilde;' => "\xC3\xA3", 'Auml' => "\xC3\x84", 'auml' => "\xC3\xA4", 'Auml;' => "\xC3\x84", 'auml;' => "\xC3\xA4", 'bdquo;' => "\xE2\x80\x9E", 'Beta;' => "\xCE\x92", 'beta;' => "\xCE\xB2", 'brvbar' => "\xC2\xA6", 'brvbar;' => "\xC2\xA6", 'bull;' => "\xE2\x80\xA2", 'cap;' => "\xE2\x88\xA9", 'Ccedil' => "\xC3\x87", 'ccedil' => "\xC3\xA7", 'Ccedil;' => "\xC3\x87", 'ccedil;' => "\xC3\xA7", 'cedil' => "\xC2\xB8", 'cedil;' => "\xC2\xB8", 'cent' => "\xC2\xA2", 'cent;' => "\xC2\xA2", 'Chi;' => "\xCE\xA7", 'chi;' => "\xCF\x87", 'circ;' => "\xCB\x86", 'clubs;' => "\xE2\x99\xA3", 'cong;' => "\xE2\x89\x85", 'COPY' => "\xC2\xA9", 'copy' => "\xC2\xA9", 'COPY;' => "\xC2\xA9", 'copy;' => "\xC2\xA9", 'crarr;' => "\xE2\x86\xB5", 'cup;' => "\xE2\x88\xAA", 'curren' => "\xC2\xA4", 'curren;' => "\xC2\xA4", 'Dagger;' => "\xE2\x80\xA1", 'dagger;' => "\xE2\x80\xA0", 'dArr;' => "\xE2\x87\x93", 'darr;' => "\xE2\x86\x93", 'deg' => "\xC2\xB0", 'deg;' => "\xC2\xB0", 'Delta;' => "\xCE\x94", 'delta;' => "\xCE\xB4", 'diams;' => "\xE2\x99\xA6", 'divide' => "\xC3\xB7", 'divide;' => "\xC3\xB7", 'Eacute' => "\xC3\x89", 'eacute' => "\xC3\xA9", 'Eacute;' => "\xC3\x89", 'eacute;' => "\xC3\xA9", 'Ecirc' => "\xC3\x8A", 'ecirc' => "\xC3\xAA", 'Ecirc;' => "\xC3\x8A", 'ecirc;' => "\xC3\xAA", 'Egrave' => "\xC3\x88", 'egrave' => "\xC3\xA8", 'Egrave;' => "\xC3\x88", 'egrave;' => "\xC3\xA8", 'empty;' => "\xE2\x88\x85", 'emsp;' => "\xE2\x80\x83", 'ensp;' => "\xE2\x80\x82", 'Epsilon;' => "\xCE\x95", 'epsilon;' => "\xCE\xB5", 'equiv;' => "\xE2\x89\xA1", 'Eta;' => "\xCE\x97", 'eta;' => "\xCE\xB7", 'ETH' => "\xC3\x90", 'eth' => "\xC3\xB0", 'ETH;' => "\xC3\x90", 'eth;' => "\xC3\xB0", 'Euml' => "\xC3\x8B", 'euml' => "\xC3\xAB", 'Euml;' => "\xC3\x8B", 'euml;' => "\xC3\xAB", 'euro;' => "\xE2\x82\xAC", 'exist;' => "\xE2\x88\x83", 'fnof;' => "\xC6\x92", 'forall;' => "\xE2\x88\x80", 'frac12' => "\xC2\xBD", 'frac12;' => "\xC2\xBD", 'frac14' => "\xC2\xBC", 'frac14;' => "\xC2\xBC", 'frac34' => "\xC2\xBE", 'frac34;' => "\xC2\xBE", 'frasl;' => "\xE2\x81\x84", 'Gamma;' => "\xCE\x93", 'gamma;' => "\xCE\xB3", 'ge;' => "\xE2\x89\xA5", 'GT' => "\x3E", 'gt' => "\x3E", 'GT;' => "\x3E", 'gt;' => "\x3E", 'hArr;' => "\xE2\x87\x94", 'harr;' => "\xE2\x86\x94", 'hearts;' => "\xE2\x99\xA5", 'hellip;' => "\xE2\x80\xA6", 'Iacute' => "\xC3\x8D", 'iacute' => "\xC3\xAD", 'Iacute;' => "\xC3\x8D", 'iacute;' => "\xC3\xAD", 'Icirc' => "\xC3\x8E", 'icirc' => "\xC3\xAE", 'Icirc;' => "\xC3\x8E", 'icirc;' => "\xC3\xAE", 'iexcl' => "\xC2\xA1", 'iexcl;' => "\xC2\xA1", 'Igrave' => "\xC3\x8C", 'igrave' => "\xC3\xAC", 'Igrave;' => "\xC3\x8C", 'igrave;' => "\xC3\xAC", 'image;' => "\xE2\x84\x91", 'infin;' => "\xE2\x88\x9E", 'int;' => "\xE2\x88\xAB", 'Iota;' => "\xCE\x99", 'iota;' => "\xCE\xB9", 'iquest' => "\xC2\xBF", 'iquest;' => "\xC2\xBF", 'isin;' => "\xE2\x88\x88", 'Iuml' => "\xC3\x8F", 'iuml' => "\xC3\xAF", 'Iuml;' => "\xC3\x8F", 'iuml;' => "\xC3\xAF", 'Kappa;' => "\xCE\x9A", 'kappa;' => "\xCE\xBA", 'Lambda;' => "\xCE\x9B", 'lambda;' => "\xCE\xBB", 'lang;' => "\xE3\x80\x88", 'laquo' => "\xC2\xAB", 'laquo;' => "\xC2\xAB", 'lArr;' => "\xE2\x87\x90", 'larr;' => "\xE2\x86\x90", 'lceil;' => "\xE2\x8C\x88", 'ldquo;' => "\xE2\x80\x9C", 'le;' => "\xE2\x89\xA4", 'lfloor;' => "\xE2\x8C\x8A", 'lowast;' => "\xE2\x88\x97", 'loz;' => "\xE2\x97\x8A", 'lrm;' => "\xE2\x80\x8E", 'lsaquo;' => "\xE2\x80\xB9", 'lsquo;' => "\xE2\x80\x98", 'LT' => "\x3C", 'lt' => "\x3C", 'LT;' => "\x3C", 'lt;' => "\x3C", 'macr' => "\xC2\xAF", 'macr;' => "\xC2\xAF", 'mdash;' => "\xE2\x80\x94", 'micro' => "\xC2\xB5", 'micro;' => "\xC2\xB5", 'middot' => "\xC2\xB7", 'middot;' => "\xC2\xB7", 'minus;' => "\xE2\x88\x92", 'Mu;' => "\xCE\x9C", 'mu;' => "\xCE\xBC", 'nabla;' => "\xE2\x88\x87", 'nbsp' => "\xC2\xA0", 'nbsp;' => "\xC2\xA0", 'ndash;' => "\xE2\x80\x93", 'ne;' => "\xE2\x89\xA0", 'ni;' => "\xE2\x88\x8B", 'not' => "\xC2\xAC", 'not;' => "\xC2\xAC", 'notin;' => "\xE2\x88\x89", 'nsub;' => "\xE2\x8A\x84", 'Ntilde' => "\xC3\x91", 'ntilde' => "\xC3\xB1", 'Ntilde;' => "\xC3\x91", 'ntilde;' => "\xC3\xB1", 'Nu;' => "\xCE\x9D", 'nu;' => "\xCE\xBD", 'Oacute' => "\xC3\x93", 'oacute' => "\xC3\xB3", 'Oacute;' => "\xC3\x93", 'oacute;' => "\xC3\xB3", 'Ocirc' => "\xC3\x94", 'ocirc' => "\xC3\xB4", 'Ocirc;' => "\xC3\x94", 'ocirc;' => "\xC3\xB4", 'OElig;' => "\xC5\x92", 'oelig;' => "\xC5\x93", 'Ograve' => "\xC3\x92", 'ograve' => "\xC3\xB2", 'Ograve;' => "\xC3\x92", 'ograve;' => "\xC3\xB2", 'oline;' => "\xE2\x80\xBE", 'Omega;' => "\xCE\xA9", 'omega;' => "\xCF\x89", 'Omicron;' => "\xCE\x9F", 'omicron;' => "\xCE\xBF", 'oplus;' => "\xE2\x8A\x95", 'or;' => "\xE2\x88\xA8", 'ordf' => "\xC2\xAA", 'ordf;' => "\xC2\xAA", 'ordm' => "\xC2\xBA", 'ordm;' => "\xC2\xBA", 'Oslash' => "\xC3\x98", 'oslash' => "\xC3\xB8", 'Oslash;' => "\xC3\x98", 'oslash;' => "\xC3\xB8", 'Otilde' => "\xC3\x95", 'otilde' => "\xC3\xB5", 'Otilde;' => "\xC3\x95", 'otilde;' => "\xC3\xB5", 'otimes;' => "\xE2\x8A\x97", 'Ouml' => "\xC3\x96", 'ouml' => "\xC3\xB6", 'Ouml;' => "\xC3\x96", 'ouml;' => "\xC3\xB6", 'para' => "\xC2\xB6", 'para;' => "\xC2\xB6", 'part;' => "\xE2\x88\x82", 'permil;' => "\xE2\x80\xB0", 'perp;' => "\xE2\x8A\xA5", 'Phi;' => "\xCE\xA6", 'phi;' => "\xCF\x86", 'Pi;' => "\xCE\xA0", 'pi;' => "\xCF\x80", 'piv;' => "\xCF\x96", 'plusmn' => "\xC2\xB1", 'plusmn;' => "\xC2\xB1", 'pound' => "\xC2\xA3", 'pound;' => "\xC2\xA3", 'Prime;' => "\xE2\x80\xB3", 'prime;' => "\xE2\x80\xB2", 'prod;' => "\xE2\x88\x8F", 'prop;' => "\xE2\x88\x9D", 'Psi;' => "\xCE\xA8", 'psi;' => "\xCF\x88", 'QUOT' => "\x22", 'quot' => "\x22", 'QUOT;' => "\x22", 'quot;' => "\x22", 'radic;' => "\xE2\x88\x9A", 'rang;' => "\xE3\x80\x89", 'raquo' => "\xC2\xBB", 'raquo;' => "\xC2\xBB", 'rArr;' => "\xE2\x87\x92", 'rarr;' => "\xE2\x86\x92", 'rceil;' => "\xE2\x8C\x89", 'rdquo;' => "\xE2\x80\x9D", 'real;' => "\xE2\x84\x9C", 'REG' => "\xC2\xAE", 'reg' => "\xC2\xAE", 'REG;' => "\xC2\xAE", 'reg;' => "\xC2\xAE", 'rfloor;' => "\xE2\x8C\x8B", 'Rho;' => "\xCE\xA1", 'rho;' => "\xCF\x81", 'rlm;' => "\xE2\x80\x8F", 'rsaquo;' => "\xE2\x80\xBA", 'rsquo;' => "\xE2\x80\x99", 'sbquo;' => "\xE2\x80\x9A", 'Scaron;' => "\xC5\xA0", 'scaron;' => "\xC5\xA1", 'sdot;' => "\xE2\x8B\x85", 'sect' => "\xC2\xA7", 'sect;' => "\xC2\xA7", 'shy' => "\xC2\xAD", 'shy;' => "\xC2\xAD", 'Sigma;' => "\xCE\xA3", 'sigma;' => "\xCF\x83", 'sigmaf;' => "\xCF\x82", 'sim;' => "\xE2\x88\xBC", 'spades;' => "\xE2\x99\xA0", 'sub;' => "\xE2\x8A\x82", 'sube;' => "\xE2\x8A\x86", 'sum;' => "\xE2\x88\x91", 'sup;' => "\xE2\x8A\x83", 'sup1' => "\xC2\xB9", 'sup1;' => "\xC2\xB9", 'sup2' => "\xC2\xB2", 'sup2;' => "\xC2\xB2", 'sup3' => "\xC2\xB3", 'sup3;' => "\xC2\xB3", 'supe;' => "\xE2\x8A\x87", 'szlig' => "\xC3\x9F", 'szlig;' => "\xC3\x9F", 'Tau;' => "\xCE\xA4", 'tau;' => "\xCF\x84", 'there4;' => "\xE2\x88\xB4", 'Theta;' => "\xCE\x98", 'theta;' => "\xCE\xB8", 'thetasym;' => "\xCF\x91", 'thinsp;' => "\xE2\x80\x89", 'THORN' => "\xC3\x9E", 'thorn' => "\xC3\xBE", 'THORN;' => "\xC3\x9E", 'thorn;' => "\xC3\xBE", 'tilde;' => "\xCB\x9C", 'times' => "\xC3\x97", 'times;' => "\xC3\x97", 'TRADE;' => "\xE2\x84\xA2", 'trade;' => "\xE2\x84\xA2", 'Uacute' => "\xC3\x9A", 'uacute' => "\xC3\xBA", 'Uacute;' => "\xC3\x9A", 'uacute;' => "\xC3\xBA", 'uArr;' => "\xE2\x87\x91", 'uarr;' => "\xE2\x86\x91", 'Ucirc' => "\xC3\x9B", 'ucirc' => "\xC3\xBB", 'Ucirc;' => "\xC3\x9B", 'ucirc;' => "\xC3\xBB", 'Ugrave' => "\xC3\x99", 'ugrave' => "\xC3\xB9", 'Ugrave;' => "\xC3\x99", 'ugrave;' => "\xC3\xB9", 'uml' => "\xC2\xA8", 'uml;' => "\xC2\xA8", 'upsih;' => "\xCF\x92", 'Upsilon;' => "\xCE\xA5", 'upsilon;' => "\xCF\x85", 'Uuml' => "\xC3\x9C", 'uuml' => "\xC3\xBC", 'Uuml;' => "\xC3\x9C", 'uuml;' => "\xC3\xBC", 'weierp;' => "\xE2\x84\x98", 'Xi;' => "\xCE\x9E", 'xi;' => "\xCE\xBE", 'Yacute' => "\xC3\x9D", 'yacute' => "\xC3\xBD", 'Yacute;' => "\xC3\x9D", 'yacute;' => "\xC3\xBD", 'yen' => "\xC2\xA5", 'yen;' => "\xC2\xA5", 'yuml' => "\xC3\xBF", 'Yuml;' => "\xC5\xB8", 'yuml;' => "\xC3\xBF", 'Zeta;' => "\xCE\x96", 'zeta;' => "\xCE\xB6", 'zwj;' => "\xE2\x80\x8D", 'zwnj;' => "\xE2\x80\x8C"); + + for ($i = 0, $match = null; $i < 9 && $this->consume() !== false; $i++) + { + $consumed = substr($this->consumed, 1); + if (isset($entities[$consumed])) + { + $match = $consumed; + } + } + + if ($match !== null) + { + $this->data = substr_replace($this->data, $entities[$match], $this->position - strlen($consumed) - 1, strlen($match) + 1); + $this->position += strlen($entities[$match]) - strlen($consumed) - 1; + } + break; + } + } +} + +/** + * IRI parser/serialiser + * + * @package SimplePie + */ +class SimplePie_IRI +{ + /** + * Scheme + * + * @access private + * @var string + */ + var $scheme; + + /** + * User Information + * + * @access private + * @var string + */ + var $userinfo; + + /** + * Host + * + * @access private + * @var string + */ + var $host; + + /** + * Port + * + * @access private + * @var string + */ + var $port; + + /** + * Path + * + * @access private + * @var string + */ + var $path; + + /** + * Query + * + * @access private + * @var string + */ + var $query; + + /** + * Fragment + * + * @access private + * @var string + */ + var $fragment; + + /** + * Whether the object represents a valid IRI + * + * @access private + * @var array + */ + var $valid = array(); + + /** + * Return the entire IRI when you try and read the object as a string + * + * @access public + * @return string + */ + function __toString() + { + return $this->get_iri(); + } + + /** + * Create a new IRI object, from a specified string + * + * @access public + * @param string $iri + * @return SimplePie_IRI + */ + function SimplePie_IRI($iri) + { + $iri = (string) $iri; + if ($iri !== '') + { + $parsed = $this->parse_iri($iri); + $this->set_scheme($parsed['scheme']); + $this->set_authority($parsed['authority']); + $this->set_path($parsed['path']); + $this->set_query($parsed['query']); + $this->set_fragment($parsed['fragment']); + } + } + + /** + * Create a new IRI object by resolving a relative IRI + * + * @static + * @access public + * @param SimplePie_IRI $base Base IRI + * @param string $relative Relative IRI + * @return SimplePie_IRI + */ + function absolutize($base, $relative) + { + $relative = (string) $relative; + if ($relative !== '') + { + $relative = new SimplePie_IRI($relative); + if ($relative->get_scheme() !== null) + { + $target = $relative; + } + elseif ($base->get_iri() !== null) + { + if ($relative->get_authority() !== null) + { + $target = $relative; + $target->set_scheme($base->get_scheme()); + } + else + { + $target = new SimplePie_IRI(''); + $target->set_scheme($base->get_scheme()); + $target->set_userinfo($base->get_userinfo()); + $target->set_host($base->get_host()); + $target->set_port($base->get_port()); + if ($relative->get_path() !== null) + { + if (strpos($relative->get_path(), '/') === 0) + { + $target->set_path($relative->get_path()); + } + elseif (($base->get_userinfo() !== null || $base->get_host() !== null || $base->get_port() !== null) && $base->get_path() === null) + { + $target->set_path('/' . $relative->get_path()); + } + elseif (($last_segment = strrpos($base->get_path(), '/')) !== false) + { + $target->set_path(substr($base->get_path(), 0, $last_segment + 1) . $relative->get_path()); + } + else + { + $target->set_path($relative->get_path()); + } + $target->set_query($relative->get_query()); + } + else + { + $target->set_path($base->get_path()); + if ($relative->get_query() !== null) + { + $target->set_query($relative->get_query()); + } + elseif ($base->get_query() !== null) + { + $target->set_query($base->get_query()); + } + } + } + $target->set_fragment($relative->get_fragment()); + } + else + { + // No base URL, just return the relative URL + $target = $relative; + } + } + else + { + $target = $base; + } + return $target; + } + + /** + * Parse an IRI into scheme/authority/path/query/fragment segments + * + * @access private + * @param string $iri + * @return array + */ + function parse_iri($iri) + { + preg_match('/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/', $iri, $match); + for ($i = count($match); $i <= 9; $i++) + { + $match[$i] = ''; + } + return array('scheme' => $match[2], 'authority' => $match[4], 'path' => $match[5], 'query' => $match[7], 'fragment' => $match[9]); + } + + /** + * Remove dot segments from a path + * + * @access private + * @param string $input + * @return string + */ + function remove_dot_segments($input) + { + $output = ''; + while (strpos($input, './') !== false || strpos($input, '/.') !== false || $input === '.' || $input === '..') + { + // A: If the input buffer begins with a prefix of "../" or "./", then remove that prefix from the input buffer; otherwise, + if (strpos($input, '../') === 0) + { + $input = substr($input, 3); + } + elseif (strpos($input, './') === 0) + { + $input = substr($input, 2); + } + // B: if the input buffer begins with a prefix of "/./" or "/.", where "." is a complete path segment, then replace that prefix with "/" in the input buffer; otherwise, + elseif (strpos($input, '/./') === 0) + { + $input = substr_replace($input, '/', 0, 3); + } + elseif ($input === '/.') + { + $input = '/'; + } + // C: if the input buffer begins with a prefix of "/../" or "/..", where ".." is a complete path segment, then replace that prefix with "/" in the input buffer and remove the last segment and its preceding "/" (if any) from the output buffer; otherwise, + elseif (strpos($input, '/../') === 0) + { + $input = substr_replace($input, '/', 0, 4); + $output = substr_replace($output, '', strrpos($output, '/')); + } + elseif ($input === '/..') + { + $input = '/'; + $output = substr_replace($output, '', strrpos($output, '/')); + } + // D: if the input buffer consists only of "." or "..", then remove that from the input buffer; otherwise, + elseif ($input === '.' || $input === '..') + { + $input = ''; + } + // E: move the first path segment in the input buffer to the end of the output buffer, including the initial "/" character (if any) and any subsequent characters up to, but not including, the next "/" character or the end of the input buffer + elseif (($pos = strpos($input, '/', 1)) !== false) + { + $output .= substr($input, 0, $pos); + $input = substr_replace($input, '', 0, $pos); + } + else + { + $output .= $input; + $input = ''; + } + } + return $output . $input; + } + + /** + * Replace invalid character with percent encoding + * + * @access private + * @param string $string Input string + * @param string $valid_chars Valid characters + * @param int $case Normalise case + * @return string + */ + function replace_invalid_with_pct_encoding($string, $valid_chars, $case = SIMPLEPIE_SAME_CASE) + { + // Normalise case + if ($case & SIMPLEPIE_LOWERCASE) + { + $string = strtolower($string); + } + elseif ($case & SIMPLEPIE_UPPERCASE) + { + $string = strtoupper($string); + } + + // Store position and string length (to avoid constantly recalculating this) + $position = 0; + $strlen = strlen($string); + + // Loop as long as we have invalid characters, advancing the position to the next invalid character + while (($position += strspn($string, $valid_chars, $position)) < $strlen) + { + // If we have a % character + if ($string[$position] === '%') + { + // If we have a pct-encoded section + if ($position + 2 < $strlen && strspn($string, '0123456789ABCDEFabcdef', $position + 1, 2) === 2) + { + // Get the the represented character + $chr = chr(hexdec(substr($string, $position + 1, 2))); + + // If the character is valid, replace the pct-encoded with the actual character while normalising case + if (strpos($valid_chars, $chr) !== false) + { + if ($case & SIMPLEPIE_LOWERCASE) + { + $chr = strtolower($chr); + } + elseif ($case & SIMPLEPIE_UPPERCASE) + { + $chr = strtoupper($chr); + } + $string = substr_replace($string, $chr, $position, 3); + $strlen -= 2; + $position++; + } + + // Otherwise just normalise the pct-encoded to uppercase + else + { + $string = substr_replace($string, strtoupper(substr($string, $position + 1, 2)), $position + 1, 2); + $position += 3; + } + } + // If we don't have a pct-encoded section, just replace the % with its own esccaped form + else + { + $string = substr_replace($string, '%25', $position, 1); + $strlen += 2; + $position += 3; + } + } + // If we have an invalid character, change into its pct-encoded form + else + { + $replacement = sprintf("%%%02X", ord($string[$position])); + $string = str_replace($string[$position], $replacement, $string); + $strlen = strlen($string); + } + } + return $string; + } + + /** + * Check if the object represents a valid IRI + * + * @access public + * @return bool + */ + function is_valid() + { + return array_sum($this->valid) === count($this->valid); + } + + /** + * Set the scheme. Returns true on success, false on failure (if there are + * any invalid characters). + * + * @access public + * @param string $scheme + * @return bool + */ + function set_scheme($scheme) + { + if ($scheme === null || $scheme === '') + { + $this->scheme = null; + } + else + { + $len = strlen($scheme); + switch (true) + { + case $len > 1: + if (!strspn($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-.', 1)) + { + $this->scheme = null; + $this->valid[__FUNCTION__] = false; + return false; + } + + case $len > 0: + if (!strspn($scheme, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 0, 1)) + { + $this->scheme = null; + $this->valid[__FUNCTION__] = false; + return false; + } + } + $this->scheme = strtolower($scheme); + } + $this->valid[__FUNCTION__] = true; + return true; + } + + /** + * Set the authority. Returns true on success, false on failure (if there are + * any invalid characters). + * + * @access public + * @param string $authority + * @return bool + */ + function set_authority($authority) + { + if (($userinfo_end = strrpos($authority, '@')) !== false) + { + $userinfo = substr($authority, 0, $userinfo_end); + $authority = substr($authority, $userinfo_end + 1); + } + else + { + $userinfo = null; + } + + if (($port_start = strpos($authority, ':')) !== false) + { + $port = substr($authority, $port_start + 1); + $authority = substr($authority, 0, $port_start); + } + else + { + $port = null; + } + + return $this->set_userinfo($userinfo) && $this->set_host($authority) && $this->set_port($port); + } + + /** + * Set the userinfo. + * + * @access public + * @param string $userinfo + * @return bool + */ + function set_userinfo($userinfo) + { + if ($userinfo === null || $userinfo === '') + { + $this->userinfo = null; + } + else + { + $this->userinfo = $this->replace_invalid_with_pct_encoding($userinfo, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=:'); + } + $this->valid[__FUNCTION__] = true; + return true; + } + + /** + * Set the host. Returns true on success, false on failure (if there are + * any invalid characters). + * + * @access public + * @param string $host + * @return bool + */ + function set_host($host) + { + if ($host === null || $host === '') + { + $this->host = null; + $this->valid[__FUNCTION__] = true; + return true; + } + elseif ($host[0] === '[' && substr($host, -1) === ']') + { + if (Net_IPv6::checkIPv6(substr($host, 1, -1))) + { + $this->host = $host; + $this->valid[__FUNCTION__] = true; + return true; + } + else + { + $this->host = null; + $this->valid[__FUNCTION__] = false; + return false; + } + } + else + { + $this->host = $this->replace_invalid_with_pct_encoding($host, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=', SIMPLEPIE_LOWERCASE); + $this->valid[__FUNCTION__] = true; + return true; + } + } + + /** + * Set the port. Returns true on success, false on failure (if there are + * any invalid characters). + * + * @access public + * @param string $port + * @return bool + */ + function set_port($port) + { + if ($port === null || $port === '') + { + $this->port = null; + $this->valid[__FUNCTION__] = true; + return true; + } + elseif (strspn($port, '0123456789') === strlen($port)) + { + $this->port = (int) $port; + $this->valid[__FUNCTION__] = true; + return true; + } + else + { + $this->port = null; + $this->valid[__FUNCTION__] = false; + return false; + } + } + + /** + * Set the path. + * + * @access public + * @param string $path + * @return bool + */ + function set_path($path) + { + if ($path === null || $path === '') + { + $this->path = null; + $this->valid[__FUNCTION__] = true; + return true; + } + elseif (substr($path, 0, 2) === '//' && $this->userinfo === null && $this->host === null && $this->port === null) + { + $this->path = null; + $this->valid[__FUNCTION__] = false; + return false; + } + else + { + $this->path = $this->replace_invalid_with_pct_encoding($path, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=@/'); + if ($this->scheme !== null) + { + $this->path = $this->remove_dot_segments($this->path); + } + $this->valid[__FUNCTION__] = true; + return true; + } + } + + /** + * Set the query. + * + * @access public + * @param string $query + * @return bool + */ + function set_query($query) + { + if ($query === null || $query === '') + { + $this->query = null; + } + else + { + $this->query = $this->replace_invalid_with_pct_encoding($query, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=:@/?'); + } + $this->valid[__FUNCTION__] = true; + return true; + } + + /** + * Set the fragment. + * + * @access public + * @param string $fragment + * @return bool + */ + function set_fragment($fragment) + { + if ($fragment === null || $fragment === '') + { + $this->fragment = null; + } + else + { + $this->fragment = $this->replace_invalid_with_pct_encoding($fragment, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~!$&\'()*+,;=:@/?'); + } + $this->valid[__FUNCTION__] = true; + return true; + } + + /** + * Get the complete IRI + * + * @access public + * @return string + */ + function get_iri() + { + $iri = ''; + if ($this->scheme !== null) + { + $iri .= $this->scheme . ':'; + } + if (($authority = $this->get_authority()) !== null) + { + $iri .= '//' . $authority; + } + if ($this->path !== null) + { + $iri .= $this->path; + } + if ($this->query !== null) + { + $iri .= '?' . $this->query; + } + if ($this->fragment !== null) + { + $iri .= '#' . $this->fragment; + } + + if ($iri !== '') + { + return $iri; + } + else + { + return null; + } + } + + /** + * Get the scheme + * + * @access public + * @return string + */ + function get_scheme() + { + return $this->scheme; + } + + /** + * Get the complete authority + * + * @access public + * @return string + */ + function get_authority() + { + $authority = ''; + if ($this->userinfo !== null) + { + $authority .= $this->userinfo . '@'; + } + if ($this->host !== null) + { + $authority .= $this->host; + } + if ($this->port !== null) + { + $authority .= ':' . $this->port; + } + + if ($authority !== '') + { + return $authority; + } + else + { + return null; + } + } + + /** + * Get the user information + * + * @access public + * @return string + */ + function get_userinfo() + { + return $this->userinfo; + } + + /** + * Get the host + * + * @access public + * @return string + */ + function get_host() + { + return $this->host; + } + + /** + * Get the port + * + * @access public + * @return string + */ + function get_port() + { + return $this->port; + } + + /** + * Get the path + * + * @access public + * @return string + */ + function get_path() + { + return $this->path; + } + + /** + * Get the query + * + * @access public + * @return string + */ + function get_query() + { + return $this->query; + } + + /** + * Get the fragment + * + * @access public + * @return string + */ + function get_fragment() + { + return $this->fragment; + } +} + +/** + * Class to validate and to work with IPv6 addresses. + * + * @package SimplePie + * @copyright 2003-2005 The PHP Group + * @license http://www.opensource.org/licenses/bsd-license.php + * @link http://pear.php.net/package/Net_IPv6 + * @author Alexander Merz + * @author elfrink at introweb dot nl + * @author Josh Peck + * @author Geoffrey Sneddon + */ +class SimplePie_Net_IPv6 +{ + /** + * Removes a possible existing netmask specification of an IP address. + * + * @param string $ip the (compressed) IP as Hex representation + * @return string the IP the without netmask + * @since 1.1.0 + * @access public + * @static + */ + function removeNetmaskSpec($ip) + { + if (strpos($ip, '/') !== false) + { + list($addr, $nm) = explode('/', $ip); + } + else + { + $addr = $ip; + } + return $addr; + } + + /** + * Uncompresses an IPv6 address + * + * RFC 2373 allows you to compress zeros in an address to '::'. This + * function expects an valid IPv6 address and expands the '::' to + * the required zeros. + * + * Example: FF01::101 -> FF01:0:0:0:0:0:0:101 + * ::1 -> 0:0:0:0:0:0:0:1 + * + * @access public + * @static + * @param string $ip a valid IPv6-address (hex format) + * @return string the uncompressed IPv6-address (hex format) + */ + function Uncompress($ip) + { + $uip = SimplePie_Net_IPv6::removeNetmaskSpec($ip); + $c1 = -1; + $c2 = -1; + if (strpos($ip, '::') !== false) + { + list($ip1, $ip2) = explode('::', $ip); + if ($ip1 === '') + { + $c1 = -1; + } + else + { + $pos = 0; + if (($pos = substr_count($ip1, ':')) > 0) + { + $c1 = $pos; + } + else + { + $c1 = 0; + } + } + if ($ip2 === '') + { + $c2 = -1; + } + else + { + $pos = 0; + if (($pos = substr_count($ip2, ':')) > 0) + { + $c2 = $pos; + } + else + { + $c2 = 0; + } + } + if (strstr($ip2, '.')) + { + $c2++; + } + // :: + if ($c1 === -1 && $c2 === -1) + { + $uip = '0:0:0:0:0:0:0:0'; + } + // ::xxx + else if ($c1 === -1) + { + $fill = str_repeat('0:', 7 - $c2); + $uip = str_replace('::', $fill, $uip); + } + // xxx:: + else if ($c2 === -1) + { + $fill = str_repeat(':0', 7 - $c1); + $uip = str_replace('::', $fill, $uip); + } + // xxx::xxx + else + { + $fill = str_repeat(':0:', 6 - $c2 - $c1); + $uip = str_replace('::', $fill, $uip); + $uip = str_replace('::', ':', $uip); + } + } + return $uip; + } + + /** + * Splits an IPv6 address into the IPv6 and a possible IPv4 part + * + * RFC 2373 allows you to note the last two parts of an IPv6 address as + * an IPv4 compatible address + * + * Example: 0:0:0:0:0:0:13.1.68.3 + * 0:0:0:0:0:FFFF:129.144.52.38 + * + * @access public + * @static + * @param string $ip a valid IPv6-address (hex format) + * @return array [0] contains the IPv6 part, [1] the IPv4 part (hex format) + */ + function SplitV64($ip) + { + $ip = SimplePie_Net_IPv6::Uncompress($ip); + if (strstr($ip, '.')) + { + $pos = strrpos($ip, ':'); + $ip[$pos] = '_'; + $ipPart = explode('_', $ip); + return $ipPart; + } + else + { + return array($ip, ''); + } + } + + /** + * Checks an IPv6 address + * + * Checks if the given IP is IPv6-compatible + * + * @access public + * @static + * @param string $ip a valid IPv6-address + * @return bool true if $ip is an IPv6 address + */ + function checkIPv6($ip) + { + $ipPart = SimplePie_Net_IPv6::SplitV64($ip); + $count = 0; + if (!empty($ipPart[0])) + { + $ipv6 = explode(':', $ipPart[0]); + for ($i = 0; $i < count($ipv6); $i++) + { + $dec = hexdec($ipv6[$i]); + $hex = strtoupper(preg_replace('/^[0]{1,3}(.*[0-9a-fA-F])$/', '\\1', $ipv6[$i])); + if ($ipv6[$i] >= 0 && $dec <= 65535 && $hex === strtoupper(dechex($dec))) + { + $count++; + } + } + if ($count === 8) + { + return true; + } + elseif ($count === 6 && !empty($ipPart[1])) + { + $ipv4 = explode('.', $ipPart[1]); + $count = 0; + foreach ($ipv4 as $ipv4_part) + { + if ($ipv4_part >= 0 && $ipv4_part <= 255 && preg_match('/^\d{1,3}$/', $ipv4_part)) + { + $count++; + } + } + if ($count === 4) + { + return true; + } + } + else + { + return false; + } + + } + else + { + return false; + } + } +} + +/** + * Date Parser + * + * @package SimplePie + */ +class SimplePie_Parse_Date +{ + /** + * Input data + * + * @access protected + * @var string + */ + var $date; + + /** + * List of days, calendar day name => ordinal day number in the week + * + * @access protected + * @var array + */ + var $day = array( + // English + 'mon' => 1, + 'monday' => 1, + 'tue' => 2, + 'tuesday' => 2, + 'wed' => 3, + 'wednesday' => 3, + 'thu' => 4, + 'thursday' => 4, + 'fri' => 5, + 'friday' => 5, + 'sat' => 6, + 'saturday' => 6, + 'sun' => 7, + 'sunday' => 7, + // Dutch + 'maandag' => 1, + 'dinsdag' => 2, + 'woensdag' => 3, + 'donderdag' => 4, + 'vrijdag' => 5, + 'zaterdag' => 6, + 'zondag' => 7, + // French + 'lundi' => 1, + 'mardi' => 2, + 'mercredi' => 3, + 'jeudi' => 4, + 'vendredi' => 5, + 'samedi' => 6, + 'dimanche' => 7, + // German + 'montag' => 1, + 'dienstag' => 2, + 'mittwoch' => 3, + 'donnerstag' => 4, + 'freitag' => 5, + 'samstag' => 6, + 'sonnabend' => 6, + 'sonntag' => 7, + // Italian + 'lunedì' => 1, + 'martedì' => 2, + 'mercoledì' => 3, + 'giovedì' => 4, + 'venerdì' => 5, + 'sabato' => 6, + 'domenica' => 7, + // Spanish + 'lunes' => 1, + 'martes' => 2, + 'miércoles' => 3, + 'jueves' => 4, + 'viernes' => 5, + 'sábado' => 6, + 'domingo' => 7, + // Finnish + 'maanantai' => 1, + 'tiistai' => 2, + 'keskiviikko' => 3, + 'torstai' => 4, + 'perjantai' => 5, + 'lauantai' => 6, + 'sunnuntai' => 7, + // Hungarian + 'hétfő' => 1, + 'kedd' => 2, + 'szerda' => 3, + 'csütörtok' => 4, + 'péntek' => 5, + 'szombat' => 6, + 'vasárnap' => 7, + // Greek + 'Δευ' => 1, + 'Τρι' => 2, + 'Τετ' => 3, + 'Πεμ' => 4, + 'Παρ' => 5, + 'Σαβ' => 6, + 'Κυρ' => 7, + ); + + /** + * List of months, calendar month name => calendar month number + * + * @access protected + * @var array + */ + var $month = array( + // English + 'jan' => 1, + 'january' => 1, + 'feb' => 2, + 'february' => 2, + 'mar' => 3, + 'march' => 3, + 'apr' => 4, + 'april' => 4, + 'may' => 5, + // No long form of May + 'jun' => 6, + 'june' => 6, + 'jul' => 7, + 'july' => 7, + 'aug' => 8, + 'august' => 8, + 'sep' => 9, + 'september' => 8, + 'oct' => 10, + 'october' => 10, + 'nov' => 11, + 'november' => 11, + 'dec' => 12, + 'december' => 12, + // Dutch + 'januari' => 1, + 'februari' => 2, + 'maart' => 3, + 'april' => 4, + 'mei' => 5, + 'juni' => 6, + 'juli' => 7, + 'augustus' => 8, + 'september' => 9, + 'oktober' => 10, + 'november' => 11, + 'december' => 12, + // French + 'janvier' => 1, + 'février' => 2, + 'mars' => 3, + 'avril' => 4, + 'mai' => 5, + 'juin' => 6, + 'juillet' => 7, + 'août' => 8, + 'septembre' => 9, + 'octobre' => 10, + 'novembre' => 11, + 'décembre' => 12, + // German + 'januar' => 1, + 'februar' => 2, + 'märz' => 3, + 'april' => 4, + 'mai' => 5, + 'juni' => 6, + 'juli' => 7, + 'august' => 8, + 'september' => 9, + 'oktober' => 10, + 'november' => 11, + 'dezember' => 12, + // Italian + 'gennaio' => 1, + 'febbraio' => 2, + 'marzo' => 3, + 'aprile' => 4, + 'maggio' => 5, + 'giugno' => 6, + 'luglio' => 7, + 'agosto' => 8, + 'settembre' => 9, + 'ottobre' => 10, + 'novembre' => 11, + 'dicembre' => 12, + // Spanish + 'enero' => 1, + 'febrero' => 2, + 'marzo' => 3, + 'abril' => 4, + 'mayo' => 5, + 'junio' => 6, + 'julio' => 7, + 'agosto' => 8, + 'septiembre' => 9, + 'setiembre' => 9, + 'octubre' => 10, + 'noviembre' => 11, + 'diciembre' => 12, + // Finnish + 'tammikuu' => 1, + 'helmikuu' => 2, + 'maaliskuu' => 3, + 'huhtikuu' => 4, + 'toukokuu' => 5, + 'kesäkuu' => 6, + 'heinäkuu' => 7, + 'elokuu' => 8, + 'suuskuu' => 9, + 'lokakuu' => 10, + 'marras' => 11, + 'joulukuu' => 12, + // Hungarian + 'január' => 1, + 'február' => 2, + 'március' => 3, + 'április' => 4, + 'május' => 5, + 'június' => 6, + 'július' => 7, + 'augusztus' => 8, + 'szeptember' => 9, + 'október' => 10, + 'november' => 11, + 'december' => 12, + // Greek + 'Ιαν' => 1, + 'Φεβ' => 2, + 'Μάώ' => 3, + 'Μαώ' => 3, + 'Απρ' => 4, + 'Μάι' => 5, + 'Μαϊ' => 5, + 'Μαι' => 5, + 'Ιούν' => 6, + 'Ιον' => 6, + 'Ιούλ' => 7, + 'Ιολ' => 7, + 'Αύγ' => 8, + 'Αυγ' => 8, + 'Σεπ' => 9, + 'Οκτ' => 10, + 'Νοέ' => 11, + 'Δεκ' => 12, + ); + + /** + * List of timezones, abbreviation => offset from UTC + * + * @access protected + * @var array + */ + var $timezone = array( + 'ACDT' => 37800, + 'ACIT' => 28800, + 'ACST' => 34200, + 'ACT' => -18000, + 'ACWDT' => 35100, + 'ACWST' => 31500, + 'AEDT' => 39600, + 'AEST' => 36000, + 'AFT' => 16200, + 'AKDT' => -28800, + 'AKST' => -32400, + 'AMDT' => 18000, + 'AMT' => -14400, + 'ANAST' => 46800, + 'ANAT' => 43200, + 'ART' => -10800, + 'AZOST' => -3600, + 'AZST' => 18000, + 'AZT' => 14400, + 'BIOT' => 21600, + 'BIT' => -43200, + 'BOT' => -14400, + 'BRST' => -7200, + 'BRT' => -10800, + 'BST' => 3600, + 'BTT' => 21600, + 'CAST' => 18000, + 'CAT' => 7200, + 'CCT' => 23400, + 'CDT' => -18000, + 'CEDT' => 7200, + 'CET' => 3600, + 'CGST' => -7200, + 'CGT' => -10800, + 'CHADT' => 49500, + 'CHAST' => 45900, + 'CIST' => -28800, + 'CKT' => -36000, + 'CLDT' => -10800, + 'CLST' => -14400, + 'COT' => -18000, + 'CST' => -21600, + 'CVT' => -3600, + 'CXT' => 25200, + 'DAVT' => 25200, + 'DTAT' => 36000, + 'EADT' => -18000, + 'EAST' => -21600, + 'EAT' => 10800, + 'ECT' => -18000, + 'EDT' => -14400, + 'EEST' => 10800, + 'EET' => 7200, + 'EGT' => -3600, + 'EKST' => 21600, + 'EST' => -18000, + 'FJT' => 43200, + 'FKDT' => -10800, + 'FKST' => -14400, + 'FNT' => -7200, + 'GALT' => -21600, + 'GEDT' => 14400, + 'GEST' => 10800, + 'GFT' => -10800, + 'GILT' => 43200, + 'GIT' => -32400, + 'GST' => 14400, + 'GST' => -7200, + 'GYT' => -14400, + 'HAA' => -10800, + 'HAC' => -18000, + 'HADT' => -32400, + 'HAE' => -14400, + 'HAP' => -25200, + 'HAR' => -21600, + 'HAST' => -36000, + 'HAT' => -9000, + 'HAY' => -28800, + 'HKST' => 28800, + 'HMT' => 18000, + 'HNA' => -14400, + 'HNC' => -21600, + 'HNE' => -18000, + 'HNP' => -28800, + 'HNR' => -25200, + 'HNT' => -12600, + 'HNY' => -32400, + 'IRDT' => 16200, + 'IRKST' => 32400, + 'IRKT' => 28800, + 'IRST' => 12600, + 'JFDT' => -10800, + 'JFST' => -14400, + 'JST' => 32400, + 'KGST' => 21600, + 'KGT' => 18000, + 'KOST' => 39600, + 'KOVST' => 28800, + 'KOVT' => 25200, + 'KRAST' => 28800, + 'KRAT' => 25200, + 'KST' => 32400, + 'LHDT' => 39600, + 'LHST' => 37800, + 'LINT' => 50400, + 'LKT' => 21600, + 'MAGST' => 43200, + 'MAGT' => 39600, + 'MAWT' => 21600, + 'MDT' => -21600, + 'MESZ' => 7200, + 'MEZ' => 3600, + 'MHT' => 43200, + 'MIT' => -34200, + 'MNST' => 32400, + 'MSDT' => 14400, + 'MSST' => 10800, + 'MST' => -25200, + 'MUT' => 14400, + 'MVT' => 18000, + 'MYT' => 28800, + 'NCT' => 39600, + 'NDT' => -9000, + 'NFT' => 41400, + 'NMIT' => 36000, + 'NOVST' => 25200, + 'NOVT' => 21600, + 'NPT' => 20700, + 'NRT' => 43200, + 'NST' => -12600, + 'NUT' => -39600, + 'NZDT' => 46800, + 'NZST' => 43200, + 'OMSST' => 25200, + 'OMST' => 21600, + 'PDT' => -25200, + 'PET' => -18000, + 'PETST' => 46800, + 'PETT' => 43200, + 'PGT' => 36000, + 'PHOT' => 46800, + 'PHT' => 28800, + 'PKT' => 18000, + 'PMDT' => -7200, + 'PMST' => -10800, + 'PONT' => 39600, + 'PST' => -28800, + 'PWT' => 32400, + 'PYST' => -10800, + 'PYT' => -14400, + 'RET' => 14400, + 'ROTT' => -10800, + 'SAMST' => 18000, + 'SAMT' => 14400, + 'SAST' => 7200, + 'SBT' => 39600, + 'SCDT' => 46800, + 'SCST' => 43200, + 'SCT' => 14400, + 'SEST' => 3600, + 'SGT' => 28800, + 'SIT' => 28800, + 'SRT' => -10800, + 'SST' => -39600, + 'SYST' => 10800, + 'SYT' => 7200, + 'TFT' => 18000, + 'THAT' => -36000, + 'TJT' => 18000, + 'TKT' => -36000, + 'TMT' => 18000, + 'TOT' => 46800, + 'TPT' => 32400, + 'TRUT' => 36000, + 'TVT' => 43200, + 'TWT' => 28800, + 'UYST' => -7200, + 'UYT' => -10800, + 'UZT' => 18000, + 'VET' => -14400, + 'VLAST' => 39600, + 'VLAT' => 36000, + 'VOST' => 21600, + 'VUT' => 39600, + 'WAST' => 7200, + 'WAT' => 3600, + 'WDT' => 32400, + 'WEST' => 3600, + 'WFT' => 43200, + 'WIB' => 25200, + 'WIT' => 32400, + 'WITA' => 28800, + 'WKST' => 18000, + 'WST' => 28800, + 'YAKST' => 36000, + 'YAKT' => 32400, + 'YAPT' => 36000, + 'YEKST' => 21600, + 'YEKT' => 18000, + ); + + /** + * Cached PCRE for SimplePie_Parse_Date::$day + * + * @access protected + * @var string + */ + var $day_pcre; + + /** + * Cached PCRE for SimplePie_Parse_Date::$month + * + * @access protected + * @var string + */ + var $month_pcre; + + /** + * Array of user-added callback methods + * + * @access private + * @var array + */ + var $built_in = array(); + + /** + * Array of user-added callback methods + * + * @access private + * @var array + */ + var $user = array(); + + /** + * Create new SimplePie_Parse_Date object, and set self::day_pcre, + * self::month_pcre, and self::built_in + * + * @access private + */ + function SimplePie_Parse_Date() + { + $this->day_pcre = '(' . implode(array_keys($this->day), '|') . ')'; + $this->month_pcre = '(' . implode(array_keys($this->month), '|') . ')'; + + static $cache; + if (!isset($cache[get_class($this)])) + { + $all_methods = get_class_methods($this); + + foreach ($all_methods as $method) + { + if (strtolower(substr($method, 0, 5)) === 'date_') + { + $cache[get_class($this)][] = $method; + } + } + } + + foreach ($cache[get_class($this)] as $method) + { + $this->built_in[] = $method; + } + } + + /** + * Get the object + * + * @access public + */ + function get() + { + static $object; + if (!$object) + { + $object = new SimplePie_Parse_Date; + } + return $object; + } + + /** + * Parse a date + * + * @final + * @access public + * @param string $date Date to parse + * @return int Timestamp corresponding to date string, or false on failure + */ + function parse($date) + { + foreach ($this->user as $method) + { + if (($returned = call_user_func($method, $date)) !== false) + { + return $returned; + } + } + + foreach ($this->built_in as $method) + { + if (($returned = call_user_func(array(&$this, $method), $date)) !== false) + { + return $returned; + } + } + + return false; + } + + /** + * Add a callback method to parse a date + * + * @final + * @access public + * @param callback $callback + */ + function add_callback($callback) + { + if (is_callable($callback)) + { + $this->user[] = $callback; + } + else + { + trigger_error('User-supplied function must be a valid callback', E_USER_WARNING); + } + } + + /** + * Parse a superset of W3C-DTF (allows hyphens and colons to be omitted, as + * well as allowing any of upper or lower case "T", horizontal tabs, or + * spaces to be used as the time seperator (including more than one)) + * + * @access protected + * @return int Timestamp + */ + function date_w3cdtf($date) + { + static $pcre; + if (!$pcre) + { + $year = '([0-9]{4})'; + $month = $day = $hour = $minute = $second = '([0-9]{2})'; + $decimal = '([0-9]*)'; + $zone = '(?:(Z)|([+\-])([0-9]{1,2}):?([0-9]{1,2}))'; + $pcre = '/^' . $year . '(?:-?' . $month . '(?:-?' . $day . '(?:[Tt\x09\x20]+' . $hour . '(?::?' . $minute . '(?::?' . $second . '(?:.' . $decimal . ')?)?)?' . $zone . ')?)?)?$/'; + } + if (preg_match($pcre, $date, $match)) + { + /* + Capturing subpatterns: + 1: Year + 2: Month + 3: Day + 4: Hour + 5: Minute + 6: Second + 7: Decimal fraction of a second + 8: Zulu + 9: Timezone ± + 10: Timezone hours + 11: Timezone minutes + */ + + // Fill in empty matches + for ($i = count($match); $i <= 3; $i++) + { + $match[$i] = '1'; + } + + for ($i = count($match); $i <= 7; $i++) + { + $match[$i] = '0'; + } + + // Numeric timezone + if (isset($match[9]) && $match[9] !== '') + { + $timezone = $match[10] * 3600; + $timezone += $match[11] * 60; + if ($match[9] === '-') + { + $timezone = 0 - $timezone; + } + } + else + { + $timezone = 0; + } + + // Convert the number of seconds to an integer, taking decimals into account + $second = round($match[6] + $match[7] / pow(10, strlen($match[7]))); + + return gmmktime($match[4], $match[5], $second, $match[2], $match[3], $match[1]) - $timezone; + } + else + { + return false; + } + } + + /** + * Remove RFC822 comments + * + * @access protected + * @param string $data Data to strip comments from + * @return string Comment stripped string + */ + function remove_rfc2822_comments($string) + { + $string = (string) $string; + $position = 0; + $length = strlen($string); + $depth = 0; + + $output = ''; + + while ($position < $length && ($pos = strpos($string, '(', $position)) !== false) + { + $output .= substr($string, $position, $pos - $position); + $position = $pos + 1; + if ($string[$pos - 1] !== '\\') + { + $depth++; + while ($depth && $position < $length) + { + $position += strcspn($string, '()', $position); + if ($string[$position - 1] === '\\') + { + $position++; + continue; + } + elseif (isset($string[$position])) + { + switch ($string[$position]) + { + case '(': + $depth++; + break; + + case ')': + $depth--; + break; + } + $position++; + } + else + { + break; + } + } + } + else + { + $output .= '('; + } + } + $output .= substr($string, $position); + + return $output; + } + + /** + * Parse RFC2822's date format + * + * @access protected + * @return int Timestamp + */ + function date_rfc2822($date) + { + static $pcre; + if (!$pcre) + { + $wsp = '[\x09\x20]'; + $fws = '(?:' . $wsp . '+|' . $wsp . '*(?:\x0D\x0A' . $wsp . '+)+)'; + $optional_fws = $fws . '?'; + $day_name = $this->day_pcre; + $month = $this->month_pcre; + $day = '([0-9]{1,2})'; + $hour = $minute = $second = '([0-9]{2})'; + $year = '([0-9]{2,4})'; + $num_zone = '([+\-])([0-9]{2})([0-9]{2})'; + $character_zone = '([A-Z]{1,5})'; + $zone = '(?:' . $num_zone . '|' . $character_zone . ')'; + $pcre = '/(?:' . $optional_fws . $day_name . $optional_fws . ',)?' . $optional_fws . $day . $fws . $month . $fws . $year . $fws . $hour . $optional_fws . ':' . $optional_fws . $minute . '(?:' . $optional_fws . ':' . $optional_fws . $second . ')?' . $fws . $zone . '/i'; + } + if (preg_match($pcre, $this->remove_rfc2822_comments($date), $match)) + { + /* + Capturing subpatterns: + 1: Day name + 2: Day + 3: Month + 4: Year + 5: Hour + 6: Minute + 7: Second + 8: Timezone ± + 9: Timezone hours + 10: Timezone minutes + 11: Alphabetic timezone + */ + + // Find the month number + $month = $this->month[strtolower($match[3])]; + + // Numeric timezone + if ($match[8] !== '') + { + $timezone = $match[9] * 3600; + $timezone += $match[10] * 60; + if ($match[8] === '-') + { + $timezone = 0 - $timezone; + } + } + // Character timezone + elseif (isset($this->timezone[strtoupper($match[11])])) + { + $timezone = $this->timezone[strtoupper($match[11])]; + } + // Assume everything else to be -0000 + else + { + $timezone = 0; + } + + // Deal with 2/3 digit years + if ($match[4] < 50) + { + $match[4] += 2000; + } + elseif ($match[4] < 1000) + { + $match[4] += 1900; + } + + // Second is optional, if it is empty set it to zero + if ($match[7] !== '') + { + $second = $match[7]; + } + else + { + $second = 0; + } + + return gmmktime($match[5], $match[6], $second, $month, $match[2], $match[4]) - $timezone; + } + else + { + return false; + } + } + + /** + * Parse RFC850's date format + * + * @access protected + * @return int Timestamp + */ + function date_rfc850($date) + { + static $pcre; + if (!$pcre) + { + $space = '[\x09\x20]+'; + $day_name = $this->day_pcre; + $month = $this->month_pcre; + $day = '([0-9]{1,2})'; + $year = $hour = $minute = $second = '([0-9]{2})'; + $zone = '([A-Z]{1,5})'; + $pcre = '/^' . $day_name . ',' . $space . $day . '-' . $month . '-' . $year . $space . $hour . ':' . $minute . ':' . $second . $space . $zone . '$/i'; + } + if (preg_match($pcre, $date, $match)) + { + /* + Capturing subpatterns: + 1: Day name + 2: Day + 3: Month + 4: Year + 5: Hour + 6: Minute + 7: Second + 8: Timezone + */ + + // Month + $month = $this->month[strtolower($match[3])]; + + // Character timezone + if (isset($this->timezone[strtoupper($match[8])])) + { + $timezone = $this->timezone[strtoupper($match[8])]; + } + // Assume everything else to be -0000 + else + { + $timezone = 0; + } + + // Deal with 2 digit year + if ($match[4] < 50) + { + $match[4] += 2000; + } + else + { + $match[4] += 1900; + } + + return gmmktime($match[5], $match[6], $match[7], $month, $match[2], $match[4]) - $timezone; + } + else + { + return false; + } + } + + /** + * Parse C99's asctime()'s date format + * + * @access protected + * @return int Timestamp + */ + function date_asctime($date) + { + static $pcre; + if (!$pcre) + { + $space = '[\x09\x20]+'; + $wday_name = $this->day_pcre; + $mon_name = $this->month_pcre; + $day = '([0-9]{1,2})'; + $hour = $sec = $min = '([0-9]{2})'; + $year = '([0-9]{4})'; + $terminator = '\x0A?\x00?'; + $pcre = '/^' . $wday_name . $space . $mon_name . $space . $day . $space . $hour . ':' . $min . ':' . $sec . $space . $year . $terminator . '$/i'; + } + if (preg_match($pcre, $date, $match)) + { + /* + Capturing subpatterns: + 1: Day name + 2: Month + 3: Day + 4: Hour + 5: Minute + 6: Second + 7: Year + */ + + $month = $this->month[strtolower($match[2])]; + return gmmktime($match[4], $match[5], $match[6], $month, $match[3], $match[7]); + } + else + { + return false; + } + } + + /** + * Parse dates using strtotime() + * + * @access protected + * @return int Timestamp + */ + function date_strtotime($date) + { + $strtotime = strtotime($date); + if ($strtotime === -1 || $strtotime === false) + { + return false; + } + else + { + return $strtotime; + } + } +} + +/** + * Content-type sniffing + * + * @package SimplePie + */ +class SimplePie_Content_Type_Sniffer +{ + /** + * File object + * + * @var SimplePie_File + * @access private + */ + var $file; + + /** + * Create an instance of the class with the input file + * + * @access public + * @param SimplePie_Content_Type_Sniffer $file Input file + */ + function SimplePie_Content_Type_Sniffer($file) + { + $this->file = $file; + } + + /** + * Get the Content-Type of the specified file + * + * @access public + * @return string Actual Content-Type + */ + function get_type() + { + if (isset($this->file->headers['content-type'])) + { + if (!isset($this->file->headers['content-encoding']) + && ($this->file->headers['content-type'] === 'text/plain' + || $this->file->headers['content-type'] === 'text/plain; charset=ISO-8859-1' + || $this->file->headers['content-type'] === 'text/plain; charset=iso-8859-1')) + { + return $this->text_or_binary(); + } + + if (($pos = strpos($this->file->headers['content-type'], ';')) !== false) + { + $official = substr($this->file->headers['content-type'], 0, $pos); + } + else + { + $official = $this->file->headers['content-type']; + } + $official = strtolower($official); + + if ($official === 'unknown/unknown' + || $official === 'application/unknown') + { + return $this->unknown(); + } + elseif (substr($official, -4) === '+xml' + || $official === 'text/xml' + || $official === 'application/xml') + { + return $official; + } + elseif (substr($official, 0, 6) === 'image/') + { + if ($return = $this->image()) + { + return $return; + } + else + { + return $official; + } + } + elseif ($official === 'text/html') + { + return $this->feed_or_html(); + } + else + { + return $official; + } + } + else + { + return $this->unknown(); + } + } + + /** + * Sniff text or binary + * + * @access private + * @return string Actual Content-Type + */ + function text_or_binary() + { + if (substr($this->file->body, 0, 2) === "\xFE\xFF" + || substr($this->file->body, 0, 2) === "\xFF\xFE" + || substr($this->file->body, 0, 4) === "\x00\x00\xFE\xFF" + || substr($this->file->body, 0, 3) === "\xEF\xBB\xBF") + { + return 'text/plain'; + } + elseif (preg_match('/[\x00-\x08\x0E-\x1A\x1C-\x1F]/', $this->file->body)) + { + return 'application/octect-stream'; + } + else + { + return 'text/plain'; + } + } + + /** + * Sniff unknown + * + * @access private + * @return string Actual Content-Type + */ + function unknown() + { + $ws = strspn($this->file->body, "\x09\x0A\x0B\x0C\x0D\x20"); + if (strtolower(substr($this->file->body, $ws, 14)) === 'file->body, $ws, 5)) === 'file->body, $ws, 7)) === 'file->body, 0, 5) === '%PDF-') + { + return 'application/pdf'; + } + elseif (substr($this->file->body, 0, 11) === '%!PS-Adobe-') + { + return 'application/postscript'; + } + elseif (substr($this->file->body, 0, 6) === 'GIF87a' + || substr($this->file->body, 0, 6) === 'GIF89a') + { + return 'image/gif'; + } + elseif (substr($this->file->body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") + { + return 'image/png'; + } + elseif (substr($this->file->body, 0, 3) === "\xFF\xD8\xFF") + { + return 'image/jpeg'; + } + elseif (substr($this->file->body, 0, 2) === "\x42\x4D") + { + return 'image/bmp'; + } + else + { + return $this->text_or_binary(); + } + } + + /** + * Sniff images + * + * @access private + * @return string Actual Content-Type + */ + function image() + { + if (substr($this->file->body, 0, 6) === 'GIF87a' + || substr($this->file->body, 0, 6) === 'GIF89a') + { + return 'image/gif'; + } + elseif (substr($this->file->body, 0, 8) === "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A") + { + return 'image/png'; + } + elseif (substr($this->file->body, 0, 3) === "\xFF\xD8\xFF") + { + return 'image/jpeg'; + } + elseif (substr($this->file->body, 0, 2) === "\x42\x4D") + { + return 'image/bmp'; + } + else + { + return false; + } + } + + /** + * Sniff HTML + * + * @access private + * @return string Actual Content-Type + */ + function feed_or_html() + { + $len = strlen($this->file->body); + $pos = strspn($this->file->body, "\x09\x0A\x0D\x20"); + + while ($pos < $len) + { + switch ($this->file->body[$pos]) + { + case "\x09": + case "\x0A": + case "\x0D": + case "\x20": + $pos += strspn($this->file->body, "\x09\x0A\x0D\x20", $pos); + continue 2; + + case '<': + $pos++; + break; + + default: + return 'text/html'; + } + + if (substr($this->file->body, $pos, 3) === '!--') + { + $pos += 3; + if ($pos < $len && ($pos = strpos($this->file->body, '-->', $pos)) !== false) + { + $pos += 3; + } + else + { + return 'text/html'; + } + } + elseif (substr($this->file->body, $pos, 1) === '!') + { + if ($pos < $len && ($pos = strpos($this->file->body, '>', $pos)) !== false) + { + $pos++; + } + else + { + return 'text/html'; + } + } + elseif (substr($this->file->body, $pos, 1) === '?') + { + if ($pos < $len && ($pos = strpos($this->file->body, '?>', $pos)) !== false) + { + $pos += 2; + } + else + { + return 'text/html'; + } + } + elseif (substr($this->file->body, $pos, 3) === 'rss' + || substr($this->file->body, $pos, 7) === 'rdf:RDF') + { + return 'application/rss+xml'; + } + elseif (substr($this->file->body, $pos, 4) === 'feed') + { + return 'application/atom+xml'; + } + else + { + return 'text/html'; + } + } + + return 'text/html'; + } +} + +/** + * Parses the XML Declaration + * + * @package SimplePie + */ +class SimplePie_XML_Declaration_Parser +{ + /** + * XML Version + * + * @access public + * @var string + */ + var $version = '1.0'; + + /** + * Encoding + * + * @access public + * @var string + */ + var $encoding = 'UTF-8'; + + /** + * Standalone + * + * @access public + * @var bool + */ + var $standalone = false; + + /** + * Current state of the state machine + * + * @access private + * @var string + */ + var $state = 'before_version_name'; + + /** + * Input data + * + * @access private + * @var string + */ + var $data = ''; + + /** + * Input data length (to avoid calling strlen() everytime this is needed) + * + * @access private + * @var int + */ + var $data_length = 0; + + /** + * Current position of the pointer + * + * @var int + * @access private + */ + var $position = 0; + + /** + * Create an instance of the class with the input data + * + * @access public + * @param string $data Input data + */ + function SimplePie_XML_Declaration_Parser($data) + { + $this->data = $data; + $this->data_length = strlen($this->data); + } + + /** + * Parse the input data + * + * @access public + * @return bool true on success, false on failure + */ + function parse() + { + while ($this->state && $this->state !== 'emit' && $this->has_data()) + { + $state = $this->state; + $this->$state(); + } + $this->data = ''; + if ($this->state === 'emit') + { + return true; + } + else + { + $this->version = ''; + $this->encoding = ''; + $this->standalone = ''; + return false; + } + } + + /** + * Check whether there is data beyond the pointer + * + * @access private + * @return bool true if there is further data, false if not + */ + function has_data() + { + return (bool) ($this->position < $this->data_length); + } + + /** + * Advance past any whitespace + * + * @return int Number of whitespace characters passed + */ + function skip_whitespace() + { + $whitespace = strspn($this->data, "\x09\x0A\x0D\x20", $this->position); + $this->position += $whitespace; + return $whitespace; + } + + /** + * Read value + */ + function get_value() + { + $quote = substr($this->data, $this->position, 1); + if ($quote === '"' || $quote === "'") + { + $this->position++; + $len = strcspn($this->data, $quote, $this->position); + if ($this->has_data()) + { + $value = substr($this->data, $this->position, $len); + $this->position += $len + 1; + return $value; + } + } + return false; + } + + function before_version_name() + { + if ($this->skip_whitespace()) + { + $this->state = 'version_name'; + } + else + { + $this->state = false; + } + } + + function version_name() + { + if (substr($this->data, $this->position, 7) === 'version') + { + $this->position += 7; + $this->skip_whitespace(); + $this->state = 'version_equals'; + } + else + { + $this->state = false; + } + } + + function version_equals() + { + if (substr($this->data, $this->position, 1) === '=') + { + $this->position++; + $this->skip_whitespace(); + $this->state = 'version_value'; + } + else + { + $this->state = false; + } + } + + function version_value() + { + if ($this->version = $this->get_value()) + { + $this->skip_whitespace(); + if ($this->has_data()) + { + $this->state = 'encoding_name'; + } + else + { + $this->state = 'emit'; + } + } + else + { + $this->state = 'standalone_name'; + } + } + + function encoding_name() + { + if (substr($this->data, $this->position, 8) === 'encoding') + { + $this->position += 8; + $this->skip_whitespace(); + $this->state = 'encoding_equals'; + } + else + { + $this->state = false; + } + } + + function encoding_equals() + { + if (substr($this->data, $this->position, 1) === '=') + { + $this->position++; + $this->skip_whitespace(); + $this->state = 'encoding_value'; + } + else + { + $this->state = false; + } + } + + function encoding_value() + { + if ($this->encoding = $this->get_value()) + { + $this->skip_whitespace(); + if ($this->has_data()) + { + $this->state = 'standalone_name'; + } + else + { + $this->state = 'emit'; + } + } + else + { + $this->state = false; + } + } + + function standalone_name() + { + if (substr($this->data, $this->position, 10) === 'standalone') + { + $this->position += 10; + $this->skip_whitespace(); + $this->state = 'standalone_equals'; + } + else + { + $this->state = false; + } + } + + function standalone_equals() + { + if (substr($this->data, $this->position, 1) === '=') + { + $this->position++; + $this->skip_whitespace(); + $this->state = 'standalone_value'; + } + else + { + $this->state = false; + } + } + + function standalone_value() + { + if ($standalone = $this->get_value()) + { + switch ($standalone) + { + case 'yes': + $this->standalone = true; + break; + + case 'no': + $this->standalone = false; + break; + + default: + $this->state = false; + return; + } + + $this->skip_whitespace(); + if ($this->has_data()) + { + $this->state = false; + } + else + { + $this->state = 'emit'; + } + } + else + { + $this->state = false; + } + } +} + +class SimplePie_Locator +{ + var $useragent; + var $timeout; + var $file; + var $local = array(); + var $elsewhere = array(); + var $file_class = 'SimplePie_File'; + var $cached_entities = array(); + var $http_base; + var $base; + var $base_location = 0; + var $checked_feeds = 0; + var $max_checked_feeds = 10; + var $content_type_sniffer_class = 'SimplePie_Content_Type_Sniffer'; + + function SimplePie_Locator(&$file, $timeout = 10, $useragent = null, $file_class = 'SimplePie_File', $max_checked_feeds = 10, $content_type_sniffer_class = 'SimplePie_Content_Type_Sniffer') + { + $this->file =& $file; + $this->file_class = $file_class; + $this->useragent = $useragent; + $this->timeout = $timeout; + $this->max_checked_feeds = $max_checked_feeds; + $this->content_type_sniffer_class = $content_type_sniffer_class; + } + + function find($type = SIMPLEPIE_LOCATOR_ALL, &$working) + { + if ($this->is_feed($this->file)) + { + return $this->file; + } + + if ($this->file->method & SIMPLEPIE_FILE_SOURCE_REMOTE) + { + $sniffer = new $this->content_type_sniffer_class($this->file); + if ($sniffer->get_type() !== 'text/html') + { + return null; + } + } + + if ($type & ~SIMPLEPIE_LOCATOR_NONE) + { + $this->get_base(); + } + + if ($type & SIMPLEPIE_LOCATOR_AUTODISCOVERY && $working = $this->autodiscovery()) + { + return $working[0]; + } + + if ($type & (SIMPLEPIE_LOCATOR_LOCAL_EXTENSION | SIMPLEPIE_LOCATOR_LOCAL_BODY | SIMPLEPIE_LOCATOR_REMOTE_EXTENSION | SIMPLEPIE_LOCATOR_REMOTE_BODY) && $this->get_links()) + { + if ($type & SIMPLEPIE_LOCATOR_LOCAL_EXTENSION && $working = $this->extension($this->local)) + { + return $working; + } + + if ($type & SIMPLEPIE_LOCATOR_LOCAL_BODY && $working = $this->body($this->local)) + { + return $working; + } + + if ($type & SIMPLEPIE_LOCATOR_REMOTE_EXTENSION && $working = $this->extension($this->elsewhere)) + { + return $working; + } + + if ($type & SIMPLEPIE_LOCATOR_REMOTE_BODY && $working = $this->body($this->elsewhere)) + { + return $working; + } + } + return null; + } + + function is_feed(&$file) + { + if ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE) + { + $sniffer = new $this->content_type_sniffer_class($file); + $sniffed = $sniffer->get_type(); + if (in_array($sniffed, array('application/rss+xml', 'application/rdf+xml', 'text/rdf', 'application/atom+xml', 'text/xml', 'application/xml'))) + { + return true; + } + else + { + return false; + } + } + elseif ($file->method & SIMPLEPIE_FILE_SOURCE_LOCAL) + { + return true; + } + else + { + return false; + } + } + + function get_base() + { + $this->http_base = $this->file->url; + $this->base = $this->http_base; + $elements = SimplePie_Misc::get_element('base', $this->file->body); + foreach ($elements as $element) + { + if ($element['attribs']['href']['data'] !== '') + { + $this->base = SimplePie_Misc::absolutize_url(trim($element['attribs']['href']['data']), $this->http_base); + $this->base_location = $element['offset']; + break; + } + } + } + + function autodiscovery() + { + $links = array_merge(SimplePie_Misc::get_element('link', $this->file->body), SimplePie_Misc::get_element('a', $this->file->body), SimplePie_Misc::get_element('area', $this->file->body)); + $done = array(); + $feeds = array(); + foreach ($links as $link) + { + if ($this->checked_feeds === $this->max_checked_feeds) + { + break; + } + if (isset($link['attribs']['href']['data']) && isset($link['attribs']['rel']['data'])) + { + $rel = array_unique(SimplePie_Misc::space_seperated_tokens(strtolower($link['attribs']['rel']['data']))); + + if ($this->base_location < $link['offset']) + { + $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->base); + } + else + { + $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->http_base); + } + + if (!in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && !empty($link['attribs']['type']['data']) && in_array(strtolower(SimplePie_Misc::parse_mime($link['attribs']['type']['data'])), array('application/rss+xml', 'application/atom+xml'))) && !isset($feeds[$href])) + { + $this->checked_feeds++; + $feed = new $this->file_class($href, $this->timeout, 5, null, $this->useragent); + if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) + { + $feeds[$href] = $feed; + } + } + $done[] = $href; + } + } + + if (!empty($feeds)) + { + return array_values($feeds); + } + else { + return null; + } + } + + function get_links() + { + $links = SimplePie_Misc::get_element('a', $this->file->body); + foreach ($links as $link) + { + if (isset($link['attribs']['href']['data'])) + { + $href = trim($link['attribs']['href']['data']); + $parsed = SimplePie_Misc::parse_url($href); + if ($parsed['scheme'] === '' || preg_match('/^(http(s)|feed)?$/i', $parsed['scheme'])) + { + if ($this->base_location < $link['offset']) + { + $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->base); + } + else + { + $href = SimplePie_Misc::absolutize_url(trim($link['attribs']['href']['data']), $this->http_base); + } + + $current = SimplePie_Misc::parse_url($this->file->url); + + if ($parsed['authority'] === '' || $parsed['authority'] === $current['authority']) + { + $this->local[] = $href; + } + else + { + $this->elsewhere[] = $href; + } + } + } + } + $this->local = array_unique($this->local); + $this->elsewhere = array_unique($this->elsewhere); + if (!empty($this->local) || !empty($this->elsewhere)) + { + return true; + } + return null; + } + + function extension(&$array) + { + foreach ($array as $key => $value) + { + if ($this->checked_feeds === $this->max_checked_feeds) + { + break; + } + if (in_array(strtolower(strrchr($value, '.')), array('.rss', '.rdf', '.atom', '.xml'))) + { + $this->checked_feeds++; + $feed = new $this->file_class($value, $this->timeout, 5, null, $this->useragent); + if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) + { + return $feed; + } + else + { + unset($array[$key]); + } + } + } + return null; + } + + function body(&$array) + { + foreach ($array as $key => $value) + { + if ($this->checked_feeds === $this->max_checked_feeds) + { + break; + } + if (preg_match('/(rss|rdf|atom|xml)/i', $value)) + { + $this->checked_feeds++; + $feed = new $this->file_class($value, $this->timeout, 5, null, $this->useragent); + if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) + { + return $feed; + } + else + { + unset($array[$key]); + } + } + } + return null; + } +} + +class SimplePie_Parser +{ + var $error_code; + var $error_string; + var $current_line; + var $current_column; + var $current_byte; + var $separator = ' '; + var $namespace = array(''); + var $element = array(''); + var $xml_base = array(''); + var $xml_base_explicit = array(false); + var $xml_lang = array(''); + var $data = array(); + var $datas = array(array()); + var $current_xhtml_construct = -1; + var $encoding; + + function parse(&$data, $encoding) + { + // Use UTF-8 if we get passed US-ASCII, as every US-ASCII character is a UTF-8 character + if (strtoupper($encoding) === 'US-ASCII') + { + $this->encoding = 'UTF-8'; + } + else + { + $this->encoding = $encoding; + } + + // Strip BOM: + // UTF-32 Big Endian BOM + if (substr($data, 0, 4) === "\x00\x00\xFE\xFF") + { + $data = substr($data, 4); + } + // UTF-32 Little Endian BOM + elseif (substr($data, 0, 4) === "\xFF\xFE\x00\x00") + { + $data = substr($data, 4); + } + // UTF-16 Big Endian BOM + elseif (substr($data, 0, 2) === "\xFE\xFF") + { + $data = substr($data, 2); + } + // UTF-16 Little Endian BOM + elseif (substr($data, 0, 2) === "\xFF\xFE") + { + $data = substr($data, 2); + } + // UTF-8 BOM + elseif (substr($data, 0, 3) === "\xEF\xBB\xBF") + { + $data = substr($data, 3); + } + + if (substr($data, 0, 5) === '')) !== false) + { + $declaration = new SimplePie_XML_Declaration_Parser(substr($data, 5, $pos - 5)); + if ($declaration->parse()) + { + $data = substr($data, $pos + 2); + $data = 'version . '" encoding="' . $encoding . '" standalone="' . (($declaration->standalone) ? 'yes' : 'no') . '"?>' . $data; + } + else + { + $this->error_string = 'SimplePie bug! Please report this!'; + return false; + } + } + + $return = true; + + static $xml_is_sane = null; + if ($xml_is_sane === null) + { + $parser_check = xml_parser_create(); + xml_parse_into_struct($parser_check, '&', $values); + xml_parser_free($parser_check); + $xml_is_sane = isset($values[0]['value']); + } + + // Create the parser + if ($xml_is_sane) + { + $xml = xml_parser_create_ns($this->encoding, $this->separator); + xml_parser_set_option($xml, XML_OPTION_SKIP_WHITE, 1); + xml_parser_set_option($xml, XML_OPTION_CASE_FOLDING, 0); + xml_set_object($xml, $this); + xml_set_character_data_handler($xml, 'cdata'); + xml_set_element_handler($xml, 'tag_open', 'tag_close'); + + // Parse! + if (!xml_parse($xml, $data, true)) + { + $this->error_code = xml_get_error_code($xml); + $this->error_string = xml_error_string($this->error_code); + $return = false; + } + $this->current_line = xml_get_current_line_number($xml); + $this->current_column = xml_get_current_column_number($xml); + $this->current_byte = xml_get_current_byte_index($xml); + xml_parser_free($xml); + return $return; + } + else + { + libxml_clear_errors(); + $xml = new XMLReader(); + $xml->xml($data); + while (@$xml->read()) + { + switch ($xml->nodeType) + { + + case constant('XMLReader::END_ELEMENT'): + if ($xml->namespaceURI !== '') + { + $tagName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}"; + } + else + { + $tagName = $xml->localName; + } + $this->tag_close(null, $tagName); + break; + case constant('XMLReader::ELEMENT'): + $empty = $xml->isEmptyElement; + if ($xml->namespaceURI !== '') + { + $tagName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}"; + } + else + { + $tagName = $xml->localName; + } + $attributes = array(); + while ($xml->moveToNextAttribute()) + { + if ($xml->namespaceURI !== '') + { + $attrName = "{$xml->namespaceURI}{$this->separator}{$xml->localName}"; + } + else + { + $attrName = $xml->localName; + } + $attributes[$attrName] = $xml->value; + } + $this->tag_open(null, $tagName, $attributes); + if ($empty) + { + $this->tag_close(null, $tagName); + } + break; + case constant('XMLReader::TEXT'): + + case constant('XMLReader::CDATA'): + $this->cdata(null, $xml->value); + break; + } + } + if ($error = libxml_get_last_error()) + { + $this->error_code = $error->code; + $this->error_string = $error->message; + $this->current_line = $error->line; + $this->current_column = $error->column; + return false; + } + else + { + return true; + } + } + } + + function get_error_code() + { + return $this->error_code; + } + + function get_error_string() + { + return $this->error_string; + } + + function get_current_line() + { + return $this->current_line; + } + + function get_current_column() + { + return $this->current_column; + } + + function get_current_byte() + { + return $this->current_byte; + } + + function get_data() + { + return $this->data; + } + + function tag_open($parser, $tag, $attributes) + { + list($this->namespace[], $this->element[]) = $this->split_ns($tag); + + $attribs = array(); + foreach ($attributes as $name => $value) + { + list($attrib_namespace, $attribute) = $this->split_ns($name); + $attribs[$attrib_namespace][$attribute] = $value; + } + + if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['base'])) + { + $this->xml_base[] = SimplePie_Misc::absolutize_url($attribs[SIMPLEPIE_NAMESPACE_XML]['base'], end($this->xml_base)); + $this->xml_base_explicit[] = true; + } + else + { + $this->xml_base[] = end($this->xml_base); + $this->xml_base_explicit[] = end($this->xml_base_explicit); + } + + if (isset($attribs[SIMPLEPIE_NAMESPACE_XML]['lang'])) + { + $this->xml_lang[] = $attribs[SIMPLEPIE_NAMESPACE_XML]['lang']; + } + else + { + $this->xml_lang[] = end($this->xml_lang); + } + + if ($this->current_xhtml_construct >= 0) + { + $this->current_xhtml_construct++; + if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML) + { + $this->data['data'] .= '<' . end($this->element); + if (isset($attribs[''])) + { + foreach ($attribs[''] as $name => $value) + { + $this->data['data'] .= ' ' . $name . '="' . htmlspecialchars($value, ENT_COMPAT, $this->encoding) . '"'; + } + } + $this->data['data'] .= '>'; + } + } + else + { + $this->datas[] =& $this->data; + $this->data =& $this->data['child'][end($this->namespace)][end($this->element)][]; + $this->data = array('data' => '', 'attribs' => $attribs, 'xml_base' => end($this->xml_base), 'xml_base_explicit' => end($this->xml_base_explicit), 'xml_lang' => end($this->xml_lang)); + if ((end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_03 && in_array(end($this->element), array('title', 'tagline', 'copyright', 'info', 'summary', 'content')) && isset($attribs['']['mode']) && $attribs['']['mode'] === 'xml') + || (end($this->namespace) === SIMPLEPIE_NAMESPACE_ATOM_10 && in_array(end($this->element), array('rights', 'subtitle', 'summary', 'info', 'title', 'content')) && isset($attribs['']['type']) && $attribs['']['type'] === 'xhtml')) + { + $this->current_xhtml_construct = 0; + } + } + } + + function cdata($parser, $cdata) + { + if ($this->current_xhtml_construct >= 0) + { + $this->data['data'] .= htmlspecialchars($cdata, ENT_QUOTES, $this->encoding); + } + else + { + $this->data['data'] .= $cdata; + } + } + + function tag_close($parser, $tag) + { + if ($this->current_xhtml_construct >= 0) + { + $this->current_xhtml_construct--; + if (end($this->namespace) === SIMPLEPIE_NAMESPACE_XHTML && !in_array(end($this->element), array('area', 'base', 'basefont', 'br', 'col', 'frame', 'hr', 'img', 'input', 'isindex', 'link', 'meta', 'param'))) + { + $this->data['data'] .= 'element) . '>'; + } + } + if ($this->current_xhtml_construct === -1) + { + $this->data =& $this->datas[count($this->datas) - 1]; + array_pop($this->datas); + } + + array_pop($this->element); + array_pop($this->namespace); + array_pop($this->xml_base); + array_pop($this->xml_base_explicit); + array_pop($this->xml_lang); + } + + function split_ns($string) + { + static $cache = array(); + if (!isset($cache[$string])) + { + if ($pos = strpos($string, $this->separator)) + { + static $separator_length; + if (!$separator_length) + { + $separator_length = strlen($this->separator); + } + $namespace = substr($string, 0, $pos); + $local_name = substr($string, $pos + $separator_length); + if (strtolower($namespace) === SIMPLEPIE_NAMESPACE_ITUNES) + { + $namespace = SIMPLEPIE_NAMESPACE_ITUNES; + } + + // Normalize the Media RSS namespaces + if ($namespace === SIMPLEPIE_NAMESPACE_MEDIARSS_WRONG) + { + $namespace = SIMPLEPIE_NAMESPACE_MEDIARSS; + } + $cache[$string] = array($namespace, $local_name); + } + else + { + $cache[$string] = array('', $string); + } + } + return $cache[$string]; + } +} + +/** + * @todo Move to using an actual HTML parser (this will allow tags to be properly stripped, and to switch between HTML and XHTML), this will also make it easier to shorten a string while preserving HTML tags + */ +class SimplePie_Sanitize +{ + // Private vars + var $base; + + // Options + var $remove_div = true; + var $image_handler = ''; + var $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style'); + var $encode_instead_of_strip = false; + var $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc'); + var $strip_comments = false; + var $output_encoding = 'UTF-8'; + var $enable_cache = true; + var $cache_location = './cache'; + var $cache_name_function = 'md5'; + var $cache_class = 'SimplePie_Cache'; + var $file_class = 'SimplePie_File'; + var $timeout = 10; + var $useragent = ''; + var $force_fsockopen = false; + + var $replace_url_attributes = array( + 'a' => 'href', + 'area' => 'href', + 'blockquote' => 'cite', + 'del' => 'cite', + 'form' => 'action', + 'img' => array('longdesc', 'src'), + 'input' => 'src', + 'ins' => 'cite', + 'q' => 'cite' + ); + + function remove_div($enable = true) + { + $this->remove_div = (bool) $enable; + } + + function set_image_handler($page = false) + { + if ($page) + { + $this->image_handler = (string) $page; + } + else + { + $this->image_handler = false; + } + } + + function pass_cache_data($enable_cache = true, $cache_location = './cache', $cache_name_function = 'md5', $cache_class = 'SimplePie_Cache') + { + if (isset($enable_cache)) + { + $this->enable_cache = (bool) $enable_cache; + } + + if ($cache_location) + { + $this->cache_location = (string) $cache_location; + } + + if ($cache_name_function) + { + $this->cache_name_function = (string) $cache_name_function; + } + + if ($cache_class) + { + $this->cache_class = (string) $cache_class; + } + } + + function pass_file_data($file_class = 'SimplePie_File', $timeout = 10, $useragent = '', $force_fsockopen = false) + { + if ($file_class) + { + $this->file_class = (string) $file_class; + } + + if ($timeout) + { + $this->timeout = (string) $timeout; + } + + if ($useragent) + { + $this->useragent = (string) $useragent; + } + + if ($force_fsockopen) + { + $this->force_fsockopen = (string) $force_fsockopen; + } + } + + function strip_htmltags($tags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style')) + { + if ($tags) + { + if (is_array($tags)) + { + $this->strip_htmltags = $tags; + } + else + { + $this->strip_htmltags = explode(',', $tags); + } + } + else + { + $this->strip_htmltags = false; + } + } + + function encode_instead_of_strip($encode = false) + { + $this->encode_instead_of_strip = (bool) $encode; + } + + function strip_attributes($attribs = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc')) + { + if ($attribs) + { + if (is_array($attribs)) + { + $this->strip_attributes = $attribs; + } + else + { + $this->strip_attributes = explode(',', $attribs); + } + } + else + { + $this->strip_attributes = false; + } + } + + function strip_comments($strip = false) + { + $this->strip_comments = (bool) $strip; + } + + function set_output_encoding($encoding = 'UTF-8') + { + $this->output_encoding = (string) $encoding; + } + + /** + * Set element/attribute key/value pairs of HTML attributes + * containing URLs that need to be resolved relative to the feed + * + * @access public + * @since 1.0 + * @param array $element_attribute Element/attribute key/value pairs + */ + function set_url_replacements($element_attribute = array('a' => 'href', 'area' => 'href', 'blockquote' => 'cite', 'del' => 'cite', 'form' => 'action', 'img' => array('longdesc', 'src'), 'input' => 'src', 'ins' => 'cite', 'q' => 'cite')) + { + $this->replace_url_attributes = (array) $element_attribute; + } + + function sanitize($data, $type, $base = '') + { + $data = trim($data); + if ($data !== '' || $type & SIMPLEPIE_CONSTRUCT_IRI) + { + if ($type & SIMPLEPIE_CONSTRUCT_MAYBE_HTML) + { + if (preg_match('/(&(#(x[0-9a-fA-F]+|[0-9]+)|[a-zA-Z0-9]+)|<\/[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>)/', $data)) + { + $type |= SIMPLEPIE_CONSTRUCT_HTML; + } + else + { + $type |= SIMPLEPIE_CONSTRUCT_TEXT; + } + } + + if ($type & SIMPLEPIE_CONSTRUCT_BASE64) + { + $data = base64_decode($data); + } + + if ($type & SIMPLEPIE_CONSTRUCT_XHTML) + { + if ($this->remove_div) + { + $data = preg_replace('/^/', '', $data); + $data = preg_replace('/<\/div>$/', '', $data); + } + else + { + $data = preg_replace('/^/', '
    ', $data); + } + } + + if ($type & (SIMPLEPIE_CONSTRUCT_HTML | SIMPLEPIE_CONSTRUCT_XHTML)) + { + // Strip comments + if ($this->strip_comments) + { + $data = SimplePie_Misc::strip_comments($data); + } + + // Strip out HTML tags and attributes that might cause various security problems. + // Based on recommendations by Mark Pilgrim at: + // http://diveintomark.org/archives/2003/06/12/how_to_consume_rss_safely + if ($this->strip_htmltags) + { + foreach ($this->strip_htmltags as $tag) + { + $pcre = "/<($tag)" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . "(>(.*)<\/$tag" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>|(\/)?>)/siU'; + while (preg_match($pcre, $data)) + { + $data = preg_replace_callback($pcre, array(&$this, 'do_strip_htmltags'), $data); + } + } + } + + if ($this->strip_attributes) + { + foreach ($this->strip_attributes as $attrib) + { + $data = preg_replace('/(<[A-Za-z][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E]*)' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . trim($attrib) . '(?:\s*=\s*(?:"(?:[^"]*)"|\'(?:[^\']*)\'|(?:[^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?' . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . '>/', '\1\2\3>', $data); + } + } + + // Replace relative URLs + $this->base = $base; + foreach ($this->replace_url_attributes as $element => $attributes) + { + $data = $this->replace_urls($data, $element, $attributes); + } + + // If image handling (caching, etc.) is enabled, cache and rewrite all the image tags. + if (isset($this->image_handler) && ((string) $this->image_handler) !== '' && $this->enable_cache) + { + $images = SimplePie_Misc::get_element('img', $data); + foreach ($images as $img) + { + if (isset($img['attribs']['src']['data'])) + { + $image_url = call_user_func($this->cache_name_function, $img['attribs']['src']['data']); + $cache = call_user_func(array($this->cache_class, 'create'), $this->cache_location, $image_url, 'spi'); + + if ($cache->load()) + { + $img['attribs']['src']['data'] = $this->image_handler . $image_url; + $data = str_replace($img['full'], SimplePie_Misc::element_implode($img), $data); + } + else + { + $file = new $this->file_class($img['attribs']['src']['data'], $this->timeout, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen); + $headers = $file->headers; + + if ($file->success && ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300))) + { + if ($cache->save(array('headers' => $file->headers, 'body' => $file->body))) + { + $img['attribs']['src']['data'] = $this->image_handler . $image_url; + $data = str_replace($img['full'], SimplePie_Misc::element_implode($img), $data); + } + else + { + trigger_error("$this->cache_location is not writeable", E_USER_WARNING); + } + } + } + } + } + } + + // Having (possibly) taken stuff out, there may now be whitespace at the beginning/end of the data + $data = trim($data); + } + + if ($type & SIMPLEPIE_CONSTRUCT_IRI) + { + $data = SimplePie_Misc::absolutize_url($data, $base); + } + + if ($type & (SIMPLEPIE_CONSTRUCT_TEXT | SIMPLEPIE_CONSTRUCT_IRI)) + { + $data = htmlspecialchars($data, ENT_COMPAT, 'UTF-8'); + } + + if ($this->output_encoding !== 'UTF-8') + { + $data = SimplePie_Misc::change_encoding($data, 'UTF-8', $this->output_encoding); + } + } + return $data; + } + + function replace_urls($data, $tag, $attributes) + { + if (!is_array($this->strip_htmltags) || !in_array($tag, $this->strip_htmltags)) + { + $elements = SimplePie_Misc::get_element($tag, $data); + foreach ($elements as $element) + { + if (is_array($attributes)) + { + foreach ($attributes as $attribute) + { + if (isset($element['attribs'][$attribute]['data'])) + { + $element['attribs'][$attribute]['data'] = SimplePie_Misc::absolutize_url($element['attribs'][$attribute]['data'], $this->base); + $new_element = SimplePie_Misc::element_implode($element); + $data = str_replace($element['full'], $new_element, $data); + $element['full'] = $new_element; + } + } + } + elseif (isset($element['attribs'][$attributes]['data'])) + { + $element['attribs'][$attributes]['data'] = SimplePie_Misc::absolutize_url($element['attribs'][$attributes]['data'], $this->base); + $data = str_replace($element['full'], SimplePie_Misc::element_implode($element), $data); + } + } + } + return $data; + } + + function do_strip_htmltags($match) + { + if ($this->encode_instead_of_strip) + { + if (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style'))) + { + $match[1] = htmlspecialchars($match[1], ENT_COMPAT, 'UTF-8'); + $match[2] = htmlspecialchars($match[2], ENT_COMPAT, 'UTF-8'); + return "<$match[1]$match[2]>$match[3]</$match[1]>"; + } + else + { + return htmlspecialchars($match[0], ENT_COMPAT, 'UTF-8'); + } + } + elseif (isset($match[4]) && !in_array(strtolower($match[1]), array('script', 'style'))) + { + return $match[4]; + } + else + { + return ''; + } + } +} + +?> diff --git a/oss/joomla/trunk/media/system/js/caption.js b/oss/joomla/trunk/media/system/js/caption.js index d9e8f364..f963face 100644 --- a/oss/joomla/trunk/media/system/js/caption.js +++ b/oss/joomla/trunk/media/system/js/caption.js @@ -1,60 +1,73 @@ -/** -* @version $Id: modal.js 5263 2006-10-02 01:25:24Z webImagery $ -* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. -* @license GNU/GPL, see LICENSE.php -* Joomla! is free software. This version may have been modified pursuant -* to the GNU General Public License, and as distributed it includes or -* is derivative of works licensed under the GNU General Public License or -* other free or open source software licenses. -* See COPYRIGHT.php for copyright notices and details. -*/ - -/** - * JCaption javascript behavior - * - * Used for displaying image captions - * - * @package Joomla - * @since 1.5 - * @version 1.0 - */ -var JCaption = new Class({ - initialize: function(selector) - { - this.selector = selector; - - var images = $$(selector); - images.each(function(image){ this.createCaption(image); }, this); - }, - - createCaption: function(element) - { - var caption = document.createTextNode(element.title); - var container = document.createElement("div"); - var text = document.createElement("p"); - var width = element.getAttribute("width"); - var align = element.getAttribute("align"); - - if(!width) { - width = element.width; - } - - text.appendChild(caption); - element.parentNode.insertBefore(container, element); - container.appendChild(element); - if ( element.title != "" ) { - container.appendChild(text); - } - container.className = this.selector.replace('.', '_'); - container.className = container.className + " " + align; - container.setAttribute("style","float:"+align); - container.style.width = width + "px"; - - } -}); - -document.caption = null -window.addEvent('load', function() { - var caption = new JCaption('img.caption') - document.caption = caption -}); +/** +* @version $Id: caption.js 5263 2006-10-02 01:25:24Z webImagery $ +* @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. +* @license GNU/GPL, see LICENSE.php +* Joomla! is free software. This version may have been modified pursuant +* to the GNU General Public License, and as distributed it includes or +* is derivative of works licensed under the GNU General Public License or +* other free or open source software licenses. +* See COPYRIGHT.php for copyright notices and details. +*/ + +/** +* JCaption javascript behavior +* +* Used for displaying image captions +* +* @package Joomla +* @since 1.5 +* @version 1.0 +*/ +var JCaption = new Class({ + initialize: function(selector) + { + this.selector = selector; + + var images = $$(selector); + images.each(function(image){ this.createCaption(image); }, this); + }, + + createCaption: function(element) + { + var caption = document.createTextNode(element.title); + var container = document.createElement("div"); + var text = document.createElement("p"); + var width = element.getAttribute("width"); + var align = element.getAttribute("align"); + + if(!width) { + width = element.width; + } + + //Windows fix + if (!align) + align = element.getStyle("float"); // Rest of the world fix + if (!align) // IE DOM Fix + align = element.style.styleFloat; + + if (align=="") { + align="none"; + } + + text.appendChild(caption); + text.className = this.selector.replace('.', '_'); + + element.parentNode.insertBefore(container, element); + container.appendChild(element); + if ( element.title != "" ) { + container.appendChild(text); + } + container.className = this.selector.replace('.', '_'); + container.className = container.className + " " + align; + container.setAttribute("style","float:"+align); + + container.style.width = width + "px"; + + } +}); + +document.caption = null; +window.addEvent('load', function() { + var caption = new JCaption('img.caption') + document.caption = caption +}); diff --git a/oss/joomla/trunk/media/system/js/combobox.js b/oss/joomla/trunk/media/system/js/combobox.js index 58de9f8f..897ad309 100644 --- a/oss/joomla/trunk/media/system/js/combobox.js +++ b/oss/joomla/trunk/media/system/js/combobox.js @@ -1,116 +1,116 @@ -/** -* @version $Id: modal.js 5263 2006-10-02 01:25:24Z webImagery $ -* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved. -* @license GNU/GPL, see LICENSE.php -* Joomla! is free software. This version may have been modified pursuant -* to the GNU General Public License, and as distributed it includes or -* is derivative of works licensed under the GNU General Public License or -* other free or open source software licenses. -* See COPYRIGHT.php for copyright notices and details. -*/ - -/** - * JCombobox javascript behavior - * - * Used for transforming tags into combobox dropdowns with appropriate