diff --git a/admin/code/CMSBatchActionHandler.php b/admin/code/CMSBatchActionHandler.php index f45533ba9..4bc6c4f3b 100644 --- a/admin/code/CMSBatchActionHandler.php +++ b/admin/code/CMSBatchActionHandler.php @@ -81,7 +81,7 @@ class CMSBatchActionHandler extends RequestHandler { $actionHandler = new $actionClass(); // Sanitise ID list and query the database for apges - $ids = split(' *, *', trim($request->requestVar('csvIDs'))); + $ids = preg_split('/ *, */', trim($request->requestVar('csvIDs'))); foreach($ids as $k => $v) if(!is_numeric($v)) unset($ids[$k]); if($ids) { @@ -135,7 +135,7 @@ class CMSBatchActionHandler extends RequestHandler { $actionHandler = new $actionClass['class'](); // Sanitise ID list and query the database for apges - $ids = split(' *, *', trim($request->requestVar('csvIDs'))); + $ids = preg_split('/ *, */', trim($request->requestVar('csvIDs'))); foreach($ids as $k => $id) $ids[$k] = (int)$id; $ids = array_filter($ids); @@ -157,7 +157,7 @@ class CMSBatchActionHandler extends RequestHandler { $actionHandler = new $actionClass(); // Sanitise ID list and query the database for apges - $ids = split(' *, *', trim($request->requestVar('csvIDs'))); + $ids = preg_split('/ *, */', trim($request->requestVar('csvIDs'))); foreach($ids as $k => $id) $ids[$k] = (int)$id; $ids = array_filter($ids); @@ -211,4 +211,4 @@ class CMSBatchActionHandler extends RequestHandler { return $actions; } -} \ No newline at end of file +} diff --git a/admin/code/LeftAndMain.php b/admin/code/LeftAndMain.php index 97c471a46..df88b41a3 100644 --- a/admin/code/LeftAndMain.php +++ b/admin/code/LeftAndMain.php @@ -250,7 +250,7 @@ class LeftAndMain extends Controller implements PermissionProvider { SAPPHIRE_ADMIN_DIR . '/thirdparty/jlayout/lib/jquery.jlayout.js', SAPPHIRE_ADMIN_DIR . '/thirdparty/history-js/scripts/uncompressed/history.js', SAPPHIRE_ADMIN_DIR . '/thirdparty/history-js/scripts/uncompressed/history.adapter.jquery.js', - // SAPPHIRE_ADMIN_DIR . '/thirdparty/history-js/scripts/uncompressed/history.html4.js', + SAPPHIRE_ADMIN_DIR . '/thirdparty/history-js/scripts/uncompressed/history.html4.js', THIRDPARTY_DIR . '/jstree/jquery.jstree.js', SAPPHIRE_ADMIN_DIR . '/thirdparty/chosen/chosen/chosen.jquery.js', SAPPHIRE_ADMIN_DIR . '/thirdparty/jquery-hoverIntent/jquery.hoverIntent.js', @@ -322,7 +322,7 @@ class LeftAndMain extends Controller implements PermissionProvider { SSViewer::set_theme(null); } - function handleRequest($request, DataModel $model) { + function handleRequest(SS_HTTPRequest $request, DataModel $model = null) { $title = $this->Title(); $response = parent::handleRequest($request, $model); diff --git a/admin/code/ModelAdmin.php b/admin/code/ModelAdmin.php index 1c5a1834c..131f4e192 100644 --- a/admin/code/ModelAdmin.php +++ b/admin/code/ModelAdmin.php @@ -113,7 +113,7 @@ abstract class ModelAdmin extends LeftAndMain { Requirements::javascript(SAPPHIRE_ADMIN_DIR . '/javascript/ModelAdmin.js'); } - function getEditForm($id = null) { + function getEditForm($id = null, $fields = null) { $list = $this->getList(); $exportButton = new GridFieldExportButton(); $exportButton->setExportColumns($this->getExportFields()); diff --git a/admin/css/ie7.css b/admin/css/ie7.css index aaf3eef74..555b52021 100644 --- a/admin/css/ie7.css +++ b/admin/css/ie7.css @@ -20,6 +20,7 @@ html { overflow: hidden; } .jstree li a .ui-icon { text-indent: 0px !important; } +.cms table.ss-gridfield-table tbody td { width: auto; } .cms table.ss-gridfield-table tr th.extra span input { height: 23px; } .ss-gridfield-button-filter.ss-ui-button { margin: -1px -5px; background: #e6e6e6 url(../images/filter-icons.png) no-repeat -40px 6px; filter: none; } diff --git a/admin/css/screen.css b/admin/css/screen.css index 4a8c71756..613a35646 100644 --- a/admin/css/screen.css +++ b/admin/css/screen.css @@ -35,7 +35,7 @@ If more variables exist in the future, consider creating a variables file.*/ /** ---------------------------------------------------- Double tone borders http://daverupert.com/2011/06/two-tone-borders-with-css3/ ----------------------------------------------------- */ /** ----------------------------- Sprite images ----------------------------- */ /** Helper SCSS file for generating sprites for the interface. */ -.btn-icon-sprite, .ui-state-default .btn-icon-accept, .ui-state-default .btn-icon-accept_disabled, .ui-state-default .btn-icon-add, .ui-state-default .btn-icon-add_disabled, .ui-state-default .btn-icon-addpage, .ui-state-default .btn-icon-addpage_disabled, .ui-state-default .btn-icon-arrow-circle-135-left, .ui-state-default .btn-icon-back, .ui-state-default .btn-icon-back_disabled, .ui-state-default .btn-icon-chain--arrow, .ui-state-default .btn-icon-chain--exclamation, .ui-state-default .btn-icon-chain--minus, .ui-state-default .btn-icon-chain--pencil, .ui-state-default .btn-icon-chain--plus, .ui-state-default .btn-icon-chain-small, .ui-state-default .btn-icon-chain-unchain, .ui-state-default .btn-icon-chain, .ui-state-default .btn-icon-cross-circle, .ui-state-default .btn-icon-cross-circle_disabled, .ui-state-default .btn-icon-decline, .ui-state-default .btn-icon-decline_disabled, .ui-state-default .btn-icon-download-csv, .ui-state-default .btn-icon-drive-upload, .ui-state-default .btn-icon-drive-upload_disabled, .ui-state-default .btn-icon-magnifier, .ui-state-default .btn-icon-minus-circle, .ui-state-default .btn-icon-minus-circle_disabled, .ui-state-default .btn-icon-navigation, .ui-state-default .btn-icon-navigation_disabled, .ui-state-default .btn-icon-network-cloud, .ui-state-default .btn-icon-network-cloud_disabled, .ui-state-default .btn-icon-pencil, .ui-state-default .btn-icon-pencil_disabled, .ui-state-default .btn-icon-plug-disconnect-prohibition, .ui-state-default .btn-icon-plug-disconnect-prohibition_disabled, .ui-state-default .btn-icon-preview, .ui-state-default .btn-icon-preview_disabled, .ui-state-default .btn-icon-settings, .ui-state-default .btn-icon-settings_disabled, .ui-state-default .btn-icon-unpublish, .ui-state-default .btn-icon-unpublish_disabled { background: url('../images/btn-icon-sb5d07676ff.png') no-repeat; } +.btn-icon-sprite, .ui-state-default .btn-icon-accept, .ui-state-default .btn-icon-accept_disabled, .ui-state-default .btn-icon-add, .ui-state-default .btn-icon-add_disabled, .ui-state-default .btn-icon-addpage, .ui-state-default .btn-icon-addpage_disabled, .ui-state-default .btn-icon-arrow-circle-135-left, .ui-state-default .btn-icon-back, .ui-state-default .btn-icon-back_disabled, .ui-state-default .btn-icon-chain--arrow, .ui-state-default .btn-icon-chain--exclamation, .ui-state-default .btn-icon-chain--minus, .ui-state-default .btn-icon-chain--pencil, .ui-state-default .btn-icon-chain--plus, .ui-state-default .btn-icon-chain-small, .ui-state-default .btn-icon-chain-unchain, .ui-state-default .btn-icon-chain, .ui-state-default .btn-icon-cross-circle, .ui-state-default .btn-icon-cross-circle_disabled, .ui-state-default .btn-icon-decline, .ui-state-default .btn-icon-decline_disabled, .ui-state-default .btn-icon-download-csv, .ui-state-default .btn-icon-drive-upload, .ui-state-default .btn-icon-drive-upload_disabled, .ui-state-default .btn-icon-magnifier, .ui-state-default .btn-icon-minus-circle, .ui-state-default .btn-icon-minus-circle_disabled, .ui-state-default .btn-icon-navigation, .ui-state-default .btn-icon-navigation_disabled, .ui-state-default .btn-icon-network-cloud, .ui-state-default .btn-icon-network-cloud_disabled, .ui-state-default .btn-icon-pencil, .ui-state-default .btn-icon-pencil_disabled, .ui-state-default .btn-icon-plug-disconnect-prohibition, .ui-state-default .btn-icon-plug-disconnect-prohibition_disabled, .ui-state-default .btn-icon-preview, .ui-state-default .btn-icon-preview_disabled, .ui-state-default .btn-icon-settings, .ui-state-default .btn-icon-settings_disabled, .ui-state-default .btn-icon-unpublish, .ui-state-default .btn-icon-unpublish_disabled { background: url('../images/btn-icon-sc495ceeeca.png') no-repeat; } .ui-state-default .btn-icon-accept { background-position: 0 0; } .ui-state-default .btn-icon-accept_disabled { background-position: 0 -17px; } @@ -45,39 +45,39 @@ If more variables exist in the future, consider creating a variables file.*/ .ui-state-default .btn-icon-addpage_disabled { background-position: 0 -88px; } .ui-state-default .btn-icon-arrow-circle-135-left { background-position: 0 -104px; } .ui-state-default .btn-icon-back { background-position: 0 -120px; } -.ui-state-default .btn-icon-back_disabled { background-position: 0 -135px; } -.ui-state-default .btn-icon-chain--arrow { background-position: 0 -150px; } -.ui-state-default .btn-icon-chain--exclamation { background-position: 0 -166px; } -.ui-state-default .btn-icon-chain--minus { background-position: 0 -182px; } -.ui-state-default .btn-icon-chain--pencil { background-position: 0 -198px; } -.ui-state-default .btn-icon-chain--plus { background-position: 0 -214px; } -.ui-state-default .btn-icon-chain-small { background-position: 0 -230px; } -.ui-state-default .btn-icon-chain-unchain { background-position: 0 -246px; } -.ui-state-default .btn-icon-chain { background-position: 0 -262px; } -.ui-state-default .btn-icon-cross-circle { background-position: 0 -278px; } -.ui-state-default .btn-icon-cross-circle_disabled { background-position: 0 -294px; } -.ui-state-default .btn-icon-decline { background-position: 0 -310px; } -.ui-state-default .btn-icon-decline_disabled { background-position: 0 -327px; } -.ui-state-default .btn-icon-download-csv { background-position: 0 -344px; } -.ui-state-default .btn-icon-drive-upload { background-position: 0 -362px; } -.ui-state-default .btn-icon-drive-upload_disabled { background-position: 0 -378px; } -.ui-state-default .btn-icon-magnifier { background-position: 0 -394px; } -.ui-state-default .btn-icon-minus-circle { background-position: 0 -410px; } -.ui-state-default .btn-icon-minus-circle_disabled { background-position: 0 -426px; } -.ui-state-default .btn-icon-navigation { background-position: 0 -442px; } -.ui-state-default .btn-icon-navigation_disabled { background-position: 0 -458px; } -.ui-state-default .btn-icon-network-cloud { background-position: 0 -474px; } -.ui-state-default .btn-icon-network-cloud_disabled { background-position: 0 -490px; } -.ui-state-default .btn-icon-pencil { background-position: 0 -506px; } -.ui-state-default .btn-icon-pencil_disabled { background-position: 0 -522px; } -.ui-state-default .btn-icon-plug-disconnect-prohibition { background-position: 0 -538px; } -.ui-state-default .btn-icon-plug-disconnect-prohibition_disabled { background-position: 0 -554px; } -.ui-state-default .btn-icon-preview { background-position: 0 -570px; } -.ui-state-default .btn-icon-preview_disabled { background-position: 0 -587px; } -.ui-state-default .btn-icon-settings { background-position: 0 -604px; } -.ui-state-default .btn-icon-settings_disabled { background-position: 0 -620px; } -.ui-state-default .btn-icon-unpublish { background-position: 0 -636px; } -.ui-state-default .btn-icon-unpublish_disabled { background-position: 0 -654px; } +.ui-state-default .btn-icon-back_disabled { background-position: 0 -136px; } +.ui-state-default .btn-icon-chain--arrow { background-position: 0 -151px; } +.ui-state-default .btn-icon-chain--exclamation { background-position: 0 -167px; } +.ui-state-default .btn-icon-chain--minus { background-position: 0 -183px; } +.ui-state-default .btn-icon-chain--pencil { background-position: 0 -199px; } +.ui-state-default .btn-icon-chain--plus { background-position: 0 -215px; } +.ui-state-default .btn-icon-chain-small { background-position: 0 -231px; } +.ui-state-default .btn-icon-chain-unchain { background-position: 0 -247px; } +.ui-state-default .btn-icon-chain { background-position: 0 -263px; } +.ui-state-default .btn-icon-cross-circle { background-position: 0 -279px; } +.ui-state-default .btn-icon-cross-circle_disabled { background-position: 0 -295px; } +.ui-state-default .btn-icon-decline { background-position: 0 -311px; } +.ui-state-default .btn-icon-decline_disabled { background-position: 0 -328px; } +.ui-state-default .btn-icon-download-csv { background-position: 0 -345px; } +.ui-state-default .btn-icon-drive-upload { background-position: 0 -363px; } +.ui-state-default .btn-icon-drive-upload_disabled { background-position: 0 -379px; } +.ui-state-default .btn-icon-magnifier { background-position: 0 -395px; } +.ui-state-default .btn-icon-minus-circle { background-position: 0 -411px; } +.ui-state-default .btn-icon-minus-circle_disabled { background-position: 0 -427px; } +.ui-state-default .btn-icon-navigation { background-position: 0 -443px; } +.ui-state-default .btn-icon-navigation_disabled { background-position: 0 -459px; } +.ui-state-default .btn-icon-network-cloud { background-position: 0 -475px; } +.ui-state-default .btn-icon-network-cloud_disabled { background-position: 0 -491px; } +.ui-state-default .btn-icon-pencil { background-position: 0 -507px; } +.ui-state-default .btn-icon-pencil_disabled { background-position: 0 -523px; } +.ui-state-default .btn-icon-plug-disconnect-prohibition { background-position: 0 -539px; } +.ui-state-default .btn-icon-plug-disconnect-prohibition_disabled { background-position: 0 -555px; } +.ui-state-default .btn-icon-preview { background-position: 0 -571px; } +.ui-state-default .btn-icon-preview_disabled { background-position: 0 -588px; } +.ui-state-default .btn-icon-settings { background-position: 0 -605px; } +.ui-state-default .btn-icon-settings_disabled { background-position: 0 -621px; } +.ui-state-default .btn-icon-unpublish { background-position: 0 -637px; } +.ui-state-default .btn-icon-unpublish_disabled { background-position: 0 -655px; } .icon { text-indent: -9999px; border: none; outline: none; } .icon.icon-24 { width: 24px; height: 24px; background: url('../images/menu-icons/24x24-s546fcae8fd.png'); } @@ -178,7 +178,7 @@ form.small .field input.text, form.small .field textarea, form.small .field sele .cms input.loading, .cms button.loading, .cms input.ui-state-default.loading, .cms .ui-widget-content input.ui-state-default.loading, .cms .ui-widget-header input.ui-state-default.loading { color: #525252; border-color: #d5d3d3; cursor: default; } .cms input.loading .ui-icon, .cms button.loading .ui-icon, .cms input.ui-state-default.loading .ui-icon, .cms .ui-widget-content input.ui-state-default.loading .ui-icon, .cms .ui-widget-header input.ui-state-default.loading .ui-icon { background: transparent url(../../images/network-save.gif) no-repeat 0 0; } .cms input.loading.ss-ui-action-constructive .ui-icon, .cms button.loading.ss-ui-action-constructive .ui-icon { background: transparent url(../../images/network-save-constructive.gif) no-repeat 0 0; } -.cms .ss-ui-button { font-weight: bold; text-decoration: none; line-height: 16px; color: #393939; border: 1px solid #c0c0c2; border-bottom: 1px solid #a6a6a9; cursor: pointer; text-shadow: white 0 1px 1px; background-color: #e6e6e6; background: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjUwJSIgeTE9IjAlIiB4Mj0iNTAlIiB5Mj0iMTAwJSI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIvPjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iI2Q5ZDlkOSIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JhZCkiIC8+PC9zdmc+IA=='); background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #ffffff), color-stop(100%, #d9d9d9)); background: -webkit-linear-gradient(#ffffff, #d9d9d9); background: -moz-linear-gradient(#ffffff, #d9d9d9); background: -o-linear-gradient(#ffffff, #d9d9d9); background: -ms-linear-gradient(#ffffff, #d9d9d9); background: linear-gradient(#ffffff, #d9d9d9); /* constructive */ /* destructive */ } +.cms .ss-ui-button { margin-top: 0px; font-weight: bold; text-decoration: none; line-height: 16px; color: #393939; border: 1px solid #c0c0c2; border-bottom: 1px solid #a6a6a9; cursor: pointer; text-shadow: white 0 1px 1px; background-color: #e6e6e6; background: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjUwJSIgeTE9IjAlIiB4Mj0iNTAlIiB5Mj0iMTAwJSI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIvPjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iI2Q5ZDlkOSIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JhZCkiIC8+PC9zdmc+IA=='); background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #ffffff), color-stop(100%, #d9d9d9)); background: -webkit-linear-gradient(#ffffff, #d9d9d9); background: -moz-linear-gradient(#ffffff, #d9d9d9); background: -o-linear-gradient(#ffffff, #d9d9d9); background: -ms-linear-gradient(#ffffff, #d9d9d9); background: linear-gradient(#ffffff, #d9d9d9); /* constructive */ /* destructive */ } .cms .ss-ui-button.buttonset { margin: 0 -1px; } .cms .ss-ui-button.ui-state-hover, .cms .ss-ui-button:hover { text-decoration: none; background-color: white; background: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjUwJSIgeTE9IjAlIiB4Mj0iNTAlIiB5Mj0iMTAwJSI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIvPjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iI2U2ZTZlNiIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JhZCkiIC8+PC9zdmc+IA=='); background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #ffffff), color-stop(100%, #e6e6e6)); background: -webkit-linear-gradient(#ffffff, #e6e6e6); background: -moz-linear-gradient(#ffffff, #e6e6e6); background: -o-linear-gradient(#ffffff, #e6e6e6); background: -ms-linear-gradient(#ffffff, #e6e6e6); background: linear-gradient(#ffffff, #e6e6e6); -moz-box-shadow: 0 0 5px #b3b3b3; -webkit-box-shadow: 0 0 5px #b3b3b3; -o-box-shadow: 0 0 5px #b3b3b3; box-shadow: 0 0 5px #b3b3b3; } .cms .ss-ui-button:active, .cms .ss-ui-button:focus, .cms .ss-ui-button.ui-state-active, .cms .ss-ui-button.ui-state-focus { border: 1px solid #b3b3b3; background-color: white; background: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjUwJSIgeTE9IjAlIiB4Mj0iNTAlIiB5Mj0iMTAwJSI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIvPjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iI2U2ZTZlNiIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JhZCkiIC8+PC9zdmc+IA=='); background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #ffffff), color-stop(100%, #e6e6e6)); background: -webkit-linear-gradient(#ffffff, #e6e6e6); background: -moz-linear-gradient(#ffffff, #e6e6e6); background: -o-linear-gradient(#ffffff, #e6e6e6); background: -ms-linear-gradient(#ffffff, #e6e6e6); background: linear-gradient(#ffffff, #e6e6e6); -moz-box-shadow: 0 0 5px #b3b3b3 inset; -webkit-box-shadow: 0 0 5px #b3b3b3 inset; -o-box-shadow: 0 0 5px #b3b3b3 inset; box-shadow: 0 0 5px #b3b3b3 inset; } @@ -256,13 +256,13 @@ body.cms { overflow: hidden; } .cms-content-header { padding: 0px 8px 8px; height: 32px; z-index: 60; background-image: url(../images/textures/cms_content_header.png); background-repeat: repeat; } .cms-content-header a { color: #1556b2; } .cms-content-header .backlink { float: left; margin-top: 7px; } -.cms-content-header .backlink span.btn-icon-back { height: 15px; } +.cms-content-header .backlink span.btn-icon-back { height: 16px; } .cms-content-header h2 { float: left; padding: 8px 8px 0 8px; font-size: 14px; line-height: 24px; font-weight: bold; text-shadow: #bfcad2 1px 1px 0; max-width: 400px; margin: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; o-text-overflow: ellipsis; } .cms-content-header > div { width: 9999em; overflow: hidden; } .cms-content-header .cms-content-header-tabs { position: fixed; right: 40px; } -.cms-content-header .cms-content-header-tabs .ui-tabs-nav li a { font-weight: bold; line-height: 16px; padding: 12px 20px 11px; } +.cms-content-header .cms-content-header-tabs .ui-tabs-nav li a { font-weight: bold; line-height: 16px; padding: 12px 20px 12px; } .cms-content-header .cms-content-header-tabs .ui-tabs-nav .ui-state-default, .cms-content-header .cms-content-header-tabs .ui-tabs-nav .ui-widget-content .ui-state-default, .cms-content-header .cms-content-header-tabs .ui-tabs-nav .ui-widget-header .ui-state-default { border-top: none; } -.cms-content-header .cms-content-header-tabs .ui-tabs-nav .ui-state-active, .cms-content-header .cms-content-header-tabs .ui-tabs-nav .ui-widget-content .ui-state-active, .cms-content-header .cms-content-header-tabs .ui-tabs-nav .ui-widget-header .ui-state-active { border-top: none; } +.cms-content-header .cms-content-header-tabs .ui-tabs-nav .ui-state-active, .cms-content-header .cms-content-header-tabs .ui-tabs-nav .ui-widget-content .ui-state-active, .cms-content-header .cms-content-header-tabs .ui-tabs-nav .ui-widget-header .ui-state-active { border-top: none; padding-bottom: 0px; } .cms-content-header .cms-content-header-tabs .ui-tabs-nav .ui-corner-all, .cms-content-header .cms-content-header-tabs .ui-tabs-nav .ui-corner-top, .cms-content-header .cms-content-header-tabs .ui-tabs-nav .ui-corner-right, .cms-content-header .cms-content-header-tabs .ui-tabs-nav .ui-corner-tr { border-radius: 0; } .cms-content-header .cms-content-header-tabs .ui-tabs-nav .ui-corner-all, .cms-content-header .cms-content-header-tabs .ui-tabs-nav .ui-corner-top, .cms-content-header .cms-content-header-tabs .ui-tabs-nav .ui-corner-left, .cms-content-header .cms-content-header-tabs .ui-tabs-nav .ui-corner-tl { border-radius: 0; } @@ -312,6 +312,9 @@ body.cms { overflow: hidden; } /** -------------------------------------------- "Add page" dialog -------------------------------------------- */ .cms-page-add-form-dialog { display: none; } +.cms-add-form .step-label .flyout { height: 17px; padding-top: 5px; } +.cms-add-form .step-label .title { padding-top: 5px; font-weight: bold; text-shadow: 1px 1px 0 white; } +.cms-add-form ul.SelectionGroup { padding-left: 28px; } .cms-add-form .parent-mode { padding: 8px; overflow: auto; } .cms-add-form #PageType li { float: none; width: 100%; padding: 9px 0 9px 15px; overflow: hidden; border-bottom-width: 2px; border-bottom: 2px groove rgba(255, 255, 255, 0.8); -webkit-border-image: url(../images/textures/bg_fieldset_elements_border.png) 2 stretch stretch; border-image: url(../images/textures/bg_fieldset_elements_border.png) 2 stretch stretch; } .cms-add-form #PageType li:last-child { border-bottom: none; } @@ -394,6 +397,12 @@ body.cms { overflow: hidden; } .cms-preview-header { background-color: #FFBE66; padding: 10px; font-weight: bold; } /** -------------------------------------------- Member Profile -------------------------------------------- */ +form.member-profile-form { padding: 0 16px 0 0; } +form.member-profile-form .ui-tabs-nav .ui-state-default, form.member-profile-form .ui-tabs-nav .ui-widget-content .ui-state-default, form.member-profile-form .ui-tabs-nav .ui-widget-header .ui-state-default { border-top: none; } +form.member-profile-form #Root_Permissions { clear: both; padding: 16px; } +form.member-profile-form #Root_Main { clear: both; padding: 16px; } +form.member-profile-form #Root_Main .cms-help-toggle { text-indent: -9999em; display: inline-block; width: 20px; background: url(../images/question.png) no-repeat 0px 0px; } +form.member-profile-form #FavouritePageID { margin-top: 8px; } form.member-profile-form #CsvFile .middleColumn { background: none !important; } form.member-profile-form .advanced h4 { margin-bottom: .5em; } form.member-profile-form .Actions { text-align: left; border: 0; } @@ -406,12 +415,15 @@ form.member-profile-form #Groups .middleColumn { margin-left: 0; width: 100%; } form.member-profile-form #Groups .middleColumn .TreeDropdownField { width: 90%; max-width: 90%; } form.member-profile-form #Permissions .optionset li { float: none; width: auto; } form.member-profile-form .ui-tabs-nav li { margin: 0 0 -1px 0; } -form.member-profile-form .ui-corner-all, form.member-profile-form .ui-corner-top, form.member-profile-form .ui-corner-right, form.member-profile-form .ui-corner-tr { border-radius: 0; } -form.member-profile-form .ui-corner-all, form.member-profile-form .ui-corner-top, form.member-profile-form .ui-corner-left, form.member-profile-form .ui-corner-tl { border-radius: 0; } +form.member-profile-form .ui-tabs-nav .ui-corner-all, form.member-profile-form .ui-tabs-nav .ui-corner-top, form.member-profile-form .ui-tabs-nav .ui-corner-right, form.member-profile-form .ui-tabs-nav .ui-corner-tr { border-radius: 0; } +form.member-profile-form .ui-tabs-nav .ui-corner-all, form.member-profile-form .ui-tabs-nav .ui-corner-top, form.member-profile-form .ui-tabs-nav .ui-corner-left, form.member-profile-form .ui-tabs-nav .ui-corner-tl { border-radius: 0; } .cms .cms-content { border-right: 1px solid rgba(201, 205, 206, 0.8); -moz-box-shadow: 3px 0 4px rgba(0, 0, 0, 0.15); -webkit-box-shadow: 3px 0 4px rgba(0, 0, 0, 0.15); -o-box-shadow: 3px 0 4px rgba(0, 0, 0, 0.15); box-shadow: 3px 0 4px rgba(0, 0, 0, 0.15); -moz-border-radius: 0; -webkit-border-radius: 0; -o-border-radius: 0; -ms-border-radius: 0; -khtml-border-radius: 0; border-radius: 0; } -.cms .cms-content-fields { /* always show a y scroll bar as popups like TreeDropdowns can trigger longer pages and the extra scroll bar doesn't fire our sizing bar */ overflow-y: auto; overflow-x: auto; background: none; width: 100%; } -.cms .cms-content-fields .aligned-right-label { margin-left: 184px; padding: 8px 0; } +.cms .cms-content-fields { overflow-y: auto; overflow-x: auto; background: none; width: 100%; } +.cms .cms-content-fields #Root_Main .confirmedpassword { border-bottom: none; box-shadow: none; } +.cms .cms-content-fields #Root_Main .customFormat { max-width: 80px; } +.cms .cms-content-fields #Root_Main .cms-help-toggle { text-indent: -9999em; display: inline-block; width: 20px; background: url(../images/question.png) no-repeat 0px 0px; } +.cms .cms-content-fields #Root_Permissions ul.optionset li { float: none; } /** -------------------------------------------- "Settings" Form -------------------------------------------- */ #CanViewType .optionset li, #CanEditType .optionset li, #CanCreateTopLevelType .optionset li { float: none; width: auto; white-space: nowrap; } @@ -450,6 +462,8 @@ form.member-profile-form .ui-corner-all, form.member-profile-form .ui-corner-top .cms .ui-widget-overlay { background-color: #000; background-image: none; } +.cms .ui-dialog .ss-ui-dialog.ui-dialog-content { padding-top: 0px; } + .ui-dialog { background: url("../images/textures/bg_cms_main_content.png") repeat left top #f0f3f4; border: 3px solid #000 !important; border-radius: 8px; overflow: visible; padding: 0; } .ui-dialog .ui-dialog-titlebar.ui-widget-header { font-size: 14px; background-color: #92a5b2; padding: 4px 4px 4px 16px; border-bottom: 2px solid #8399a7; background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjUwJSIgeTE9IjAlIiB4Mj0iNTAlIiB5Mj0iMTAwJSI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2NlZDdkYyIvPjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzkyYTViMiIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JhZCkiIC8+PC9zdmc+IA=='); background-size: 100%; background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #ced7dc), color-stop(100%, #92a5b2)); background-image: -webkit-linear-gradient(#ced7dc, #92a5b2); background-image: -moz-linear-gradient(#ced7dc, #92a5b2); background-image: -o-linear-gradient(#ced7dc, #92a5b2); background-image: -ms-linear-gradient(#ced7dc, #92a5b2); background-image: linear-gradient(#ced7dc, #92a5b2); } .ui-dialog.loading { background-image: url(../images/spinner.gif); background-position: 50% 50%; background-repeat: no-repeat; } @@ -461,7 +475,7 @@ body.cms-dialog { overflow: auto; background: url("../images/textures/bg_cms_mai .cms-dialog-content .ss-tabset { z-index: 60; -moz-border-radius: none; -webkit-border-radius: none; -o-border-radius: none; -ms-border-radius: none; -khtml-border-radius: none; border-radius: none; } .cms-dialog-content .ss-tabset .tab { background: none; overflow-y: auto; } .cms-dialog-content .ss-tabset.ui-tabs { background: none; } -.cms-dialog-content .ss-tabset.ui-tabs .ui-tabs-nav { padding: 8px 0 0 0; border: none; } +.cms-dialog-content .ss-tabset.ui-tabs .ui-tabs-nav { border: none; padding: 0 40px 0 0; float: right; } .cms-dialog-content .ss-tabset.ui-tabs .ui-tabs-nav li { font-weight: bold; line-height: 16px; padding: 11px 12px 9px; border-bottom: 2px solid #B3B3B3; } .cms-dialog-content .ss-tabset.ui-tabs .ui-tabs-nav li.ui-tabs-selected { margin-bottom: -1px; } .cms-dialog-content .ss-tabset.ui-tabs .ui-tabs-nav li:first-child { margin-left: 15px; } @@ -517,6 +531,9 @@ form.import-form ul li { margin-left: 20px; } form.import-form p { margin-bottom: 5px; } form.import-form label.left { width: 250px; } +/** -------------------------------------------- Page Edit Controller -------------------------------------------- */ +.cms-container .CMSMain.CMSPageEditController { margin-left: -1px; } + /** This file defines the jstree base styling (see http://jstree.com), as well as any customizations (see bottom of file). The styles are usually added through jstree.js on DOM load, but we need it earlier in order to correctly display the uninitialized tree. */ .cms .jstree ul, .TreeDropdownField .treedropdownfield-panel .jstree ul { display: block; margin: 0; padding: 0; background: none; list-style-type: none; } .cms .jstree li, .TreeDropdownField .treedropdownfield-panel .jstree li { display: block; margin: 0; padding: 0; list-style-type: none; display: block; min-height: 18px; line-height: 18px; white-space: nowrap; margin-left: 18px; min-width: 18px; } @@ -605,8 +622,8 @@ form.import-form label.left { width: 250px; } .tree-holder.jstree-apple li, .cms-tree.jstree-apple li { padding: 0px; clear: left; } .tree-holder.jstree-apple ins, .cms-tree.jstree-apple ins { background-color: transparent; background-image: url(../images/sitetree_ss_default_icons.png); } .tree-holder.jstree-apple li.jstree-checked > a, .tree-holder.jstree-apple li.jstree-checked > a:link, .cms-tree.jstree-apple li.jstree-checked > a, .cms-tree.jstree-apple li.jstree-checked > a:link { background-color: #efe999; } -.tree-holder.jstree-apple .jstree-closed > ins, .cms-tree.jstree-apple .jstree-closed > ins { background-position: 0 0; } -.tree-holder.jstree-apple .jstree-open > ins, .cms-tree.jstree-apple .jstree-open > ins { background-position: -20px 0; } +.tree-holder.jstree-apple .jstree-closed > ins, .cms-tree.jstree-apple .jstree-closed > ins { background-position: 0 0; cursor: pointer; } +.tree-holder.jstree-apple .jstree-open > ins, .cms-tree.jstree-apple .jstree-open > ins { background-position: -20px 0; cursor: pointer; } a .jstree-pageicon { display: block; float: left; width: 16px; height: 16px; margin-right: 4px; background-color: transparent; background-image: url(../images/sitetree_ss_pageclass_icons_default.png); background-repeat: no-repeat; } diff --git a/admin/images/btn-icon-sb5d07676ff.png b/admin/images/btn-icon-sb5d07676ff.png deleted file mode 100644 index 6e9b49a31..000000000 Binary files a/admin/images/btn-icon-sb5d07676ff.png and /dev/null differ diff --git a/admin/images/btn-icon-sc495ceeeca.png b/admin/images/btn-icon-sc495ceeeca.png new file mode 100644 index 000000000..7f27b0297 Binary files /dev/null and b/admin/images/btn-icon-sc495ceeeca.png differ diff --git a/admin/images/btn-icon/addpage.png b/admin/images/btn-icon/addpage.png index 3dae3ddcc..554433e84 100644 Binary files a/admin/images/btn-icon/addpage.png and b/admin/images/btn-icon/addpage.png differ diff --git a/admin/images/btn-icon/back.png b/admin/images/btn-icon/back.png old mode 100644 new mode 100755 index 019b175ca..e3f39762c Binary files a/admin/images/btn-icon/back.png and b/admin/images/btn-icon/back.png differ diff --git a/admin/images/question.png b/admin/images/question.png new file mode 100755 index 000000000..f51f15ba3 Binary files /dev/null and b/admin/images/question.png differ diff --git a/admin/javascript/LeftAndMain.Content.js b/admin/javascript/LeftAndMain.Content.js index 2852be827..fb6c8a391 100644 --- a/admin/javascript/LeftAndMain.Content.js +++ b/admin/javascript/LeftAndMain.Content.js @@ -142,6 +142,11 @@ var formData = form.serializeArray(); // add button action formData.push({name: $(button).attr('name'), value:'1'}); + // Artificial HTTP referer, IE doesn't submit them via ajax. + // Also rewrites anchors to their page counterparts, which is important + // as automatic browser ajax response redirects seem to discard the hash/fragment. + formData.push({name: 'BackURL', value:History.getPageUrl()}); + jQuery.ajax(jQuery.extend({ url: form.attr('action'), data: formData, @@ -159,12 +164,6 @@ self.submitForm_responseHandler(form, xmlhttp.responseText, status, xmlhttp, formData); } - // Simulates a redirect on an ajax response - just exchange the URL without re-requesting it - if(window.History.enabled) { - var url = xmlhttp.getResponseHeader('X-ControllerURL'); - if(url) window.history.replaceState({}, '', url); - } - // Re-init tabs (in case the form tag itself is a tabset) if(self.hasClass('ss-tabset')) self.removeClass('ss-tabset').addClass('ss-tabset'); @@ -287,7 +286,7 @@ var url = $(node).find('a:first').attr('href'); if(url && url != '#') { - if($(node).find('a:first').is(':internal')) url = url = $.path.makeUrlAbsolute(url, $('base').attr('href')); + if($.path.isExternal($(node).find('a:first'))) url = url = $.path.makeUrlAbsolute(url, $('base').attr('href')); // Reload only edit form if it exists (side-by-side view of tree and edit view), otherwise reload whole panel if(container.find('.cms-edit-form').length) { url += '?cms-view-form=1'; @@ -311,4 +310,4 @@ } }); -})(jQuery); \ No newline at end of file +})(jQuery); diff --git a/admin/javascript/LeftAndMain.Menu.js b/admin/javascript/LeftAndMain.Menu.js index aeb8226f1..7f6792d63 100644 --- a/admin/javascript/LeftAndMain.Menu.js +++ b/admin/javascript/LeftAndMain.Menu.js @@ -207,16 +207,16 @@ onclick: function(e) { // Only catch left clicks, in order to allow opening in tabs. // Ignore external links, fallback to standard link behaviour - if(e.which > 1 || this.is(':external')) return; + var isExternal = $.path.isExternal(this.attr('href')); + if(e.which > 1 || isExternal) return; e.preventDefault(); var item = this.getMenuItem(); var url = this.attr('href'); - if(this.is(':internal')) url = $('base').attr('href') + url; + if(!isExternal) url = $('base').attr('href') + url; var children = item.find('li'); - if(children.length) { children.first().find('a').click(); } else { @@ -261,8 +261,4 @@ }); }); - - // Internal Helper - $.expr[':'].internal = function(obj){return obj.href.match(/^mailto\:/) || (obj.hostname == location.hostname);}; - $.expr[':'].external = function(obj){return !$(obj).is(':internal');}; }(jQuery)); \ No newline at end of file diff --git a/admin/javascript/LeftAndMain.js b/admin/javascript/LeftAndMain.js index 340978ff1..ffdd578e6 100644 --- a/admin/javascript/LeftAndMain.js +++ b/admin/javascript/LeftAndMain.js @@ -18,12 +18,28 @@ jQuery.noConflict(); spinner.show(); }; + // apply an select element only when it is ready, ie. when it is rendered into a template + // with css applied and got a width value. + var applyChosen = function(el){ + if(el.outerWidth()){ + el.chosen().addClass("has-chzn"); + // Copy over title attribute if required + if(el.attr('title')) el.siblings('.chzn-container').attr('title', el.attr('title')); + } else { + setTimeout(function() {applyChosen(el);},500); + } + }; + $(window).bind('resize', positionLoadingSpinner).trigger('resize'); // global ajax error handlers $.ajaxSetup({ error: function(xmlhttp, status, error) { - var msg = (xmlhttp.getResponseHeader('X-Status')) ? xmlhttp.getResponseHeader('X-Status') : xmlhttp.statusText; + if(xmlhttp.status < 200 || xmlhttp.status > 399) { + var msg = (xmlhttp.getResponseHeader('X-Status')) ? xmlhttp.getResponseHeader('X-Status') : xmlhttp.statusText; + } else { + msg = error; + } statusMessage(msg, 'bad'); } }); @@ -72,7 +88,8 @@ jQuery.noConflict(); $('.cms-edit-form').live('reloadeditform', function(e, data) { // Simulates a redirect on an ajax response - just exchange the URL without re-requesting it - if(window.History.enabled) { + // Causes non-pushState browser to re-request the URL, so ignore for those. + if(window.History.enabled && !History.emulated.pushState) { var url = data.xmlhttp.getResponseHeader('X-ControllerURL'); if(url) window.history.replaceState({}, '', url); } @@ -207,12 +224,13 @@ jQuery.noConflict(); var layoutClasses = ['east', 'west', 'center', 'north', 'south']; var elemClasses = contentEl.attr('class'); - var origLayoutClasses = $.grep( - elemClasses.split(' '), - function(val) { - return ($.inArray(val, layoutClasses) >= 0); - } - ); + var origLayoutClasses = []; + if(elemClasses) { + origLayoutClasses = $.grep( + elemClasses.split(' '), + function(val) { return ($.inArray(val, layoutClasses) >= 0);} + ); + } newContentEl .removeClass(layoutClasses.join(' ')) @@ -233,12 +251,13 @@ jQuery.noConflict(); newContentEl.css('visibility', 'visible'); newContentEl.removeClass('loading'); - // Simulates a redirect on an ajax response - just exchange the URL without re-requesting it - if(window.History.enabled) { + // Simulates a redirect on an ajax response - just exchange the URL without re-requesting it. + // Causes non-pushState browser to re-request the URL, so ignore for those. + if(window.History.enabled && !History.emulated.pushState) { var url = xhr.getResponseHeader('X-ControllerURL'); - if(url) window.history.replaceState({}, '', url); + if(url) window.History.replaceState({}, '', url); } - + self.trigger('afterstatechange', {data: data, status: status, xhr: xhr, element: newContentEl}); }, error: function(xhr, status, e) { @@ -452,8 +471,8 @@ jQuery.noConflict(); // Explicitly disable default placeholder if no custom one is defined if(!this.data('placeholder')) this.data('placeholder', ' '); - // Apply chosen - this.chosen().addClass("has-chzn"); + // Apply Chosen + applyChosen(this); this._super(); } @@ -538,4 +557,4 @@ var statusMessage = function(text, type) { var errorMessage = function(text) { jQuery.noticeAdd({text: text, type: 'error'}); -}; \ No newline at end of file +}; diff --git a/admin/javascript/ModelAdmin.js b/admin/javascript/ModelAdmin.js index a5b8a9b37..306c584e1 100644 --- a/admin/javascript/ModelAdmin.js +++ b/admin/javascript/ModelAdmin.js @@ -4,6 +4,13 @@ (function($) { $.entwine('ss', function($){ + $('#cms-content-tools #Form_SearchForm').entwine({ + onsubmit: function(e) { + //We need to trigger handleStateChange() explicitly, otherwise handleStageChange() + //doesn't called if landing from another section of cms + this.trigger('beforeSubmit'); + } + }); /** * Class: .importSpec @@ -21,6 +28,5 @@ this._super(); } }); - }); })(jQuery); \ No newline at end of file diff --git a/admin/javascript/lib.js b/admin/javascript/lib.js index 6df032e0c..c6437cc7e 100644 --- a/admin/javascript/lib.js +++ b/admin/javascript/lib.js @@ -232,8 +232,4 @@ }; $.path = path; - - // Internal Helper - $.expr[':'].internal = function(obj){return obj.href.match(/^mailto\:/) || (obj.hostname == location.hostname);}; - $.expr[':'].external = function(obj){return !$(obj).is(':internal')}; }(jQuery)); \ No newline at end of file diff --git a/admin/scss/_forms.scss b/admin/scss/_forms.scss index 641431145..520dd5292 100644 --- a/admin/scss/_forms.scss +++ b/admin/scss/_forms.scss @@ -275,7 +275,7 @@ form.small .field, .field.small { } .ss-ui-button { - + margin-top:0px; &.buttonset { margin: 0 -1px; // hack to avoid double borders } diff --git a/admin/scss/_style.scss b/admin/scss/_style.scss index dce375150..77c6f9a06 100644 --- a/admin/scss/_style.scss +++ b/admin/scss/_style.scss @@ -100,7 +100,7 @@ body.cms { float:left; margin-top:$grid-x - 1; span.btn-icon-back { - height:15px; + height:16px; } } @@ -129,7 +129,7 @@ body.cms { a { font-weight: bold; line-height: $grid-y * 2; - padding: ($grid-y * 2 - 4) ($grid-x * 2 + 4) $grid-y + 3; + padding: $grid-y*1.5 $grid-x*2.5 $grid-y*1.5; } } @@ -147,6 +147,7 @@ body.cms { border: { top:none; } + padding-bottom:0px; } .ui-corner-all, .ui-corner-top, .ui-corner-right, .ui-corner-tr { border-radius:0; @@ -407,6 +408,20 @@ body.cms { } .cms-add-form { + .step-label { + .flyout { + height:17px; //centres number within the grey arrow + padding-top:5px; + } + .title { + padding-top:5px; //aligns label with point of arrow + font-weight:bold; //to match pagetype label + @include text-shadow(1px 1px 0 $color-text-shadow); + } + } + ul.SelectionGroup { + padding-left:28px; + } .parent-mode { padding: $grid-x; overflow: auto; @@ -822,7 +837,37 @@ body.cms { * -------------------------------------------- */ form.member-profile-form { - + padding: 0 $grid-x*2 0 0; + .ui-tabs-nav { + .ui-state-default, + .ui-widget-content .ui-state-default, + .ui-widget-header .ui-state-default { + border: { + top:none; + } + } + } + + #Root_Permissions { + clear:both; + padding: $grid-x*2; + } + + #Root_Main { + clear:both; + padding: $grid-x*2; + .cms-help-toggle { + text-indent: -9999em; + display: inline-block; + width: 20px; + background:url(../images/question.png) no-repeat 0px 0px; + } + } + + #FavouritePageID { + margin-top:$grid-y; + } + #CsvFile .middleColumn { background: none !important; } @@ -888,13 +933,13 @@ form.member-profile-form { li { margin:0 0 -1px 0; } - } - .ui-corner-all, .ui-corner-top, .ui-corner-right, .ui-corner-tr { - border-radius:0; - } + .ui-corner-all, .ui-corner-top, .ui-corner-right, .ui-corner-tr { + border-radius:0; + } - .ui-corner-all, .ui-corner-top, .ui-corner-left, .ui-corner-tl { - border-radius:0; + .ui-corner-all, .ui-corner-top, .ui-corner-left, .ui-corner-tl { + border-radius:0; + } } } @@ -907,17 +952,32 @@ form.member-profile-form { } .cms-content-fields { - /* always show a y scroll bar as popups like TreeDropdowns - can trigger longer pages and the extra scroll bar doesn't - fire our sizing bar */ + // always show a y scroll bar as popups like TreeDropdowns + // can trigger longer pages and the extra scroll bar doesn't fire our sizing bar overflow-y: auto; overflow-x: auto; background: none; width:100%; - .aligned-right-label { - margin-left:$grid-x*23; - padding:$grid-x 0; + #Root_Main { + .confirmedpassword { + border-bottom:none; + box-shadow:none; + } + .customFormat { + max-width:80px; + } + .cms-help-toggle { + text-indent: -9999em; + display: inline-block; + width: 20px; + background:url(../images/question.png) no-repeat 0px 0px; + } } + #Root_Permissions{ + ul.optionset li { + float:none; + } + } } } @@ -1092,6 +1152,10 @@ form.member-profile-form { background-image: none; } +.cms .ui-dialog .ss-ui-dialog.ui-dialog-content { + padding-top: 0px; //removes padding so that tabs are flush with header +} + // Elements with this class can either frame inline markup or an iframe, // most styles should be applied to .cms-dialog instead (which declares the content in the frame) .ui-dialog { @@ -1147,8 +1211,9 @@ body.cms-dialog { background: none; .ui-tabs-nav { - padding: $grid-x 0 0 0; border: none; + padding: 0 $grid-x*5 0 0; //allows for 40px gap to the right of tabs to match the tabs on main CMS + float: right; li { &.ui-tabs-selected { @@ -1391,5 +1456,14 @@ form.import-form { label.left { width: 250px; } + } +/** -------------------------------------------- + * Page Edit Controller + * -------------------------------------------- */ + +.cms-container .CMSMain.CMSPageEditController { + // Fix pixel gap between nav tree and main page header + margin-left:-1px; +} diff --git a/admin/scss/_tree.scss b/admin/scss/_tree.scss index aa6f6cad8..00b48c807 100644 --- a/admin/scss/_tree.scss +++ b/admin/scss/_tree.scss @@ -24,8 +24,14 @@ min-height: 18px; line-height: 18px; white-space: nowrap; - margin-left: 18px; min-width: 18px; + + li { + margin: 0; + } + li li { + margin-left: 10px; + } } ins { display: inline-block; @@ -240,7 +246,7 @@ } li.jstree-open > ul { display: block; - margin-left:-13px; + li ul { margin-left:2px; } @@ -535,11 +541,13 @@ } & .jstree-closed > ins { - background-position:0 0; + background-position:0 0; + cursor:pointer; } & .jstree-open > ins { - background-position:-20px 0; + background-position:-20px 0; + cursor:pointer; } } diff --git a/admin/scss/ie7.scss b/admin/scss/ie7.scss index b25afb383..1f7e9b434 100644 --- a/admin/scss/ie7.scss +++ b/admin/scss/ie7.scss @@ -68,10 +68,16 @@ html { text-indent: 0px !important; } -//fix for filter and reset icons on datagrid - -.cms table.ss-gridfield-table tr th.extra span input { - height:23px; +.cms table.ss-gridfield-table { + tbody td { + // Overrule width: 100% setting to trigger "shrink fit" + // of button row, which IE7 doesn't support + width: auto; + } + tr th.extra span input { + //fix for filter and reset icons on datagrid + height:23px; + } } .ss-gridfield-button-filter.ss-ui-button { diff --git a/admin/scss/themes/_default.scss b/admin/scss/themes/_default.scss index 82285412c..cab053679 100644 --- a/admin/scss/themes/_default.scss +++ b/admin/scss/themes/_default.scss @@ -7,69 +7,69 @@ /** ----------------------------------------------- * Colours * ------------------------------------------------ */ -$color-base: #b0bec7; -$color-widget-bg: lighten($color-base, 20%); +$color-base: #b0bec7 !default; +$color-widget-bg: lighten($color-base, 20%) !default; -$color-dark-bg: #003050; -$color-dark-separator: #19435c; -$color-medium-separator: #808080; -$color-light-separator: rgba(201, 205, 206, 0.8); +$color-dark-bg: #003050 !default; +$color-dark-separator: #19435c !default; +$color-medium-separator: #808080 !default; +$color-light-separator: rgba(201, 205, 206, 0.8) !default; -$color-tab: #d9d9d9; -$color-dark-grey: #7B8C91; +$color-tab: #d9d9d9 !default; +$color-dark-grey: #7B8C91 !default; -$color-shadow-light: rgba(201, 205, 206, 0.8); -$color-shadow-dark: rgba(107, 120, 123, 0.5); +$color-shadow-light: rgba(201, 205, 206, 0.8) !default; +$color-shadow-dark: rgba(107, 120, 123, 0.5) !default; -$color-highlight: #FFFF66; -$color-highlight-opacity: rgba(255, 255, 102, 0.3); +$color-highlight: #FFFF66 !default; +$color-highlight-opacity: rgba(255, 255, 102, 0.3) !default; -$color-menu-button: #338DC1; -$color-menu-background: #c6d7df; -$color-menu-border: #8c99a1; +$color-menu-button: #338DC1 !default; +$color-menu-background: #c6d7df !default; +$color-menu-border: #8c99a1 !default; -$color-text: #444; -$color-text-light: white; -$color-text-light-link: white; -$color-text-disabled: #aaa; -$color-text-dark: #1f1f1f; -$color-text-dark-link: #3EBAE0; -$color-text-blue-link:#1556B2; -$color-text-shadow: white; +$color-text: #444 !default; +$color-text-light: white !default; +$color-text-light-link: white !default; +$color-text-disabled: #aaa !default; +$color-text-dark: #1f1f1f !default; +$color-text-dark-link: #3EBAE0 !default; +$color-text-blue-link:#1556B2 !default; +$color-text-shadow: white !default; -$color-button-generic: #e6e6e6; -$color-button-generic-border: #c0c0c2; +$color-button-generic: #e6e6e6 !default; +$color-button-generic-border: #c0c0c2 !default; -$color-button-highlight: #e6e6e6; -$color-button-highlight-border: #708284; +$color-button-highlight: #e6e6e6 !default; +$color-button-highlight-border: #708284 !default; -$color-button-constructive: #669933; -$color-button-constructive-border: #78a127; +$color-button-constructive: #669933 !default; +$color-button-constructive-border: #78a127 !default; -$color-button-destructive: #f00; +$color-button-destructive: #f00 !default; -$color-button-disabled: #eeeded; +$color-button-disabled: #eeeded !default; -$color-warning: #FF9300; -$color-error: #FF9300; -$color-notice: #FF9300; -$color-good: $color-button-constructive; +$color-warning: #FF9300 !default; +$color-error: #FF9300 !default; +$color-notice: #FF9300 !default; +$color-good: $color-button-constructive !default; -$color-cms-batchactions-menu-background: #f5f5f5; -$color-cms-batchactions-menu-selected-background: #efe999; +$color-cms-batchactions-menu-background: #f5f5f5 !default; +$color-cms-batchactions-menu-selected-background: #efe999 !default; /** ----------------------------------------------- * Textures * ----------------------------------------------- */ -$tab-panel-texture-color: #f0f3f4; -$tab-panel-texture-background: $tab-panel-texture-color url(../images/textures/bg_cms_main_content.png) repeat top left; +$tab-panel-texture-color: #f0f3f4 !default; +$tab-panel-texture-background: $tab-panel-texture-color url(../images/textures/bg_cms_main_content.png) repeat top left !default; /** ----------------------------------------------- * Typography. * ------------------------------------------------ */ -$font-family: Arial, sans-serif; -$font-base-size: 12px; +$font-family: Arial, sans-serif !default; +$font-base-size: 12px !default; /** ----------------------------------------------- * Grid Units (px) @@ -78,10 +78,10 @@ $font-base-size: 12px; * both x (=horizontal) and y (=vertical). All internal padding and * margins are scaled to this and accounting for paragraphs * ------------------------------------------------ */ -$grid-y: 8px; -$grid-x: 8px; +$grid-y: 8px !default; +$grid-x: 8px !default; /** ----------------------------------------------- * Application Logo (CMS Logo) Must be 24px x 24px * ------------------------------------------------ */ -$application-logo-small: url("../images/logo_small.png"); +$application-logo-small: url("../images/logo_small.png") !default; diff --git a/admin/templates/Includes/LeftAndMain_Menu.ss b/admin/templates/Includes/LeftAndMain_Menu.ss index 9e5abf2f1..45b5d6cb9 100644 --- a/admin/templates/Includes/LeftAndMain_Menu.ss +++ b/admin/templates/Includes/LeftAndMain_Menu.ss @@ -58,7 +58,7 @@ diff --git a/admin/thirdparty/chosen/.piston.yml b/admin/thirdparty/chosen/.piston.yml index 65c32c6f1..a9041863d 100644 --- a/admin/thirdparty/chosen/.piston.yml +++ b/admin/thirdparty/chosen/.piston.yml @@ -1,7 +1,7 @@ --- format: 1 handler: - commit: 880a30dcb49555996a875cf4474999a2341aa055 + commit: f584bc49d6de7cf68475c3e51baa4cf2008a130e branch: master lock: false repository_class: Piston::Git::Repository diff --git a/admin/thirdparty/chosen/VERSION b/admin/thirdparty/chosen/VERSION index c81aa44af..e3e180701 100644 --- a/admin/thirdparty/chosen/VERSION +++ b/admin/thirdparty/chosen/VERSION @@ -1 +1 @@ -0.9.7 +0.9.8 diff --git a/admin/thirdparty/chosen/chosen/chosen-sprite.png b/admin/thirdparty/chosen/chosen/chosen-sprite.png index 231fe9055..113dc9885 100644 Binary files a/admin/thirdparty/chosen/chosen/chosen-sprite.png and b/admin/thirdparty/chosen/chosen/chosen-sprite.png differ diff --git a/admin/thirdparty/chosen/chosen/chosen.css b/admin/thirdparty/chosen/chosen/chosen.css index a90506fd6..36abf3412 100644 --- a/admin/thirdparty/chosen/chosen/chosen.css +++ b/admin/thirdparty/chosen/chosen/chosen.css @@ -51,6 +51,9 @@ color: #444444; text-decoration: none; } +.chzn-container-single .chzn-default { + color: #999; +} .chzn-container-single .chzn-single span { margin-right: 26px; display: block; @@ -68,7 +71,7 @@ width: 12px; height: 13px; font-size: 1px; - background: url(chosen-sprite.png) right top no-repeat; + background: url('chosen-sprite.png') right top no-repeat; } .chzn-container-single .chzn-single abbr:hover { background-position: right -11px; @@ -206,7 +209,7 @@ width: 12px; height: 13px; font-size: 1px; - background: url(chosen-sprite.png) right top no-repeat; + background: url('chosen-sprite.png') right top no-repeat; } .chzn-container-multi .chzn-choices .search-choice .search-choice-close:hover { background-position: right -11px; diff --git a/admin/thirdparty/chosen/chosen/chosen.jquery.js b/admin/thirdparty/chosen/chosen/chosen.jquery.js index bb3c1ee4e..52959dfb3 100644 --- a/admin/thirdparty/chosen/chosen/chosen.jquery.js +++ b/admin/thirdparty/chosen/chosen/chosen.jquery.js @@ -1,5 +1,15 @@ -//based on version 0.9.7 and applied a very simple patch that fix percentaage width support on select tag -//the patch has been documented https://github.com/harvesthq/chosen/issues/300. +// Chosen, a Select Box Enhancer for jQuery and Protoype +// by Patrick Filler for Harvest, http://getharvest.com +// +// Version 0.9.8 +// Full source at https://github.com/harvesthq/chosen +// Copyright (c) 2011 Harvest http://getharvest.com + +// MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md +// This file is generated by `cake build`, do not edit it by hand. + +// based on version 0.9.7, applied a very simple patch that fix percentaage width support on select tag +// the patch has been documented https://github.com/harvesthq/chosen/issues/300. (function() { var SelectParser; @@ -123,6 +133,7 @@ Copyright (c) 2011 by Harvest this.result_single_selected = null; this.allow_single_deselect = (this.options.allow_single_deselect != null) && (this.form_field.options[0] != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false; this.disable_search_threshold = this.options.disable_search_threshold || 0; + this.search_contains = this.options.search_contains || false; this.choices = 0; return this.results_none_found = this.options.no_results_text || "No results match"; }; @@ -303,7 +314,7 @@ Copyright (c) 2011 by Harvest if (this.is_multiple) { container_div.html('
'); } else { - container_div.html('' + this.default_text + '
'); + container_div.html('' + this.default_text + '
'); } this.form_field_jq.hide().after(container_div); this.container = $('#' + this.container_id); @@ -411,7 +422,9 @@ Copyright (c) 2011 by Harvest var target_closelink; if (!this.is_disabled) { target_closelink = evt != null ? ($(evt.target)).hasClass("search-choice-close") : false; - if (evt && evt.type === "mousedown") evt.stopPropagation(); + if (evt && evt.type === "mousedown" && !this.results_showing) { + evt.stopPropagation(); + } if (!this.pending_destroy_click && !target_closelink) { if (!this.active_field) { if (this.is_multiple) this.search_field.val(""); @@ -498,7 +511,7 @@ Copyright (c) 2011 by Harvest if (data.selected && this.is_multiple) { this.choice_build(data); } else if (data.selected && !this.is_multiple) { - this.selected_item.find("span").text(data.text); + this.selected_item.removeClass("chzn-default").find("span").text(data.text); if (this.allow_single_deselect) this.single_deselect_control_build(); } } @@ -544,7 +557,8 @@ Copyright (c) 2011 by Harvest }; Chosen.prototype.results_show = function() { - var dd_top; + //patch applied: https://github.com/harvesthq/chosen/issues/300, add variable declaration dd_width + var dd_top, dd_width; if (!this.is_multiple) { this.selected_item.addClass("chzn-single-with-drop"); if (this.result_single_selected) { @@ -552,6 +566,8 @@ Copyright (c) 2011 by Harvest } } dd_top = this.is_multiple ? this.container.height() : this.container.height() - 1; + //patch applied: https://github.com/harvesthq/chosen/issues/300, add variable assignment dd_width + dd_width = this.container.width() - get_side_border_padding(this.dropdown); this.dropdown.css({ "top": dd_top + "px", "left": 0 @@ -662,6 +678,7 @@ Copyright (c) 2011 by Harvest Chosen.prototype.results_reset = function(evt) { this.form_field.options[0].selected = true; this.selected_item.find("span").text(this.default_text); + if (!this.is_multiple) this.selected_item.addClass("chzn-default"); this.show_search_field_default(); $(evt.target).remove(); this.form_field_jq.trigger("change"); @@ -679,6 +696,7 @@ Copyright (c) 2011 by Harvest } else { this.search_results.find(".result-selected").removeClass("result-selected"); this.result_single_selected = high; + this.selected_item.removeClass("chzn-default"); } high.addClass("result-selected"); position = high_id.substr(high_id.lastIndexOf("_") + 1); @@ -726,11 +744,12 @@ Copyright (c) 2011 by Harvest }; Chosen.prototype.winnow_results = function() { - var found, option, part, parts, regex, result, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len2, _ref; + var found, option, part, parts, regex, regexAnchor, result, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len2, _ref; this.no_results_clear(); results = 0; searchText = this.search_field.val() === this.default_text ? "" : $('
').text($.trim(this.search_field.val())).html(); - regex = new RegExp('^' + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i'); + regexAnchor = this.search_contains ? "" : "^"; + regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i'); zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i'); _ref = this.results_data; for (_i = 0, _len = _ref.length; _i < _len; _i++) { diff --git a/admin/thirdparty/chosen/chosen/chosen.jquery.min.js b/admin/thirdparty/chosen/chosen/chosen.jquery.min.js index 930fb9a50..9e4d23e70 100644 --- a/admin/thirdparty/chosen/chosen/chosen.jquery.min.js +++ b/admin/thirdparty/chosen/chosen/chosen.jquery.min.js @@ -1,10 +1,11 @@ // Chosen, a Select Box Enhancer for jQuery and Protoype // by Patrick Filler for Harvest, http://getharvest.com // -// Version 0.9.7 +// Version 0.9.8 // Full source at https://github.com/harvesthq/chosen // Copyright (c) 2011 Harvest http://getharvest.com // MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md // This file is generated by `cake build`, do not edit it by hand. -((function(){var a;a=function(){function a(){this.options_index=0,this.parsed=[]}return a.prototype.add_node=function(a){return a.nodeName==="OPTGROUP"?this.add_group(a):this.add_option(a)},a.prototype.add_group=function(a){var b,c,d,e,f,g;b=this.parsed.length,this.parsed.push({array_index:b,group:!0,label:a.label,children:0,disabled:a.disabled}),f=a.childNodes,g=[];for(d=0,e=f.length;d"+a.html+"")},a.prototype.results_update_field=function(){return this.result_clear_highlight(),this.result_single_selected=null,this.results_build()},a.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},a.prototype.results_search=function(a){return this.results_showing?this.winnow_results():this.results_show()},a.prototype.keyup_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale();switch(b){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices>0)return this.keydown_backstroke();if(!this.pending_backstroke)return this.result_clear_highlight(),this.results_search();break;case 13:a.preventDefault();if(this.results_showing)return this.result_select(a);break;case 27:return this.results_showing&&this.results_hide(),!0;case 9:case 38:case 40:case 16:case 91:case 17:break;default:return this.results_search()}},a.prototype.generate_field_id=function(){var a;return a=this.generate_random_id(),this.form_field.id=a,a},a.prototype.generate_random_char=function(){var a,b,c;return a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ",c=Math.floor(Math.random()*a.length),b=a.substring(c,c+1)},a}(),b.AbstractChosen=a}.call(this),function(){var a,b,c,d,e=Object.prototype.hasOwnProperty,f=function(a,b){function d(){this.constructor=a}for(var c in b)e.call(b,c)&&(a[c]=b[c]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};d=this,a=jQuery,a.fn.extend({chosen:function(c){return!a.browser.msie||a.browser.version!=="6.0"&&a.browser.version!=="7.0"?a(this).each(function(d){if(!a(this).hasClass("chzn-done"))return new b(this,c)}):this}}),b=function(b){function e(){e.__super__.constructor.apply(this,arguments)}return f(e,b),e.prototype.setup=function(){return this.form_field_jq=a(this.form_field),this.is_rtl=this.form_field_jq.hasClass("chzn-rtl")},e.prototype.finish_setup=function(){return this.form_field_jq.addClass("chzn-done")},e.prototype.set_up_html=function(){var b,d,e,f;return this.container_id=this.form_field.id.length?this.form_field.id.replace(/(:|\.)/g,"_"):this.generate_field_id(),this.container_id+="_chzn",this.f_width=this.form_field_jq.outerWidth(),this.default_text=this.form_field_jq.data("placeholder")?this.form_field_jq.data("placeholder"):this.default_text_default,b=a("
",{id:this.container_id,"class":"chzn-container"+(this.is_rtl?" chzn-rtl":""),style:"width: "+this.f_width+"px;"}),this.is_multiple?b.html('
    '):b.html(''+this.default_text+'
      '),this.form_field_jq.hide().after(b),this.container=a("#"+this.container_id),this.container.addClass("chzn-container-"+(this.is_multiple?"multi":"single")),this.dropdown=this.container.find("div.chzn-drop").first(),d=this.container.height(),e=this.f_width-c(this.dropdown),this.dropdown.css({width:e+"px",top:d+"px"}),this.search_field=this.container.find("input").first(),this.search_results=this.container.find("ul.chzn-results").first(),this.search_field_scale(),this.search_no_results=this.container.find("li.no-results").first(),this.is_multiple?(this.search_choices=this.container.find("ul.chzn-choices").first(),this.search_container=this.container.find("li.search-field").first()):(this.search_container=this.container.find("div.chzn-search").first(),this.selected_item=this.container.find(".chzn-single").first(),f=e-c(this.search_container)-c(this.search_field),this.search_field.css({width:f+"px"})),this.results_build(),this.set_tab_index(),this.form_field_jq.trigger("liszt:ready",{chosen:this})},e.prototype.register_observers=function(){var a=this;return this.container.mousedown(function(b){return a.container_mousedown(b)}),this.container.mouseup(function(b){return a.container_mouseup(b)}),this.container.mouseenter(function(b){return a.mouse_enter(b)}),this.container.mouseleave(function(b){return a.mouse_leave(b)}),this.search_results.mouseup(function(b){return a.search_results_mouseup(b)}),this.search_results.mouseover(function(b){return a.search_results_mouseover(b)}),this.search_results.mouseout(function(b){return a.search_results_mouseout(b)}),this.form_field_jq.bind("liszt:updated",function(b){return a.results_update_field(b)}),this.search_field.blur(function(b){return a.input_blur(b)}),this.search_field.keyup(function(b){return a.keyup_checker(b)}),this.search_field.keydown(function(b){return a.keydown_checker(b)}),this.is_multiple?(this.search_choices.click(function(b){return a.choices_click(b)}),this.search_field.focus(function(b){return a.input_focus(b)})):this.container.click(function(a){return a.preventDefault()})},e.prototype.search_field_disabled=function(){this.is_disabled=this.form_field_jq[0].disabled;if(this.is_disabled)return this.container.addClass("chzn-disabled"),this.search_field[0].disabled=!0,this.is_multiple||this.selected_item.unbind("focus",this.activate_action),this.close_field();this.container.removeClass("chzn-disabled"),this.search_field[0].disabled=!1;if(!this.is_multiple)return this.selected_item.bind("focus",this.activate_action)},e.prototype.container_mousedown=function(b){var c;if(!this.is_disabled)return c=b!=null?a(b.target).hasClass("search-choice-close"):!1,b&&b.type==="mousedown"&&b.stopPropagation(),!this.pending_destroy_click&&!c?(this.active_field?!this.is_multiple&&b&&(a(b.target)[0]===this.selected_item[0]||a(b.target).parents("a.chzn-single").length)&&(b.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),a(document).click(this.click_test_action),this.results_show()),this.activate_field()):this.pending_destroy_click=!1},e.prototype.container_mouseup=function(a){if(a.target.nodeName==="ABBR")return this.results_reset(a)},e.prototype.blur_test=function(a){if(!this.active_field&&this.container.hasClass("chzn-container-active"))return this.close_field()},e.prototype.close_field=function(){return a(document).unbind("click",this.click_test_action),this.is_multiple||(this.selected_item.attr("tabindex",this.search_field.attr("tabindex")),this.search_field.attr("tabindex",-1)),this.active_field=!1,this.results_hide(),this.container.removeClass("chzn-container-active"),this.winnow_results_clear(),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale()},e.prototype.activate_field=function(){return!this.is_multiple&&!this.active_field&&(this.search_field.attr("tabindex",this.selected_item.attr("tabindex")),this.selected_item.attr("tabindex",-1)),this.container.addClass("chzn-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.focus()},e.prototype.test_active_click=function(b){return a(b.target).parents("#"+this.container_id).length?this.active_field=!0:this.close_field()},e.prototype.results_build=function(){var a,b,c,e,f;this.parsing=!0,this.results_data=d.SelectParser.select_to_array(this.form_field),this.is_multiple&&this.choices>0?(this.search_choices.find("li.search-choice").remove(),this.choices=0):this.is_multiple||(this.selected_item.find("span").text(this.default_text),this.form_field.options.length<=this.disable_search_threshold?this.container.addClass("chzn-container-single-nosearch"):this.container.removeClass("chzn-container-single-nosearch")),a="",f=this.results_data;for(c=0,e=f.length;c'+a("
      ").text(b.label).html()+"")},e.prototype.result_do_highlight=function(a){var b,c,d,e,f;if(a.length){this.result_clear_highlight(),this.result_highlight=a,this.result_highlight.addClass("highlighted"),d=parseInt(this.search_results.css("maxHeight"),10),f=this.search_results.scrollTop(),e=d+f,c=this.result_highlight.position().top+this.search_results.scrollTop(),b=c+this.result_highlight.outerHeight();if(b>=e)return this.search_results.scrollTop(b-d>0?b-d:0);if(c'+b.html+''),d=a("#"+c).find("a").first(),d.click(function(a){return e.choice_destroy_link_click(a)})},e.prototype.choice_destroy_link_click=function(b){return b.preventDefault(),this.is_disabled?b.stopPropagation:(this.pending_destroy_click=!0,this.choice_destroy(a(b.target)))},e.prototype.choice_destroy=function(a){return this.choices-=1,this.show_search_field_default(),this.is_multiple&&this.choices>0&&this.search_field.val().length<1&&this.results_hide(),this.result_deselect(a.attr("rel")),a.parents("li").first().remove()},e.prototype.results_reset=function(b){this.form_field.options[0].selected=!0,this.selected_item.find("span").text(this.default_text),this.show_search_field_default(),a(b.target).remove(),this.form_field_jq.trigger("change");if(this.active_field)return this.results_hide()},e.prototype.result_select=function(a){var b,c,d,e;if(this.result_highlight)return b=this.result_highlight,c=b.attr("id"),this.result_clear_highlight(),this.is_multiple?this.result_deactivate(b):(this.search_results.find(".result-selected").removeClass("result-selected"),this.result_single_selected=b),b.addClass("result-selected"),e=c.substr(c.lastIndexOf("_")+1),d=this.results_data[e],d.selected=!0,this.form_field.options[d.options_index].selected=!0,this.is_multiple?this.choice_build(d):(this.selected_item.find("span").first().text(d.text),this.allow_single_deselect&&this.single_deselect_control_build()),(!a.metaKey||!this.is_multiple)&&this.results_hide(),this.search_field.val(""),this.form_field_jq.trigger("change"),this.search_field_scale()},e.prototype.result_activate=function(a){return a.addClass("active-result")},e.prototype.result_deactivate=function(a){return a.removeClass("active-result")},e.prototype.result_deselect=function(b){var c,d;return d=this.results_data[b],d.selected=!1,this.form_field.options[d.options_index].selected=!1,c=a("#"+this.container_id+"_o_"+b),c.removeClass("result-selected").addClass("active-result").show(),this.result_clear_highlight(),this.winnow_results(),this.form_field_jq.trigger("change"),this.search_field_scale()},e.prototype.single_deselect_control_build=function(){if(this.allow_single_deselect&&this.selected_item.find("abbr").length<1)return this.selected_item.find("span").first().after('')},e.prototype.winnow_results=function(){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;this.no_results_clear(),i=0,j=this.search_field.val()===this.default_text?"":a("
      ").text(a.trim(this.search_field.val())).html(),f=new RegExp("^"+j.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),m=new RegExp(j.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),r=this.results_data;for(n=0,p=r.length;n=0||c.html.indexOf("[")===0){e=c.html.replace(/\[|\]/g,"").split(" ");if(e.length)for(o=0,q=e.length;o"+c.html.substr(k+j.length),l=l.substr(0,k)+""+l.substr(k)):l=c.html,g.html(l),this.result_activate(g),c.group_array_index!=null&&a("#"+this.results_data[c.group_array_index].dom_id).css("display","list-item")):(this.result_highlight&&h===this.result_highlight.attr("id")&&this.result_clear_highlight(),this.result_deactivate(g))}}return i<1&&j.length?this.no_results(j):this.winnow_results_set_highlight()},e.prototype.winnow_results_clear=function(){var b,c,d,e,f;this.search_field.val(""),c=this.search_results.find("li"),f=[];for(d=0,e=c.length;d'+this.results_none_found+' ""'),c.find("span").first().html(b),this.search_results.append(c)},e.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},e.prototype.keydown_arrow=function(){var b,c;this.result_highlight?this.results_showing&&(c=this.result_highlight.nextAll("li.active-result").first(),c&&this.result_do_highlight(c)):(b=this.search_results.find("li.active-result").first(),b&&this.result_do_highlight(a(b)));if(!this.results_showing)return this.results_show()},e.prototype.keyup_arrow=function(){var a;if(!this.results_showing&&!this.is_multiple)return this.results_show();if(this.result_highlight)return a=this.result_highlight.prevAll("li.active-result"),a.length?this.result_do_highlight(a.first()):(this.choices>0&&this.results_hide(),this.result_clear_highlight())},e.prototype.keydown_backstroke=function(){return this.pending_backstroke?(this.choice_destroy(this.pending_backstroke.find("a").first()),this.clear_backstroke()):(this.pending_backstroke=this.search_container.siblings("li.search-choice").last(),this.pending_backstroke.addClass("search-choice-focus"))},e.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus"),this.pending_backstroke=null},e.prototype.keydown_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale(),b!==8&&this.pending_backstroke&&this.clear_backstroke();switch(b){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(a),this.mouse_on_container=!1;break;case 13:a.preventDefault();break;case 38:a.preventDefault(),this.keyup_arrow();break;case 40:this.keydown_arrow()}},e.prototype.search_field_scale=function(){var b,c,d,e,f,g,h,i,j;if(this.is_multiple){d=0,h=0,f="position:absolute; left: -1000px; top: -1000px; display:none;",g=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"];for(i=0,j=g.length;i",{style:f}),c.text(this.search_field.val()),a("body").append(c),h=c.width()+25,c.remove(),h>this.f_width-10&&(h=this.f_width-10),this.search_field.css({width:h+"px"}),b=this.container.height(),this.dropdown.css({top:b+"px"})}},e.prototype.generate_random_id=function(){var b;b="sel"+this.generate_random_char()+this.generate_random_char()+this.generate_random_char();while(a("#"+b).length>0)b+=this.generate_random_char();return b},e}(AbstractChosen),c=function(a){var b;return b=a.outerWidth()-a.width()},d.get_side_border_padding=c}.call(this) \ No newline at end of file +((function(){var a;a=function(){function a(){this.options_index=0,this.parsed=[]}return a.prototype.add_node=function(a){return a.nodeName==="OPTGROUP"?this.add_group(a):this.add_option(a)},a.prototype.add_group=function(a){var b,c,d,e,f,g;b=this.parsed.length,this.parsed.push({array_index:b,group:!0,label:a.label,children:0,disabled:a.disabled}),f=a.childNodes,g=[];for(d=0,e=f.length;d"+a.html+"")},a.prototype.results_update_field=function(){return this.result_clear_highlight(),this.result_single_selected=null,this.results_build()},a.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},a.prototype.results_search=function(a){return this.results_showing?this.winnow_results():this.results_show()},a.prototype.keyup_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale();switch(b){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices>0)return this.keydown_backstroke();if(!this.pending_backstroke)return this.result_clear_highlight(),this.results_search();break;case 13:a.preventDefault();if(this.results_showing)return this.result_select(a);break;case 27:return this.results_showing&&this.results_hide(),!0;case 9:case 38:case 40:case 16:case 91:case 17:break;default:return this.results_search()}},a.prototype.generate_field_id=function(){var a;return a=this.generate_random_id(),this.form_field.id=a,a},a.prototype.generate_random_char=function(){var a,b,c;return a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ",c=Math.floor(Math.random()*a.length),b=a.substring(c,c+1)},a}(),b.AbstractChosen=a}.call(this),function(){var a,b,c,d,e=Object.prototype.hasOwnProperty,f=function(a,b){function d(){this.constructor=a}for(var c in b)e.call(b,c)&&(a[c]=b[c]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};d=this,a=jQuery,a.fn.extend({chosen:function(c){return!a.browser.msie||a.browser.version!=="6.0"&&a.browser.version!=="7.0"?a(this).each(function(d){if(!a(this).hasClass("chzn-done"))return new b(this,c)}):this}}),b=function(b){function e(){e.__super__.constructor.apply(this,arguments)}return f(e,b),e.prototype.setup=function(){return this.form_field_jq=a(this.form_field),this.is_rtl=this.form_field_jq.hasClass("chzn-rtl")},e.prototype.finish_setup=function(){return this.form_field_jq.addClass("chzn-done")},e.prototype.set_up_html=function(){var b,d,e,f;return this.container_id=this.form_field.id.length?this.form_field.id.replace(/(:|\.)/g,"_"):this.generate_field_id(),this.container_id+="_chzn",this.f_width=this.form_field_jq.outerWidth(),this.default_text=this.form_field_jq.data("placeholder")?this.form_field_jq.data("placeholder"):this.default_text_default,b=a("
      ",{id:this.container_id,"class":"chzn-container"+(this.is_rtl?" chzn-rtl":""),style:"width: "+this.f_width+"px;"}),this.is_multiple?b.html('
        '):b.html(''+this.default_text+'
          '),this.form_field_jq.hide().after(b),this.container=a("#"+this.container_id),this.container.addClass("chzn-container-"+(this.is_multiple?"multi":"single")),this.dropdown=this.container.find("div.chzn-drop").first(),d=this.container.height(),e=this.f_width-c(this.dropdown),this.dropdown.css({width:e+"px",top:d+"px"}),this.search_field=this.container.find("input").first(),this.search_results=this.container.find("ul.chzn-results").first(),this.search_field_scale(),this.search_no_results=this.container.find("li.no-results").first(),this.is_multiple?(this.search_choices=this.container.find("ul.chzn-choices").first(),this.search_container=this.container.find("li.search-field").first()):(this.search_container=this.container.find("div.chzn-search").first(),this.selected_item=this.container.find(".chzn-single").first(),f=e-c(this.search_container)-c(this.search_field),this.search_field.css({width:f+"px"})),this.results_build(),this.set_tab_index(),this.form_field_jq.trigger("liszt:ready",{chosen:this})},e.prototype.register_observers=function(){var a=this;return this.container.mousedown(function(b){return a.container_mousedown(b)}),this.container.mouseup(function(b){return a.container_mouseup(b)}),this.container.mouseenter(function(b){return a.mouse_enter(b)}),this.container.mouseleave(function(b){return a.mouse_leave(b)}),this.search_results.mouseup(function(b){return a.search_results_mouseup(b)}),this.search_results.mouseover(function(b){return a.search_results_mouseover(b)}),this.search_results.mouseout(function(b){return a.search_results_mouseout(b)}),this.form_field_jq.bind("liszt:updated",function(b){return a.results_update_field(b)}),this.search_field.blur(function(b){return a.input_blur(b)}),this.search_field.keyup(function(b){return a.keyup_checker(b)}),this.search_field.keydown(function(b){return a.keydown_checker(b)}),this.is_multiple?(this.search_choices.click(function(b){return a.choices_click(b)}),this.search_field.focus(function(b){return a.input_focus(b)})):this.container.click(function(a){return a.preventDefault()})},e.prototype.search_field_disabled=function(){this.is_disabled=this.form_field_jq[0].disabled;if(this.is_disabled)return this.container.addClass("chzn-disabled"),this.search_field[0].disabled=!0,this.is_multiple||this.selected_item.unbind("focus",this.activate_action),this.close_field();this.container.removeClass("chzn-disabled"),this.search_field[0].disabled=!1;if(!this.is_multiple)return this.selected_item.bind("focus",this.activate_action)},e.prototype.container_mousedown=function(b){var c;if(!this.is_disabled)return c=b!=null?a(b.target).hasClass("search-choice-close"):!1,b&&b.type==="mousedown"&&!this.results_showing&&b.stopPropagation(),!this.pending_destroy_click&&!c?(this.active_field?!this.is_multiple&&b&&(a(b.target)[0]===this.selected_item[0]||a(b.target).parents("a.chzn-single").length)&&(b.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),a(document).click(this.click_test_action),this.results_show()),this.activate_field()):this.pending_destroy_click=!1},e.prototype.container_mouseup=function(a){if(a.target.nodeName==="ABBR")return this.results_reset(a)},e.prototype.blur_test=function(a){if(!this.active_field&&this.container.hasClass("chzn-container-active"))return this.close_field()},e.prototype.close_field=function(){return a(document).unbind("click",this.click_test_action),this.is_multiple||(this.selected_item.attr("tabindex",this.search_field.attr("tabindex")),this.search_field.attr("tabindex",-1)),this.active_field=!1,this.results_hide(),this.container.removeClass("chzn-container-active"),this.winnow_results_clear(),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale()},e.prototype.activate_field=function(){return!this.is_multiple&&!this.active_field&&(this.search_field.attr("tabindex",this.selected_item.attr("tabindex")),this.selected_item.attr("tabindex",-1)),this.container.addClass("chzn-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.focus()},e.prototype.test_active_click=function(b){return a(b.target).parents("#"+this.container_id).length?this.active_field=!0:this.close_field()},e.prototype.results_build=function(){var a,b,c,e,f;this.parsing=!0,this.results_data=d.SelectParser.select_to_array(this.form_field),this.is_multiple&&this.choices>0?(this.search_choices.find("li.search-choice").remove(),this.choices=0):this.is_multiple||(this.selected_item.find("span").text(this.default_text),this.form_field.options.length<=this.disable_search_threshold?this.container.addClass("chzn-container-single-nosearch"):this.container.removeClass("chzn-container-single-nosearch")),a="",f=this.results_data;for(c=0,e=f.length;c'+a("
          ").text(b.label).html()+"")},e.prototype.result_do_highlight=function(a){var b,c,d,e,f;if(a.length){this.result_clear_highlight(),this.result_highlight=a,this.result_highlight.addClass("highlighted"),d=parseInt(this.search_results.css("maxHeight"),10),f=this.search_results.scrollTop(),e=d+f,c=this.result_highlight.position().top+this.search_results.scrollTop(),b=c+this.result_highlight.outerHeight();if(b>=e)return this.search_results.scrollTop(b-d>0?b-d:0);if(c'+b.html+''),d=a("#"+c).find("a").first(),d.click(function(a){return e.choice_destroy_link_click(a)})},e.prototype.choice_destroy_link_click=function(b){return b.preventDefault(),this.is_disabled?b.stopPropagation:(this.pending_destroy_click=!0,this.choice_destroy(a(b.target)))},e.prototype.choice_destroy=function(a){return this.choices-=1,this.show_search_field_default(),this.is_multiple&&this.choices>0&&this.search_field.val().length<1&&this.results_hide(),this.result_deselect(a.attr("rel")),a.parents("li").first().remove()},e.prototype.results_reset=function(b){this.form_field.options[0].selected=!0,this.selected_item.find("span").text(this.default_text),this.is_multiple||this.selected_item.addClass("chzn-default"),this.show_search_field_default(),a(b.target).remove(),this.form_field_jq.trigger("change");if(this.active_field)return this.results_hide()},e.prototype.result_select=function(a){var b,c,d,e;if(this.result_highlight)return b=this.result_highlight,c=b.attr("id"),this.result_clear_highlight(),this.is_multiple?this.result_deactivate(b):(this.search_results.find(".result-selected").removeClass("result-selected"),this.result_single_selected=b,this.selected_item.removeClass("chzn-default")),b.addClass("result-selected"),e=c.substr(c.lastIndexOf("_")+1),d=this.results_data[e],d.selected=!0,this.form_field.options[d.options_index].selected=!0,this.is_multiple?this.choice_build(d):(this.selected_item.find("span").first().text(d.text),this.allow_single_deselect&&this.single_deselect_control_build()),(!a.metaKey||!this.is_multiple)&&this.results_hide(),this.search_field.val(""),this.form_field_jq.trigger("change"),this.search_field_scale()},e.prototype.result_activate=function(a){return a.addClass("active-result")},e.prototype.result_deactivate=function(a){return a.removeClass("active-result")},e.prototype.result_deselect=function(b){var c,d;return d=this.results_data[b],d.selected=!1,this.form_field.options[d.options_index].selected=!1,c=a("#"+this.container_id+"_o_"+b),c.removeClass("result-selected").addClass("active-result").show(),this.result_clear_highlight(),this.winnow_results(),this.form_field_jq.trigger("change"),this.search_field_scale()},e.prototype.single_deselect_control_build=function(){if(this.allow_single_deselect&&this.selected_item.find("abbr").length<1)return this.selected_item.find("span").first().after('')},e.prototype.winnow_results=function(){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;this.no_results_clear(),j=0,k=this.search_field.val()===this.default_text?"":a("
          ").text(a.trim(this.search_field.val())).html(),g=this.search_contains?"":"^",f=new RegExp(g+k.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),n=new RegExp(k.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),s=this.results_data;for(o=0,q=s.length;o=0||c.html.indexOf("[")===0){e=c.html.replace(/\[|\]/g,"").split(" ");if(e.length)for(p=0,r=e.length;p"+c.html.substr(l+k.length),m=m.substr(0,l)+""+m.substr(l)):m=c.html,h.html(m),this.result_activate(h),c.group_array_index!=null&&a("#"+this.results_data[c.group_array_index].dom_id).css("display","list-item")):(this.result_highlight&&i===this.result_highlight.attr("id")&&this.result_clear_highlight(),this.result_deactivate(h))}}return j<1&&k.length?this.no_results(k):this.winnow_results_set_highlight()},e.prototype.winnow_results_clear=function(){var b,c,d,e,f;this.search_field.val(""),c=this.search_results.find("li"),f=[];for(d=0,e=c.length;d'+this.results_none_found+' ""'),c.find("span").first().html(b),this.search_results.append(c)},e.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},e.prototype.keydown_arrow=function(){var b,c;this.result_highlight?this.results_showing&&(c=this.result_highlight.nextAll("li.active-result").first(),c&&this.result_do_highlight(c)):(b=this.search_results.find("li.active-result").first(),b&&this.result_do_highlight(a(b)));if(!this.results_showing)return this.results_show()},e.prototype.keyup_arrow=function(){var a;if(!this.results_showing&&!this.is_multiple)return this.results_show();if(this.result_highlight)return a=this.result_highlight.prevAll("li.active-result"),a.length?this.result_do_highlight(a.first()):(this.choices>0&&this.results_hide(),this.result_clear_highlight())},e.prototype.keydown_backstroke=function(){return this.pending_backstroke?(this.choice_destroy(this.pending_backstroke.find("a").first()),this.clear_backstroke()):(this.pending_backstroke=this.search_container.siblings("li.search-choice").last(),this.pending_backstroke.addClass("search-choice-focus"))},e.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus"),this.pending_backstroke=null},e.prototype.keydown_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale(),b!==8&&this.pending_backstroke&&this.clear_backstroke();switch(b){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(a),this.mouse_on_container=!1;break;case 13:a.preventDefault();break;case 38:a.preventDefault(),this.keyup_arrow();break;case 40:this.keydown_arrow()}},e.prototype.search_field_scale=function(){var b,c,d,e,f,g,h,i,j;if(this.is_multiple){d=0,h=0,f="position:absolute; left: -1000px; top: -1000px; display:none;",g=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"];for(i=0,j=g.length;i",{style:f}),c.text(this.search_field.val()),a("body").append(c),h=c.width()+25,c.remove(),h>this.f_width-10&&(h=this.f_width-10),this.search_field.css({width:h+"px"}),b=this.container.height(),this.dropdown.css({top:b+"px"})}},e.prototype.generate_random_id=function(){var b;b="sel"+this.generate_random_char()+this.generate_random_char()+this.generate_random_char();while(a("#"+b).length>0)b+=this.generate_random_char();return b},e}(AbstractChosen),c=function(a){var b;return b=a.outerWidth()-a.width()},d.get_side_border_padding=c}.call(this) + diff --git a/admin/thirdparty/chosen/chosen/chosen.proto.js b/admin/thirdparty/chosen/chosen/chosen.proto.js index e141a6924..0cbad475a 100644 --- a/admin/thirdparty/chosen/chosen/chosen.proto.js +++ b/admin/thirdparty/chosen/chosen/chosen.proto.js @@ -1,7 +1,7 @@ // Chosen, a Select Box Enhancer for jQuery and Protoype // by Patrick Filler for Harvest, http://getharvest.com // -// Version 0.9.7 +// Version 0.9.8 // Full source at https://github.com/harvesthq/chosen // Copyright (c) 2011 Harvest http://getharvest.com @@ -129,6 +129,7 @@ Copyright (c) 2011 by Harvest this.result_single_selected = null; this.allow_single_deselect = (this.options.allow_single_deselect != null) && (this.form_field.options[0] != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false; this.disable_search_threshold = this.options.disable_search_threshold || 0; + this.search_contains = this.options.search_contains || false; this.choices = 0; return this.results_none_found = this.options.no_results_text || "No results match"; }; @@ -281,7 +282,7 @@ Copyright (c) 2011 by Harvest Chosen.prototype.set_default_values = function() { Chosen.__super__.set_default_values.call(this); - this.single_temp = new Template('#{default}
            '); + this.single_temp = new Template('#{default}
              '); this.multi_temp = new Template('
                '); this.choice_temp = new Template('
              • #{choice}
              • '); return this.no_results_temp = new Template('
              • ' + this.results_none_found + ' "#{terms}"
              • '); @@ -407,7 +408,7 @@ Copyright (c) 2011 by Harvest var target_closelink; if (!this.is_disabled) { target_closelink = evt != null ? evt.target.hasClassName("search-choice-close") : false; - if (evt && evt.type === "mousedown") evt.stop(); + if (evt && evt.type === "mousedown" && !this.results_showing) evt.stop(); if (!this.pending_destroy_click && !target_closelink) { if (!this.active_field) { if (this.is_multiple) this.search_field.clear(); @@ -493,7 +494,7 @@ Copyright (c) 2011 by Harvest if (data.selected && this.is_multiple) { this.choice_build(data); } else if (data.selected && !this.is_multiple) { - this.selected_item.down("span").update(data.html); + this.selected_item.removeClassName("chzn-default").down("span").update(data.html); if (this.allow_single_deselect) this.single_deselect_control_build(); } } @@ -659,6 +660,7 @@ Copyright (c) 2011 by Harvest Chosen.prototype.results_reset = function(evt) { this.form_field.options[0].selected = true; this.selected_item.down("span").update(this.default_text); + if (!this.is_multiple) this.selected_item.addClassName("chzn-default"); this.show_search_field_default(); evt.target.remove(); if (typeof Event.simulate === 'function') this.form_field.simulate("change"); @@ -674,6 +676,7 @@ Copyright (c) 2011 by Harvest this.result_deactivate(high); } else { this.search_results.descendants(".result-selected").invoke("removeClassName", "result-selected"); + this.selected_item.removeClassName("chzn-default"); this.result_single_selected = high; } high.addClassName("result-selected"); @@ -726,11 +729,12 @@ Copyright (c) 2011 by Harvest }; Chosen.prototype.winnow_results = function() { - var found, option, part, parts, regex, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len2, _ref; + var found, option, part, parts, regex, regexAnchor, result_id, results, searchText, startpos, text, zregex, _i, _j, _len, _len2, _ref; this.no_results_clear(); results = 0; searchText = this.search_field.value === this.default_text ? "" : this.search_field.value.strip().escapeHTML(); - regex = new RegExp('^' + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i'); + regexAnchor = this.search_contains ? "" : "^"; + regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i'); zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i'); _ref = this.results_data; for (_i = 0, _len = _ref.length; _i < _len; _i++) { diff --git a/admin/thirdparty/chosen/chosen/chosen.proto.min.js b/admin/thirdparty/chosen/chosen/chosen.proto.min.js index 8e80774f1..0f8257239 100644 --- a/admin/thirdparty/chosen/chosen/chosen.proto.min.js +++ b/admin/thirdparty/chosen/chosen/chosen.proto.min.js @@ -1,10 +1,10 @@ // Chosen, a Select Box Enhancer for jQuery and Protoype // by Patrick Filler for Harvest, http://getharvest.com // -// Version 0.9.7 +// Version 0.9.8 // Full source at https://github.com/harvesthq/chosen // Copyright (c) 2011 Harvest http://getharvest.com // MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md // This file is generated by `cake build`, do not edit it by hand. -((function(){var a;a=function(){function a(){this.options_index=0,this.parsed=[]}return a.prototype.add_node=function(a){return a.nodeName==="OPTGROUP"?this.add_group(a):this.add_option(a)},a.prototype.add_group=function(a){var b,c,d,e,f,g;b=this.parsed.length,this.parsed.push({array_index:b,group:!0,label:a.label,children:0,disabled:a.disabled}),f=a.childNodes,g=[];for(d=0,e=f.length;d"+a.html+"")},a.prototype.results_update_field=function(){return this.result_clear_highlight(),this.result_single_selected=null,this.results_build()},a.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},a.prototype.results_search=function(a){return this.results_showing?this.winnow_results():this.results_show()},a.prototype.keyup_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale();switch(b){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices>0)return this.keydown_backstroke();if(!this.pending_backstroke)return this.result_clear_highlight(),this.results_search();break;case 13:a.preventDefault();if(this.results_showing)return this.result_select(a);break;case 27:return this.results_showing&&this.results_hide(),!0;case 9:case 38:case 40:case 16:case 91:case 17:break;default:return this.results_search()}},a.prototype.generate_field_id=function(){var a;return a=this.generate_random_id(),this.form_field.id=a,a},a.prototype.generate_random_char=function(){var a,b,c;return a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ",c=Math.floor(Math.random()*a.length),b=a.substring(c,c+1)},a}(),b.AbstractChosen=a}.call(this),function(){var a,b,c,d=Object.prototype.hasOwnProperty,e=function(a,b){function e(){this.constructor=a}for(var c in b)d.call(b,c)&&(a[c]=b[c]);return e.prototype=b.prototype,a.prototype=new e,a.__super__=b.prototype,a};c=this,a=function(a){function d(){d.__super__.constructor.apply(this,arguments)}return e(d,a),d.prototype.setup=function(){return this.is_rtl=this.form_field.hasClassName("chzn-rtl")},d.prototype.finish_setup=function(){return this.form_field.addClassName("chzn-done")},d.prototype.set_default_values=function(){return d.__super__.set_default_values.call(this),this.single_temp=new Template('#{default}
                  '),this.multi_temp=new Template('
                    '),this.choice_temp=new Template('
                  • #{choice}
                  • '),this.no_results_temp=new Template('
                  • '+this.results_none_found+' "#{terms}"
                  • ')},d.prototype.set_up_html=function(){var a,c,d,e,f;return this.container_id=this.form_field.identify().replace(/(:|\.)/g,"_")+"_chzn",this.f_width=this.form_field.getStyle("width")?parseInt(this.form_field.getStyle("width"),10):this.form_field.getWidth(),c={id:this.container_id,"class":"chzn-container"+(this.is_rtl?" chzn-rtl":""),style:"width: "+this.f_width+"px"},this.default_text=this.form_field.readAttribute("data-placeholder")?this.form_field.readAttribute("data-placeholder"):this.default_text_default,a=this.is_multiple?(new Element("div",c)).update(this.multi_temp.evaluate({"default":this.default_text})):(new Element("div",c)).update(this.single_temp.evaluate({"default":this.default_text})),this.form_field.hide().insert({after:a}),this.container=$(this.container_id),this.container.addClassName("chzn-container-"+(this.is_multiple?"multi":"single")),this.dropdown=this.container.down("div.chzn-drop"),d=this.container.getHeight(),e=this.f_width-b(this.dropdown),this.dropdown.setStyle({width:e+"px",top:d+"px"}),this.search_field=this.container.down("input"),this.search_results=this.container.down("ul.chzn-results"),this.search_field_scale(),this.search_no_results=this.container.down("li.no-results"),this.is_multiple?(this.search_choices=this.container.down("ul.chzn-choices"),this.search_container=this.container.down("li.search-field")):(this.search_container=this.container.down("div.chzn-search"),this.selected_item=this.container.down(".chzn-single"),f=e-b(this.search_container)-b(this.search_field),this.search_field.setStyle({width:f+"px"})),this.results_build(),this.set_tab_index(),this.form_field.fire("liszt:ready",{chosen:this})},d.prototype.register_observers=function(){var a=this;return this.container.observe("mousedown",function(b){return a.container_mousedown(b)}),this.container.observe("mouseup",function(b){return a.container_mouseup(b)}),this.container.observe("mouseenter",function(b){return a.mouse_enter(b)}),this.container.observe("mouseleave",function(b){return a.mouse_leave(b)}),this.search_results.observe("mouseup",function(b){return a.search_results_mouseup(b)}),this.search_results.observe("mouseover",function(b){return a.search_results_mouseover(b)}),this.search_results.observe("mouseout",function(b){return a.search_results_mouseout(b)}),this.form_field.observe("liszt:updated",function(b){return a.results_update_field(b)}),this.search_field.observe("blur",function(b){return a.input_blur(b)}),this.search_field.observe("keyup",function(b){return a.keyup_checker(b)}),this.search_field.observe("keydown",function(b){return a.keydown_checker(b)}),this.is_multiple?(this.search_choices.observe("click",function(b){return a.choices_click(b)}),this.search_field.observe("focus",function(b){return a.input_focus(b)})):this.container.observe("click",function(a){return a.preventDefault()})},d.prototype.search_field_disabled=function(){this.is_disabled=this.form_field.disabled;if(this.is_disabled)return this.container.addClassName("chzn-disabled"),this.search_field.disabled=!0,this.is_multiple||this.selected_item.stopObserving("focus",this.activate_action),this.close_field();this.container.removeClassName("chzn-disabled"),this.search_field.disabled=!1;if(!this.is_multiple)return this.selected_item.observe("focus",this.activate_action)},d.prototype.container_mousedown=function(a){var b;if(!this.is_disabled)return b=a!=null?a.target.hasClassName("search-choice-close"):!1,a&&a.type==="mousedown"&&a.stop(),!this.pending_destroy_click&&!b?(this.active_field?!this.is_multiple&&a&&(a.target===this.selected_item||a.target.up("a.chzn-single"))&&this.results_toggle():(this.is_multiple&&this.search_field.clear(),document.observe("click",this.click_test_action),this.results_show()),this.activate_field()):this.pending_destroy_click=!1},d.prototype.container_mouseup=function(a){if(a.target.nodeName==="ABBR")return this.results_reset(a)},d.prototype.blur_test=function(a){if(!this.active_field&&this.container.hasClassName("chzn-container-active"))return this.close_field()},d.prototype.close_field=function(){return document.stopObserving("click",this.click_test_action),this.is_multiple||(this.selected_item.tabIndex=this.search_field.tabIndex,this.search_field.tabIndex=-1),this.active_field=!1,this.results_hide(),this.container.removeClassName("chzn-container-active"),this.winnow_results_clear(),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale()},d.prototype.activate_field=function(){return!this.is_multiple&&!this.active_field&&(this.search_field.tabIndex=this.selected_item.tabIndex,this.selected_item.tabIndex=-1),this.container.addClassName("chzn-container-active"),this.active_field=!0,this.search_field.value=this.search_field.value,this.search_field.focus()},d.prototype.test_active_click=function(a){return a.target.up("#"+this.container_id)?this.active_field=!0:this.close_field()},d.prototype.results_build=function(){var a,b,d,e,f;this.parsing=!0,this.results_data=c.SelectParser.select_to_array(this.form_field),this.is_multiple&&this.choices>0?(this.search_choices.select("li.search-choice").invoke("remove"),this.choices=0):this.is_multiple||(this.selected_item.down("span").update(this.default_text),this.form_field.options.length<=this.disable_search_threshold?this.container.addClassName("chzn-container-single-nosearch"):this.container.removeClassName("chzn-container-single-nosearch")),a="",f=this.results_data;for(d=0,e=f.length;d'+a.label.escapeHTML()+"")},d.prototype.result_do_highlight=function(a){var b,c,d,e,f;this.result_clear_highlight(),this.result_highlight=a,this.result_highlight.addClassName("highlighted"),d=parseInt(this.search_results.getStyle("maxHeight"),10),f=this.search_results.scrollTop,e=d+f,c=this.result_highlight.positionedOffset().top,b=c+this.result_highlight.getHeight();if(b>=e)return this.search_results.scrollTop=b-d>0?b-d:0;if(c0&&this.search_field.value.length<1&&this.results_hide(),this.result_deselect(a.readAttribute("rel")),a.up("li").remove()},d.prototype.results_reset=function(a){this.form_field.options[0].selected=!0,this.selected_item.down("span").update(this.default_text),this.show_search_field_default(),a.target.remove(),typeof Event.simulate=="function"&&this.form_field.simulate("change");if(this.active_field)return this.results_hide()},d.prototype.result_select=function(a){var b,c,d;if(this.result_highlight)return b=this.result_highlight,this.result_clear_highlight(),this.is_multiple?this.result_deactivate(b):(this.search_results.descendants(".result-selected").invoke("removeClassName","result-selected"),this.result_single_selected=b),b.addClassName("result-selected"),d=b.id.substr(b.id.lastIndexOf("_")+1),c=this.results_data[d],c.selected=!0,this.form_field.options[c.options_index].selected=!0,this.is_multiple?this.choice_build(c):(this.selected_item.down("span").update(c.html),this.allow_single_deselect&&this.single_deselect_control_build()),(!a.metaKey||!this.is_multiple)&&this.results_hide(),this.search_field.value="",typeof Event.simulate=="function"&&this.form_field.simulate("change"),this.search_field_scale()},d.prototype.result_activate=function(a){return a.addClassName("active-result")},d.prototype.result_deactivate=function(a){return a.removeClassName("active-result")},d.prototype.result_deselect=function(a){var b,c;return c=this.results_data[a],c.selected=!1,this.form_field.options[c.options_index].selected=!1,b=$(this.container_id+"_o_"+a),b.removeClassName("result-selected").addClassName("active-result").show(),this.result_clear_highlight(),this.winnow_results(),typeof Event.simulate=="function"&&this.form_field.simulate("change"),this.search_field_scale()},d.prototype.single_deselect_control_build=function(){if(this.allow_single_deselect&&!this.selected_item.down("abbr"))return this.selected_item.down("span").insert({after:''})},d.prototype.winnow_results=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p;this.no_results_clear(),g=0,h=this.search_field.value===this.default_text?"":this.search_field.value.strip().escapeHTML(),e=new RegExp("^"+h.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),k=new RegExp(h.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),p=this.results_data;for(l=0,n=p.length;l=0||b.html.indexOf("[")===0){d=b.html.replace(/\[|\]/g,"").split(" ");if(d.length)for(m=0,o=d.length;m"+b.html.substr(i+h.length),j=j.substr(0,i)+""+j.substr(i)):j=b.html,$(f).innerHTML!==j&&$(f).update(j),this.result_activate($(f)),b.group_array_index!=null&&$(this.results_data[b.group_array_index].dom_id).setStyle({display:"list-item"})):($(f)===this.result_highlight&&this.result_clear_highlight(),this.result_deactivate($(f)))}}return g<1&&h.length?this.no_results(h):this.winnow_results_set_highlight()},d.prototype.winnow_results_clear=function(){var a,b,c,d,e;this.search_field.clear(),b=this.search_results.select("li"),e=[];for(c=0,d=b.length;c0&&this.results_hide(),this.result_clear_highlight())},d.prototype.keydown_backstroke=function(){return this.pending_backstroke?(this.choice_destroy(this.pending_backstroke.down("a")),this.clear_backstroke()):(this.pending_backstroke=this.search_container.siblings("li.search-choice").last(),this.pending_backstroke.addClassName("search-choice-focus"))},d.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClassName("search-choice-focus"),this.pending_backstroke=null},d.prototype.keydown_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale(),b!==8&&this.pending_backstroke&&this.clear_backstroke();switch(b){case 8:this.backstroke_length=this.search_field.value.length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(a),this.mouse_on_container=!1;break;case 13:a.preventDefault();break;case 38:a.preventDefault(),this.keyup_arrow();break;case 40:this.keydown_arrow()}},d.prototype.search_field_scale=function(){var a,b,c,d,e,f,g,h,i;if(this.is_multiple){c=0,g=0,e="position:absolute; left: -1000px; top: -1000px; display:none;",f=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"];for(h=0,i=f.length;hthis.f_width-10&&(g=this.f_width-10),this.search_field.setStyle({width:g+"px"}),a=this.container.getHeight(),this.dropdown.setStyle({top:a+"px"})}},d}(AbstractChosen),c.Chosen=a,Prototype.Browser.IE&&/MSIE (\d+\.\d+);/.test(navigator.userAgent)&&(Prototype.BrowserFeatures.Version=new Number(RegExp.$1)),b=function(a){var b,c;return b=new Element.Layout(a),c=b.get("border-left")+b.get("border-right")+b.get("padding-left")+b.get("padding-right")},c.get_side_border_padding=b}.call(this) \ No newline at end of file +((function(){var a;a=function(){function a(){this.options_index=0,this.parsed=[]}return a.prototype.add_node=function(a){return a.nodeName==="OPTGROUP"?this.add_group(a):this.add_option(a)},a.prototype.add_group=function(a){var b,c,d,e,f,g;b=this.parsed.length,this.parsed.push({array_index:b,group:!0,label:a.label,children:0,disabled:a.disabled}),f=a.childNodes,g=[];for(d=0,e=f.length;d"+a.html+"")},a.prototype.results_update_field=function(){return this.result_clear_highlight(),this.result_single_selected=null,this.results_build()},a.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},a.prototype.results_search=function(a){return this.results_showing?this.winnow_results():this.results_show()},a.prototype.keyup_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale();switch(b){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices>0)return this.keydown_backstroke();if(!this.pending_backstroke)return this.result_clear_highlight(),this.results_search();break;case 13:a.preventDefault();if(this.results_showing)return this.result_select(a);break;case 27:return this.results_showing&&this.results_hide(),!0;case 9:case 38:case 40:case 16:case 91:case 17:break;default:return this.results_search()}},a.prototype.generate_field_id=function(){var a;return a=this.generate_random_id(),this.form_field.id=a,a},a.prototype.generate_random_char=function(){var a,b,c;return a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ",c=Math.floor(Math.random()*a.length),b=a.substring(c,c+1)},a}(),b.AbstractChosen=a}.call(this),function(){var a,b,c,d=Object.prototype.hasOwnProperty,e=function(a,b){function e(){this.constructor=a}for(var c in b)d.call(b,c)&&(a[c]=b[c]);return e.prototype=b.prototype,a.prototype=new e,a.__super__=b.prototype,a};c=this,a=function(a){function d(){d.__super__.constructor.apply(this,arguments)}return e(d,a),d.prototype.setup=function(){return this.is_rtl=this.form_field.hasClassName("chzn-rtl")},d.prototype.finish_setup=function(){return this.form_field.addClassName("chzn-done")},d.prototype.set_default_values=function(){return d.__super__.set_default_values.call(this),this.single_temp=new Template('#{default}
                      '),this.multi_temp=new Template('
                        '),this.choice_temp=new Template('
                      • #{choice}
                      • '),this.no_results_temp=new Template('
                      • '+this.results_none_found+' "#{terms}"
                      • ')},d.prototype.set_up_html=function(){var a,c,d,e,f;return this.container_id=this.form_field.identify().replace(/(:|\.)/g,"_")+"_chzn",this.f_width=this.form_field.getStyle("width")?parseInt(this.form_field.getStyle("width"),10):this.form_field.getWidth(),c={id:this.container_id,"class":"chzn-container"+(this.is_rtl?" chzn-rtl":""),style:"width: "+this.f_width+"px"},this.default_text=this.form_field.readAttribute("data-placeholder")?this.form_field.readAttribute("data-placeholder"):this.default_text_default,a=this.is_multiple?(new Element("div",c)).update(this.multi_temp.evaluate({"default":this.default_text})):(new Element("div",c)).update(this.single_temp.evaluate({"default":this.default_text})),this.form_field.hide().insert({after:a}),this.container=$(this.container_id),this.container.addClassName("chzn-container-"+(this.is_multiple?"multi":"single")),this.dropdown=this.container.down("div.chzn-drop"),d=this.container.getHeight(),e=this.f_width-b(this.dropdown),this.dropdown.setStyle({width:e+"px",top:d+"px"}),this.search_field=this.container.down("input"),this.search_results=this.container.down("ul.chzn-results"),this.search_field_scale(),this.search_no_results=this.container.down("li.no-results"),this.is_multiple?(this.search_choices=this.container.down("ul.chzn-choices"),this.search_container=this.container.down("li.search-field")):(this.search_container=this.container.down("div.chzn-search"),this.selected_item=this.container.down(".chzn-single"),f=e-b(this.search_container)-b(this.search_field),this.search_field.setStyle({width:f+"px"})),this.results_build(),this.set_tab_index(),this.form_field.fire("liszt:ready",{chosen:this})},d.prototype.register_observers=function(){var a=this;return this.container.observe("mousedown",function(b){return a.container_mousedown(b)}),this.container.observe("mouseup",function(b){return a.container_mouseup(b)}),this.container.observe("mouseenter",function(b){return a.mouse_enter(b)}),this.container.observe("mouseleave",function(b){return a.mouse_leave(b)}),this.search_results.observe("mouseup",function(b){return a.search_results_mouseup(b)}),this.search_results.observe("mouseover",function(b){return a.search_results_mouseover(b)}),this.search_results.observe("mouseout",function(b){return a.search_results_mouseout(b)}),this.form_field.observe("liszt:updated",function(b){return a.results_update_field(b)}),this.search_field.observe("blur",function(b){return a.input_blur(b)}),this.search_field.observe("keyup",function(b){return a.keyup_checker(b)}),this.search_field.observe("keydown",function(b){return a.keydown_checker(b)}),this.is_multiple?(this.search_choices.observe("click",function(b){return a.choices_click(b)}),this.search_field.observe("focus",function(b){return a.input_focus(b)})):this.container.observe("click",function(a){return a.preventDefault()})},d.prototype.search_field_disabled=function(){this.is_disabled=this.form_field.disabled;if(this.is_disabled)return this.container.addClassName("chzn-disabled"),this.search_field.disabled=!0,this.is_multiple||this.selected_item.stopObserving("focus",this.activate_action),this.close_field();this.container.removeClassName("chzn-disabled"),this.search_field.disabled=!1;if(!this.is_multiple)return this.selected_item.observe("focus",this.activate_action)},d.prototype.container_mousedown=function(a){var b;if(!this.is_disabled)return b=a!=null?a.target.hasClassName("search-choice-close"):!1,a&&a.type==="mousedown"&&!this.results_showing&&a.stop(),!this.pending_destroy_click&&!b?(this.active_field?!this.is_multiple&&a&&(a.target===this.selected_item||a.target.up("a.chzn-single"))&&this.results_toggle():(this.is_multiple&&this.search_field.clear(),document.observe("click",this.click_test_action),this.results_show()),this.activate_field()):this.pending_destroy_click=!1},d.prototype.container_mouseup=function(a){if(a.target.nodeName==="ABBR")return this.results_reset(a)},d.prototype.blur_test=function(a){if(!this.active_field&&this.container.hasClassName("chzn-container-active"))return this.close_field()},d.prototype.close_field=function(){return document.stopObserving("click",this.click_test_action),this.is_multiple||(this.selected_item.tabIndex=this.search_field.tabIndex,this.search_field.tabIndex=-1),this.active_field=!1,this.results_hide(),this.container.removeClassName("chzn-container-active"),this.winnow_results_clear(),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale()},d.prototype.activate_field=function(){return!this.is_multiple&&!this.active_field&&(this.search_field.tabIndex=this.selected_item.tabIndex,this.selected_item.tabIndex=-1),this.container.addClassName("chzn-container-active"),this.active_field=!0,this.search_field.value=this.search_field.value,this.search_field.focus()},d.prototype.test_active_click=function(a){return a.target.up("#"+this.container_id)?this.active_field=!0:this.close_field()},d.prototype.results_build=function(){var a,b,d,e,f;this.parsing=!0,this.results_data=c.SelectParser.select_to_array(this.form_field),this.is_multiple&&this.choices>0?(this.search_choices.select("li.search-choice").invoke("remove"),this.choices=0):this.is_multiple||(this.selected_item.down("span").update(this.default_text),this.form_field.options.length<=this.disable_search_threshold?this.container.addClassName("chzn-container-single-nosearch"):this.container.removeClassName("chzn-container-single-nosearch")),a="",f=this.results_data;for(d=0,e=f.length;d'+a.label.escapeHTML()+"")},d.prototype.result_do_highlight=function(a){var b,c,d,e,f;this.result_clear_highlight(),this.result_highlight=a,this.result_highlight.addClassName("highlighted"),d=parseInt(this.search_results.getStyle("maxHeight"),10),f=this.search_results.scrollTop,e=d+f,c=this.result_highlight.positionedOffset().top,b=c+this.result_highlight.getHeight();if(b>=e)return this.search_results.scrollTop=b-d>0?b-d:0;if(c0&&this.search_field.value.length<1&&this.results_hide(),this.result_deselect(a.readAttribute("rel")),a.up("li").remove()},d.prototype.results_reset=function(a){this.form_field.options[0].selected=!0,this.selected_item.down("span").update(this.default_text),this.is_multiple||this.selected_item.addClassName("chzn-default"),this.show_search_field_default(),a.target.remove(),typeof Event.simulate=="function"&&this.form_field.simulate("change");if(this.active_field)return this.results_hide()},d.prototype.result_select=function(a){var b,c,d;if(this.result_highlight)return b=this.result_highlight,this.result_clear_highlight(),this.is_multiple?this.result_deactivate(b):(this.search_results.descendants(".result-selected").invoke("removeClassName","result-selected"),this.selected_item.removeClassName("chzn-default"),this.result_single_selected=b),b.addClassName("result-selected"),d=b.id.substr(b.id.lastIndexOf("_")+1),c=this.results_data[d],c.selected=!0,this.form_field.options[c.options_index].selected=!0,this.is_multiple?this.choice_build(c):(this.selected_item.down("span").update(c.html),this.allow_single_deselect&&this.single_deselect_control_build()),(!a.metaKey||!this.is_multiple)&&this.results_hide(),this.search_field.value="",typeof Event.simulate=="function"&&this.form_field.simulate("change"),this.search_field_scale()},d.prototype.result_activate=function(a){return a.addClassName("active-result")},d.prototype.result_deactivate=function(a){return a.removeClassName("active-result")},d.prototype.result_deselect=function(a){var b,c;return c=this.results_data[a],c.selected=!1,this.form_field.options[c.options_index].selected=!1,b=$(this.container_id+"_o_"+a),b.removeClassName("result-selected").addClassName("active-result").show(),this.result_clear_highlight(),this.winnow_results(),typeof Event.simulate=="function"&&this.form_field.simulate("change"),this.search_field_scale()},d.prototype.single_deselect_control_build=function(){if(this.allow_single_deselect&&!this.selected_item.down("abbr"))return this.selected_item.down("span").insert({after:''})},d.prototype.winnow_results=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;this.no_results_clear(),h=0,i=this.search_field.value===this.default_text?"":this.search_field.value.strip().escapeHTML(),f=this.search_contains?"":"^",e=new RegExp(f+i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),l=new RegExp(i.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),"i"),q=this.results_data;for(m=0,o=q.length;m=0||b.html.indexOf("[")===0){d=b.html.replace(/\[|\]/g,"").split(" ");if(d.length)for(n=0,p=d.length;n"+b.html.substr(j+i.length),k=k.substr(0,j)+""+k.substr(j)):k=b.html,$(g).innerHTML!==k&&$(g).update(k),this.result_activate($(g)),b.group_array_index!=null&&$(this.results_data[b.group_array_index].dom_id).setStyle({display:"list-item"})):($(g)===this.result_highlight&&this.result_clear_highlight(),this.result_deactivate($(g)))}}return h<1&&i.length?this.no_results(i):this.winnow_results_set_highlight()},d.prototype.winnow_results_clear=function(){var a,b,c,d,e;this.search_field.clear(),b=this.search_results.select("li"),e=[];for(c=0,d=b.length;c0&&this.results_hide(),this.result_clear_highlight())},d.prototype.keydown_backstroke=function(){return this.pending_backstroke?(this.choice_destroy(this.pending_backstroke.down("a")),this.clear_backstroke()):(this.pending_backstroke=this.search_container.siblings("li.search-choice").last(),this.pending_backstroke.addClassName("search-choice-focus"))},d.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClassName("search-choice-focus"),this.pending_backstroke=null},d.prototype.keydown_checker=function(a){var b,c;b=(c=a.which)!=null?c:a.keyCode,this.search_field_scale(),b!==8&&this.pending_backstroke&&this.clear_backstroke();switch(b){case 8:this.backstroke_length=this.search_field.value.length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(a),this.mouse_on_container=!1;break;case 13:a.preventDefault();break;case 38:a.preventDefault(),this.keyup_arrow();break;case 40:this.keydown_arrow()}},d.prototype.search_field_scale=function(){var a,b,c,d,e,f,g,h,i;if(this.is_multiple){c=0,g=0,e="position:absolute; left: -1000px; top: -1000px; display:none;",f=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"];for(h=0,i=f.length;hthis.f_width-10&&(g=this.f_width-10),this.search_field.setStyle({width:g+"px"}),a=this.container.getHeight(),this.dropdown.setStyle({top:a+"px"})}},d}(AbstractChosen),c.Chosen=a,Prototype.Browser.IE&&/MSIE (\d+\.\d+);/.test(navigator.userAgent)&&(Prototype.BrowserFeatures.Version=new Number(RegExp.$1)),b=function(a){var b,c;return b=new Element.Layout(a),c=b.get("border-left")+b.get("border-right")+b.get("padding-left")+b.get("padding-right")},c.get_side_border_padding=b}.call(this) \ No newline at end of file diff --git a/admin/thirdparty/chosen/coffee/chosen.jquery.coffee b/admin/thirdparty/chosen/coffee/chosen.jquery.coffee index d65d0354a..ae71f9e55 100644 --- a/admin/thirdparty/chosen/coffee/chosen.jquery.coffee +++ b/admin/thirdparty/chosen/coffee/chosen.jquery.coffee @@ -40,7 +40,7 @@ class Chosen extends AbstractChosen if @is_multiple container_div.html '
                          ' else - container_div.html '' + @default_text + '
                            ' + container_div.html '' + @default_text + '
                              ' @form_field_jq.hide().after container_div @container = ($ '#' + @container_id) @@ -108,7 +108,7 @@ class Chosen extends AbstractChosen container_mousedown: (evt) -> if !@is_disabled target_closelink = if evt? then ($ evt.target).hasClass "search-choice-close" else false - if evt and evt.type is "mousedown" + if evt and evt.type is "mousedown" and not @results_showing evt.stopPropagation() if not @pending_destroy_click and not target_closelink if not @active_field @@ -187,7 +187,7 @@ class Chosen extends AbstractChosen if data.selected and @is_multiple this.choice_build data else if data.selected and not @is_multiple - @selected_item.find("span").text data.text + @selected_item.removeClass("chzn-default").find("span").text data.text this.single_deselect_control_build() if @allow_single_deselect this.search_field_disabled() @@ -315,6 +315,7 @@ class Chosen extends AbstractChosen results_reset: (evt) -> @form_field.options[0].selected = true @selected_item.find("span").text @default_text + @selected_item.addClass("chzn-default") if not @is_multiple this.show_search_field_default() $(evt.target).remove(); @form_field_jq.trigger "change" @@ -332,6 +333,7 @@ class Chosen extends AbstractChosen else @search_results.find(".result-selected").removeClass "result-selected" @result_single_selected = high + @selected_item.removeClass("chzn-default") high.addClass "result-selected" @@ -383,7 +385,8 @@ class Chosen extends AbstractChosen results = 0 searchText = if @search_field.val() is @default_text then "" else $('
                              ').text($.trim(@search_field.val())).html() - regex = new RegExp('^' + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i') + regexAnchor = if @search_contains then "" else "^" + regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i') zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i') for option in @results_data diff --git a/admin/thirdparty/chosen/coffee/chosen.proto.coffee b/admin/thirdparty/chosen/coffee/chosen.proto.coffee index 4c306a766..d63d64047 100644 --- a/admin/thirdparty/chosen/coffee/chosen.proto.coffee +++ b/admin/thirdparty/chosen/coffee/chosen.proto.coffee @@ -16,7 +16,7 @@ class Chosen extends AbstractChosen super() # HTML Templates - @single_temp = new Template('#{default}
                                ') + @single_temp = new Template('#{default}
                                  ') @multi_temp = new Template('
                                    ') @choice_temp = new Template('
                                  • #{choice}
                                  • ') @no_results_temp = new Template('
                                  • ' + @results_none_found + ' "#{terms}"
                                  • ') @@ -101,7 +101,7 @@ class Chosen extends AbstractChosen container_mousedown: (evt) -> if !@is_disabled target_closelink = if evt? then evt.target.hasClassName "search-choice-close" else false - if evt and evt.type is "mousedown" + if evt and evt.type is "mousedown" and not @results_showing evt.stop() if not @pending_destroy_click and not target_closelink if not @active_field @@ -179,7 +179,7 @@ class Chosen extends AbstractChosen if data.selected and @is_multiple this.choice_build data else if data.selected and not @is_multiple - @selected_item.down("span").update( data.html ) + @selected_item.removeClassName("chzn-default").down("span").update( data.html ) this.single_deselect_control_build() if @allow_single_deselect this.search_field_disabled() @@ -308,6 +308,7 @@ class Chosen extends AbstractChosen results_reset: (evt) -> @form_field.options[0].selected = true @selected_item.down("span").update(@default_text) + @selected_item.addClassName("chzn-default") if not @is_multiple this.show_search_field_default() evt.target.remove() @form_field.simulate("change") if typeof Event.simulate is 'function' @@ -322,6 +323,7 @@ class Chosen extends AbstractChosen this.result_deactivate high else @search_results.descendants(".result-selected").invoke "removeClassName", "result-selected" + @selected_item.removeClassName("chzn-default") @result_single_selected = high high.addClassName("result-selected") @@ -374,7 +376,8 @@ class Chosen extends AbstractChosen results = 0 searchText = if @search_field.value is @default_text then "" else @search_field.value.strip().escapeHTML() - regex = new RegExp('^' + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i') + regexAnchor = if @search_contains then "" else "^" + regex = new RegExp(regexAnchor + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i') zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i') for option in @results_data diff --git a/admin/thirdparty/chosen/coffee/lib/abstract-chosen.coffee b/admin/thirdparty/chosen/coffee/lib/abstract-chosen.coffee index a7c1b01da..dc68b7da9 100644 --- a/admin/thirdparty/chosen/coffee/lib/abstract-chosen.coffee +++ b/admin/thirdparty/chosen/coffee/lib/abstract-chosen.coffee @@ -29,6 +29,7 @@ class AbstractChosen @result_single_selected = null @allow_single_deselect = if @options.allow_single_deselect? and @form_field.options[0]? and @form_field.options[0].text is "" then @options.allow_single_deselect else false @disable_search_threshold = @options.disable_search_threshold || 0 + @search_contains = @options.search_contains || false @choices = 0 @results_none_found = @options.no_results_text or "No results match" diff --git a/admin/thirdparty/chosen/example.proto.html b/admin/thirdparty/chosen/example.proto.html index 77c48c71f..d24a08bbf 100644 --- a/admin/thirdparty/chosen/example.proto.html +++ b/admin/thirdparty/chosen/example.proto.html @@ -1343,7 +1343,7 @@ orgia and The South Sandwich Islands">South Georgia and The South Sandwich Islan

                                    Using Chosen is easy as can be.

                                    1. Download the plugin and copy the chosen files to your app.
                                    2. -
                                    3. Activate the plugin by creating a new instance of Chosen: New Chosen(some_form_field);
                                    4. +
                                    5. Activate the plugin by creating a new instance of Chosen: new Chosen(some_form_field);
                                    6. Disco.
                                    diff --git a/admin/thirdparty/chosen/package.json b/admin/thirdparty/chosen/package.json index a26bb42c8..a97f4f48b 100644 --- a/admin/thirdparty/chosen/package.json +++ b/admin/thirdparty/chosen/package.json @@ -1,7 +1,7 @@ { "author": "harvest", "name": "chosen", - "version": "0.9.7", + "version": "0.9.8", "description": "Chosen is a JavaScript plugin that makes long, unwieldy select boxes much more user-friendly. It is currently available in both jQuery and Prototype flavors.", "repository": { "type": "git", diff --git a/admin/thirdparty/history-js/scripts/uncompressed/history.html4.js b/admin/thirdparty/history-js/scripts/uncompressed/history.html4.js index 6d8d4274a..709d9b887 100644 --- a/admin/thirdparty/history-js/scripts/uncompressed/history.html4.js +++ b/admin/thirdparty/history-js/scripts/uncompressed/history.html4.js @@ -429,7 +429,10 @@ } // Create State - currentState = History.extractState(History.getFullUrl(currentHash||document.location.href,false),true); + // MODIFIED ischommer: URL normalization needs to respect our tag, + // otherwise will go into infinite loops + currentState = History.extractState(History.getFullUrl(currentHash||document.location.href,true),true); + // END MODIFIED // Check if we are the same state if ( History.isLastSavedState(currentState) ) { diff --git a/core/Convert.php b/core/Convert.php index ac13d72ae..f4a8d9635 100644 --- a/core/Convert.php +++ b/core/Convert.php @@ -92,28 +92,28 @@ class Convert { return str_replace(array("\\", '"', "\n", "\r", "'"), array("\\\\", '\"', '\n', '\r', "\\'"), $val); } } - + /** - * Uses the PHP 5.2 native json_encode function if available, - * otherwise falls back to the Services_JSON class. - * - * @see http://pear.php.net/pepr/pepr-proposal-show.php?id=198 - * @uses Director::baseFolder() - * @uses Services_JSON + * Encode a value as a JSON encoded string. * - * @param mixed $val - * @return string JSON safe string + * @param mixed $val Value to be encoded + * @return string JSON encoded string */ static function raw2json($val) { - if(function_exists('json_encode')) { - return json_encode($val); - } else { - require_once(Director::baseFolder() . '/sapphire/thirdparty/json/JSON.php'); - $json = new Services_JSON(); - return $json->encode($val); - } + return json_encode($val); } - + + /** + * Encode an array as a JSON encoded string. + * THis is an alias to {@link raw2json()} + * + * @param array $val Array to convert + * @return string JSON encoded string + */ + static function array2json($val) { + return self::raw2json($val); + } + static function raw2sql($val) { if(is_array($val)) { foreach($val as $k => $v) $val[$k] = self::raw2sql($v); @@ -138,41 +138,15 @@ class Convert { else return html_entity_decode($val, ENT_QUOTES, 'UTF-8'); } } - - /** - * Convert an array into a JSON encoded string. - * - * @see http://pear.php.net/pepr/pepr-proposal-show.php?id=198 - * @uses Director::baseFolder() - * @uses Services_JSON - * - * @param array $val Array to convert - * @return string JSON encoded string - */ - static function array2json($val) { - if(function_exists('json_encode')) { - return json_encode($val); - } else { - require_once(Director::baseFolder() . '/sapphire/thirdparty/json/JSON.php'); - $json = new Services_JSON(); - return $json->encode($val); - } - } - + /** * Convert a JSON encoded string into an object. - * - * @see http://pear.php.net/pepr/pepr-proposal-show.php?id=198 - * @uses Director::baseFolder() - * @uses Services_JSON * * @param string $val - * @return mixed JSON safe string + * @return object|boolean */ static function json2obj($val) { - require_once(Director::baseFolder() . '/sapphire/thirdparty/json/JSON.php'); - $json = new Services_JSON(); - return $json->decode($val); + return json_decode($val); } /** @@ -183,15 +157,7 @@ class Convert { * @return array|boolean */ static function json2array($val) { - $json = self::json2obj($val); - if(!$json) return false; - - $arr = array(); - foreach($json as $k => $v) { - $arr[$k] = $v; - } - - return $arr; + return json_decode($val, true); } /** diff --git a/core/Core.php b/core/Core.php index 2c450b15e..622655494 100644 --- a/core/Core.php +++ b/core/Core.php @@ -38,21 +38,8 @@ /////////////////////////////////////////////////////////////////////////////// // ENVIRONMENT CONFIG -if(defined('E_DEPRECATED')) error_reporting(E_ALL & ~(E_DEPRECATED | E_STRICT)); +if(defined('E_DEPRECATED')) error_reporting(E_ALL & ~(E_STRICT)); else error_reporting(E_ALL); -/* - * This is for versions of PHP prior to version 5.2 - * Creating this here will allow both web requests and cron jobs to inherit it. - */ -if (!function_exists('array_fill_keys')) { - function array_fill_keys($keys,$value) { - //Sometimes we get passed an empty array, and if that's the case, you'll get an error message - if(sizeof($keys)==0) - return Array(); - else - return array_combine($keys,array_fill(0,count($keys),$value)); - } -} /** * Include _ss_environment.php files diff --git a/core/Diff.php b/core/Diff.php index f59da6705..8623f8b14 100644 --- a/core/Diff.php +++ b/core/Diff.php @@ -800,7 +800,7 @@ class Diff if(is_array($content)) $content = implode(',', $content); $content = str_replace(array(" ","<", ">"),array(" "," <", "> "),$content); - $candidateChunks = split("[\t\r\n ]+", $content); + $candidateChunks = preg_split("/[\t\r\n ]+/", $content); while(list($i,$item) = each($candidateChunks)) { if(isset($item[0]) && $item[0] == "<") { $newChunk = $item; diff --git a/core/manifest/ClassLoader.php b/core/manifest/ClassLoader.php index d91f31861..425fc9da7 100644 --- a/core/manifest/ClassLoader.php +++ b/core/manifest/ClassLoader.php @@ -85,4 +85,4 @@ class SS_ClassLoader { return class_exists($class, false) || $this->getManifest()->getItemPath($class); } -} \ No newline at end of file +} diff --git a/css/AssetUploadField.css b/css/AssetUploadField.css index 75de568af..d4d9b52b5 100644 --- a/css/AssetUploadField.css +++ b/css/AssetUploadField.css @@ -6,6 +6,8 @@ /** ----------------------------------------------- Application Logo (CMS Logo) Must be 24px x 24px ------------------------------------------------ */ #AssetUploadField { border-bottom: 0; -moz-box-shadow: none; -webkit-box-shadow: none; -o-box-shadow: none; box-shadow: none; } +body.cms.ss-uploadfield-edit-iframe { padding: 16px; overflow: auto; } + .ss-assetuploadfield h3 { border-bottom: 1px solid rgba(201, 205, 206, 0.8); -moz-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8); -webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8); -o-box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8); margin: 0 0 8px; padding: 0 0 7px; clear: both; } .ss-assetuploadfield .field { border-bottom: 0; } .ss-assetuploadfield .ss-uploadfield-files { margin: 0; padding: 0; } @@ -30,7 +32,7 @@ .ss-assetuploadfield .ss-uploadfield-files .ss-uploadfield-item-cancel { position: absolute; top: 7px; right: 7px; } .ss-assetuploadfield .ss-uploadfield-files .ss-uploadfield-item-cancel button { display: block; overflow: hidden; text-indent: -9999px; padding: 0; margin: 0; border: 0; width: 16px; height: 16px; cursor: pointer; -moz-box-shadow: none; -webkit-box-shadow: none; -o-box-shadow: none; box-shadow: none; } .ss-assetuploadfield .ss-uploadfield-files .ss-uploadfield-item-editform { /* don't use display none, for it will break jQuery('iframe').contents().height() */ height: 0; overflow: hidden; clear: both; } -.ss-assetuploadfield .ss-uploadfield-files .ss-uploadfield-item-editform iframe { margin: 16px; width: 100%; } +.ss-assetuploadfield .ss-uploadfield-files .ss-uploadfield-item-editform iframe { width: 100%; } .ss-assetuploadfield .ss-uploadfield-addfile .ss-uploadfield-item-info { float: left; margin: 19px 0 0; } .ss-assetuploadfield .ss-uploadfield-addfile .ss-uploadfield-fromcomputer { position: relative; overflow: hidden; display: block; margin: 0 10px 0 0; } .ss-assetuploadfield .ss-uploadfield-addfile .ss-uploadfield-item-uploador { float: left; font-weight: bold; font-size: 22px; padding: 0 20px; line-height: 70px; display: none; } diff --git a/css/GridField.css b/css/GridField.css index e2e67e4c9..8d8d74f78 100644 --- a/css/GridField.css +++ b/css/GridField.css @@ -12,11 +12,12 @@ .cms table.ss-gridfield-table thead { color: #1d2224; background: transparent; } .cms table.ss-gridfield-table thead tr.filter-header .fieldgroup { max-width: 512px; } .cms table.ss-gridfield-table tbody { background: #FFF; } +.cms table.ss-gridfield-table tbody td { width: 100%; } +.cms table.ss-gridfield-table tbody td.col-buttons { width: auto; text-align: right; white-space: nowrap; } .cms table.ss-gridfield-table tbody td button { border: none; background: none; margin: 0 0 0 2px; padding: 0; width: auto; text-shadow: none; } .cms table.ss-gridfield-table tbody td button.ui-state-hover { background: none; -moz-box-shadow: none; -webkit-box-shadow: none; box-shadow: none; } .cms table.ss-gridfield-table tbody td button.ui-state-active { border: none; -moz-box-shadow: none; -webkit-box-shadow: none; box-shadow: none; } -.cms table.ss-gridfield-table tbody td a.edit-link { display: inline-block; width: 16px; height: 20px; text-indent: -9999em; background: url(../images/icons/document--pencil.png) no-repeat 0 1px; } -.cms table.ss-gridfield-table tbody td.col-buttons { white-space: nowrap; } +.cms table.ss-gridfield-table tbody td a.edit-link { display: inline-block; width: 16px; height: 20px; text-indent: 9999em; background: url(../images/icons/document--pencil.png) no-repeat 0 1px; } .cms table.ss-gridfield-table tfoot { color: #1d2224; } .cms table.ss-gridfield-table tfoot tr td { background: #95a5ab; padding: .7em; border-bottom: 1px solid rgba(0, 0, 0, 0.1); } .cms table.ss-gridfield-table tr.title { -moz-border-radius-topleft: 7px; -webkit-border-top-left-radius: 7px; -o-border-top-left-radius: 7px; -ms-border-top-left-radius: 7px; -khtml-border-top-left-radius: 7px; border-top-left-radius: 7px; -moz-border-radius-topright: 7px; -webkit-border-top-right-radius: 7px; -o-border-top-right-radius: 7px; -ms-border-top-right-radius: 7px; -khtml-border-top-right-radius: 7px; border-top-right-radius: 7px; } @@ -45,6 +46,7 @@ .cms table.ss-gridfield-table tr th.action { border-right: 0; } .cms table.ss-gridfield-table tr th.first { -moz-border-radius-topleft: 7px; -webkit-border-top-left-radius: 7px; -o-border-top-left-radius: 7px; -ms-border-top-left-radius: 7px; -khtml-border-top-left-radius: 7px; border-top-left-radius: 7px; } .cms table.ss-gridfield-table tr th.last { -moz-border-radius-topright: 7px; -webkit-border-top-right-radius: 7px; -o-border-top-right-radius: 7px; -ms-border-top-right-radius: 7px; -khtml-border-top-right-radius: 7px; border-top-right-radius: 7px; } +.cms table.ss-gridfield-table tr th button#action_gridfield_relationadd:hover { color: #444 !important; /* Not sure why IE think it needs this */ } .cms table.ss-gridfield-table tr th button:hover { color: #ccc !important; /* Not sure why IE think it needs this */ } .cms table.ss-gridfield-table tr th button.ss-gridfield-sort:hover { color: #fff !important; -moz-box-shadow: none; -webkit-box-shadow: none; box-shadow: none; } .cms table.ss-gridfield-table tr th button.ss-gridfield-sort { background: transparent url(../images/arrows.png) no-repeat right 6px; border: none; width: 100%; text-align: left; padding: 4px 0; text-shadow: rgba(0, 0, 0, 0.3) 0px -1px 0; color: #fff; -moz-border-radius: 0; -webkit-border-radius: 0; -o-border-radius: 0; -ms-border-radius: 0; -khtml-border-radius: 0; border-radius: 0; } diff --git a/dev/Debug.php b/dev/Debug.php index 2083c64e4..847b3bedd 100644 --- a/dev/Debug.php +++ b/dev/Debug.php @@ -697,6 +697,8 @@ function errorHandler($errno, $errstr, $errfile, $errline) { case E_NOTICE: case E_USER_NOTICE: + case E_DEPRECATED: + case E_USER_DEPRECATED: Debug::noticeHandler($errno, $errstr, $errfile, $errline, null); break; } diff --git a/dev/DebugView.php b/dev/DebugView.php index 6eac9dabe..d29d9987a 100644 --- a/dev/DebugView.php +++ b/dev/DebugView.php @@ -30,6 +30,14 @@ class DebugView extends Object { 'title' => 'User Notice', 'class' => 'notice' ), + E_DEPRECATED => array( + 'title' => 'Deprecation', + 'class' => 'notice' + ), + E_USER_DEPRECATED => array( + 'title' => 'Deprecation', + 'class' => 'notice' + ), E_CORE_ERROR => array( 'title' => 'Core Error', 'class' => 'error' diff --git a/dev/SapphireTest.php b/dev/SapphireTest.php index 97c6114b5..823edcc6e 100644 --- a/dev/SapphireTest.php +++ b/dev/SapphireTest.php @@ -143,6 +143,9 @@ class SapphireTest extends PHPUnit_Framework_TestCase { i18n::set_date_format(null); i18n::set_time_format(null); + // Set default timezone consistently to avoid NZ-specific dependencies + date_default_timezone_set('UTC'); + // Remove password validation $this->originalMemberPasswordValidator = Member::password_validator(); $this->originalRequirements = Requirements::backend(); @@ -272,6 +275,9 @@ class SapphireTest extends PHPUnit_Framework_TestCase { // which is used in DatabaseAdmin->doBuild() global $_SINGLETONS; $_SINGLETONS = array(); + + // Set default timezone consistently to avoid NZ-specific dependencies + date_default_timezone_set('UTC'); } /** @@ -765,7 +771,10 @@ class SapphireTest extends PHPUnit_Framework_TestCase { // Disable PHPUnit error handling restore_error_handler(); - // Create a temporary database + // Create a temporary database, and force the connection to use UTC for time + global $databaseConfig; + $databaseConfig['timezone'] = '+0:00'; + DB::connect($databaseConfig); $dbConn = DB::getConn(); $prefix = defined('SS_DATABASE_PREFIX') ? SS_DATABASE_PREFIX : 'ss_'; $dbname = strtolower(sprintf('%stmpdb', $prefix)) . rand(1000000,9999999); diff --git a/dev/install/install.php5 b/dev/install/install.php5 index 5efee6e34..45c95f2d3 100644 --- a/dev/install/install.php5 +++ b/dev/install/install.php5 @@ -402,9 +402,9 @@ class InstallRequirements { $this->requireDateTimezone(array('PHP Configuration', 'date.timezone set and valid', 'date.timezone option in php.ini must be set in PHP 5.3.0+', ini_get('date.timezone'))); } - $this->suggestPHPSetting('asp_tags', array(''), array('PHP Configuration', 'asp_tags option turned off', 'This should be turned off as it can cause issues with SilverStripe')); - $this->suggestPHPSetting('magic_quotes_gpc', array(''), array('PHP Configuration', 'magic_quotes_gpc option turned off', 'This should be turned off, as it can cause issues with cookies. More specifically, unserializing data stored in cookies.')); - $this->suggestPHPSetting('display_errors', array(''), array('PHP Configuration', 'display_errors option turned off', 'Unless you\'re in a development environment, this should be turned off, as it can expose sensitive data to website users.')); + $this->suggestPHPSetting('asp_tags', array(false,0,''), array('PHP Configuration', 'asp_tags option turned off', 'This should be turned off as it can cause issues with SilverStripe')); + $this->suggestPHPSetting('magic_quotes_gpc', array(false,0,''), array('PHP Configuration', 'magic_quotes_gpc option turned off', 'This should be turned off, as it can cause issues with cookies. More specifically, unserializing data stored in cookies.')); + $this->suggestPHPSetting('display_errors', array(false,0,''), array('PHP Configuration', 'display_errors option turned off', 'Unless you\'re in a development environment, this should be turned off, as it can expose sensitive data to website users.')); // Check memory allocation $this->requireMemory(32*1024*1024, 64*1024*1024, array("PHP Configuration", "Memory allocated (PHP config option 'memory_limit')", "SilverStripe needs a minimum of 32M allocated to PHP, but recommends 64M.", ini_get("memory_limit"))); @@ -414,7 +414,6 @@ class InstallRequirements { function suggestPHPSetting($settingName, $settingValues, $testDetails) { $this->testing($testDetails); - $val = ini_get($settingName); if(!in_array($val, $settingValues) && $val != $settingValues) { $testDetails[2] = "$settingName is set to '$val' in php.ini. $testDetails[2]"; diff --git a/docs/en/changelogs/3.0.0.md b/docs/en/changelogs/3.0.0.md index bc84a8bea..04cd56b29 100644 --- a/docs/en/changelogs/3.0.0.md +++ b/docs/en/changelogs/3.0.0.md @@ -113,6 +113,38 @@ As with any SilverStripe upgrade, we recommend database backups before calling ` See [mysql.com](http://dev.mysql.com/doc/refman/5.5/en/converting-tables-to-innodb.html) for details on the conversion. Note: MySQL has made InnoDB the default engine in its [5.5 release](http://dev.mysql.com/doc/refman/5.5/en/innodb-storage-engine.html). +### Convert::json2array() changes ### + +Convert JSON functions have been changed to use built-in json PHP functions `json_decode()` and `json_encode()` + +Because `json_decode()` will convert nested JSON structures to arrays as well, this has changed the way it worked, +as before nested structures would be converted to an object instead. + +So, given the following JSON input to `Convert::json2array()`: + + {"Joe":"Bloggs","Tom":"Jones","My":{"Complicated":"Structure"}} + +Here's the output from SilverStripe 2.4, with nested JSON as objects: + + array( + 'Joe' => 'Bloggs' + 'Tom' => 'Jones', + 'My' => stdObject( + Complicated => 'Structure' // property on object + ) + ) + +Now in SilverStripe 3.x, nested structures are arrays: + + array( + 'Joe' => 'Bloggs', + 'Tom' => 'Jones', + 'My' => array( + 'Complicated' => 'Structure' // key value on nested array + ) + ) + + ### GridField: Replacement for TableListField and ComplexTableField ### We have a new component for managing lists of objects: The `[GridField](/topics/grid-field)`. diff --git a/docs/en/installation/from-source.md b/docs/en/installation/from-source.md index 645cc8712..0d3941409 100644 --- a/docs/en/installation/from-source.md +++ b/docs/en/installation/from-source.md @@ -26,7 +26,7 @@ SilverStripe core is currently hosted on [github.com/silverstripe](http://github * The `installer` project ([github.com/silverstripe/silverstripe-installer](http://github.com/silverstripe/silverstripe-installer)) * The `sapphire` module ([github.com/silverstripe/sapphire](http://github.com/silverstripe/sapphire)) * The `cms` module ([github.com/silverstripe/silverstripe-cms](http://github.com/silverstripe/silverstripe-cms)) - * A sample theme called `blackcandy` ([github.com/silverstripe-themes/silverstripe-blackcandy](http://github.com/silverstripe-themes/silverstripe-blackcandy)) + * A sample theme called `simple` ([github.com/silverstripe-themes/silverstripe-simple](http://github.com/silverstripe-themes/silverstripe-simple)) First, you'll have to decide what you want to do with your project: @@ -72,7 +72,7 @@ Run the following command to download all core dependencies via [Piston](http:// cd my-silverstripe-project/ tools/new-project -This will add `sapphire`, `cms` and the `blackcandy` theme to your project. +This will add `sapphire`, `cms` and the `simple` theme to your project. As a fallback solution, you can simply download all necessary files without any dependency management through piston. This is handy if you have an existing project in version control, and want a one-off snapshot @@ -146,8 +146,7 @@ Please replace `` below with your github username. cd my-silverstripe-project git clone git@github.com:/sapphire.git sapphire git clone git@github.com:/silverstripe-cms.git cms - rm -rf themes - git clone git@github.com:/silverstripe-blackcandy.git themes + git clone git@github.com:/silverstripe-simple.git themes/simple Now you need to add the original repository as `upstream`, so you can keep your fork updated later on. @@ -155,7 +154,7 @@ Now you need to add the original repository as `upstream`, so you can keep your (git remote add upstream git://github.com/silverstripe/silverstripe-installer.git && git fetch upstream) (cd sapphire && git remote add upstream git://github.com/silverstripe/sapphire.git && git fetch upstream) (cd cms && git remote add upstream git://github.com/silverstripe/silverstripe-cms.git && git fetch upstream) - (cd themes/blackcandy && git remote add upstream git://github.com/silverstripe-themes/silverstripe-blackcandy.git) + (cd themes/simple && git remote add upstream git://github.com/silverstripe-themes/silverstripe-simple.git) Now that you're set up, please read our ["Collaboration on Git"](../misc/collaboration-on-git) guide, as well as our general ["Contributor guidelines"](../misc/contributing). @@ -175,7 +174,7 @@ You can optionally select a ["release branch"](https://github.com/silverstripe/s git checkout -b 2.4 origin/2.4 (cd sapphire && git checkout -b 2.4 origin/2.4) (cd cms && git checkout -b 2.4 origin/2.4) - (cd themes/blackcandy && git checkout -b 2.4 origin/2.4) + (cd themes/simple && git checkout -b 2.4 origin/2.4) # repeat for all modules in your project... After creating the local branch, you can simply switch between branches: @@ -184,7 +183,7 @@ After creating the local branch, you can simply switch between branches: git checkout 2.4 (cd sapphire && git checkout 2.4) (cd cms && git checkout 2.4) - (cd themes/blackcandy && git checkout 2.4) + (cd themes/simple && git checkout 2.4) # repeat for all modules in your project... To switch back to master: @@ -193,7 +192,7 @@ To switch back to master: git checkout master (cd sapphire && git checkout master) (cd cms && git checkout master) - (cd themes/blackcandy && git checkout master) + (cd themes/simple && git checkout master) # repeat for all modules in your project... You can't switch branches if your working copy has local changes (typically in `mysite/_config.php`). diff --git a/docs/en/tutorials/2-extending-a-basic-site.md b/docs/en/tutorials/2-extending-a-basic-site.md index 198d8f523..e5662a23f 100644 --- a/docs/en/tutorials/2-extending-a-basic-site.md +++ b/docs/en/tutorials/2-extending-a-basic-site.md @@ -87,7 +87,6 @@ We'll start with the *ArticlePage* page type. First we create the model, a class } - ?> Here we've created our data object/controller pair, but we haven't actually extended them at all. Don't worry about the @@ -116,8 +115,6 @@ Let's create the *ArticleHolder* page type. class ArticleHolder_Controller extends Page_Controller { } - - ?> Here we have done something interesting: the *$allowed_children* field. This is one of a number of static fields we can @@ -249,7 +246,7 @@ Let's walk through these changes. *$dateField* is added only to the DateField in order to change the configuration. :::php - $dateField->setConfig('showCalendar', true); + $dateField->setConfig('showcalendar', true); Set *showCalendar* to true to have a calendar appear underneath the Date field when you click on the field. @@ -424,44 +421,6 @@ This will change the icons for the pages in the CMS. ![](_images/icons2.jpg) -### Allowing comments on news articles - -A handy feature built into SilverStripe is the ability for guests to your site to leave comments on pages. We can turn -this on for an article simply by ticking the box in the behaviour tab of a page in the CMS. Enable this for all your -*ArticlePage*s. - -![](_images/comments.jpg) - -We then need to include *$PageComments* in our template, which will insert the comment form as well as all comments left -on the page. - -**themes/tutorial/templates/Layout/ArticlePage.ss** - - :::html - ... -
                                    - Posted on $Date.Nice by $Author -
                                    - $PageComments - ... - - -You should also prepare the *Page* template in the same manner, so comments can be enabled at a later point on any page. - -![](_images/news-comments.jpg) - -It would be nice to have comments on for all articles by default. We can do this with the *$defaults* array. Add this to -the *ArticlePage* class: - - :::php - static $defaults = array( - 'ProvideComments' => true - ); - - -You can set defaults for any of the fields in your data object. *ProvideComments* is defined in *SiteTree*, so it is -part of our *ArticlePage* data object. - ## Showing the latest news on the homepage It would be nice to greet page visitors with a summary of the latest news when they visit the homepage. This requires a diff --git a/filesystem/File.php b/filesystem/File.php index 92d73e738..8d93a0a7b 100644 --- a/filesystem/File.php +++ b/filesystem/File.php @@ -316,10 +316,13 @@ class File extends DataObject { } /** - * Returns the fields to power the edit screen of files in the CMS + * Returns the fields to power the edit screen of files in the CMS. + * You can modify this FieldList by subclassing folder, or by creating a {@link DataExtension} + * and implemeting updateCMSFields(FieldList $fields) on that extension. + * * @return FieldList */ - function getCMSFields() { + function getCMSFields($params = null) { // Preview if($this instanceof Image) { $formattedImage = $this->getFormattedImage('SetWidth', Image::$asset_preview_width); @@ -383,6 +386,9 @@ class File extends DataObject { ) ); + // Folder has its own updateCMSFields hook + if(!($this instanceof Folder)) $this->extend('updateCMSFields', $fields); + return $fields; } @@ -816,8 +822,8 @@ class File extends DataObject { } } - public function flushCache() { - parent::flushCache(); + public function flushCache($persistant = true) { + parent::flushCache($persistant); self::$cache_file_fields = null; } diff --git a/filesystem/Folder.php b/filesystem/Folder.php index 0a1c698b6..3d540e1b3 100644 --- a/filesystem/Folder.php +++ b/filesystem/Folder.php @@ -406,7 +406,7 @@ class Folder extends File { * You can modify this FieldList by subclassing folder, or by creating a {@link DataExtension} * and implemeting updateCMSFields(FieldList $fields) on that extension. */ - function getCMSFields() { + function getCMSFields($param = null) { // Hide field on root level, which can't be renamed if(!$this->ID || $this->ID === "root") { $titleField = new HiddenField("Name"); diff --git a/filesystem/GD.php b/filesystem/GD.php index 667265096..16eccff93 100644 --- a/filesystem/GD.php +++ b/filesystem/GD.php @@ -64,6 +64,11 @@ class GD extends Object { $width = round($width); $height = round($height); + // Check that a resize is actually necessary. + if ($width == $this->width && $height == $this->height) { + return $this; + } + $newGD = imagecreatetruecolor($width, $height); // Preserves transparency between images @@ -125,6 +130,11 @@ class GD extends Object { $width = round($width); $height = round($height); + // Check that a resize is actually necessary. + if ($width == $this->width && $height == $this->height) { + return $this; + } + if(!$width && !$height) user_error("No dimensions given", E_USER_ERROR); if(!$width) user_error("Width not given", E_USER_ERROR); if(!$height) user_error("Height not given", E_USER_ERROR); @@ -299,6 +309,10 @@ class GD extends Object { $width = round($width); $height = round($height); + // Check that a resize is actually necessary. + if ($width == $this->width && $height == $this->height) { + return $this; + } $newGD = imagecreatetruecolor($width, $height); diff --git a/forms/DateField.php b/forms/DateField.php index cc4c49615..a1f2c6b66 100644 --- a/forms/DateField.php +++ b/forms/DateField.php @@ -196,8 +196,13 @@ class DateField extends TextField { // Setting in correct locale if(is_array($val) && $this->validateArrayValue($val)) { // set() gets confused with custom date formats when using array notation - $this->valueObj = new Zend_Date($val, null, $this->locale); - $this->value = $this->valueObj->toArray(); + if(!(empty($val['day']) || empty($val['month']) || empty($val['year']))) { + $this->valueObj = new Zend_Date($val, null, $this->locale); + $this->value = $this->valueObj->toArray(); + } else { + $this->value = $val; + $this->valueObj = null; + } } // load ISO date from database (usually through Form->loadDataForm()) else if(!empty($val) && Zend_Date::isDate($val, $this->getConfig('datavalueformat'), $this->locale)) { diff --git a/forms/OptionsetField.php b/forms/OptionsetField.php index 50a39f6c0..353f8201d 100644 --- a/forms/OptionsetField.php +++ b/forms/OptionsetField.php @@ -28,10 +28,10 @@ * * * //Database request for the object - * $myDoSet = DataObject::get("FooBars",""); + * $myDoSet = DataList::create("FooBars",""); * if($myDoSet){ * // This returns an array of ID => Title - * $map = $myDoSet->toDropDownMap(); + * $map = $myDoSet->map(); * * // Instantiate the OptionsetField * $FieldList = new FieldList( diff --git a/forms/TreeDropdownField.php b/forms/TreeDropdownField.php index 73282d113..2f62d7c8e 100644 --- a/forms/TreeDropdownField.php +++ b/forms/TreeDropdownField.php @@ -343,7 +343,7 @@ class TreeDropdownField extends FormField { class TreeDropdownField_Readonly extends TreeDropdownField { protected $readonly = true; - function Field() { + function Field($properties = array()) { $fieldName = $this->labelField; if($this->value) { $keyObj = $this->objectForKey($this->value); @@ -361,4 +361,4 @@ class TreeDropdownField_Readonly extends TreeDropdownField { $field->setForm($this->form); return $field->Field(); } -} \ No newline at end of file +} diff --git a/javascript/HtmlEditorField.js b/javascript/HtmlEditorField.js index 16b3bd770..e6852b574 100644 --- a/javascript/HtmlEditorField.js +++ b/javascript/HtmlEditorField.js @@ -782,8 +782,8 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE; return { 'src' : this.find(':input[name=URL]').val(), 'alt' : this.find(':input[name=AltText]').val(), - 'width' : width ? parseInt(width, 10) + "px" : null, - 'height' : height ? parseInt(height, 10) + "px" : null, + 'width' : width ? parseInt(width, 10) : null, + 'height' : height ? parseInt(height, 10) : null, 'title' : this.find(':input[name=Title]').val(), 'class' : this.find(':input[name=CSSClass]').val() }; diff --git a/javascript/lang/en_US.js b/javascript/lang/en_US.js index efabd2c6e..3f5967af8 100644 --- a/javascript/lang/en_US.js +++ b/javascript/lang/en_US.js @@ -11,6 +11,7 @@ if(typeof(ss) == 'undefined' || typeof(ss.i18n) == 'undefined') { 'UNIQUEFIELD.CANNOTLEAVEEMPTY': 'This field cannot be left empty', 'RESTRICTEDTEXTFIELD.CHARCANTBEUSED': "The character '%s' cannot be used in this field", 'UPDATEURL.CONFIRM': 'Would you like me to change the URL to:\n\n%s/\n\nClick Ok to change the URL, click Cancel to leave it as:\n\n%s', + 'UPDATEURL.CONFIRMURLCHANGED':'The URL has been changed to\n"%s"', 'FILEIFRAMEFIELD.DELETEFILE': 'Delete File', 'FILEIFRAMEFIELD.UNATTACHFILE': 'Un-Attach File', 'FILEIFRAMEFIELD.DELETEIMAGE': 'Delete Image', diff --git a/model/Aggregate.php b/model/Aggregate.php index 77a483db3..e2fd134ff 100644 --- a/model/Aggregate.php +++ b/model/Aggregate.php @@ -90,7 +90,7 @@ class Aggregate extends ViewableData { * This gets the aggregate function * */ - public function XML_val($name, $args) { + public function XML_val($name, $args = null, $cache = false) { $func = strtoupper( strpos($name, 'get') === 0 ? substr($name, 3) : $name ); $attribute = $args ? $args[0] : 'ID'; diff --git a/model/DataExtension.php b/model/DataExtension.php index 614825997..7d8e9c172 100644 --- a/model/DataExtension.php +++ b/model/DataExtension.php @@ -131,7 +131,7 @@ abstract class DataExtension extends Extension { * @return array Returns a map where the keys are db, has_one, etc, and * the values are additional fields/relations to be defined. */ - function extraStatics($class=null, $extension=null) { + function extraStatics($class = null, $extension = null) { return array(); } diff --git a/model/DataList.php b/model/DataList.php index 1984af0df..721cedd50 100644 --- a/model/DataList.php +++ b/model/DataList.php @@ -658,7 +658,7 @@ class DataList extends ViewableData implements SS_List, SS_Filterable, SS_Sortab * * Example: Get members from all Groups: * - * DataObject::get("Group")->relation("Members") + * DataList::Create("Group")->relation("Members") * * @param string $relationName * @return HasManyList|ManyManyList @@ -668,6 +668,10 @@ class DataList extends ViewableData implements SS_List, SS_Filterable, SS_Sortab return singleton($this->dataClass)->$relationName()->forForeignID($ids); } + function dbObject($fieldName) { + return singleton($this->dataClass)->dbObject($fieldName); + } + /** * Add a number of items to the component set. * diff --git a/model/DataObject.php b/model/DataObject.php index 24c98d805..024a01e15 100644 --- a/model/DataObject.php +++ b/model/DataObject.php @@ -309,7 +309,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity else $passed = "The value '$record'"; user_error("DataObject::__construct passed $passed. It's supposed to be passed an array, - taken straight from the database. Perhaps you should use DataObject::get_one instead?", E_USER_WARNING); + taken straight from the database. Perhaps you should use DataList::create()->First(); instead?", E_USER_WARNING); $record = null; } @@ -2404,7 +2404,12 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity // Traverse dot syntax $component = $this; foreach($parts as $relation) { - $component = $component->$relation(); + if($component instanceof SS_List) { + if(method_exists($component,$relation)) $component = $component->$relation(); + else $component = $component->relation($relation); + } else { + $component = $component->$relation(); + } } $object = $component->dbObject($fieldName); @@ -2436,7 +2441,12 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity // Traverse dot syntax $component = $this; foreach($parts as $relation) { - $component = $component->$relation(); + if($component instanceof SS_List) { + if(method_exists($component,$relation)) $component = $component->$relation(); + else $component = $component->relation($relation); + } else { + $component = $component->$relation(); + } } return $component->$fieldName; @@ -2469,10 +2479,10 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity } /** - * @deprecated 3.0 Use DataObject::get and DataList to do your querying + * @deprecated 3.0 Use DataList::create and DataList to do your querying */ public function buildSQL($filter = "", $sort = "", $limit = "", $join = "", $restrictClasses = true, $having = "") { - Deprecation::notice('3.0', 'Use DataObject::get and DataList to do your querying instead.'); + Deprecation::notice('3.0', 'Use DataList::create and DataList to do your querying instead.'); return $this->extendedSQL($filter, $sort, $limit, $join, $having); } @@ -2483,10 +2493,10 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity private static $cache_buildSQL_query; /** - * @deprecated 3.0 Use DataObject::get and DataList to do your querying + * @deprecated 3.0 Use DataList::create and DataList to do your querying */ public function extendedSQL($filter = "", $sort = "", $limit = "", $join = ""){ - Deprecation::notice('3.0', 'Use DataObject::get and DataList to do your querying instead.'); + Deprecation::notice('3.0', 'Use DataList::create and DataList to do your querying instead.'); $dataList = DataObject::get($this->class, $filter, $sort, $join, $limit); return $dataList->dataQuery()->query(); } @@ -2521,10 +2531,10 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity } /** - * @deprecated 3.0 Use DataObject::get and DataList to do your querying + * @deprecated 3.0 Use DataList::create and DataList to do your querying */ public function Aggregate($class = null) { - Deprecation::notice('3.0', 'Use DataObject::get and DataList to do your querying instead.'); + Deprecation::notice('3.0', 'Use DataList::create and DataList to do your querying instead.'); if($class) { $list = new DataList($class); @@ -2538,19 +2548,18 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity } /** - * @deprecated 3.0 Use DataObject::get and DataList to do your querying + * @deprecated 3.0 Use DataList::create and DataList to do your querying */ public function RelationshipAggregate($relationship) { - Deprecation::notice('3.0', 'Use DataObject::get and DataList to do your querying instead.'); + Deprecation::notice('3.0', 'Use DataList::create and DataList to do your querying instead.'); return $this->$relationship(); } /** - * The internal function that actually performs the querying for get(). - * DataObject::get("Table","filter") is the same as singleton("Table")->instance_get("filter") + * DataList::create("Table")->where("filter") is the same as singleton("Table")->instance_get("filter") * - * @deprecated 3.0 Use DataObject::get and DataList to do your querying + * @deprecated 3.0 Use DataList::create and DataList to do your querying * * @param string $filter A filter to be inserted into the WHERE clause. * @param string $sort A sort expression to be inserted into the ORDER BY clause. If omitted, self::$default_sort will be used. @@ -2561,7 +2570,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * @return mixed The objects matching the filter, in the class specified by $containerClass */ public function instance_get($filter = "", $sort = "", $join = "", $limit="", $containerClass = "DataObjectSet") { - Deprecation::notice('3.0', 'Use DataObject::get and DataList to do your querying instead.'); + Deprecation::notice('3.0', 'Use DataList::create and DataList to do your querying instead.'); return self::get($this->class, $filter, $sort, $join, $limit, $containerClass); } @@ -2655,7 +2664,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * When false will just clear session-local cached data * */ - public function flushCache($persistant=true) { + public function flushCache($persistant = true) { if($persistant) Aggregate::flushCache($this->class); if($this->class == 'DataObject') { @@ -2693,7 +2702,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity /** * Does the hard work for get_one() * - * @deprecated 3.0 Use DataObject::get_one() instead + * @deprecated 3.0 Use DataList::create($this->class)->where($filter)->sort($orderby)->First() instead * * @uses DataExtension->augmentSQL() * @@ -2702,7 +2711,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * @return DataObject The first item matching the query */ public function instance_get_one($filter, $orderby = null) { - Deprecation::notice('3.0', 'Use DataObject::get_one() instead.'); + Deprecation::notice('3.0', 'Use DataList::create($this->class)->where($filter)->sort($orderby)->First() instead.'); return DataObject::get_one($this->class, $filter, true, $orderby); } @@ -3343,4 +3352,4 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity } } -} \ No newline at end of file +} diff --git a/model/DataQuery.php b/model/DataQuery.php index 2dad960fd..03d32c9f3 100644 --- a/model/DataQuery.php +++ b/model/DataQuery.php @@ -145,7 +145,7 @@ class DataQuery { if($this->dataClass != $baseClass) { // Get the ClassName values to filter to $classNames = ClassInfo::subclassesFor($this->dataClass); - if(!$classNames) user_error("DataObject::get() Can't find data sub-classes for '$callerClass'"); + if(!$classNames) user_error("DataList::create() Can't find data sub-classes for '$callerClass'"); $query->where[] = "\"$baseClass\".\"ClassName\" IN ('" . implode("','", $classNames) . "')"; } } diff --git a/model/Hierarchy.php b/model/Hierarchy.php index 20b33e49b..b8e988e3f 100644 --- a/model/Hierarchy.php +++ b/model/Hierarchy.php @@ -674,12 +674,12 @@ class Hierarchy extends DataExtension { self::$expanded = array(); self::$treeOpened = array(); } - - function reset() { + + public static function reset() { self::$marked = array(); self::$expanded = array(); self::$treeOpened = array(); } + } - diff --git a/model/Image.php b/model/Image.php index f94ff443c..658bd5898 100644 --- a/model/Image.php +++ b/model/Image.php @@ -73,8 +73,8 @@ class Image extends File { parent::defineMethods(); } - function getCMSFields() { - $fields = parent::getCMSFields(); + function getCMSFields($params = null) { + $fields = parent::getCMSFields($params); $urlLink = "
                                    "; $urlLink .= ""; diff --git a/model/SQLQuery.php b/model/SQLQuery.php index c283474a5..6d66e1cc9 100644 --- a/model/SQLQuery.php +++ b/model/SQLQuery.php @@ -554,7 +554,7 @@ class SQLQuery { * Return the number of rows in this query if the limit were removed. Useful in paged data sets. * @return int */ - function unlimitedRowCount( $column = null) { + function unlimitedRowCount($column = null) { // we can't clear the select if we're relying on its output by a HAVING clause if(count($this->having)) { $records = $this->execute(); diff --git a/model/Versioned.php b/model/Versioned.php index ce96c9338..dc9a62500 100644 --- a/model/Versioned.php +++ b/model/Versioned.php @@ -132,7 +132,7 @@ class Versioned extends DataExtension { * Augment the the SQLQuery that is created by the DataQuery * @todo Should this all go into VersionedDataQuery? */ - function augmentSQL(SQLQuery &$query, DataQuery &$dataQuery) { + function augmentSQL(SQLQuery &$query, DataQuery &$dataQuery = null) { $baseTable = ClassInfo::baseDataClass($dataQuery->dataClass()); switch($dataQuery->getQueryParam('Versioned.mode')) { @@ -1006,7 +1006,7 @@ class Versioned extends DataExtension { } /** - * Return the equivalent of a DataObject::get() call, querying the latest + * Return the equivalent of a DataList::create() call, querying the latest * version of each page stored in the (class)_versions tables. * * In particular, this will query deleted records as well as active ones. diff --git a/model/fieldtypes/Currency.php b/model/fieldtypes/Currency.php index 23a10c734..5d0d2b6ec 100644 --- a/model/fieldtypes/Currency.php +++ b/model/fieldtypes/Currency.php @@ -41,7 +41,7 @@ class Currency extends Decimal { else return $val; } - function setValue($value) { + function setValue($value, $record = null) { $matches = null; if(is_numeric($value)) { $this->value = $value; diff --git a/model/fieldtypes/Date.php b/model/fieldtypes/Date.php index 60d3c834f..804fad3a1 100644 --- a/model/fieldtypes/Date.php +++ b/model/fieldtypes/Date.php @@ -20,7 +20,7 @@ */ class Date extends DBField { - function setValue($value) { + function setValue($value, $record = null) { if($value === false || $value === null || (is_string($value) && !strlen($value))) { // don't try to evaluate empty values with strtotime() below, as it returns "1970-01-01" when it should be saved as NULL in database $this->value = null; diff --git a/model/fieldtypes/Datetime.php b/model/fieldtypes/Datetime.php index ac4536877..b655eff5a 100644 --- a/model/fieldtypes/Datetime.php +++ b/model/fieldtypes/Datetime.php @@ -25,7 +25,7 @@ */ class SS_Datetime extends Date { - function setValue($value) { + function setValue($value, $record = null) { if($value === false || $value === null || (is_string($value) && !strlen($value))) { // don't try to evaluate empty values with strtotime() below, as it returns "1970-01-01" when it should be saved as NULL in database $this->value = null; diff --git a/model/fieldtypes/HTMLText.php b/model/fieldtypes/HTMLText.php index 046be3262..b90c98681 100644 --- a/model/fieldtypes/HTMLText.php +++ b/model/fieldtypes/HTMLText.php @@ -136,7 +136,7 @@ class HTMLText extends Text { return new HtmlEditorField($this->name, $title); } - public function scaffoldSearchField($title = null) { + public function scaffoldSearchField($title = null, $params = null) { return new TextField($this->name, $title); } diff --git a/scss/AssetUploadField.scss b/scss/AssetUploadField.scss index df2f25d50..9414a01fe 100644 --- a/scss/AssetUploadField.scss +++ b/scss/AssetUploadField.scss @@ -8,6 +8,11 @@ @include box-shadow(none); } +body.cms.ss-uploadfield-edit-iframe { + padding: $grid-x*2; + overflow: auto; +} + .ss-assetuploadfield { h3 { border-bottom: 1px solid $color-shadow-light; @@ -162,7 +167,6 @@ clear: both; iframe { - margin: $grid-x*2; width: 100%; } } diff --git a/scss/GridField.scss b/scss/GridField.scss index d70194d88..c3cea9f9e 100644 --- a/scss/GridField.scss +++ b/scss/GridField.scss @@ -98,6 +98,16 @@ $gf_grid_x: 16px; tbody { background: #FFF; td { + // Give browser some hints on which cols take priority: + // The last column (buttons) should always shrink to fit. + // Overwritten for IE7, which doesn't support this. + width: 100%; + &.col-buttons { + width: auto; + text-align: right; + white-space: nowrap; + } + button { border: none; background: none; @@ -118,13 +128,9 @@ $gf_grid_x: 16px; display:inline-block; width:$gf_grid_x; height:20px; //min height to fit the edit icon - text-indent:-9999em; + text-indent:9999em; background: url(../images/icons/document--pencil.png) no-repeat 0 1px; } - - &.col-buttons { - white-space: nowrap; - } } } @@ -265,6 +271,9 @@ $gf_grid_x: 16px; } button { + &#action_gridfield_relationadd:hover { + color: #444 !important; /* Not sure why IE think it needs this */ + } &:hover { color: #ccc !important; /* Not sure why IE think it needs this */ } diff --git a/security/Authenticator.php b/security/Authenticator.php index 0a226a89a..0d38b9e1c 100644 --- a/security/Authenticator.php +++ b/security/Authenticator.php @@ -37,9 +37,8 @@ abstract class Authenticator extends Object { * @return bool|Member Returns FALSE if authentication fails, otherwise * the member object */ - public abstract static function authenticate($RAW_data, - Form $form = null); - + public static function authenticate($RAW_data, Form $form = null) { + } /** * Method that creates the login form for this authentication method @@ -49,7 +48,8 @@ abstract class Authenticator extends Object { * @return Form Returns the login form to use with this authentication * method */ - public abstract static function get_login_form(Controller $controller); + public static function get_login_form(Controller $controller) { + } /** @@ -57,7 +57,8 @@ abstract class Authenticator extends Object { * * @return string Returns the name of the authentication method. */ - public abstract static function get_name(); + public static function get_name() { + } public static function register($authenticator) { self::register_authenticator($authenticator); diff --git a/security/Group.php b/security/Group.php index ee52b4521..c4127880e 100755 --- a/security/Group.php +++ b/security/Group.php @@ -59,7 +59,7 @@ class Group extends DataObject { * * @return FieldList */ - public function getCMSFields() { + public function getCMSFields($params = null) { Requirements::javascript(SAPPHIRE_DIR . '/javascript/PermissionCheckboxSetField.js'); $fields = new FieldList( @@ -85,7 +85,10 @@ class Group extends DataObject { ) ); - $parentidfield->setRightTitle('' . _t('Group.GroupReminder', 'If you choose a parent group, this group will take all it\'s roles') . ''); + $parentidfield->setAttribute( + 'title', + _t('Group.GroupReminder', 'If you choose a parent group, this group will take all it\'s roles') + ); // Filter permissions // TODO SecurityAdmin coupling, not easy to get to the form fields through GridFieldDetailForm @@ -334,17 +337,21 @@ class Group extends DataObject { if(!$this->Code) $this->setCode($this->Title); } } - - function onAfterDelete() { - parent::onAfterDelete(); - + + function onBeforeDelete() { + parent::onBeforeDelete(); + + // if deleting this group, delete it's children as well + foreach($this->Groups() as $group) { + $group->delete(); + } + // Delete associated permissions - $permissions = $this->Permissions(); - foreach ( $permissions as $permission ) { + foreach($this->Permissions() as $permission) { $permission->delete(); } } - + /** * Checks for permission-code CMS_ACCESS_SecurityAdmin. * If the group has ADMIN permissions, it requires the user to have ADMIN permissions as well. diff --git a/security/Member.php b/security/Member.php index b1e12a1c7..e118ae013 100644 --- a/security/Member.php +++ b/security/Member.php @@ -1084,7 +1084,7 @@ class Member extends DataObject implements TemplateGlobalProvider { * @return FieldList Return a FieldList of fields that would appropriate for * editing this member. */ - public function getCMSFields() { + public function getCMSFields($params = null) { require_once('Zend/Date.php'); $fields = parent::getCMSFields(); diff --git a/security/PasswordEncryptor.php b/security/PasswordEncryptor.php index 813c0f015..2574d7876 100644 --- a/security/PasswordEncryptor.php +++ b/security/PasswordEncryptor.php @@ -139,13 +139,7 @@ class PasswordEncryptor_PHPHash extends PasswordEncryptor { } function encrypt($password, $salt = null, $member = null) { - if(function_exists('hash')) { - // Available in PHP 5.1+ only - return hash($this->algorithm, $password . $salt); - } else { - // Fallback to global built-in methods - return call_user_func($this->algorithm, $password . $salt); - } + return hash($this->algorithm, $password . $salt); } } diff --git a/security/PermissionRole.php b/security/PermissionRole.php index 3f2dd0da1..3c1a00193 100644 --- a/security/PermissionRole.php +++ b/security/PermissionRole.php @@ -33,8 +33,8 @@ class PermissionRole extends DataObject { static $plural_name = 'Roles'; - function getCMSFields() { - $fields = parent::getCMSFields(); + function getCMSFields($params = null) { + $fields = parent::getCMSFields($params); $fields->removeFieldFromTab('Root', 'Codes'); $fields->removeFieldFromTab('Root', 'Groups'); diff --git a/tests/control/RequestHandlingTest.php b/tests/control/RequestHandlingTest.php index 72b62fe88..0454332a5 100644 --- a/tests/control/RequestHandlingTest.php +++ b/tests/control/RequestHandlingTest.php @@ -329,7 +329,7 @@ class RequestHandlingTest_Controller extends Controller implements TestOnly { $this->httpError(404, 'This page does not exist.'); } - public function getViewer(){ + public function getViewer($action) { return new SSViewer('BlankPage'); } } @@ -384,7 +384,7 @@ class RequestHandlingTest_FormActionController extends Controller { return 'formactionInAllowedActions'; } - public function getViewer(){ + public function getViewer($action = null) { return new SSViewer('BlankPage'); } diff --git a/tests/core/ConvertTest.php b/tests/core/ConvertTest.php index b94b79cc7..5e82eec0f 100644 --- a/tests/core/ConvertTest.php +++ b/tests/core/ConvertTest.php @@ -101,6 +101,7 @@ class ConvertTest extends SapphireTest { $this->assertEquals(3, count($decoded), '3 items in the decoded array'); $this->assertContains('Bloggs', $decoded, 'Contains "Bloggs" value in decoded array'); $this->assertContains('Jones', $decoded, 'Contains "Jones" value in decoded array'); + $this->assertContains('Structure', $decoded['My']['Complicated']); } function testJSON2Obj() { @@ -121,4 +122,4 @@ class ConvertTest extends SapphireTest { $this->assertEquals('foos-bar-2', Convert::raw2url('foo\'s [bar] (2)')); } -} \ No newline at end of file +} diff --git a/tests/forms/DateFieldTest.php b/tests/forms/DateFieldTest.php index 24d990cd2..5bb1c29e8 100644 --- a/tests/forms/DateFieldTest.php +++ b/tests/forms/DateFieldTest.php @@ -135,7 +135,18 @@ class DateFieldTest extends SapphireTest { // $f = new DateField('Date', 'Date', array('day' => 9999, 'month' => 9999, 'year' => 9999)); // $this->assertFalse($f->validate(new RequiredFields())); } - + + function testValidateEmptyArrayValuesSetsNullForValueObject() { + $f = new DateField('Date', 'Date'); + $f->setConfig('dmyfields', true); + + $f->setValue(array('day' => '', 'month' => '', 'year' => '')); + $this->assertNull($f->dataValue()); + + $f->setValue(array('day' => null, 'month' => null, 'year' => null)); + $this->assertNull($f->dataValue()); + } + function testValidateArrayValue() { $f = new DateField('Date', 'Date'); $this->assertTrue($f->validateArrayValue(array('day' => 29, 'month' => 03, 'year' => 2003))); diff --git a/tests/forms/FormScaffolderTest.php b/tests/forms/FormScaffolderTest.php index 365d9d0ac..e95874866 100644 --- a/tests/forms/FormScaffolderTest.php +++ b/tests/forms/FormScaffolderTest.php @@ -128,11 +128,13 @@ class FormScaffolderTest_ArticleExtension extends DataExtension implements TestO static $db = array( 'ExtendedField' => 'Varchar' ); - function updateCMSFields(&$fields) { + + function updateCMSFields(FieldList $fields) { $fields->addFieldToTab('Root.Main', new TextField('AddedExtensionField') ); } + } DataObject::add_extension('FormScaffolderTest_Article', 'FormScaffolderTest_ArticleExtension'); diff --git a/tests/forms/FormTest.php b/tests/forms/FormTest.php index 7ad8565fb..d6e0b5fa7 100644 --- a/tests/forms/FormTest.php +++ b/tests/forms/FormTest.php @@ -468,7 +468,7 @@ class FormTest_Controller extends Controller implements TestOnly { return $this->redirectBack(); } - function getViewer(){ + function getViewer($action = null) { return new SSViewer('BlankPage'); } @@ -505,7 +505,7 @@ class FormTest_ControllerWithSecurityToken extends Controller implements TestOnl return $this->redirectBack(); } - function getViewer(){ + function getViewer($action = null) { return new SSViewer('BlankPage'); } } diff --git a/tests/forms/gridfield/GridFieldAddExistingAutocompleterTest.php b/tests/forms/gridfield/GridFieldAddExistingAutocompleterTest.php index af7397865..0d0eecd30 100644 --- a/tests/forms/gridfield/GridFieldAddExistingAutocompleterTest.php +++ b/tests/forms/gridfield/GridFieldAddExistingAutocompleterTest.php @@ -33,7 +33,7 @@ class GridFieldAddExistingAutocompleterTest extends FunctionalTest { ); $this->assertFalse($response->isError()); $result = Convert::json2array($response->getBody()); - $this->assertFalse($result); + $this->assertEmpty($result, 'The output is either an empty array or boolean FALSE'); } function testAdd() { @@ -80,4 +80,4 @@ class GridFieldAddExistingAutocompleterTest_Controller extends Controller implem $field = new GridField('testfield', 'testfield', $player->Teams(), $config); return new Form($this, 'Form', new FieldList($field), new FieldList()); } -} \ No newline at end of file +} diff --git a/tests/forms/gridfield/GridFieldDeleteActionTest.php b/tests/forms/gridfield/GridFieldDeleteActionTest.php index 3c09d7b6a..b29196cd8 100644 --- a/tests/forms/gridfield/GridFieldDeleteActionTest.php +++ b/tests/forms/gridfield/GridFieldDeleteActionTest.php @@ -31,7 +31,7 @@ class GridFieldDeleteActionTest extends SapphireTest { // Check that there are content $this->assertEquals(4, count($content->getBySelector('.ss-gridfield-item'))); // Make sure that there are no delete buttons - $this->assertEmpty($content->getBySelector('.gridfield-button-delete'), 'Delete buttons should not show when not logged in.'); + $this->assertEquals(0, count($content->getBySelector('.gridfield-button-delete')), 'Delete buttons should not show when not logged in.'); } public function testShowDeleteButtonsWithAdminPermission() { diff --git a/tests/forms/gridfield/GridFieldDetailFormTest.php b/tests/forms/gridfield/GridFieldDetailFormTest.php index c66a9fe9e..d71655811 100644 --- a/tests/forms/gridfield/GridFieldDetailFormTest.php +++ b/tests/forms/gridfield/GridFieldDetailFormTest.php @@ -140,8 +140,8 @@ class GridFieldDetailFormTest_Person extends DataObject implements TestOnly { 'Categories' => 'GridFieldDetailFormTest_Category' ); - function getCMSFields() { - $fields = parent::getCMSFields(); + function getCMSFields($params = null) { + $fields = parent::getCMSFields($params); // TODO No longer necessary once FormScaffolder uses GridField $fields->replaceField('Categories', Object::create('GridField', 'Categories', 'Categories', @@ -162,8 +162,8 @@ class GridFieldDetailFormTest_PeopleGroup extends DataObject implements TestOnly 'People' => 'GridFieldDetailFormTest_Person' ); - function getCMSFields() { - $fields = parent::getCMSFields(); + function getCMSFields($params = null) { + $fields = parent::getCMSFields($params); // TODO No longer necessary once FormScaffolder uses GridField $fields->replaceField('People', Object::create('GridField', 'People', 'People', @@ -184,8 +184,8 @@ class GridFieldDetailFormTest_Category extends DataObject implements TestOnly { 'People' => 'GridFieldDetailFormTest_Person' ); - function getCMSFields() { - $fields = parent::getCMSFields(); + function getCMSFields($params = null) { + $fields = parent::getCMSFields($params); // TODO No longer necessary once FormScaffolder uses GridField $fields->replaceField('People', Object::create('GridField', 'People', 'People', diff --git a/tests/forms/gridfield/GridFieldEditButtonTest.php b/tests/forms/gridfield/GridFieldEditButtonTest.php index 13b3b045b..10cf20d94 100644 --- a/tests/forms/gridfield/GridFieldEditButtonTest.php +++ b/tests/forms/gridfield/GridFieldEditButtonTest.php @@ -32,7 +32,7 @@ class GridFieldEditButtonTest extends SapphireTest { // Check that there are content $this->assertEquals(3, count($content->getBySelector('.ss-gridfield-item'))); // Make sure that there are no edit links - $this->assertEmpty($content->getBySelector('.edit-link'), 'Edit links should not show when not logged in.'); + $this->assertEquals(0, count($content->getBySelector('.edit-link')), 'Edit links should not show when not logged in.'); } public function testShowEditLinksWithAdminPermission() { diff --git a/tests/forms/uploadfield/UploadFieldTest.php b/tests/forms/uploadfield/UploadFieldTest.php index d25231373..0e6cff31b 100644 --- a/tests/forms/uploadfield/UploadFieldTest.php +++ b/tests/forms/uploadfield/UploadFieldTest.php @@ -567,21 +567,21 @@ static $many_many = array( class UploadFieldTest_FileExtension extends DataExtension implements TestOnly { - function extraStatics() { + function extraStatics($class = null, $extension = null) { return array( 'has_one' => array('Record' => 'UploadFieldTest_Record') ); } - function canDelete() { + function canDelete($member = null) { if($this->owner->Name == 'nodelete.txt') return false; } - function canEdit() { + function canEdit($member = null) { if($this->owner->Name == 'noedit.txt') return false; } - function canView() { + function canView($member = null) { if($this->owner->Name == 'noview.txt') return false; } } @@ -655,4 +655,4 @@ class UploadFieldTest_Controller extends Controller implements TestOnly { } -} \ No newline at end of file +} diff --git a/tests/model/AggregateTest.php b/tests/model/AggregateTest.php index 615b59361..2c1dc15bc 100644 --- a/tests/model/AggregateTest.php +++ b/tests/model/AggregateTest.php @@ -73,13 +73,15 @@ class AggregateTest extends SapphireTest { * Test basic aggregation on a passed type */ function testTypeSpecifiedAggregate() { + $foo = $this->objFromFixture('AggregateTest_Foo', 'foo1'); + // Template style access - $this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->XML_val('Max', array('Foo')), 9); - $this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->XML_val('Max', array('Fab')), 3); + $this->assertEquals($foo->Aggregate('AggregateTest_Foo')->XML_val('Max', array('Foo')), 9); + $this->assertEquals($foo->Aggregate('AggregateTest_Fab')->XML_val('Max', array('Fab')), 3); // PHP style access - $this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->Max('Foo'), 9); - $this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->Max('Fab'), 3); + $this->assertEquals($foo->Aggregate('AggregateTest_Foo')->Max('Foo'), 9); + $this->assertEquals($foo->Aggregate('AggregateTest_Fab')->Max('Fab'), 3); } /* */ @@ -90,7 +92,7 @@ class AggregateTest extends SapphireTest { function testAutoTypeAggregate() { $foo = $this->objFromFixture('AggregateTest_Foo', 'foo1'); $fab = $this->objFromFixture('AggregateTest_Fab', 'fab1'); - + // Template style access $this->assertEquals($foo->Aggregate()->XML_val('Max', array('Foo')), 9); $this->assertEquals($fab->Aggregate()->XML_val('Max', array('Fab')), 3); @@ -106,13 +108,15 @@ class AggregateTest extends SapphireTest { * @return unknown_type */ function testBaseFieldAggregate() { + $foo = $this->objFromFixture('AggregateTest_Foo', 'foo1'); + $this->assertEquals( - $this->formatDate(DataObject::Aggregate('AggregateTest_Foo')->Max('LastEdited')), + $this->formatDate($foo->Aggregate('AggregateTest_Foo')->Max('LastEdited')), $this->formatDate(DataObject::get_one('AggregateTest_Foo', '', '', '"LastEdited" DESC')->LastEdited) ); $this->assertEquals( - $this->formatDate(DataObject::Aggregate('AggregateTest_Foo')->Max('Created')), + $this->formatDate($foo->Aggregate('AggregateTest_Foo')->Max('Created')), $this->formatDate(DataObject::get_one('AggregateTest_Foo', '', '', '"Created" DESC')->Created) ); } @@ -122,13 +126,14 @@ class AggregateTest extends SapphireTest { * Test aggregation takes place on the passed type & it's children only */ function testChildAggregate() { - + $foo = $this->objFromFixture('AggregateTest_Foo', 'foo1'); + // For base classes, aggregate is calculcated on it and all children classes - $this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->Max('Foo'), 9); + $this->assertEquals($foo->Aggregate('AggregateTest_Foo')->Max('Foo'), 9); // For subclasses, aggregate is calculated for that subclass and it's children only - $this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->Max('Foo'), 9); - $this->assertEquals(DataObject::Aggregate('AggregateTest_Fac')->Max('Foo'), 6); + $this->assertEquals($foo->Aggregate('AggregateTest_Fab')->Max('Foo'), 9); + $this->assertEquals($foo->Aggregate('AggregateTest_Fac')->Max('Foo'), 6); } /* */ @@ -145,35 +150,35 @@ class AggregateTest extends SapphireTest { * Test cache is correctly flushed on write */ function testCacheFlushing() { - + $foo = $this->objFromFixture('AggregateTest_Foo', 'foo1'); + $fab = $this->objFromFixture('AggregateTest_Fab', 'fab1'); + // For base classes, aggregate is calculcated on it and all children classes - $this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->Max('Foo'), 9); + $this->assertEquals($fab->Aggregate('AggregateTest_Foo')->Max('Foo'), 9); // For subclasses, aggregate is calculated for that subclass and it's children only - $this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->Max('Foo'), 9); - $this->assertEquals(DataObject::Aggregate('AggregateTest_Fac')->Max('Foo'), 6); - - $foo = $this->objFromFixture('AggregateTest_Foo', 'foo1'); + $this->assertEquals($fab->Aggregate('AggregateTest_Fab')->Max('Foo'), 9); + $this->assertEquals($fab->Aggregate('AggregateTest_Fac')->Max('Foo'), 6); + $foo->Foo = 12; $foo->write(); // For base classes, aggregate is calculcated on it and all children classes - $this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->Max('Foo'), 12); + $this->assertEquals($fab->Aggregate('AggregateTest_Foo')->Max('Foo'), 12); // For subclasses, aggregate is calculated for that subclass and it's children only - $this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->Max('Foo'), 9); - $this->assertEquals(DataObject::Aggregate('AggregateTest_Fac')->Max('Foo'), 6); + $this->assertEquals($fab->Aggregate('AggregateTest_Fab')->Max('Foo'), 9); + $this->assertEquals($fab->Aggregate('AggregateTest_Fac')->Max('Foo'), 6); - $fab = $this->objFromFixture('AggregateTest_Fab', 'fab1'); $fab->Foo = 15; $fab->write(); // For base classes, aggregate is calculcated on it and all children classes - $this->assertEquals(DataObject::Aggregate('AggregateTest_Foo')->Max('Foo'), 15); + $this->assertEquals($fab->Aggregate('AggregateTest_Foo')->Max('Foo'), 15); // For subclasses, aggregate is calculated for that subclass and it's children only - $this->assertEquals(DataObject::Aggregate('AggregateTest_Fab')->Max('Foo'), 15); - $this->assertEquals(DataObject::Aggregate('AggregateTest_Fac')->Max('Foo'), 6); + $this->assertEquals($fab->Aggregate('AggregateTest_Fab')->Max('Foo'), 15); + $this->assertEquals($fab->Aggregate('AggregateTest_Fac')->Max('Foo'), 6); } /* */ diff --git a/tests/model/DataDifferencerTest.php b/tests/model/DataDifferencerTest.php index c2cee4898..443173fc9 100644 --- a/tests/model/DataDifferencerTest.php +++ b/tests/model/DataDifferencerTest.php @@ -62,8 +62,8 @@ class DataDifferencerTest_Object extends DataObject implements TestOnly { 'HasOneRelation' => 'DataDifferencerTest_HasOneRelationObject' ); - function getCMSFields() { - $fields = parent::getCMSFields(); + function getCMSFields($params = null) { + $fields = parent::getCMSFields($params); $choices = array( 'a' => 'a', 'b' => 'b', @@ -103,4 +103,4 @@ class DataDifferencerTest_MockImage extends Image implements TestOnly { // Skip aktual generation return $gd; } -} \ No newline at end of file +} diff --git a/tests/model/DateTest.php b/tests/model/DateTest.php index f09da2c86..00a344a1f 100644 --- a/tests/model/DateTest.php +++ b/tests/model/DateTest.php @@ -32,16 +32,16 @@ class DateTest extends SapphireTest { } function testNiceDate() { - $this->assertEquals('01/04/2008', DBField::create('Date', 1206968400)->Nice(), + $this->assertEquals('31/03/2008', DBField::create('Date', 1206968400)->Nice(), "Date->Nice() works with timestamp integers" ); - $this->assertEquals('31/03/2008', DBField::create('Date', 1206882000)->Nice(), + $this->assertEquals('30/03/2008', DBField::create('Date', 1206882000)->Nice(), "Date->Nice() works with timestamp integers" ); - $this->assertEquals('01/04/2008', DBField::create('Date', '1206968400')->Nice(), + $this->assertEquals('31/03/2008', DBField::create('Date', '1206968400')->Nice(), "Date->Nice() works with timestamp strings" ); - $this->assertEquals('31/03/2008', DBField::create('Date', '1206882000')->Nice(), + $this->assertEquals('30/03/2008', DBField::create('Date', '1206882000')->Nice(), "Date->Nice() works with timestamp strings" ); $this->assertEquals('04/03/2003', DBField::create('Date', '4/3/03')->Nice(), @@ -74,16 +74,16 @@ class DateTest extends SapphireTest { } function testLongDate() { - $this->assertEquals('1 April 2008', DBField::create('Date', 1206968400)->Long(), + $this->assertEquals('31 March 2008', DBField::create('Date', 1206968400)->Long(), "Date->Long() works with numeric timestamp" ); - $this->assertEquals('1 April 2008', DBField::create('Date', '1206968400')->Long(), + $this->assertEquals('31 March 2008', DBField::create('Date', '1206968400')->Long(), "Date->Long() works with string timestamp" ); - $this->assertEquals('31 March 2008', DBField::create('Date', 1206882000)->Long(), + $this->assertEquals('30 March 2008', DBField::create('Date', 1206882000)->Long(), "Date->Long() works with numeric timestamp" ); - $this->assertEquals('31 March 2008', DBField::create('Date', '1206882000')->Long(), + $this->assertEquals('30 March 2008', DBField::create('Date', '1206882000')->Long(), "Date->Long() works with numeric timestamp" ); $this->assertEquals('3 April 2003', DBField::create('Date', '2003-4-3')->Long(), diff --git a/tests/model/DatetimeTest.php b/tests/model/DatetimeTest.php index 910751b63..5c1483e08 100644 --- a/tests/model/DatetimeTest.php +++ b/tests/model/DatetimeTest.php @@ -35,8 +35,6 @@ class SS_DatetimeTest extends SapphireTest { } function testSetNullAndZeroValues() { - date_default_timezone_set('UTC'); - $date = DBField::create('SS_Datetime', ''); $this->assertNull($date->getValue(), 'Empty string evaluates to NULL'); diff --git a/tests/model/DbDatetimeTest.php b/tests/model/DbDatetimeTest.php index 31ce19dfe..211100284 100644 --- a/tests/model/DbDatetimeTest.php +++ b/tests/model/DbDatetimeTest.php @@ -11,6 +11,8 @@ class DbDatetimeTest extends FunctionalTest { E_USER_ERROR => 1800, E_USER_NOTICE => 5, ); + + private $adapter; /** * Check if dates match more or less. This takes into the account the db query diff --git a/tests/security/GroupTest.php b/tests/security/GroupTest.php index b3e0c08ec..dc3ea3d79 100644 --- a/tests/security/GroupTest.php +++ b/tests/security/GroupTest.php @@ -94,15 +94,6 @@ class GroupTest extends FunctionalTest { } - function testDelete() { - $adminGroup = $this->objFromFixture('Group', 'admingroup'); - - $adminGroup->delete(); - - $this->assertEquals(0, DataObject::get('Group', "\"ID\"={$adminGroup->ID}")->count(), 'Group is removed'); - $this->assertEquals(0, DataObject::get('Permission',"\"GroupID\"={$adminGroup->ID}")->count(), 'Permissions removed along with the group'); - } - function testCollateAncestorIDs() { $parentGroup = $this->objFromFixture('Group', 'parentgroup'); $childGroup = $this->objFromFixture('Group', 'childgroup'); @@ -128,11 +119,24 @@ class GroupTest extends FunctionalTest { 'Orphaned nodes dont contain invalid parent IDs' ); } + + public function testDelete() { + $group = $this->objFromFixture('Group', 'parentgroup'); + $groupID = $group->ID; + $childGroupID = $this->idFromFixture('Group', 'childgroup'); + $group->delete(); + + $this->assertEquals(0, DataObject::get('Group', "\"ID\" = {$groupID}")->Count(), 'Group is removed'); + $this->assertEquals(0, DataObject::get('Permission', "\"GroupID\" = {$groupID}")->Count(), 'Permissions removed along with the group'); + $this->assertEquals(0, DataObject::get('Group', "\"ParentID\" = {$groupID}")->Count(), 'Child groups are removed'); + $this->assertEquals(0, DataObject::get('Group', "\"ParentID\" = {$childGroupID}")->Count(), 'Grandchild groups are removed'); + } + } class GroupTest_Member extends Member implements TestOnly { - function getCMSFields() { + function getCMSFields($params = null) { $groups = DataObject::get('Group'); $groupsMap = ($groups) ? $groups->map() : false; $fields = new FieldList( diff --git a/tests/security/GroupTest.yml b/tests/security/GroupTest.yml index a0c3d8a97..13ca9f5ce 100644 --- a/tests/security/GroupTest.yml +++ b/tests/security/GroupTest.yml @@ -6,6 +6,9 @@ Group: childgroup: Code: childgroup Parent: =>Group.parentgroup + grandchildgroup: + Code: grandchildgroup + Parent: =>Group.childgroup group1: Title: Group 1 group2: @@ -26,4 +29,4 @@ GroupTest_Member: Permission: admincode: Code: ADMIN - Group: =>Group.admingroup \ No newline at end of file + Group: =>Group.admingroup diff --git a/tests/security/MemberTest.php b/tests/security/MemberTest.php index b485aecd0..5e8656760 100644 --- a/tests/security/MemberTest.php +++ b/tests/security/MemberTest.php @@ -591,29 +591,29 @@ class MemberTest extends FunctionalTest { } class MemberTest_ViewingAllowedExtension extends DataExtension implements TestOnly { - public function canView() { + public function canView($member = null) { return true; } } class MemberTest_ViewingDeniedExtension extends DataExtension implements TestOnly { - public function canView() { + public function canView($member = null) { return false; } } class MemberTest_EditingAllowedDeletingDeniedExtension extends DataExtension implements TestOnly { - public function canView() { + public function canView($member = null) { return true; } - public function canEdit() { + public function canEdit($member = null) { return true; } - public function canDelete() { + public function canDelete($member = null) { return false; } diff --git a/tests/view/SSViewerTest.php b/tests/view/SSViewerTest.php index c68d6d219..df0b6ecba 100644 --- a/tests/view/SSViewerTest.php +++ b/tests/view/SSViewerTest.php @@ -930,7 +930,7 @@ class SSViewerTestFixture extends ViewableData { } - function XML_val($fieldName, $arguments = null) { + function XML_val($fieldName, $arguments = null, $cache = false) { if(preg_match('/NotSet/i', $fieldName)) { return ''; } else if(preg_match('/Raw/i', $fieldName)) { @@ -940,7 +940,7 @@ class SSViewerTestFixture extends ViewableData { } } - function hasValue($fieldName, $arguments = null) { + function hasValue($fieldName, $arguments = null, $cache = true) { return (bool)$this->XML_val($fieldName, $arguments); } } @@ -1021,4 +1021,4 @@ class SSViewerTest_GlobalProvider implements TemplateGlobalProvider, TestOnly { return 'z' . implode(':', $args) . 'z'; } -} \ No newline at end of file +} diff --git a/thirdparty/json/.piston.yml b/thirdparty/json/.piston.yml deleted file mode 100644 index 11765e63a..000000000 --- a/thirdparty/json/.piston.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -format: 1 -handler: - piston:remote-revision: 93520 - piston:uuid: 467b73ca-7a2a-4603-9d3b-597d59a354a9 -lock: false -repository_class: Piston::Svn::Repository -repository_url: http://svn.silverstripe.com/open/thirdparty/json/tags/1.31 diff --git a/thirdparty/json/JSON.php b/thirdparty/json/JSON.php deleted file mode 100644 index 0cddbddb4..000000000 --- a/thirdparty/json/JSON.php +++ /dev/null @@ -1,806 +0,0 @@ - - * @author Matt Knapp - * @author Brett Stimmerman - * @copyright 2005 Michal Migurski - * @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $ - * @license http://www.opensource.org/licenses/bsd-license.php - * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198 - */ - -/** - * Marker constant for Services_JSON::decode(), used to flag stack state - */ -define('SERVICES_JSON_SLICE', 1); - -/** - * Marker constant for Services_JSON::decode(), used to flag stack state - */ -define('SERVICES_JSON_IN_STR', 2); - -/** - * Marker constant for Services_JSON::decode(), used to flag stack state - */ -define('SERVICES_JSON_IN_ARR', 3); - -/** - * Marker constant for Services_JSON::decode(), used to flag stack state - */ -define('SERVICES_JSON_IN_OBJ', 4); - -/** - * Marker constant for Services_JSON::decode(), used to flag stack state - */ -define('SERVICES_JSON_IN_CMT', 5); - -/** - * Behavior switch for Services_JSON::decode() - */ -define('SERVICES_JSON_LOOSE_TYPE', 16); - -/** - * Behavior switch for Services_JSON::decode() - */ -define('SERVICES_JSON_SUPPRESS_ERRORS', 32); - -/** - * Converts to and from JSON format. - * - * Brief example of use: - * - * - * // create a new instance of Services_JSON - * $json = new Services_JSON(); - * - * // convert a complexe value to JSON notation, and send it to the browser - * $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4))); - * $output = $json->encode($value); - * - * print($output); - * // prints: ["foo","bar",[1,2,"baz"],[3,[4]]] - * - * // accept incoming POST data, assumed to be in JSON notation - * $input = file_get_contents('php://input', 1000000); - * $value = $json->decode($input); - * - */ -class Services_JSON -{ - /** - * constructs a new JSON instance - * - * @param int $use object behavior flags; combine with boolean-OR - * - * possible values: - * - SERVICES_JSON_LOOSE_TYPE: loose typing. - * "{...}" syntax creates associative arrays - * instead of objects in decode(). - * - SERVICES_JSON_SUPPRESS_ERRORS: error suppression. - * Values which can't be encoded (e.g. resources) - * appear as NULL instead of throwing errors. - * By default, a deeply-nested resource will - * bubble up with an error, so all return values - * from encode() should be checked with isError() - */ - function Services_JSON($use = 0) - { - $this->use = $use; - } - - /** - * convert a string from one UTF-16 char to one UTF-8 char - * - * Normally should be handled by mb_convert_encoding, but - * provides a slower PHP-only method for installations - * that lack the multibye string extension. - * - * @param string $utf16 UTF-16 character - * @return string UTF-8 character - * @access private - */ - function utf162utf8($utf16) - { - // oh please oh please oh please oh please oh please - if(function_exists('mb_convert_encoding')) { - return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16'); - } - - $bytes = (ord($utf16{0}) << 8) | ord($utf16{1}); - - switch(true) { - case ((0x7F & $bytes) == $bytes): - // this case should never be reached, because we are in ASCII range - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr(0x7F & $bytes); - - case (0x07FF & $bytes) == $bytes: - // return a 2-byte UTF-8 character - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr(0xC0 | (($bytes >> 6) & 0x1F)) - . chr(0x80 | ($bytes & 0x3F)); - - case (0xFFFF & $bytes) == $bytes: - // return a 3-byte UTF-8 character - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr(0xE0 | (($bytes >> 12) & 0x0F)) - . chr(0x80 | (($bytes >> 6) & 0x3F)) - . chr(0x80 | ($bytes & 0x3F)); - } - - // ignoring UTF-32 for now, sorry - return ''; - } - - /** - * convert a string from one UTF-8 char to one UTF-16 char - * - * Normally should be handled by mb_convert_encoding, but - * provides a slower PHP-only method for installations - * that lack the multibye string extension. - * - * @param string $utf8 UTF-8 character - * @return string UTF-16 character - * @access private - */ - function utf82utf16($utf8) - { - // oh please oh please oh please oh please oh please - if(function_exists('mb_convert_encoding')) { - return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); - } - - switch(strlen($utf8)) { - case 1: - // this case should never be reached, because we are in ASCII range - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return $utf8; - - case 2: - // return a UTF-16 character from a 2-byte UTF-8 char - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr(0x07 & (ord($utf8{0}) >> 2)) - . chr((0xC0 & (ord($utf8{0}) << 6)) - | (0x3F & ord($utf8{1}))); - - case 3: - // return a UTF-16 character from a 3-byte UTF-8 char - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr((0xF0 & (ord($utf8{0}) << 4)) - | (0x0F & (ord($utf8{1}) >> 2))) - . chr((0xC0 & (ord($utf8{1}) << 6)) - | (0x7F & ord($utf8{2}))); - } - - // ignoring UTF-32 for now, sorry - return ''; - } - - /** - * encodes an arbitrary variable into JSON format - * - * @param mixed $var any number, boolean, string, array, or object to be encoded. - * see argument 1 to Services_JSON() above for array-parsing behavior. - * if var is a strng, note that encode() always expects it - * to be in ASCII or UTF-8 format! - * - * @return mixed JSON string representation of input var or an error if a problem occurs - * @access public - */ - function encode($var) - { - switch (gettype($var)) { - case 'boolean': - return $var ? 'true' : 'false'; - - case 'NULL': - return 'null'; - - case 'integer': - return (int) $var; - - case 'double': - case 'float': - return (float) $var; - - case 'string': - // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT - $ascii = ''; - $strlen_var = strlen($var); - - /* - * Iterate over every character in the string, - * escaping with a slash or encoding to UTF-8 where necessary - */ - for ($c = 0; $c < $strlen_var; ++$c) { - - $ord_var_c = ord($var{$c}); - - switch (true) { - case $ord_var_c == 0x08: - $ascii .= '\b'; - break; - case $ord_var_c == 0x09: - $ascii .= '\t'; - break; - case $ord_var_c == 0x0A: - $ascii .= '\n'; - break; - case $ord_var_c == 0x0C: - $ascii .= '\f'; - break; - case $ord_var_c == 0x0D: - $ascii .= '\r'; - break; - - case $ord_var_c == 0x22: - case $ord_var_c == 0x2F: - case $ord_var_c == 0x5C: - // double quote, slash, slosh - $ascii .= '\\'.$var{$c}; - break; - - case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): - // characters U-00000000 - U-0000007F (same as ASCII) - $ascii .= $var{$c}; - break; - - case (($ord_var_c & 0xE0) == 0xC0): - // characters U-00000080 - U-000007FF, mask 110XXXXX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, ord($var{$c + 1})); - $c += 1; - $utf16 = $this->utf82utf16($char); - $ascii .= sprintf('\u%04s', bin2hex($utf16)); - break; - - case (($ord_var_c & 0xF0) == 0xE0): - // characters U-00000800 - U-0000FFFF, mask 1110XXXX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, - ord($var{$c + 1}), - ord($var{$c + 2})); - $c += 2; - $utf16 = $this->utf82utf16($char); - $ascii .= sprintf('\u%04s', bin2hex($utf16)); - break; - - case (($ord_var_c & 0xF8) == 0xF0): - // characters U-00010000 - U-001FFFFF, mask 11110XXX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, - ord($var{$c + 1}), - ord($var{$c + 2}), - ord($var{$c + 3})); - $c += 3; - $utf16 = $this->utf82utf16($char); - $ascii .= sprintf('\u%04s', bin2hex($utf16)); - break; - - case (($ord_var_c & 0xFC) == 0xF8): - // characters U-00200000 - U-03FFFFFF, mask 111110XX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, - ord($var{$c + 1}), - ord($var{$c + 2}), - ord($var{$c + 3}), - ord($var{$c + 4})); - $c += 4; - $utf16 = $this->utf82utf16($char); - $ascii .= sprintf('\u%04s', bin2hex($utf16)); - break; - - case (($ord_var_c & 0xFE) == 0xFC): - // characters U-04000000 - U-7FFFFFFF, mask 1111110X - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, - ord($var{$c + 1}), - ord($var{$c + 2}), - ord($var{$c + 3}), - ord($var{$c + 4}), - ord($var{$c + 5})); - $c += 5; - $utf16 = $this->utf82utf16($char); - $ascii .= sprintf('\u%04s', bin2hex($utf16)); - break; - } - } - - return '"'.$ascii.'"'; - - case 'array': - /* - * As per JSON spec if any array key is not an integer - * we must treat the the whole array as an object. We - * also try to catch a sparsely populated associative - * array with numeric keys here because some JS engines - * will create an array with empty indexes up to - * max_index which can cause memory issues and because - * the keys, which may be relevant, will be remapped - * otherwise. - * - * As per the ECMA and JSON specification an object may - * have any string as a property. Unfortunately due to - * a hole in the ECMA specification if the key is a - * ECMA reserved word or starts with a digit the - * parameter is only accessible using ECMAScript's - * bracket notation. - */ - - // treat as a JSON object - if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) { - $properties = array_map(array($this, 'name_value'), - array_keys($var), - array_values($var)); - - foreach($properties as $property) { - if(Services_JSON::isError($property)) { - return $property; - } - } - - return '{' . join(',', $properties) . '}'; - } - - // treat it like a regular array - $elements = array_map(array($this, 'encode'), $var); - - foreach($elements as $element) { - if(Services_JSON::isError($element)) { - return $element; - } - } - - return '[' . join(',', $elements) . ']'; - - case 'object': - $vars = get_object_vars($var); - - $properties = array_map(array($this, 'name_value'), - array_keys($vars), - array_values($vars)); - - foreach($properties as $property) { - if(Services_JSON::isError($property)) { - return $property; - } - } - - return '{' . join(',', $properties) . '}'; - - default: - return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS) - ? 'null' - : new Services_JSON_Error(gettype($var)." can not be encoded as JSON string"); - } - } - - /** - * array-walking function for use in generating JSON-formatted name-value pairs - * - * @param string $name name of key to use - * @param mixed $value reference to an array element to be encoded - * - * @return string JSON-formatted name-value pair, like '"name":value' - * @access private - */ - function name_value($name, $value) - { - $encoded_value = $this->encode($value); - - if(Services_JSON::isError($encoded_value)) { - return $encoded_value; - } - - return $this->encode(strval($name)) . ':' . $encoded_value; - } - - /** - * reduce a string by removing leading and trailing comments and whitespace - * - * @param $str string string value to strip of comments and whitespace - * - * @return string string value stripped of comments and whitespace - * @access private - */ - function reduce_string($str) - { - $str = preg_replace(array( - - // eliminate single line comments in '// ...' form - '#^\s*//(.+)$#m', - - // eliminate multi-line comments in '/* ... */' form, at start of string - '#^\s*/\*(.+)\*/#Us', - - // eliminate multi-line comments in '/* ... */' form, at end of string - '#/\*(.+)\*/\s*$#Us' - - ), '', $str); - - // eliminate extraneous space - return trim($str); - } - - /** - * decodes a JSON string into appropriate variable - * - * @param string $str JSON-formatted string - * - * @return mixed number, boolean, string, array, or object - * corresponding to given JSON input string. - * See argument 1 to Services_JSON() above for object-output behavior. - * Note that decode() always returns strings - * in ASCII or UTF-8 format! - * @access public - */ - function decode($str) - { - $str = $this->reduce_string($str); - - switch (strtolower($str)) { - case 'true': - return true; - - case 'false': - return false; - - case 'null': - return null; - - default: - $m = array(); - - if (is_numeric($str)) { - // Lookie-loo, it's a number - - // This would work on its own, but I'm trying to be - // good about returning integers where appropriate: - // return (float)$str; - - // Return float or int, as appropriate - return ((float)$str == (integer)$str) - ? (integer)$str - : (float)$str; - - } elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) { - // STRINGS RETURNED IN UTF-8 FORMAT - $delim = substr($str, 0, 1); - $chrs = substr($str, 1, -1); - $utf8 = ''; - $strlen_chrs = strlen($chrs); - - for ($c = 0; $c < $strlen_chrs; ++$c) { - - $substr_chrs_c_2 = substr($chrs, $c, 2); - $ord_chrs_c = ord($chrs{$c}); - - switch (true) { - case $substr_chrs_c_2 == '\b': - $utf8 .= chr(0x08); - ++$c; - break; - case $substr_chrs_c_2 == '\t': - $utf8 .= chr(0x09); - ++$c; - break; - case $substr_chrs_c_2 == '\n': - $utf8 .= chr(0x0A); - ++$c; - break; - case $substr_chrs_c_2 == '\f': - $utf8 .= chr(0x0C); - ++$c; - break; - case $substr_chrs_c_2 == '\r': - $utf8 .= chr(0x0D); - ++$c; - break; - - case $substr_chrs_c_2 == '\\"': - case $substr_chrs_c_2 == '\\\'': - case $substr_chrs_c_2 == '\\\\': - case $substr_chrs_c_2 == '\\/': - if (($delim == '"' && $substr_chrs_c_2 != '\\\'') || - ($delim == "'" && $substr_chrs_c_2 != '\\"')) { - $utf8 .= $chrs{++$c}; - } - break; - - case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)): - // single, escaped unicode character - $utf16 = chr(hexdec(substr($chrs, ($c + 2), 2))) - . chr(hexdec(substr($chrs, ($c + 4), 2))); - $utf8 .= $this->utf162utf8($utf16); - $c += 5; - break; - - case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F): - $utf8 .= $chrs{$c}; - break; - - case ($ord_chrs_c & 0xE0) == 0xC0: - // characters U-00000080 - U-000007FF, mask 110XXXXX - //see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $utf8 .= substr($chrs, $c, 2); - ++$c; - break; - - case ($ord_chrs_c & 0xF0) == 0xE0: - // characters U-00000800 - U-0000FFFF, mask 1110XXXX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $utf8 .= substr($chrs, $c, 3); - $c += 2; - break; - - case ($ord_chrs_c & 0xF8) == 0xF0: - // characters U-00010000 - U-001FFFFF, mask 11110XXX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $utf8 .= substr($chrs, $c, 4); - $c += 3; - break; - - case ($ord_chrs_c & 0xFC) == 0xF8: - // characters U-00200000 - U-03FFFFFF, mask 111110XX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $utf8 .= substr($chrs, $c, 5); - $c += 4; - break; - - case ($ord_chrs_c & 0xFE) == 0xFC: - // characters U-04000000 - U-7FFFFFFF, mask 1111110X - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $utf8 .= substr($chrs, $c, 6); - $c += 5; - break; - - } - - } - - return $utf8; - - } elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) { - // array, or object notation - - if ($str{0} == '[') { - $stk = array(SERVICES_JSON_IN_ARR); - $arr = array(); - } else { - if ($this->use & SERVICES_JSON_LOOSE_TYPE) { - $stk = array(SERVICES_JSON_IN_OBJ); - $obj = array(); - } else { - $stk = array(SERVICES_JSON_IN_OBJ); - $obj = new stdClass(); - } - } - - array_push($stk, array('what' => SERVICES_JSON_SLICE, - 'where' => 0, - 'delim' => false)); - - $chrs = substr($str, 1, -1); - $chrs = $this->reduce_string($chrs); - - if ($chrs == '') { - if (reset($stk) == SERVICES_JSON_IN_ARR) { - return $arr; - - } else { - return $obj; - - } - } - - //print("\nparsing {$chrs}\n"); - - $strlen_chrs = strlen($chrs); - - for ($c = 0; $c <= $strlen_chrs; ++$c) { - - $top = end($stk); - $substr_chrs_c_2 = substr($chrs, $c, 2); - - if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) { - // found a comma that is not inside a string, array, etc., - // OR we've reached the end of the character list - $slice = substr($chrs, $top['where'], ($c - $top['where'])); - array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false)); - //print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); - - if (reset($stk) == SERVICES_JSON_IN_ARR) { - // we are in an array, so just push an element onto the stack - array_push($arr, $this->decode($slice)); - - } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) { - // we are in an object, so figure - // out the property name and set an - // element in an associative array, - // for now - $parts = array(); - - if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) { - // "name":value pair - $key = $this->decode($parts[1]); - $val = $this->decode($parts[2]); - - if ($this->use & SERVICES_JSON_LOOSE_TYPE) { - $obj[$key] = $val; - } else { - $obj->$key = $val; - } - } elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) { - // name:value pair, where name is unquoted - $key = $parts[1]; - $val = $this->decode($parts[2]); - - if ($this->use & SERVICES_JSON_LOOSE_TYPE) { - $obj[$key] = $val; - } else { - $obj->$key = $val; - } - } - - } - - } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) { - // found a quote, and we are not inside a string - array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c})); - //print("Found start of string at {$c}\n"); - - } elseif (($chrs{$c} == $top['delim']) && - ($top['what'] == SERVICES_JSON_IN_STR) && - ((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) { - // found a quote, we're in a string, and it's not escaped - // we know that it's not escaped becase there is _not_ an - // odd number of backslashes at the end of the string so far - array_pop($stk); - //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n"); - - } elseif (($chrs{$c} == '[') && - in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { - // found a left-bracket, and we are in an array, object, or slice - array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false)); - //print("Found start of array at {$c}\n"); - - } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) { - // found a right-bracket, and we're in an array - array_pop($stk); - //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); - - } elseif (($chrs{$c} == '{') && - in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { - // found a left-brace, and we are in an array, object, or slice - array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false)); - //print("Found start of object at {$c}\n"); - - } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) { - // found a right-brace, and we're in an object - array_pop($stk); - //print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); - - } elseif (($substr_chrs_c_2 == '/*') && - in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { - // found a comment start, and we are in an array, object, or slice - array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false)); - $c++; - //print("Found start of comment at {$c}\n"); - - } elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) { - // found a comment end, and we're in one now - array_pop($stk); - $c++; - - for ($i = $top['where']; $i <= $c; ++$i) - $chrs = substr_replace($chrs, ' ', $i, 1); - - //print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); - - } - - } - - if (reset($stk) == SERVICES_JSON_IN_ARR) { - return $arr; - - } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) { - return $obj; - - } - - } - } - } - - /** - * @todo Ultimately, this should just call PEAR::isError() - */ - function isError($data, $code = null) - { - if (class_exists('pear')) { - return PEAR::isError($data, $code); - } elseif (is_object($data) && (get_class($data) == 'services_json_error' || - is_subclass_of($data, 'services_json_error'))) { - return true; - } - - return false; - } -} - -if (class_exists('PEAR_Error')) { - - class Services_JSON_Error extends PEAR_Error - { - function Services_JSON_Error($message = 'unknown error', $code = null, - $mode = null, $options = null, $userinfo = null) - { - parent::PEAR_Error($message, $code, $mode, $options, $userinfo); - } - } - -} else { - - /** - * @todo Ultimately, this class shall be descended from PEAR_Error - */ - class Services_JSON_Error - { - function Services_JSON_Error($message = 'unknown error', $code = null, - $mode = null, $options = null, $userinfo = null) - { - - } - } - -} - -?> diff --git a/thirdparty/json/LICENSE b/thirdparty/json/LICENSE deleted file mode 100644 index 4ae6bef55..000000000 --- a/thirdparty/json/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED -WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN -NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/thirdparty/json/Test-JSON.php b/thirdparty/json/Test-JSON.php deleted file mode 100644 index 4a437f743..000000000 --- a/thirdparty/json/Test-JSON.php +++ /dev/null @@ -1,521 +0,0 @@ - - * @author Matt Knapp - * @author Brett Stimmerman - * @copyright 2005 Michal Migurski - * @version CVS: $Id: Test-JSON.php,v 1.28 2006/06/28 05:54:17 migurski Exp $ - * @license http://www.opensource.org/licenses/bsd-license.php - * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198 - */ - - error_reporting(E_ALL); - - require_once 'PHPUnit.php'; - require_once 'JSON.php'; - - class Services_JSON_EncDec_TestCase extends PHPUnit_TestCase { - - function Services_JSON_EncDec_TestCase($name) { - $this->PHPUnit_TestCase($name); - } - - function setUp() { - $this->json = new Services_JSON(); - - $obj = new stdClass(); - $obj->a_string = '"he":llo}:{world'; - $obj->an_array = array(1, 2, 3); - $obj->obj = new stdClass(); - $obj->obj->a_number = 123; - - $this->obj = $obj; - $this->obj_j = '{"a_string":"\"he\":llo}:{world","an_array":[1,2,3],"obj":{"a_number":123}}'; - $this->obj_d = 'object with properties, nested object and arrays'; - - $this->arr = array(null, true, array(1, 2, 3), "hello\"],[world!"); - $this->arr_j = '[null,true,[1,2,3],"hello\"],[world!"]'; - $this->arr_d = 'array with elements and nested arrays'; - - $this->str1 = 'hello world'; - $this->str1_j = '"hello world"'; - $this->str1_j_ = "'hello world'"; - $this->str1_d = 'hello world'; - $this->str1_d_ = 'hello world, double quotes'; - - $this->str2 = "hello\t\"world\""; - $this->str2_j = '"hello\\t\\"world\\""'; - $this->str2_d = 'hello world, with tab, double-quotes'; - - $this->str3 = "\\\r\n\t\"/"; - $this->str3_j = '"\\\\\\r\\n\\t\\"\\/"'; - $this->str3_d = 'backslash, return, newline, tab, double-quote'; - - $this->str4 = 'héllö wørłd'; - $this->str4_j = '"h\u00e9ll\u00f6 w\u00f8r\u0142d"'; - $this->str4_j_ = '"héllö wørłd"'; - $this->str4_d = 'hello world, with unicode'; - } - - function test_to_JSON() - { - $this->assertEquals('null', $this->json->encode(null), 'type case: null'); - $this->assertEquals('true', $this->json->encode(true), 'type case: boolean true'); - $this->assertEquals('false', $this->json->encode(false), 'type case: boolean false'); - - $this->assertEquals('1', $this->json->encode(1), 'numeric case: 1'); - $this->assertEquals('-1', $this->json->encode(-1), 'numeric case: -1'); - $this->assertEquals('1.000000', $this->json->encode(1.0), 'numeric case: 1.0'); - $this->assertEquals('1.100000', $this->json->encode(1.1), 'numeric case: 1.1'); - - $this->assertEquals($this->str1_j, $this->json->encode($this->str1), "string case: {$this->str1_d}"); - $this->assertEquals($this->str2_j, $this->json->encode($this->str2), "string case: {$this->str2_d}"); - $this->assertEquals($this->str3_j, $this->json->encode($this->str3), "string case: {$this->str3_d}"); - $this->assertEquals($this->str4_j, $this->json->encode($this->str4), "string case: {$this->str4_d}"); - - $this->assertEquals($this->arr_j, $this->json->encode($this->arr), "array case: {$this->arr_d}"); - $this->assertEquals($this->obj_j, $this->json->encode($this->obj), "object case: {$this->obj_d}"); - } - - function test_from_JSON() - { - $this->assertEquals(null, $this->json->decode('null'), 'type case: null'); - $this->assertEquals(true, $this->json->decode('true'), 'type case: boolean true'); - $this->assertEquals(false, $this->json->decode('false'), 'type case: boolean false'); - - $this->assertEquals(1, $this->json->decode('1'), 'numeric case: 1'); - $this->assertEquals(-1, $this->json->decode('-1'), 'numeric case: -1'); - $this->assertEquals(1.0, $this->json->decode('1.0'), 'numeric case: 1.0'); - $this->assertEquals(1.1, $this->json->decode('1.1'), 'numeric case: 1.1'); - - $this->assertEquals(11.0, $this->json->decode('1.1e1'), 'numeric case: 1.1e1'); - $this->assertEquals(11.0, $this->json->decode('1.10e+1'), 'numeric case: 1.10e+1'); - $this->assertEquals(0.11, $this->json->decode('1.1e-1'), 'numeric case: 1.1e-1'); - $this->assertEquals(-0.11, $this->json->decode('-1.1e-1'), 'numeric case: -1.1e-1'); - - $this->assertEquals($this->str1, $this->json->decode($this->str1_j), "string case: {$this->str1_d}"); - $this->assertEquals($this->str1, $this->json->decode($this->str1_j_), "string case: {$this->str1_d_}"); - $this->assertEquals($this->str2, $this->json->decode($this->str2_j), "string case: {$this->str2_d}"); - $this->assertEquals($this->str3, $this->json->decode($this->str3_j), "string case: {$this->str3_d}"); - $this->assertEquals($this->str4, $this->json->decode($this->str4_j), "string case: {$this->str4_d}"); - $this->assertEquals($this->str4, $this->json->decode($this->str4_j_), "string case: {$this->str4_d}"); - - $this->assertEquals($this->arr, $this->json->decode($this->arr_j), "array case: {$this->arr_d}"); - $this->assertEquals($this->obj, $this->json->decode($this->obj_j), "object case: {$this->obj_d}"); - } - - function test_to_then_from_JSON() - { - $this->assertEquals(null, $this->json->decode($this->json->encode(null)), 'type case: null'); - $this->assertEquals(true, $this->json->decode($this->json->encode(true)), 'type case: boolean true'); - $this->assertEquals(false, $this->json->decode($this->json->encode(false)), 'type case: boolean false'); - - $this->assertEquals(1, $this->json->decode($this->json->encode(1)), 'numeric case: 1'); - $this->assertEquals(-1, $this->json->decode($this->json->encode(-1)), 'numeric case: -1'); - $this->assertEquals(1.0, $this->json->decode($this->json->encode(1.0)), 'numeric case: 1.0'); - $this->assertEquals(1.1, $this->json->decode($this->json->encode(1.1)), 'numeric case: 1.1'); - - $this->assertEquals($this->str1, $this->json->decode($this->json->encode($this->str1)), "string case: {$this->str1_d}"); - $this->assertEquals($this->str2, $this->json->decode($this->json->encode($this->str2)), "string case: {$this->str2_d}"); - $this->assertEquals($this->str3, $this->json->decode($this->json->encode($this->str3)), "string case: {$this->str3_d}"); - $this->assertEquals($this->str4, $this->json->decode($this->json->encode($this->str4)), "string case: {$this->str4_d}"); - - $this->assertEquals($this->arr, $this->json->decode($this->json->encode($this->arr)), "array case: {$this->arr_d}"); - $this->assertEquals($this->obj, $this->json->decode($this->json->encode($this->obj)), "object case: {$this->obj_d}"); - } - - function test_from_then_to_JSON() - { - $this->assertEquals('null', $this->json->encode($this->json->decode('null')), 'type case: null'); - $this->assertEquals('true', $this->json->encode($this->json->decode('true')), 'type case: boolean true'); - $this->assertEquals('false', $this->json->encode($this->json->decode('false')), 'type case: boolean false'); - - $this->assertEquals('1', $this->json->encode($this->json->decode('1')), 'numeric case: 1'); - $this->assertEquals('-1', $this->json->encode($this->json->decode('-1')), 'numeric case: -1'); - $this->assertEquals('1.0', $this->json->encode($this->json->decode('1.0')), 'numeric case: 1.0'); - $this->assertEquals('1.1', $this->json->encode($this->json->decode('1.1')), 'numeric case: 1.1'); - - $this->assertEquals($this->str1_j, $this->json->encode($this->json->decode($this->str1_j)), "string case: {$this->str1_d}"); - $this->assertEquals($this->str2_j, $this->json->encode($this->json->decode($this->str2_j)), "string case: {$this->str2_d}"); - $this->assertEquals($this->str3_j, $this->json->encode($this->json->decode($this->str3_j)), "string case: {$this->str3_d}"); - $this->assertEquals($this->str4_j, $this->json->encode($this->json->decode($this->str4_j)), "string case: {$this->str4_d}"); - $this->assertEquals($this->str4_j, $this->json->encode($this->json->decode($this->str4_j_)), "string case: {$this->str4_d}"); - - $this->assertEquals($this->arr_j, $this->json->encode($this->json->decode($this->arr_j)), "array case: {$this->arr_d}"); - $this->assertEquals($this->obj_j, $this->json->encode($this->json->decode($this->obj_j)), "object case: {$this->obj_d}"); - } - } - - class Services_JSON_AssocArray_TestCase extends PHPUnit_TestCase { - - function Services_JSON_AssocArray_TestCase($name) { - $this->PHPUnit_TestCase($name); - } - - function setUp() { - $this->json_l = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); - $this->json_s = new Services_JSON(); - - $this->arr = array('car1'=> array('color'=> 'tan', 'model' => 'sedan'), - 'car2' => array('color' => 'red', 'model' => 'sports')); - $this->arr_jo = '{"car1":{"color":"tan","model":"sedan"},"car2":{"color":"red","model":"sports"}}'; - $this->arr_d = 'associative array with nested associative arrays'; - - $this->arn = array(0=> array(0=> 'tan\\', 'model\\' => 'sedan'), 1 => array(0 => 'red', 'model' => 'sports')); - $this->arn_ja = '[{"0":"tan\\\\","model\\\\":"sedan"},{"0":"red","model":"sports"}]'; - $this->arn_d = 'associative array with nested associative arrays, and some numeric keys thrown in'; - - $this->arrs = array (1 => 'one', 2 => 'two', 5 => 'five'); - $this->arrs_jo = '{"1":"one","2":"two","5":"five"}'; - $this->arrs_d = 'associative array numeric keys which are not fully populated in a range of 0 to length-1'; - } - - function test_type() - { - $this->assertEquals('array', gettype($this->json_l->decode($this->arn_ja)), "loose type should be array"); - $this->assertEquals('array', gettype($this->json_s->decode($this->arn_ja)), "strict type should be array"); - } - - function test_to_JSON() - { - // both strict and loose JSON should result in an object - $this->assertEquals($this->arr_jo, $this->json_l->encode($this->arr), "array case - loose: {$this->arr_d}"); - $this->assertEquals($this->arr_jo, $this->json_s->encode($this->arr), "array case - strict: {$this->arr_d}"); - - // ...unless the input array has some numeric indeces, in which case the behavior is to degrade to a regular array - $this->assertEquals($this->arn_ja, $this->json_s->encode($this->arn), "array case - strict: {$this->arn_d}"); - - // Test a sparsely populated numerically indexed associative array - $this->assertEquals($this->arrs_jo, $this->json_l->encode($this->arrs), "sparse numeric assoc array: {$this->arrs_d}"); - } - - function test_to_then_from_JSON() - { - // these tests motivated by a bug in which strings that end - // with backslashes followed by quotes were incorrectly decoded. - - foreach(array('\\"', '\\\\"', '\\"\\"', '\\""\\""', '\\\\"\\\\"') as $v) { - $this->assertEquals(array($v), $this->json_l->decode($this->json_l->encode(array($v)))); - $this->assertEquals(array('a' => $v), $this->json_l->decode($this->json_l->encode(array('a' => $v)))); - } - } - } - - class Services_JSON_NestedArray_TestCase extends PHPUnit_TestCase { - - function Services_JSON_NestedArray_TestCase($name) { - $this->PHPUnit_TestCase($name); - } - - function setUp() { - $this->json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); - - $this->str1 = '[{"this":"that"}]'; - $this->arr1 = array(array('this' => 'that')); - - $this->str2 = '{"this":["that"]}'; - $this->arr2 = array('this' => array('that')); - - $this->str3 = '{"params":[{"foo":["1"],"bar":"1"}]}'; - $this->arr3 = array('params' => array(array('foo' => array('1'), 'bar' => '1'))); - - $this->str4 = '{"0": {"foo": "bar", "baz": "winkle"}}'; - $this->arr4 = array('0' => array('foo' => 'bar', 'baz' => 'winkle')); - - $this->str5 = '{"params":[{"options": {"old": [ ], "new": {"0": {"elements": {"old": [], "new": {"0": {"elementName": "aa", "isDefault": false, "elementRank": "0", "priceAdjust": "0", "partNumber": ""}}}, "optionName": "aa", "isRequired": false, "optionDesc": null}}}}]}'; - $this->arr5 = array ( - 'params' => array ( - 0 => array ( - 'options' => - array ( - 'old' => array(), - 'new' => array ( - 0 => array ( - 'elements' => array ( - 'old' => array(), - 'new' => array ( - 0 => array ( - 'elementName' => 'aa', - 'isDefault' => false, - 'elementRank' => '0', - 'priceAdjust' => '0', - 'partNumber' => '', - ), - ), - ), - 'optionName' => 'aa', - 'isRequired' => false, - 'optionDesc' => NULL, - ), - ), - ), - ), - ), - ); - } - - function test_type() - { - $this->assertEquals('array', gettype($this->json->decode($this->str1)), "loose type should be array"); - $this->assertEquals('array', gettype($this->json->decode($this->str2)), "loose type should be array"); - $this->assertEquals('array', gettype($this->json->decode($this->str3)), "loose type should be array"); - } - - function test_from_JSON() - { - $this->assertEquals($this->arr1, $this->json->decode($this->str1), "simple compactly-nested array"); - $this->assertEquals($this->arr2, $this->json->decode($this->str2), "simple compactly-nested array"); - $this->assertEquals($this->arr3, $this->json->decode($this->str3), "complex compactly nested array"); - $this->assertEquals($this->arr4, $this->json->decode($this->str4), "complex compactly nested array"); - $this->assertEquals($this->arr5, $this->json->decode($this->str5), "super complex compactly nested array"); - } - - function _test_from_JSON() - { - $super = '{"params":[{"options": {"old": {}, "new": {"0": {"elements": {"old": {}, "new": {"0": {"elementName": "aa", "isDefault": false, "elementRank": "0", "priceAdjust": "0", "partNumber": ""}}}, "optionName": "aa", "isRequired": false, "optionDesc": ""}}}}]}'; - print("trying {$super}...\n"); - print var_export($this->json->decode($super)); - } - } - - class Services_JSON_Object_TestCase extends PHPUnit_TestCase { - - function Services_JSON_Object_TestCase($name) { - $this->PHPUnit_TestCase($name); - } - - function setUp() { - $this->json_l = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); - $this->json_s = new Services_JSON(); - - $this->obj_j = '{"a_string":"\"he\":llo}:{world","an_array":[1,2,3],"obj":{"a_number":123}}'; - - $this->obj1->car1->color = 'tan'; - $this->obj1->car1->model = 'sedan'; - $this->obj1->car2->color = 'red'; - $this->obj1->car2->model = 'sports'; - $this->obj1_j = '{"car1":{"color":"tan","model":"sedan"},"car2":{"color":"red","model":"sports"}}'; - $this->obj1_d = 'Object with nested objects'; - } - - function test_type() - { - $this->assertEquals('object', gettype($this->json_s->decode($this->obj_j)), "checking whether decoded type is object"); - $this->assertEquals('array', gettype($this->json_l->decode($this->obj_j)), "checking whether decoded type is array"); - } - - function test_to_JSON() - { - $this->assertEquals($this->obj1_j, $this->json_s->encode($this->obj1), "object - strict: {$this->obj1_d}"); - $this->assertEquals($this->obj1_j, $this->json_l->encode($this->obj1), "object - loose: {$this->obj1_d}"); - } - - function test_from_then_to_JSON() - { - $this->assertEquals($this->obj_j, $this->json_s->encode($this->json_s->decode($this->obj_j)), "object case"); - $this->assertEquals($this->obj_j, $this->json_l->encode($this->json_l->decode($this->obj_j)), "array case"); - } - } - - class Services_JSON_Spaces_Comments_TestCase extends PHPUnit_TestCase { - - function Services_JSON_Spaces_Comments_TestCase($name) { - $this->PHPUnit_TestCase($name); - } - - function setUp() { - $this->json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); - - $this->obj_j = '{"a_string":"\"he\":llo}:{world","an_array":[1,2,3],"obj":{"a_number":123}}'; - - $this->obj_js = '{"a_string": "\"he\":llo}:{world", - "an_array":[1, 2, 3], - "obj": {"a_number":123}}'; - - $this->obj_jc1 = '{"a_string": "\"he\":llo}:{world", - // here is a comment, hoorah - "an_array":[1, 2, 3], - "obj": {"a_number":123}}'; - - $this->obj_jc2 = '/* this here is the sneetch */ "the sneetch" - // this has been the sneetch.'; - - $this->obj_jc3 = '{"a_string": "\"he\":llo}:{world", - /* here is a comment, hoorah */ - "an_array":[1, 2, 3 /* and here is another */], - "obj": {"a_number":123}}'; - - $this->obj_jc4 = '{\'a_string\': "\"he\":llo}:{world", - /* here is a comment, hoorah */ - \'an_array\':[1, 2, 3 /* and here is another */], - "obj": {"a_number":123}}'; - } - - function test_spaces() - { - $this->assertEquals($this->json->decode($this->obj_j), $this->json->decode($this->obj_js), "checking whether notation with spaces works"); - } - - function test_comments() - { - $this->assertEquals($this->json->decode($this->obj_j), $this->json->decode($this->obj_jc1), "checking whether notation with single line comments works"); - $this->assertEquals('the sneetch', $this->json->decode($this->obj_jc2), "checking whether notation with multiline comments works"); - $this->assertEquals($this->json->decode($this->obj_j), $this->json->decode($this->obj_jc3), "checking whether notation with multiline comments works"); - $this->assertEquals($this->json->decode($this->obj_j), $this->json->decode($this->obj_jc4), "checking whether notation with single-quotes and multiline comments works"); - } - } - - class Services_JSON_Empties_TestCase extends PHPUnit_TestCase { - - function Services_JSON_Empties_TestCase($name) { - $this->PHPUnit_TestCase($name); - } - - function setUp() { - $this->json_l = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); - $this->json_s = new Services_JSON(); - - $this->obj0_j = '{}'; - $this->arr0_j = '[]'; - - $this->obj1_j = '{ }'; - $this->arr1_j = '[ ]'; - - $this->obj2_j = '{ /* comment inside */ }'; - $this->arr2_j = '[ /* comment inside */ ]'; - } - - function test_type() - { - $this->assertEquals('array', gettype($this->json_l->decode($this->arr0_j)), "should be array"); - $this->assertEquals('object', gettype($this->json_s->decode($this->obj0_j)), "should be object"); - - $this->assertEquals(0, count($this->json_l->decode($this->arr0_j)), "should be empty array"); - $this->assertEquals(0, count(get_object_vars($this->json_s->decode($this->obj0_j))), "should be empty object"); - - $this->assertEquals('array', gettype($this->json_l->decode($this->arr1_j)), "should be array, even with space"); - $this->assertEquals('object', gettype($this->json_s->decode($this->obj1_j)), "should be object, even with space"); - - $this->assertEquals(0, count($this->json_l->decode($this->arr1_j)), "should be empty array, even with space"); - $this->assertEquals(0, count(get_object_vars($this->json_s->decode($this->obj1_j))), "should be empty object, even with space"); - - $this->assertEquals('array', gettype($this->json_l->decode($this->arr2_j)), "should be array, despite comment"); - $this->assertEquals('object', gettype($this->json_s->decode($this->obj2_j)), "should be object, despite comment"); - - $this->assertEquals(0, count($this->json_l->decode($this->arr2_j)), "should be empty array, despite comment"); - $this->assertEquals(0, count(get_object_vars($this->json_s->decode($this->obj2_j))), "should be empty object, despite commentt"); - } - } - - class Services_JSON_UnquotedKeys_TestCase extends PHPUnit_TestCase { - - function Services_JSON_UnquotedKeys_TestCase($name) { - $this->PHPUnit_TestCase($name); - } - - function setUp() { - $this->json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); - - $this->arn = array(0=> array(0=> 'tan', 'model' => 'sedan'), 1 => array(0 => 'red', 'model' => 'sports')); - $this->arn_ja = '[{0:"tan","model":"sedan"},{"0":"red",model:"sports"}]'; - $this->arn_d = 'associative array with unquoted keys, nested associative arrays, and some numeric keys thrown in'; - - $this->arrs = array (1 => 'one', 2 => 'two', 5 => 'fi"ve'); - $this->arrs_jo = '{"1":"one",2:"two","5":\'fi"ve\'}'; - $this->arrs_d = 'associative array with unquoted keys, single-quoted values, numeric keys which are not fully populated in a range of 0 to length-1'; - } - - function test_from_JSON() - { - // ...unless the input array has some numeric indeces, in which case the behavior is to degrade to a regular array - $this->assertEquals($this->arn, $this->json->decode($this->arn_ja), "array case - strict: {$this->arn_d}"); - - // Test a sparsely populated numerically indexed associative array - $this->assertEquals($this->arrs, $this->json->decode($this->arrs_jo), "sparse numeric assoc array: {$this->arrs_d}"); - } - } - - class Services_JSON_ErrorSuppression_TestCase extends PHPUnit_TestCase { - - function Services_JSON_ErrorSuppression_TestCase($name) { - $this->PHPUnit_TestCase($name); - } - - function setUp() { - $this->json = new Services_JSON(); - $this->json_ = new Services_JSON(SERVICES_JSON_SUPPRESS_ERRORS); - - $this->res = tmpfile(); - $this->res_j_ = 'null'; - $this->res_d = 'naked resource'; - - $this->arr = array('a', 1, tmpfile()); - $this->arr_j_ = '["a",1,null]'; - $this->arr_d = 'array with string, number and resource'; - - $obj = new stdClass(); - $obj->a_string = '"he":llo}:{world'; - $obj->an_array = array(1, 2, 3); - $obj->resource = tmpfile(); - - $this->obj = $obj; - $this->obj_j_ = '{"a_string":"\"he\":llo}:{world","an_array":[1,2,3],"resource":null}'; - $this->obj_d = 'object with properties, array, and nested resource'; - } - - function test_to_JSON() - { - $this->assertTrue(Services_JSON::isError($this->json->encode($this->res)), "resource case: {$this->res_d}"); - $this->assertTrue(Services_JSON::isError($this->json->encode($this->arr)), "array case: {$this->arr_d}"); - $this->assertTrue(Services_JSON::isError($this->json->encode($this->obj)), "object case: {$this->obj_d}"); - } - - function test_to_JSON_suppressed() - { - $this->assertEquals($this->res_j_, $this->json_->encode($this->res), "resource case: {$this->res_d}"); - $this->assertEquals($this->arr_j_, $this->json_->encode($this->arr), "array case: {$this->arr_d}"); - $this->assertEquals($this->obj_j_, $this->json_->encode($this->obj), "object case: {$this->obj_d}"); - } - } - - $suite = new PHPUnit_TestSuite('Services_JSON_EncDec_TestCase'); - $result = PHPUnit::run($suite); - echo $result->toString(); - - $suite = new PHPUnit_TestSuite('Services_JSON_AssocArray_TestCase'); - $result = PHPUnit::run($suite); - echo $result->toString(); - - $suite = new PHPUnit_TestSuite('Services_JSON_NestedArray_TestCase'); - $result = PHPUnit::run($suite); - echo $result->toString(); - - $suite = new PHPUnit_TestSuite('Services_JSON_Object_TestCase'); - $result = PHPUnit::run($suite); - echo $result->toString(); - - $suite = new PHPUnit_TestSuite('Services_JSON_Spaces_Comments_TestCase'); - $result = PHPUnit::run($suite); - echo $result->toString(); - - $suite = new PHPUnit_TestSuite('Services_JSON_Empties_TestCase'); - $result = PHPUnit::run($suite); - echo $result->toString(); - - $suite = new PHPUnit_TestSuite('Services_JSON_UnquotedKeys_TestCase'); - $result = PHPUnit::run($suite); - echo $result->toString(); - - $suite = new PHPUnit_TestSuite('Services_JSON_ErrorSuppression_TestCase'); - $result = PHPUnit::run($suite); - echo $result->toString(); - -?> diff --git a/thirdparty/simpletest/form.php b/thirdparty/simpletest/form.php index cbef6636d..b359552f4 100644 --- a/thirdparty/simpletest/form.php +++ b/thirdparty/simpletest/form.php @@ -172,7 +172,7 @@ class SimpleForm { */ function _addRadioButton(&$tag) { if (! isset($this->_radios[$tag->getName()])) { - $this->_widgets[] = &new SimpleRadioGroup(); + $this->_widgets[] = new SimpleRadioGroup(); $this->_radios[$tag->getName()] = count($this->_widgets) - 1; } $this->_widgets[$this->_radios[$tag->getName()]]->addWidget($tag); @@ -191,7 +191,7 @@ class SimpleForm { $index = $this->_checkboxes[$tag->getName()]; if (! SimpleTestCompatibility::isA($this->_widgets[$index], 'SimpleCheckboxGroup')) { $previous = &$this->_widgets[$index]; - $this->_widgets[$index] = &new SimpleCheckboxGroup(); + $this->_widgets[$index] = new SimpleCheckboxGroup(); $this->_widgets[$index]->addWidget($previous); } $this->_widgets[$index]->addWidget($tag); @@ -352,4 +352,4 @@ class SimpleForm { return $this->_encode(); } } -?> \ No newline at end of file +?> diff --git a/thirdparty/simpletest/http.php b/thirdparty/simpletest/http.php index e6c6e89da..176d9fccd 100644 --- a/thirdparty/simpletest/http.php +++ b/thirdparty/simpletest/http.php @@ -98,9 +98,9 @@ class SimpleRoute { */ function &_createSocket($scheme, $host, $port, $timeout) { if (in_array($scheme, array('https'))) { - $socket = &new SimpleSecureSocket($host, $port, $timeout); + $socket = new SimpleSecureSocket($host, $port, $timeout); } else { - $socket = &new SimpleSocket($host, $port, $timeout); + $socket = new SimpleSocket($host, $port, $timeout); } return $socket; } @@ -279,7 +279,7 @@ class SimpleHttpRequest { * @access protected */ function &_createResponse(&$socket) { - $response = &new SimpleHttpResponse( + $response = new SimpleHttpResponse( $socket, $this->_route->getUrl(), $this->_encoding); @@ -516,13 +516,13 @@ class SimpleHttpResponse extends SimpleStickyError { function _parse($raw) { if (! $raw) { $this->_setError('Nothing fetched'); - $this->_headers = &new SimpleHttpHeaders(''); + $this->_headers = new SimpleHttpHeaders(''); } elseif (! strstr($raw, "\r\n\r\n")) { $this->_setError('Could not split headers from content'); - $this->_headers = &new SimpleHttpHeaders($raw); + $this->_headers = new SimpleHttpHeaders($raw); } else { list($headers, $this->_content) = split("\r\n\r\n", $raw, 2); - $this->_headers = &new SimpleHttpHeaders($headers); + $this->_headers = new SimpleHttpHeaders($headers); } } @@ -621,4 +621,4 @@ class SimpleHttpResponse extends SimpleStickyError { return ! $packet; } } -?> \ No newline at end of file +?> diff --git a/thirdparty/simpletest/page.php b/thirdparty/simpletest/page.php index 08e5649dc..6c037626c 100644 --- a/thirdparty/simpletest/page.php +++ b/thirdparty/simpletest/page.php @@ -163,7 +163,7 @@ class SimplePageBuilder extends SimpleSaxListener { * @access protected */ function &_createPage($response) { - $page = &new SimplePage($response); + $page = new SimplePage($response); return $page; } @@ -175,7 +175,7 @@ class SimplePageBuilder extends SimpleSaxListener { * @access protected */ function &_createParser(&$listener) { - $parser = &new SimpleHtmlSaxParser($listener); + $parser = new SimpleHtmlSaxParser($listener); return $parser; } @@ -188,7 +188,7 @@ class SimplePageBuilder extends SimpleSaxListener { * @access public */ function startElement($name, $attributes) { - $factory = &new SimpleTagBuilder(); + $factory = new SimpleTagBuilder(); $tag = $factory->createTag($name, $attributes); if (! $tag) { return true; @@ -641,7 +641,7 @@ class SimplePage { * @access public */ function acceptFormStart(&$tag) { - $this->_open_forms[] = &new SimpleForm($tag, $this); + $this->_open_forms[] = new SimpleForm($tag, $this); } /** @@ -980,4 +980,4 @@ class SimplePage { return null; } } -?> \ No newline at end of file +?> diff --git a/thirdparty/simpletest/parser.php b/thirdparty/simpletest/parser.php index 3f3b37b83..93f8cf980 100644 --- a/thirdparty/simpletest/parser.php +++ b/thirdparty/simpletest/parser.php @@ -197,7 +197,7 @@ class SimpleLexer { $this->_case = $case; $this->_regexes = array(); $this->_parser = &$parser; - $this->_mode = &new SimpleStateStack($start); + $this->_mode = new SimpleStateStack($start); $this->_mode_handlers = array($start => $start); } @@ -579,7 +579,7 @@ class SimpleHtmlSaxParser { * @static */ function &createLexer(&$parser) { - $lexer = &new SimpleHtmlLexer($parser); + $lexer = new SimpleHtmlLexer($parser); return $lexer; } @@ -761,4 +761,4 @@ class SimpleSaxListener { function addContent($text) { } } -?> \ No newline at end of file +?> diff --git a/thirdparty/simpletest/url.php b/thirdparty/simpletest/url.php index 0ea220409..d3461657a 100644 --- a/thirdparty/simpletest/url.php +++ b/thirdparty/simpletest/url.php @@ -106,7 +106,7 @@ class SimpleUrl { } if (preg_match('/^([^\/]*)@(.*)/', $url, $matches)) { $url = $prefix . $matches[2]; - $parts = split(":", $matches[1]); + $parts = preg_split('/:/', $matches[1]); return array( urldecode($parts[0]), isset($parts[1]) ? urldecode($parts[1]) : false); @@ -184,7 +184,7 @@ class SimpleUrl { function _parseRequest($raw) { $this->_raw = $raw; $request = new SimpleGetEncoding(); - foreach (split("&", $raw) as $pair) { + foreach (preg_split('/&/', $raw) as $pair) { if (preg_match('/(.*?)=(.*)/', $pair, $matches)) { $request->add($matches[1], urldecode($matches[2])); } elseif ($pair) { @@ -379,7 +379,7 @@ class SimpleUrl { */ function clearRequest() { $this->_raw = false; - $this->_request = &new SimpleGetEncoding(); + $this->_request = new SimpleGetEncoding(); } /** @@ -525,4 +525,4 @@ class SimpleUrl { return 'com|edu|net|org|gov|mil|int|biz|info|name|pro|aero|coop|museum'; } } -?> \ No newline at end of file +?>