diff --git a/sites/all/modules/contrib/views/views/README.txt b/sites/all/modules/contrib/views/views/README.txt index 8097eb4..3e361c5 100644 --- a/sites/all/modules/contrib/views/views/README.txt +++ b/sites/all/modules/contrib/views/views/README.txt @@ -1,19 +1,50 @@ +CONTENTS OF THIS FILE +--------------------- + + * Introduction + * Requirements + * Installation + * Configuration + * Recommended + + +INTRODUCTION +------------ Welcome to Views 3. Please see the advanced help for more information. -If you're having trouble installing this module, please ensure that your -tar program is not flattening the directory tree, truncating filenames -or losing files. +If you're having trouble installing this module, please ensure that your tar +program is not flattening the directory tree, truncating filenames or losing +files. -Installing Views: -Place the entirety of this directory in sites/all/modules/views -You must also install the CTools module (http://www.drupal.org/project/ctools) to use Views. +REQUIREMENTS +------------ -Navigate to administer >> build >> modules. Enable Views and Views UI. +This module requires the following modules: -If you're new to Views, try the Simple Views module which can create some -often used Views for you, this might save you some time. + * Chaos tool suite (ctools) (https://drupal.org/project/ctools) -Here you can find many modules extending the functionality of Views: - http://drupal.org/taxonomy/term/89 + +INSTALLATION +------------ + +Install as you would normally install a contributed Drupal module. See: +https://drupal.org/documentation/install/modules-themes/modules-7 for further +information. + +Navigate to administer >> modules. Enable Views and Views UI. + + +RECOMMENDED +----------- + + * SimpleViews (https://www.drupal.org/project/simpleviews): + If you're new to Views, try the Simple Views which can create some often used + Views for you, this might save you some time. + + * Advanced help (https://www.drupal.org/project/advanced_help): + If you enable the advanced help, Views will provide more and better help. + + * Here you can find many modules extending the functionality of Views: + http://drupal.org/taxonomy/term/89 diff --git a/sites/all/modules/contrib/views/views/css/views-admin-rtl.css b/sites/all/modules/contrib/views/views/css/views-admin-rtl.css index 6d1e03a..fe68652 100644 --- a/sites/all/modules/contrib/views/views/css/views-admin-rtl.css +++ b/sites/all/modules/contrib/views/views/css/views-admin-rtl.css @@ -22,7 +22,7 @@ */ .form-actions { - float: left; + float: right; } /* @end */ diff --git a/sites/all/modules/contrib/views/views/css/views-admin.bartik-rtl.css b/sites/all/modules/contrib/views/views/css/views-admin.bartik-rtl.css index abf2a30..7075978 100644 --- a/sites/all/modules/contrib/views/views/css/views-admin.bartik-rtl.css +++ b/sites/all/modules/contrib/views/views/css/views-admin.bartik-rtl.css @@ -3,7 +3,7 @@ * in the Bartik theme. */ - /* @group Lists */ +/* @group Lists */ .views-display-top .secondary .action-list { padding-right: 0; diff --git a/sites/all/modules/contrib/views/views/css/views-admin.bartik.css b/sites/all/modules/contrib/views/views/css/views-admin.bartik.css index c6f0692..d5cfeb6 100644 --- a/sites/all/modules/contrib/views/views/css/views-admin.bartik.css +++ b/sites/all/modules/contrib/views/views/css/views-admin.bartik.css @@ -42,7 +42,7 @@ } .views-displays .secondary .open > a:hover { - color: #0071B3; + color: #0071b3; } .views-displays .secondary input.form-submit { @@ -57,7 +57,7 @@ */ .views-filterable-options .even .form-type-checkbox { - background-color: #F9F9F9; + background-color: #f9f9f9; } .views-ui-dialog .ui-dialog-titlebar-close, @@ -83,29 +83,28 @@ /* @group Buttons */ .ctools-button-processed { - background-image: - -moz-linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); - background-image: - -webkit-gradient( - linear, - left top, - left bottom, - color-stop(0.0, rgba(255, 255, 255, 1.0)), - color-stop(1.0, rgba(249, 249, 249, 1.0)) - ); - background-image: - -webkit-linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); - background-image: - linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); + background-image: -moz-linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); + background-image: -webkit-gradient( + linear, + left top, + left bottom, + color-stop(0.0, rgba(255, 255, 255, 1.0)), + color-stop(1.0, rgba(249, 249, 249, 1.0)) + ); + background-image: -webkit-linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); + background-image: linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; @@ -114,29 +113,28 @@ } .ctools-button-processed:hover { - background-image: - -moz-linear-gradient( - -90deg, - #ffffff 0px, - #f1f1f1 100%); - background-image: - -webkit-gradient( - linear, - left top, - left bottom, - color-stop(0.0, rgba(255, 255, 255, 1.0)), - color-stop(1.0, rgba(241, 241, 241, 1.0)) - ); - background-image: - -webkit-linear-gradient( - -90deg, - #ffffff 0px, - #f1f1f1 100%); - background-image: - linear-gradient( - -90deg, - #ffffff 0px, - #f1f1f1 100%); + background-image: -moz-linear-gradient( + -90deg, + #fff 0px, + #f1f1f1 100% + ); + background-image: -webkit-gradient( + linear, + left top, + left bottom, + color-stop(0.0, rgba(255, 255, 255, 1.0)), + color-stop(1.0, rgba(241, 241, 241, 1.0)) + ); + background-image: -webkit-linear-gradient( + -90deg, + #fff 0px, + #f1f1f1 100% + ); + background-image: linear-gradient( + -90deg, + #fff 0px, + #f1f1f1 100% + ); } .ctools-button-processed li a, @@ -150,29 +148,28 @@ } .ctools-dropbutton-processed.open:hover { - background-image: - -moz-linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); - background-image: - -webkit-gradient( - linear, - left top, - left bottom, - color-stop(0.0, rgba(255, 255, 255, 1.0)), - color-stop(1.0, rgba(249, 249, 249, 1.0)) - ); - background-image: - -webkit-linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); - background-image: - linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); + background-image: -moz-linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); + background-image: -webkit-gradient( + linear, + left top, + left bottom, + color-stop(0.0, rgba(255, 255, 255, 1.0)), + color-stop(1.0, rgba(249, 249, 249, 1.0)) + ); + background-image: -webkit-linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); + background-image: linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); } .ctools-dropbutton-processed.open { @@ -220,12 +217,12 @@ } .views-ui-display-tab-actions .ctools-button input { - color: #0071B3; + color: #0071b3; } .views-ui-display-tab-actions .ctools-button input:hover, .views-ui-display-tab-actions .ctools-button input:focus { - color: #018FE2; + color: #018fe2; } /* @end */ diff --git a/sites/all/modules/contrib/views/views/css/views-admin.css b/sites/all/modules/contrib/views/views/css/views-admin.css index 7ce7088..7b367fd 100644 --- a/sites/all/modules/contrib/views/views/css/views-admin.css +++ b/sites/all/modules/contrib/views/views/css/views-admin.css @@ -117,12 +117,12 @@ * * The tabs that switch between sections */ - .views-displays .secondary { - border-bottom: 0 none; - margin: 0; - overflow: visible; - padding: 0; - } +.views-displays .secondary { + border-bottom: 0 none; + margin: 0; + overflow: visible; + padding: 0; +} .views-displays .secondary > li { border-right: 0 none; diff --git a/sites/all/modules/contrib/views/views/css/views-admin.ctools-rtl.css b/sites/all/modules/contrib/views/views/css/views-admin.ctools-rtl.css index 338b2fb..7fc8649 100644 --- a/sites/all/modules/contrib/views/views/css/views-admin.ctools-rtl.css +++ b/sites/all/modules/contrib/views/views/css/views-admin.ctools-rtl.css @@ -10,7 +10,7 @@ } .ctools-dropbutton .ctools-link { - border-right: 1px solid #ffffff; + border-right: 1px solid #fff; } .ctools-dropbutton li { diff --git a/sites/all/modules/contrib/views/views/css/views-admin.ctools.css b/sites/all/modules/contrib/views/views/css/views-admin.ctools.css index b1f0e29..4c994ce 100644 --- a/sites/all/modules/contrib/views/views/css/views-admin.ctools.css +++ b/sites/all/modules/contrib/views/views/css/views-admin.ctools.css @@ -1,8 +1,8 @@ /* @group Buttons */ .ctools-button-processed { - background-color: #ffffff; - border-color: #cccccc; + background-color: #fff; + border-color: #ccc; font-size: 11px; padding-bottom: 2px; padding-top: 2px; @@ -46,7 +46,7 @@ } .ctools-dropbutton-processed.open:hover { - border-color: #D0D0D0; + border-color: #d0d0d0; } .ctools-dropbutton-processed.open { @@ -54,11 +54,11 @@ } .ctools-dropbutton-processed .ctools-link { - border-left: 1px solid #ffffff; + border-left: 1px solid #fff; } .ctools-dropbutton-processed.open .ctools-content { - padding-bottom: 4px; + padding-bottom: 4px; } .ctools-dropbutton-processed li a, @@ -132,7 +132,7 @@ .ctools-toggle.ctools-toggle-collapsed { border-bottom-color: transparent; - border-left: 4px solid; + border-left: 4px solid; border-right-color: transparent; border-top-color: transparent; border-width: 5px 0 5px 5px; @@ -158,7 +158,7 @@ } .views-display-settings .ctools-toggle { - color: #000000; + color: #000; } .views-display-column > .ctools-toggle { @@ -173,7 +173,7 @@ } .views-display-column > .ctools-collapsible-handle { - border-color: #F3F3F3; + border-color: #f3f3f3; border-style: solid; border-width: 1px 1px 0; font-size: 13px; @@ -225,7 +225,7 @@ h2.ctools-collapsible-handle { /* @group Jump list */ -#views-live-preview .ctools-jump-menu-select{ +#views-live-preview .ctools-jump-menu-select { max-width: 450px; } diff --git a/sites/all/modules/contrib/views/views/css/views-admin.garland-rtl.css b/sites/all/modules/contrib/views/views/css/views-admin.garland-rtl.css index 9a8de6d..99a761e 100644 --- a/sites/all/modules/contrib/views/views/css/views-admin.garland-rtl.css +++ b/sites/all/modules/contrib/views/views/css/views-admin.garland-rtl.css @@ -3,11 +3,11 @@ * in the Garland theme. */ - /* @group Lists */ +/* @group Lists */ .views-displays .secondary .action-list { left: auto; right: 1px; } - /* @end */ +/* @end */ diff --git a/sites/all/modules/contrib/views/views/css/views-admin.garland.css b/sites/all/modules/contrib/views/views/css/views-admin.garland.css index cd9010a..dc2734f 100644 --- a/sites/all/modules/contrib/views/views/css/views-admin.garland.css +++ b/sites/all/modules/contrib/views/views/css/views-admin.garland.css @@ -54,7 +54,7 @@ .views-displays .secondary .open > a:hover { border-color: #e9e9e9 #e9e9e9 #f1f1f1 #e9e9e9; border-width: 1px 1px 1px 1px; - color: #0071B3; + color: #0071b3; } .views-displays .secondary input.form-submit { @@ -84,7 +84,7 @@ } .views-filterable-options .even .form-type-checkbox { - background-color: #F9F9F9; + background-color: #f9f9f9; } .views-ui-dialog .ui-dialog-titlebar-close, @@ -101,29 +101,28 @@ /* @group Buttons */ .ctools-button-processed { - background-image: - -moz-linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); - background-image: - -webkit-gradient( - linear, - left top, - left bottom, - color-stop(0.0, rgba(255, 255, 255, 1.0)), - color-stop(1.0, rgba(249, 249, 249, 1.0)) - ); - background-image: - -webkit-linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); - background-image: - linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); + background-image: -moz-linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); + background-image: -webkit-gradient( + linear, + left top, + left bottom, + color-stop(0.0, rgba(255, 255, 255, 1.0)), + color-stop(1.0, rgba(249, 249, 249, 1.0)) + ); + background-image: -webkit-linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); + background-image: linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; @@ -132,29 +131,28 @@ } .ctools-button-processed:hover { - background-image: - -moz-linear-gradient( - -90deg, - #ffffff 0px, - #f1f1f1 100%); - background-image: - -webkit-gradient( - linear, - left top, - left bottom, - color-stop(0.0, rgba(255, 255, 255, 1.0)), - color-stop(1.0, rgba(241, 241, 241, 1.0)) - ); - background-image: - -webkit-linear-gradient( - -90deg, - #ffffff 0px, - #f1f1f1 100%); - background-image: - linear-gradient( - -90deg, - #ffffff 0px, - #f1f1f1 100%); + background-image: -moz-linear-gradient( + -90deg, + #fff 0px, + #f1f1f1 100% + ); + background-image: -webkit-gradient( + linear, + left top, + left bottom, + color-stop(0.0, rgba(255, 255, 255, 1.0)), + color-stop(1.0, rgba(241, 241, 241, 1.0)) + ); + background-image: -webkit-linear-gradient( + -90deg, + #fff 0px, + #f1f1f1 100% + ); + background-image: linear-gradient( + -90deg, + #fff 0px, + #f1f1f1 100% + ); } .ctools-button-processed ol li, @@ -172,29 +170,28 @@ } .ctools-dropbutton-processed.open:hover { - background-image: - -moz-linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); - background-image: - -webkit-gradient( - linear, - left top, - left bottom, - color-stop(0.0, rgba(255, 255, 255, 1.0)), - color-stop(1.0, rgba(249, 249, 249, 1.0)) - ); - background-image: - -webkit-linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); - background-image: - linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); + background-image: -moz-linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); + background-image: -webkit-gradient( + linear, + left top, + left bottom, + color-stop(0.0, rgba(255, 255, 255, 1.0)), + color-stop(1.0, rgba(249, 249, 249, 1.0)) + ); + background-image: -webkit-linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); + background-image: linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); } .ctools-dropbutton-processed.open { @@ -249,13 +246,13 @@ } .views-ui-display-tab-actions .ctools-button input { - color: #027AC6; + color: #027ac6; font-size: 12px; } .views-ui-display-tab-actions .ctools-button input:hover, .views-ui-display-tab-actions .ctools-button input:focus { - color: #0062A0; + color: #0062a0; } /* @end */ diff --git a/sites/all/modules/contrib/views/views/css/views-admin.seven.css b/sites/all/modules/contrib/views/views/css/views-admin.seven.css index d58bb1b..3f879a2 100644 --- a/sites/all/modules/contrib/views/views/css/views-admin.seven.css +++ b/sites/all/modules/contrib/views/views/css/views-admin.seven.css @@ -213,14 +213,14 @@ fieldset.fieldset-no-legend { /* Override for input elements that are themed like ctools-buttons */ .ctools-button-processed input.form-submit:hover { background-image: none; - color: #0074BD; + color: #0074bd; text-shadow: none; } .ctools-button-processed input.form-submit:active { background: none; border: medium none; - color: #0074BD; + color: #0074bd; text-shadow: none; } @@ -238,7 +238,7 @@ table th { /* @group Attachment details */ #edit-display-settings-title { - color: #008BCB; + color: #008bcb; } /* @end */ @@ -249,11 +249,11 @@ table th { */ .views-displays .secondary { - text-align: left; /* LTR */ + text-align: left; /* LTR */ } .views-displays .secondary > li:first-child { - padding-left: 0; + padding-left: 0; } .views-admin .icon.add { @@ -265,7 +265,7 @@ table th { -moz-border-radius: 7px; -webkit-border-radius: 7px; border-radius: 7px; - color: #008BCB; + color: #008bcb; } .views-displays .secondary a:hover > .icon.add { @@ -280,7 +280,7 @@ table th { .views-displays .secondary .open > a:hover { background-color: #f1f1f1; - color: #008BCB; + color: #008bcb; } .views-displays .secondary .action-list li:first-child { @@ -299,7 +299,7 @@ table th { -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0; - color: #008BCB; + color: #008bcb; } /* @end */ @@ -349,11 +349,11 @@ table th { } #views-ui-rearrange-filter-form tr.drag td { - background-color: #FFEE77 !important; + background-color: #ffee77 !important; } #views-ui-rearrange-filter-form tr.drag-previous td { - background-color: #FFFFBB !important; + background-color: #ffffbb !important; } /* @end */ @@ -402,7 +402,7 @@ table th { -moz-box-shadow: none; -webkit-box-shadow: none; box-shadow: none; - border-color: #cccccc; + border-color: #ccc; right: -27px; top: -1px; } @@ -429,84 +429,81 @@ table th { /* @group Buttons */ .ctools-button-processed { - background-image: - -moz-linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); - background-image: - -webkit-gradient( - linear, - left top, - left bottom, - color-stop(0.0, rgba(255, 255, 255, 1.0)), - color-stop(1.0, rgba(249, 249, 249, 1.0)) - ); - background-image: - -webkit-linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); - background-image: - linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); + background-image: -moz-linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); + background-image: -webkit-gradient( + linear, + left top, + left bottom, + color-stop(0.0, rgba(255, 255, 255, 1.0)), + color-stop(1.0, rgba(249, 249, 249, 1.0)) + ); + background-image: -webkit-linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); + background-image: linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); -moz-border-radius: 11px 11px 11px 11px; -webkit-border-radius: 11px 11px 11px 11px; border-radius: 11px 11px 11px 11px; } .ctools-button-processed:hover { - background-image: - -moz-linear-gradient( - -90deg, - #ffffff 0px, - #f1f1f1 100%); - background-image: - -webkit-gradient( - linear, - left top, - left bottom, - color-stop(0.0, rgba(255, 255, 255, 1.0)), - color-stop(1.0, rgba(241, 241, 241, 1.0)) - ); - background-image: - -webkit-linear-gradient( - -90deg, - #ffffff 0px, - #f1f1f1 100%); - background-image: - linear-gradient( - -90deg, - #ffffff 0px, - #f1f1f1 100%); + background-image: -moz-linear-gradient( + -90deg, + #fff 0px, + #f1f1f1 100% + ); + background-image: -webkit-gradient( + linear, + left top, + left bottom, + color-stop(0.0, rgba(255, 255, 255, 1.0)), + color-stop(1.0, rgba(241, 241, 241, 1.0)) + ); + background-image: -webkit-linear-gradient( + -90deg, + #fff 0px, + #f1f1f1 100% + ); + background-image: linear-gradient( + -90deg, + #fff 0px, + #f1f1f1 100% + ); } .ctools-dropbutton-processed.open:hover { - background-image: - -moz-linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); - background-image: - -webkit-gradient( - linear, - left top, - left bottom, - color-stop(0.0, rgba(255, 255, 255, 1.0)), - color-stop(1.0, rgba(249, 249, 249, 1.0)) - ); - background-image: - -webkit-linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); - background-image: - linear-gradient( - -90deg, - #ffffff 0px, - #f9f9f9 100%); + background-image: -moz-linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); + background-image: -webkit-gradient( + linear, + left top, + left bottom, + color-stop(0.0, rgba(255, 255, 255, 1.0)), + color-stop(1.0, rgba(249, 249, 249, 1.0)) + ); + background-image: -webkit-linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); + background-image: linear-gradient( + -90deg, + #fff 0px, + #f9f9f9 100% + ); } .ctools-dropbutton-processed.open { @@ -528,7 +525,7 @@ table th { } .views-display-settings .ctools-toggle { - color: #008BCB; + color: #008bcb; } .views-display-column > .ctools-toggle { @@ -540,11 +537,11 @@ table th { } .views-display-column > .ctools-collapsible-handle { - color: #008BCB; + color: #008bcb; } .views-ui-display-tab-actions .ctools-button-processed input { - color: #0074BD; + color: #0074bd; } /* @end */ diff --git a/sites/all/modules/contrib/views/views/css/views-admin.theme.css b/sites/all/modules/contrib/views/views/css/views-admin.theme.css index 8611783..d92a47e 100644 --- a/sites/all/modules/contrib/views/views/css/views-admin.theme.css +++ b/sites/all/modules/contrib/views/views/css/views-admin.theme.css @@ -39,35 +39,34 @@ .views-admin .icon, .views-admin .icon-text { background-attachment: scroll; - background-image: url("../images/sprites.png"); + background-image: url('../images/sprites.png'); background-position: left top; /* LTR */ background-repeat: no-repeat; } .views-admin a.icon { - background-image: - url("../images/sprites.png"), - -moz-linear-gradient( - -90deg, - #ffffff 0px, - #e8e8e8 100%); - background-image: - url("../images/sprites.png"), - -webkit-gradient( - linear, - left top, - left bottom, - color-stop(0.0, rgba(255, 255, 255, 1.0)), - color-stop(1.0, rgba(232, 232, 232, 1.0)) - ); - background-image: - url("../images/sprites.png"), - -webkit-linear-gradient( - -90deg, - #ffffff 0px, - #e8e8e8 100%); + background-image: url('../images/sprites.png'), + -moz-linear-gradient( + -90deg, + #fff 0px, + #e8e8e8 100% + ); + background-image: url('../images/sprites.png'), + -webkit-gradient( + linear, + left top, + left bottom, + color-stop(0.0, rgba(255, 255, 255, 1.0)), + color-stop(1.0, rgba(232, 232, 232, 1.0)) + ); + background-image: url('../images/sprites.png'), + -webkit-linear-gradient( + -90deg, + #fff 0px, + #e8e8e8 100% + ); background-repeat: no-repeat, repeat-y; - border: 1px solid #dddddd; + border: 1px solid #ddd; -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; @@ -206,7 +205,7 @@ input.form-radio { /* Hide 'remove' checkboxes. */ .views-remove-checkbox { - display: none; + display: none; } /* sizes the labels of checkboxes and radio button to the height of the text */ @@ -406,13 +405,13 @@ td.group-title { /* @group Attachments */ .views-displays { - border: 1px solid #CCC; + border: 1px solid #ccc; padding-bottom: 36px; } .views-display-top { - background-color: #F9F9F9; - border-bottom: 1px solid #CCCCCC; + background-color: #f9f9f9; + border-bottom: 1px solid #ccc; padding: 8px 8px 8px; /* LTR */ position: relative; } @@ -453,7 +452,7 @@ ul#views-display-menu-tabs li { margin-bottom: 5px; } -ul#views-display-menu-tabs li.add ul.action-list li{ +ul#views-display-menu-tabs li.add ul.action-list li { margin: 0; } @@ -470,7 +469,7 @@ ul#views-display-menu-tabs li.add ul.action-list li{ */ .views-displays ul.secondary li.active a.active.error, .views-displays .secondary a.error { - border: 2px solid #ED541D; + border: 2px solid #ed541d; padding: 1px 6px; } @@ -480,8 +479,8 @@ ul#views-display-menu-tabs li.add ul.action-list li{ .views-displays .secondary a:hover, .views-displays .secondary .active a { - background-color: #666666; - color: #ffffff; + background-color: #666; + color: #fff; border-bottom-width: 1px; } @@ -523,7 +522,7 @@ ul#views-display-menu-tabs li.add ul.action-list li{ } .views-displays .secondary .action-list li:hover { - background-color: #dddddd; + background-color: #ddd; } /* @end */ @@ -556,10 +555,10 @@ ul#views-display-menu-tabs li.add ul.action-list li{ */ .views-display-column + .views-display-column { - margin-top: 0; - } + margin-top: 0; +} - /* @end */ +/* @end */ /* @group Auto preview * @@ -683,7 +682,7 @@ ul#views-display-menu-tabs li.add ul.action-list li{ */ .views-ui-display-tab-bucket .views-display-setting { - color: #666666; + color: #666; font-size: 12px; padding-bottom: 2px; } @@ -753,8 +752,8 @@ ul#views-display-menu-tabs li.add ul.action-list li{ } .views-ui-dialog .ui-dialog-titlebar-close { - background: url("../images/close.png") no-repeat scroll 6px 3px #F3F4EE; - border-color: #aaaaaa; + background: url('../images/close.png') no-repeat scroll 6px 3px #f3f4ee; + border-color: #aaa; -moz-border-radius: 0 10px 12px 0; -webkit-border-radius: 0 10px 12px 0; border-radius: 0 10px 12px 0; @@ -774,17 +773,17 @@ ul#views-display-menu-tabs li.add ul.action-list li{ } .views-filterable-options .form-type-checkbox { - border: 1px solid #CCC; + border: 1px solid #ccc; padding: 5px 8px; border-top: none; } .views-filterable-options { - border-top: 1px solid #CCC; + border-top: 1px solid #ccc; } .views-filterable-options .even .form-type-checkbox { - background-color: #F3F4EE; + background-color: #f3f4ee; } .filterable-option .form-item { @@ -830,7 +829,7 @@ ul#views-display-menu-tabs li.add ul.action-list li{ .views-ui-dialog #views-ajax-title, .views-ui-dialog .views-override { - background-color: #F3F4EE; + background-color: #f3f4ee; } .views-ui-dialog .views-override { @@ -862,7 +861,7 @@ ul#views-display-menu-tabs li.add ul.action-list li{ } .views-ui-dialog .scroll { - border: 1px solid #CCC; + border: 1px solid #ccc; border-width: 1px 0; padding: 8px 13px; } @@ -872,7 +871,7 @@ ul#views-display-menu-tabs li.add ul.action-list li{ } .views-ui-dialog .form-buttons { - background-color: #F3F4EE; + background-color: #f3f4ee; padding: 8px 13px; } .views-ui-dialog .form-buttons input { @@ -888,7 +887,7 @@ ul#views-display-menu-tabs li.add ul.action-list li{ /* @todo Make this a class to be used anywhere there's node types? */ .form-type-checkboxes #edit-options-value, .form-type-checkboxes #edit-options-validate-options-node-types { - border-color: #CCCCCC; + border-color: #ccc; border-style: solid; border-width: 1px; max-height: 210px; @@ -907,25 +906,25 @@ ul#views-display-menu-tabs li.add ul.action-list li{ } #views-ui-rearrange-filter-form tr td[rowspan] { - border-color: #CDCDCD; + border-color: #cdcdcd; border-style: solid; border-width: 0 1px 1px 1px; } #views-ui-rearrange-filter-form tr[id^="views-row"] { - border-right: 1px solid #CDCDCD; + border-right: 1px solid #cdcdcd; } #views-ui-rearrange-filter-form tr[id^="views-row"].even td { - background-color: #F3F4ED; + background-color: #f3f4ed; } #views-ui-rearrange-filter-form .views-group-title { - border-top: 1px solid #CDCDCD; + border-top: 1px solid #cdcdcd; } #views-ui-rearrange-filter-form .group-empty { - border-bottom: 1px solid #CDCDCD; + border-bottom: 1px solid #cdcdcd; } /* @end */ @@ -945,8 +944,8 @@ ul#views-display-menu-tabs li.add ul.action-list li{ /* @group Live preview elements */ #views-preview-wrapper { - border: 1px solid #CCC; - border-top: 2px solid #CCC; + border: 1px solid #ccc; + border-top: 2px solid #ccc; padding-bottom: 12px; padding-top: 12px; } @@ -979,7 +978,7 @@ ul#views-display-menu-tabs li.add ul.action-list li{ } #views-live-preview .preview-section { - border: 1px dashed #DEDEDE; + border: 1px dashed #dedede; margin: 0 -5px; padding: 3px 5px; } @@ -997,7 +996,7 @@ ul#views-display-menu-tabs li.add ul.action-list li{ .views-query-info table { border-collapse: separate; - border-color: #dddddd; + border-color: #ddd; border-spacing: 0; margin: 10px 0; } @@ -1008,7 +1007,7 @@ ul#views-display-menu-tabs li.add ul.action-list li{ .views-query-info table th, .views-query-info table td { - color: #666666; + color: #666; padding: 4px 10px; } @@ -1058,7 +1057,7 @@ ul#views-display-menu-tabs li.add ul.action-list li{ .ajax-progress-throbber { background-color: #232323; - background-image: url("../images/loading-small.gif"); + background-image: url('../images/loading-small.gif'); background-position: center center; background-repeat: no-repeat; -moz-border-radius: 7px; diff --git a/sites/all/modules/contrib/views/views/css/views-rtl.css b/sites/all/modules/contrib/views/views/css/views-rtl.css index f804639..0c0c0e0 100644 --- a/sites/all/modules/contrib/views/views/css/views-rtl.css +++ b/sites/all/modules/contrib/views/views/css/views-rtl.css @@ -1,4 +1,3 @@ - .views-exposed-form .views-exposed-widget { float: right; /* RTL */ padding: .5em 1em 0 0; /* RTL */ diff --git a/sites/all/modules/contrib/views/views/drush/views.drush.inc b/sites/all/modules/contrib/views/views/drush/views.drush.inc index dd8af1b..e4ccfb4 100644 --- a/sites/all/modules/contrib/views/views/drush/views.drush.inc +++ b/sites/all/modules/contrib/views/views/drush/views.drush.inc @@ -2,14 +2,15 @@ /** * @file - * Drush integration of views. + * Drush integration for Views. * - * drush cache-clear views - Clears the views specific caches. - * views-revert - Drush command to revert views overridden in the system. + * Useful commands: + * - drush cache-clear views - Clears the views specific caches. + * - views-revert - Drush command to revert views overridden in the system. */ /** - * Implement hook_drush_help(). + * Implements hook_drush_help(). */ function views_drush_help($section) { switch ($section) { @@ -18,17 +19,20 @@ function views_drush_help($section) { $help .= dt('If no view names are specified, you will be presented with a list of overridden views to choose from. '); $help .= dt('To revert all views, do not specify any view names, and choose the option "All" from the options presented.'); return $help; + case 'drush:views-list': return dt('Show a list of available views with information about them.'); + case 'drush:views-enable': return dt('Enable the specified views. Follow the command with a space delimited list of view names'); + case 'drush:views-disable': return dt('Disable the specified views. Follow the command with a space delimited list of view names'); } } /** - * Implement hook_drush_command(). + * Implements hook_drush_command(). */ function views_drush_command() { $items = array(); @@ -42,10 +46,14 @@ function views_drush_command() { ), 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL, 'aliases' => array('vr'), + 'options' => array( + 'all' => 'If provided, all views will be reverted.', + ), 'examples' => array( 'drush vr archive' => 'Reverts the "archive" view.', 'drush rln archive frontpage' => 'Reverts the "archive" and "frontpage" view.', 'drush vr' => 'Will present you with a list of overridden views to choose from, and an option to revert all overridden views.', + 'drush vr --all' => 'Will revert all overridden views.', ), ); $items['views-dev'] = array( @@ -66,7 +74,7 @@ function views_drush_command() { 'tags' => 'A comma-separated list of views tags by which to filter the results.', 'status' => 'Status of the views by which to filter the results. Choices: enabled, disabled.', 'type' => 'Type of the views by which to filter the results. Choices: normal, default or overridden.', - ), + ), 'examples' => array( 'drush vl' => 'Show a list of all available views.', 'drush vl --name=blog' => 'Show a list of views which names contain "blog".', @@ -126,17 +134,23 @@ function views_revert_views() { } } - // Return early if there are no overridden views in the system. + // If there are no overridden views in the system, report it. if (empty($overridden)) { - return drush_set_error(dt('There are no overridden views in the system.')); + drush_log(dt('There are no overridden views in the system.'), 'ok'); } - // If the user specified in the command the views to be overridden. - if (!empty($viewnames)) { + // If the user provided the "--all" option, revert all views. + if (drush_get_option('all')) { + $i = views_revert_allviews($views); + } + + // If the user specified a list of views on the CLI, revert those. + elseif (!empty($viewnames)) { foreach ($viewnames as $key => $viewname) { - $is_overridden = key_exists($viewname, $overridden); - // Check if the provided view name is in the system - if ($viewname && !key_exists($viewname, $views)) { + $is_overridden = array_key_exists($viewname, $overridden); + + // Check if the provided view name is in the system. + if ($viewname && !array_key_exists($viewname, $views)) { drush_set_error(dt("'@viewname' view is not present in the system.", array('@viewname' => $viewname))); } // Check if the provided view is overridden. @@ -144,29 +158,34 @@ function views_revert_views() { drush_set_error(dt("The view specified '@viewname' is not overridden.", array('@viewname' => $viewname))); } // If the view is overriden, revert it. - elseif ($is_overridden){ + elseif ($is_overridden) { views_revert_view($views[$viewname]); $i++; } - // We should never get here but well... + // We should never get here but well. else { - drush_set_error(dt("The view specified '@viewname' is not provided in code, and thus cannot be reverted.", array('@viewname' => $viewname))); + drush_set_error(dt( + "The view specified '@viewname' is not provided in code, and thus cannot be reverted.", + array('@viewname' => $viewname) + )); } } } - // The user did not specify any views in the command, prompt the user + // The user neither selected the "--all" option, nor provided a list of views + // to revert. Prompt the user. else { - // list of choices for the user - $overridden['all'] = dt('Revert all overridden views'); // add a choice at the end - $choice = drush_choice($overridden, 'Enter a number to choose which view to revert.', '!key'); // prompt the user - + // List of choices for the user. + $overridden['all'] = dt('Revert all overridden views'); + // Add a choice at the end. + $choice = drush_choice($overridden, 'Enter a number to choose which view to revert.', '!key'); + // Prompt the user. if ($choice !== FALSE) { - // revert all views option + // Revert all views option. if ($choice == 'all') { $i = views_revert_allviews($views); } - // else the user specified a single view + // Else the user specified a single view. else { views_revert_view($views[$choice]); $i++; @@ -175,7 +194,7 @@ function views_revert_views() { } - // final results output + // Final results output. if ($i == 0) { drush_log(dt('No views were reverted.'), 'ok'); } @@ -185,9 +204,10 @@ function views_revert_views() { } /** - * Reverts all views - * @param $views - * All views in the system as provided by views_get_all_views(). + * Reverts all views. + * + * @param array $views + * All views in the system as provided by views_get_all_views(). */ function views_revert_allviews($views) { $i = 0; @@ -205,15 +225,17 @@ function views_revert_allviews($views) { } /** - * Revert a specified view - * @param $view - * The view object to be reverted + * Revert a specified view. * - * Checks on wether or not the view is overridden is handled in views_revert_views_revert() - * We perform a check here anyway in case someone somehow calls this function on their own... + * Checks on wether or not the view is overridden is handled in + * views_revert_views_revert(). We perform a check here anyway in case someone + * somehow calls this function on their own... + * + * @param object $view + * The view object to be reverted. */ function views_revert_view($view) { - // check anyway just in case + // Check anyway just in case. if ($view->type == t('Overridden')) { // Revert the view. $view->delete(); @@ -255,7 +277,7 @@ function views_development_settings() { * Callback function for views-list command. */ function drush_views_list() { - // Initialize stuf + // Initialize stuff. $rows = array(); $disabled_views = array(); $enabled_views = array(); @@ -267,19 +289,18 @@ function drush_views_list() { $views = views_get_all_views(); - // get the --name option - // TODO : take into account the case off a comma-separated list of names + // Get the --name option. + // @todo Take into account the case off a comma-separated list of names. $name = drush_get_option_list('name'); $with_name = !empty($name) ? TRUE : FALSE; - // get the --tags option + // Get the --tags option. $tags = drush_get_option_list('tags'); $with_tags = !empty($tags) ? TRUE : FALSE; - // get the --status option - // store user input appart to reuse it after + // Get the --status option. Store user input appart to reuse it after. $status_opt = drush_get_option_list('status'); - // use the same logic than $view->disabled + // Use the same logic than $view->disabled. if (in_array('disabled', $status_opt)) { $status = TRUE; $with_status = TRUE; @@ -290,19 +311,19 @@ function drush_views_list() { } else { $status = NULL; - // wrong or empty --status option + // Wrong or empty --status option. $with_status = FALSE; } - // get the --type option + // Get the --type option. $type = drush_get_option_list('type'); - // use the same logic than $view->type + // Use the same logic than $view->type. $with_type = FALSE; if (in_array('normal', $type) || in_array('default', $type)|| in_array('overridden', $type)) { $with_type = TRUE; } - // set the table headers + // Set the table headers. $header = array( dt('Machine name'), dt('Description'), @@ -311,10 +332,10 @@ function drush_views_list() { dt('Tag'), ); - // setup a row for each view - foreach($views as $id => $view){ - // if options were specified, check that first - // mismatch push the loop to the next view + // Setup a row for each view. + foreach ($views as $id => $view) { + // If options were specified, check that first mismatch push the loop to + // the next view. if ($with_tags && !in_array($view->tag, $tags)) { continue; } @@ -329,25 +350,25 @@ function drush_views_list() { } $row = array(); - // each row entry should be in the same order as the header + // Each row entry should be in the same order as the header. $row[] = $view->name; $row[] = $view->description; $row[] = $view->type; $row[] = $view->disabled ? dt('Disabled') : dt('Enabled'); $row[] = $view->tag; - // place the row in the appropiate array, - // so we can have disabled views at the bottom - if($view->disabled) { + // Place the row in the appropiate array so we can have disabled views at + // the bottom. + if ($view->disabled) { $disabled_views[] = $row; - } - else{ + } + else { $enabled_views[] = $row; } unset($row); - // gather some statistics - switch($view->type) { + // Gather some statistics. + switch ($view->type) { case dt('Normal'): $indb++; break; @@ -365,11 +386,11 @@ function drush_views_list() { $disabled = count($disabled_views); - // sort alphabeticaly + // Sort alphabeticaly. asort($disabled_views); asort($enabled_views); - // if options were used + // If options were used. $summary = ""; if ($with_name || $with_tags || $with_status || $with_type) { $summary = "Views"; @@ -398,23 +419,26 @@ function drush_views_list() { drush_print($summary . "\n"); } - // print all rows as a table + // Print all rows as a table. if ($total > 0) { $rows = array_merge($enabled_views, $disabled_views); - // put the headers as first row + // Put the headers as first row. array_unshift($rows, $header); drush_print_table($rows, TRUE); } - // print the statistics messages + // Print the statistics messages. drush_print(dt("A total of @total views were found in this Drupal installation:", array('@total' => $total))); - drush_print(dt(" @indb views reside only in the database", array('@indb' => $indb ))); + drush_print(dt(" @indb views reside only in the database", array('@indb' => $indb))); drush_print(dt(" @over views are overridden", array('@over' => $overridden))); drush_print(dt(" @incode views are in their default state", array('@incode' => $incode))); drush_print(dt(" @dis views are disabled\n", array('@dis' => $disabled))); } +/** + * Analyze all installed views. + */ function drush_views_analyze() { views_include('analyze'); $messages_count = 0; @@ -426,7 +450,7 @@ function drush_views_analyze() { drush_print($view_name); foreach ($messages as $message) { $messages_count++; - drush_print($message['type'] .': '. $message['message'], 2); + drush_print($message['type'] . ': ' . $message['message'], 2); } } } @@ -434,7 +458,7 @@ function drush_views_analyze() { } /** - * Enables views + * Enables views. */ function drush_views_enable() { $viewnames = _convert_csv_to_array(func_get_args()); @@ -446,7 +470,7 @@ function drush_views_enable() { } /** - * Disables views + * Disables views. */ function drush_views_disable() { $viewnames = _convert_csv_to_array(func_get_args()); @@ -458,9 +482,12 @@ function drush_views_disable() { } /** - * Helper function to enable / disable views - * @param $viewnames: array of viewnames to process - * @param $status: TRUE to disable or FALSE to enable the view + * Helper function to enable / disable views. + * + * @param array $viewnames + * Names of the views to process. + * @param bool $status + * TRUE to disable or FALSE to enable the view. */ function _views_drush_changestatus($viewnames = array(), $status = NULL) { if ($status !== NULL && !empty($viewnames)) { @@ -478,7 +505,7 @@ function _views_drush_changestatus($viewnames = array(), $status = NULL) { drush_set_error(dt("The view '!name' is already !processed", array('!name' => $viewname, '!processed' => $processed))); } } - // If we made changes to views status, save them and clear caches + // If we made changes to views status, save them and clear caches. if ($changed) { variable_set('views_defaults', $views_status); views_invalidate_cache(); @@ -490,6 +517,9 @@ function _views_drush_changestatus($viewnames = array(), $status = NULL) { /** * Adds a cache clear option for views. + * + * @param array $types + * The list of cache types that are available. */ function views_drush_cache_clear(&$types) { $types['views'] = 'views_invalidate_cache'; diff --git a/sites/all/modules/contrib/views/views/handlers/views_handler_area.inc b/sites/all/modules/contrib/views/views/handlers/views_handler_area.inc index 9fed11c..95f51a1 100644 --- a/sites/all/modules/contrib/views/views/handlers/views_handler_area.inc +++ b/sites/all/modules/contrib/views/views/handlers/views_handler_area.inc @@ -2,7 +2,7 @@ /** * @file - * Views area handlers. + * Definition of views_handler_area and views_handler_area_broken. */ /** @@ -20,29 +20,31 @@ class views_handler_area extends views_handler { /** - * Overrides views_handler::init(). - * - * Make sure that no result area handlers are set to be shown when the result - * is empty. + * {@inheritdoc} */ - function init(&$view, &$options) { + public function init(&$view, &$options) { parent::init($view, $options); + // Make sure that no result area handlers are set to be shown when the + // result is empty. if ($this->handler_type == 'empty') { $this->options['empty'] = TRUE; } } /** - * Get this field's label. + * {@inheritdoc} */ - function label() { + public function label() { if (!isset($this->options['label'])) { return $this->ui_name(); } return $this->options['label']; } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $this->definition['field'] = !empty($this->definition['field']) ? $this->definition['field'] : ''; @@ -54,17 +56,17 @@ class views_handler_area extends views_handler { } /** - * Provide extra data to the administration form + * Provide extra data to the administration form. */ - function admin_summary() { + public function admin_summary() { return $this->label(); } /** - * Default options form that provides the label widget that all fields - * should have. + * Default options form that provides the label widget that all fields should + * have. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['label'] = array( '#type' => 'textfield', @@ -83,23 +85,25 @@ class views_handler_area extends views_handler { } /** - * Don't run a query + * Don't run a query. */ - function query() { } + public function query() { + } /** - * Render the area + * Render the area. */ - function render($empty = FALSE) { + public function render($empty = FALSE) { return ''; } /** * Area handlers shouldn't have groupby. */ - function use_group_by() { + public function use_group_by() { return FALSE; } + } /** @@ -108,14 +112,39 @@ class views_handler_area extends views_handler { * @ingroup views_area_handlers */ class views_handler_area_broken extends views_handler_area { - function ui_name($short = FALSE) { + + /** + * {@inheritdoc} + */ + public function ui_name($short = FALSE) { return t('Broken/missing handler'); } - function ensure_my_table() { /* No table to ensure! */ } - function query($group_by = FALSE) { /* No query to run */ } - function render($empty = FALSE) { return ''; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function ensure_my_table() { + // No table to ensure! + } + + /** + * {@inheritdoc} + */ + public function query($group_by = FALSE) { + // No query to run. + } + + /** + * {@inheritdoc} + */ + public function render($empty = FALSE) { + return ''; + } + + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['markup'] = array( '#prefix' => '
', '#value' => t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.'), @@ -123,9 +152,12 @@ class views_handler_area_broken extends views_handler_area { } /** - * Determine if the handler is considered 'broken' + * {@inheritdoc} */ - function broken() { return TRUE; } + public function broken() { + return TRUE; + } + } /** diff --git a/sites/all/modules/contrib/views/views/handlers/views_handler_area_messages.inc b/sites/all/modules/contrib/views/views/handlers/views_handler_area_messages.inc index eb1e22a..2c8bd49 100644 --- a/sites/all/modules/contrib/views/views/handlers/views_handler_area_messages.inc +++ b/sites/all/modules/contrib/views/views/handlers/views_handler_area_messages.inc @@ -2,7 +2,7 @@ /** * @file - * Contains views_handler_area_messages. + * Definition of views_handler_area_messages. */ /** diff --git a/sites/all/modules/contrib/views/views/handlers/views_handler_area_result.inc b/sites/all/modules/contrib/views/views/handlers/views_handler_area_result.inc index 86b1849..c69d3d2 100644 --- a/sites/all/modules/contrib/views/views/handlers/views_handler_area_result.inc +++ b/sites/all/modules/contrib/views/views/handlers/views_handler_area_result.inc @@ -12,7 +12,10 @@ */ class views_handler_area_result extends views_handler_area { - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['content'] = array( @@ -23,7 +26,10 @@ class views_handler_area_result extends views_handler_area { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $variables = array( 'items' => array( @@ -47,11 +53,10 @@ class views_handler_area_result extends views_handler_area { ); } - /** * Find out the information to render. */ - function render($empty = FALSE) { + public function render($empty = FALSE) { // Must have options and does not work on summaries. if (!isset($this->options['content']) || $this->view->plugin_name == 'default_summary') { return; @@ -61,8 +66,7 @@ class views_handler_area_result extends views_handler_area { // Calculate the page totals. $current_page = (int) $this->view->get_current_page() + 1; $per_page = (int) $this->view->get_items_per_page(); - $count = count($this->view->result); - // @TODO: Maybe use a possible is views empty functionality. + // @todo Maybe use a possible is views empty functionality. // Not every view has total_rows set, use view->result instead. $total = isset($this->view->total_rows) ? $this->view->total_rows : count($this->view->result); $name = check_plain($this->view->human_name); @@ -82,7 +86,16 @@ class views_handler_area_result extends views_handler_area { } $current_record_count = ($end - $start) + 1; // Get the search information. - $items = array('start', 'end', 'total', 'name', 'per_page', 'current_page', 'current_record_count', 'page_count'); + $items = array( + 'start', + 'end', + 'total', + 'name', + 'per_page', + 'current_page', + 'current_record_count', + 'page_count', + ); $replacements = array(); foreach ($items as $item) { $replacements["@$item"] = ${$item}; @@ -93,4 +106,5 @@ class views_handler_area_result extends views_handler_area { } return $output; } + } diff --git a/sites/all/modules/contrib/views/views/handlers/views_handler_area_text.inc b/sites/all/modules/contrib/views/views/handlers/views_handler_area_text.inc index edb282f..cad4a59 100644 --- a/sites/all/modules/contrib/views/views/handlers/views_handler_area_text.inc +++ b/sites/all/modules/contrib/views/views/handlers/views_handler_area_text.inc @@ -12,15 +12,30 @@ */ class views_handler_area_text extends views_handler_area { - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); - $options['content'] = array('default' => '', 'translatable' => TRUE, 'format_key' => 'format'); - $options['format'] = array('default' => NULL); - $options['tokenize'] = array('default' => FALSE, 'bool' => TRUE); + $options['content'] = array( + 'default' => '', + 'translatable' => TRUE, + 'format_key' => 'format', + ); + $options['format'] = array( + 'default' => NULL, + ); + $options['tokenize'] = array( + 'default' => FALSE, + 'bool' => TRUE, + ); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['content'] = array( @@ -31,7 +46,7 @@ class views_handler_area_text extends views_handler_area { '#wysiwyg' => FALSE, ); - // @TODO: Refactor token handling into a base class. + // @todo Refactor token handling into a base class. $form['tokenize'] = array( '#type' => 'checkbox', '#title' => t('Use replacement tokens from the first row'), @@ -44,14 +59,17 @@ class views_handler_area_text extends views_handler_area { $options[t('Fields')]["[$field]"] = $handler->ui_name(); } - $count = 0; // This lets us prepare the key as we want it printed. + $count = 0; + // This lets us prepare the key as we want it printed. foreach ($this->view->display_handler->get_handlers('argument') as $arg => $handler) { $options[t('Arguments')]['%' . ++$count] = t('@argument title', array('@argument' => $handler->ui_name())); $options[t('Arguments')]['!' . $count] = t('@argument input', array('@argument' => $handler->ui_name())); } if (!empty($options)) { - $output = '

' . t('The following tokens are available. If you would like to have the characters \'[\' and \']\' please use the html entity codes \'%5B\' or \'%5D\' or they will get replaced with empty space.' . '

'); + $output = '

' + . t("The following tokens are available. If you would like to have the characters '[' and ']' please use the html entity codes '%5B' or '%5D' or they will get replaced with empty space.") + . '

'; foreach (array_keys($options) as $type) { if (!empty($options[$type])) { $items = array(); @@ -61,7 +79,7 @@ class views_handler_area_text extends views_handler_area { $output .= theme('item_list', array( 'items' => $items, - 'type' => $type + 'type' => $type, )); } } @@ -82,13 +100,19 @@ class views_handler_area_text extends views_handler_area { } } - function options_submit(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_submit(&$form, &$form_state) { $form_state['values']['options']['format'] = $form_state['values']['options']['content']['format']; $form_state['values']['options']['content'] = $form_state['values']['options']['content']['value']; parent::options_submit($form, $form_state); } - function render($empty = FALSE) { + /** + * {@inheritdoc} + */ + public function render($empty = FALSE) { $format = isset($this->options['format']) ? $this->options['format'] : filter_default_format(); if (!$empty || !empty($this->options['empty'])) { return $this->render_textarea($this->options['content'], $format); @@ -99,7 +123,7 @@ class views_handler_area_text extends views_handler_area { /** * Render a text area, using the proper format. */ - function render_textarea($value, $format) { + public function render_textarea($value, $format) { if ($value) { if ($this->options['tokenize']) { $value = $this->view->style_plugin->tokenize_value($value, 0); @@ -107,4 +131,5 @@ class views_handler_area_text extends views_handler_area { return check_markup($value, $format, '', FALSE); } } + } diff --git a/sites/all/modules/contrib/views/views/handlers/views_handler_area_text_custom.inc b/sites/all/modules/contrib/views/views/handlers/views_handler_area_text_custom.inc index 3627f0c..89577bc 100644 --- a/sites/all/modules/contrib/views/views/handlers/views_handler_area_text_custom.inc +++ b/sites/all/modules/contrib/views/views/handlers/views_handler_area_text_custom.inc @@ -12,13 +12,19 @@ */ class views_handler_area_text_custom extends views_handler_area_text { - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); unset($options['format']); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); // Alter the form element, to be a regular text area. @@ -26,14 +32,20 @@ class views_handler_area_text_custom extends views_handler_area_text { unset($form['content']['#format']); unset($form['content']['#wysiwyg']); - // @TODO: Use the token refactored base class. + // @todo Use the token refactored base class. } - // Empty, so we don't inherit options_submit from the parent. - function options_submit(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_submit(&$form, &$form_state) { + // Empty, so we don't inherit options_submit from the parent. } - function render($empty = FALSE) { + /** + * {@inheritdoc} + */ + public function render($empty = FALSE) { if (!$empty || !empty($this->options['empty'])) { return $this->render_textarea_custom($this->options['content']); } @@ -43,8 +55,14 @@ class views_handler_area_text_custom extends views_handler_area_text { /** * Render a text area with filter_xss_admin. + * + * @param string $value + * The text area string to process. + * + * @return string + * The string after it has been sanitized, optionally tokenized too. */ - function render_textarea_custom($value) { + public function render_textarea_custom($value) { if ($value) { if ($this->options['tokenize']) { $value = $this->view->style_plugin->tokenize_value($value, 0); diff --git a/sites/all/modules/contrib/views/views/handlers/views_handler_area_view.inc b/sites/all/modules/contrib/views/views/handlers/views_handler_area_view.inc index 45ea499..2e93135 100644 --- a/sites/all/modules/contrib/views/views/handlers/views_handler_area_view.inc +++ b/sites/all/modules/contrib/views/views/handlers/views_handler_area_view.inc @@ -12,7 +12,10 @@ */ class views_handler_area_view extends views_handler_area { - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['view_to_insert'] = array('default' => ''); @@ -21,10 +24,9 @@ class views_handler_area_view extends views_handler_area { } /** - * Default options form that provides the label widget that all fields - * should have. + * Default options form; provides the label widget all fields should have. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $view_display = $this->view->name . ':' . $this->view->current_display; @@ -48,36 +50,51 @@ class views_handler_area_view extends views_handler_area { } /** - * Render the area + * Render the area. */ - function render($empty = FALSE) { - if (!empty($this->options['view_to_insert'])) { - list($view_name, $display_id) = explode(':', $this->options['view_to_insert']); - - $view = views_get_view($view_name); - if (empty($view) || !$view->access($display_id)) { - return; - } - $view->set_display($display_id); - - // Avoid recursion - $view->parent_views += $this->view->parent_views; - $view->parent_views[] = "$view_name:$display_id"; - - // Check if the view is part of the parent views of this view - $search = "$view_name:$display_id"; - if (in_array($search, $this->view->parent_views)) { - drupal_set_message(t("Recursion detected in view @view display @display.", array('@view' => $view_name, '@display' => $display_id)), 'error'); + public function render($empty = FALSE) { + if ($view = $this->loadView()) { + if (!empty($this->options['inherit_arguments']) && !empty($this->view->args)) { + return $view->preview(NULL, $this->view->args); } else { - if (!empty($this->options['inherit_arguments']) && !empty($this->view->args)) { - return $view->preview($display_id, $this->view->args); - } - else { - return $view->preview($display_id); - } + return $view->preview(NULL); } } return ''; } + + /** + * Loads the used view for rendering. + * + * @return \view|NULL + * The loaded view or NULL, in case the view was not loadable / recursion + * got detected / access got denied. + */ + protected function loadView() { + if (empty($this->options['view_to_insert'])) { + return NULL; + } + list($view_name, $display_id) = explode(':', $this->options['view_to_insert']); + + $view = views_get_view($view_name); + if (empty($view) || !$view->access($display_id)) { + return NULL; + } + $view->set_display($display_id); + + // Avoid recursion. + $view->parent_views += $this->view->parent_views; + $view->parent_views[] = "$view_name:$display_id"; + + // Check if the view is part of the parent views of this view. + $search = "$view_name:$display_id"; + if (in_array($search, $this->view->parent_views)) { + drupal_set_message(t("Recursion detected in view @view display @display.", array('@view' => $view_name, '@display' => $display_id)), 'error'); + return NULL; + } + + return $view; + } + } diff --git a/sites/all/modules/contrib/views/views/handlers/views_handler_argument.inc b/sites/all/modules/contrib/views/views/handlers/views_handler_argument.inc index 5a5ec00..309091e 100644 --- a/sites/all/modules/contrib/views/views/handlers/views_handler_argument.inc +++ b/sites/all/modules/contrib/views/views/handlers/views_handler_argument.inc @@ -2,7 +2,7 @@ /** * @file - * @todo. + * Definition of views_handler_argument. */ /** @@ -18,46 +18,59 @@ * * Definition terms for this handler: * - name field: The field to use for the name to use in the summary, which is - * the displayed output. For example, for the node: nid argument, - * the argument itself is the nid, but node.title is displayed. + * the displayed output. For example, for the node: nid argument, the argument + * itself is the nid, but node.title is displayed. * - name table: The table to use for the name, should it not be in the same - * table as the argument. + * table as the argument. * - empty field name: For arguments that can have no value, such as taxonomy - * which can have "no term", this is the string which - * will be displayed for this lack of value. Be sure to use - * t(). + * which can have "no term", this is the string which will be displayed for + * this lack of value. Be sure to use t(). * - validate type: A little used string to allow an argument to restrict - * which validator is available to just one. Use the - * validator ID. This probably should not be used at all, - * and may disappear or change. + * which validator is available to just one. Use the validator ID. This + * probably should not be used at all, and may disappear or change. * - numeric: If set to TRUE this field is numeric and will use %d instead of - * %s in queries. + * %s in queries. * * @ingroup views_argument_handlers */ class views_handler_argument extends views_handler { - var $validator = NULL; - var $argument = NULL; - var $value = NULL; /** - * The table to use for the name, should it not be in the same table as the argument. + * @var object + */ + public $validator = NULL; + + /** + * @var mixed + */ + public $argument = NULL; + + /** + * @var mixed + */ + public $value = NULL; + + /** + * The table to use for the name, if not the same table as the argument. + * * @var string */ - var $name_table; + public $name_table; /** - * The field to use for the name to use in the summary, which is - * the displayed output. For example, for the node: nid argument, - * the argument itself is the nid, but node.title is displayed. + * The field to use for the name to use in the summary. + * + * Used as the displayed output. For example, for the node: nid argument, the + * argument itself is the nid, but node.title is displayed. + * * @var string */ - var $name_field; + public $name_field; /** - * Constructor + * {@inheritdoc} */ - function construct() { + public function construct() { parent::construct(); if (!empty($this->definition['name field'])) { @@ -68,7 +81,10 @@ class views_handler_argument extends views_handler { } } - function init(&$view, &$options) { + /** + * {@inheritdoc} + */ + public function init(&$view, &$options) { parent::init($view, $options); // Compatibility: The new UI changed several settings. @@ -132,31 +148,42 @@ class views_handler_argument extends views_handler { /** * Give an argument the opportunity to modify the breadcrumb, if it wants. - * This only gets called on displays where a breadcrumb is actually used. + * + * Only gets called on displays where a breadcrumb is actually used. * * The breadcrumb will be in the form of an array, with the keys being * the path and the value being the already sanitized title of the path. */ - function set_breadcrumb(&$breadcrumb) { } + public function set_breadcrumb(&$breadcrumb) { + } /** * Determine if the argument can generate a breadcrumb * - * @return TRUE/FALSE + * @return bool */ - function uses_breadcrumb() { + public function uses_breadcrumb() { $info = $this->default_actions($this->options['default_action']); return !empty($info['breadcrumb']); } - function is_exception($arg = NULL) { + /** + * {@inheritdoc} + */ + public function is_exception($arg = NULL) { if (!isset($arg)) { $arg = isset($this->argument) ? $this->argument : NULL; } - return !empty($this->options['exception']['value']) && $this->options['exception']['value'] === $arg; + return !empty($this->options['exception']['value']) && ($this->options['exception']['value'] === $arg); } - function exception_title() { + /** + * Work out which title to use. + * + * @return string + * The title string to use. + */ + public function exception_title() { // If title overriding is off for the exception, return the normal title. if (empty($this->options['exception']['title_enable'])) { return $this->get_title(); @@ -167,15 +194,18 @@ class views_handler_argument extends views_handler { /** * Determine if the argument needs a style plugin. * - * @return TRUE/FALSE + * @return bool */ - function needs_style_plugin() { + public function needs_style_plugin() { $info = $this->default_actions($this->options['default_action']); $validate_info = $this->default_actions($this->options['validate']['fail']); return !empty($info['style plugin']) || !empty($validate_info['style plugin']); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['default_action'] = array('default' => 'ignore'); @@ -213,7 +243,10 @@ class views_handler_argument extends views_handler { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $argument_text = $this->view->display_handler->get_argument_text(); @@ -380,8 +413,9 @@ class views_handler_argument extends views_handler { '#prefix' => '
', '#suffix' => '
', '#type' => 'item', - // Even if the plugin has no options add the key to the form_state. - '#input' => TRUE, // trick it into checking input to make #process run + // Even if the plugin has no options, add the key to the + // form_state. Trick it into checking input to make #process run. + '#input' => TRUE, '#dependency' => array( 'edit-options-specify-validation' => array('1'), 'edit-options-validate-type' => array($id), @@ -411,7 +445,10 @@ class views_handler_argument extends views_handler { ); } - function options_validate(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_validate(&$form, &$form_state) { if (empty($form_state['values']['options'])) { return; } @@ -419,7 +456,7 @@ class views_handler_argument extends views_handler { // Let the plugins do validation. $default_id = $form_state['values']['options']['default_argument_type']; $plugin = $this->get_plugin('argument default', $default_id); - if ($plugin) { + if ($plugin && isset($form['argument_default'][$default_id]) && isset($form_state['values']['options']['argument_default'][$default_id])) { $plugin->options_validate($form['argument_default'][$default_id], $form_state, $form_state['values']['options']['argument_default'][$default_id]); } @@ -440,7 +477,10 @@ class views_handler_argument extends views_handler { } - function options_submit(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_submit(&$form, &$form_state) { if (empty($form_state['values']['options'])) { return; } @@ -451,7 +491,8 @@ class views_handler_argument extends views_handler { if ($plugin) { $options = &$form_state['values']['options']['argument_default'][$default_id]; $plugin->options_submit($form['argument_default'][$default_id], $form_state, $options); - // Copy the now submitted options to their final resting place so they get saved. + // Copy the now submitted options to their final resting place so they + // get saved. $form_state['values']['options']['default_argument_options'] = $options; } @@ -462,7 +503,8 @@ class views_handler_argument extends views_handler { if ($plugin) { $options = &$form_state['values']['options']['summary']['options'][$summary_id]; $plugin->options_submit($form['summary']['options'][$summary_id], $form_state, $options); - // Copy the now submitted options to their final resting place so they get saved. + // Copy the now submitted options to their final resting place so they + // get saved. $form_state['values']['options']['summary_options'] = $options; } } @@ -472,7 +514,8 @@ class views_handler_argument extends views_handler { if ($plugin) { $options = &$form_state['values']['options']['validate']['options'][$validate_id]; $plugin->options_submit($form['validate']['options'][$validate_id], $form_state, $options); - // Copy the now submitted options to their final resting place so they get saved. + // Copy the now submitted options to their final resting place so they + // get saved. $form_state['values']['options']['validate_options'] = $options; } @@ -489,42 +532,49 @@ class views_handler_argument extends views_handler { * * Override this method to provide additional (or fewer) default behaviors. */ - function default_actions($which = NULL) { + public function default_actions($which = NULL) { $defaults = array( 'ignore' => array( 'title' => t('Display all results for the specified field'), 'method' => 'default_ignore', - 'breadcrumb' => TRUE, // generate a breadcrumb to here + // Generate a breadcrumb to here. + 'breadcrumb' => TRUE, ), 'default' => array( 'title' => t('Provide default value'), 'method' => 'default_default', 'form method' => 'default_argument_form', 'has default argument' => TRUE, - 'default only' => TRUE, // this can only be used for missing argument, not validation failure - 'breadcrumb' => TRUE, // generate a breadcrumb to here + // This can only be used for missing argument, not validation failure. + 'default only' => TRUE, + // Generate a breadcrumb to here. + 'breadcrumb' => TRUE, ), 'not found' => array( 'title' => t('Hide view'), 'method' => 'default_not_found', - 'hard fail' => TRUE, // This is a hard fail condition + // This is a hard fail condition. + 'hard fail' => TRUE, ), 'summary' => array( 'title' => t('Display a summary'), 'method' => 'default_summary', 'form method' => 'default_summary_form', 'style plugin' => TRUE, - 'breadcrumb' => TRUE, // generate a breadcrumb to here + // Generate a breadcrumb to here. + 'breadcrumb' => TRUE, ), 'empty' => array( 'title' => t('Display contents of "No results found"'), 'method' => 'default_empty', - 'breadcrumb' => TRUE, // generate a breadcrumb to here + // Generate a breadcrumb to here. + 'breadcrumb' => TRUE, ), 'access denied' => array( 'title' => t('Display "Access Denied"'), 'method' => 'default_access_denied', - 'breadcrumb' => FALSE, // generate a breadcrumb to here + // Generate a breadcrumb to here. + 'breadcrumb' => FALSE, ), ); @@ -543,10 +593,11 @@ class views_handler_argument extends views_handler { } /** - * Provide a form for selecting the default argument when the - * default action is set to provide default argument. + * Provide a form for selecting the default argument. + * + * Used when the default action is set to provide default argument. */ - function default_argument_form(&$form, &$form_state) { + public function default_argument_form(&$form, &$form_state) { $plugins = views_fetch_plugin_data('argument default'); $options = array(); @@ -554,7 +605,7 @@ class views_handler_argument extends views_handler { '#type' => 'checkbox', '#title' => t('Skip default argument for view URL'), '#default_value' => $this->options['default_argument_skip_url'], - '#description' => t('Select whether to include this default argument when constructing the URL for this view. Skipping default arguments is useful e.g. in the case of feeds.') + '#description' => t('Select whether to include this default argument when constructing the URL for this view. Skipping default arguments is useful e.g. in the case of feeds.'), ); $form['default_argument_type'] = array( @@ -564,8 +615,11 @@ class views_handler_argument extends views_handler { '#id' => 'edit-options-default-argument-type', '#title' => t('Type'), '#default_value' => $this->options['default_argument_type'], - - '#dependency' => array('radio:options[default_action]' => array('default')), + '#dependency' => array( + 'radio:options[default_action]' => array( + 'default', + ), + ), // Views custom key, moves this element to the appropriate container // under the radio button. '#argument_option' => 'default', @@ -588,7 +642,7 @@ class views_handler_argument extends views_handler { '#input' => TRUE, '#dependency' => array( 'radio:options[default_action]' => array('default'), - 'edit-options-default-argument-type' => array($id) + 'edit-options-default-argument-type' => array($id), ), '#dependency_count' => 2, ); @@ -603,10 +657,10 @@ class views_handler_argument extends views_handler { } /** - * Provide a form for selecting further summary options when the - * default action is set to display one. + * Provide a form for selecting further summary options when the default + * action is set to display one. */ - function default_summary_form(&$form, &$form_state) { + public function default_summary_form(&$form, &$form_state) { $style_plugins = views_fetch_plugin_data('style'); $summary_plugins = array(); $format_options = array(); @@ -635,7 +689,7 @@ class views_handler_argument extends views_handler { '#default_value' => $this->options['summary']['number_of_records'], '#options' => array( 0 => $this->get_sort_name(), - 1 => t('Number of records') + 1 => t('Number of records'), ), '#dependency' => array('radio:options[default_action]' => array('summary')), ); @@ -659,7 +713,8 @@ class views_handler_argument extends views_handler { '#suffix' => '
', '#id' => 'edit-options-summary-options-' . $id, '#type' => 'item', - '#input' => TRUE, // trick it into checking input to make #process run + // Trick it into checking input to make #process run. + '#input' => TRUE, '#dependency' => array( 'radio:options[default_action]' => array('summary'), 'radio:options[summary][format]' => array($id), @@ -677,11 +732,11 @@ class views_handler_argument extends views_handler { * * Override this method only with extreme care. * - * @return + * @return bool * A boolean value; if TRUE, continue building this view. If FALSE, * building the view will be aborted here. */ - function default_action($info = NULL) { + public function default_action($info = NULL) { if (!isset($info)) { $info = $this->default_actions($this->options['default_action']); } @@ -699,29 +754,30 @@ class views_handler_argument extends views_handler { } /** - * How to act if validation failes + * How to act if validation fails. */ - function validate_fail() { + public function validate_fail() { $info = $this->default_actions($this->options['validate']['fail']); return $this->default_action($info); } + /** * Default action: ignore. * - * If an argument was expected and was not given, in this case, simply - * ignore the argument entirely. + * If an argument was expected and was not given, in this case, simply ignore + * the argument entirely. */ - function default_ignore() { + public function default_ignore() { return TRUE; } /** * Default action: not found. * - * If an argument was expected and was not given, in this case, report - * the view as 'not found' or hide it. + * If an argument was expected and was not given, in this case, report the + * view as 'not found' or hide it. */ - function default_not_found() { + public function default_not_found() { // Set a failure condition and let the display manager handle it. $this->view->build_info['fail'] = TRUE; return FALSE; @@ -730,10 +786,10 @@ class views_handler_argument extends views_handler { /** * Default action: access denied. * - * If an argument was expected and was not given, in this case, report - * the view as 'access denied'. + * If an argument was expected and was not given, in this case, report the + * view as 'access denied'. */ - function default_access_denied() { + public function default_access_denied() { $this->view->build_info['denied'] = TRUE; return FALSE; } @@ -741,10 +797,10 @@ class views_handler_argument extends views_handler { /** * Default action: empty * - * If an argument was expected and was not given, in this case, display - * the view's empty text + * If an argument was expected and was not given, in this case, display the + * view's empty text */ - function default_empty() { + public function default_empty() { // We return with no query; this will force the empty text. $this->view->built = TRUE; $this->view->executed = TRUE; @@ -753,17 +809,20 @@ class views_handler_argument extends views_handler { } /** - * This just returns true. The view argument builder will know where - * to find the argument from. + * This just returns true. + * + * The view argument builder will know where to find the argument from. + * + * @todo Why is this needed? */ - function default_default() { + public function default_default() { return TRUE; } /** * Determine if the argument is set to provide a default argument. */ - function has_default_argument() { + public function has_default_argument() { $info = $this->default_actions($this->options['default_action']); return !empty($info['has default argument']); } @@ -771,7 +830,7 @@ class views_handler_argument extends views_handler { /** * Get a default argument, if available. */ - function get_default_argument() { + public function get_default_argument() { $plugin = $this->get_plugin('argument default'); if ($plugin) { return $plugin->get_argument(); @@ -784,7 +843,7 @@ class views_handler_argument extends views_handler { * For example, the validation plugin may want to alter an argument for use in * the URL. */ - function process_summary_arguments(&$args) { + public function process_summary_arguments(&$args) { if ($this->options['validate']['type'] != 'none') { if (isset($this->validator) || $this->validator = $this->get_plugin('argument validator')) { $this->validator->process_summary_arguments($args); @@ -795,20 +854,19 @@ class views_handler_argument extends views_handler { /** * Default action: summary. * - * If an argument was expected and was not given, in this case, display - * a summary query. + * If an argument was expected and was not given, in this case, display a + * summary query. */ - function default_summary() { + public function default_summary() { $this->view->build_info['summary'] = TRUE; $this->view->build_info['summary_level'] = $this->options['id']; - // Change the display style to the summary style for this - // argument. + // Change the display style to the summary style for this argument. $this->view->plugin_name = $this->options['summary']['format']; $this->view->style_options = $this->options['summary_options']; - // Clear out the normal primary field and whatever else may have - // been added and let the summary do the work. + // Clear out the normal primary field and whatever else may have been added + // and let the summary do the work. $this->query->clear_fields(); $this->summary_query(); @@ -826,14 +884,14 @@ class views_handler_argument extends views_handler { * * This must: * - add_groupby: group on this field in order to create summaries. - * - add_field: add a 'num_nodes' field for the count. Usually it will - * be a count on $view->base_field + * - add_field: add a 'num_nodes' field for the count. Usually it will be a + * count on $view->base_field * - set_count_field: Reset the count field so we get the right paging. * - * @return + * @return string * The alias used to get the number of records (count) for this entry. */ - function summary_query() { + public function summary_query() { $this->ensure_my_table(); // Add the field. $this->base_alias = $this->query->add_field($this->table_alias, $this->real_field); @@ -844,15 +902,15 @@ class views_handler_argument extends views_handler { /** * Add the name field, which is the field displayed in summary queries. + * * This is often used when the argument is numeric. */ - function summary_name_field() { - // Add the 'name' field. For example, if this is a uid argument, the - // name field would be 'name' (i.e, the username). - + public function summary_name_field() { + // Add the 'name' field. For example, if this is a uid argument, the name + // field would be 'name' (i.e, the username). if (isset($this->name_table)) { - // if the alias is different then we're probably added, not ensured, - // so look up the join and add it instead. + // If the alias is different then we're probably added, not ensured, so + // look up the join and add it instead. if ($this->table_alias != $this->name_table) { $j = views_get_table_join($this->name_table, $this->table); if ($j) { @@ -878,15 +936,21 @@ class views_handler_argument extends views_handler { } /** - * Some basic summary behavior that doesn't need to be repeated as much as - * code that goes into summary_query() + * Some basic summary behavior. + * + * This doesn't need to be repeated as much as code that goes into + * summary_query(). */ - function summary_basics($count_field = TRUE) { - // Add the number of nodes counter + public function summary_basics($count_field = TRUE) { + // Add the number of nodes counter. $distinct = ($this->view->display_handler->get_option('distinct') && empty($this->query->no_distinct)); - $count_alias = $this->query->add_field($this->query->base_table, $this->query->base_field, 'num_records', - array('count' => TRUE, 'distinct' => $distinct)); + $count_alias = $this->query->add_field($this->query->base_table, + $this->query->base_field, 'num_records', + array( + 'count' => TRUE, + 'distinct' => $distinct, + )); $this->query->add_groupby($this->name_alias); if ($count_field) { @@ -897,36 +961,42 @@ class views_handler_argument extends views_handler { } /** - * Sorts the summary based upon the user's selection. The base variant of - * this is usually adequte. + * Sorts the summary based upon the user's selection. * - * @param $order + * The base variant of this is usually adequte. + * + * @param string $order * The order selected in the UI. */ - function summary_sort($order, $by = NULL) { + public function summary_sort($order, $by = NULL) { $this->query->add_orderby(NULL, NULL, $order, (!empty($by) ? $by : $this->name_alias)); } /** - * Provide the argument to use to link from the summary to the next level; - * this will be called once per row of a summary, and used as part of + * Provide the argument to use to link from the summary to the next level. + * + * This will be called once per row of a summary, and used as part of * $view->get_url(). * - * @param $data + * @param object $data * The query results for the row. */ - function summary_argument($data) { + public function summary_argument($data) { return $data->{$this->base_alias}; } /** - * Provides the name to use for the summary. By default this is just - * the name field. + * Provides the name to use for the summary. * - * @param $data + * By default this is just the name field. + * + * @param object $data * The query results for the row. + * + * @return string + * The summary. */ - function summary_name($data) { + public function summary_name($data) { $value = $data->{$this->name_alias}; if (empty($value) && !empty($this->definition['empty field name'])) { $value = $this->definition['empty field name']; @@ -938,8 +1008,11 @@ class views_handler_argument extends views_handler { * Set up the query for this argument. * * The argument sent may be found at $this->argument. + * + * @param bool $group_by + * Whether the query uses a group-by. */ - function query($group_by = FALSE) { + public function query($group_by = FALSE) { $this->ensure_my_table(); $this->query->add_where(0, "$this->table_alias.$this->real_field", $this->argument); } @@ -949,15 +1022,17 @@ class views_handler_argument extends views_handler { * * This usually needs to be overridden to provide a proper title. */ - function title() { + public function title() { return check_plain($this->argument); } /** - * Called by the view object to get the title. This may be set by a - * validator so we don't necessarily call through to title(). + * Called by the view object to get the title. + * + * This may be set by a validator so we don't necessarily call through to + * title(). */ - function get_title() { + public function get_title() { if (isset($this->validated_title)) { return $this->validated_title; } @@ -969,7 +1044,7 @@ class views_handler_argument extends views_handler { /** * Validate that this argument works. By default, all arguments are valid. */ - function validate_arg($arg) { + public function validate_arg($arg) { // By using % in URLs, arguments could be validated twice; this eases // that pain. if (isset($this->argument_validated)) { @@ -989,7 +1064,7 @@ class views_handler_argument extends views_handler { return $this->argument_validated = $plugin->validate_argument($arg); } - // If the plugin isn't found, fall back to the basic validation path: + // If the plugin isn't found, fall back to the basic validation path. return $this->argument_validated = $this->validate_argument_basic($arg); } @@ -997,10 +1072,10 @@ class views_handler_argument extends views_handler { * Called by the menu system to validate an argument. * * This checks to see if this is a 'soft fail', which means that if the - * argument fails to validate, but there is an action to take anyway, - * then validation cannot actually fail. + * argument fails to validate, but there is an action to take anyway, then + * validation cannot actually fail. */ - function validate_argument($arg) { + public function validate_argument($arg) { $validate_info = $this->default_actions($this->options['validate']['fail']); if (empty($validate_info['hard fail'])) { return TRUE; @@ -1008,8 +1083,8 @@ class views_handler_argument extends views_handler { $rc = $this->validate_arg($arg); - // If the validator has changed the validate fail condition to a - // soft fail, deal with that: + // If the validator has changed the validate fail condition to a soft fail, + // deal with that. $validate_info = $this->default_actions($this->options['validate']['fail']); if (empty($validate_info['hard fail'])) { return TRUE; @@ -1021,11 +1096,14 @@ class views_handler_argument extends views_handler { /** * Provide a basic argument validation. * - * This can be overridden for more complex types; the basic - * validator only checks to see if the argument is not NULL - * or is numeric if the definition says it's numeric. + * This can be overridden for more complex types; the basic validator only + * checks to see if the argument is not NULL or is numeric if the definition + * says it's numeric. + * + * @return bool + * Whether or not the argument validates. */ - function validate_argument_basic($arg) { + public function validate_argument_basic($arg) { if (!isset($arg) || $arg === '') { return FALSE; } @@ -1040,17 +1118,21 @@ class views_handler_argument extends views_handler { /** * Set the input for this argument * - * @return TRUE if it successfully validates; FALSE if it does not. + * @return bool + * TRUE if it successfully validates; FALSE if it does not. */ - function set_argument($arg) { + public function set_argument($arg) { $this->argument = $arg; return $this->validate_arg($arg); } /** * Get the value of this argument. + * + * @return string + * The value. */ - function get_value() { + public function get_value() { // If we already processed this argument, we're done. if (isset($this->argument)) { return $this->argument; @@ -1075,9 +1157,6 @@ class views_handler_argument extends views_handler { $argument = clone $this; if (!isset($arg) && $argument->has_default_argument()) { $arg = $argument->get_default_argument(); - - // remember that this argument was computed, not passed on the URL. - $this->is_default = TRUE; } // Set the argument, which will also validate that the argument can be set. if ($argument->set_argument($arg)) { @@ -1092,8 +1171,11 @@ class views_handler_argument extends views_handler { * * Arguments can have styles for the summary view. This special export * handler makes sure this works properly. + * + * @return string + * The export summary. */ - function export_summary($indent, $prefix, $storage, $option, $definition, $parents) { + public function export_summary($indent, $prefix, $storage, $option, $definition, $parents) { $output = ''; $name = $this->options['summary'][$option]; $options = $this->options['summary_options']; @@ -1116,8 +1198,11 @@ class views_handler_argument extends views_handler { * * Arguments use validation plugins. This special export handler makes sure * this works properly. + * + * @return string + * The validation response. */ - function export_validation($indent, $prefix, $storage, $option, $definition, $parents) { + public function export_validation($indent, $prefix, $storage, $option, $definition, $parents) { $output = ''; $name = $this->options['validate'][$option]; $options = $this->options['validate_options']; @@ -1140,8 +1225,11 @@ class views_handler_argument extends views_handler { * * Since style and validation plugins have their own export handlers, this * one is currently only used for default argument plugins. + * + * @return string + * Export string. */ - function export_plugin($indent, $prefix, $storage, $option, $definition, $parents) { + public function export_plugin($indent, $prefix, $storage, $option, $definition, $parents) { $output = ''; if ($option == 'default_argument_type') { $type = 'argument default'; @@ -1165,28 +1253,30 @@ class views_handler_argument extends views_handler { /** * Get the display or row plugin, if it exists. */ - function get_plugin($type = 'argument default', $name = NULL) { + public function get_plugin($type = 'argument default', $name = NULL) { $options = array(); switch ($type) { case 'argument default': $plugin_name = $this->options['default_argument_type']; $options_name = 'default_argument_options'; break; + case 'argument validator': $plugin_name = $this->options['validate']['type']; $options_name = 'validate_options'; break; + case 'style': $plugin_name = $this->options['summary']['format']; $options_name = 'summary_options'; + break; } if (!$name) { $name = $plugin_name; } - // we only fetch the options if we're fetching the plugin actually - // in use. + // We only fetch the options if we're fetching the plugin actually in use. if ($name == $plugin_name) { $options = $this->options[$options_name]; } @@ -1209,10 +1299,14 @@ class views_handler_argument extends views_handler { * * Subclasses should override this to specify what the default sort order of * their argument is (e.g. alphabetical, numeric, date). + * + * @return string + * The label for the sorter. */ - function get_sort_name() { + public function get_sort_name() { return t('Default sort', array(), array('context' => 'Sort order')); } + } /** @@ -1221,22 +1315,44 @@ class views_handler_argument extends views_handler { * @ingroup views_argument_handlers */ class views_handler_argument_broken extends views_handler_argument { - function ui_name($short = FALSE) { + + /** + * {@inheritdoc} + */ + public function ui_name($short = FALSE) { return t('Broken/missing handler'); } - function ensure_my_table() { /* No table to ensure! */ } - function query($group_by = FALSE) { /* No query to run */ } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function ensure_my_table() { + // No table to ensure! + } + + /** + * {@inheritdoc} + */ + public function query($group_by = FALSE) { + // No query to run. + } + + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['markup'] = array( '#markup' => '
' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '
', ); } /** - * Determine if the handler is considered 'broken' + * {@inheritdoc} */ - function broken() { return TRUE; } + public function broken() { + return TRUE; + } + } /** diff --git a/sites/all/modules/contrib/views/views/handlers/views_handler_argument_date.inc b/sites/all/modules/contrib/views/views/handlers/views_handler_argument_date.inc index 6803c36..d10694c 100644 --- a/sites/all/modules/contrib/views/views/handlers/views_handler_argument_date.inc +++ b/sites/all/modules/contrib/views/views/handlers/views_handler_argument_date.inc @@ -10,9 +10,9 @@ * * Adds an option to set a default argument based on the current date. * - * @param $arg_format - * The format string to use on the current time when - * creating a default date argument. + * @param string $arg_format + * The format string to use on the current time when creating a default date + * argument. * * Definitions terms: * - many to one: If true, the "many to one" helper will be used. @@ -24,27 +24,40 @@ * @ingroup views_argument_handlers */ class views_handler_argument_date extends views_handler_argument_formula { - var $option_name = 'default_argument_date'; - var $arg_format = 'Y-m-d'; + + /** + * + */ + public $option_name = 'default_argument_date'; + + /** + * + */ + public $arg_format = 'Y-m-d'; /** * Add an option to set the default value to the current date. */ - function default_argument_form(&$form, &$form_state) { + public function default_argument_form(&$form, &$form_state) { parent::default_argument_form($form, $form_state); $form['default_argument_type']['#options'] += array('date' => t('Current date')); $form['default_argument_type']['#options'] += array('node_created' => t("Current node's creation time")); - $form['default_argument_type']['#options'] += array('node_changed' => t("Current node's update time")); } + $form['default_argument_type']['#options'] += array('node_changed' => t("Current node's update time")); + } /** * Set the empty argument value to the current date, + * * formatted appropriately for this argument. + * + * @return string + * The default argument. */ - function get_default_argument($raw = FALSE) { + public function get_default_argument($raw = FALSE) { if (!$raw && $this->options['default_argument_type'] == 'date') { return date($this->arg_format, REQUEST_TIME); } - else if (!$raw && in_array($this->options['default_argument_type'], array('node_created', 'node_changed'))) { + elseif (!$raw && in_array($this->options['default_argument_type'], array('node_created', 'node_changed'))) { foreach (range(1, 3) as $i) { $node = menu_get_object('node', $i); if (!empty($node)) { @@ -71,11 +84,12 @@ class views_handler_argument_date extends views_handler_argument_formula { } /** - * The date handler provides some default argument types, which aren't argument default plugins, - * so addapt the export mechanism. + * Adapt the export mechanism. + * + * The date handler provides some default argument types, which aren't + * argument default plugins. */ - function export_plugin($indent, $prefix, $storage, $option, $definition, $parents) { - + public function export_plugin($indent, $prefix, $storage, $option, $definition, $parents) { // Only use a special behaviour for the special argument types, else just // use the default behaviour. if ($option == 'default_argument_type') { @@ -94,8 +108,11 @@ class views_handler_argument_date extends views_handler_argument_formula { return parent::export_plugin($indent, $prefix, $storage, $option, $definition, $parents); } - - function get_sort_name() { + /** + * {@inheritdoc} + */ + public function get_sort_name() { return t('Date', array(), array('context' => 'Sort order')); } + } diff --git a/sites/all/modules/contrib/views/views/handlers/views_handler_argument_formula.inc b/sites/all/modules/contrib/views/views/handlers/views_handler_argument_formula.inc index 76f5991..56ae976 100644 --- a/sites/all/modules/contrib/views/views/handlers/views_handler_argument_formula.inc +++ b/sites/all/modules/contrib/views/views/handlers/views_handler_argument_formula.inc @@ -16,11 +16,16 @@ * @ingroup views_argument_handlers */ class views_handler_argument_formula extends views_handler_argument { - var $formula = NULL; + /** - * Constructor + * */ - function construct() { + public $formula = NULL; + + /** + * {@inheritdoc} + */ + public function construct() { parent::construct(); if (!empty($this->definition['formula'])) { @@ -28,14 +33,17 @@ class views_handler_argument_formula extends views_handler_argument { } } - function get_formula() { + /** + * + */ + public function get_formula() { return str_replace('***table***', $this->table_alias, $this->formula); } /** * Build the summary query based on a formula */ - function summary_query() { + public function summary_query() { $this->ensure_my_table(); // Now that our table is secure, get our formula. $formula = $this->get_formula(); @@ -50,14 +58,15 @@ class views_handler_argument_formula extends views_handler_argument { /** * Build the query based upon the formula */ - function query($group_by = FALSE) { + public function query($group_by = FALSE) { $this->ensure_my_table(); // Now that our table is secure, get our formula. $placeholder = $this->placeholder(); - $formula = $this->get_formula() .' = ' . $placeholder; + $formula = $this->get_formula() . ' = ' . $placeholder; $placeholders = array( $placeholder => $this->argument, ); $this->query->add_where(0, $formula, $placeholders, 'formula'); } + } diff --git a/sites/all/modules/contrib/views/views/handlers/views_handler_argument_group_by_numeric.inc b/sites/all/modules/contrib/views/views/handlers/views_handler_argument_group_by_numeric.inc index aa522ea..01010b5 100644 --- a/sites/all/modules/contrib/views/views/handlers/views_handler_argument_group_by_numeric.inc +++ b/sites/all/modules/contrib/views/views/handlers/views_handler_argument_group_by_numeric.inc @@ -10,8 +10,12 @@ * * @ingroup views_argument_handlers */ -class views_handler_argument_group_by_numeric extends views_handler_argument { - function query($group_by = FALSE) { +class views_handler_argument_group_by_numeric extends views_handler_argument { + + /** + * {@inheritdoc} + */ + public function query($group_by = FALSE) { $this->ensure_my_table(); $field = $this->get_field(); $placeholder = $this->placeholder(); @@ -19,11 +23,18 @@ class views_handler_argument_group_by_numeric extends views_handler_argument { $this->query->add_having_expression(0, "$field = $placeholder", array($placeholder => $this->argument)); } - function ui_name($short = FALSE) { + /** + * {@inheritdoc} + */ + public function ui_name($short = FALSE) { return $this->get_field(parent::ui_name($short)); } - function get_sort_name() { + /** + * {@inheritdoc} + */ + public function get_sort_name() { return t('Numerical', array(), array('context' => 'Sort order')); } + } diff --git a/sites/all/modules/contrib/views/views/handlers/views_handler_argument_many_to_one.inc b/sites/all/modules/contrib/views/views/handlers/views_handler_argument_many_to_one.inc index 3446760..ce581f7 100644 --- a/sites/all/modules/contrib/views/views/handlers/views_handler_argument_many_to_one.inc +++ b/sites/all/modules/contrib/views/views/handlers/views_handler_argument_many_to_one.inc @@ -6,29 +6,39 @@ */ /** - * An argument handler for use in fields that have a many to one relationship - * with the table(s) to the left. This adds a bunch of options that are - * reasonably common with this type of relationship. + * Argument handler for fields that have many-to-one table relationships. + * + * (i.e. with the table(s) to the left.) + * This adds a bunch of options that are reasonably common with this type of + * relationship. + * * Definition terms: * - numeric: If true, the field will be considered numeric. Probably should * always be set TRUE as views_handler_argument_string has many to one * capabilities. - * - zero is null: If true, a 0 will be handled as empty, so for example - * a default argument can be provided or a summary can be shown. + * - zero is null: If true, a 0 will be handled as empty, so for example a + * default argument can be provided or a summary can be shown. * * @ingroup views_argument_handlers */ class views_handler_argument_many_to_one extends views_handler_argument { - function init(&$view, &$options) { + + /** + * {@inheritdoc} + */ + public function init(&$view, &$options) { parent::init($view, $options); $this->helper = new views_many_to_one_helper($this); - // Ensure defaults for these, during summaries and stuff: + // Ensure defaults for these, during summaries and stuff. $this->operator = 'or'; $this->value = array(); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); if (!empty($this->definition['numeric'])) { @@ -49,7 +59,10 @@ class views_handler_argument_many_to_one extends views_handler_argument { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); // allow + for or, , for and @@ -85,11 +98,14 @@ class views_handler_argument_many_to_one extends views_handler_argument { * Override ensure_my_table so we can control how this joins in. * The operator actually has influence over joining. */ - function ensure_my_table() { + public function ensure_my_table() { $this->helper->ensure_my_table(); } - function query($group_by = FALSE) { + /** + * {@inheritdoc} + */ + public function query($group_by = FALSE) { $empty = FALSE; if (isset($this->definition['zero is null']) && $this->definition['zero is null']) { if (empty($this->argument)) { @@ -118,7 +134,10 @@ class views_handler_argument_many_to_one extends views_handler_argument { $this->helper->add_filter(); } - function title() { + /** + * {@inheritdoc} + */ + public function title() { if (!$this->argument) { return !empty($this->definition['empty field name']) ? $this->definition['empty field name'] : t('Uncategorized'); } @@ -144,7 +163,10 @@ class views_handler_argument_many_to_one extends views_handler_argument { return implode($this->operator == 'or' ? ' + ' : ', ', $this->title_query()); } - function summary_query() { + /** + * {@inheritdoc} + */ + public function summary_query() { $field = $this->table . '.' . $this->field; $join = $this->get_join(); @@ -167,7 +189,10 @@ class views_handler_argument_many_to_one extends views_handler_argument { return $this->summary_basics(); } - function summary_argument($data) { + /** + * {@inheritdoc} + */ + public function summary_argument($data) { $value = $data->{$this->base_alias}; if (empty($value)) { $value = 0; @@ -179,7 +204,8 @@ class views_handler_argument_many_to_one extends views_handler_argument { /** * Override for specific title lookups. */ - function title_query() { + public function title_query() { return $this->value; } + } diff --git a/sites/all/modules/contrib/views/views/handlers/views_handler_argument_null.inc b/sites/all/modules/contrib/views/views/handlers/views_handler_argument_null.inc index 5b42728..afe0c60 100644 --- a/sites/all/modules/contrib/views/views/handlers/views_handler_argument_null.inc +++ b/sites/all/modules/contrib/views/views/handlers/views_handler_argument_null.inc @@ -11,7 +11,11 @@ * @ingroup views_argument_handlers */ class views_handler_argument_null extends views_handler_argument { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['must_not_be'] = array('default' => FALSE, 'bool' => TRUE); return $options; @@ -21,7 +25,7 @@ class views_handler_argument_null extends views_handler_argument { * Override options_form() so that only the relevant options * are displayed to the user. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['must_not_be'] = array( '#type' => 'checkbox', @@ -38,9 +42,9 @@ class views_handler_argument_null extends views_handler_argument { * Override default_actions() to remove actions that don't * make sense for a null argument. */ - function default_actions($which = NULL) { + public function default_actions($which = NULL) { if ($which) { - if (in_array($which, array('ignore', 'not found', 'empty', 'default'))) { + if (in_array($which, array('ignore', 'not found', 'empty', 'default', 'access denied'))) { return parent::default_actions($which); } return; @@ -51,7 +55,10 @@ class views_handler_argument_null extends views_handler_argument { return $actions; } - function validate_argument_basic($arg) { + /** + * {@inheritdoc} + */ + public function validate_argument_basic($arg) { if (!empty($this->options['must_not_be'])) { return !isset($arg); } @@ -63,5 +70,7 @@ class views_handler_argument_null extends views_handler_argument { * Override the behavior of query() to prevent the query * from being changed in any way. */ - function query($group_by = FALSE) {} + public function query($group_by = FALSE) { + } + } diff --git a/sites/all/modules/contrib/views/views/handlers/views_handler_argument_numeric.inc b/sites/all/modules/contrib/views/views/handlers/views_handler_argument_numeric.inc index 8f36b21..c0e2e2b 100644 --- a/sites/all/modules/contrib/views/views/handlers/views_handler_argument_numeric.inc +++ b/sites/all/modules/contrib/views/views/handlers/views_handler_argument_numeric.inc @@ -6,25 +6,30 @@ */ /** - * Basic argument handler for arguments that are numeric. Incorporates - * break_phrase. + * Basic argument handler for arguments that are numeric. + * + * Incorporates break_phrase. * * @ingroup views_argument_handlers */ class views_handler_argument_numeric extends views_handler_argument { + /** * The operator used for the query: or|and. * @var string */ - var $operator; + public $operator; /** * The actual value which is used for querying. * @var array */ - var $value; + public $value; - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['break_phrase'] = array('default' => FALSE, 'bool' => TRUE); @@ -33,7 +38,10 @@ class views_handler_argument_numeric extends views_handler_argument { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); // allow + for or, , for and @@ -54,7 +62,10 @@ class views_handler_argument_numeric extends views_handler_argument { ); } - function title() { + /** + * {@inheritdoc} + */ + public function title() { if (!$this->argument) { return !empty($this->definition['empty field name']) ? $this->definition['empty field name'] : t('Uncategorized'); } @@ -80,14 +91,18 @@ class views_handler_argument_numeric extends views_handler_argument { /** * Override for specific title lookups. + * * @return array * Returns all titles, if it's just one title it's an array with one entry. */ - function title_query() { + public function title_query() { return $this->value; } - function query($group_by = FALSE) { + /** + * {@inheritdoc} + */ + public function query($group_by = FALSE) { $this->ensure_my_table(); if (!empty($this->options['break_phrase'])) { @@ -110,7 +125,11 @@ class views_handler_argument_numeric extends views_handler_argument { } } - function get_sort_name() { + /** + * {@inheritdoc} + */ + public function get_sort_name() { return t('Numerical', array(), array('context' => 'Sort order')); } + } diff --git a/sites/all/modules/contrib/views/views/handlers/views_handler_argument_string.inc b/sites/all/modules/contrib/views/views/handlers/views_handler_argument_string.inc index dbb98fe..2b605cf 100644 --- a/sites/all/modules/contrib/views/views/handlers/views_handler_argument_string.inc +++ b/sites/all/modules/contrib/views/views/handlers/views_handler_argument_string.inc @@ -6,24 +6,30 @@ */ /** - * Basic argument handler to implement string arguments that may have length - * limits. + * Argument handler to implement string arguments that may have length limits. * * @ingroup views_argument_handlers */ class views_handler_argument_string extends views_handler_argument { - function init(&$view, &$options) { + + /** + * {@inheritdoc} + */ + public function init(&$view, &$options) { parent::init($view, $options); if (!empty($this->definition['many to one'])) { $this->helper = new views_many_to_one_helper($this); - // Ensure defaults for these, during summaries and stuff: + // Ensure defaults for these, during summaries and stuff. $this->operator = 'or'; $this->value = array(); } } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['glossary'] = array('default' => FALSE, 'bool' => TRUE); @@ -41,7 +47,10 @@ class views_handler_argument_string extends views_handler_argument { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['glossary'] = array( @@ -126,9 +135,9 @@ class views_handler_argument_string extends views_handler_argument { } /** - * Build the summary query based on a string + * Build the summary query based on a string. */ - function summary_query() { + public function summary_query() { if (empty($this->definition['many to one'])) { $this->ensure_my_table(); } @@ -157,14 +166,14 @@ class views_handler_argument_string extends views_handler_argument { * * $this->ensure_my_table() MUST have been called prior to this. */ - function get_formula() { + public function get_formula() { return "SUBSTRING($this->table_alias.$this->real_field, 1, " . intval($this->options['limit']) . ")"; } /** * Build the query based upon the formula */ - function query($group_by = FALSE) { + public function query($group_by = FALSE) { $argument = $this->argument; if (!empty($this->options['transform_dash'])) { $argument = strtr($argument, '-', ' '); @@ -223,7 +232,10 @@ class views_handler_argument_string extends views_handler_argument { } } - function summary_argument($data) { + /** + * {@inheritdoc} + */ + public function summary_argument($data) { $value = $this->case_transform($data->{$this->base_alias}, $this->options['path_case']); if (!empty($this->options['transform_dash'])) { $value = strtr($value, ' ', '-'); @@ -231,11 +243,17 @@ class views_handler_argument_string extends views_handler_argument { return $value; } - function get_sort_name() { + /** + * {@inheritdoc} + */ + public function get_sort_name() { return t('Alphabetical', array(), array('context' => 'Sort order')); } - function title() { + /** + * {@inheritdoc} + */ + public function title() { $this->argument = $this->case_transform($this->argument, $this->options['case']); if (!empty($this->options['transform_dash'])) { $this->argument = strtr($this->argument, '-', ' '); @@ -263,11 +281,14 @@ class views_handler_argument_string extends views_handler_argument { /** * Override for specific title lookups. */ - function title_query() { + public function title_query() { return drupal_map_assoc($this->value, 'check_plain'); } - function summary_name($data) { + /** + * {@inheritdoc} + */ + public function summary_name($data) { return $this->case_transform(parent::summary_name($data), $this->options['case']); } diff --git a/sites/all/modules/contrib/views/views/handlers/views_handler_field.inc b/sites/all/modules/contrib/views/views/handlers/views_handler_field.inc index 65210d9..f33cf88 100644 --- a/sites/all/modules/contrib/views/views/handlers/views_handler_field.inc +++ b/sites/all/modules/contrib/views/views/handlers/views_handler_field.inc @@ -2,25 +2,26 @@ /** * @file - * @todo. + * Definition of views_handler_field. */ /** * @defgroup views_field_handlers Views field handlers * @{ * Handlers to tell Views how to build and display fields. - * */ /** * Indicator of the render_text() method for rendering a single item. - * (If no render_item() is present). + * + * If no render_item() is present. */ define('VIEWS_HANDLER_RENDER_TEXT_PHASE_SINGLE_ITEM', 0); /** * Indicator of the render_text() method for rendering the whole element. - * (if no render_item() method is available). + * + * if no render_item() method is available. */ define('VIEWS_HANDLER_RENDER_TEXT_PHASE_COMPLETELY', 1); @@ -34,17 +35,29 @@ define('VIEWS_HANDLER_RENDER_TEXT_PHASE_EMPTY', 2); * * Definition terms: * - additional fields: An array of fields that should be added to the query - * for some purpose. The array is in the form of: - * array('identifier' => array('table' => tablename, - * 'field' => fieldname); as many fields as are necessary - * may be in this array. + * for some purpose. The array is in the form of: + * array( + * 'identifier' => array( + * 'table' => tablename, + * 'field' => fieldname, + * ) + * ); + * with as many fields as are necessary may be in this array. * - click sortable: If TRUE, this field may be click sorted. * * @ingroup views_field_handlers */ class views_handler_field extends views_handler { - var $field_alias = 'unknown'; - var $aliases = array(); + + /** + * + */ + public $field_alias = 'unknown'; + + /** + * + */ + public $aliases = array(); /** * The field value prior to any rewriting. @@ -58,12 +71,12 @@ class views_handler_field extends views_handler { * Stores additional fields which get's added to the query. * The generated aliases are stored in $aliases. */ - var $additional_fields = array(); + public $additional_fields = array(); /** * Construct a new field handler. */ - function construct() { + public function construct() { parent::construct(); $this->additional_fields = array(); @@ -79,21 +92,24 @@ class views_handler_field extends views_handler { /** * Determine if this field can allow advanced rendering. * - * Fields can set this to FALSE if they do not wish to allow - * token based rewriting or link-making. + * Fields can set this to FALSE if they do not wish to allow token based + * rewriting or link-making. */ - function allow_advanced_render() { + public function allow_advanced_render() { return TRUE; } - function init(&$view, &$options) { + /** + * {@inheritdoc} + */ + public function init(&$view, &$options) { parent::init($view, $options); } /** * Called to add the field to a query. */ - function query() { + public function query() { $this->ensure_my_table(); // Add the field. $params = $this->options['group_type'] != 'group' ? array('function' => $this->options['group_type']) : array(); @@ -105,16 +121,15 @@ class views_handler_field extends views_handler { /** * Add 'additional' fields to the query. * - * @param $fields - * An array of fields. The key is an identifier used to later find the - * field alias used. The value is either a string in which case it's - * assumed to be a field on this handler's table; or it's an array in the - * form of - * @code array('table' => $tablename, 'field' => $fieldname) @endcode + * @param array $fields + * An array of fields. The key is an identifier used to later find the field + * alias used. The value is either a string in which case it's assumed to be + * a field on this handler's table; or it's an array in the form of + * @code array('table' => $tablename, 'field' => $fieldname) @endcode */ - function add_additional_fields($fields = NULL) { + public function add_additional_fields($fields = NULL) { if (!isset($fields)) { - // notice check + // Notice check. if (empty($this->additional_fields)) { return; } @@ -139,7 +154,12 @@ class views_handler_field extends views_handler { } if (empty($table_alias)) { - debug(t('Handler @handler tried to add additional_field @identifier but @table could not be added!', array('@handler' => $this->definition['handler'], '@identifier' => $identifier, '@table' => $info['table']))); + $t_args = array( + '@handler' => $this->definition['handler'], + '@identifier' => $identifier, + '@table' => $info['table'], + ); + debug(t('Handler @handler tried to add additional_field @identifier but @table could not be added!', $t_args)); $this->aliases[$identifier] = 'broken'; continue; } @@ -162,7 +182,7 @@ class views_handler_field extends views_handler { /** * Called to determine what to tell the clicksorter. */ - function click_sort($order) { + public function click_sort($order) { if (isset($this->field_alias)) { // Since fields should always have themselves already added, just // add a sort on the field. @@ -174,14 +194,14 @@ class views_handler_field extends views_handler { /** * Determine if this field is click sortable. */ - function click_sortable() { + public function click_sortable() { return !empty($this->definition['click sortable']); } /** * Get this field's label. */ - function label() { + public function label() { if (!isset($this->options['label'])) { return ''; } @@ -191,7 +211,7 @@ class views_handler_field extends views_handler { /** * Return an HTML element based upon the field's element type. */ - function element_type($none_supported = FALSE, $default_empty = FALSE, $inline = FALSE) { + public function element_type($none_supported = FALSE, $default_empty = FALSE, $inline = FALSE) { if ($none_supported) { if ($this->options['element_type'] === '0') { return ''; @@ -219,7 +239,7 @@ class views_handler_field extends views_handler { /** * Return an HTML element for the label based upon the field's element type. */ - function element_label_type($none_supported = FALSE, $default_empty = FALSE) { + public function element_label_type($none_supported = FALSE, $default_empty = FALSE) { if ($none_supported) { if ($this->options['element_label_type'] === '0') { return ''; @@ -239,7 +259,7 @@ class views_handler_field extends views_handler { /** * Return an HTML element for the wrapper based upon the field's element type. */ - function element_wrapper_type($none_supported = FALSE, $default_empty = FALSE) { + public function element_wrapper_type($none_supported = FALSE, $default_empty = FALSE) { if ($none_supported) { if ($this->options['element_wrapper_type'] === '0') { return 0; @@ -259,11 +279,10 @@ class views_handler_field extends views_handler { /** * Provide a list of elements valid for field HTML. * - * This function can be overridden by fields that want more or fewer - * elements available, though this seems like it would be an incredibly - * rare occurence. + * This function can be overridden by fields that want more or fewer elements + * available, though this seems like it would be an incredibly rare occurence. */ - function get_elements() { + public function get_elements() { static $elements = NULL; if (!isset($elements)) { $elements = variable_get('views_field_rewrite_elements', array( @@ -289,7 +308,7 @@ class views_handler_field extends views_handler { /** * Return the class of the field. */ - function element_classes($row_index = NULL) { + public function element_classes($row_index = NULL) { $classes = explode(' ', $this->options['element_class']); foreach ($classes as &$class) { $class = $this->tokenize_value($class, $row_index); @@ -304,15 +323,14 @@ class views_handler_field extends views_handler { * This function actually figures out which field was last and uses its * tokens so they will all be available. */ - function tokenize_value($value, $row_index = NULL) { + public function tokenize_value($value, $row_index = NULL) { if (strpos($value, '[') !== FALSE || strpos($value, '!') !== FALSE || strpos($value, '%') !== FALSE) { $fake_item = array( 'alter_text' => TRUE, 'text' => $value, ); - // Use isset() because empty() will trigger on 0 and 0 is - // the first row. + // Use isset() because empty() will trigger on 0 and 0 is the first row. if (isset($row_index) && isset($this->view->style_plugin->render_tokens[$row_index])) { $tokens = $this->view->style_plugin->render_tokens[$row_index]; } @@ -339,7 +357,7 @@ class views_handler_field extends views_handler { /** * Return the class of the field's label. */ - function element_label_classes($row_index = NULL) { + public function element_label_classes($row_index = NULL) { $classes = explode(' ', $this->options['element_label_class']); foreach ($classes as &$class) { $class = $this->tokenize_value($class, $row_index); @@ -351,7 +369,7 @@ class views_handler_field extends views_handler { /** * Return the class of the field's wrapper. */ - function element_wrapper_classes($row_index = NULL) { + public function element_wrapper_classes($row_index = NULL) { $classes = explode(' ', $this->options['element_wrapper_class']); foreach ($classes as &$class) { $class = $this->tokenize_value($class, $row_index); @@ -366,12 +384,12 @@ class views_handler_field extends views_handler { * This api exists so that other modules can easy set the values of the field * without having the need to change the render method as well. * - * @param $values + * @param object $values * An object containing all retrieved values. - * @param $field + * @param string $field * Optional name of the field where the value is stored. */ - function get_value($values, $field = NULL) { + public function get_value($values, $field = NULL) { $alias = isset($field) ? $this->aliases[$field] : $this->field_alias; if (isset($values->{$alias})) { return $values->{$alias}; @@ -383,13 +401,16 @@ class views_handler_field extends views_handler { * by in the style settings. * * @return bool - * TRUE if this field handler is groupable, otherwise FALSE. + * TRUE if this field handler is groupable, otherwise FALSE. */ - function use_string_group_by() { + public function use_string_group_by() { return TRUE; } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['label'] = array('default' => $this->definition['title'], 'translatable' => TRUE); @@ -447,10 +468,19 @@ class views_handler_field extends views_handler { /** * Performs some cleanup tasks on the options array before saving it. */ - function options_submit(&$form, &$form_state) { + public function options_submit(&$form, &$form_state) { $options = &$form_state['values']['options']; - $types = array('element_type', 'element_label_type', 'element_wrapper_type'); - $classes = array_combine(array('element_class', 'element_label_class', 'element_wrapper_class'), $types); + $types = array( + 'element_type', + 'element_label_type', + 'element_wrapper_type', + ); + $base_types = array( + 'element_class', + 'element_label_class', + 'element_wrapper_class', + ); + $classes = array_combine($base_types, $types); foreach ($types as $type) { if (!$options[$type . '_enable']) { @@ -471,10 +501,9 @@ class views_handler_field extends views_handler { } /** - * Default options form that provides the label widget that all fields - * should have. + * Default options form provides the label widget that all fields should have. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $label = $this->label(); @@ -581,7 +610,7 @@ class views_handler_field extends views_handler { '#type' => 'checkbox', '#title' => t('Create a CSS class'), '#dependency' => array( - 'edit-options-element-label-type-enable' => array(1) + 'edit-options-element-label-type-enable' => array(1), ), '#default_value' => !empty($this->options['element_label_class']) || (string) $this->options['element_label_class'] == '0', '#fieldset' => 'style_settings', @@ -703,7 +732,7 @@ class views_handler_field extends views_handler { '#title' => t('Replace spaces with dashes'), '#default_value' => $this->options['alter']['replace_spaces'], '#dependency' => array( - 'edit-options-alter-make-link' => array(1) + 'edit-options-alter-make-link' => array(1), ), ); $form['alter']['external'] = array( @@ -722,7 +751,7 @@ class views_handler_field extends views_handler { '#dependency' => array( 'edit-options-alter-make-link' => array(1), ), - '#options' => array( + '#options' => array( 'none' => t('No transform'), 'upper' => t('Upper case'), 'lower' => t('Lower case'), @@ -796,7 +825,8 @@ class views_handler_field extends views_handler { break; } } - $count = 0; // This lets us prepare the key as we want it printed. + // This lets us prepare the key as we want it printed. + $count = 0; foreach ($this->view->display_handler->get_handlers('argument') as $arg => $handler) { $options[t('Arguments')]['%' . ++$count] = t('@argument title', array('@argument' => $handler->ui_name())); $options[t('Arguments')]['!' . $count] = t('@argument input', array('@argument' => $handler->ui_name())); @@ -819,15 +849,15 @@ If you would like to have the characters \'[\' and \']\' please use the html ent $output .= theme('item_list', array( 'items' => $items, - 'type' => $type + 'type' => $type, )); } } } // This construct uses 'hidden' and not markup because process doesn't - // run. It also has an extra div because the dependency wants to hide - // the parent in situations like this, so we need a second div to - // make this work. + // run. It also has an extra div because the dependency wants to hide the + // parent in situations like this, so we need a second div to make this + // work. $form['alter']['help'] = array( '#type' => 'fieldset', '#title' => t('Replacement patterns'), @@ -997,28 +1027,29 @@ If you would like to have the characters \'[\' and \']\' please use the html ent /** * Provide extra data to the administration form */ - function admin_summary() { + public function admin_summary() { return $this->label(); } /** * Run before any fields are rendered. * - * This gives the handlers some time to set up before any handler has - * been rendered. + * This gives the handlers some time to set up before any handler has been + * rendered. * - * @param $values + * @param array $values * An array of all objects returned from the query. */ - function pre_render(&$values) { } + public function pre_render(&$values) { + } /** * Render the field. * - * @param $values + * @param array $values * The values retrieved from the database. */ - function render($values) { + public function render($values) { $value = $this->get_value($values); return $this->sanitize_value($value); } @@ -1029,7 +1060,7 @@ If you would like to have the characters \'[\' and \']\' please use the html ent * This renders a field normally, then decides if render-as-link and * text-replacement rendering is necessary. */ - function advanced_render($values) { + public function advanced_render($values) { if ($this->allow_advanced_render() && method_exists($this, 'render_item')) { $raw_items = $this->get_items($values); // If there are no items, set the original value to NULL. @@ -1094,7 +1125,7 @@ If you would like to have the characters \'[\' and \']\' please use the html ent /** * Checks if a field value is empty. * - * @param $value + * @param mixed $value * The field value. * @param bool $empty_zero * Whether or not this field is configured to consider 0 as empty. @@ -1102,9 +1133,9 @@ If you would like to have the characters \'[\' and \']\' please use the html ent * Whether or not to use empty() to check the value. * * @return bool - * TRUE if the value is considered empty, FALSE otherwise. + * TRUE if the value is considered empty, FALSE otherwise. */ - function is_value_empty($value, $empty_zero, $no_skip_empty = TRUE) { + public function is_value_empty($value, $empty_zero, $no_skip_empty = TRUE) { if (!isset($value)) { $empty = TRUE; } @@ -1124,7 +1155,7 @@ If you would like to have the characters \'[\' and \']\' please use the html ent * This is separated out as some fields may render lists, and this allows * each item to be handled individually. */ - function render_text($alter) { + public function render_text($alter) { $value = $this->last_render; if (!empty($alter['alter_text']) && $alter['text'] !== '') { @@ -1139,9 +1170,10 @@ If you would like to have the characters \'[\' and \']\' please use the html ent // Check if there should be no further rewrite for empty values. $no_rewrite_for_empty = $this->options['hide_alter_empty'] && $this->is_value_empty($this->original_value, $this->options['empty_zero']); - // Check whether the value is empty and return nothing, so the field isn't rendered. - // First check whether the field should be hidden if the value(hide_alter_empty = TRUE) /the rewrite is empty (hide_alter_empty = FALSE). - // For numeric values you can specify whether "0"/0 should be empty. + // Check whether the value is empty and return nothing, so the field isn't + // rendered. First check whether the field should be hidden if the + // value(hide_alter_empty = TRUE) /the rewrite is empty (hide_alter_empty = + // FALSE). For numeric values you can specify whether "0"/0 should be empty. if ((($this->options['hide_empty'] && empty($value)) || ($alter['phase'] != VIEWS_HANDLER_RENDER_TEXT_PHASE_EMPTY && $no_rewrite_for_empty)) && $this->is_value_empty($value, $this->options['empty_zero'], FALSE)) { @@ -1169,7 +1201,8 @@ If you would like to have the characters \'[\' and \']\' please use the html ent $more_link_path = $this->options['alter']['more_link_path']; $more_link_path = strip_tags(decode_entities(strtr($more_link_path, $tokens))); - // Take sure that paths which was runned through url() does work as well. + // Take sure that paths which was runned through url() does work as + // well. $base_path = base_path(); // Checks whether the path starts with the base_path. if (strpos($more_link_path, $base_path) === 0) { @@ -1189,7 +1222,7 @@ If you would like to have the characters \'[\' and \']\' please use the html ent if (!empty($alter['make_link']) && !empty($alter['path'])) { if (!isset($tokens)) { - $tokens = $this->get_render_tokens($alter); + $tokens = $this->get_render_tokens($alter); } $value = $this->render_as_link($alter, $value, $tokens); } @@ -1200,7 +1233,7 @@ If you would like to have the characters \'[\' and \']\' please use the html ent /** * Render this field as altered text, from a fieldset set by the user. */ - function render_altered($alter, $tokens) { + public function render_altered($alter, $tokens) { // Filter this right away as our substitutions are already sanitized. $value = filter_xss_admin($alter['text']); $value = strtr($value, $tokens); @@ -1211,21 +1244,20 @@ If you would like to have the characters \'[\' and \']\' please use the html ent /** * Trim the field down to the specified length. */ - function render_trim_text($alter, $value) { + public function render_trim_text($alter, $value) { if (!empty($alter['strip_tags'])) { // NOTE: It's possible that some external fields might override the - // element type so if someone from, say, CCK runs into a bug here, - // this may be why =) + // element type so if someone from, say, CCK runs into a bug here, this + // may be why =) $this->definition['element type'] = 'span'; } return views_trim_text($alter, $value); } /** - * Render this field as a link, with the info from a fieldset set by - * the user. + * Render this field as a link, with info from a fieldset set by the user. */ - function render_as_link($alter, $text, $tokens) { + public function render_as_link($alter, $text, $tokens) { $value = ''; if (!empty($alter['prefix'])) { @@ -1243,9 +1275,9 @@ If you would like to have the characters \'[\' and \']\' please use the html ent // strip_tags() removes , so check whether its different to front. if ($path != '') { - // Use strip tags as there should never be HTML in the path. - // However, we need to preserve special characters like " that - // were removed by check_plain(). + // Use strip tags as there should never be HTML in the path. However, we + // need to preserve special characters like " that were removed by + // check_plain(). $path = strip_tags(decode_entities(strtr($path, $tokens))); if (!empty($alter['path_case']) && $alter['path_case'] != 'none') { @@ -1266,16 +1298,16 @@ If you would like to have the characters \'[\' and \']\' please use the html ent } // If the path is empty do not build a link around the given text and return - // it as is. - // http://www.example.com URLs will not have a $url['path'], so check host as well. + // it as is. http://www.example.com URLs will not have a $url['path'], so + // check host as well. if (empty($url['path']) && empty($url['host']) && empty($url['fragment'])) { return $text; } // If no scheme is provided in the $path, assign the default 'http://'. - // This allows a url of 'www.example.com' to be converted to 'http://www.example.com'. - // Only do this on for external URLs. - if ($alter['external']){ + // This allows a url of 'www.example.com' to be converted to + // 'http://www.example.com'. Only do this on for external URLs. + if ($alter['external']) { if (!isset($url['scheme'])) { // There is no scheme, add the default 'http://' to the $path. $path = "http://$path"; @@ -1320,13 +1352,14 @@ If you would like to have the characters \'[\' and \']\' please use the html ent $options['attributes']['rel'] = $rel; } - $target = check_plain(trim(strtr($alter['target'],$tokens))); + $target = check_plain(trim(strtr($alter['target'], $tokens))); if (!empty($target)) { $options['attributes']['target'] = $target; } - // Allow the addition of arbitrary attributes to links. Additional attributes - // currently can only be altered in preprocessors and not within the UI. + // Allow the addition of arbitrary attributes to links. Additional + // attributes currently can only be altered in preprocessors and not within + // the UI. if (isset($alter['link_attributes']) && is_array($alter['link_attributes'])) { foreach ($alter['link_attributes'] as $key => $attribute) { if (!isset($options['attributes'][$key])) { @@ -1375,11 +1408,10 @@ If you would like to have the characters \'[\' and \']\' please use the html ent /** * Get the 'render' tokens to use for advanced rendering. * - * This runs through all of the fields and arguments that - * are available and gets their values. This will then be - * used in one giant str_replace(). + * This runs through all of the fields and arguments that are available and + * gets their values. This will then be used in one giant str_replace(). */ - function get_render_tokens($item) { + public function get_render_tokens($item) { $tokens = array(); if (!empty($this->view->build_info['substitutions'])) { $tokens = $this->view->build_info['substitutions']; @@ -1391,9 +1423,9 @@ If you would like to have the characters \'[\' and \']\' please use the html ent $tokens[$token] = ''; } - // Use strip tags as there should never be HTML in the path. - // However, we need to preserve special characters like " that - // were removed by check_plain(). + // Use strip tags as there should never be HTML in the path. However, we + // need to preserve special characters like " that were removed by + // check_plain(). $tokens['!' . $count] = isset($this->view->args[$count - 1]) ? strip_tags(decode_entities($this->view->args[$count - 1])) : ''; } @@ -1450,27 +1482,28 @@ If you would like to have the characters \'[\' and \']\' please use the html ent * '%bar_b_c' => 'value' * ); * - * @param $array + * @param array $array * An array of values. - * - * @param $parent_keys + * @param array $parent_keys * An array of parent keys. This will represent the array depth. * - * @return - * An array of available tokens, with nested keys representative of the array structure. + * @return array + * An array of available tokens, with nested keys representative of the + * array structure. */ - function get_token_values_recursive(array $array, array $parent_keys = array()) { + public function get_token_values_recursive(array $array, array $parent_keys = array()) { $tokens = array(); foreach ($array as $param => $val) { if (is_array($val)) { - // Copy parent_keys array, so we don't afect other elements of this iteration. - $child_parent_keys = $parent_keys; - $child_parent_keys[] = $param; - // Get the child tokens. - $child_tokens = $this->get_token_values_recursive($val, $child_parent_keys); - // Add them to the current tokens array. - $tokens += $child_tokens; + // Copy parent_keys array, so we don't afect other elements of this + // iteration. + $child_parent_keys = $parent_keys; + $child_parent_keys[] = $param; + // Get the child tokens. + $child_tokens = $this->get_token_values_recursive($val, $child_parent_keys); + // Add them to the current tokens array. + $tokens += $child_tokens; } else { // Create a token key based on array element structure. @@ -1485,50 +1518,57 @@ If you would like to have the characters \'[\' and \']\' please use the html ent /** * Add any special tokens this field might use for itself. * - * This method is intended to be overridden by items that generate - * fields as a list. For example, the field that displays all terms - * on a node might have tokens for the tid and the term. + * This method is intended to be overridden by items that generate fields as a + * list. For example, the field that displays all terms on a node might have + * tokens for the tid and the term. * - * By convention, tokens should follow the format of [token-subtoken] - * where token is the field ID and subtoken is the field. If the - * field ID is terms, then the tokens might be [terms-tid] and [terms-name]. + * By convention, tokens should follow the format of [token-subtoken] where + * token is the field ID and subtoken is the field. If the field ID is terms, + * then the tokens might be [terms-tid] and [terms-name]. */ - function add_self_tokens(&$tokens, $item) { } + public function add_self_tokens(&$tokens, $item) { + } /** * Document any special tokens this field might use for itself. * * @see add_self_tokens() */ - function document_self_tokens(&$tokens) { } + public function document_self_tokens(&$tokens) { + } /** - * Call out to the theme() function, which probably just calls render() but - * allows sites to override output fairly easily. + * Call out to the theme() function. + * + * It probably just calls render() but allows sites to override output fairly + * easily. */ - function theme($values) { + public function theme($values) { return theme($this->theme_functions(), array( 'view' => $this->view, 'field' => $this, - 'row' => $values + 'row' => $values, )); } - function theme_functions() { + /** + * Build a list of suitable theme functions for this view. + */ + public function theme_functions() { $themes = array(); $hook = 'views_view_field'; $display = $this->view->display[$this->view->current_display]; if (!empty($display)) { - $themes[] = $hook . '__' . $this->view->name . '__' . $display->id . '__' . $this->options['id']; - $themes[] = $hook . '__' . $this->view->name . '__' . $display->id; + $themes[] = $hook . '__' . $this->view->name . '__' . $display->id . '__' . $this->options['id']; + $themes[] = $hook . '__' . $this->view->name . '__' . $display->id; $themes[] = $hook . '__' . $display->id . '__' . $this->options['id']; $themes[] = $hook . '__' . $display->id; if ($display->id != $display->display_plugin) { - $themes[] = $hook . '__' . $this->view->name . '__' . $display->display_plugin . '__' . $this->options['id']; - $themes[] = $hook . '__' . $this->view->name . '__' . $display->display_plugin; + $themes[] = $hook . '__' . $this->view->name . '__' . $display->display_plugin . '__' . $this->options['id']; + $themes[] = $hook . '__' . $this->view->name . '__' . $display->display_plugin; $themes[] = $hook . '__' . $display->display_plugin . '__' . $this->options['id']; $themes[] = $hook . '__' . $display->display_plugin; } @@ -1541,9 +1581,13 @@ If you would like to have the characters \'[\' and \']\' please use the html ent return $themes; } - function ui_name($short = FALSE) { + /** + * {@inheritdoc} + */ + public function ui_name($short = FALSE) { return $this->get_field(parent::ui_name($short)); } + } /** @@ -1552,22 +1596,44 @@ If you would like to have the characters \'[\' and \']\' please use the html ent * @ingroup views_field_handlers */ class views_handler_field_broken extends views_handler_field { - function ui_name($short = FALSE) { + + /** + * {@inheritdoc} + */ + public function ui_name($short = FALSE) { return t('Broken/missing handler'); } - function ensure_my_table() { /* No table to ensure! */ } - function query($group_by = FALSE) { /* No query to run */ } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function ensure_my_table() { + // No table to ensure! + } + + /** + * {@inheritdoc} + */ + public function query($group_by = FALSE) { + // No query to run. + } + + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['markup'] = array( '#markup' => '
' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '
', ); } /** - * Determine if the handler is considered 'broken' + * {@inheritdoc} */ - function broken() { return TRUE; } + public function broken() { + return TRUE; + } + } /** @@ -1576,7 +1642,11 @@ class views_handler_field_broken extends views_handler_field { * @ingroup views_field_handlers */ class views_handler_field_file_size extends views_handler_field { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['file_size_display'] = array('default' => 'formatted'); @@ -1584,7 +1654,10 @@ class views_handler_field_file_size extends views_handler_field { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['file_size_display'] = array( '#title' => t('File size display'), @@ -1596,7 +1669,10 @@ class views_handler_field_file_size extends views_handler_field { ); } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values); if ($value) { switch ($this->options['file_size_display']) { @@ -1611,6 +1687,7 @@ class views_handler_field_file_size extends views_handler_field { return ''; } } + } /** @@ -1619,10 +1696,15 @@ class views_handler_field_file_size extends views_handler_field { * @ingroup views_field_handlers */ class views_handler_field_xss extends views_handler_field { - function render($values) { + + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values); return $this->sanitize_value($value, 'xss'); } + } /** diff --git a/sites/all/modules/contrib/views/views/handlers/views_handler_field_boolean.inc b/sites/all/modules/contrib/views/views/handlers/views_handler_field_boolean.inc index 8acfb32..cfa1605 100644 --- a/sites/all/modules/contrib/views/views/handlers/views_handler_field_boolean.inc +++ b/sites/all/modules/contrib/views/views/handlers/views_handler_field_boolean.inc @@ -11,18 +11,22 @@ * Allows for display of true/false, yes/no, on/off, enabled/disabled. * * Definition terms: - * - output formats: An array where the first entry is displayed on boolean true - * and the second is displayed on boolean false. An example for sticky is: - * @code - * 'output formats' => array( - * 'sticky' => array(t('Sticky'), ''), - * ), - * @endcode + * - output formats: An array where the first entry is displayed on boolean true + * and the second is displayed on boolean false. An example for sticky is: + * @code + * 'output formats' => array( + * 'sticky' => array(t('Sticky'), ''), + * ), + * @endcode * * @ingroup views_field_handlers */ class views_handler_field_boolean extends views_handler_field { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['type'] = array('default' => 'yes-no'); $options['type_custom_true'] = array('default' => '', 'translatable' => TRUE); @@ -32,7 +36,10 @@ class views_handler_field_boolean extends views_handler_field { return $options; } - function init(&$view, &$options) { + /** + * {@inheritdoc} + */ + public function init(&$view, &$options) { parent::init($view, $options); $default_formats = array( @@ -48,7 +55,10 @@ class views_handler_field_boolean extends views_handler_field { $this->formats = array_merge($default_formats, $output_formats, $custom_format); } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { foreach ($this->formats as $key => $item) { $options[$key] = implode('/', $item); } @@ -91,7 +101,10 @@ class views_handler_field_boolean extends views_handler_field { parent::options_form($form, $form_state); } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = $this->get_value($values); if (!empty($this->options['not'])) { $value = !$value; @@ -100,11 +113,12 @@ class views_handler_field_boolean extends views_handler_field { if ($this->options['type'] == 'custom') { return $value ? filter_xss_admin($this->options['type_custom_true']) : filter_xss_admin($this->options['type_custom_false']); } - else if (isset($this->formats[$this->options['type']])) { + elseif (isset($this->formats[$this->options['type']])) { return $value ? $this->formats[$this->options['type']][0] : $this->formats[$this->options['type']][1]; } else { return $value ? $this->formats['yes-no'][0] : $this->formats['yes-no'][1]; } } + } diff --git a/sites/all/modules/contrib/views/views/handlers/views_handler_field_contextual_links.inc b/sites/all/modules/contrib/views/views/handlers/views_handler_field_contextual_links.inc index faeeedc..f3eb66e 100644 --- a/sites/all/modules/contrib/views/views/handlers/views_handler_field_contextual_links.inc +++ b/sites/all/modules/contrib/views/views/handlers/views_handler_field_contextual_links.inc @@ -10,36 +10,12 @@ * * @ingroup views_field_handlers */ -class views_handler_field_contextual_links extends views_handler_field { - function option_definition() { - $options = parent::option_definition(); +class views_handler_field_contextual_links extends views_handler_field_links { - $options['fields'] = array('default' => array()); - $options['destination'] = array('default' => TRUE, 'bool' => TRUE); - - return $options; - } - - function options_form(&$form, &$form_state) { - $all_fields = $this->view->display_handler->get_field_labels(); - // Offer to include only those fields that follow this one. - $field_options = array_slice($all_fields, 0, array_search($this->options['id'], array_keys($all_fields))); - $form['fields'] = array( - '#type' => 'checkboxes', - '#title' => t('Fields'), - '#description' => t('Fields to be included as contextual links.'), - '#options' => $field_options, - '#default_value' => $this->options['fields'], - ); - $form['destination'] = array( - '#type' => 'checkbox', - '#title' => t('Include destination'), - '#description' => t('Include a "destination" parameter in the link to return the user to the original view upon completing the contextual action.'), - '#default_value' => $this->options['destination'], - ); - } - - function pre_render(&$values) { + /** + * {@inheritdoc} + */ + public function pre_render(&$values) { // Add a row plugin css class for the contextual link. $class = 'contextual-links-region'; if (!empty($this->view->style_plugin->options['row_class'])) { @@ -50,35 +26,21 @@ class views_handler_field_contextual_links extends views_handler_field { } } + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { + parent::options_form($form, $form_state); + + $form['fields']['#description'] = t('Fields to be included as contextual links.'); + $form['destination']['#description'] = t('Include a "destination" parameter in the link to return the user to the original view upon completing the contextual action.'); + } + /** * Render the contextual fields. */ - function render($values) { - $links = array(); - foreach ($this->options['fields'] as $field) { - if (empty($this->view->style_plugin->rendered_fields[$this->view->row_index][$field])) { - continue; - } - $title = $this->view->field[$field]->last_render_text; - $path = ''; - if (!empty($this->view->field[$field]->options['alter']['path'])) { - $path = $this->view->field[$field]->options['alter']['path']; - } - if (!empty($title) && !empty($path)) { - // Make sure that tokens are replaced for this paths as well. - $tokens = $this->get_render_tokens(array()); - $path = strip_tags(decode_entities(strtr($path, $tokens))); - - $links[$field] = array( - 'href' => $path, - 'title' => $title, - ); - if (!empty($this->options['destination'])) { - $links[$field]['query'] = drupal_get_destination(); - } - } - } - + public function render($values) { + $links = $this->get_links(); if (!empty($links)) { $build = array( '#prefix' => '', '#tree' => TRUE, ); - $cache = $this->get_option('cache'); $form['cache']['type'] = array( '#type' => 'radios', '#options' => views_fetch_plugin_names('cache', NULL, array($this->view->base_table)), '#default_value' => $cache['type'], ); - $cache_plugin = views_fetch_plugin_data('cache', $cache['type']); if (!empty($cache_plugin['uses options'])) { $form['markup'] = array( @@ -1610,14 +1688,18 @@ class views_plugin_display extends views_plugin { ); } break; + case 'cache_options': $cache = $this->get_option('cache'); $plugin = $this->get_plugin('cache'); $form['#title'] .= t('Caching options'); if ($plugin) { - $form['#help_topic'] = $plugin->definition['help topic']; - $form['#help_module'] = $plugin->definition['module']; - + if (!empty($plugin->definition['help topic'])) { + $form['#help_topic'] = $plugin->definition['help topic']; + } + if (!empty($plugin->definition['module'])) { + $form['#help_module'] = $plugin->definition['module']; + } $form['cache_options'] = array( '#tree' => TRUE, ); @@ -1628,6 +1710,7 @@ class views_plugin_display extends views_plugin { $plugin->options_form($form['cache_options'], $form_state); } break; + case 'query': $query_options = $this->get_option('query'); $plugin_name = $query_options['type']; @@ -1635,14 +1718,12 @@ class views_plugin_display extends views_plugin { $form['#title'] .= t('Query options'); $this->view->init_query(); if ($this->view->query) { - if (isset($this->view->query->definition['help topic'])) { + if (!empty($this->view->query->definition['help topic'])) { $form['#help_topic'] = $this->view->query->definition['help topic']; } - - if (isset($this->view->query->definition['module'])) { + if (!empty($this->view->query->definition['module'])) { $form['#help_module'] = $this->view->query->definition['module']; } - $form['query'] = array( '#tree' => TRUE, 'type' => array( @@ -1653,10 +1734,10 @@ class views_plugin_display extends views_plugin { '#tree' => TRUE, ), ); - $this->view->query->options_form($form['query']['options'], $form_state); } break; + case 'field_language': $form['#title'] .= t('Field Language'); @@ -1699,6 +1780,7 @@ class views_plugin_display extends views_plugin { $form['field_language']['#markup'] = t("You don't have translatable entity types."); } break; + case 'style_plugin': $form['#title'] .= t('How should this view be styled'); $form['#help_topic'] = 'style'; @@ -1715,8 +1797,8 @@ class views_plugin_display extends views_plugin { '#markup' => '
' . t('You may also adjust the !settings for the currently selected style.', array('!settings' => $this->option_link(t('settings'), 'style_options'))) . '
', ); } - break; + case 'style_options': $form['#title'] .= t('Style options'); $style = TRUE; @@ -1727,15 +1809,17 @@ class views_plugin_display extends views_plugin { if (!isset($name)) { $name = $this->get_option('row_plugin'); } - // if row, $style will be empty. + // If row, $style will be empty. if (empty($style)) { $form['#title'] .= t('Row style options'); $type = 'row_plugin'; } $plugin = $this->get_plugin(empty($style) ? 'row' : 'style'); if ($plugin) { - if (isset($plugin->definition['help topic'])) { + if (!empty($plugin->definition['help topic'])) { $form['#help_topic'] = $plugin->definition['help topic']; + } + if (!empty($plugin->definition['module'])) { $form['#help_module'] = $plugin->definition['module']; } $form[$form_state['section']] = array( @@ -1744,6 +1828,7 @@ class views_plugin_display extends views_plugin { $plugin->options_form($form[$form_state['section']], $form_state); } break; + case 'row_plugin': $form['#title'] .= t('How should each row in this view be styled'); $form['#help_topic'] = 'style-row'; @@ -1759,8 +1844,8 @@ class views_plugin_display extends views_plugin { '#markup' => '
' . t('You may also adjust the !settings for the currently selected row style.', array('!settings' => $this->option_link(t('settings'), 'row_options'))) . '
', ); } - break; + case 'link_display': $form['#title'] .= t('Which display to use for path'); foreach ($this->view->display as $display_id => $display) { @@ -1779,14 +1864,14 @@ class views_plugin_display extends views_plugin { } $options = array(); - $count = 0; // This lets us prepare the key as we want it printed. + // This lets us prepare the key as we want it printed. + $count = 0; foreach ($this->view->display_handler->get_handlers('argument') as $arg => $handler) { $options[t('Arguments')]['%' . ++$count] = t('@argument title', array('@argument' => $handler->ui_name())); $options[t('Arguments')]['!' . $count] = t('@argument input', array('@argument' => $handler->ui_name())); } - // Default text. - // We have some options, so make a list. + // Default text. We have some options, so make a list. $output = ''; if (!empty($options)) { $output = t('

The following tokens are available for this link.

'); @@ -1813,6 +1898,7 @@ class views_plugin_display extends views_plugin { '#dependency' => array('radio:link_display' => array('custom_url')), ); break; + case 'analyze-theme': $form['#title'] .= t('Theming information'); $form['#help_topic'] = 'analyze-theme'; @@ -1843,7 +1929,7 @@ class views_plugin_display extends views_plugin { // The base themes should be initialized in the right order. $base_theme = array_reverse($base_theme); - // This code is copied directly from _drupal_theme_initialize() + // This code is copied directly from _drupal_theme_initialize(). $theme_engine = NULL; // Initialize the theme. @@ -1875,8 +1961,8 @@ class views_plugin_display extends views_plugin { $this->theme_registry = _theme_load_registry($theme, $base_theme, $theme_engine); } - // If there's a theme engine involved, we also need to know its extension - // so we can give the proper filename. + // If there's a theme engine involved, we also need to know its + // extension so we can give the proper filename. $this->theme_extension = '.tpl.php'; if (isset($theme_engine)) { $extension_function = $theme_engine . '_extension'; @@ -1983,6 +2069,7 @@ class views_plugin_display extends views_plugin { $form_state['ok_button'] = TRUE; break; + case 'analyze-theme-display': $form['#title'] .= t('Theming information (display)'); $output = '

' . t('Back to !info.', array('!info' => $this->option_link(t('theming information'), 'analyze-theme'))) . '

'; @@ -2008,6 +2095,7 @@ class views_plugin_display extends views_plugin { $form_state['ok_button'] = TRUE; break; + case 'analyze-theme-style': $form['#title'] .= t('Theming information (style)'); $output = '

' . t('Back to !info.', array('!info' => $this->option_link(t('theming information'), 'analyze-theme'))) . '

'; @@ -2035,6 +2123,7 @@ class views_plugin_display extends views_plugin { $form_state['ok_button'] = TRUE; break; + case 'analyze-theme-row': $form['#title'] .= t('Theming information (row style)'); $output = '

' . t('Back to !info.', array('!info' => $this->option_link(t('theming information'), 'analyze-theme'))) . '

'; @@ -2062,6 +2151,7 @@ class views_plugin_display extends views_plugin { $form_state['ok_button'] = TRUE; break; + case 'analyze-theme-field': $form['#title'] .= t('Theming information (row style)'); $output = '

' . t('Back to !info.', array('!info' => $this->option_link(t('theming information'), 'analyze-theme'))) . '

'; @@ -2089,6 +2179,7 @@ class views_plugin_display extends views_plugin { '#default_value' => $this->get_option('exposed_block') ? 1 : 0, ); break; + case 'exposed_form': $form['#title'] .= t('Exposed Form'); $form['exposed_form'] = array( @@ -2113,11 +2204,17 @@ class views_plugin_display extends views_plugin { ); } break; + case 'exposed_form_options': $plugin = $this->get_plugin('exposed_form'); $form['#title'] .= t('Exposed form options'); if ($plugin) { - $form['#help_topic'] = $plugin->definition['help topic']; + if (!empty($plugin->definition['help topic'])) { + $form['#help_topic'] = $plugin->definition['help topic']; + } + if (!empty($plugin->definition['module'])) { + $form['#help_module'] = $plugin->definition['module']; + } $form['exposed_form_options'] = array( '#tree' => TRUE, @@ -2125,6 +2222,7 @@ class views_plugin_display extends views_plugin { $plugin->options_form($form['exposed_form_options'], $form_state); } break; + case 'pager': $form['#title'] .= t('Select which pager, if any, to use for this view'); $form['pager'] = array( @@ -2140,7 +2238,7 @@ class views_plugin_display extends views_plugin { '#default_value' => $pager['type'], ); - $pager_plugin = views_fetch_plugin_data('pager', $pager['type'], array($this->view->base_table)); + $pager_plugin = views_fetch_plugin_data('pager', $pager['type']); if (!empty($pager_plugin['uses options'])) { $form['markup'] = array( '#prefix' => '
', @@ -2148,13 +2246,18 @@ class views_plugin_display extends views_plugin { '#markup' => t('You may also adjust the !settings for the currently selected pager.', array('!settings' => $this->option_link(t('settings'), 'pager_options'))), ); } - break; + case 'pager_options': $plugin = $this->get_plugin('pager'); $form['#title'] .= t('Pager options'); if ($plugin) { - $form['#help_topic'] = $plugin->definition['help topic']; + if (!empty($plugin->definition['help topic'])) { + $form['#help_topic'] = $plugin->definition['help topic']; + } + if (!empty($plugin->definition['module'])) { + $form['#help_module'] = $plugin->definition['module']; + } $form['pager_options'] = array( '#tree' => TRUE, @@ -2172,7 +2275,7 @@ class views_plugin_display extends views_plugin { /** * Format a list of theme templates for output by the theme info helper. */ - function format_themes($themes) { + public function format_themes($themes) { $registry = $this->theme_registry; $extension = $this->theme_extension; @@ -2200,19 +2303,21 @@ class views_plugin_display extends views_plugin { /** * Validate the options form. */ - function options_validate(&$form, &$form_state) { + public function options_validate(&$form, &$form_state) { switch ($form_state['section']) { case 'display_title': if (empty($form_state['values']['display_title'])) { form_error($form['display_title'], t('Display title may not be empty.')); } break; + case 'css_class': $css_class = $form_state['values']['css_class']; if (preg_match('/[^a-zA-Z0-9-_ ]/', $css_class)) { form_error($form['css_class'], t('CSS classes must be alphanumeric or dashes only.')); } - break; + break; + case 'display_id': if ($form_state['values']['display_id']) { if (preg_match('/[^a-z0-9_]/', $form_state['values']['display_id'])) { @@ -2226,6 +2331,7 @@ class views_plugin_display extends views_plugin { } } break; + case 'style_options': $style = TRUE; case 'row_options': @@ -2235,29 +2341,34 @@ class views_plugin_display extends views_plugin { $plugin->options_validate($form[$form_state['section']], $form_state); } break; + case 'access_options': $plugin = $this->get_plugin('access'); if ($plugin) { $plugin->options_validate($form['access_options'], $form_state); } break; + case 'query': if ($this->view->query) { $this->view->query->options_validate($form['query'], $form_state); } break; + case 'cache_options': $plugin = $this->get_plugin('cache'); if ($plugin) { $plugin->options_validate($form['cache_options'], $form_state); } break; + case 'exposed_form_options': $plugin = $this->get_plugin('exposed_form'); if ($plugin) { $plugin->options_validate($form['exposed_form_options'], $form_state); } break; + case 'pager_options': $plugin = $this->get_plugin('pager'); if ($plugin) { @@ -2275,7 +2386,7 @@ class views_plugin_display extends views_plugin { * Perform any necessary changes to the form values prior to storage. * There is no need for this function to actually store the data. */ - function options_submit(&$form, &$form_state) { + public function options_submit(&$form, &$form_state) { // Not sure I like this being here, but it seems (?) like a logical place. $cache_plugin = $this->get_plugin('cache'); if ($cache_plugin) { @@ -2289,10 +2400,12 @@ class views_plugin_display extends views_plugin { $this->display->new_id = $form_state['values']['display_id']; } break; + case 'display_title': $this->display->display_title = $form_state['values']['display_title']; $this->set_option('display_description', $form_state['values']['display_description']); break; + case 'access': $access = $this->get_option('access'); if ($access['type'] != $form_state['values']['access']['type']) { @@ -2305,8 +2418,8 @@ class views_plugin_display extends views_plugin { } } } - break; + case 'access_options': $plugin = views_get_plugin('access', $form_state['values'][$section]['type']); if ($plugin) { @@ -2314,6 +2427,7 @@ class views_plugin_display extends views_plugin { $this->set_option('access', $form_state['values'][$section]); } break; + case 'cache': $cache = $this->get_option('cache'); if ($cache['type'] != $form_state['values']['cache']['type']) { @@ -2326,8 +2440,8 @@ class views_plugin_display extends views_plugin { } } } - break; + case 'cache_options': $plugin = views_get_plugin('cache', $form_state['values'][$section]['type']); if ($plugin) { @@ -2335,6 +2449,7 @@ class views_plugin_display extends views_plugin { $this->set_option('cache', $form_state['values'][$section]); } break; + case 'query': $plugin = $this->get_plugin('query'); if ($plugin) { @@ -2350,25 +2465,31 @@ class views_plugin_display extends views_plugin { case 'display_comment': $this->set_option($section, $form_state['values'][$section]); break; + case 'field_language': $this->set_option('field_language', $form_state['values']['field_language']); $this->set_option('field_language_add_to_query', $form_state['values']['field_language_add_to_query']); break; + case 'use_ajax': case 'hide_attachment_summary': case 'hide_admin_links': $this->set_option($section, (bool)$form_state['values'][$section]); break; + case 'use_more': $this->set_option($section, intval($form_state['values'][$section])); $this->set_option('use_more_always', !intval($form_state['values']['use_more_always'])); + $this->set_option('open_new_window', $form_state['values']['open_new_window']) == '1'; $this->set_option('use_more_text', $form_state['values']['use_more_text']); case 'distinct': $this->set_option($section, $form_state['values'][$section]); break; + case 'group_by': $this->set_option($section, $form_state['values'][$section]); break; + case 'row_plugin': // This if prevents resetting options to default if they don't change // the plugin. @@ -2385,6 +2506,7 @@ class views_plugin_display extends views_plugin { } } break; + case 'style_plugin': // This if prevents resetting options to default if they don't change // the plugin. @@ -2400,6 +2522,7 @@ class views_plugin_display extends views_plugin { } } break; + case 'style_options': $style = TRUE; case 'row_options': @@ -2410,9 +2533,11 @@ class views_plugin_display extends views_plugin { } $this->set_option($section, $form_state['values'][$section]); break; + case 'exposed_block': $this->set_option($section, (bool) $form_state['values'][$section]); break; + case 'exposed_form': $exposed_form = $this->get_option('exposed_form'); if ($exposed_form['type'] != $form_state['values']['exposed_form']['type']) { @@ -2425,8 +2550,8 @@ class views_plugin_display extends views_plugin { } } } - break; + case 'exposed_form_options': $plugin = $this->get_plugin('exposed_form'); if ($plugin) { @@ -2436,6 +2561,7 @@ class views_plugin_display extends views_plugin { $this->set_option('exposed_form', $exposed_form); } break; + case 'pager': $pager = $this->get_option('pager'); if ($pager['type'] != $form_state['values']['pager']['type']) { @@ -2452,8 +2578,8 @@ class views_plugin_display extends views_plugin { } } } - break; + case 'pager_options': $plugin = $this->get_plugin('pager'); if ($plugin) { @@ -2473,7 +2599,7 @@ class views_plugin_display extends views_plugin { /** * If override/revert was clicked, perform the proper toggle. */ - function options_override($form, &$form_state) { + public function options_override($form, &$form_state) { $this->set_override($form_state['section']); } @@ -2487,7 +2613,7 @@ class views_plugin_display extends views_plugin { * - TRUE: Revert to default. * - FALSE: Mark it as overridden. */ - function set_override($section, $new_state = NULL) { + public function set_override($section, $new_state = NULL) { $options = $this->defaultable_sections($section); if (!$options) { return; @@ -2517,28 +2643,29 @@ class views_plugin_display extends views_plugin { /** * Inject anything into the query that the display handler needs. */ - function query() { + public function query() { foreach ($this->extender as $extender) { $extender->query(); } } /** - * Not all display plugins will support filtering + * Not all display plugins will support filtering. */ - function render_filters() { } + public function render_filters() { + } /** * Not all display plugins will suppert pager rendering. */ - function render_pager() { + public function render_pager() { return TRUE; } /** - * Render the 'more' link + * Render the 'more' link. */ - function render_more_link() { + public function render_more_link() { if ($this->use_more() && ($this->use_more_always() || (!empty($this->view->query->pager) && $this->view->query->pager->has_more_records()))) { $path = $this->get_path(); @@ -2556,14 +2683,30 @@ class views_plugin_display extends views_plugin { $url_options['query'] = $this->view->exposed_raw_input; } $theme = views_theme_functions('views_more', $this->view, $this->display); + + $parsed_url = drupal_parse_url($path); + // Preserve the query string from url. + if (!empty($parsed_url['query'])) { + if (!empty($url_options['query'])) { + $url_options['query'] = array_merge($parsed_url['query'], $url_options['query']); + } + else { + $url_options['query'] = $parsed_url['query']; + } + $path = $parsed_url['path']; + } + // Add fragment if applicable. + if (!empty($parsed_url['fragment'])) { + $url_options['fragment'] = $parsed_url['fragment']; + } + $path = check_url(url($path, $url_options)); - return theme($theme, array('more_url' => $path, 'link_text' => check_plain($this->use_more_text()), 'view' => $this->view)); + return theme($theme, array('more_url' => $path, 'new_window' => $this->use_more_open_new_window(), 'link_text' => check_plain($this->use_more_text()), 'view' => $this->view)); } } } - /** * Legacy functions. */ @@ -2571,7 +2714,7 @@ class views_plugin_display extends views_plugin { /** * Render the header of the view. */ - function render_header() { + public function render_header() { $empty = !empty($this->view->result); return $this->render_area('header', $empty); } @@ -2579,33 +2722,43 @@ class views_plugin_display extends views_plugin { /** * Render the footer of the view. */ - function render_footer() { + public function render_footer() { $empty = !empty($this->view->result); return $this->render_area('footer', $empty); } - function render_empty() { + /** + * + */ + public function render_empty() { return $this->render_area('empty'); } /** * If this display creates a block, implement one of these. */ - function hook_block_list($delta = 0, $edit = array()) { return array(); } + public function hook_block_list($delta = 0, $edit = array()) { + return array(); + } /** * If this display creates a page with a menu item, implement it here. */ - function hook_menu() { return array(); } + public function hook_menu() { + return array(); + } /** * Render this display. */ - function render() { + public function render() { return theme($this->theme_functions(), array('view' => $this->view)); } - function render_area($area, $empty = FALSE) { + /** + * + */ + public function render_area($area, $empty = FALSE) { $return = ''; foreach ($this->get_handlers($area) as $area) { $return .= $area->render($empty); @@ -2613,11 +2766,10 @@ class views_plugin_display extends views_plugin { return $return; } - /** * Determine if the user has access to this display of the view. */ - function access($account = NULL) { + public function access($account = NULL) { if (!isset($account)) { global $user; $account = $user; @@ -2633,7 +2785,7 @@ class views_plugin_display extends views_plugin { return $plugin->access($account); } - // fallback to all access if no plugin. + // Fallback to all access if no plugin. return TRUE; } @@ -2642,7 +2794,7 @@ class views_plugin_display extends views_plugin { * from execute because they are extremely common and unlikely to be * overridden on an individual display. */ - function pre_execute() { + public function pre_execute() { $this->view->set_use_ajax($this->use_ajax()); if ($this->use_more() && !$this->use_more_always()) { $this->view->get_total_rows = TRUE; @@ -2668,27 +2820,35 @@ class views_plugin_display extends views_plugin { * * The base class cannot be executed. */ - function execute() { } + public function execute() { + } /** - * Fully render the display for the purposes of a live preview or - * some other AJAXy reason. + * Fully render the display. + * + * Used for the purposes of a live preview or some other AJAXy reason. */ - function preview() { return $this->view->render(); } + public function preview() { + return $this->view->render(); + } /** - * Displays can require a certain type of style plugin. By default, they will - * be 'normal'. + * Displays can require a certain type of style plugin. + * + * By default, they will be 'normal'. */ - function get_style_type() { return 'normal'; } + public function get_style_type() { + return 'normal'; + } /** * Make sure the display and all associated handlers are valid. * * @return - * Empty array if the display is valid; an array of error strings if it is not. + * Empty array if the display is valid; an array of error strings if it is + * not. */ - function validate() { + public function validate() { $errors = array(); // Make sure displays that use fields HAVE fields. if ($this->uses_fields()) { @@ -2708,7 +2868,7 @@ class views_plugin_display extends views_plugin { $errors[] = t('Display "@display" uses a path but the path is undefined.', array('@display' => $this->display->display_title)); } - // Validate style plugin + // Validate style plugin. $style = $this->get_plugin(); if (empty($style)) { $errors[] = t('Display "@display" has an invalid style plugin.', array('@display' => $this->display->display_title)); @@ -2727,7 +2887,7 @@ class views_plugin_display extends views_plugin { $errors = array_merge($errors, $result); } - // Validate handlers + // Validate handlers. foreach (views_object_types() as $type => $info) { foreach ($this->get_handlers($type) as $handler) { $result = $handler->validate(); @@ -2750,9 +2910,8 @@ class views_plugin_display extends views_plugin { * * @return bool * Returns whether the identifier is unique on all handlers. - * */ - function is_identifier_unique($id, $identifier) { + public function is_identifier_unique($id, $identifier) { foreach (views_object_types() as $type => $info) { foreach ($this->get_handlers($type) as $key => $handler) { if ($handler->can_expose() && $handler->is_exposed()) { @@ -2762,7 +2921,7 @@ class views_plugin_display extends views_plugin { } } else { - if ($id != $key && $identifier == $handler->options['expose']['identifier']) { + if ($id != $key && isset($handler->options['expose']['identifier']) && $identifier == $handler->options['expose']['identifier']) { return FALSE; } } @@ -2775,7 +2934,7 @@ class views_plugin_display extends views_plugin { /** * Provide the block system with any exposed widget blocks for this display. */ - function get_special_blocks() { + public function get_special_blocks() { $blocks = array(); if ($this->uses_exposed_form_in_block()) { @@ -2794,7 +2953,7 @@ class views_plugin_display extends views_plugin { /** * Render any special blocks provided for this display. */ - function view_special_blocks($type) { + public function view_special_blocks($type) { if ($type == '-exp') { // avoid interfering with the admin forms. if (arg(0) == 'admin' && arg(1) == 'structure' && arg(2) == 'views') { @@ -2814,11 +2973,13 @@ class views_plugin_display extends views_plugin { /** * Override of export_option() * - * Because displays do not want to export options that are NOT overridden from the - * default display, we need some special handling during the export process. + * Because displays do not want to export options that are NOT overridden from + * the default display, we need some special handling during the export + * process. */ - function export_option($indent, $prefix, $storage, $option, $definition, $parents) { - // The $prefix is wrong because we store our actual options a little differently: + public function export_option($indent, $prefix, $storage, $option, $definition, $parents) { + // The $prefix is wrong because we store our actual options a little + // differently. $prefix = '$handler->display->display_options'; $output = ''; if (!$parents && !$this->is_default_display()) { @@ -2827,8 +2988,8 @@ class views_plugin_display extends views_plugin { return; } - // If this is not defaulted and is overrideable, flip the switch to say this - // is overridden. + // If this is not defaulted and is overrideable, flip the switch to say + // this is overridden. if ($this->defaultable_sections($option)) { $output .= $indent . $prefix . "['defaults']['$option'] = FALSE;\n"; } @@ -2841,15 +3002,15 @@ class views_plugin_display extends views_plugin { /** * Special method to export items that have handlers. * - * This method was specified in the option_definition() as the method to utilize to - * export fields, filters, sort criteria, relationships and arguments. This passes - * the export off to the individual handlers so that they can export themselves - * properly. + * This method was specified in the option_definition() as the method to + * utilize to export fields, filters, sort criteria, relationships and + * arguments. This passes the export off to the individual handlers so that + * they can export themselves properly. */ - function export_handler($indent, $prefix, $storage, $option, $definition, $parents) { + public function export_handler($indent, $prefix, $storage, $option, $definition, $parents) { $output = ''; - // cut the 's' off because the data is stored as the plural form but we need + // Cut the 's' off because the data is stored as the plural form but we need // the singular form. Who designed that anyway? Oh yeah, I did. :( if ($option != 'header' && $option != 'footer' && $option != 'empty') { $type = substr($option, 0, -1); @@ -2899,7 +3060,7 @@ class views_plugin_display extends views_plugin { * row_options accordingly. The options are told not to export, and the * export for the plugin should export both. */ - function export_style($indent, $prefix, $storage, $option, $definition, $parents) { + public function export_style($indent, $prefix, $storage, $option, $definition, $parents) { $output = ''; $style_plugin = $this->get_plugin(); if ($option == 'style_plugin') { @@ -2938,7 +3099,7 @@ class views_plugin_display extends views_plugin { * array, but for legacy plugins (access and cache) options are stored as * siblings to the type. */ - function export_plugin($indent, $prefix, $storage, $option, $definition, $parents) { + public function export_plugin($indent, $prefix, $storage, $option, $definition, $parents) { $output = ''; $plugin_type = end($parents); $plugin = $this->get_plugin($plugin_type); @@ -2960,7 +3121,10 @@ class views_plugin_display extends views_plugin { return $output; } - function unpack_style($indent, $prefix, $storage, $option, $definition, $parents) { + /** + * + */ + public function unpack_style($indent, $prefix, $storage, $option, $definition, $parents) { $output = ''; $style_plugin = $this->get_plugin(); if ($option == 'style_plugin') { @@ -2987,7 +3151,7 @@ class views_plugin_display extends views_plugin { /** * Special handling for plugin unpacking. */ - function unpack_plugin(&$translatable, $storage, $option, $definition, $parents) { + public function unpack_plugin(&$translatable, $storage, $option, $definition, $parents) { $plugin_type = end($parents); $plugin = $this->get_plugin($plugin_type); if ($plugin) { @@ -2996,18 +3160,18 @@ class views_plugin_display extends views_plugin { } } - /** + /** * Special method to unpack items that have handlers. * - * This method was specified in the option_definition() as the method to utilize to - * export fields, filters, sort criteria, relationships and arguments. This passes - * the export off to the individual handlers so that they can export themselves - * properly. + * This method was specified in the option_definition() as the method to + * utilize to export fields, filters, sort criteria, relationships and + * arguments. This passes the export off to the individual handlers so that + * they can export themselves properly. */ - function unpack_handler(&$translatable, $storage, $option, $definition, $parents) { + public function unpack_handler(&$translatable, $storage, $option, $definition, $parents) { $output = ''; - // cut the 's' off because the data is stored as the plural form but we need + // Cut the 's' off because the data is stored as the plural form but we need // the singular form. Who designed that anyway? Oh yeah, I did. :( if ($option != 'header' && $option != 'footer' && $option != 'empty') { $type = substr($option, 0, -1); @@ -3038,6 +3202,7 @@ class views_plugin_display extends views_plugin { /** * Provide some helpful text for the arguments. + * * The result should contain of an array with * - filter value present: The title of the fieldset in the argument * where you can configure what should be done with a given argument. @@ -3047,7 +3212,7 @@ class views_plugin_display extends views_plugin { * - description: A description about how arguments comes to the display. * For example blocks don't get it from url. */ - function get_argument_text() { + public function get_argument_text() { return array( 'filter value not present' => t('When the filter value is NOT available'), 'filter value present' => t('When the filter value IS available or a default is provided'), @@ -3061,14 +3226,14 @@ class views_plugin_display extends views_plugin { * The result should contain of an array within * - items per page title */ - function get_pager_text() { + public function get_pager_text() { return array( 'items per page title' => t('Items to display'), 'items per page description' => t('The number of items to display. Enter 0 for no limit.') ); } -} +} /** * @} diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_display_attachment.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_display_attachment.inc index 91c8d1f..c80771a 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_display_attachment.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_display_attachment.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the attachment display plugin. + * Definition of views_plugin_display_attachment. */ /** @@ -15,7 +15,11 @@ * @ingroup views_display_plugins */ class views_plugin_display_attachment extends views_plugin_display { - function option_definition () { + + /** + * {@inheritdoc} + */ + public function option_definition () { $options = parent::option_definition(); $options['displays'] = array('default' => array()); @@ -28,11 +32,17 @@ class views_plugin_display_attachment extends views_plugin_display { return $options; } - function execute() { + /** + * {@inheritdoc} + */ + public function execute() { return $this->view->render($this->display->id); } - function attachment_positions($position = NULL) { + /** + * {@inheritdoc} + */ + public function attachment_positions($position = NULL) { $positions = array( 'before' => t('Before'), 'after' => t('After'), @@ -51,8 +61,8 @@ class views_plugin_display_attachment extends views_plugin_display { * * This output is returned as an array. */ - function options_summary(&$categories, &$options) { - // It is very important to call the parent function here: + public function options_summary(&$categories, &$options) { + // It is very important to call the parent function here. parent::options_summary($categories, $options); $categories['attachment'] = array( @@ -119,8 +129,8 @@ class views_plugin_display_attachment extends views_plugin_display { /** * Provide the default form for setting options. */ - function options_form(&$form, &$form_state) { - // It is very important to call the parent function here: + public function options_form(&$form, &$form_state) { + // It is very important to call the parent function here. parent::options_form($form, $form_state); switch ($form_state['section']) { @@ -133,6 +143,7 @@ class views_plugin_display_attachment extends views_plugin_display { '#default_value' => $this->get_option('inherit_arguments'), ); break; + case 'inherit_exposed_filters': $form['#title'] .= t('Inherit exposed filters'); $form['inherit_exposed_filters'] = array( @@ -142,6 +153,7 @@ class views_plugin_display_attachment extends views_plugin_display { '#default_value' => $this->get_option('inherit_exposed_filters'), ); break; + case 'inherit_pager': $form['#title'] .= t('Inherit pager'); $form['inherit_pager'] = array( @@ -151,6 +163,7 @@ class views_plugin_display_attachment extends views_plugin_display { '#default_value' => $this->get_option('inherit_pager'), ); break; + case 'render_pager': $form['#title'] .= t('Render pager'); $form['render_pager'] = array( @@ -160,6 +173,7 @@ class views_plugin_display_attachment extends views_plugin_display { '#default_value' => $this->get_option('render_pager'), ); break; + case 'attachment_position': $form['#title'] .= t('Position'); $form['attachment_position'] = array( @@ -169,6 +183,7 @@ class views_plugin_display_attachment extends views_plugin_display { '#default_value' => $this->get_option('attachment_position'), ); break; + case 'displays': $form['#title'] .= t('Attach to'); $displays = array(); @@ -191,8 +206,8 @@ class views_plugin_display_attachment extends views_plugin_display { * Perform any necessary changes to the form values prior to storage. * There is no need for this function to actually store the data. */ - function options_submit(&$form, &$form_state) { - // It is very important to call the parent function here: + public function options_submit(&$form, &$form_state) { + // It is very important to call the parent function here. parent::options_submit($form, $form_state); switch ($form_state['section']) { case 'inherit_arguments': @@ -209,7 +224,7 @@ class views_plugin_display_attachment extends views_plugin_display { /** * Attach to another view. */ - function attach_to($display_id) { + public function attach_to($display_id) { $displays = $this->get_option('displays'); if (empty($displays[$display_id])) { @@ -220,13 +235,15 @@ class views_plugin_display_attachment extends views_plugin_display { return; } - // Get a fresh view because our current one has a lot of stuff on it because it's - // already been executed. + // Get a fresh view because our current one has a lot of stuff on it + // because it's already been executed. $view = $this->view->clone_view(); $view->original_args = $view->args; $args = $this->get_option('inherit_arguments') ? $this->view->args : array(); $view->set_arguments($args); + $exposed_input = $this->get_option('inherit_exposed_filters') ? $this->view->exposed_input : array(); + $view->set_exposed_input($exposed_input); $view->set_display($this->display->id); if ($this->get_option('inherit_pager')) { $view->display_handler->use_pager = $this->view->display[$display_id]->handler->use_pager(); @@ -239,9 +256,11 @@ class views_plugin_display_attachment extends views_plugin_display { case 'before': $this->view->attachment_before .= $attachment; break; + case 'after': $this->view->attachment_after .= $attachment; break; + case 'both': $this->view->attachment_before .= $attachment; $this->view->attachment_after .= $attachment; @@ -252,11 +271,10 @@ class views_plugin_display_attachment extends views_plugin_display { } /** - * Attachment displays only use exposed widgets if - * they are set to inherit the exposed filter settings - * of their parent display. + * Attachment displays only use exposed widgets if they are set to inherit + * the exposed filter settings of their parent display. */ - function uses_exposed() { + public function uses_exposed() { if (!empty($this->options['inherit_exposed_filters']) && parent::uses_exposed()) { return TRUE; } @@ -264,19 +282,26 @@ class views_plugin_display_attachment extends views_plugin_display { } /** - * If an attachment is set to inherit the exposed filter - * settings from its parent display, then don't render and - * display a second set of exposed filter widgets. + * If an attachment is set to inherit the exposed filter settings from its + * parent display, then don't render and display a second set of exposed + * filter widgets. */ - function displays_exposed() { + public function displays_exposed() { return $this->options['inherit_exposed_filters'] ? FALSE : TRUE; } - function use_pager() { + /** + * {@inheritdoc} + */ + public function use_pager() { return !empty($this->use_pager); } - function render_pager() { + /** + * {@inheritdoc} + */ + public function render_pager() { return !empty($this->use_pager) && $this->get_option('render_pager'); } + } diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_display_block.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_display_block.inc index c903a9b..9fc0111 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_display_block.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_display_block.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the block display plugin. + * Definition of views_plugin_display_block. */ /** @@ -11,7 +11,11 @@ * @ingroup views_display_plugins */ class views_plugin_display_block extends views_plugin_display { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['block_description'] = array('default' => '', 'translatable' => TRUE); @@ -25,7 +29,7 @@ class views_plugin_display_block extends views_plugin_display { * but extended block handlers might be able to do interesting * stuff with it. */ - function execute_hook_block_list($delta = 0, $edit = array()) { + public function execute_hook_block_list($delta = 0, $edit = array()) { $delta = $this->view->name . '-' . $this->display->id; $desc = $this->get_option('block_description'); @@ -40,7 +44,7 @@ class views_plugin_display_block extends views_plugin_display { return array( $delta => array( 'info' => $desc, - 'cache' => $this->get_cache_type() + 'cache' => $this->get_cache_type(), ), ); } @@ -48,11 +52,12 @@ class views_plugin_display_block extends views_plugin_display { /** * The display block handler returns the structure necessary for a block. */ - function execute() { + public function execute() { // Prior to this being called, the $view should already be set to this // display, and arguments should be set on the view. $info['content'] = $this->view->render(); - $info['subject'] = filter_xss_admin($this->view->get_title()); + $title = $this->view->get_title(); + $info['subject'] = ($title == '') ? '' : filter_xss_admin($title); if (!empty($this->view->result) || $this->get_option('empty') || !empty($this->view->style_plugin->definition['even empty'])) { return $info; } @@ -63,8 +68,8 @@ class views_plugin_display_block extends views_plugin_display { * * This output is returned as an array. */ - function options_summary(&$categories, &$options) { - // It is very important to call the parent function here: + public function options_summary(&$categories, &$options) { + // It is very important to call the parent function here. parent::options_summary($categories, $options); $categories['block'] = array( @@ -97,7 +102,7 @@ class views_plugin_display_block extends views_plugin_display { /** * Provide a list of core's block caching modes. */ - function block_caching_modes() { + public function block_caching_modes() { return array( DRUPAL_NO_CACHE => t('Do not cache'), DRUPAL_CACHE_GLOBAL => t('Cache once for everything (global)'), @@ -113,7 +118,7 @@ class views_plugin_display_block extends views_plugin_display { * Provide a single method to figure caching type, keeping a sensible default * for when it's unset. */ - function get_cache_type() { + public function get_cache_type() { $cache_type = $this->get_option('block_caching'); if (empty($cache_type)) { $cache_type = DRUPAL_NO_CACHE; @@ -124,8 +129,8 @@ class views_plugin_display_block extends views_plugin_display { /** * Provide the default form for setting options. */ - function options_form(&$form, &$form_state) { - // It is very important to call the parent function here: + public function options_form(&$form, &$form_state) { + // It is very important to call the parent function here. parent::options_form($form, $form_state); switch ($form_state['section']) { @@ -137,6 +142,7 @@ class views_plugin_display_block extends views_plugin_display { '#default_value' => $this->get_option('block_description'), ); break; + case 'block_caching': $form['#title'] .= t('Block caching type'); @@ -147,6 +153,7 @@ class views_plugin_display_block extends views_plugin_display { '#default_value' => $this->get_cache_type(), ); break; + case 'exposed_form_options': $this->view->init_handlers(); if (!$this->uses_exposed() && parent::uses_exposed()) { @@ -155,6 +162,7 @@ class views_plugin_display_block extends views_plugin_display { '#markup' => '
' . t('Exposed filters in block displays require "Use AJAX" to be set to work correctly.') . '
', ); } + break; } } @@ -162,19 +170,21 @@ class views_plugin_display_block extends views_plugin_display { * Perform any necessary changes to the form values prior to storage. * There is no need for this function to actually store the data. */ - function options_submit(&$form, &$form_state) { - // It is very important to call the parent function here: + public function options_submit(&$form, &$form_state) { + // It is very important to call the parent function here. parent::options_submit($form, $form_state); switch ($form_state['section']) { case 'display_id': $this->update_block_bid($form_state['view']->name, $this->display->id, $this->display->new_id); break; + case 'block_description': $this->set_option('block_description', $form_state['values']['block_description']); break; + case 'block_caching': $this->set_option('block_caching', $form_state['values']['block_caching']); - $this->save_block_cache($form_state['view']->name . '-'. $form_state['display_id'], $form_state['values']['block_caching']); + $this->save_block_cache($form_state['view']->name . '-' . $form_state['display_id'], $form_state['values']['block_caching']); break; } } @@ -182,17 +192,17 @@ class views_plugin_display_block extends views_plugin_display { /** * Block views use exposed widgets only if AJAX is set. */ - function uses_exposed() { - if ($this->use_ajax()) { - return parent::uses_exposed(); - } - return FALSE; + public function uses_exposed() { + if ($this->use_ajax()) { + return parent::uses_exposed(); } + return FALSE; + } /** - * Update the block delta when you change the machine readable name of the display. + * Update the block delta when the machine name of the display changes. */ - function update_block_bid($name, $old_delta, $delta) { + public function update_block_bid($name, $old_delta, $delta) { $old_hashes = $hashes = variable_get('views_block_hashes', array()); $old_delta = $name . '-' . $old_delta; @@ -222,22 +232,23 @@ class views_plugin_display_block extends views_plugin_display { } /** - * Save the block cache setting in the blocks table if this block allready - * exists in the blocks table. Dirty fix untill http://drupal.org/node/235673 gets in. + * Save the block cache setting in the blocks table if this block already + * exists in the blocks table. Dirty fix until http://drupal.org/node/235673 + * gets in. */ - function save_block_cache($delta, $cache_setting) { + public function save_block_cache($delta, $cache_setting) { if (strlen($delta) >= 32) { $delta = md5($delta); } - if (db_table_exists('block') && $bid = db_query("SELECT bid FROM {block} WHERE module = 'views' AND delta = :delta", array( - ':delta' => $delta))->fetchField()) { + if (db_table_exists('block') && $bid = db_query("SELECT bid FROM {block} WHERE module = 'views' AND delta = :delta", array(':delta' => $delta))->fetchField()) { db_update('block') ->fields(array( - 'cache' => $cache_setting, + 'cache' => $cache_setting, )) - ->condition('module','views') + ->condition('module', 'views') ->condition('delta', $delta) ->execute(); } } + } diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_display_default.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_display_default.inc index 4b1fc08..9531013 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_display_default.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_display_default.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the default display plugin. + * Definition of views_plugin_display_default. */ /** @@ -11,11 +11,14 @@ * @ingroup views_display_plugins */ class views_plugin_display_default extends views_plugin_display { + /** * Determine if this display is the 'default' display which contains - * fallback settings + * fallback settings. */ - function is_default_display() { return TRUE; } + public function is_default_display() { + return TRUE; + } /** * The default execute handler fully renders the view. @@ -26,32 +29,34 @@ class views_plugin_display_default extends views_plugin_display { * @endcode * * For more complex usages, a view can be partially built: + * * @code * $view->set_arguments($args); - * $view->build('default'); // Build the query + * $view->build('default'); // Build the query. * $view->pre_execute(); // Pre-execute the query. - * $view->execute(); // Run the query - * $output = $view->render(); // Render the view + * $view->execute(); // Run the query. + * $output = $view->render(); // Render the view. * @endcode * - * If short circuited at any point, look in $view->build_info for - * information about the query. After execute, look in $view->result - * for the array of objects returned from db_query. + * If short circuited at any point, look in $view->build_info for information + * about the query. After execute, look in $view->result for the array of + * objects returned from db_query. * * You can also do: + * * @code * $view->set_arguments($args); - * $output = $view->render('default'); // Render the view + * $output = $view->render('default'); // Render the view. * @endcode * - * This illustrates that render is smart enough to call build and execute - * if these items have not already been accomplished. + * This illustrates that render is smart enough to call build and execute if + * these items have not already been accomplished. * - * Note that execute also must accomplish other tasks, such - * as setting page titles, breadcrumbs, and generating exposed filter - * data if necessary. + * Note that execute also must accomplish other tasks, such as setting page + * titles, breadcrumbs, and generating exposed filter data if necessary. */ - function execute() { + public function execute() { return $this->view->render($this->display->id); } + } diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_display_embed.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_display_embed.inc index 8b25cf9..65cc6ca 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_display_embed.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_display_embed.inc @@ -1,7 +1,8 @@ view = $view; $this->display = $display; } + /** + * Provide a form to edit options for this plugin. + */ + public function options_definition_alter(&$options) { + } /** * Provide a form to edit options for this plugin. */ - function options_definition_alter(&$options) { } - - /** - * Provide a form to edit options for this plugin. - */ - function options_form(&$form, &$form_state) { } + public function options_form(&$form, &$form_state) { + } /** * Validate the options form. */ - function options_validate(&$form, &$form_state) { } + public function options_validate(&$form, &$form_state) { + } /** * Handle any special handling on the validate form. */ - function options_submit(&$form, &$form_state) { } + public function options_submit(&$form, &$form_state) { + } /** * Set up any variables on the view prior to execution. */ - function pre_execute() { } + public function pre_execute() { + } /** * Inject anything into the query that the display_extender handler needs. */ - function query() { } + public function query() { + } /** * Provide the default summary for options in the views UI. * * This output is returned as an array. */ - function options_summary(&$categories, &$options) { } + public function options_summary(&$categories, &$options) { + } /** * Static member function to list which sections are defaultable * and what items each section contains. */ - function defaultable_sections(&$sections, $section = NULL) { } + public function defaultable_sections(&$sections, $section = NULL) { + } + } diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_display_feed.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_display_feed.inc index 5eb68e3..a3c2333 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_display_feed.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_display_feed.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the feed display plugin. + * Definition of views_plugin_display_feed. */ /** @@ -13,7 +13,11 @@ * @ingroup views_display_plugins */ class views_plugin_display_feed extends views_plugin_display_page { - function init(&$view, &$display, $options = NULL) { + + /** + * {@inheritdoc} + */ + public function init(&$view, &$display, $options = NULL) { parent::init($view, $display, $options); // Set the default row style. Ideally this would be part of the option @@ -26,23 +30,40 @@ class views_plugin_display_feed extends views_plugin_display_page { } } - function uses_breadcrumb() { return FALSE; } - function get_style_type() { return 'feed'; } + /** + * {@inheritdoc} + */ + public function uses_breadcrumb() { + return FALSE; + } + + /** + * {@inheritdoc} + */ + public function get_style_type() { + return 'feed'; + } /** * Feeds do not go through the normal page theming mechanism. Instead, they * go through their own little theme function and then return NULL so that * Drupal believes that the page has already rendered itself...which it has. */ - function execute() { + public function execute() { $output = $this->view->render(); + if (!empty($this->view->build_info['denied'])) { + return MENU_ACCESS_DENIED; + } if (empty($output)) { return MENU_NOT_FOUND; } print $output; } - function preview() { + /** + * {@inheritdoc} + */ + public function preview() { if (!empty($this->view->live_preview)) { return '
' . check_plain($this->view->render()) . '
'; } @@ -53,11 +74,14 @@ class views_plugin_display_feed extends views_plugin_display_page { * Instead of going through the standard views_view.tpl.php, delegate this * to the style handler. */ - function render() { + public function render() { return $this->view->style_plugin->render($this->view->result); } - function defaultable_sections($section = NULL) { + /** + * {@inheritdoc} + */ + public function defaultable_sections($section = NULL) { if (in_array($section, array('style_options', 'style_plugin', 'row_options', 'row_plugin',))) { return FALSE; } @@ -74,12 +98,15 @@ class views_plugin_display_feed extends views_plugin_display_page { return $sections; } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['displays'] = array('default' => array()); - // Overrides for standard stuff: + // Overrides for standard stuff. $options['style_plugin']['default'] = 'rss'; $options['style_options']['default'] = array('description' => ''); $options['sitename_title']['default'] = FALSE; @@ -92,8 +119,11 @@ class views_plugin_display_feed extends views_plugin_display_page { return $options; } - function options_summary(&$categories, &$options) { - // It is very important to call the parent function here: + /** + * {@inheritdoc} + */ + public function options_summary(&$categories, &$options) { + // It is very important to call the parent function here. parent::options_summary($categories, $options); // Since we're childing off the 'page' type, we'll still *call* our @@ -138,7 +168,7 @@ class views_plugin_display_feed extends views_plugin_display_page { /** * Provide the default form for setting options. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { // It is very important to call the parent function here. parent::options_form($form, $form_state); @@ -155,6 +185,7 @@ class views_plugin_display_feed extends views_plugin_display_page { $form['title'] = $title; $form['title']['#dependency'] = array('edit-sitename-title' => array(FALSE)); break; + case 'displays': $form['#title'] .= t('Attach to'); $displays = array(); @@ -170,8 +201,10 @@ class views_plugin_display_feed extends views_plugin_display_page { '#default_value' => $this->get_option('displays'), ); break; + case 'path': $form['path']['#description'] = t('This view will be displayed by visiting this path on your site. It is recommended that the path be something like "path/%/%/feed" or "path/%/%/rss.xml", putting one % in the path for each contextual filter you have defined in the view.'); + break; } } @@ -179,13 +212,14 @@ class views_plugin_display_feed extends views_plugin_display_page { * Perform any necessary changes to the form values prior to storage. * There is no need for this function to actually store the data. */ - function options_submit(&$form, &$form_state) { - // It is very important to call the parent function here: + public function options_submit(&$form, &$form_state) { + // It is very important to call the parent function here. parent::options_submit($form, $form_state); switch ($form_state['section']) { case 'title': $this->set_option('sitename_title', $form_state['values']['sitename_title']); break; + case 'displays': $this->set_option($form_state['section'], $form_state['values'][$form_state['section']]); break; @@ -195,7 +229,7 @@ class views_plugin_display_feed extends views_plugin_display_page { /** * Attach to another view. */ - function attach_to($display_id) { + public function attach_to($display_id) { $displays = $this->get_option('displays'); if (empty($displays[$display_id])) { return; @@ -216,7 +250,11 @@ class views_plugin_display_feed extends views_plugin_display_page { } } - function uses_link_display() { + /** + * {@inheritdoc} + */ + public function uses_link_display() { return TRUE; } + } diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_display_page.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_display_page.inc index 4bcec0b..e2cc017 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_display_page.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_display_page.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the page display plugin. + * Definition of views_plugin_display_page. */ /** @@ -11,13 +11,25 @@ * @ingroup views_display_plugins */ class views_plugin_display_page extends views_plugin_display { + /** * The page display has a path. */ - function has_path() { return TRUE; } - function uses_breadcrumb() { return TRUE; } + public function has_path() { + return TRUE; + } - function option_definition() { + /** + * {@inheritdoc} + */ + public function uses_breadcrumb() { + return TRUE; + } + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['path'] = array('default' => ''); @@ -50,7 +62,7 @@ class views_plugin_display_page extends views_plugin_display { /** * Add this display's path information to Drupal's menu system. */ - function execute_hook_menu($callbacks) { + public function execute_hook_menu($callbacks) { $items = array(); // Replace % with the link to our standard views argument loader // views_arg_load -- which lives in views.module @@ -79,7 +91,8 @@ class views_plugin_display_page extends views_plugin_display { $access_plugin = views_get_plugin('access', 'none'); } - // Get access callback might return an array of the callback + the dynamic arguments. + // Get access callback might return an array of the callback + the dynamic + // arguments. $access_plugin_callback = $access_plugin->get_access_callback(); if (is_array($access_plugin_callback)) { @@ -118,6 +131,8 @@ class views_plugin_display_page extends views_plugin_display { 'access arguments' => $access_arguments, // Identify URL embedded arguments and correlate them to a handler 'load arguments' => array($this->view->name, $this->display->id, '%index'), + // Make sure the menu router knows where views_page is. + 'module' => 'views', ); $menu = $this->get_option('menu'); if (empty($menu)) { @@ -138,14 +153,17 @@ class views_plugin_display_page extends views_plugin_display { default: $items[$path]['type'] = MENU_CALLBACK; break; + case 'normal': $items[$path]['type'] = MENU_NORMAL_ITEM; // Insert item into the proper menu $items[$path]['menu_name'] = $menu['name']; break; + case 'tab': $items[$path]['type'] = MENU_LOCAL_TASK; break; + case 'default tab': $items[$path]['type'] = MENU_DEFAULT_LOCAL_TASK; break; @@ -167,7 +185,7 @@ class views_plugin_display_page extends views_plugin_display { $bit = array_pop($bits); // we can't do this if they tried to make the last path bit variable. - // @todo: We can validate this. + // @todo We can validate this. if ($bit != '%views_arg' && !empty($bits)) { $default_path = implode('/', $bits); $items[$default_path] = array( @@ -182,12 +200,15 @@ class views_plugin_display_page extends views_plugin_display { 'title' => $tab_options['title'], 'description' => $tab_options['description'], 'menu_name' => $tab_options['name'], + // Make sure the menu router knows where views_page is. + 'module' => 'views', ); switch ($tab_options['type']) { default: case 'normal': $items[$default_path]['type'] = MENU_NORMAL_ITEM; break; + case 'tab': $items[$default_path]['type'] = MENU_LOCAL_TASK; break; @@ -208,7 +229,7 @@ class views_plugin_display_page extends views_plugin_display { * a drupal_set_title for the page, and does a views_set_page_view * on the view. */ - function execute() { + public function execute() { // Let the world know that this is the page view we're using. views_set_page_view($this->view); @@ -231,7 +252,13 @@ class views_plugin_display_page extends views_plugin_display { // First execute the view so it's possible to get tokens for the title. // And the title, which is much easier. - drupal_set_title(filter_xss_admin($this->view->get_title()), PASS_THROUGH); + $title = $this->view->get_title(); + // Support the core method of using '' to indicate nothing should be + // assigned to the title, so only process the title value if it is not that + // value. + if ($title != '') { + drupal_set_title(filter_xss_admin($title), PASS_THROUGH); + } return $render; } @@ -240,8 +267,8 @@ class views_plugin_display_page extends views_plugin_display { * * This output is returned as an array. */ - function options_summary(&$categories, &$options) { - // It is very important to call the parent function here: + public function options_summary(&$categories, &$options) { + // It is very important to call the parent function here. parent::options_summary($categories, $options); $categories['page'] = array( @@ -263,21 +290,23 @@ class views_plugin_display_page extends views_plugin_display { $options['path'] = array( 'category' => 'page', 'title' => t('Path'), - 'value' => views_ui_truncate($path, 24), + 'value' => $path, ); $menu = $this->get_option('menu'); if (!is_array($menu)) { $menu = array('type' => 'none'); } - switch($menu['type']) { + switch ($menu['type']) { case 'none': default: $menu_str = t('No menu'); break; + case 'normal': $menu_str = t('Normal: @title', array('@title' => $menu['title'])); break; + case 'tab': case 'default tab': $menu_str = t('Tab: @title', array('@title' => $menu['title'])); @@ -290,7 +319,8 @@ class views_plugin_display_page extends views_plugin_display { 'value' => views_ui_truncate($menu_str, 24), ); - // This adds a 'Settings' link to the style_options setting if the style has options. + // This adds a 'Settings' link to the style_options setting if the style + // has options. if ($menu['type'] == 'default tab') { $options['menu']['setting'] = t('Parent menu item'); $options['menu']['links']['tab_options'] = t('Change settings for the parent menu'); @@ -300,8 +330,8 @@ class views_plugin_display_page extends views_plugin_display { /** * Provide the default form for setting options. */ - function options_form(&$form, &$form_state) { - // It is very important to call the parent function here: + public function options_form(&$form, &$form_state) { + // It is very important to call the parent function here. parent::options_form($form, $form_state); switch ($form_state['section']) { @@ -312,11 +342,12 @@ class views_plugin_display_page extends views_plugin_display { '#type' => 'textfield', '#description' => t('This view will be displayed by visiting this path on your site. You may use "%" in your URL to represent values that will be used for contextual filters: For example, "node/%/feed".'), '#default_value' => $this->get_option('path'), - '#field_prefix' => '' . url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='), - '#field_suffix' => '‎', - '#attributes' => array('dir'=>'ltr'), + '#field_prefix' => '' . url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='), + '#field_suffix' => '‎', + '#attributes' => array('dir'=>'ltr'), ); break; + case 'menu': $form['#title'] .= t('Menu item entry'); $form['#help_topic'] = 'menu'; @@ -405,6 +436,7 @@ class views_plugin_display_page extends views_plugin_display { '#dependency_count' => 2, ); break; + case 'tab_options': $form['#title'] .= t('Default tab options'); $tab_options = $this->get_option('tab_options'); @@ -477,8 +509,11 @@ class views_plugin_display_page extends views_plugin_display { } } - function options_validate(&$form, &$form_state) { - // It is very important to call the parent function here: + /** + * {@inheritdoc} + */ + public function options_validate(&$form, &$form_state) { + // It is very important to call the parent function here. parent::options_validate($form, $form_state); switch ($form_state['section']) { case 'path': @@ -490,9 +525,10 @@ class views_plugin_display_page extends views_plugin_display { form_error($form['path'], t('"%" may not be used for the first segment of a path.')); } - // automatically remove '/' and trailing whitespace from path. + // Automatically remove '/' and trailing whitespace from path. $form_state['values']['path'] = trim($form_state['values']['path'], '/ '); break; + case 'menu': $path = $this->get_option('path'); if ($form_state['values']['menu']['type'] == 'normal' && strpos($path, '%') !== FALSE) { @@ -514,27 +550,35 @@ class views_plugin_display_page extends views_plugin_display { } } - function options_submit(&$form, &$form_state) { - // It is very important to call the parent function here: + /** + * {@inheritdoc} + */ + public function options_submit(&$form, &$form_state) { + // It is very important to call the parent function here. parent::options_submit($form, $form_state); switch ($form_state['section']) { case 'path': $this->set_option('path', $form_state['values']['path']); break; + case 'menu': $this->set_option('menu', $form_state['values']['menu']); - // send ajax form to options page if we use it. + // Send ajax form to options page if we use it. if ($form_state['values']['menu']['type'] == 'default tab') { views_ui_add_form_to_stack('display', $this->view, $this->display->id, array('tab_options')); } break; + case 'tab_options': $this->set_option('tab_options', $form_state['values']['tab_options']); break; } } - function validate() { + /** + * {@inheritdoc} + */ + public function validate() { $errors = parent::validate(); $menu = $this->get_option('menu'); @@ -552,7 +596,10 @@ class views_plugin_display_page extends views_plugin_display { return $errors; } - function get_argument_text() { + /** + * {@inheritdoc} + */ + public function get_argument_text() { return array( 'filter value not present' => t('When the filter value is NOT in the URL'), 'filter value present' => t('When the filter value IS in the URL or a default is provided'), @@ -560,10 +607,14 @@ class views_plugin_display_page extends views_plugin_display { ); } - function get_pager_text() { + /** + * {@inheritdoc} + */ + public function get_pager_text() { return array( 'items per page title' => t('Items per page'), - 'items per page description' => t('The number of items to display per page. Enter 0 for no limit.') + 'items per page description' => t('The number of items to display per page. Enter 0 for no limit.'), ); } + } diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_exposed_form.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_exposed_form.inc index 5d54600..2bba730 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_exposed_form.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_exposed_form.inc @@ -23,19 +23,24 @@ class views_plugin_exposed_form extends views_plugin { /** * Initialize the plugin. * - * @param $view + * @param object $view * The view object. - * @param $display + * @param object $display * The display handler. + * @param array $options + * Any additional options that are being added. */ - function init(&$view, &$display, $options = array()) { + public function init(&$view, &$display, $options = array()) { $this->view = &$view; $this->display = &$display; $this->unpack_options($this->options, $options); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['submit_button'] = array('default' => 'Apply', 'translatable' => TRUE); $options['reset_button'] = array('default' => FALSE, 'bool' => TRUE); @@ -49,7 +54,10 @@ class views_plugin_exposed_form extends views_plugin { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['submit_button'] = array( '#type' => 'textfield', @@ -135,7 +143,7 @@ class views_plugin_exposed_form extends views_plugin { * also assign data to the appropriate handlers for use in building the * query. */ - function render_exposed_form($block = FALSE) { + public function render_exposed_form($block = FALSE) { // Deal with any exposed filters we may have, before building. $form_state = array( 'view' => &$this->view, @@ -169,7 +177,10 @@ class views_plugin_exposed_form extends views_plugin { } } - function query() { + /** + * {@inheritdoc} + */ + public function query() { $view = $this->view; $exposed_data = isset($view->exposed_data) ? $view->exposed_data : array(); $sort_by = isset($exposed_data['sort_by']) ? $exposed_data['sort_by'] : NULL; @@ -182,7 +193,7 @@ class views_plugin_exposed_form extends views_plugin { if (!$sort->is_exposed()) { $sort->query(); } - else if ($key == $sort_by) { + elseif ($key == $sort_by) { if (isset($exposed_data['sort_order']) && in_array($exposed_data['sort_order'], array('ASC', 'DESC'))) { $sort->options['order'] = $exposed_data['sort_order']; } @@ -194,15 +205,34 @@ class views_plugin_exposed_form extends views_plugin { } } - function pre_render($values) { } + /** + * {@inheritdoc} + */ + public function pre_render($values) { + } - function post_render(&$output) { } + /** + * {@inheritdoc} + */ + public function post_render(&$output) { + } - function pre_execute() { } + /** + * {@inheritdoc} + */ + public function pre_execute() { + } - function post_execute() { } + /** + * {@inheritdoc} + */ + public function post_execute() { + } - function exposed_form_alter(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function exposed_form_alter(&$form, &$form_state) { if (!empty($this->options['reset_button'])) { $form['reset'] = array( '#value' => $this->options['reset_button_label'], @@ -231,7 +261,8 @@ class views_plugin_exposed_form extends views_plugin { ); if (isset($form_state['input']['sort_by']) && isset($this->view->sort[$form_state['input']['sort_by']])) { $default_sort_order = $this->view->sort[$form_state['input']['sort_by']]->options['order']; - } else { + } + else { $first_sort = reset($this->view->sort); $default_sort_order = $first_sort->options['order']; } @@ -275,7 +306,10 @@ class views_plugin_exposed_form extends views_plugin { } } - function exposed_form_validate(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function exposed_form_validate(&$form, &$form_state) { if (isset($form_state['pager_plugin'])) { $form_state['pager_plugin']->exposed_form_validate($form, $form_state); } @@ -284,15 +318,14 @@ class views_plugin_exposed_form extends views_plugin { /** * This function is executed when exposed form is submited. * - * @param $form + * @param array $form * Nested array of form elements that comprise the form. - * @param $form_state + * @param array $form_state * A keyed array containing the current state of the form. - * @param $exclude - * Nested array of keys to exclude of insert into - * $view->exposed_raw_input + * @param array $exclude + * Nested array of keys to exclude of insert into $view->exposed_raw_input. */ - function exposed_form_submit(&$form, &$form_state, &$exclude) { + public function exposed_form_submit(&$form, &$form_state, &$exclude) { if (!empty($form_state['values']['op']) && $form_state['values']['op'] == $this->options['reset_button_label']) { $this->reset_form($form, $form_state); } @@ -302,7 +335,10 @@ class views_plugin_exposed_form extends views_plugin { } } - function reset_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function reset_form(&$form, &$form_state) { // _SESSION is not defined for users who are not logged in. // If filters are not overridden, store the 'remember' settings on the @@ -327,6 +363,7 @@ class views_plugin_exposed_form extends views_plugin { $form_state['redirect'] = current_path(); $form_state['values'] = array(); } + } /** diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_exposed_form_basic.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_exposed_form_basic.inc index 73ae54a..2bf8162 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_exposed_form_basic.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_exposed_form_basic.inc @@ -10,4 +10,6 @@ * * @ingroup views_exposed_form_plugins */ -class views_plugin_exposed_form_basic extends views_plugin_exposed_form { } +class views_plugin_exposed_form_basic extends views_plugin_exposed_form { + // Nothing to see here. +} diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_exposed_form_input_required.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_exposed_form_input_required.inc index ca97674..93a3bc3 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_exposed_form_input_required.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_exposed_form_input_required.inc @@ -12,7 +12,10 @@ */ class views_plugin_exposed_form_input_required extends views_plugin_exposed_form { - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['text_input_required'] = array('default' => 'Select any filter and click on Apply to see results', 'translatable' => TRUE); @@ -20,7 +23,10 @@ class views_plugin_exposed_form_input_required extends views_plugin_exposed_form return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['text_input_required'] = array( @@ -33,13 +39,19 @@ class views_plugin_exposed_form_input_required extends views_plugin_exposed_form ); } - function options_submit(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_submit(&$form, &$form_state) { $form_state['values']['exposed_form_options']['text_input_required_format'] = $form_state['values']['exposed_form_options']['text_input_required']['format']; $form_state['values']['exposed_form_options']['text_input_required'] = $form_state['values']['exposed_form_options']['text_input_required']['value']; parent::options_submit($form, $form_state); } - function exposed_filter_applied() { + /** + * {@inheritdoc} + */ + public function exposed_filter_applied() { static $cache = NULL; if (!isset($cache)) { $view = $this->view; @@ -60,7 +72,10 @@ class views_plugin_exposed_form_input_required extends views_plugin_exposed_form return $cache; } - function pre_render($values) { + /** + * {@inheritdoc} + */ + public function pre_render($values) { if (!$this->exposed_filter_applied()) { $options = array( 'id' => 'area', @@ -82,7 +97,10 @@ class views_plugin_exposed_form_input_required extends views_plugin_exposed_form } } - function query() { + /** + * {@inheritdoc} + */ + public function query() { if (!$this->exposed_filter_applied()) { // We return with no query; this will force the empty text. $this->view->built = TRUE; diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_localization.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_localization.inc index 08caf9e..f572a8d 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_localization.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_localization.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the base class for views localization plugins. + * Definition of views_plugin_localization. */ /** @@ -17,22 +17,29 @@ * The base plugin to handle localization of Views strings. */ class views_plugin_localization extends views_plugin { - // Store for exported strings - var $export_strings = array(); - var $translate = TRUE; + + /** + * Store for exported strings. + */ + public $export_strings = array(); + + /** + * + */ + public $translate = TRUE; /** * Initialize the plugin. * - * @param $view + * @param view $view * The view object. */ - function init(&$view) { + public function init(&$view) { $this->view = &$view; } /** - * Translate a string / text with format + * Translate a string / text with format. * * The $source parameter is an array with the following elements: * - value, source string @@ -40,14 +47,15 @@ class views_plugin_localization extends views_plugin { * - keys. An array of keys to identify the string. Generally constructed from * view name, display_id, and a property, e.g., 'header'. * - * @param $source + * @param string $source * Full data for the string to be translated. * * @return string - * Translated string / text + * Translated string / text. */ - function translate($source) { - // Allow other modules to make changes to the string before and after translation + public function translate($source) { + // Allow other modules to make changes to the string before and after + // translation. $source['pre_process'] = $this->invoke_translation_process($source, 'pre'); $source['translation'] = $this->translate_string($source['value'], $source['keys'], $source['format']); $source['post_process'] = $this->invoke_translation_process($source, 'post'); @@ -57,64 +65,67 @@ class views_plugin_localization extends views_plugin { /** * Translate a string. * - * @param $string + * @param string $string * The string to be translated. - * @param $keys + * @param array $keys * An array of keys to identify the string. Generally constructed from - * view name, display_id, and a property, e.g., 'header'. - * @param $format + * view name, display_id, and a property, e.g. 'header'. + * @param string $format * The input format of the string. This is optional. */ - function translate_string($string, $keys = array(), $format = '') {} + public function translate_string($string, $keys = array(), $format = '') {} /** * Save string source for translation. * - * @param $source + * @param string $source * Full data for the string to be translated. */ - function save($source) { - // Allow other modules to make changes to the string before saving + public function save($source) { + // Allow other modules to make changes to the string before saving. $source['pre_process'] = $this->invoke_translation_process($source, 'pre'); $this->save_string($source['value'], $source['keys'], isset($source['format']) ? $source['format'] : ''); } /** - * Save a string for translation + * Save a string for translation. * - * @param $string + * @param string $string * The string to be translated. - * @param $keys + * @param array $keys * An array of keys to identify the string. Generally constructed from * view name, display_id, and a property, e.g., 'header'. - * @param $format + * @param string $format * The input format of the string. This is optional. */ - function save_string($string, $keys = array(), $format = '') {} + public function save_string($string, $keys = array(), $format = '') {} /** * Delete a string. * - * @param $source + * @param string $source * Full data for the string to be translated. */ - function delete($source) { } + public function delete($source) { + } /** * Collect strings to be exported to code. * - * @param $source + * @param string $source * Full data for the string to be translated. */ - function export($source) { } + public function export($source) { + } /** * Render any collected exported strings to code. * - * @param $indent + * @param string $indent * An optional indentation for prettifying nested code. */ - function export_render($indent = ' ') { } + public function export_render($indent = ' ') { + } /** * Invoke hook_translation_pre_process() or hook_translation_post_process(). @@ -122,7 +133,7 @@ class views_plugin_localization extends views_plugin { * Like node_invoke_nodeapi(), this function is needed to enable both passing * by reference and fetching return values. */ - function invoke_translation_process(&$value, $op) { + public function invoke_translation_process(&$value, $op) { $return = array(); $hook = 'translation_' . $op . '_process'; foreach (module_implements($hook) as $module) { @@ -135,7 +146,10 @@ class views_plugin_localization extends views_plugin { return $return; } - function process_locale_strings($op) { + /** + * + */ + public function process_locale_strings($op) { $this->view->init_display(); foreach ($this->view->display as $display_id => $display) { @@ -154,9 +168,11 @@ class views_plugin_localization extends views_plugin { case 'save': $this->save($data); break; + case 'delete': $this->delete($data); break; + case 'export': $this->export($data); break; @@ -164,6 +180,7 @@ class views_plugin_localization extends views_plugin { } } } + } /** diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_localization_core.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_localization_core.inc index 87443ca..92feb2d 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_localization_core.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_localization_core.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the Drupal core localization plugin. + * Definition of views_plugin_localization_core. */ /** @@ -15,35 +15,35 @@ class views_plugin_localization_core extends views_plugin_localization { /** * Translate a string. * - * @param $string + * @param string $string * The string to be translated. - * @param $keys + * @param array $keys * An array of keys to identify the string. Generally constructed from * view name, display_id, and a property, e.g., 'header'. - * @param $format + * @param string $format * The input format of the string. This is optional. */ - function translate_string($string, $keys = array(), $format = '') { + public function translate_string($string, $keys = array(), $format = '') { return t($string); } /** * Save a string for translation. * - * @param $string + * @param string $string * The string to be translated. - * @param $keys + * @param array $keys * An array of keys to identify the string. Generally constructed from * view name, display_id, and a property, e.g., 'header'. - * @param $format + * @param string $format * The input format of the string. This is optional. */ - function save_string($string, $keys = array(), $format = '') { + public function save_string($string, $keys = array(), $format = '') { global $language; // If the current language is 'en', we need to reset the language // in order to trigger an update. - // TODO: add test for number of languages. + // @todo add test for number of languages. if ($language->language == 'en') { $changed = TRUE; $languages = language_list(); @@ -67,22 +67,23 @@ class views_plugin_localization_core extends views_plugin_localization { * * Deletion is not supported. * - * @param $source + * @param mixed $source * Full data for the string to be translated. */ - function delete($source) { + public function delete($source) { return FALSE; } /** * Collect strings to be exported to code. * - * String identifiers are not supported so strings are anonymously in an array. + * String identifiers are not supported so strings are anonymously in an + * array. * - * @param $source + * @param array $source * Full data for the string to be translated. */ - function export($source) { + public function export($source) { if (!empty($source['value'])) { $this->export_strings[] = $source['value']; } @@ -91,10 +92,10 @@ class views_plugin_localization_core extends views_plugin_localization { /** * Render any collected exported strings to code. * - * @param $indent + * @param string $indent * An optional indentation for prettifying nested code. */ - function export_render($indent = ' ') { + public function export_render($indent = ' ') { $output = ''; if (!empty($this->export_strings)) { $this->export_strings = array_unique($this->export_strings); @@ -106,4 +107,5 @@ class views_plugin_localization_core extends views_plugin_localization { } return $output; } + } diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_localization_none.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_localization_none.inc index 620352a..4a1a7d9 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_localization_none.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_localization_none.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the 'none' localization plugin. + * Definition of views_plugin_localization_none. */ /** @@ -11,26 +11,31 @@ * @ingroup views_localization_plugins */ class views_plugin_localization_none extends views_plugin_localization { - var $translate = FALSE; + + /** + * {@inheritdoc} + */ + public $translate = FALSE; /** * Translate a string; simply return the string. */ - function translate($source) { + public function translate($source) { return $source['value']; } /** * Save a string for translation; not supported. */ - function save($source) { + public function save($source) { return FALSE; } /** * Delete a string; not supported. */ - function delete($source) { + public function delete($source) { return FALSE; } + } diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_pager.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_pager.inc index 312f54b..ab45863 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_pager.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_pager.inc @@ -17,18 +17,26 @@ * The base plugin to handle pager. */ class views_plugin_pager extends views_plugin { - var $current_page = NULL; - var $total_items = 0; + + /** + * + */ + public $current_page = NULL; + + /** + * + */ + public $total_items = 0; /** * Initialize the plugin. * - * @param $view + * @param view $view * The view object. - * @param $display + * @param object $display * The display handler. */ - function init(&$view, &$display, $options = array()) { + public function init(&$view, &$display, $options = array()) { $this->view = &$view; $this->display = &$display; @@ -41,7 +49,7 @@ class views_plugin_pager extends views_plugin { * All but the leanest pagers should probably return a value here, so * most pagers will not need to override this method. */ - function get_items_per_page() { + public function get_items_per_page() { return isset($this->options['items_per_page']) ? $this->options['items_per_page'] : 0; } @@ -50,7 +58,7 @@ class views_plugin_pager extends views_plugin { * * This is mostly used for things that will override the value. */ - function set_items_per_page($items) { + public function set_items_per_page($items) { $this->options['items_per_page'] = $items; } @@ -60,14 +68,14 @@ class views_plugin_pager extends views_plugin { * Even pagers that don't actually page can skip items at the beginning, * so few pagers will need to override this method. */ - function get_offset() { + public function get_offset() { return isset($this->options['offset']) ? $this->options['offset'] : 0; } /** * Set the page offset, or how many items to skip. */ - function set_offset($offset) { + public function set_offset($offset) { $this->options['offset'] = $offset; } @@ -76,18 +84,18 @@ class views_plugin_pager extends views_plugin { * * If NULL, we do not know what the current page is. */ - function get_current_page() { + public function get_current_page() { return $this->current_page; } /** * Set the current page. * - * @param $number + * @param int $number * If provided, the page number will be set to this. If NOT provided, * the page number will be set from the global page array. */ - function set_current_page($number = NULL) { + public function set_current_page($number = NULL) { if (!is_numeric($number) || $number < 0) { $number = 0; } @@ -99,32 +107,34 @@ class views_plugin_pager extends views_plugin { * * If NULL, we do not yet know what the total number of items are. */ - function get_total_items() { + public function get_total_items() { return $this->total_items; } /** - * Get the pager id, if it exists + * Get the pager id, if it exists. */ - function get_pager_id() { + public function get_pager_id() { return !empty($this->options['id']) ? $this->options['id'] : 0; } /** - * Provide the default form form for validating options + * Provide the default form form for validating options. */ - function options_validate(&$form, &$form_state) { } + public function options_validate(&$form, &$form_state) { + } /** - * Provide the default form form for submitting options + * Provide the default form form for submitting options. */ - function options_submit(&$form, &$form_state) { } + public function options_submit(&$form, &$form_state) { + } /** * Return a string to display as the clickable title for the * pager plugin. */ - function summary_title() { + public function summary_title() { return t('Unknown'); } @@ -133,7 +143,7 @@ class views_plugin_pager extends views_plugin { * * Only a couple of very specific pagers will set this to false. */ - function use_pager() { + public function use_pager() { return TRUE; } @@ -142,7 +152,7 @@ class views_plugin_pager extends views_plugin { * * If a pager needs a count query, a simple query */ - function use_count_query() { + public function use_count_query() { return TRUE; } @@ -150,7 +160,7 @@ class views_plugin_pager extends views_plugin { * Execute the count query, which will be done just prior to the query * itself being executed. */ - function execute_count_query(&$count_query) { + public function execute_count_query(&$count_query) { $this->total_items = $count_query->execute()->fetchField(); if (!empty($this->options['offset'])) { $this->total_items -= $this->options['offset']; @@ -164,8 +174,7 @@ class views_plugin_pager extends views_plugin { * If there are pagers that need global values set, this method can * be used to set them. It will be called when the count query is run. */ - function update_page_info() { - + public function update_page_info() { } /** @@ -173,22 +182,26 @@ class views_plugin_pager extends views_plugin { * * This is called during the build phase and can directly modify the query. */ - function query() { } + public function query() { + } /** * Perform any needed actions just prior to the query executing. */ - function pre_execute(&$query) { } + public function pre_execute(&$query) { + } /** * Perform any needed actions just after the query executing. */ - function post_execute(&$result) { } + public function post_execute(&$result) { + } /** * Perform any needed actions just before rendering. */ - function pre_render(&$result) { } + public function pre_render(&$result) { + } /** * Render the pager. @@ -196,39 +209,62 @@ class views_plugin_pager extends views_plugin { * Called during the view render process, this will render the * pager. * - * @param $input + * @param array $input * Any extra GET parameters that should be retained, such as exposed * input. */ - function render($input) { } + public function render($input) { + } /** * Determine if there are more records available. * * This is primarily used to control the display of a more link. */ - function has_more_records() { + public function has_more_records() { return $this->get_items_per_page() && $this->total_items > (intval($this->current_page) + 1) * $this->get_items_per_page(); } - function exposed_form_alter(&$form, &$form_state) { } + /** + * {@inheritdoc} + */ + public function exposed_form_alter(&$form, &$form_state) { + } - function exposed_form_validate(&$form, &$form_state) { } + /** + * {@inheritdoc} + */ + public function exposed_form_validate(&$form, &$form_state) { + } - function exposed_form_submit(&$form, &$form_state, &$exclude) { } + /** + * {@inheritdoc} + */ + public function exposed_form_submit(&$form, &$form_state, &$exclude) { + } - function uses_exposed() { + /** + * {@inheritdoc} + */ + public function uses_exposed() { return FALSE; } - function items_per_page_exposed() { + /** + * {@inheritdoc} + */ + public function items_per_page_exposed() { return FALSE; } - function offset_exposed() { + /** + * {@inheritdoc} + */ + public function offset_exposed() { return FALSE; } + } /** diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_pager_full.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_pager_full.inc index aedb223..fff7691 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_pager_full.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_pager_full.inc @@ -11,14 +11,21 @@ * @ingroup views_pager_plugins */ class views_plugin_pager_full extends views_plugin_pager { - function summary_title() { + + /** + * {@inheritdoc} + */ + public function summary_title() { if (!empty($this->options['offset'])) { return format_plural($this->options['items_per_page'], '@count item, skip @skip', 'Paged, @count items, skip @skip', array('@count' => $this->options['items_per_page'], '@skip' => $this->options['offset'])); } - return format_plural($this->options['items_per_page'], '@count item', 'Paged, @count items', array('@count' => $this->options['items_per_page'])); + return format_plural($this->options['items_per_page'], '@count item', 'Paged, @count items', array('@count' => $this->options['items_per_page'])); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['items_per_page'] = array('default' => 10); $options['offset'] = array('default' => 0); @@ -52,7 +59,7 @@ class views_plugin_pager_full extends views_plugin_pager { /** * Provide the default form for setting options. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $pager_text = $this->display->handler->get_pager_text(); $form['items_per_page'] = array( @@ -90,7 +97,7 @@ class views_plugin_pager_full extends views_plugin_pager { '#default_value' => $this->options['quantity'], ); - $form['tags'] = array ( + $form['tags'] = array( '#type' => 'fieldset', '#collapsible' => FALSE, '#collapsed' => FALSE, @@ -128,7 +135,7 @@ class views_plugin_pager_full extends views_plugin_pager { '#default_value' => $this->options['tags']['last'], ); - $form['expose'] = array ( + $form['expose'] = array( '#type' => 'fieldset', '#collapsible' => FALSE, '#collapsed' => FALSE, @@ -152,7 +159,7 @@ class views_plugin_pager_full extends views_plugin_pager { '#description' => t('Label to use in the exposed items per page form element.'), '#default_value' => $this->options['expose']['items_per_page_label'], '#dependency' => array( - 'edit-pager-options-expose-items-per-page' => array(1) + 'edit-pager-options-expose-items-per-page' => array(1), ), ); @@ -163,11 +170,10 @@ class views_plugin_pager_full extends views_plugin_pager { '#description' => t('Set between which values the user can choose when determining the items per page. Separated by comma.'), '#default_value' => $this->options['expose']['items_per_page_options'], '#dependency' => array( - 'edit-pager-options-expose-items-per-page' => array(1) + 'edit-pager-options-expose-items-per-page' => array(1), ), ); - $form['expose']['items_per_page_options_all'] = array( '#type' => 'checkbox', '#title' => t('Include all items option'), @@ -199,19 +205,22 @@ class views_plugin_pager_full extends views_plugin_pager { '#description' => t('Label to use in the exposed offset form element.'), '#default_value' => $this->options['expose']['offset_label'], '#dependency' => array( - 'edit-pager-options-expose-offset' => array(1) + 'edit-pager-options-expose-offset' => array(1), ), ); } - function options_validate(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_validate(&$form, &$form_state) { // Only accept integer values. $error = FALSE; $exposed_options = $form_state['values']['pager_options']['expose']['items_per_page_options']; if (strpos($exposed_options, '.') !== FALSE) { $error = TRUE; } - $options = explode(',',$exposed_options); + $options = explode(',', $exposed_options); if (!$error && is_array($options)) { foreach ($options as $option) { if (!is_numeric($option) || intval($option) == 0) { @@ -237,7 +246,10 @@ class views_plugin_pager_full extends views_plugin_pager { } } - function query() { + /** + * {@inheritdoc} + */ + public function query() { if ($this->items_per_page_exposed()) { if (!empty($_GET['items_per_page']) && $_GET['items_per_page'] > 0) { $this->options['items_per_page'] = $_GET['items_per_page']; @@ -265,7 +277,10 @@ class views_plugin_pager_full extends views_plugin_pager { $this->view->query->set_offset($offset); } - function render($input) { + /** + * {@inheritdoc} + */ + public function render($input) { $pager_theme = views_theme_functions('pager', $this->view, $this->display); // The 0, 1, 3, 4 index are correct. See theme_pager documentation. $tags = array( @@ -286,11 +301,11 @@ class views_plugin_pager_full extends views_plugin_pager { /** * Set the current page. * - * @param $number + * @param int $number * If provided, the page number will be set to this. If NOT provided, * the page number will be set from the global page array. */ - function set_current_page($number = NULL) { + public function set_current_page($number = NULL) { if (isset($number)) { $this->current_page = $number; return; @@ -320,7 +335,10 @@ class views_plugin_pager_full extends views_plugin_pager { } } - function get_pager_total() { + /** + * {@inheritdoc} + */ + public function get_pager_total() { if ($items_per_page = intval($this->get_items_per_page())) { return ceil($this->total_items / $items_per_page); } @@ -336,7 +354,7 @@ class views_plugin_pager_full extends views_plugin_pager { * items available and to update the current page if the requested * page is out of range. */ - function update_page_info() { + public function update_page_info() { if (!empty($this->options['total_pages'])) { if (($this->options['total_pages'] * $this->options['items_per_page']) < $this->total_items) { $this->total_items = $this->options['total_pages'] * $this->options['items_per_page']; @@ -356,34 +374,47 @@ class views_plugin_pager_full extends views_plugin_pager { // Calculate and set the count of available pages. $pager_total[$pager_id] = $this->get_pager_total(); - // See if the requested page was within range: + // See if the requested page was within range. if ($this->current_page < 0) { $this->current_page = 0; } - else if ($this->current_page >= $pager_total[$pager_id]) { - // Pages are numbered from 0 so if there are 10 pages, the last page is 9. + elseif ($this->current_page >= $pager_total[$pager_id]) { + // Pages are numbered from 0 so if there are 10 pages, the last page is + // 9. $this->current_page = $pager_total[$pager_id] - 1; } - // Put this number in to guarantee that we do not generate notices when the pager - // goes to look for it later. + // Put this number in to guarantee that we do not generate notices when + // the pager goes to look for it later. $pager_page_array[$pager_id] = $this->current_page; } } - function uses_exposed() { + /** + * + */ + public function uses_exposed() { return $this->items_per_page_exposed() || $this->offset_exposed(); } - function items_per_page_exposed() { + /** + * + */ + public function items_per_page_exposed() { return !empty($this->options['expose']['items_per_page']); } - function offset_exposed() { + /** + * + */ + public function offset_exposed() { return !empty($this->options['expose']['offset']); } - function exposed_form_alter(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function exposed_form_alter(&$form, &$form_state) { if ($this->items_per_page_exposed()) { $options = explode(',', $this->options['expose']['items_per_page_options']); $sanitized_options = array(); @@ -414,11 +445,15 @@ class views_plugin_pager_full extends views_plugin_pager { } } - function exposed_form_validate(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function exposed_form_validate(&$form, &$form_state) { if (!empty($form_state['values']['offset']) && trim($form_state['values']['offset'])) { if (!is_numeric($form_state['values']['offset']) || $form_state['values']['offset'] < 0) { - form_set_error('offset', t('Offset must be an number greather or equal than 0.')); + form_set_error('offset', t('Offset must be a number greater than or equal to 0.')); } } } + } diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_pager_mini.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_pager_mini.inc index 87d5541..4e7dc35 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_pager_mini.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_pager_mini.inc @@ -11,21 +11,24 @@ * @ingroup views_pager_plugins */ class views_plugin_pager_mini extends views_plugin_pager_full { - function summary_title() { + + /** + * {@inheritdoc} + */ + public function summary_title() { if (!empty($this->options['offset'])) { return format_plural($this->options['items_per_page'], 'Mini pager, @count item, skip @skip', 'Mini pager, @count items, skip @skip', array('@count' => $this->options['items_per_page'], '@skip' => $this->options['offset'])); } - return format_plural($this->options['items_per_page'], 'Mini pager, @count item', 'Mini pager, @count items', array('@count' => $this->options['items_per_page'])); + return format_plural($this->options['items_per_page'], 'Mini pager, @count item', 'Mini pager, @count items', array('@count' => $this->options['items_per_page'])); } /** - * Overrides views_plugin_pager_full::option_definition(). - * - * Overrides the full pager options form by deleting unused settings. + * {@inheritdoc} */ - function option_definition() { + public function option_definition() { $options = parent::option_definition(); + // Overrides the full pager options form by deleting unused settings. unset($options['quantity']); unset($options['tags']['first']); unset($options['tags']['last']); @@ -36,25 +39,25 @@ class views_plugin_pager_mini extends views_plugin_pager_full { } /** - * Overrides views_plugin_pager_full::options_form(). - * - * Overrides the full pager options form by deleting unused settings. + * {@inheritdoc} */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); + + // Overrides the full pager options form by deleting unused settings. unset($form['quantity']); unset($form['tags']['first']); unset($form['tags']['last']); } /** - * Overrides views_plugin_pager_full::render(). - * - * Overrides the full pager renderer by changing the theme function - * and leaving out variables that are not used in the mini pager. + * {@inheritdoc} */ - function render($input) { + public function render($input) { + // Overrides the full pager renderer by changing the theme function and + // leaving out variables that are not used in the mini pager. $pager_theme = views_theme_functions('views_mini_pager', $this->view, $this->display); + // The 1, 3 index are correct. // @see theme_pager(). $tags = array( @@ -67,4 +70,5 @@ class views_plugin_pager_mini extends views_plugin_pager_full { 'parameters' => $input, )); } + } diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_pager_none.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_pager_none.inc index 12b96d0..3faa301 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_pager_none.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_pager_none.inc @@ -12,21 +12,30 @@ */ class views_plugin_pager_none extends views_plugin_pager { - function init(&$view, &$display, $options = array()) { + /** + * {@inheritdoc} + */ + public function init(&$view, &$display, $options = array()) { parent::init($view, $display, $options); // If the pager is set to none, then it should show all items. $this->set_items_per_page(0); } - function summary_title() { + /** + * {@inheritdoc} + */ + public function summary_title() { if (!empty($this->options['offset'])) { return t('All items, skip @skip', array('@skip' => $this->options['offset'])); } return t('All items'); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['offset'] = array('default' => 0); @@ -36,7 +45,7 @@ class views_plugin_pager_none extends views_plugin_pager { /** * Provide the default form for setting options. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['offset'] = array( '#type' => 'textfield', @@ -46,30 +55,50 @@ class views_plugin_pager_none extends views_plugin_pager { ); } - function use_pager() { + /** + * {@inheritdoc} + */ + public function use_pager() { return FALSE; } - function use_count_query() { + /** + * {@inheritdoc} + */ + public function use_count_query() { return FALSE; } - function get_items_per_page() { + /** + * {@inheritdoc} + */ + public function get_items_per_page() { return 0; } - function execute_count_query(&$count_query) { - // If we are displaying all items, never count. But we can update the count in post_execute. + /** + * {@inheritdoc} + */ + public function execute_count_query(&$count_query) { + // If we are displaying all items, never count. But we can update the count + // in post_execute. } - function post_execute(&$result) { + /** + * {@inheritdoc} + */ + public function post_execute(&$result) { $this->total_items = count($result); } - function query() { + /** + * {@inheritdoc} + */ + public function query() { // The only query modifications we might do are offsets. if (!empty($this->options['offset'])) { $this->view->query->set_offset($this->options['offset']); } } + } diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_pager_some.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_pager_some.inc index 09452ce..12025b2 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_pager_some.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_pager_some.inc @@ -11,14 +11,21 @@ * @ingroup views_pager_plugins */ class views_plugin_pager_some extends views_plugin_pager { - function summary_title() { + + /** + * + */ + public function summary_title() { if (!empty($this->options['offset'])) { return format_plural($this->options['items_per_page'], '@count item, skip @skip', '@count items, skip @skip', array('@count' => $this->options['items_per_page'], '@skip' => $this->options['offset'])); } - return format_plural($this->options['items_per_page'], '@count item', '@count items', array('@count' => $this->options['items_per_page'])); + return format_plural($this->options['items_per_page'], '@count item', '@count items', array('@count' => $this->options['items_per_page'])); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['items_per_page'] = array('default' => 10); $options['offset'] = array('default' => 0); @@ -29,7 +36,7 @@ class views_plugin_pager_some extends views_plugin_pager { /** * Provide the default form for setting options. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $pager_text = $this->display->handler->get_pager_text(); $form['items_per_page'] = array( @@ -47,16 +54,26 @@ class views_plugin_pager_some extends views_plugin_pager { ); } - function use_pager() { + /** + * {@inheritdoc} + */ + public function use_pager() { return FALSE; } - function use_count_query() { + /** + * {@inheritdoc} + */ + public function use_count_query() { return FALSE; } - function query() { + /** + * {@inheritdoc} + */ + public function query() { $this->view->query->set_limit($this->options['items_per_page']); $this->view->query->set_offset($this->options['offset']); } + } diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_query.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_query.inc index d39ed98..fe45793 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_query.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_query.inc @@ -2,7 +2,7 @@ /** * @file - * Defines the base query class, which is the underlying layer in a View. + * Definition of views_plugin_query. */ /** @@ -14,20 +14,21 @@ */ /** - * Object used to create a SELECT query. + * The base query class, which is the underlying layer in a View. */ class views_plugin_query extends views_plugin { + /** * A pager plugin that should be provided by the display. * * @var views_plugin_pager */ - var $pager = NULL; + public $pager = NULL; /** * Constructor; Create the basic query object and fill with default values. */ - function init($base_table, $base_field, $options) { + public function init($base_table, $base_field, $options) { $this->base_table = $base_table; $this->base_field = $base_field; $this->unpack_options($this->options, $options); @@ -37,10 +38,14 @@ class views_plugin_query extends views_plugin { * Generate a query and a countquery from all of the information supplied * to the object. * - * @param $get_count - * Provide a countquery if this is true, otherwise provide a normal query. + * @param bool $get_count + * Provide a countquery if this is TRUE, otherwise provide a normal query. + * + * @return SelectQuery + * A SelectQuery object. */ - function query($get_count = FALSE) { } + public function query($get_count = FALSE) { + } /** * Let modules modify the query just prior to finalizing it. @@ -48,7 +53,8 @@ class views_plugin_query extends views_plugin { * @param view $view * The view which is executed. */ - function alter(&$view) { } + public function alter(&$view) { + } /** * Builds the necessary info to execute the query. @@ -56,7 +62,8 @@ class views_plugin_query extends views_plugin { * @param view $view * The view which is executed. */ - function build(&$view) { } + public function build(&$view) { + } /** * Executes the query and fills the associated view object with according @@ -71,7 +78,8 @@ class views_plugin_query extends views_plugin { * @param view $view * The view which is executed. */ - function execute(&$view) { } + public function execute(&$view) { + } /** * Add a signature to the query, if such a thing is feasible. @@ -82,48 +90,61 @@ class views_plugin_query extends views_plugin { * @param view $view * The view which is executed. */ - function add_signature(&$view) { } + public function add_signature(&$view) { + } /** * Get aggregation info for group by queries. * * If NULL, aggregation is not allowed. */ - function get_aggregation_info() { } + public function get_aggregation_info() { + } /** * Add settings for the ui. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); } - function options_validate(&$form, &$form_state) { } + /** + * {@inheritdoc} + */ + public function options_validate(&$form, &$form_state) { + } - function options_submit(&$form, &$form_state) { } + /** + * {@inheritdoc} + */ + public function options_submit(&$form, &$form_state) { + } - function summary_title() { + /** + * {@inheritdoc} + */ + public function summary_title() { return t('Settings'); } /** * Set a LIMIT on the query, specifying a maximum number of results. */ - function set_limit($limit) { + public function set_limit($limit) { $this->limit = $limit; } /** * Set an OFFSET on the query, specifying a number of results to skip */ - function set_offset($offset) { + public function set_offset($offset) { $this->offset = $offset; } /** * Render the pager, if necessary. */ - function render_pager($exposed_input) { + public function render_pager($exposed_input) { if (!empty($this->pager) && $this->pager->use_pager()) { return $this->pager->render($exposed_input); } @@ -134,18 +155,18 @@ class views_plugin_query extends views_plugin { /** * Create a new grouping for the WHERE or HAVING clause. * - * @param $type + * @param string $type * Either 'AND' or 'OR'. All items within this group will be added * to the WHERE clause with this logical operator. - * @param $group + * @param string $group * An ID to use for this group. If unspecified, an ID will be generated. - * @param $where + * @param string $where * 'where' or 'having'. * - * @return $group + * @return string * The group ID generated. */ - function set_where_group($type = 'AND', $group = NULL, $where = 'where') { + public function set_where_group($type = 'AND', $group = NULL, $where = 'where') { // Set an alias. $groups = &$this->$where; @@ -165,19 +186,20 @@ class views_plugin_query extends views_plugin { /** * Control how all WHERE and HAVING groups are put together. * - * @param $type - * Either 'AND' or 'OR' + * @param string $type + * Either 'AND' or 'OR'. */ - function set_group_operator($type = 'AND') { + public function set_group_operator($type = 'AND') { $this->group_operator = strtoupper($type); } /** * Returns the according entity objects for the given query results. */ - function get_result_entities($results, $relationship = NULL) { + public function get_result_entities($results, $relationship = NULL) { return FALSE; } + } /** diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_query_default.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_query_default.inc index 8a15e8d..2911a56 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_query_default.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_query_default.inc @@ -2,7 +2,7 @@ /** * @file - * Defines the default query object. + * Definition of views_plugin_query_default. */ /** @@ -15,95 +15,98 @@ class views_plugin_query_default extends views_plugin_query { /** * A list of tables in the order they should be added, keyed by alias. */ - var $table_queue = array(); + public $table_queue = array(); /** - * Holds an array of tables and counts added so that we can create aliases + * Holds an array of tables and counts added so that we can create aliases. */ - var $tables = array(); + public $tables = array(); /** * Holds an array of relationships, which are aliases of the primary * table that represent different ways to join the same table in. */ - var $relationships = array(); + public $relationships = array(); /** * An array of sections of the WHERE query. Each section is in itself * an array of pieces and a flag as to whether or not it should be AND * or OR. */ - var $where = array(); + public $where = array(); + /** * An array of sections of the HAVING query. Each section is in itself * an array of pieces and a flag as to whether or not it should be AND * or OR. */ - var $having = array(); + public $having = array(); + /** * The default operator to use when connecting the WHERE groups. May be * AND or OR. */ - var $group_operator = 'AND'; + public $group_operator = 'AND'; /** * A simple array of order by clauses. */ - var $orderby = array(); + public $orderby = array(); /** * A simple array of group by clauses. */ - var $groupby = array(); - + public $groupby = array(); /** * An array of fields. */ - var $fields = array(); - + public $fields = array(); /** * The table header to use for tablesort. This matters because tablesort * needs to modify the query and needs the header. */ - var $header = array(); + public $header = array(); /** * A flag as to whether or not to make the primary field distinct. */ - var $distinct = FALSE; + public $distinct = FALSE; - var $has_aggregate = FALSE; + /** + * + */ + public $has_aggregate = FALSE; /** * Should this query be optimized for counts, for example no sorts. */ - var $get_count_optimized = NULL; + public $get_count_optimized = NULL; /** * The current used pager plugin. * * @var views_plugin_pager */ - var $pager = NULL; + public $pager = NULL; - /** + /** * An array mapping table aliases and field names to field aliases. */ - var $field_aliases = array(); + public $field_aliases = array(); - /** + /** * Query tags which will be passed over to the dbtng query object. */ - var $tags = array(); + public $tags = array(); /** * Is the view marked as not distinct. * * @var bool */ - var $no_distinct; + public $no_distinct; /** * Defines the distinct type. @@ -115,20 +118,21 @@ class views_plugin_query_default extends views_plugin_query { public $pure_distinct = FALSE; /** - * Constructor; Create the basic query object and fill with default values. + * {@inheritdoc} */ - function init($base_table = 'node', $base_field = 'nid', $options) { + public function init($base_table = 'node', $base_field = 'nid', $options) { parent::init($base_table, $base_field, $options); - $this->base_table = $base_table; // Predefine these above, for clarity. + $this->base_table = $base_table; + // Predefine these above, for clarity. $this->base_field = $base_field; $this->relationships[$base_table] = array( 'link' => NULL, 'table' => $base_table, 'alias' => $base_table, - 'base' => $base_table + 'base' => $base_table, ); - // init the table queue with our primary table. + // Unit the table queue with our primary table. $this->table_queue[$base_table] = array( 'alias' => $base_table, 'table' => $base_table, @@ -136,22 +140,20 @@ class views_plugin_query_default extends views_plugin_query { 'join' => NULL, ); - // init the tables with our primary table + // Init the tables with our primary table. $this->tables[$base_table][$base_table] = array( 'count' => 1, 'alias' => $base_table, ); -/** - * -- we no longer want the base field to appear automatigically. - if ($base_field) { - $this->fields[$base_field] = array( - 'table' => $base_table, - 'field' => $base_field, - 'alias' => $base_field, - ); - } - */ + // We no longer want the base field to appear automatically. + // if ($base_field) { + // $this->fields[$base_field] = array( + // 'table' => $base_table, + // 'field' => $base_field, + // 'alias' => $base_field, + // ); + // } $this->count_field = array( 'table' => $base_table, @@ -161,8 +163,9 @@ class views_plugin_query_default extends views_plugin_query { ); } - // ---------------------------------------------------------------- - // Utility methods to set flags and data. + /** + * Utility methods to set flags and data. + */ /** * Set the view to be distinct. @@ -175,7 +178,7 @@ class views_plugin_query_default extends views_plugin_query { * @param bool $pure_distinct * Should only the sql keyword be added. */ - function set_distinct($value = TRUE, $pure_distinct = FALSE) { + public function set_distinct($value = TRUE, $pure_distinct = FALSE) { if (!(isset($this->no_distinct) && $value)) { $this->distinct = $value; $this->pure_distinct = $pure_distinct; @@ -185,7 +188,7 @@ class views_plugin_query_default extends views_plugin_query { /** * Set what field the query will count() on for paging. */ - function set_count_field($table, $field, $alias = NULL) { + public function set_count_field($table, $field, $alias = NULL) { if (empty($alias)) { $alias = $table . '_' . $field; } @@ -198,14 +201,19 @@ class views_plugin_query_default extends views_plugin_query { } /** - * Set the table header; used for click-sorting because it's needed - * info to modify the ORDER BY clause. + * Set the table header. + * + * Used for click-sorting because it's needed info to modify the ORDER BY + * clause. */ - function set_header($header) { + public function set_header($header) { $this->header = $header; } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['disable_sql_rewrite'] = array( 'default' => FALSE, @@ -237,7 +245,7 @@ class views_plugin_query_default extends views_plugin_query { /** * Add settings for the ui. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['disable_sql_rewrite'] = array( @@ -245,7 +253,9 @@ class views_plugin_query_default extends views_plugin_query { '#description' => t('Disabling SQL rewriting will disable node_access checks as well as other modules that implement hook_query_alter().'), '#type' => 'checkbox', '#default_value' => !empty($this->options['disable_sql_rewrite']), - '#suffix' => '
' . t('WARNING: Disabling SQL rewriting means that node access security is disabled. This may allow users to see data they should not be able to see if your view is misconfigured. Please use this option only if you understand and accept this security risk.') . '
', + '#suffix' => '
' + . t('WARNING: Disabling SQL rewriting means that node access security is disabled. This may allow users to see data they should not be able to see if your view is misconfigured. Please use this option only if you understand and accept this security risk.') + . '
', ); $form['distinct'] = array( '#type' => 'checkbox', @@ -284,45 +294,45 @@ class views_plugin_query_default extends views_plugin_query { /** * Special submit handling. */ - function options_submit(&$form, &$form_state) { + public function options_submit(&$form, &$form_state) { $element = array('#parents' => array('query', 'options', 'query_tags')); $value = explode(',', drupal_array_get_nested_value($form_state['values'], $element['#parents'])); $value = array_filter(array_map('trim', $value)); form_set_value($element, $value, $form_state); } - // ---------------------------------------------------------------- - // Table/join adding + /** + * Table/join adding. + */ /** - * A relationship is an alternative endpoint to a series of table - * joins. Relationships must be aliases of the primary table and - * they must join either to the primary table or to a pre-existing - * relationship. + * A relationship is an alternative endpoint to a series of table joins. * - * An example of a relationship would be a nodereference table. - * If you have a nodereference named 'book_parent' which links to a - * parent node, you could set up a relationship 'node_book_parent' - * to 'node'. Then, anything that links to 'node' can link to - * 'node_book_parent' instead, thus allowing all properties of - * both nodes to be available in the query. + * Relationships must be aliases of the primary table and they must join + * either to the primary table or to a pre-existing relationship. * - * @param $alias - * What this relationship will be called, and is also the alias - * for the table. + * An example of a relationship would be a nodereference table. If you have a + * nodereference named 'book_parent' which links to a parent node, you could + * set up a relationship 'node_book_parent' to 'node'. Then, anything that + * links to 'node' can link to 'node_book_parent' instead, thus allowing all + * properties of both nodes to be available in the query. + * + * @param string $alias + * What this relationship will be called, and is also the alias for the + * table. * @param views_join $join * A views_join object (or derived object) to join the alias in. - * @param $base - * The name of the 'base' table this relationship represents; this - * tells the join search which path to attempt to use when finding - * the path to this relationship. - * @param $link_point - * If this relationship links to something other than the primary - * table, specify that table here. For example, a 'track' node - * might have a relationship to an 'album' node, which might - * have a relationship to an 'artist' node. + * @param string $base + * The name of the 'base' table this relationship represents; this tells the + * join search which path to attempt to use when finding the path to this + * relationship. + * @param string $link_point + * If this relationship links to something other than the primary table, + * specify that table here. For example, a 'track' node might have a + * relationship to an 'album' node, which might have a relationship to an + * 'artist' node. */ - function add_relationship($alias, $join, $base, $link_point = NULL) { + public function add_relationship($alias, $join, $base, $link_point = NULL) { if (empty($link_point)) { $link_point = $this->base_table; } @@ -342,8 +352,7 @@ class views_plugin_query_default extends views_plugin_query { $join = $this->adjust_join($join, $link_point); } - // Add the table directly to the queue to avoid accidentally marking - // it. + // Add the table directly to the queue to avoid accidentally marking it. $this->table_queue[$alias] = array( 'table' => $join->table, 'num' => 1, @@ -369,34 +378,34 @@ class views_plugin_query_default extends views_plugin_query { /** * Add a table to the query, ensuring the path exists. * - * This function will test to ensure that the path back to the primary - * table is valid and exists; if you do not wish for this testing to - * occur, use $query->queue_table() instead. + * This function will test to ensure that the path back to the primary table + * is valid and exists; if you do not wish for this testing to occur, use + * $query->queue_table() instead. * - * @param $table + * @param string $table * The name of the table to add. It needs to exist in the global table * array. - * @param $relationship - * An alias of a table; if this is set, the path back to this table will - * be tested prior to adding the table, making sure that all intermediary - * tables exist and are properly aliased. If set to NULL the path to - * the primary table will be ensured. If the path cannot be made, the - * table will NOT be added. + * @param string $relationship + * An alias of a table; if this is set, the path back to this table will be + * tested prior to adding the table, making sure that all intermediary + * tables exist and are properly aliased. If set to NULL the path to the + * primary table will be ensured. If the path cannot be made, the table + * will NOT be added. * @param views_join $join - * In some join configurations this table may actually join back through - * a different method; this is most likely to be used when tracing - * a hierarchy path. (node->parent->parent2->parent3). This parameter - * will specify how this table joins if it is not the default. - * @param $alias + * In some join configurations this table may actually join back through a + * different method; this is most likely to be used when tracing a + * hierarchy path. (node->parent->parent2->parent3). This parameter will + * specify how this table joins if it is not the default. + * @param string $alias * A specific alias to use, rather than the default alias. * - * @return $alias + * @return string * The alias of the table; this alias can be used to access information * about the table and should always be used to refer to the table when * adding parts to the query. Or FALSE if the table was not able to be * added. */ - function add_table($table, $relationship = NULL, $join = NULL, $alias = NULL) { + public function add_table($table, $relationship = NULL, $join = NULL, $alias = NULL) { if (!$this->ensure_path($table, $relationship, $join)) { return FALSE; } @@ -415,27 +424,27 @@ class views_plugin_query_default extends views_plugin_query { * ensure_table() should be used instead of this one, unless you are * absolutely sure this is what you want. * - * @param $table + * @param string $table * The name of the table to add. It needs to exist in the global table * array. - * @param $relationship + * @param string $relationship * The primary table alias this table is related to. If not set, the * primary table will be used. * @param views_join $join - * In some join configurations this table may actually join back through - * a different method; this is most likely to be used when tracing - * a hierarchy path. (node->parent->parent2->parent3). This parameter - * will specify how this table joins if it is not the default. - * @param $alias + * In some join configurations this table may actually join back through a + * different method; this is most likely to be used when tracing a + * hierarchy path. (node->parent->parent2->parent3). This parameter will + * specify how this table joins if it is not the default. + * @param string $alias * A specific alias to use, rather than the default alias. * - * @return $alias + * @return string * The alias of the table; this alias can be used to access information * about the table and should always be used to refer to the table when * adding parts to the query. Or FALSE if the table was not able to be * added. */ - function queue_table($table, $relationship = NULL, $join = NULL, $alias = NULL) { + public function queue_table($table, $relationship = NULL, $join = NULL, $alias = NULL) { // If the alias is set, make sure it doesn't already exist. if (isset($this->table_queue[$alias])) { return $alias; @@ -458,8 +467,8 @@ class views_plugin_query_default extends views_plugin_query { } } - // Check this again to make sure we don't blow up existing aliases for already - // adjusted joins. + // Check this again to make sure we don't blow up existing aliases for + // already adjusted joins. if (isset($this->table_queue[$alias])) { return $alias; } @@ -471,8 +480,8 @@ class views_plugin_query_default extends views_plugin_query { $alias = $this->tables[$relationship][$table]['alias'] . $this->tables[$relationship][$table]['count']; } - // If this is a relationship based table, add a marker with - // the relationship as a primary table for the alias. + // If this is a relationship based table, add a marker with the + // relationship as a primary table for the alias. if ($table != $alias) { $this->mark_table($alias, $this->base_table, $alias); } @@ -498,14 +507,17 @@ class views_plugin_query_default extends views_plugin_query { return $alias; } - function mark_table($table, $relationship, $alias) { + /** + * + */ + public function mark_table($table, $relationship, $alias) { // Mark that this table has been added. if (empty($this->tables[$relationship][$table])) { if (!isset($alias)) { $alias = ''; if ($relationship != $this->base_table) { - // double underscore will help prevent accidental name - // space collisions. + // Double underscore will help prevent accidental name space + // collisions. $alias = $relationship . '__'; } $alias .= $table; @@ -523,33 +535,33 @@ class views_plugin_query_default extends views_plugin_query { } /** - * Ensure a table exists in the queue; if it already exists it won't - * do anything, but if it doesn't it will add the table queue. It will ensure - * a path leads back to the relationship table. + * Ensure a table exists in the queue; if it already exists it won't do + * anything, but if it doesn't it will add the table queue. It will ensure a + * path leads back to the relationship table. * - * @param $table + * @param string $table * The unaliased name of the table to ensure. - * @param $relationship + * @param string $relationship * The relationship to ensure the table links to. Each relationship will - * get a unique instance of the table being added. If not specified, - * will be the primary table. + * get a unique instance of the table being added. If not specified, will + * be the primary table. * @param views_join $join * A views_join object (or derived object) to join the alias in. * - * @return + * @return string * The alias used to refer to this specific table, or NULL if the table * cannot be ensured. */ - function ensure_table($table, $relationship = NULL, $join = NULL) { - // ensure a relationship + public function ensure_table($table, $relationship = NULL, $join = NULL) { + // Ensure a relationship. if (empty($relationship)) { $relationship = $this->base_table; } // If the relationship is the primary table, this actually be a relationship - // link back from an alias. We store all aliases along with the primary table - // to detect this state, because eventually it'll hit a table we already - // have and that's when we want to stop. + // link back from an alias. We store all aliases along with the primary + // table to detect this state, because eventually it'll hit a table we + // already have and that's when we want to stop. if ($relationship == $this->base_table && !empty($this->tables[$relationship][$table])) { return $this->tables[$relationship][$table]['alias']; } @@ -578,31 +590,28 @@ class views_plugin_query_default extends views_plugin_query { $join = $this->adjust_join($join, $relationship); if ($this->ensure_path($table, $relationship, $join)) { - // Attempt to eliminate redundant joins. If this table's - // relationship and join exactly matches an existing table's - // relationship and join, we do not have to join to it again; - // just return the existing table's alias. See - // http://groups.drupal.org/node/11288 for details. + // Attempt to eliminate redundant joins. If this table's relationship + // and join exactly matches an existing table's relationship and join, we + // do not have to join to it again; just return the existing table's + // alias. + // @see http://groups.drupal.org/node/11288 // - // This can be done safely here but not lower down in - // queue_table(), because queue_table() is also used by - // add_table() which requires the ability to intentionally add - // the same table with the same join multiple times. For - // example, a view that filters on 3 taxonomy terms using AND - // needs to join taxonomy_term_data 3 times with the same join. - + // This can be done safely here but not lower down in queue_table(), + // because queue_table() is also used by add_table() which requires the + // ability to intentionally add the same table with the same join + // multiple times. For example, a view that filters on 3 taxonomy terms + // using AND needs to join taxonomy_term_data 3 times with the same join. // scan through the table queue to see if a matching join and // relationship exists. If so, use it instead of this join. - - // TODO: Scanning through $this->table_queue results in an - // O(N^2) algorithm, and this code runs every time the view is - // instantiated (Views 2 does not currently cache queries). - // There are a couple possible "improvements" but we should do - // some performance testing before picking one. + // @todo Scanning through $this->table_queue results in an O(N^2) + // algorithm, and this code runs every time the view is instantiated + // (Views 2 does not currently cache queries). There are a couple + // possible "improvements" but we should do some performance testing + // before picking one. foreach ($this->table_queue as $queued_table) { - // In PHP 4 and 5, the == operation returns TRUE for two objects - // if they are instances of the same class and have the same - // attributes and values. + // In PHP 4 and 5, the == operation returns TRUE for two objects if + // they are instances of the same class and have the same attributes + // and values. if ($queued_table['relationship'] == $relationship && $queued_table['join'] == $join) { return $queued_table['alias']; } @@ -614,12 +623,12 @@ class views_plugin_query_default extends views_plugin_query { /** * Make sure that the specified table can be properly linked to the primary - * table in the JOINs. This function uses recursion. If the tables - * needed to complete the path back to the primary table are not in the - * query they will be added, but additional copies will NOT be added - * if the table is already there. + * table in the JOINs. This function uses recursion. If the tables needed + * to complete the path back to the primary table are not in the query they + * will be added, but additional copies will NOT be added if the table is + * already there. */ - function ensure_path($table, $relationship = NULL, $join = NULL, $traced = array(), $add = array()) { + public function ensure_path($table, $relationship = NULL, $join = NULL, $traced = array(), $add = array()) { if (!isset($relationship)) { $relationship = $this->base_table; } @@ -652,7 +661,7 @@ class views_plugin_query_default extends views_plugin_query { // Have we been this way? if (isset($traced[$join->left_table])) { - // we looped. Broked. + // We looped. Broked. return FALSE; } @@ -668,10 +677,12 @@ class views_plugin_query_default extends views_plugin_query { } /** - * Fix a join to adhere to the proper relationship; the left table can vary - * based upon what relationship items are joined in on. + * Fix a join to adhere to the proper relationship. + * + * The left table can vary based upon what relationship items are joined in + * on. */ - function adjust_join($join, $relationship) { + public function adjust_join($join, $relationship) { if (!empty($join->adjusted)) { return $join; } @@ -683,9 +694,8 @@ class views_plugin_query_default extends views_plugin_query { // Adjusts the left table for our relationship. if ($relationship != $this->base_table) { // If we're linking to the primary table, the relationship to use will - // be the prior relationship. Unless it's a direct link. - - // Safety! Don't modify an original here. + // be the prior relationship. Unless it's a direct link. Safety! Don't + // modify an original here. $join = clone $join; // Do we need to try to ensure a path? @@ -695,7 +705,8 @@ class views_plugin_query_default extends views_plugin_query { $this->ensure_table($join->left_table, $relationship); } - // First, if this is our link point/anchor table, just use the relationship + // First, if this is our link point/anchor table, just use the + // relationship. if ($join->left_table == $this->relationships[$relationship]['table']) { $join->left_table = $relationship; } @@ -716,15 +727,15 @@ class views_plugin_query_default extends views_plugin_query { /** * Retrieve join data from the larger join data cache. * - * @param $table + * @param string $table * The table to get the join information for. - * @param $base_table + * @param string $base_table * The path we're following to get this join. * * @return views_join * A views_join object or child object, if one exists. */ - function get_join_data($table, $base_table) { + public function get_join_data($table, $base_table) { // Check to see if we're linking to a known alias. If so, get the real // table's data instead. if (!empty($this->table_queue[$table])) { @@ -739,7 +750,7 @@ class views_plugin_query_default extends views_plugin_query { * If you need the alias of a table with a particular relationship, use * ensure_table(). */ - function get_table_info($table) { + public function get_table_info($table) { if (!empty($this->table_queue[$table])) { return $this->table_queue[$table]; } @@ -755,27 +766,26 @@ class views_plugin_query_default extends views_plugin_query { /** * Add a field to the query table, possibly with an alias. This will - * automatically call ensure_table to make sure the required table - * exists, *unless* $table is unset. + * automatically call ensure_table to make sure the required table exists, + * *unless* $table is unset. * - * @param $table - * The table this field is attached to. If NULL, it is assumed this will - * be a formula; otherwise, ensure_table is used to make sure the - * table exists. - * @param $field + * @param string $table + * The table this field is attached to. If NULL, it is assumed this will be + * a formula; otherwise, ensure_table is used to make sure the table exists. + * @param string $field * The name of the field to add. This may be a real field or a formula. - * @param $alias + * @param string $alias * The alias to create. If not specified, the alias will be $table_$field * unless $table is NULL. When adding formulae, it is recommended that an * alias be used. - * @param $params + * @param array $params * An array of parameters additional to the field that will control items * such as aggregation functions and DISTINCT. * - * @return $name - * The name that this field can be referred to as. Usually this is the alias. + * @return string + * The name that this field can be referred to as, usually the alias. */ - function add_field($table, $field, $alias = '', $params = array()) { + public function add_field($table, $field, $alias = '', $params = array()) { // We check for this specifically because it gets a special alias. if ($table == $this->base_table && $field == $this->base_field && empty($alias)) { $alias = $this->base_field; @@ -789,13 +799,13 @@ class views_plugin_query_default extends views_plugin_query { $alias = $table . '_' . $field; } - // Make sure an alias is assigned + // Make sure an alias is assigned. $alias = $alias ? $alias : $field; - // PostgreSQL truncates aliases to 63 characters: http://drupal.org/node/571548 - + // PostgreSQL truncates aliases to 63 characters. + // @see http://drupal.org/node/571548 // We limit the length of the original alias up to 60 characters - // to get a unique alias later if its have duplicates + // to get a unique alias later if its have duplicates. $alias = strtolower(substr($alias, 0, 60)); // Create a field info array. @@ -805,9 +815,9 @@ class views_plugin_query_default extends views_plugin_query { 'alias' => $alias, ) + $params; - // Test to see if the field is actually the same or not. Due to - // differing parameters changing the aggregation function, we need - // to do some automatic alias collision detection: + // Test to see if the field is actually the same or not. Due to differing + // parameters changing the aggregation function, we need to do some + // automatic alias collision detection. $base = $alias; $counter = 0; while (!empty($this->fields[$alias]) && $this->fields[$alias] != $field_info) { @@ -825,35 +835,40 @@ class views_plugin_query_default extends views_plugin_query { } /** - * Remove all fields that may've been added; primarily used for summary - * mode where we're changing the query because we didn't get data we needed. + * Remove all fields that may've been added. + * + * Primarily used for summary mode where we're changing the query because we + * didn't get data we needed. */ - function clear_fields() { + public function clear_fields() { $this->fields = array(); } /** - * Add a simple WHERE clause to the query. The caller is responsible for - * ensuring that all fields are fully qualified (TABLE.FIELD) and that - * the table already exists in the query. + * Add a simple WHERE clause to the query. * - * @param $group + * The caller is responsible for ensuring that all fields are fully qualified + * (TABLE.FIELD) and that the table already exists in the query. + * + * @param string $group * The WHERE group to add these to; groups are used to create AND/OR - * sections. Groups cannot be nested. Use 0 as the default group. - * If the group does not yet exist it will be created as an AND group. - * @param $field + * sections. Groups cannot be nested. Use 0 as the default group. If the + * group does not yet exist it will be created as an AND group. + * @param string $field * The name of the field to check. - * @param $value - * The value to test the field against. In most cases, this is a scalar. For more - * complex options, it is an array. The meaning of each element in the array is - * dependent on the $operator. - * @param $operator - * The comparison operator, such as =, <, or >=. It also accepts more complex - * options such as IN, LIKE, or BETWEEN. Defaults to IN if $value is an array - * = otherwise. If $field is a string you have to use 'formula' here. + * @param string $value + * The value to test the field against. In most cases, this is a scalar. For + * more complex options, it is an array. The meaning of each element in the + * array is dependent on the $operator. + * @param string $operator + * The comparison operator, such as =, <, or >=. It also accepts more + * complex options such as IN, LIKE, or BETWEEN. Defaults to IN if $value is + * an array = otherwise. If $field is a string you have to use 'formula' + * here. * * The $field, $value and $operator arguments can also be passed in with a * single DatabaseCondition object, like this: + * * @code * $this->query->add_where( * $this->options['group'], @@ -866,9 +881,9 @@ class views_plugin_query_default extends views_plugin_query { * @see QueryConditionInterface::condition() * @see DatabaseCondition */ - function add_where($group, $field, $value = NULL, $operator = NULL) { - // Ensure all variants of 0 are actually 0. Thus '', 0 and NULL are all - // the default group. + public function add_where($group, $field, $value = NULL, $operator = NULL) { + // Ensure all variants of 0 are actually 0. Thus '', 0 and NULL are all the + // default group. if (empty($group)) { $group = 0; } @@ -888,23 +903,23 @@ class views_plugin_query_default extends views_plugin_query { /** * Add a complex WHERE clause to the query. * - * The caller is reponsible for ensuring that all fields are fully qualified - * (TABLE.FIELD) and that the table already exists in the query. - * Internally the dbtng method "where" is used. + * The caller is responsible for ensuring that all fields are fully qualified + * (TABLE.FIELD) and that the table already exists in the query. Internally + * the dbtng method "where" is used. * - * @param $group + * @param string $group * The WHERE group to add these to; groups are used to create AND/OR - * sections. Groups cannot be nested. Use 0 as the default group. - * If the group does not yet exist it will be created as an AND group. - * @param $snippet - * The snippet to check. This can be either a column or - * a complex expression like "UPPER(table.field) = 'value'" - * @param $args + * sections. Groups cannot be nested. Use 0 as the default group. If the + * group does not yet exist it will be created as an AND group. + * @param string $snippet + * The snippet to check. This can be either a column or a complex expression + * like "UPPER(table.field) = 'value'". + * @param array $args * An associative array of arguments. * * @see QueryConditionInterface::where() */ - function add_where_expression($group, $snippet, $args = array()) { + public function add_where_expression($group, $snippet, $args = array()) { // Ensure all variants of 0 are actually 0. Thus '', 0 and NULL are all // the default group. if (empty($group)) { @@ -927,29 +942,30 @@ class views_plugin_query_default extends views_plugin_query { * Add a simple HAVING clause to the query. * * The caller is responsible for ensuring that all fields are fully qualified - * (TABLE.FIELD) and that the table and an appropriate GROUP BY already exist in the query. - * Internally the dbtng method "havingCondition" is used. + * (TABLE.FIELD) and that the table and an appropriate GROUP BY already exist + * in the query. Internally the dbtng method "havingCondition" is used. * - * @param $group + * @param string $group * The HAVING group to add these to; groups are used to create AND/OR - * sections. Groups cannot be nested. Use 0 as the default group. - * If the group does not yet exist it will be created as an AND group. - * @param $field + * sections. Groups cannot be nested. Use 0 as the default group. If the + * group does not yet exist it will be created as an AND group. + * @param string $field * The name of the field to check. - * @param $value - * The value to test the field against. In most cases, this is a scalar. For more - * complex options, it is an array. The meaning of each element in the array is - * dependent on the $operator. - * @param $operator - * The comparison operator, such as =, <, or >=. It also accepts more complex - * options such as IN, LIKE, or BETWEEN. Defaults to IN if $value is an array - * = otherwise. If $field is a string you have to use 'formula' here. + * @param string $value + * The value to test the field against. In most cases, this is a scalar. For + * more complex options, it is an array. The meaning of each element in the + * array is dependent on the $operator. + * @param string $operator + * The comparison operator, such as =, <, or >=. It also accepts more + * complex options such as IN, LIKE, or BETWEEN. Defaults to IN if $value is + * an array = otherwise. If $field is a string you have to use 'formula' + * here. * * @see SelectQueryInterface::havingCondition() */ - function add_having($group, $field, $value = NULL, $operator = NULL) { - // Ensure all variants of 0 are actually 0. Thus '', 0 and NULL are all - // the default group. + public function add_having($group, $field, $value = NULL, $operator = NULL) { + // Ensure all variants of 0 are actually 0. Thus '', 0 and NULL are all the + // default group. if (empty($group)) { $group = 0; } @@ -969,23 +985,24 @@ class views_plugin_query_default extends views_plugin_query { /** * Add a complex HAVING clause to the query. - * The caller is responsible for ensuring that all fields are fully qualified - * (TABLE.FIELD) and that the table and an appropriate GROUP BY already exist in the query. - * Internally the dbtng method "having" is used. * - * @param $group + * The caller is responsible for ensuring that all fields are fully qualified + * (TABLE.FIELD) and that the table and an appropriate GROUP BY already exist + * in the query. Internally the dbtng method "having" is used. + * + * @param string $group * The HAVING group to add these to; groups are used to create AND/OR - * sections. Groups cannot be nested. Use 0 as the default group. - * If the group does not yet exist it will be created as an AND group. - * @param $snippet - * The snippet to check. This can be either a column or - * a complex expression like "COUNT(table.field) > 3" - * @param $args + * sections. Groups cannot be nested. Use 0 as the default group. If the + * group does not yet exist it will be created as an AND group. + * @param string $snippet + * The snippet to check. This can be either a column or a complex + * expression like "COUNT(table.field) > 3" + * @param array $args * An associative array of arguments. * * @see QueryConditionInterface::having() */ - function add_having_expression($group, $snippet, $args = array()) { + public function add_having_expression($group, $snippet, $args = array()) { // Ensure all variants of 0 are actually 0. Thus '', 0 and NULL are all // the default group. if (empty($group)) { @@ -1008,31 +1025,32 @@ class views_plugin_query_default extends views_plugin_query { /** * Add an ORDER BY clause to the query. * - * @param $table - * The table this field is part of. If a formula, enter NULL. - * If you want to orderby random use "rand" as table and nothing else. - * @param $field - * The field or formula to sort on. If already a field, enter NULL - * and put in the alias. - * @param $order + * @param string $table + * The table this field is part of. If a formula, enter NULL. If you want to + * orderby random use "rand" as table and nothing else. + * @param string $field + * The field or formula to sort on. If already a field, enter NULL and put + * in the alias. + * @param string $order * Either ASC or DESC. - * @param $alias - * The alias to add the field as. In SQL, all fields in the order by - * must also be in the SELECT portion. If an $alias isn't specified - * one will be generated for from the $field; however, if the - * $field is a formula, this alias will likely fail. - * @param $params + * @param string $alias + * The alias to add the field as. In SQL, all fields in the order by must + * also be in the SELECT portion. If an $alias isn't specified one will be + * generated for from the $field; however, if the $field is a formula, this + * alias will likely fail. + * @param string $params * Any params that should be passed through to the add_field. */ - function add_orderby($table, $field = NULL, $order = 'ASC', $alias = '', $params = array()) { + public function add_orderby($table, $field = NULL, $order = 'ASC', $alias = '', $params = array()) { // Only ensure the table if it's not the special random key. - // @todo: Maybe it would make sense to just add a add_orderby_rand or something similar. + // @todo Maybe it would make sense to just add a add_orderby_rand or + // something similar. if ($table && $table != 'rand') { $this->ensure_table($table); } - // Only fill out this aliasing if there is a table; - // otherwise we assume it is a formula. + // Only fill out this aliasing if there is a table; otherwise we assume it + // is a formula. if (!$alias && $table) { $as = $table . '_' . $field; } @@ -1046,27 +1064,17 @@ class views_plugin_query_default extends views_plugin_query { $this->orderby[] = array( 'field' => $as, - 'direction' => strtoupper($order) + 'direction' => strtoupper($order), ); - - /** - * -- removing, this should be taken care of by field adding now. - * -- leaving commented because I am unsure. - // If grouping, all items in the order by must also be in the - // group by clause. Check $table to ensure that this is not a - // formula. - if ($this->groupby && $table) { - $this->add_groupby($as); - } - */ } /** - * Add a simple GROUP BY clause to the query. The caller is responsible - * for ensuring that the fields are fully qualified and the table is properly - * added. + * Add a simple GROUP BY clause to the query. + * + * The caller is responsible for ensuring that the fields are fully qualified + * and the table is properly added. */ - function add_groupby($clause) { + public function add_groupby($clause) { // Only add it if it's not already in there. if (!in_array($clause, $this->groupby)) { $this->groupby[] = $clause; @@ -1078,7 +1086,7 @@ class views_plugin_query_default extends views_plugin_query { * * @see views_plugin_query_default::add_field() */ - function get_field_alias($table_alias, $field) { + public function get_field_alias($table_alias, $field) { return isset($this->field_aliases[$table_alias][$field]) ? $this->field_aliases[$table_alias][$field] : FALSE; } @@ -1087,14 +1095,14 @@ class views_plugin_query_default extends views_plugin_query { * * @see SelectQuery::addTag() */ - function add_tag($tag) { + public function add_tag($tag) { $this->tags[] = $tag; } /** * Generates a unique placeholder used in the db query. */ - function placeholder($base = 'views') { + public function placeholder($base = 'views') { static $placeholders = array(); if (!isset($placeholders[$base])) { $placeholders[$base] = 0; @@ -1113,10 +1121,10 @@ class views_plugin_query_default extends views_plugin_query { * There is other code in filters which makes sure that the group IDs are * higher than zero. * - * @param $where - * 'where' or 'having'. + * @param string $where + * Either 'where' or 'having'. */ - function build_condition($where = 'where') { + public function build_condition($where = 'where') { $has_condition = FALSE; $has_arguments = FALSE; $has_filter = FALSE; @@ -1130,8 +1138,9 @@ class views_plugin_query_default extends views_plugin_query { $sub_group = $info['type'] == 'OR' ? db_or() : db_and(); foreach ($info['conditions'] as $key => $clause) { // DBTNG doesn't support to add the same subquery twice to the main - // query and the count query, so clone the subquery to have two instances - // of the same object. - http://drupal.org/node/1112854 + // query and the count query, so clone the subquery to have two + // instances of the same object. + // @see http://drupal.org/node/1112854 if (is_object($clause['value']) && $clause['value'] instanceof SelectQuery) { $clause['value'] = clone $clause['value']; } @@ -1172,7 +1181,7 @@ class views_plugin_query_default extends views_plugin_query { /** * Build fields array. */ - function compile_fields($fields_array, $query) { + public function compile_fields($fields_array, $query) { $non_aggregates = array(); foreach ($fields_array as $field) { $string = ''; @@ -1187,7 +1196,7 @@ class views_plugin_query_default extends views_plugin_query { } if (!empty($field['count'])) { - // Retained for compatibility + // Retained for compatibility. $field['function'] = 'count'; // It seems there's no way to abstract the table+column reference // without adding a field, aliasing, and then using the alias. @@ -1205,7 +1214,9 @@ class views_plugin_query_default extends views_plugin_query { } // This is a formula, using no tables. elseif (empty($field['table'])) { - $non_aggregates[] = $fieldname; + if (!in_array($fieldname, $non_aggregates)) { + $non_aggregates[] = $fieldname; + } $placeholders = !empty($field['placeholders']) ? $field['placeholders'] : array(); $query->addExpression($string, $fieldname, $placeholders); } @@ -1213,14 +1224,19 @@ class views_plugin_query_default extends views_plugin_query { elseif ($this->distinct && !in_array($fieldname, $this->groupby)) { // d7cx: This code was there, apparently needed for PostgreSQL // $string = db_driver() == 'pgsql' ? "FIRST($string)" : $string; + if (!in_array($string, $non_aggregates)) { + $non_aggregates[] = $string; + } $query->addField(!empty($field['table']) ? $field['table'] : $this->base_table, $field['field'], $fieldname); } elseif (empty($field['aggregate'])) { - $non_aggregates[] = $fieldname; + if (!in_array($string, $non_aggregates)) { + $non_aggregates[] = $string; + } $query->addField(!empty($field['table']) ? $field['table'] : $this->base_table, $field['field'], $fieldname); } - // @TODO Remove this old code. + // @todo Remove this old code. if (!empty($field['distinct']) && empty($field['function'])) { $distinct[] = $string; } @@ -1242,23 +1258,25 @@ class views_plugin_query_default extends views_plugin_query { * Generate a query and a countquery from all of the information supplied * to the object. * - * @param $get_count + * @param bool $get_count * Provide a countquery if this is true, otherwise provide a normal query. + * + * @return SelectQuery + * A SelectQuery object. */ - function query($get_count = FALSE) { + public function query($get_count = FALSE) { // Check query distinct value. if (empty($this->no_distinct) && $this->distinct && !empty($this->fields)) { - if ($this->pure_distinct === FALSE){ + if ($this->pure_distinct === FALSE) { $base_field_alias = $this->add_field($this->base_table, $this->base_field); $this->add_groupby($base_field_alias); } $distinct = TRUE; } - /** - * An optimized count query includes just the base field instead of all the fields. - * Determine of this query qualifies by checking for a groupby or distinct. - */ + // An optimized count query includes just the base field instead of all the + // fields. Determine of this query qualifies by checking for a groupby or + // distinct. $fields_array = $this->fields; if ($get_count && !$this->groupby) { foreach ($fields_array as $field) { @@ -1278,18 +1296,18 @@ class views_plugin_query_default extends views_plugin_query { $options = array(); $target = 'default'; $key = 'default'; - // Detect an external database and set the + // Detect an external database and set the. if (isset($this->view->base_database)) { $key = $this->view->base_database; } - // Set the slave target if the slave option is set + // Set the slave target if the slave option is set. if (!empty($this->options['slave'])) { $target = 'slave'; } - // Go ahead and build the query. - // db_select doesn't support to specify the key, so use getConnection directly. + // Go ahead and build the query. db_select doesn't support to specify the + // key, so use getConnection directly. $query = Database::getConnection($target, $key) ->select($this->base_table, $this->base_table, $options) ->addTag('views') @@ -1322,6 +1340,10 @@ class views_plugin_query_default extends views_plugin_query { if (count($this->having)) { $this->has_aggregate = TRUE; } + elseif (!$this->has_aggregate) { + // Allow 'GROUP BY' even no aggregation function has been set. + $this->has_aggregate = $this->view->display_handler->get_option('group_by'); + } if ($this->has_aggregate && (!empty($this->groupby) || !empty($non_aggregates))) { $groupby = array_unique(array_merge($this->groupby, $non_aggregates)); foreach ($groupby as $field) { @@ -1333,7 +1355,7 @@ class views_plugin_query_default extends views_plugin_query { } if (!$this->get_count_optimized) { - // we only add the orderby if we're not counting. + // We only add the orderby if we're not counting. if ($this->orderby) { foreach ($this->orderby as $order) { if ($order['field'] == 'rand_') { @@ -1363,12 +1385,12 @@ class views_plugin_query_default extends views_plugin_query { } // Add all query substitutions as metadata. - $query->addMetaData('views_substitutions', module_invoke_all('views_query_substitutions', $this)); + $query->addMetaData('views_substitutions', module_invoke_all('views_query_substitutions', $this->view)); if (!$get_count) { if (!empty($this->limit) || !empty($this->offset)) { - // We can't have an offset without a limit, so provide a very large limit - // instead. + // We can't have an offset without a limit, so provide a very large + // limit instead. $limit = intval(!empty($this->limit) ? $this->limit : 999999); $offset = intval(!empty($this->offset) ? $this->offset : 0); $query->range($offset, $limit); @@ -1381,7 +1403,7 @@ class views_plugin_query_default extends views_plugin_query { /** * Get the arguments attached to the WHERE and HAVING clauses of this query. */ - function get_where_args() { + public function get_where_args() { $args = array(); foreach ($this->where as $group => $where) { $args = array_merge($args, $where['args']); @@ -1395,7 +1417,7 @@ class views_plugin_query_default extends views_plugin_query { /** * Let modules modify the query just prior to finalizing it. */ - function alter(&$view) { + public function alter(&$view) { foreach (module_implements('views_query_alter') as $module) { $function = $module . '_views_query_alter'; $function($view, $this); @@ -1405,7 +1427,7 @@ class views_plugin_query_default extends views_plugin_query { /** * Builds the necessary info to execute the query. */ - function build(&$view) { + public function build(&$view) { // Make the query distinct if the option was set. if (!empty($this->options['distinct'])) { $this->set_distinct(TRUE, !empty($this->options['pure_distinct'])); @@ -1430,8 +1452,9 @@ class views_plugin_query_default extends views_plugin_query { * Values to set: $view->result, $view->total_rows, $view->execute_time, * $view->current_page. */ - function execute(&$view) { - $external = FALSE; // Whether this query will run against an external database. + public function execute(&$view) { + // Whether this query will run against an external database. + $external = FALSE; $query = $view->build_info['query']; $count_query = $view->build_info['count_query']; @@ -1455,9 +1478,9 @@ class views_plugin_query_default extends views_plugin_query { // If not, then hook_query_node_access_alter() may munge the count by // adding a distinct against an empty query string // (e.g. COUNT DISTINCT(1) ...) and no pager will return. - // See pager.inc > PagerDefault::execute() - // http://api.drupal.org/api/drupal/includes--pager.inc/function/PagerDefault::execute/7 - // See http://drupal.org/node/1046170. + // @see pager.inc > PagerDefault::execute() + // @see http://api.drupal.org/api/drupal/includes--pager.inc/function/PagerDefault::execute/7 + // @see http://drupal.org/node/1046170. $count_query->preExecute(); // Build the count query. @@ -1473,7 +1496,6 @@ class views_plugin_query_default extends views_plugin_query { $start = microtime(TRUE); - try { if ($this->pager->use_count_query() || !empty($view->get_total_rows)) { $this->pager->execute_count_query($count_query); @@ -1511,12 +1533,18 @@ class views_plugin_query_default extends views_plugin_query { $view->execute_time = microtime(TRUE) - $start; } - function add_signature(&$view) { + /** + * + */ + public function add_signature(&$view) { $view->query->add_field(NULL, "'" . $view->name . ':' . $view->current_display . "'", 'view_name'); } - function get_aggregation_info() { - // @todo -- need a way to get database specific and customized aggregation + /** + * + */ + public function get_aggregation_info() { + // @todo Need a way to get database specific and customized aggregation // functions into here. return array( 'group' => array( @@ -1587,15 +1615,14 @@ class views_plugin_query_default extends views_plugin_query { 'filter' => 'views_handler_filter_group_by_numeric', 'sort' => 'views_handler_sort_group_by_numeric', ), - ) - ); + ), + ) + views_fetch_plugin_data('query_aggregate'); } /** * Returns the according entity objects for the given query results. - * */ - function get_result_entities($results, $relationship = NULL) { + public function get_result_entities($results, $relationship = NULL) { $base_table = $this->base_table; $base_table_alias = $base_table; @@ -1616,7 +1643,8 @@ class views_plugin_query_default extends views_plugin_query { } $entity_type = $table_data['table']['entity type']; $info = entity_get_info($entity_type); - $id_alias = $this->get_field_alias($base_table_alias, $info['entity keys']['id']); + $is_revision = !empty($table_data['table']['revision']); + $id_alias = $this->get_field_alias($base_table_alias, $info['entity keys'][$is_revision ? 'revision' : 'id']); // Assemble the ids of the entities to load. $ids = array(); @@ -1626,20 +1654,49 @@ class views_plugin_query_default extends views_plugin_query { } } - $entities = entity_load($entity_type, $ids); - // Re-key the array by row-index. - $result = array(); - foreach ($ids as $key => $id) { - $result[$key] = isset($entities[$id]) ? $entities[$id] : FALSE; + if (!$is_revision) { + $entities = entity_load($entity_type, $ids); + + // Re-key the array by row-index. + $result = array(); + foreach ($ids as $key => $id) { + $result[$key] = isset($entities[$id]) ? $entities[$id] : FALSE; + } } + else { + // There's no way in core to load revisions in bulk. + $result = array(); + foreach ($ids as $key => $id) { + // Nodes can be dealt with in core. + if ($entity_type == 'node') { + $result[$key] = node_load(NULL, $id); + } + // Otherwise see if entity is enabled. + elseif (module_exists('entity')) { + $result[$key] = entity_revision_load($entity_type, $id); + } + else { + // Otherwise this isn't supported. + watchdog('views', 'Attempt to load a revision on an unsupported entity type @entity_type.', array('@entity_type' => $entity_type), WATCHDOG_WARNING); + } + } + } + return array($entity_type, $result); } + } +/** + * + */ function views_query_default_aggregation_method_simple($group_type, $field) { return strtoupper($group_type) . '(' . $field . ')'; } +/** + * + */ function views_query_default_aggregation_method_distinct($group_type, $field) { $group_type = str_replace('_distinct', '', $group_type); return strtoupper($group_type) . '(DISTINCT ' . $field . ')'; diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_row.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_row.inc index 157cc26..833a675 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_row.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_row.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the base row style plugin. + * Definition of views_plugin_row. */ /** @@ -17,14 +17,15 @@ */ /** - * Default plugin to view a single row of a table. This is really just a wrapper around - * a theme function. + * Default plugin to view a single row of a table. This is really just a wrapper + * around a theme function. */ class views_plugin_row extends views_plugin { + /** - * Initialize the row plugin. + * {@inheritdoc} */ - function init(&$view, &$display, $options = NULL) { + public function init(&$view, &$display, $options = NULL) { $this->view = &$view; $this->display = &$display; @@ -32,12 +33,17 @@ class views_plugin_row extends views_plugin { $this->unpack_options($this->options, isset($options) ? $options : $display->handler->get_option('row_options')); } - function uses_fields() { + /** + * {@inheritdoc} + */ + public function uses_fields() { return !empty($this->definition['uses fields']); } - - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); if (isset($this->base_table)) { $options['relationship'] = array('default' => 'none'); @@ -49,7 +55,7 @@ class views_plugin_row extends views_plugin { /** * Provide a form for setting options. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); if (isset($this->base_table)) { $view = &$form_state['view']; @@ -98,15 +104,20 @@ class views_plugin_row extends views_plugin { /** * Validate the options form. */ - function options_validate(&$form, &$form_state) { } + public function options_validate(&$form, &$form_state) { + } /** * Perform any necessary changes to the form values prior to storage. * There is no need for this function to actually store the data. */ - function options_submit(&$form, &$form_state) { } + public function options_submit(&$form, &$form_state) { + } - function query() { + /** + * {@inheritdoc} + */ + public function query() { if (isset($this->base_table)) { if (isset($this->options['relationship']) && isset($this->view->relationship[$this->options['relationship']])) { $relationship = $this->view->relationship[$this->options['relationship']]; @@ -121,10 +132,11 @@ class views_plugin_row extends views_plugin { /** * Allow the style to do stuff before each row is rendered. * - * @param $result + * @param array $result * The full array of results from the query. */ - function pre_render($result) { } + public function pre_render($result) { + } /** * Render a row object. This usually passes through to a theme template @@ -136,7 +148,7 @@ class views_plugin_row extends views_plugin { * @return string * The rendered output of a single row, used by the style plugin. */ - function render($row) { + public function render($row) { return theme($this->theme_functions(), array( 'view' => $this->view, @@ -145,6 +157,7 @@ class views_plugin_row extends views_plugin { 'field_alias' => isset($this->field_alias) ? $this->field_alias : '', )); } + } /** diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_row_fields.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_row_fields.inc index b1c02e1..edc854c 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_row_fields.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_row_fields.inc @@ -2,11 +2,11 @@ /** * @file - * Contains the base row style plugin. + * Definition of views_plugin_row_fields. */ /** - * The basic 'fields' row plugin + * The basic 'fields' row plugin. * * This displays fields one after another, giving options for inline * or not. @@ -14,7 +14,11 @@ * @ingroup views_row_plugins */ class views_plugin_row_fields extends views_plugin_row { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['inline'] = array('default' => array()); @@ -27,7 +31,7 @@ class views_plugin_row_fields extends views_plugin_row { /** * Provide a form for setting options. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $options = $this->display->handler->get_field_labels(); @@ -80,7 +84,8 @@ class views_plugin_row_fields extends views_plugin_row { * Perform any necessary changes to the form values prior to storage. * There is no need for this function to actually store the data. */ - function options_submit(&$form, &$form_state) { + public function options_submit(&$form, &$form_state) { $form_state['values']['row_options']['inline'] = array_filter($form_state['values']['row_options']['inline']); } + } diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_row_rss_fields.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_row_rss_fields.inc index 9355e83..4af7c9f 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_row_rss_fields.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_row_rss_fields.inc @@ -1,14 +1,19 @@ ''); $options['link_field'] = array('default' => ''); @@ -20,7 +25,10 @@ class views_plugin_row_rss_fields extends views_plugin_row { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $initial_labels = array('' => t('- None -')); @@ -89,7 +97,10 @@ class views_plugin_row_rss_fields extends views_plugin_row { ); } - function validate() { + /** + * + */ + public function validate() { $errors = parent::validate(); $required_options = array('title_field', 'link_field', 'description_field', 'creator_field', 'date_field'); foreach ($required_options as $required_option) { @@ -105,7 +116,10 @@ class views_plugin_row_rss_fields extends views_plugin_row { return $errors; } - function render($row) { + /** + * {@inheritdoc} + */ + public function render($row) { static $row_index; if (!isset($row_index)) { $row_index = 0; @@ -165,12 +179,12 @@ class views_plugin_row_rss_fields extends views_plugin_row { /** * Retrieves a views field value from the style plugin. * - * @param $index - * The index count of the row as expected by views_plugin_style::get_field(). - * @param $field_id + * @param int $index + * The index of the row as expected by views_plugin_style::get_field(). + * @param string $field_id * The ID assigned to the required field in the display. */ - function get_field($index, $field_id) { + public function get_field($index, $field_id) { if (empty($this->view->style_plugin) || !is_object($this->view->style_plugin) || empty($field_id)) { return ''; } diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_style.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_style.inc index d355e1b..6f3cf34 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_style.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_style.inc @@ -8,13 +8,13 @@ /** * @defgroup views_style_plugins Views style plugins * @{ - * Style plugins control how a view is rendered. For example, they - * can choose to display a collection of fields, node_view() output, - * table output, or any kind of crazy output they want. + * Style plugins control how a view is rendered. For example, they can choose to + * display a collection of fields, node_view() output, table output, or any kind + * of crazy output they want. * - * Many style plugins can have an optional 'row' plugin, that displays - * a single record. Not all style plugins can utilize this, so it is - * up to the plugin to set this up and call through to the row plugin. + * Many style plugins can have an optional 'row' plugin, that displays a single + * record. Not all style plugins can utilize this, so it is up to the plugin to + * set this up and call through to the row plugin. * * @see hook_views_plugins() */ @@ -23,29 +23,29 @@ * Base class to define a style plugin handler. */ class views_plugin_style extends views_plugin { + /** * Store all available tokens row rows. */ - var $row_tokens = array(); + public $row_tokens = array(); /** - * Contains the row plugin, if it's initialized - * and the style itself supports it. + * The row plugin, if it's initialized and the style itself supports it. * * @var views_plugin_row */ - var $row_plugin; + public $row_plugin; /** * Initialize a style plugin. * - * @param $view - * @param $display - * @param $options + * @param view $view + * @param object $display + * @param array $options * The style options might come externally as the style can be sourced * from at least two locations. If it's not included, look on the display. */ - function init(&$view, &$display, $options = NULL) { + public function init(&$view, &$display, $options = NULL) { $this->view = &$view; $this->display = &$display; @@ -65,7 +65,10 @@ class views_plugin_style extends views_plugin { ); } - function destroy() { + /** + * + */ + public function destroy() { parent::destroy(); if (isset($this->row_plugin)) { @@ -76,14 +79,14 @@ class views_plugin_style extends views_plugin { /** * Return TRUE if this style also uses a row plugin. */ - function uses_row_plugin() { + public function uses_row_plugin() { return !empty($this->definition['uses row plugin']); } /** * Return TRUE if this style also uses a row plugin. */ - function uses_row_class() { + public function uses_row_class() { return !empty($this->definition['uses row class']); } @@ -92,7 +95,7 @@ class views_plugin_style extends views_plugin { * * @return bool */ - function uses_fields() { + public function uses_fields() { // If we use a row plugin, ask the row plugin. Chances are, we don't // care, it does. $row_uses_fields = FALSE; @@ -108,7 +111,7 @@ class views_plugin_style extends views_plugin { * * Used to ensure we don't fetch tokens when not needed for performance. */ - function uses_tokens() { + public function uses_tokens() { if ($this->uses_row_class()) { $class = $this->options['row_class']; if (strpos($class, '[') !== FALSE || strpos($class, '!') !== FALSE || strpos($class, '%') !== FALSE) { @@ -120,14 +123,24 @@ class views_plugin_style extends views_plugin { /** * Return the token replaced row class for the specified row. */ - function get_row_class($row_index) { + public function get_row_class($row_index) { if ($this->uses_row_class()) { $class = $this->options['row_class']; + if ($this->uses_fields() && $this->view->field) { - $class = strip_tags($this->tokenize_value($class, $row_index)); + $classes = array(); + + // Explode the value by whitespace, this allows the function to handle + // a single class name and multiple class names that are then tokenized. + foreach (explode(' ', $class) as $token_class) { + $classes = array_merge($classes, explode(' ', strip_tags($this->tokenize_value($token_class, $row_index)))); + } + } + else { + $classes = explode(' ', $class); } - $classes = explode(' ', $class); + // Convert whatever the result is to a nice clean class name foreach ($classes as &$class) { $class = drupal_clean_css_identifier($class); } @@ -138,7 +151,7 @@ class views_plugin_style extends views_plugin { /** * Take a value and apply token replacement logic to it. */ - function tokenize_value($value, $row_index) { + public function tokenize_value($value, $row_index) { if (strpos($value, '[') !== FALSE || strpos($value, '!') !== FALSE || strpos($value, '%') !== FALSE) { $fake_item = array( 'alter_text' => TRUE, @@ -160,13 +173,16 @@ class views_plugin_style extends views_plugin { } /** - * Should the output of the style plugin be rendered even if it's a empty view. + * Should the output of the style plugin be rendered even if it's empty. */ - function even_empty() { + public function even_empty() { return !empty($this->definition['even empty']); } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['grouping'] = array('default' => array()); if ($this->uses_row_class()) { @@ -179,19 +195,23 @@ class views_plugin_style extends views_plugin { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); - // Only fields-based views can handle grouping. Style plugins can also exclude - // themselves from being groupable by setting their "use grouping" definiton - // key to FALSE. - // @TODO: Document "uses grouping" in docs.php when docs.php is written. + // Only fields-based views can handle grouping. Style plugins can also + // exclude themselves from being groupable by setting their "use grouping" + // definition key to FALSE. + // @todo Document "uses grouping" in docs.php when docs.php is written. if ($this->uses_fields() && $this->definition['uses grouping']) { $options = array('' => t('- None -')); $field_labels = $this->display->handler->get_field_labels(TRUE); $options += $field_labels; // If there are no fields, we can't group on them. if (count($options) > 1) { - // This is for backward compability, when there was just a single select form. + // This is for backward compatibility, when there was just a single + // select form. if (is_string($this->options['grouping'])) { $grouping = $this->options['grouping']; $this->options['grouping'] = array(); @@ -227,6 +247,7 @@ class views_plugin_style extends views_plugin { '#type' => 'checkbox', '#title' => t('Remove tags from rendered output'), '#default_value' => $grouping['rendered_strip'], + '#description' => t('Some modules add HTML to the rendered output and prevent the rows from grouping correctly. Stripping the HTML tags should correct this.'), '#dependency' => array( 'edit-style-options-grouping-' . $i . '-field' => array_keys($field_labels), ) @@ -271,7 +292,10 @@ class views_plugin_style extends views_plugin { } } - function options_validate(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_validate(&$form, &$form_state) { // Don't run validation on style plugins without the grouping setting. if (isset($form_state['values']['style_options']['grouping'])) { // Don't save grouping if no field is specified. @@ -288,21 +312,24 @@ class views_plugin_style extends views_plugin { * interfere with the sorts. If so it should build; if it returns * any non-TRUE value, normal sorting will NOT be added to the query. */ - function build_sort() { return TRUE; } + public function build_sort() { + return TRUE; + } /** * Called by the view builder to let the style build a second set of * sorts that will come after any other sorts in the view. */ - function build_sort_post() { } + public function build_sort_post() { + } /** * Allow the style to do stuff before each row is rendered. * - * @param $result + * @param array $result * The full array of results from the query. */ - function pre_render($result) { + public function pre_render($result) { if (!empty($this->row_plugin)) { $this->row_plugin->pre_render($result); } @@ -311,7 +338,7 @@ class views_plugin_style extends views_plugin { /** * Render the display in this style. */ - function render() { + public function render() { if ($this->uses_row_plugin() && empty($this->row_plugin)) { debug('views_plugin_style_default: Missing row plugin'); return; @@ -333,15 +360,15 @@ class views_plugin_style extends views_plugin { * Plugins may override this method if they wish some other way of handling * grouping. * - * @param $sets + * @param array $sets * Array containing the grouping sets to render. - * @param $level + * @param int $level * Integer indicating the hierarchical level of the grouping. * * @return string * Rendered output of given grouping sets. */ - function render_grouping_sets($sets, $level = 0) { + public function render_grouping_sets($sets, $level = 0) { $output = ''; foreach ($sets as $set) { $row = reset($set['rows']); @@ -382,18 +409,19 @@ class views_plugin_style extends views_plugin { /** * Group records as needed for rendering. * - * @param $records + * @param array $records * An array of records from the view to group. - * @param $groupings + * @param array $groupings * An array of grouping instructions on which fields to group. If empty, the * result set will be given a single group with an empty string as a label. - * @param $group_rendered + * @param bool $group_rendered * Boolean value whether to use the rendered or the raw field value for * grouping. If set to NULL the return is structured as before * Views 7.x-3.0-rc2. After Views 7.x-3.0 this boolean is only used if * $groupings is an old-style string or if the rendered option is missing * for a grouping instruction. - * @return + * + * @return array * The grouped record set. * A nested set structure is generated if multiple grouping fields are used. * @@ -418,9 +446,9 @@ class views_plugin_style extends views_plugin { * ) * @endcode */ - function render_grouping($records, $groupings = array(), $group_rendered = NULL) { - // This is for backward compability, when $groupings was a string containing - // the ID of a single field. + public function render_grouping($records, $groupings = array(), $group_rendered = NULL) { + // This is for backward compatibility, when $groupings was a string + // containing the ID of a single field. if (is_string($groupings)) { $rendered = $group_rendered === NULL ? TRUE : $group_rendered; $groupings = array(array('field' => $groupings, 'rendered' => $rendered)); @@ -471,10 +499,12 @@ class views_plugin_style extends views_plugin { $set[$grouping]['rows'] = array(); } - // Move the set reference into the row set of the group we just determined. + // Move the set reference into the row set of the group we just + // determined. $set = &$set[$grouping]['rows']; } - // Add the row to the hierarchically positioned row set we just determined. + // Add the row to the hierarchically positioned row set we just + // determined. $set[$index] = $row; } } @@ -486,9 +516,9 @@ class views_plugin_style extends views_plugin { ); } - // If this parameter isn't explicitely set modify the output to be fully + // If this parameter isn't explicitly set modify the output to be fully // backward compatible to code before Views 7.x-3.0-rc2. - // @TODO Remove this as soon as possible e.g. October 2020 + // @todo Remove this as soon as possible e.g. October 2020 if ($group_rendered === NULL) { $old_style_sets = array(); foreach ($sets as $group) { @@ -503,10 +533,10 @@ class views_plugin_style extends views_plugin { /** * Render all of the fields for a given style and store them on the object. * - * @param $result + * @param array $result * The result array from $view->result */ - function render_fields($result) { + public function render_fields($result) { if (!$this->uses_fields()) { return; } @@ -537,12 +567,12 @@ class views_plugin_style extends views_plugin { /** * Get a rendered field. * - * @param $index + * @param int $index * The index count of the row. - * @param $field + * @param string $field * The id of the field. */ - function get_field($index, $field) { + public function get_field($index, $field) { if (!isset($this->rendered_fields)) { $this->render_fields($this->view->result); } @@ -555,19 +585,22 @@ class views_plugin_style extends views_plugin { /** * Get the raw field value. * - * @param $index + * @param int $index * The index count of the row. - * @param $field + * @param string $field * The id of the field. */ - function get_field_value($index, $field) { + public function get_field_value($index, $field) { $this->view->row_index = $index; $value = $this->view->field[$field]->get_value($this->view->result[$index]); unset($this->view->row_index); return $value; } - function validate() { + /** + * {@inheritdoc} + */ + public function validate() { $errors = parent::validate(); if ($this->uses_row_plugin()) { @@ -585,12 +618,16 @@ class views_plugin_style extends views_plugin { return $errors; } - function query() { + /** + * {@inheritdoc} + */ + public function query() { parent::query(); if (isset($this->row_plugin)) { $this->row_plugin->query(); } } + } /** diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_style_default.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_style_default.inc index a18f6cc..131b991 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_style_default.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_style_default.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the default style plugin. + * Definition of views_plugin_style_default. */ /** @@ -12,14 +12,19 @@ * @ingroup views_style_plugins */ class views_plugin_style_default extends views_plugin_style { + /** - * Set default options + * Set default options. */ - function options(&$options) { + public function options(&$options) { parent::options($options); } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); } + } diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_style_grid.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_style_grid.inc index a2e4375..ffa4cf0 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_style_grid.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_style_grid.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the grid style plugin. + * Definition of views_plugin_style_grid. */ /** @@ -11,10 +11,11 @@ * @ingroup views_style_plugins */ class views_plugin_style_grid extends views_plugin_style { + /** - * Set default options + * Set default options. */ - function option_definition() { + public function option_definition() { $options = parent::option_definition(); $options['columns'] = array('default' => '4'); @@ -29,7 +30,7 @@ class views_plugin_style_grid extends views_plugin_style { /** * Render the given style. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['columns'] = array( '#type' => 'textfield', @@ -67,4 +68,5 @@ class views_plugin_style_grid extends views_plugin_style { '#default_value' => $this->options['summary'], ); } + } diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_style_jump_menu.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_style_jump_menu.inc index 1de90f7..3d83ea3 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_style_jump_menu.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_style_jump_menu.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the table style plugin. + * Definition of views_plugin_style_jump_menu. */ /** @@ -11,7 +11,11 @@ * @ingroup views_style_plugins */ class views_plugin_style_jump_menu extends views_plugin_style { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['hide'] = array('default' => FALSE, 'bool' => TRUE); @@ -28,7 +32,7 @@ class views_plugin_style_jump_menu extends views_plugin_style { /** * Render the given style. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $handlers = $this->display->handler->get_handlers('field'); if (empty($handlers)) { @@ -103,7 +107,7 @@ class views_plugin_style_jump_menu extends views_plugin_style { * * This is overridden so that we can render our grouping specially. */ - function render() { + public function render() { $sets = $this->render_grouping($this->view->result, $this->options['grouping']); // Turn this all into an $options array for the jump menu. @@ -122,8 +126,8 @@ class views_plugin_style_jump_menu extends views_plugin_style { $path = drupal_substr($path, drupal_strlen($base_path)); } - // use drupal_parse_url() to preserve query and fragment in case the user - // wants to do fun tricks. + // Use drupal_parse_url() to preserve query and fragment in case the + // user wants to do fun tricks. $url_options = drupal_parse_url($path); $path = url($url_options['path'], $url_options); @@ -144,9 +148,9 @@ class views_plugin_style_jump_menu extends views_plugin_style { $default_value = ''; if ($this->options['default_value']) { $lookup_options = array(); - // We need to check if the path is absolute - // or else language is not taken in account. - if ($this->view->display[$this->view->current_display]->display_options['fields'][$this->options['path']]['absolute']) { + // We need to check if the path is absolute or else language is not taken + // in account. + if (!empty($this->view->display[$this->view->current_display]->display_options['fields'][$this->options['path']]['absolute'])) { $lookup_options['absolute'] = TRUE; } $lookup_url = url($_GET['q'], $lookup_options); @@ -169,8 +173,12 @@ class views_plugin_style_jump_menu extends views_plugin_style { return $form; } - function render_set($title, $records) { + /** + * + */ + public function render_set($title, $records) { $options = array(); $fields = $this->rendered_fields; } + } diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_style_list.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_style_list.inc index 2a1dadb..7c8417f 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_style_list.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_style_list.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the list style plugin. + * Definition of views_plugin_style_list. */ /** @@ -11,10 +11,11 @@ * @ingroup views_style_plugins */ class views_plugin_style_list extends views_plugin_style { + /** - * Set default options + * Set default options. */ - function option_definition() { + public function option_definition() { $options = parent::option_definition(); $options['type'] = array('default' => 'ul'); @@ -27,7 +28,7 @@ class views_plugin_style_list extends views_plugin_style { /** * Render the given style. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['type'] = array( '#type' => 'radios', @@ -50,4 +51,5 @@ class views_plugin_style_list extends views_plugin_style { '#default_value' => $this->options['class'], ); } + } diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_style_mapping.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_style_mapping.inc index fb60a03..29ecebc 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_style_mapping.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_style_mapping.inc @@ -27,9 +27,9 @@ abstract class views_plugin_style_mapping extends views_plugin_style { abstract protected function define_mapping(); /** - * Overrides views_plugin_style::option_definition(). + * {@inheritdoc} */ - function option_definition() { + public function option_definition() { $options = parent::option_definition(); // Parse the mapping and add a default for each. @@ -50,9 +50,9 @@ abstract class views_plugin_style_mapping extends views_plugin_style { } /** - * Overrides views_plugin_style::options_form(). + * {@inheritdoc} */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); // Get the mapping. @@ -84,7 +84,8 @@ abstract class views_plugin_style_mapping extends views_plugin_style { // Optionally filter the available fields. if (isset($mapping[$key]['#filter'])) { $this->view->init_handlers(); - $this::$mapping[$key]['#filter']($field_options); + $filter = $mapping[$key]['#filter']; + $this::$filter($field_options); unset($mapping[$key]['#filter']); } @@ -109,11 +110,10 @@ abstract class views_plugin_style_mapping extends views_plugin_style { } /** - * Overrides views_plugin_style::render(). - * - * Provides the mapping definition as an available variable. + * {@inheritdoc} */ - function render() { + public function render() { + // Provides the mapping definition as an available variable. return theme($this->theme_functions(), array( 'view' => $this->view, 'options' => $this->options, diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_style_rss.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_style_rss.inc index 27106a8..0092ea4 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_style_rss.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_style_rss.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the RSS style plugin. + * Definition of views_plugin_style_rss. */ /** @@ -11,7 +11,11 @@ * @ingroup views_style_plugins */ class views_plugin_style_rss extends views_plugin_style { - function attach_to($display_id, $path, $title) { + + /** + * + */ + public function attach_to($display_id, $path, $title) { $display = $this->view->display[$display_id]->handler; $url_options = array(); $input = $this->view->get_exposed_input(); @@ -36,12 +40,15 @@ class views_plugin_style_rss extends views_plugin_style { 'rel' => 'alternate', 'type' => 'application/rss+xml', 'title' => $title, - 'href' => $url + 'href' => $url, )); } } - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['description'] = array('default' => '', 'translatable' => TRUE); @@ -49,7 +56,10 @@ class views_plugin_style_rss extends views_plugin_style { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['description'] = array( @@ -67,17 +77,47 @@ class views_plugin_style_rss extends views_plugin_style { * @return * An array that can be passed to format_xml_elements(). */ - function get_channel_elements() { + public function get_channel_elements() { return array(); } + /** + * Return an atom:link XHTML element to add to the channel to comply with + * the RSS 2.0 specification. + * + * @see http://validator.w3.org/feed/docs/warning/MissingAtomSelfLink.html + * + * @return + * An array that can be passed to format_xml_elements(). + */ + public function get_channel_elements_atom_link() { + $url_options = array('absolute' => TRUE); + $input = $this->view->get_exposed_input(); + if ($input) { + $url_options['query'] = $input; + } + $url = url($this->view->get_url(), $url_options); + + return array( + array( + 'namespace' => array('xmlns:atom' => 'http://www.w3.org/2005/Atom'), + 'key' => 'atom:link', + 'attributes' => array( + 'href' => $url, + 'rel' => 'self', + 'type' => 'application/rss+xml', + ), + ), + ); + } + /** * Get RSS feed description. * * @return string * The string containing the description with the tokens replaced. */ - function get_description() { + public function get_description() { $description = $this->options['description']; // Allow substitutions from the first row. @@ -86,7 +126,10 @@ class views_plugin_style_rss extends views_plugin_style { return $description; } - function render() { + /** + * {@inheritdoc} + */ + public function render() { if (empty($this->row_plugin)) { vpr('views_plugin_style_default: Missing row plugin'); return; @@ -99,7 +142,10 @@ class views_plugin_style_rss extends views_plugin_style { // Fetch any additional elements for the channel and merge in their // namespaces. - $this->channel_elements = $this->get_channel_elements(); + $this->channel_elements = array_merge( + $this->get_channel_elements(), + $this->get_channel_elements_atom_link() + ); foreach ($this->channel_elements as $element) { if (isset($element['namespace'])) { $this->namespaces = array_merge($this->namespaces, $element['namespace']); @@ -115,9 +161,10 @@ class views_plugin_style_rss extends views_plugin_style { array( 'view' => $this->view, 'options' => $this->options, - 'rows' => $rows + 'rows' => $rows, )); unset($this->view->row_index); return $output; } + } diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_style_summary.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_style_summary.inc index 5081dd6..02e8973 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_style_summary.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_style_summary.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the default summary style plugin, which displays items in an HTML list. + * Definition of views_plugin_style_summary. */ /** @@ -11,7 +11,11 @@ * @ingroup views_style_plugins */ class views_plugin_style_summary extends views_plugin_style { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['base_path'] = array('default' => ''); @@ -22,13 +26,19 @@ class views_plugin_style_summary extends views_plugin_style { return $options; } - function query() { + /** + * {@inheritdoc} + */ + public function query() { if (!empty($this->options['override'])) { $this->view->set_items_per_page(intval($this->options['items_per_page'])); } } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['base_path'] = array( '#type' => 'textfield', '#title' => t('Base path'), @@ -55,22 +65,26 @@ class views_plugin_style_summary extends views_plugin_style { '#title' => t('Items to display'), '#default_value' => $this->options['items_per_page'], '#dependency' => array( - 'edit-options-summary-options-' . str_replace('_', '-', $this->definition['name']) . '-override' => array(1) + 'edit-options-summary-options-' . str_replace('_', '-', $this->definition['name']) . '-override' => array(1), ), ); } - function render() { + /** + * {@inheritdoc} + */ + public function render() { $rows = array(); foreach ($this->view->result as $row) { - // @todo: Include separator as an option. + // @todo Include separator as an option. $rows[] = $row; } return theme($this->theme_functions(), array( 'view' => $this->view, 'options' => $this->options, - 'rows' => $rows + 'rows' => $rows, )); } + } diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_style_summary_jump_menu.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_style_summary_jump_menu.inc index a16a84b..17fdcca 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_style_summary_jump_menu.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_style_summary_jump_menu.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the default summary style plugin, which displays items in an HTML list. + * Definition of views_plugin_style_summary_jump_menu. */ /** @@ -11,7 +11,11 @@ * @ingroup views_style_plugins */ class views_plugin_style_summary_jump_menu extends views_plugin_style { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['base_path'] = array('default' => ''); @@ -26,7 +30,10 @@ class views_plugin_style_summary_jump_menu extends views_plugin_style { return $options; } - function query() { + /** + * {@inheritdoc} + */ + public function query() { // Copy the offset option. $pager = array( 'type' => 'none', @@ -35,7 +42,10 @@ class views_plugin_style_summary_jump_menu extends views_plugin_style { $this->display->handler->set_option('pager', $pager); } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { $form['base_path'] = array( '#type' => 'textfield', '#title' => t('Base path'), @@ -93,7 +103,10 @@ class views_plugin_style_summary_jump_menu extends views_plugin_style { ); } - function render() { + /** + * {@inheritdoc} + */ + public function render() { $argument = $this->view->argument[$this->view->build_info['summary_level']]; $url_options = array(); @@ -143,4 +156,5 @@ class views_plugin_style_summary_jump_menu extends views_plugin_style { $form = drupal_get_form('ctools_jump_menu', $options, $settings); return drupal_render($form); } + } diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_style_summary_unformatted.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_style_summary_unformatted.inc index fc46624..fb16207 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_style_summary_unformatted.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_style_summary_unformatted.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the unformatted summary style plugin. + * Definition of views_plugin_style_summary_unformatted. */ /** @@ -11,14 +11,21 @@ * @ingroup views_style_plugins */ class views_plugin_style_summary_unformatted extends views_plugin_style_summary { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['inline'] = array('default' => FALSE, 'bool' => TRUE); $options['separator'] = array('default' => ''); return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['inline'] = array( '#type' => 'checkbox', @@ -31,4 +38,5 @@ class views_plugin_style_summary_unformatted extends views_plugin_style_summary '#default_value' => $this->options['separator'], ); } + } diff --git a/sites/all/modules/contrib/views/views/plugins/views_plugin_style_table.inc b/sites/all/modules/contrib/views/views/plugins/views_plugin_style_table.inc index 45ed976..75fe389 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_plugin_style_table.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_plugin_style_table.inc @@ -2,7 +2,7 @@ /** * @file - * Contains the table style plugin. + * Definition of views_plugin_style_table. */ /** @@ -24,7 +24,10 @@ class views_plugin_style_table extends views_plugin_style { */ public $order; - function option_definition() { + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['columns'] = array('default' => array()); @@ -45,7 +48,7 @@ class views_plugin_style_table extends views_plugin_style { * * @return bool */ - function build_sort() { + public function build_sort() { if (!isset($_GET['order']) && ($this->options['default'] == -1 || empty($this->view->field[$this->options['default']]))) { return TRUE; } @@ -62,7 +65,7 @@ class views_plugin_style_table extends views_plugin_style { /** * Add our actual sort criteria */ - function build_sort_post() { + public function build_sort_post() { if (!isset($_GET['order'])) { // check for a 'default' clicksort. If there isn't one, exit gracefully. if (empty($this->options['default'])) { @@ -111,10 +114,10 @@ class views_plugin_style_table extends views_plugin_style { * - Any fields not currently represented must be added. * - Columns must be re-ordered to match the fields. * - * @param $columns + * @param array $columns * An array of all fields; the key is the id of the field and the * value is the id of the column the field should be in. - * @param $fields + * @param array $fields * The fields to use for the columns. If not provided, they will * be requested from the current display. The running render should * send the fields through, as they may be different than what the @@ -123,7 +126,7 @@ class views_plugin_style_table extends views_plugin_style { * @return array * An array of all the sanitized columns. */ - function sanitize_columns($columns, $fields = NULL) { + public function sanitize_columns($columns, $fields = NULL) { $sanitized = array(); if ($fields === NULL) { $fields = $this->display->handler->get_option('fields'); @@ -157,7 +160,7 @@ class views_plugin_style_table extends views_plugin_style { /** * Render the given style. */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $handlers = $this->display->handler->get_handlers('field'); if (empty($handlers)) { @@ -202,7 +205,7 @@ class views_plugin_style_table extends views_plugin_style { $columns = $this->sanitize_columns($this->options['columns']); - // Create an array of allowed columns from the data we know: + // Create an array of allowed columns from the data we know. $field_names = $this->display->handler->get_field_labels(); if (isset($this->options['default'])) { @@ -301,7 +304,10 @@ class views_plugin_style_table extends views_plugin_style { ); } - function even_empty() { + /** + * + */ + public function even_empty() { return parent::even_empty() || !empty($this->options['empty_table']); } } diff --git a/sites/all/modules/contrib/views/views/plugins/views_wizard/file_managed.inc b/sites/all/modules/contrib/views/views/plugins/views_wizard/file_managed.inc index 049ce1b..191f9ab 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_wizard/file_managed.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_wizard/file_managed.inc @@ -14,8 +14,7 @@ $plugin = array( 'class' => 'ViewsUiFileManagedViewsWizard', ), 'title' => t('Files'), - 'filters' => array( - ), + 'filters' => array(), 'path_field' => array( 'id' => 'uri', 'table' => 'file_managed', diff --git a/sites/all/modules/contrib/views/views/plugins/views_wizard/node.inc b/sites/all/modules/contrib/views/views/plugins/views_wizard/node.inc index ccca48d..d5b3e3d 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_wizard/node.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_wizard/node.inc @@ -10,7 +10,7 @@ $plugin = array( 'base_table' => 'node', 'created_column' => 'created', 'available_sorts' => array( - 'title:DESC' => t('Title') + 'title:DESC' => t('Title'), ), 'form_wizard_class' => array( 'file' => 'views_ui_node_views_wizard.class.php', diff --git a/sites/all/modules/contrib/views/views/plugins/views_wizard/node_revision.inc b/sites/all/modules/contrib/views/views/plugins/views_wizard/node_revision.inc index ddf1d61..3a9ea64 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_wizard/node_revision.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_wizard/node_revision.inc @@ -17,7 +17,8 @@ $plugin = array( 'filters' => array( 'status' => array( 'value' => '1', - 'table' => 'node', // @todo - unclear if this should be node or node_revision + 'table' => 'node', +// @todo - unclear if this should be node or node_revision 'field' => 'status', ), ), diff --git a/sites/all/modules/contrib/views/views/plugins/views_wizard/taxonomy_term.inc b/sites/all/modules/contrib/views/views/plugins/views_wizard/taxonomy_term.inc index 599e354..687a4e9 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_wizard/taxonomy_term.inc +++ b/sites/all/modules/contrib/views/views/plugins/views_wizard/taxonomy_term.inc @@ -14,8 +14,7 @@ if (module_exists('taxonomy')) { 'class' => 'ViewsUiTaxonomyTermViewsWizard', ), 'title' => t('Taxonomy terms'), - 'filters' => array( - ), + 'filters' => array(), 'path_field' => array( 'id' => 'tid', 'table' => 'taxonomy_term_data', diff --git a/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_base_views_wizard.class.php b/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_base_views_wizard.class.php index 8893ab8..35989c4 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_base_views_wizard.class.php +++ b/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_base_views_wizard.class.php @@ -9,6 +9,10 @@ * Defines a common interface for Views Wizard plugins. */ interface ViewsWizardInterface { + + /** + * Constructor. + */ function __construct($plugin); /** @@ -31,6 +35,7 @@ interface ViewsWizardInterface { * @throws ViewsWizardException in the event of a problem. */ function create_view($form, &$form_state); + } /** @@ -43,6 +48,7 @@ class ViewsWizardException extends Exception { * A very generic Views Wizard class - can be constructed for any base table. */ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { + protected $base_table; protected $entity_type; protected $entity_info = array(); @@ -87,7 +93,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { $form['displays']['page'] = array( '#type' => 'fieldset', - '#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend'),), + '#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend')), '#tree' => TRUE, ); $form['displays']['page']['create'] = array( @@ -102,7 +108,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { // can be hidden en masse when the "Create a page" checkbox is unchecked. $form['displays']['page']['options'] = array( '#type' => 'container', - '#attributes' => array('class' => array('options-set'),), + '#attributes' => array('class' => array('options-set')), '#dependency' => array( 'edit-page-create' => array(1), ), @@ -224,7 +230,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { $form['displays']['block'] = array( '#type' => 'fieldset', - '#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend'),), + '#attributes' => array('class' => array('views-attachment', 'fieldset-no-legend')), '#tree' => TRUE, ); $form['displays']['block']['create'] = array( @@ -238,7 +244,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { // can be hidden en masse when the "Create a block" checkbox is unchecked. $form['displays']['block']['options'] = array( '#type' => 'container', - '#attributes' => array('class' => array('options-set'),), + '#attributes' => array('class' => array('options-set')), '#dependency' => array( 'edit-block-create' => array(1), ), @@ -334,7 +340,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { } /** - * Build the part of the form that allows the user to select the view's filters. + * Build the part of the form that allows the user to select the filters. * * By default, this adds "of type" and "tagged with" filters (when they are * available). @@ -344,7 +350,8 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { $fields = views_fetch_fields($this->base_table, 'filter'); $entity_info = $this->entity_info; - // If the current base table support bundles and has more than one (like user). + // If the current base table support bundles and has more than one (like + // user). if (isset($entity_info['bundle keys']) && isset($entity_info['bundles'])) { // Get all bundles and their human readable names. $options = array('all' => t('All')); @@ -431,7 +438,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { } /** - * Build the part of the form that allows the user to select the view's sort order. + * Build the part of the form that allows the user to select the sort order. * * By default, this adds a "sorted by [date]" filter (when it is available). */ @@ -492,7 +499,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { * arrays of options for that display. */ protected function build_display_options($form, $form_state) { - // Display: Master + // Display: Master. $display_options['default'] = $this->default_display_options($form, $form_state); $display_options['default'] += array( 'filters' => array(), @@ -501,17 +508,17 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { $display_options['default']['filters'] += $this->default_display_filters($form, $form_state); $display_options['default']['sorts'] += $this->default_display_sorts($form, $form_state); - // Display: Page + // Display: Page. if (!empty($form_state['values']['page']['create'])) { $display_options['page'] = $this->page_display_options($form, $form_state); - // Display: Feed (attached to the page) + // Display: Feed (attached to the page). if (!empty($form_state['values']['page']['feed'])) { $display_options['feed'] = $this->page_feed_display_options($form, $form_state); } } - // Display: Block + // Display: Block. if (!empty($form_state['values']['block']['create'])) { $display_options['block'] = $this->block_display_options($form, $form_state); } @@ -573,13 +580,13 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { * Add the array of display options to the view, with appropriate overrides. */ protected function add_displays($view, $display_options, $form, $form_state) { - // Display: Master + // Display: Master. $default_display = $view->new_display('default', 'Master', 'default'); foreach ($display_options['default'] as $option => $value) { $default_display->set_option($option, $value); } - // Display: Page + // Display: Page. if (isset($display_options['page'])) { $display = $view->new_display('page', 'Page', 'page'); // The page display is usually the main one (from the user's point of @@ -587,14 +594,14 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { // so that new displays which are added later automatically inherit them. $this->set_default_options($display_options['page'], $display, $default_display); - // Display: Feed (attached to the page) + // Display: Feed (attached to the page). if (isset($display_options['feed'])) { $display = $view->new_display('feed', 'Feed', 'feed'); $this->set_override_options($display_options['feed'], $display, $default_display); } } - // Display: Block + // Display: Block. if (isset($display_options['block'])) { $display = $view->new_display('block', 'Block', 'block'); // When there is no page, the block display options should become the @@ -622,9 +629,10 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { $display_options['style_plugin'] = 'default'; $display_options['row_plugin'] = 'fields'; - // Add a least one field so the view validates and the user has already a preview. - // Therefore the basefield could provide 'defaults][field]' in it's base settings. - // If there is nothing like this choose the first field with a field handler. + // Add a least one field so the view validates and the user has already a + // preview. Therefore the basefield could provide 'defaults][field]' in + // it's base settings. If there is nothing like this choose the first field + // with a field handler. $data = views_fetch_data($this->base_table); if (isset($data['table']['base']['defaults']['field'])) { $field = $data['table']['base']['defaults']['field']; @@ -682,8 +690,9 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { } } $table_data = views_fetch_data($table); - // Check whether the bundle key filter handler is or an child of it views_handler_filter_in_operator - // If it's not just use a single value instead of an array. + // Check whether the bundle key filter handler is or an child of it + // views_handler_filter_in_operator. If it's not just use a single value + // instead of an array. $handler = $table_data[$bundle_key]['filter']['handler']; if ($handler == 'views_handler_filter_in_operator' || is_subclass_of($handler, 'views_handler_filter_in_operator')) { $value = drupal_map_assoc(array($form_state['values']['show']['type'])); @@ -700,7 +709,7 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { ); } - // @todo: Figure out why this isn't part of node_views_wizard. + // @todo Figure out why this isn't part of node_views_wizard. if (!empty($form_state['values']['show']['tagged_with']['tids'])) { $filters['tid'] = array( 'id' => 'tid', @@ -741,7 +750,8 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { protected function default_display_sorts_user($form, $form_state) { $sorts = array(); - // Don't add a sort if there is no form value or the user selected none as sort. + // Don't add a sort if there is no form value or the user selected none as + // sort. if (!empty($form_state['values']['show']['sort']) && $form_state['values']['show']['sort'] != 'none') { list($column, $sort) = explode(':', $form_state['values']['show']['sort']); // Column either be a column-name or the table-columnn-ame. @@ -826,14 +836,14 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { * so that new displays which the user adds later will be similar to this * one. * - * @param $options + * @param array $options * An array whose keys are the name of each option and whose values are the * desired values to set. - * @param $display + * @param object $display * The display which the options will be applied to. The default display * will actually be assigned the options (and this display will inherit * them) when possible. - * @param $default_display + * @param object$default_display * The default display, which will store the options when possible. */ protected function set_default_options($options, $display, $default_display) { @@ -862,13 +872,13 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { * the views wizard, then the view will wind up with the title stored as the * default (with the page and block both inheriting from it). * - * @param $options + * @param array $options * An array whose keys are the name of each option and whose values are the * desired values. - * @param $display + * @param object $display * The display which the options will apply to. It will get the options by * inheritance from the default display when possible. - * @param $default_display + * @param object $default_display * The default display, from which the options will be inherited when * possible. */ @@ -918,12 +928,12 @@ class ViewsUiBaseViewsWizard implements ViewsWizardInterface { * * @throws ViewsWizardException if the values have not been validated. */ - function create_view($form, &$form_state) { - $view = $this->retrieve_validated_view($form, $form_state); - if (empty($view)) { - throw new ViewsWizardException(t('Attempted to create_view with values that have not been validated')); - } - return $view; - } + function create_view($form, &$form_state) { + $view = $this->retrieve_validated_view($form, $form_state); + if (empty($view)) { + throw new ViewsWizardException(t('Attempted to create_view with values that have not been validated')); + } + return $view; + } } diff --git a/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_comment_views_wizard.class.php b/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_comment_views_wizard.class.php index fa26d33..4b68e98 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_comment_views_wizard.class.php +++ b/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_comment_views_wizard.class.php @@ -105,4 +105,5 @@ class ViewsUiCommentViewsWizard extends ViewsUiBaseViewsWizard { return $display_options; } + } diff --git a/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_file_managed_views_wizard.class.php b/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_file_managed_views_wizard.class.php index 111b631..12435cb 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_file_managed_views_wizard.class.php +++ b/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_file_managed_views_wizard.class.php @@ -9,6 +9,7 @@ * Tests creating managed files views with the wizard. */ class ViewsUiFileManagedViewsWizard extends ViewsUiBaseViewsWizard { + protected function default_display_options($form, $form_state) { $display_options = parent::default_display_options($form, $form_state); @@ -37,4 +38,5 @@ class ViewsUiFileManagedViewsWizard extends ViewsUiBaseViewsWizard { return $display_options; } + } diff --git a/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_node_revision_views_wizard.class.php b/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_node_revision_views_wizard.class.php index 3623f53..49d52e0 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_node_revision_views_wizard.class.php +++ b/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_node_revision_views_wizard.class.php @@ -65,4 +65,5 @@ class ViewsUiNodeRevisionViewsWizard extends ViewsUiNodeViewsWizard { return $display_options; } + } diff --git a/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_node_views_wizard.class.php b/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_node_views_wizard.class.php index 07bb91d..ffdd7d1 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_node_views_wizard.class.php +++ b/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_node_views_wizard.class.php @@ -118,20 +118,24 @@ class ViewsUiNodeViewsWizard extends ViewsUiBaseViewsWizard { $display_options['row_options']['links'] = !empty($row_options['links']); $display_options['row_options']['comments'] = !empty($row_options['comments']); break; + case 'teasers': $display_options['row_plugin'] = 'node'; $display_options['row_options']['build_mode'] = 'teaser'; $display_options['row_options']['links'] = !empty($row_options['links']); $display_options['row_options']['comments'] = !empty($row_options['comments']); break; + case 'titles_linked': $display_options['row_plugin'] = 'fields'; $display_options['field']['title']['link_to_node'] = 1; break; + case 'titles': $display_options['row_plugin'] = 'fields'; $display_options['field']['title']['link_to_node'] = 0; break; } } + } diff --git a/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_taxonomy_term_views_wizard.class.php b/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_taxonomy_term_views_wizard.class.php index 8c1d6d5..b73156e 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_taxonomy_term_views_wizard.class.php +++ b/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_taxonomy_term_views_wizard.class.php @@ -39,4 +39,5 @@ class ViewsUiTaxonomyTermViewsWizard extends ViewsUiBaseViewsWizard { return $display_options; } + } diff --git a/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_users_views_wizard.class.php b/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_users_views_wizard.class.php index 73eff48..c20c89e 100644 --- a/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_users_views_wizard.class.php +++ b/sites/all/modules/contrib/views/views/plugins/views_wizard/views_ui_users_views_wizard.class.php @@ -9,6 +9,7 @@ * Tests creating user views with the wizard. */ class ViewsUiUsersViewsWizard extends ViewsUiBaseViewsWizard { + protected function default_display_options($form, $form_state) { $display_options = parent::default_display_options($form, $form_state); @@ -39,4 +40,5 @@ class ViewsUiUsersViewsWizard extends ViewsUiBaseViewsWizard { return $display_options; } + } diff --git a/sites/all/modules/contrib/views/views/test_templates/README.txt b/sites/all/modules/contrib/views/views/test_templates/README.txt new file mode 100644 index 0000000..551f738 --- /dev/null +++ b/sites/all/modules/contrib/views/views/test_templates/README.txt @@ -0,0 +1,11 @@ +Workaround for: + +- https://www.drupal.org/node/2450447 +- https://www.drupal.org/node/2415991 + + +Files of this folder cannot be included inside the views/tests directory because +they are included as tests cases and make testbot crash. + +This files could be moved to tests/templates once +https://www.drupal.org/node/2415991 be properly fixed. diff --git a/sites/all/modules/contrib/views/views/tests/templates/views-view--frontpage.tpl.php b/sites/all/modules/contrib/views/views/test_templates/views-view--frontpage.tpl.php similarity index 98% rename from sites/all/modules/contrib/views/views/tests/templates/views-view--frontpage.tpl.php rename to sites/all/modules/contrib/views/views/test_templates/views-view--frontpage.tpl.php index eb4f58b..bfe67b1 100644 --- a/sites/all/modules/contrib/views/views/tests/templates/views-view--frontpage.tpl.php +++ b/sites/all/modules/contrib/views/views/test_templates/views-view--frontpage.tpl.php @@ -22,7 +22,7 @@ * - $pager: The pager next/prev links to display, if any * - $exposed: Exposed widget form/info to display * - $feed_icon: Feed icon to display, if any - * - $more: A link to view more, if any + * - $more: A link to view more, if any. * * @ingroup views_templates */ diff --git a/sites/all/modules/contrib/views/views/tests/README.txt b/sites/all/modules/contrib/views/views/tests/README.txt new file mode 100644 index 0000000..e292de3 --- /dev/null +++ b/sites/all/modules/contrib/views/views/tests/README.txt @@ -0,0 +1,29 @@ +Views Tests +``````````` +All of the tests may be executed with the following command: + +$ scripts/run-tests.sh --color --url http://example.com/ --php `which php` --concurrency 4 --verbose --directory 'sites/all/modules/contrib/views/tests' 2> /dev/null + +Explanation: + --color + Colorizes the output. Optional. + --url http://example.com/ + The name of the Drupal 7 hostname used locally for running tests, e.g. + "http://drupal7.dev". Required. + --php `which php` + Tells the test runner the path to the PHP binary. Only necessary if the test + runner is unable to find the path automatically or to use an alternative + PHP binary. Optional. + --cuncurrency 4 + Run multiple test processes simultaneously. Four appears to be a good + balance between melting the computer and improving performance. Optional. + --verbose + Display results for all of the assertion statements after the summary + details. Optional. + --directory 'sites/all/modules/contrib/views/tests' + Run all of the commands in the following directory. The path is relative to + the Drupal installation's root directory. This will run all of Views' tests + in one go, rather than either repeating the names of test groups or running + multiple commands. Optional. + 2> /dev/null + Outputs all error messages to /dev/null, i.e. hides them. Optional. diff --git a/sites/all/modules/contrib/views/views/tests/comment/views_handler_argument_comment_user_uid.test b/sites/all/modules/contrib/views/views/tests/comment/views_handler_argument_comment_user_uid.test index 353d929..9599499 100644 --- a/sites/all/modules/contrib/views/views/tests/comment/views_handler_argument_comment_user_uid.test +++ b/sites/all/modules/contrib/views/views/tests/comment/views_handler_argument_comment_user_uid.test @@ -20,10 +20,10 @@ class viewsHandlerArgumentCommentUserUidTest extends ViewsSqlTest { /** * Post comment. * - * @param $node + * @param object $node * Node to post comment on. - * @param $comment - * Comment to save + * @param array $comment + * Comment to save. */ function postComment($node, $comment = array()) { $comment += array( @@ -38,8 +38,8 @@ class viewsHandlerArgumentCommentUserUidTest extends ViewsSqlTest { function setUp() { parent::setUp(); - // Add two users, create a node with the user1 as author and another node with user2 as author. - // For the second node add a comment from user1. + // Add two users, create a node with the user1 as author and another node + // with user2 as author. For the second node add a comment from user1. $this->account = $this->drupalCreateUser(); $this->account2 = $this->drupalCreateUser(); $this->drupalLogin($this->account); @@ -51,7 +51,6 @@ class viewsHandlerArgumentCommentUserUidTest extends ViewsSqlTest { function testCommentUserUidTest() { $view = $this->view_comment_user_uid(); - $this->executeView($view, array($this->account->uid)); $resultset = array( array( @@ -67,7 +66,7 @@ class viewsHandlerArgumentCommentUserUidTest extends ViewsSqlTest { } function view_comment_user_uid() { - $view = new view; + $view = new view(); $view->name = 'test_comment_user_uid'; $view->description = ''; $view->tag = 'default'; @@ -103,4 +102,5 @@ class viewsHandlerArgumentCommentUserUidTest extends ViewsSqlTest { return $view; } + } diff --git a/sites/all/modules/contrib/views/views/tests/comment/views_handler_filter_comment_user_uid.test b/sites/all/modules/contrib/views/views/tests/comment/views_handler_filter_comment_user_uid.test index 1f3f75c..4093317 100644 --- a/sites/all/modules/contrib/views/views/tests/comment/views_handler_filter_comment_user_uid.test +++ b/sites/all/modules/contrib/views/views/tests/comment/views_handler_filter_comment_user_uid.test @@ -38,4 +38,5 @@ class viewsHandlerFilterCommentUserUidTest extends viewsHandlerArgumentCommentUs return $view; } + } diff --git a/sites/all/modules/contrib/views/views/tests/field/views_fieldapi.test b/sites/all/modules/contrib/views/views/tests/field/views_fieldapi.test index da4c27b..0d049e1 100644 --- a/sites/all/modules/contrib/views/views/tests/field/views_fieldapi.test +++ b/sites/all/modules/contrib/views/views/tests/field/views_fieldapi.test @@ -6,33 +6,40 @@ */ /** - * @TODO - * - Test on a generic entity not on a node. + * @todo Test on a generic entity not on a node. * * What has to be tested: - * - Take sure that every wanted field is added to the according entity type. - * - Take sure the joins are done correct. - * - Use basic fields and take sure that the full wanted object is build. - * - Use relationships between different entity types, for example node and the node author(user). + * - Take sure that every wanted field is added to the according entity type. + * - Take sure the joins are done correct. + * - Use basic fields and take sure that the full wanted object is build. + * - Use relationships between different entity types, for example node and + * the node author(user). */ /** * Provides some helper methods for testing fieldapi integration into views. */ class ViewsFieldApiTestHelper extends ViewsSqlTest { + /** * Stores the field definitions used by the test. + * * @var array */ public $fields; + /** * Stores the instances of the fields. They have * the same keys as the fields. + * * @var array */ public $instances; - protected function CreateUser($extra_edit = array()) { + /** + * + */ + protected function createUser($extra_edit = array()) { $permissions = array('access comments', 'access content', 'post comments', 'skip comment approval'); // Create a role with the given permission set. if (!($rid = $this->drupalCreateRole($permissions))) { @@ -92,6 +99,7 @@ class ViewsFieldApiTestHelper extends ViewsSqlTest { drupal_static_reset('_views_fetch_data_recursion_protected'); drupal_static_reset('_views_fetch_data_fully_loaded'); } + } /** @@ -116,7 +124,6 @@ class viewsFieldApiDataTest extends ViewsFieldApiTestHelper { $langcode = LANGUAGE_NONE; - $field_names = $this->setUpFields(); // The first one will be attached to nodes only. @@ -152,7 +159,7 @@ class viewsFieldApiDataTest extends ViewsFieldApiTestHelper { // Now create some example nodes/users for the view result. for ($i = 0; $i < 5; $i++) { $edit = array( - // @TODO Write a helper method to create such values. + // @todo Write a helper method to create such values. 'field_name_0' => array($langcode => array((array('value' => $this->randomName())))), 'field_name_2' => array($langcode => array((array('value' => $this->randomName())))), ); @@ -164,7 +171,7 @@ class viewsFieldApiDataTest extends ViewsFieldApiTestHelper { 'field_name_1' => array($langcode => array((array('value' => $this->randomName())))), 'field_name_2' => array($langcode => array((array('value' => $this->randomName())))), ); - $this->users[] = $this->CreateUser($edit); + $this->users[] = $this->createUser($edit); } // Reset views data cache. @@ -178,7 +185,7 @@ class viewsFieldApiDataTest extends ViewsFieldApiTestHelper { */ function testViewsData() { $data = views_fetch_data(); - + // Check the table and the joins of the first field. // Attached to node only. $field = $this->fields[0]; @@ -210,7 +217,6 @@ class viewsFieldApiDataTest extends ViewsFieldApiTestHelper { ); $this->assertEqual($expected_join, $data[$revision_table]['table']['join']['node_revision']); - // Check the table and the joins of the second field. // Attached to both node and user. $field_2 = $this->fields[2]; @@ -230,7 +236,7 @@ class viewsFieldApiDataTest extends ViewsFieldApiTestHelper { 'extra' => array( array('field' => 'entity_type', 'value' => 'node'), array('field' => 'deleted', 'value' => 0, 'numeric' => TRUE), - ) + ), ); $this->assertEqual($expected_join, $data[$current_table_2]['table']['join']['node']); $expected_join = array( @@ -239,7 +245,7 @@ class viewsFieldApiDataTest extends ViewsFieldApiTestHelper { 'extra' => array( array('field' => 'entity_type', 'value' => 'node'), array('field' => 'deleted', 'value' => 0, 'numeric' => TRUE), - ) + ), ); $this->assertEqual($expected_join, $data[$revision_table_2]['table']['join']['node_revision']); $expected_join = array( @@ -248,32 +254,25 @@ class viewsFieldApiDataTest extends ViewsFieldApiTestHelper { 'extra' => array( array('field' => 'entity_type', 'value' => 'user'), array('field' => 'deleted', 'value' => 0, 'numeric' => TRUE), - ) + ), ); $this->assertEqual($expected_join, $data[$current_table_2]['table']['join']['users']); - // Check the fields - // @todo - - // Check the arguments - // @todo - - // Check the sort criterias - // @todo - - // Check the relationships - // @todo - + // @todo Check the fields. + // @todo Check the arguments. + // @todo Check the sort criterias. + // @todo Check the relationships. } + } /** * Tests the field_field handler. - * @TODO - * Check a entity-type with bundles - * Check a entity-type without bundles - * Check locale:disabled, locale:enabled and locale:enabled with another language - * Check revisions + * + * @todo Check a entity-type with bundles. + * @todo Check a entity-type without bundles. + * @todo Check locale:disabled, locale:enabled and locale:enabled with another language. + * @todo Check revisions. */ class viewsHandlerFieldFieldTest extends ViewsFieldApiTestHelper { public $nodes; @@ -282,7 +281,7 @@ class viewsHandlerFieldFieldTest extends ViewsFieldApiTestHelper { return array( 'name' => 'Fieldapi: Field handler', 'description' => 'Tests the field itself of the fieldapi integration', - 'group' => 'Views Modules' + 'group' => 'Views Modules', ); } @@ -353,7 +352,7 @@ class viewsHandlerFieldFieldTest extends ViewsFieldApiTestHelper { $this->executeView($view); // Take sure that the formatter works as expected. - // @TODO: actually there should be a specific formatter. + // @todo actually there should be a specific formatter. for ($i = 0; $i < 2; $i++) { $rendered_field = $view->style_plugin->get_field($i, $this->fields[0]['field_name']); $this->assertEqual(strlen($rendered_field), 3); @@ -384,7 +383,7 @@ class viewsHandlerFieldFieldTest extends ViewsFieldApiTestHelper { $view->destroy(); - // Test delta limit + offset + // Test delta limit + offset. $view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['group_rows'] = TRUE; $view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['delta_limit'] = 3; $view->display['default']->display_options['fields'][$this->fields[3]['field_name']]['delta_offset'] = 1; @@ -459,7 +458,7 @@ class viewsHandlerFieldFieldTest extends ViewsFieldApiTestHelper { } protected function getFieldView() { - $view = new view; + $view = new view(); $view->name = 'view_fieldapi'; $view->description = ''; $view->tag = 'default'; @@ -491,4 +490,3 @@ class viewsHandlerFieldFieldTest extends ViewsFieldApiTestHelper { } } - diff --git a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_area_text.test b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_area_text.test index 9f30e0c..c5ebe81 100644 --- a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_area_text.test +++ b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_area_text.test @@ -22,7 +22,7 @@ class ViewsHandlerAreaTextTest extends ViewsSqlTest { public function testAreaText() { $view = $this->getBasicView(); - // add a text header + // add a text header. $string = $this->randomName(); $view->display['default']->handler->override_option('header', array( 'area' => array( diff --git a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_argument_null.test b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_argument_null.test index e8650a3..95db4df 100644 --- a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_argument_null.test +++ b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_argument_null.test @@ -25,7 +25,7 @@ class ViewsHandlerArgumentNullTest extends ViewsSqlTest { } public function testAreaText() { - // Test validation + // Test validation. $view = $this->getBasicView(); // Add a null argument. diff --git a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_argument_string.test b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_argument_string.test index d078abf..4c76ff6 100644 --- a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_argument_string.test +++ b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_argument_string.test @@ -53,6 +53,7 @@ class ViewsHandlerArgumentStringTest extends ViewsSqlTest { * Provide a test view for testGlossary. * * @see testGlossary + * * @return view */ function viewGlossary() { @@ -93,4 +94,5 @@ class ViewsHandlerArgumentStringTest extends ViewsSqlTest { return $view; } + } diff --git a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field.test b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field.test index 9e6dfca..df9574f 100644 --- a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field.test +++ b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field.test @@ -6,11 +6,15 @@ */ /** - * Tests the generic field handler + * Tests the generic field handler. * * @see views_handler_field */ class ViewsHandlerFieldTest extends ViewsSqlTest { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Field', @@ -19,6 +23,9 @@ class ViewsHandlerFieldTest extends ViewsSqlTest { ); } + /** + * + */ protected function setUp() { parent::setUp(); $this->column_map = array( @@ -26,17 +33,12 @@ class ViewsHandlerFieldTest extends ViewsSqlTest { ); } - function testEmpty() { - $this->_testHideIfEmpty(); - $this->_testEmptyText(); - } - /** * Tests the hide if empty functionality. * * This tests alters the result to get easier and less coupled results. */ - function _testHideIfEmpty() { + public function testHideIfEmpty() { $view = $this->getBasicView(); $view->init_display(); $this->executeView($view); @@ -139,7 +141,8 @@ class ViewsHandlerFieldTest extends ViewsSqlTest { $render = $view->field['name']->advanced_render($view->result[0]); $this->assertIdentical($render, $random_name, 'If the rewritten string is not empty, "0" should not be treated as empty.'); - // Test when results are rewritten to an empty string and non-zero empty results are hidden. + // Test when results are rewritten to an empty string and non-zero empty + // results are hidden. $view->field['name']->options['hide_alter_empty'] = TRUE; $view->field['name']->options['hide_empty'] = TRUE; $view->field['name']->options['empty_zero'] = FALSE; @@ -254,7 +257,7 @@ class ViewsHandlerFieldTest extends ViewsSqlTest { /** * Tests the usage of the empty text. */ - function _testEmptyText() { + public function testEmptyText() { $view = $this->getBasicView(); $view->init_display(); $this->executeView($view); @@ -291,7 +294,7 @@ class ViewsHandlerFieldTest extends ViewsSqlTest { /** * Tests views_handler_field::is_value_empty(). */ - function testIsValueEmpty() { + public function testIsValueEmpty() { $view = $this->getBasicView(); $view->init_display(); $view->init_handlers(); diff --git a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_boolean.test b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_boolean.test index 286b942..38eb38c 100644 --- a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_boolean.test +++ b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_boolean.test @@ -18,7 +18,7 @@ class ViewsHandlerFieldBooleanTest extends ViewsSqlTest { } function dataSet() { - // Use default dataset but remove the age from john and paul + // Use default dataset but remove the age from john and paul. $data = parent::dataSet(); $data[0]['age'] = 0; $data[3]['age'] = 0; @@ -105,4 +105,5 @@ class ViewsHandlerFieldBooleanTest extends ViewsSqlTest { $this->assertNotEqual($values['false'], $view->field['age']->advanced_render($view->result[0])); $this->assertNotEqual($values['true'], $view->field['age']->advanced_render($view->result[1])); } + } diff --git a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_counter.test b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_counter.test index 2ddcb6f..9a4766a 100644 --- a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_counter.test +++ b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_counter.test @@ -48,7 +48,7 @@ class ViewsHandlerFilterCounterTest extends ViewsSqlTest { 'table' => 'views', 'field' => 'counter', 'relationship' => 'none', - 'counter_start' => $rand_start + 'counter_start' => $rand_start, ), 'name' => array( 'id' => 'name', @@ -64,7 +64,8 @@ class ViewsHandlerFilterCounterTest extends ViewsSqlTest { $this->assertEqual(2 + $rand_start, $view->style_plugin->rendered_fields[2]['counter']); } - // @TODO: Write tests for pager. + // @todo Write tests for pager. function testPager() { } + } diff --git a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_custom.test b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_custom.test index b45fd17..b8f8a08 100644 --- a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_custom.test +++ b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_custom.test @@ -44,4 +44,5 @@ class ViewsHandlerFieldCustomTest extends ViewsSqlTest { $this->assertEqual($random, $view->style_plugin->get_field(0, 'name')); } + } diff --git a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_date.test b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_date.test index 7944142..54cbf0e 100644 --- a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_date.test +++ b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_date.test @@ -9,6 +9,10 @@ * Tests the core views_handler_field_date handler. */ class ViewsHandlerFieldDateTest extends ViewsSqlTest { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Field: Date', @@ -17,12 +21,18 @@ class ViewsHandlerFieldDateTest extends ViewsSqlTest { ); } + /** + * + */ function viewsData() { $data = parent::viewsData(); $data['views_test']['created']['field']['handler'] = 'views_handler_field_date'; return $data; } + /** + * + */ public function testFieldDate() { $view = $this->getBasicView(); @@ -32,7 +42,8 @@ class ViewsHandlerFieldDateTest extends ViewsSqlTest { 'table' => 'views_test', 'field' => 'created', 'relationship' => 'none', - // c is iso 8601 date format @see http://php.net/manual/en/function.date.php + // c is iso 8601 date format. + // @see http://php.net/manual/en/function.date.php 'custom_date_format' => 'c', 'second_date_format' => 'custom', 'second_date_format_custom' => 'c', @@ -62,13 +73,17 @@ class ViewsHandlerFieldDateTest extends ViewsSqlTest { $intervals = array( 'raw time ago' => format_interval(REQUEST_TIME - $time, 2), 'time ago' => t('%time ago', array('%time' => format_interval(REQUEST_TIME - $time, 2))), - // TODO write tests for them -// 'raw time span' => format_interval(REQUEST_TIME - $time, 2), -// 'time span' => t('%time hence', array('%time' => format_interval(REQUEST_TIME - $time, 2))), + // @todo write tests for them + // 'raw time span' => format_interval(REQUEST_TIME - $time, 2), + // 'time span' => t('%time hence', + // array('%time' => format_interval(REQUEST_TIME - $time, 2))), ); $this->assertRenderedDatesEqual($view, $intervals); } + /** + * + */ protected function assertRenderedDatesEqual($view, $map, $timezone = NULL) { foreach ($map as $date_format => $expected_result) { $check_result_number = 0; @@ -114,4 +129,5 @@ class ViewsHandlerFieldDateTest extends ViewsSqlTest { return $data; } + } diff --git a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_file_extension.test b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_file_extension.test index ab8b0a9..ddc12f9 100644 --- a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_file_extension.test +++ b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_file_extension.test @@ -63,4 +63,5 @@ class ViewsHandlerFileExtensionTest extends ViewsSqlTest { $this->assertEqual($view->field['name']->advanced_render($view->result[2]), 'tar.gz'); $this->assertEqual($view->field['name']->advanced_render($view->result[3]), ''); } + } diff --git a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_file_size.test b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_file_size.test index 8652754..a8828c7 100644 --- a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_file_size.test +++ b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_file_size.test @@ -61,4 +61,5 @@ class ViewsHandlerTestFileSize extends ViewsSqlTest { $this->assertEqual($view->field['age']->advanced_render($view->result[2]), 1000); $this->assertEqual($view->field['age']->advanced_render($view->result[3]), 10000); } + } diff --git a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_math.test b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_math.test index ac33ac4..cd39528 100644 --- a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_math.test +++ b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_math.test @@ -42,4 +42,5 @@ class ViewsHandlerFieldMath extends ViewsSqlTest { $this->assertEqual($rand1 + $rand2, $view->style_plugin->get_field(0, 'expression')); } + } diff --git a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_url.test b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_url.test index 527e94f..ad6f71d 100644 --- a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_url.test +++ b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_url.test @@ -57,4 +57,5 @@ class ViewsHandlerFieldUrlTest extends ViewsSqlTest { $this->assertEqual(l('John', 'John'), $view->field['name']->advanced_render($view->result[0])); } + } diff --git a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_xss.test b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_xss.test index 65a1ce2..c12a408 100644 --- a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_xss.test +++ b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_field_xss.test @@ -23,7 +23,7 @@ class ViewsHandlerTestXss extends ViewsSqlTest { $map = array( 'John' => 'John', "Foo\xC0barbaz" => '', - 'Fooÿñ' => 'Fooÿñ' + 'Fooÿñ' => 'Fooÿñ', ); return $map; @@ -57,4 +57,5 @@ class ViewsHandlerTestXss extends ViewsSqlTest { $counter++; } } + } diff --git a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_filter_combine.test b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_filter_combine.test index 99bf1eb..57d5e6f 100644 --- a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_filter_combine.test +++ b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_filter_combine.test @@ -102,4 +102,5 @@ class ViewsHandlerFilterCombineTest extends ViewsSqlTest { unset($schema['views_test']['fields']['job']['not null']); return $schema; } + } diff --git a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_filter_date.test b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_filter_date.test index 34ccba6..ad6a98b 100644 --- a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_filter_date.test +++ b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_filter_date.test @@ -50,6 +50,21 @@ class ViewsHandlerFilterDateTest extends ViewsSqlTest { $this->assertIdenticalResultset($view, $expected_result, $this->map); $view->destroy(); + // Test "first day of" type of relative dates for simple operator. + $view->set_display('default'); + $view->init_handlers(); + $view->filter['created']->operator = '<'; + $view->filter['created']->value['type'] = 'offset'; + $view->filter['created']->value['value'] = 'last day of January 1970'; + $view->execute_display('default'); + $expected_result = array( + array('nid' => $this->nodes[0]->nid), + array('nid' => $this->nodes[1]->nid), + array('nid' => $this->nodes[2]->nid), + ); + $this->assertIdenticalResultset($view, $expected_result, $this->map); + $view->destroy(); + // Test offset for between operator. $view->set_display('default'); $view->init_handlers(); @@ -63,6 +78,22 @@ class ViewsHandlerFilterDateTest extends ViewsSqlTest { ); $this->assertIdenticalResultset($view, $expected_result, $this->map); $view->destroy(); + + // Test "first day of" type of relative dates for between operator. + $view->set_display('default'); + $view->init_handlers(); + $view->filter['created']->operator = 'between'; + $view->filter['created']->value['type'] = 'offset'; + $view->filter['created']->value['max'] = 'last day of January 1970'; + $view->filter['created']->value['min'] = 'first day of January 1970'; + $view->execute_display('default'); + $expected_result = array( + array('nid' => $this->nodes[0]->nid), + array('nid' => $this->nodes[1]->nid), + array('nid' => $this->nodes[2]->nid), + ); + $this->assertIdenticalResultset($view, $expected_result, $this->map); + $view->destroy(); } @@ -137,7 +168,7 @@ class ViewsHandlerFilterDateTest extends ViewsSqlTest { $view = $this->views_test_between(); $view->save(); - $admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration')); + $admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration')); $this->drupalLogin($admin_user); menu_rebuild(); $this->drupalGet('admin/structure/views/view/test_filter_date_between/edit'); @@ -151,7 +182,7 @@ class ViewsHandlerFilterDateTest extends ViewsSqlTest { } function views_test_between() { - $view = new view; + $view = new view(); $view->name = 'test_filter_date_between'; $view->description = ''; $view->tag = ''; @@ -187,4 +218,5 @@ class ViewsHandlerFilterDateTest extends ViewsSqlTest { $view = $this->views_test_between(); return $view; } + } diff --git a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_filter_equality.test b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_filter_equality.test index 5bb48c8..a1dbc4e 100644 --- a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_filter_equality.test +++ b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_filter_equality.test @@ -34,7 +34,7 @@ class ViewsHandlerFilterEqualityTest extends ViewsSqlTest { function testEqual() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'name' => array( 'id' => 'name', @@ -59,7 +59,7 @@ class ViewsHandlerFilterEqualityTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Name, Operator: =, Value: Ringo + // Filter: Name, Operator: =, Value: Ringo. $filters['name']['group_info']['default_group'] = 1; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); @@ -76,7 +76,7 @@ class ViewsHandlerFilterEqualityTest extends ViewsSqlTest { function testNotEqual() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'name' => array( 'id' => 'name', @@ -110,7 +110,7 @@ class ViewsHandlerFilterEqualityTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Name, Operator: !=, Value: Ringo + // Filter: Name, Operator: !=, Value: Ringo. $filters['name']['group_info']['default_group'] = 2; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); diff --git a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_filter_numeric.test b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_filter_numeric.test index 2ab1aea..6cfe2d3 100644 --- a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_filter_numeric.test +++ b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_filter_numeric.test @@ -38,7 +38,7 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest { public function testFilterNumericSimple() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'age' => array( 'id' => 'age', @@ -82,7 +82,7 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest { public function testFilterNumericBetween() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'age' => array( 'id' => 'age', @@ -114,11 +114,11 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest { ); $this->assertIdenticalResultset($view, $resultset, $this->column_map); - // test not between + // test not between. $view->delete(); $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'age' => array( 'id' => 'age', @@ -160,7 +160,6 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest { $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); - $this->executeView($view); $resultset = array( array( @@ -188,7 +187,6 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest { $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); - $this->executeView($view); $resultset = array( array( @@ -211,7 +209,7 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest { public function testFilterNumericEmpty() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'age' => array( 'id' => 'age', @@ -223,14 +221,13 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest { )); $this->executeView($view); - $resultset = array( - ); + $resultset = array(); $this->assertIdenticalResultset($view, $resultset, $this->column_map); $view->delete(); $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'age' => array( 'id' => 'age', @@ -243,7 +240,7 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest { $this->executeView($view); $resultset = array( - array( + array( 'name' => 'John', 'age' => 25, ), @@ -272,15 +269,13 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Age, Operator: empty, Value: + // Filter: Age, Operator: empty, Value. $filters['age']['group_info']['default_group'] = 4; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); - $this->executeView($view); - $resultset = array( - ); + $resultset = array(); $this->assertIdenticalResultset($view, $resultset, $this->column_map); } @@ -288,15 +283,14 @@ class ViewsHandlerFilterNumericTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Age, Operator: empty, Value: + // Filter: Age, Operator: empty, Value. $filters['age']['group_info']['default_group'] = 5; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); - $this->executeView($view); $resultset = array( - array( + array( 'name' => 'John', 'age' => 25, ), diff --git a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_filter_string.test b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_filter_string.test index ee74a28..ab6af92 100644 --- a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_filter_string.test +++ b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_filter_string.test @@ -75,7 +75,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { function testFilterStringEqual() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'name' => array( 'id' => 'name', @@ -100,7 +100,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Name, Operator: =, Value: Ringo + // Filter: Name, Operator: =, Value: Ringo. $filters['name']['group_info']['default_group'] = 1; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); @@ -119,7 +119,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { function testFilterStringNotEqual() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'name' => array( 'id' => 'name', @@ -153,7 +153,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Name, Operator: !=, Value: Ringo + // Filter: Name, Operator: !=, Value: Ringo. $filters['name']['group_info']['default_group'] = '2'; $view->set_display('page_1'); @@ -182,7 +182,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { function testFilterStringContains() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'name' => array( 'id' => 'name', @@ -208,7 +208,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Name, Operator: contains, Value: ing + // Filter: Name, Operator: contains, Value: ing. $filters['name']['group_info']['default_group'] = '3'; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); @@ -228,7 +228,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { function testFilterStringWord() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'description' => array( 'id' => 'description', @@ -254,7 +254,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'description' => array( 'id' => 'description', @@ -277,10 +277,10 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { function testFilterStringGroupedExposedWord() { - $filters = $this->getGroupedExposedFilters(); + $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Name, Operator: contains, Value: ing + // Filter: Name, Operator: contains, Value: ing. $filters['name']['group_info']['default_group'] = '3'; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); @@ -299,7 +299,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Description, Operator: contains, Value: actor + // Filter: Description, Operator: contains, Value: actor. $filters['description']['group_info']['default_group'] = '1'; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); @@ -319,7 +319,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { function testFilterStringStarts() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'description' => array( 'id' => 'description', @@ -344,7 +344,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Name, Operator: starts, Value: George + // Filter: Name, Operator: starts, Value: George. $filters['description']['group_info']['default_group'] = 2; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); @@ -362,7 +362,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { function testFilterStringNotStarts() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'description' => array( 'id' => 'description', @@ -385,7 +385,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { array( 'name' => 'Paul', ), - // There is no Meredith returned because his description is empty + // There is no Meredith returned because his description is empty. ); $this->assertIdenticalResultset($view, $resultset, $this->column_map); } @@ -394,7 +394,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Name, Operator: not_starts, Value: George + // Filter: Name, Operator: not_starts, Value: George. $filters['description']['group_info']['default_group'] = 3; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); @@ -411,7 +411,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { array( 'name' => 'Paul', ), - // There is no Meredith returned because his description is empty + // There is no Meredith returned because his description is empty. ); $this->assertIdenticalResultset($view, $resultset, $this->column_map); } @@ -419,7 +419,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { function testFilterStringEnds() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'description' => array( 'id' => 'description', @@ -447,7 +447,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Descriptino, Operator: ends, Value: Beatles + // Filter: Descriptino, Operator: ends, Value: Beatles. $filters['description']['group_info']['default_group'] = 4; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); @@ -468,7 +468,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { function testFilterStringNotEnds() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'description' => array( 'id' => 'description', @@ -488,7 +488,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { array( 'name' => 'Paul', ), - // There is no Meredith returned because his description is empty + // There is no Meredith returned because his description is empty. ); $this->assertIdenticalResultset($view, $resultset, $this->column_map); } @@ -497,7 +497,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Description, Operator: not_ends, Value: Beatles + // Filter: Description, Operator: not_ends, Value: Beatles. $filters['description']['group_info']['default_group'] = 5; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); @@ -511,7 +511,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { array( 'name' => 'Paul', ), - // There is no Meredith returned because his description is empty + // There is no Meredith returned because his description is empty. ); $this->assertIdenticalResultset($view, $resultset, $this->column_map); } @@ -519,7 +519,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { function testFilterStringNot() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'description' => array( 'id' => 'description', @@ -539,7 +539,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { array( 'name' => 'Paul', ), - // There is no Meredith returned because his description is empty + // There is no Meredith returned because his description is empty. ); $this->assertIdenticalResultset($view, $resultset, $this->column_map); } @@ -549,7 +549,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Description, Operator: not (does not contains), Value: Beatles + // Filter: Description, Operator: not (does not contains), Value: Beatles. $filters['description']['group_info']['default_group'] = 6; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); @@ -563,7 +563,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { array( 'name' => 'Paul', ), - // There is no Meredith returned because his description is empty + // There is no Meredith returned because his description is empty. ); $this->assertIdenticalResultset($view, $resultset, $this->column_map); @@ -572,7 +572,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { function testFilterStringShorter() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'name' => array( 'id' => 'name', @@ -620,7 +620,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { function testFilterStringLonger() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'name' => array( 'id' => 'name', @@ -663,7 +663,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { function testFilterStringEmpty() { $view = $this->getBasicView(); - // Change the filtering + // Change the filtering. $view->display['default']->handler->override_option('filters', array( 'description' => array( 'id' => 'description', @@ -687,7 +687,7 @@ class ViewsHandlerFilterStringTest extends ViewsSqlTest { $filters = $this->getGroupedExposedFilters(); $view = $this->getBasicPageView(); - // Filter: Description, Operator: empty, Value: + // Filter: Description, Operator: empty, Value. $filters['description']['group_info']['default_group'] = 7; $view->set_display('page_1'); $view->display['page_1']->handler->override_option('filters', $filters); diff --git a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_sort.test b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_sort.test index 70f2aac..35708c1 100644 --- a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_sort.test +++ b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_sort.test @@ -23,7 +23,7 @@ class ViewsHandlerSortTest extends ViewsSqlTest { public function testNumericOrdering() { $view = $this->getBasicView(); - // Change the ordering + // Change the ordering. $view->display['default']->handler->override_option('sorts', array( 'age' => array( 'order' => 'ASC', @@ -46,7 +46,7 @@ class ViewsHandlerSortTest extends ViewsSqlTest { $view = $this->getBasicView(); - // Reverse the ordering + // Reverse the ordering. $view->display['default']->handler->override_option('sorts', array( 'age' => array( 'order' => 'DESC', @@ -74,7 +74,7 @@ class ViewsHandlerSortTest extends ViewsSqlTest { public function testStringOrdering() { $view = $this->getBasicView(); - // Change the ordering + // Change the ordering. $view->display['default']->handler->override_option('sorts', array( 'name' => array( 'order' => 'ASC', @@ -97,7 +97,7 @@ class ViewsHandlerSortTest extends ViewsSqlTest { $view = $this->getBasicView(); - // Reverse the ordering + // Reverse the ordering. $view->display['default']->handler->override_option('sorts', array( 'name' => array( 'order' => 'DESC', @@ -118,4 +118,5 @@ class ViewsHandlerSortTest extends ViewsSqlTest { 'views_test_age' => 'age', )); } + } diff --git a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_sort_date.test b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_sort_date.test index 65a94e8..4a8c4ca 100644 --- a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_sort_date.test +++ b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_sort_date.test @@ -21,61 +21,66 @@ class ViewsHandlerSortDateTest extends ViewsSqlTest { $expected = array(); if (!$reverse) { switch ($granularity) { - case 'second': - $expected = array( - array('name' => 'John'), - array('name' => 'Paul'), - array('name' => 'Meredith'), - array('name' => 'Ringo'), - array('name' => 'George'), - ); - break; - case 'minute': - $expected = array( - array('name' => 'John'), - array('name' => 'Paul'), - array('name' => 'Ringo'), - array('name' => 'Meredith'), - array('name' => 'George'), - ); - break; - case 'hour': - $expected = array( - array('name' => 'John'), - array('name' => 'Ringo'), - array('name' => 'Paul'), - array('name' => 'Meredith'), - array('name' => 'George'), - ); - break; - case 'day': - $expected = array( - array('name' => 'John'), - array('name' => 'Ringo'), - array('name' => 'Paul'), - array('name' => 'Meredith'), - array('name' => 'George'), - ); - break; - case 'month': - $expected = array( - array('name' => 'John'), - array('name' => 'George'), - array('name' => 'Ringo'), - array('name' => 'Paul'), - array('name' => 'Meredith'), - ); - break; - case 'year': - $expected = array( - array('name' => 'John'), - array('name' => 'George'), - array('name' => 'Ringo'), - array('name' => 'Paul'), - array('name' => 'Meredith'), - ); - break; - } + case 'second': + $expected = array( + array('name' => 'John'), + array('name' => 'Paul'), + array('name' => 'Meredith'), + array('name' => 'Ringo'), + array('name' => 'George'), + ); + break; + + case 'minute': + $expected = array( + array('name' => 'John'), + array('name' => 'Paul'), + array('name' => 'Ringo'), + array('name' => 'Meredith'), + array('name' => 'George'), + ); + break; + + case 'hour': + $expected = array( + array('name' => 'John'), + array('name' => 'Ringo'), + array('name' => 'Paul'), + array('name' => 'Meredith'), + array('name' => 'George'), + ); + break; + + case 'day': + $expected = array( + array('name' => 'John'), + array('name' => 'Ringo'), + array('name' => 'Paul'), + array('name' => 'Meredith'), + array('name' => 'George'), + ); + break; + + case 'month': + $expected = array( + array('name' => 'John'), + array('name' => 'George'), + array('name' => 'Ringo'), + array('name' => 'Paul'), + array('name' => 'Meredith'), + ); + break; + + case 'year': + $expected = array( + array('name' => 'John'), + array('name' => 'George'), + array('name' => 'Ringo'), + array('name' => 'Paul'), + array('name' => 'Meredith'), + ); + break; + } } else { switch ($granularity) { @@ -88,6 +93,7 @@ class ViewsHandlerSortDateTest extends ViewsSqlTest { array('name' => 'John'), ); break; + case 'minute': $expected = array( array('name' => 'George'), @@ -95,8 +101,9 @@ class ViewsHandlerSortDateTest extends ViewsSqlTest { array('name' => 'Meredith'), array('name' => 'Paul'), array('name' => 'John'), - ); + ); break; + case 'hour': $expected = array( array('name' => 'George'), @@ -106,6 +113,7 @@ class ViewsHandlerSortDateTest extends ViewsSqlTest { array('name' => 'John'), ); break; + case 'day': $expected = array( array('name' => 'George'), @@ -115,6 +123,7 @@ class ViewsHandlerSortDateTest extends ViewsSqlTest { array('name' => 'Meredith'), ); break; + case 'month': $expected = array( array('name' => 'John'), @@ -124,6 +133,7 @@ class ViewsHandlerSortDateTest extends ViewsSqlTest { array('name' => 'Meredith'), ); break; + case 'year': $expected = array( array('name' => 'John'), @@ -163,7 +173,7 @@ class ViewsHandlerSortDateTest extends ViewsSqlTest { ), )); - // Change the ordering + // Change the ordering. $view->display['default']->handler->override_option('sorts', array( 'created' => array( 'id' => 'created', @@ -195,4 +205,5 @@ class ViewsHandlerSortDateTest extends ViewsSqlTest { } } } + } diff --git a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_sort_random.test b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_sort_random.test index 19db8a9..b7a620d 100644 --- a/sites/all/modules/contrib/views/views/tests/handlers/views_handler_sort_random.test +++ b/sites/all/modules/contrib/views/views/tests/handlers/views_handler_sort_random.test @@ -9,6 +9,10 @@ * Tests for core views_handler_sort_random handler. */ class ViewsHandlerSortRandomTest extends ViewsSqlTest { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Sort: random', @@ -77,7 +81,8 @@ class ViewsHandlerSortRandomTest extends ViewsSqlTest { 'views_test_age' => 'views_test_name', )); - // Execute a second random view, we expect the result set to be different again. + // Execute a second random view, we expect the result set to be different + // again. $view_random_2 = $this->getBasicRandomView(); $this->executeView($view_random_2); $this->assertEqual(count($this->dataSet()), count($view_random_2->result), t('The number of returned rows match.')); @@ -86,4 +91,5 @@ class ViewsHandlerSortRandomTest extends ViewsSqlTest { 'views_test_age' => 'views_test_name', )); } + } diff --git a/sites/all/modules/contrib/views/views/tests/handlers/views_handlers.test b/sites/all/modules/contrib/views/views/tests/handlers/views_handlers.test index f2faee3..6f010ac 100644 --- a/sites/all/modules/contrib/views/views/tests/handlers/views_handlers.test +++ b/sites/all/modules/contrib/views/views/tests/handlers/views_handlers.test @@ -2,7 +2,7 @@ /** * @file - * Contains ViewsHandlerTest. + * Definition of ViewsHandlerTest. */ /** @@ -42,7 +42,7 @@ class ViewsHandlerTest extends ViewsSqlTest { public function testHandlerAccess() { $view = $this->getBasicView(); - // add a test area + // add a test area. $view->display['default']->handler->override_option('header', array( 'test_access' => array( 'id' => 'test_access', @@ -61,7 +61,7 @@ class ViewsHandlerTest extends ViewsSqlTest { $view = $this->getBasicView(); - // add a test area + // add a test area. $view->display['default']->handler->override_option('header', array( 'test_access' => array( 'id' => 'test_access', diff --git a/sites/all/modules/contrib/views/views/tests/node/views_node_revision_relations.test b/sites/all/modules/contrib/views/views/tests/node/views_node_revision_relations.test index 6b38396..e3a50c0 100644 --- a/sites/all/modules/contrib/views/views/tests/node/views_node_revision_relations.test +++ b/sites/all/modules/contrib/views/views/tests/node/views_node_revision_relations.test @@ -174,4 +174,5 @@ class ViewsNodeRevisionRelationsTestCase extends ViewsSqlTest { return $view; } + } diff --git a/sites/all/modules/contrib/views/views/tests/plugins/views_plugin_display.test b/sites/all/modules/contrib/views/views/tests/plugins/views_plugin_display.test index df33a34..7efb2e7 100644 --- a/sites/all/modules/contrib/views/views/tests/plugins/views_plugin_display.test +++ b/sites/all/modules/contrib/views/views/tests/plugins/views_plugin_display.test @@ -10,6 +10,9 @@ */ class ViewsPluginDisplayTestCase extends ViewsSqlTest { + /** + * + */ public static function getInfo() { return array( 'name' => 'Display plugin', @@ -35,6 +38,7 @@ class ViewsPluginDisplayTestCase extends ViewsSqlTest { * Returns a test view for testFilterGroupsOverriding. * * @see testFilterGroupsOverriding + * * @return view */ function viewFilterGroupsOverriding() { @@ -80,7 +84,9 @@ class ViewsPluginDisplayTestCase extends ViewsSqlTest { } /** - * Based on a bug some filter_groups landed in the overridden display, even the filters weren't overridden. + * Based on a bug some filter_groups landed in the overridden display. + * + * Even the filters weren't overridden. * This caused multiple issues. * Take sure that the value from the default display are used. * @@ -191,4 +197,5 @@ class ViewsPluginDisplayTestCase extends ViewsSqlTest { return $view; } + } diff --git a/sites/all/modules/contrib/views/views/tests/styles/views_plugin_style.test b/sites/all/modules/contrib/views/views/tests/styles/views_plugin_style.test index dfc5413..20a24eb 100644 --- a/sites/all/modules/contrib/views/views/tests/styles/views_plugin_style.test +++ b/sites/all/modules/contrib/views/views/tests/styles/views_plugin_style.test @@ -185,7 +185,6 @@ class ViewsPluginStyleTestCase extends ViewsPluginStyleTestBase { $expected['Job: Drummer']['rows']['Age: 28']['rows'][2]->views_test_age = '28'; $expected['Job: Drummer']['rows']['Age: 28']['rows'][2]->views_test_id = '3'; - // Alter the results to support the stripped case. if ($stripped) { @@ -206,7 +205,6 @@ class ViewsPluginStyleTestCase extends ViewsPluginStyleTestBase { $view->style_plugin->options['grouping'][1] = array('field' => 'age', 'rendered' => TRUE, 'rendered_strip' => TRUE); } - // The newer api passes the value of the grouping as well. $sets_new_rendered = $view->style_plugin->render_grouping($view->result, $view->style_plugin->options['grouping'], TRUE); @@ -241,7 +239,7 @@ class ViewsPluginStyleTestCase extends ViewsPluginStyleTestBase { // Setup some random css class. $view->init_display(); $view->init_style(); - $random_name = $this->randomName(); + $random_name = drupal_html_class($this->randomName()); $view->style_plugin->options['row_class'] = $random_name . " test-token-[name]"; $rendered_output = $view->preview(); @@ -252,13 +250,14 @@ class ViewsPluginStyleTestCase extends ViewsPluginStyleTestBase { foreach ($rows as $row) { $attributes = $row->attributes(); $class = (string) $attributes['class'][0]; - $this->assertTrue(strpos($class, $random_name) !== FALSE, 'Take sure that a custom css class is added to the output.'); + $this->assertTrue(strpos($class, $random_name) !== FALSE, 'Make sure that a custom css class is added to the output.'); // Check token replacement. - $name = $view->field['name']->get_value($view->result[$count]); - $this->assertTrue(strpos($class, "test-token-$name") !== FALSE, 'Take sure that a token in custom css class is replaced.'); + $name = drupal_clean_css_identifier($view->field['name']->get_value($view->result[$count])); + $this->assertTrue(strpos($class, "test-token-$name") !== FALSE, 'Make sure that a token in custom css class is replaced.'); $count++; } } + } diff --git a/sites/all/modules/contrib/views/views/tests/styles/views_plugin_style_jump_menu.test b/sites/all/modules/contrib/views/views/tests/styles/views_plugin_style_jump_menu.test index dd4eca0..aadaa56 100644 --- a/sites/all/modules/contrib/views/views/tests/styles/views_plugin_style_jump_menu.test +++ b/sites/all/modules/contrib/views/views/tests/styles/views_plugin_style_jump_menu.test @@ -17,6 +17,9 @@ class viewsPluginStyleJumpMenuTest extends ViewsSqlTest { */ var $nodes; + /** + * + */ public static function getInfo() { return array( 'name' => 'Jump menu', @@ -25,7 +28,9 @@ class viewsPluginStyleJumpMenuTest extends ViewsSqlTest { ); } - + /** + * + */ public function setUp() { parent::setUp(); $this->nodes = array(); @@ -37,7 +42,6 @@ class viewsPluginStyleJumpMenuTest extends ViewsSqlTest { $this->nodeTitles = array($this->nodes['page'][0]->title, $this->nodes['page'][1]->title, $this->nodes['story'][0]->title, $this->nodes['story'][1]->title); } - /** * Tests jump menues with more then one same path but maybe differnet titles. */ @@ -46,7 +50,8 @@ class viewsPluginStyleJumpMenuTest extends ViewsSqlTest { $view->set_display(); $view->init_handlers(); - // Setup a [path] which would leed to "duplicate" paths, but still the shouldn't be used for grouping. + // Setup a [path] which would leed to "duplicate" paths, but still the + // shouldn't be used for grouping. $view->field['nothing']->options['alter']['text'] = '[path]'; $view->preview(); $form = $view->style_plugin->render($view->result); @@ -65,8 +70,11 @@ class viewsPluginStyleJumpMenuTest extends ViewsSqlTest { } } + /** + * + */ function getJumpMenuView() { - $view = new view; + $view = new view(); $view->name = 'test_jump_menu'; $view->description = ''; $view->tag = 'default'; @@ -148,4 +156,5 @@ class viewsPluginStyleJumpMenuTest extends ViewsSqlTest { return $view; } + } diff --git a/sites/all/modules/contrib/views/views/tests/styles/views_plugin_style_mapping.test b/sites/all/modules/contrib/views/views/tests/styles/views_plugin_style_mapping.test index 5785075..c73cb57 100644 --- a/sites/all/modules/contrib/views/views/tests/styles/views_plugin_style_mapping.test +++ b/sites/all/modules/contrib/views/views/tests/styles/views_plugin_style_mapping.test @@ -27,7 +27,7 @@ class ViewsPluginStyleMappingTest extends ViewsPluginStyleTestBase { protected function viewsPlugins() { return array( - 'style' => array( + 'style' => array( 'test_mapping' => array( 'title' => t('Field mapping'), 'help' => t('Maps specific fields to specific purposes.'), diff --git a/sites/all/modules/contrib/views/views/tests/styles/views_plugin_style_unformatted.test b/sites/all/modules/contrib/views/views/tests/styles/views_plugin_style_unformatted.test index 0c0e882..eb5cc99 100644 --- a/sites/all/modules/contrib/views/views/tests/styles/views_plugin_style_unformatted.test +++ b/sites/all/modules/contrib/views/views/tests/styles/views_plugin_style_unformatted.test @@ -42,7 +42,7 @@ class ViewsPluginStyleUnformattedTestCase extends ViewsPluginStyleTestBase { if ($count == 1) { $this->assertTrue(strpos($class, "views-row-first") !== FALSE, 'Take sure that the first class is set right.'); } - else if ($count == $count_result) { + elseif ($count == $count_result) { $this->assertTrue(strpos($class, "views-row-last") !== FALSE, 'Take sure that the last class is set right.'); } diff --git a/sites/all/modules/contrib/views/views/tests/taxonomy/views_handler_relationship_node_term_data.test b/sites/all/modules/contrib/views/views/tests/taxonomy/views_handler_relationship_node_term_data.test index 37e8aa6..7bce980 100644 --- a/sites/all/modules/contrib/views/views/tests/taxonomy/views_handler_relationship_node_term_data.test +++ b/sites/all/modules/contrib/views/views/tests/taxonomy/views_handler_relationship_node_term_data.test @@ -34,9 +34,8 @@ class ViewsHandlerRelationshipNodeTermDataTest extends ViewsSqlTest { function setUp() { parent::setUp(); - //$web_user = $this->drupalCreateUser(array('create article content')); - //$this->drupalLogin($web_user); - + // $web_user = $this->drupalCreateUser(array('create article content')); + // $this->drupalLogin($web_user); $vocabulary = taxonomy_vocabulary_machine_name_load('tags'); $this->term_1 = $this->createTerm($vocabulary); $this->term_2 = $this->createTerm($vocabulary); @@ -119,4 +118,5 @@ class ViewsHandlerRelationshipNodeTermDataTest extends ViewsSqlTest { return $view; } -} \ No newline at end of file + +} diff --git a/sites/all/modules/contrib/views/views/tests/test_handlers/views_test_area_access.inc b/sites/all/modules/contrib/views/views/tests/test_handlers/views_test_area_access.inc index 57a0014..268c675 100644 --- a/sites/all/modules/contrib/views/views/tests/test_handlers/views_test_area_access.inc +++ b/sites/all/modules/contrib/views/views/tests/test_handlers/views_test_area_access.inc @@ -2,22 +2,25 @@ /** * @file - * Contains views_test_area_access + * Definition of views_test_area_access. */ +/** + * A test access plugin. + */ class views_test_area_access extends views_handler_area { /** * {@inheritdoc} */ - function access() { + public function access() { return $this->options['custom_access']; - } + } /** * {@inheritdoc} */ - function option_definition() { + public function option_definition() { $options = parent::option_definition(); $options['custom_access'] = array('default' => TRUE, 'bool' => TRUE); diff --git a/sites/all/modules/contrib/views/views/tests/test_plugins/views_test_plugin_access_test_dynamic.inc b/sites/all/modules/contrib/views/views/tests/test_plugins/views_test_plugin_access_test_dynamic.inc index cecec2f..39f7600 100644 --- a/sites/all/modules/contrib/views/views/tests/test_plugins/views_test_plugin_access_test_dynamic.inc +++ b/sites/all/modules/contrib/views/views/tests/test_plugins/views_test_plugin_access_test_dynamic.inc @@ -9,18 +9,29 @@ * Tests a dynamic access plugin. */ class views_test_plugin_access_test_dynamic extends views_plugin_access { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['access'] = array('default' => FALSE, 'bool' => TRUE); return $options; } - function access($account) { + /** + * {@inheritdoc} + */ + public function access($account) { return !empty($this->options['access']) && isset($this->view->args[0]) && $this->view->args[0] == variable_get('test_dynamic_access_argument1', NULL) && isset($this->view->args[1]) && $this->view->args[1] == variable_get('test_dynamic_access_argument2', NULL); } - function get_access_callback() { + /** + * {@inheritdoc} + */ + public function get_access_callback() { return array('views_test_test_dynamic_access_callback', array(!empty($options['access']), 1, 2)); } + } diff --git a/sites/all/modules/contrib/views/views/tests/test_plugins/views_test_plugin_access_test_static.inc b/sites/all/modules/contrib/views/views/tests/test_plugins/views_test_plugin_access_test_static.inc index 187d6ea..eb6dde3 100644 --- a/sites/all/modules/contrib/views/views/tests/test_plugins/views_test_plugin_access_test_static.inc +++ b/sites/all/modules/contrib/views/views/tests/test_plugins/views_test_plugin_access_test_static.inc @@ -9,18 +9,29 @@ * Tests a static access plugin. */ class views_test_plugin_access_test_static extends views_plugin_access { - function option_definition() { + + /** + * {@inheritdoc} + */ + public function option_definition() { $options = parent::option_definition(); $options['access'] = array('default' => FALSE, 'bool' => TRUE); return $options; } - function access($account) { + /** + * {@inheritdoc} + */ + public function access($account) { return !empty($this->options['access']); } - function get_access_callback() { + /** + * {@inheritdoc} + */ + public function get_access_callback() { return array('views_test_test_static_access_callback', array(!empty($options['access']))); } + } diff --git a/sites/all/modules/contrib/views/views/tests/test_plugins/views_test_plugin_style_test_mapping.inc b/sites/all/modules/contrib/views/views/tests/test_plugins/views_test_plugin_style_test_mapping.inc index b926787..46d202a 100644 --- a/sites/all/modules/contrib/views/views/tests/test_plugins/views_test_plugin_style_test_mapping.inc +++ b/sites/all/modules/contrib/views/views/tests/test_plugins/views_test_plugin_style_test_mapping.inc @@ -11,7 +11,7 @@ class views_test_plugin_style_test_mapping extends views_plugin_style_mapping { /** - * Overrides views_plugin_style_mapping::define_mapping(). + * {@inheritdoc} */ protected function define_mapping() { return array( @@ -49,4 +49,5 @@ class views_test_plugin_style_test_mapping extends views_plugin_style_mapping { } } } + } diff --git a/sites/all/modules/contrib/views/views/tests/user/views_handler_field_user_name.test b/sites/all/modules/contrib/views/views/tests/user/views_handler_field_user_name.test index 6ace471..60ec3b2 100644 --- a/sites/all/modules/contrib/views/views/tests/user/views_handler_field_user_name.test +++ b/sites/all/modules/contrib/views/views/tests/user/views_handler_field_user_name.test @@ -43,17 +43,16 @@ class viewsHandlerFieldUserNameTest extends ViewsSqlTest { $anon_name = variable_get('anonymous', t('Anonymous')); $view->result[0]->users_name = ''; $render = $view->field['name']->advanced_render($view->result[0]); - $this->assertIdentical($render, $anon_name , 'For user0 it should use the default anonymous name by default.'); + $this->assertIdentical($render, $anon_name, 'For user0 it should use the default anonymous name by default.'); $view->field['name']->options['overwrite_anonymous'] = TRUE; $anon_name = $view->field['name']->options['anonymous_text'] = $this->randomName(); $render = $view->field['name']->advanced_render($view->result[0]); - $this->assertIdentical($render, $anon_name , 'For user0 it should use the configured anonymous text if overwrite_anonymous is checked.'); - + $this->assertIdentical($render, $anon_name, 'For user0 it should use the configured anonymous text if overwrite_anonymous is checked.'); } function view_user_name() { - $view = new view; + $view = new view(); $view->name = 'test_views_handler_field_user_name'; $view->description = ''; $view->tag = 'default'; @@ -93,4 +92,5 @@ class viewsHandlerFieldUserNameTest extends ViewsSqlTest { return $view; } + } diff --git a/sites/all/modules/contrib/views/views/tests/user/views_user.test b/sites/all/modules/contrib/views/views/tests/user/views_user.test index 52c5026..2f0e2cd 100644 --- a/sites/all/modules/contrib/views/views/tests/user/views_user.test +++ b/sites/all/modules/contrib/views/views/tests/user/views_user.test @@ -9,9 +9,20 @@ * Tests basic user module integration into views. */ class ViewsUserTestCase extends ViewsSqlTest { + + /** + * + */ var $users = array(); + + /** + * + */ var $nodes = array(); + /** + * + */ public static function getInfo() { return array( 'name' => 'Tests basic user integration', @@ -20,7 +31,9 @@ class ViewsUserTestCase extends ViewsSqlTest { ); } - + /** + * + */ protected function setUp() { parent::setUp(); @@ -31,7 +44,7 @@ class ViewsUserTestCase extends ViewsSqlTest { } /** - * Add a view which has no explicit relationship to the author and check the result. + * Add a view which has no explicit relationship to the author. * * @todo: Remove the following comment once the relationship is required. * One day a view will require the relationship so it should still work @@ -51,8 +64,11 @@ class ViewsUserTestCase extends ViewsSqlTest { $this->assertIdenticalResultset($view, $expected); } + /** + * + */ function test_view_user_relationship() { - $view = new view; + $view = new view(); $view->name = 'test_user_relationship'; $view->description = ''; $view->tag = 'default'; @@ -140,4 +156,5 @@ class ViewsUserTestCase extends ViewsSqlTest { return $view; } + } diff --git a/sites/all/modules/contrib/views/views/tests/user/views_user_argument_default.test b/sites/all/modules/contrib/views/views/tests/user/views_user_argument_default.test index afb24d1..2888193 100644 --- a/sites/all/modules/contrib/views/views/tests/user/views_user_argument_default.test +++ b/sites/all/modules/contrib/views/views/tests/user/views_user_argument_default.test @@ -9,6 +9,10 @@ * Tests views user argument default plugin. */ class ViewsUserArgumentDefault extends ViewsSqlTest { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Tests user argument default plugin', @@ -17,11 +21,15 @@ class ViewsUserArgumentDefault extends ViewsSqlTest { ); } + /** + * + */ public function test_plugin_argument_default_current_user() { // Create a user to test. $account = $this->drupalCreateUser(); - // Switch the user, we have to check the global user too, because drupalLogin is only for the simpletest browser. + // Switch the user, we have to check the global user too, because + // drupalLogin is only for the simpletest browser. $this->drupalLogin($account); global $user; $admin = $user; @@ -40,8 +48,11 @@ class ViewsUserArgumentDefault extends ViewsSqlTest { drupal_save_session(TRUE); } + /** + * + */ function view_plugin_argument_default_current_user() { - $view = new view; + $view = new view(); $view->name = 'test_plugin_argument_default_current_user'; $view->description = ''; $view->tag = ''; @@ -87,4 +98,5 @@ class ViewsUserArgumentDefault extends ViewsSqlTest { return $view; } + } diff --git a/sites/all/modules/contrib/views/views/tests/user/views_user_argument_validate.test b/sites/all/modules/contrib/views/views/tests/user/views_user_argument_validate.test index 6e157bf..91aebba 100644 --- a/sites/all/modules/contrib/views/views/tests/user/views_user_argument_validate.test +++ b/sites/all/modules/contrib/views/views/tests/user/views_user_argument_validate.test @@ -24,7 +24,7 @@ class ViewsUserArgumentValidate extends ViewsSqlTest { function testArgumentValidateUserUid() { $account = $this->account; - // test 'uid' case + // test 'uid' case. $view = $this->view_argument_validate_user('uid'); $view->set_display('default'); $view->pre_execute(); @@ -36,13 +36,13 @@ class ViewsUserArgumentValidate extends ViewsSqlTest { $this->assertFalse($view->argument['null']->validate_arg($account->name)); // Reset safed argument validation. $view->argument['null']->argument_validated = NULL; - // Fail for a valid numeric, but for a user that doesn't exist + // Fail for a valid numeric, but for a user that doesn't exist. $this->assertFalse($view->argument['null']->validate_arg(32)); } function testArgumentValidateUserName() { $account = $this->account; - // test 'name' case + // test 'name' case. $view = $this->view_argument_validate_user('name'); $view->set_display('default'); $view->pre_execute(); @@ -54,13 +54,13 @@ class ViewsUserArgumentValidate extends ViewsSqlTest { $this->assertFalse($view->argument['null']->validate_arg($account->uid)); // Reset safed argument validation. $view->argument['null']->argument_validated = NULL; - // Fail for a valid string, but for a user that doesn't exist + // Fail for a valid string, but for a user that doesn't exist. $this->assertFalse($view->argument['null']->validate_arg($this->randomName())); } function testArgumentValidateUserEither() { $account = $this->account; - // test 'either' case + // test 'either' case. $view = $this->view_argument_validate_user('either'); $view->set_display('default'); $view->pre_execute(); @@ -72,16 +72,16 @@ class ViewsUserArgumentValidate extends ViewsSqlTest { $this->assertTrue($view->argument['null']->validate_arg($account->uid)); // Reset safed argument validation. $view->argument['null']->argument_validated = NULL; - // Fail for a valid string, but for a user that doesn't exist + // Fail for a valid string, but for a user that doesn't exist. $this->assertFalse($view->argument['null']->validate_arg($this->randomName())); // Reset safed argument validation. $view->argument['null']->argument_validated = NULL; - // Fail for a valid uid, but for a user that doesn't exist + // Fail for a valid uid, but for a user that doesn't exist. $this->assertFalse($view->argument['null']->validate_arg(32)); } function view_argument_validate_user($argtype) { - $view = new view; + $view = new view(); $view->name = 'view_argument_validate_user'; $view->description = ''; $view->tag = ''; diff --git a/sites/all/modules/contrib/views/views/tests/views_access.test b/sites/all/modules/contrib/views/views/tests/views_access.test index f02eca9..73b23ef 100644 --- a/sites/all/modules/contrib/views/views/tests/views_access.test +++ b/sites/all/modules/contrib/views/views/tests/views_access.test @@ -17,6 +17,9 @@ class ViewsAccessTest extends ViewsSqlTest { ); } + /** + * {@inheritdoc} + */ public function setUp() { parent::setUp(); diff --git a/sites/all/modules/contrib/views/views/tests/views_ajax.test b/sites/all/modules/contrib/views/views/tests/views_ajax.test new file mode 100644 index 0000000..685d09e --- /dev/null +++ b/sites/all/modules/contrib/views/views/tests/views_ajax.test @@ -0,0 +1,109 @@ + 'Ajax', + 'description' => 'Test views with and without ajax enabled.', + 'group' => 'Views Handlers', + ); + } + + public function setUp() { + parent::setUp('views', 'views_test'); + // Create a second node. + $this->drupalCreateNode(array('type' => 'article', 'status' => NODE_PUBLISHED)); + } + + /** + * Perform a simple AJAX POST HTTP request. + * + * @param string $path + * Drupal path where the request should be POSTed. + * @param string $accept + * The value for the "Accept" header. Usually either 'application/json' or + * 'application/vnd.drupal-ajax'. + * @param array $post + * The POST data. When making a 'application/vnd.drupal-ajax' request, the + * Ajax page state data should be included. Use getAjaxPageStatePostData() + * for that. + * + * @return + * The content returned from the call to curl_exec(). + */ + public function simpleAjaxPost($path, $accept, $post = array()) { + $options['absolute'] = TRUE; + foreach ($post as $key => $value) { + // Encode according to application/x-www-form-urlencoded + // Both names and values needs to be urlencoded, according to + // http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1 + $post[$key] = urlencode($key) . '=' . urlencode($value); + } + $postfields = implode('&', $post); + $headers = array( + 'Accept: ' . $accept, + 'Content-Type: application/x-www-form-urlencoded', + ); + return $this->curlExec(array( + CURLOPT_URL => url($path, $options), + CURLOPT_POST => TRUE, + CURLOPT_POSTFIELDS => $postfields, + CURLOPT_HTTPHEADER => $headers, + )); + } + + /** + * Tests an ajax and non-ajax view. + */ + public function testAjaxView() { + $this->drupalCreateNode(); + $this->drupalGet('test_ajax_view'); + $drupal_settings = $this->drupalGetSettings(); + $this->assertTrue(isset($drupal_settings['views']['ajax_path']), 'The Ajax callback path is set in drupalSettings.'); + $this->assertEqual(count($drupal_settings['views']['ajaxViews']), 1); + $view_entry = current(array_keys($drupal_settings['views']['ajaxViews'])); + $this->assertEqual($drupal_settings['views']['ajaxViews'][$view_entry]['view_name'], 'test_ajax_view', 'The view\'s ajaxViews array entry has the correct \'view_name\' key.'); + $this->assertEqual($drupal_settings['views']['ajaxViews'][$view_entry]['view_display_id'], 'page_1', 'The view\'s ajaxViews array entry has the correct \'view_display_id\' key.'); + + $post = array( + 'view_name' => 'test_ajax_view', + 'view_display_id' => 'page_1', + ); + + $response = $this->simpleAjaxPost('views/ajax', 'application/json', $post); + $data = drupal_json_decode($response); + + $this->assertTrue(isset($data[0]['settings']['views']['ajaxViews'])); + + // Ensure that the view insert command is part of the result. + $this->assertEqual($data[1]['command'], 'insert'); + $this->assertTrue(strpos($data[1]['selector'], '.view-dom-id-') === 0); + + $this->drupalSetContent($data[1]['data']); + $result = $this->xpath('//div[contains(@class, "views-row")]'); + $this->assertEqual(count($result), 2, 'Ensure that two items are rendered in the HTML.'); + + $post = array( + 'view_name' => 'test_noajax_view', + 'view_display_id' => 'default', + ); + + $response = $this->simpleAjaxPost('views/ajax', 'application/json', $post); + $data = drupal_json_decode($response); + // In Drupal 7 we get an ajax response with no commands instead of a 403 if + // the view cannot be accessed. + foreach ($data as $item) { + $this->assertIdentical('settings', $item['command']); + $this->assertTrue(empty($item['data'])); + } + } + +} diff --git a/sites/all/modules/contrib/views/views/tests/views_analyze.test b/sites/all/modules/contrib/views/views/tests/views_analyze.test index c21a4bb..d16103e 100644 --- a/sites/all/modules/contrib/views/views/tests/views_analyze.test +++ b/sites/all/modules/contrib/views/views/tests/views_analyze.test @@ -20,7 +20,7 @@ class ViewsAnalyzeTest extends ViewsSqlTest { public function setUp() { parent::setUp('views_ui'); module_enable(array('views_ui')); - // @TODO Figure out why it's required to clear the cache here. + // @todo Figure out why it's required to clear the cache here. views_module_include('views_default', TRUE); views_get_all_views(TRUE); menu_rebuild(); @@ -48,4 +48,5 @@ class ViewsAnalyzeTest extends ViewsSqlTest { // This redirects the user back to the main views edit page. $this->drupalPost(NULL, array(), t('Ok')); } + } diff --git a/sites/all/modules/contrib/views/views/tests/views_argument_default.test b/sites/all/modules/contrib/views/views/tests/views_argument_default.test index 9c0a7eb..f6e1282 100644 --- a/sites/all/modules/contrib/views/views/tests/views_argument_default.test +++ b/sites/all/modules/contrib/views/views/tests/views_argument_default.test @@ -13,7 +13,7 @@ class ViewsArgumentDefaultTest extends ViewsSqlTest { return array( 'name' => 'Argument_default', 'description' => 'Tests pluggable argument_default for views.', - 'group' => 'Views Plugins' + 'group' => 'Views Plugins', ); } @@ -62,7 +62,7 @@ class ViewsArgumentDefaultTest extends ViewsSqlTest { $view->destroy(); - // Make sure that a normal argument provided is used + // Make sure that a normal argument provided is used. $view = $this->view_argument_default_fixed(); $view->set_display('default'); @@ -87,7 +87,7 @@ class ViewsArgumentDefaultTest extends ViewsSqlTest { } function view_argument_default_fixed() { - $view = new view; + $view = new view(); $view->name = 'test_argument_default_fixed'; $view->description = ''; $view->tag = ''; @@ -134,4 +134,5 @@ class ViewsArgumentDefaultTest extends ViewsSqlTest { return $view; } + } diff --git a/sites/all/modules/contrib/views/views/tests/views_argument_validator.test b/sites/all/modules/contrib/views/views/tests/views_argument_validator.test index fb2e4f2..6927584 100644 --- a/sites/all/modules/contrib/views/views/tests/views_argument_validator.test +++ b/sites/all/modules/contrib/views/views/tests/views_argument_validator.test @@ -40,10 +40,27 @@ class ViewsArgumentValidatorTest extends ViewsSqlTest { $this->assertTrue($view->argument['null']->validate_arg(12)); } + /** + * Make sure argument validation works properly. + */ + function testArgumentValidatePhpFailure() { + $view = $this->view_test_argument_validate_php_failure(); + $view->save(); + $this->drupalGet('test-php-failure'); + + // This should return a 403, indicating that the arguments validation fails. + $this->assertResponse(403); + + $this->drupalGet('test-php-failure-feed'); + + // This should return a 403, indicating that the arguments validation fails. + $this->assertResponse(403); + } + function view_test_argument_validate_php($string) { - $code = 'return $argument == \''. $string .'\';'; - $view = new view; - $view->name = 'view_argument_validate_numeric'; + $code = 'return $argument == \'' . $string . '\';'; + $view = new view(); + $view->name = 'view_argument_validate_php'; $view->description = ''; $view->tag = ''; $view->view_php = ''; @@ -74,7 +91,7 @@ class ViewsArgumentValidatorTest extends ViewsSqlTest { } function view_argument_validate_numeric() { - $view = new view; + $view = new view(); $view->name = 'view_argument_validate_numeric'; $view->description = ''; $view->tag = ''; @@ -103,4 +120,69 @@ class ViewsArgumentValidatorTest extends ViewsSqlTest { return $view; } + + /** + * + * + * @return view $view + * The required view object. + */ + function view_test_argument_validate_php_failure() { + $view = new view(); + $view->name = 'view_argument_validate_php_failure'; + $view->description = ''; + $view->tag = ''; + $view->base_table = 'node'; + $view->human_name = ''; + $view->core = 0; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'none'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'none'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'fields'; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['element_label_colon'] = FALSE; + $handler->display->display_options['fields']['title']['link_to_node'] = FALSE; + /* Contextual filter: Global: Null */ + $handler->display->display_options['arguments']['null']['id'] = 'null'; + $handler->display->display_options['arguments']['null']['table'] = 'views'; + $handler->display->display_options['arguments']['null']['field'] = 'null'; + $handler->display->display_options['arguments']['null']['default_action'] = 'default'; + $handler->display->display_options['arguments']['null']['default_argument_type'] = 'fixed'; + $handler->display->display_options['arguments']['null']['default_argument_options']['argument'] = 'No filter'; + $handler->display->display_options['arguments']['null']['summary']['number_of_records'] = '0'; + $handler->display->display_options['arguments']['null']['summary']['format'] = 'default_summary'; + $handler->display->display_options['arguments']['null']['summary_options']['items_per_page'] = '25'; + $handler->display->display_options['arguments']['null']['specify_validation'] = TRUE; + $handler->display->display_options['arguments']['null']['validate']['type'] = 'php'; + $handler->display->display_options['arguments']['null']['validate_options']['code'] = 'return FALSE;'; + $handler->display->display_options['arguments']['null']['validate']['fail'] = 'access denied'; + + /* Display: Page */ + $handler = $view->new_display('page', 'Page', 'page_1'); + $handler->display->display_options['path'] = 'test-php-failure'; + + /* Display: Feed */ + $handler = $view->new_display('feed', 'Feed', 'feed_1'); + $handler->display->display_options['path'] = 'test-php-failure-feed'; + $handler->display->display_options['pager']['type'] = 'none'; + $handler->display->display_options['pager']['options']['offset'] = '0'; + $handler->display->display_options['style_plugin'] = 'rss'; + $handler->display->display_options['row_plugin'] = 'node_rss'; + + return $view; + } + } diff --git a/sites/all/modules/contrib/views/views/tests/views_basic.test b/sites/all/modules/contrib/views/views/tests/views_basic.test index 5fc60d8..5d590f9 100644 --- a/sites/all/modules/contrib/views/views/tests/views_basic.test +++ b/sites/all/modules/contrib/views/views/tests/views_basic.test @@ -2,18 +2,20 @@ /** * @file - * Definition of ViewsBasicTest. */ /** * Basic test class for Views query builder tests. */ +/** + * + */ class ViewsBasicTest extends ViewsSqlTest { public static function getInfo() { return array( 'name' => 'Basic query test', 'description' => 'A basic query test for Views.', - 'group' => 'Views' + 'group' => 'Views', ); } @@ -137,12 +139,12 @@ class ViewsBasicTest extends ViewsSqlTest { 'validate_argument_transform' => 0, 'validate_user_restrict_roles' => 0, 'validate_argument_php' => '', - ) + ), )); $saved_view = clone $view; - // Execute with a view + // Execute with a view. $view->set_arguments(array(27)); $this->executeView($view); @@ -175,4 +177,5 @@ class ViewsBasicTest extends ViewsSqlTest { 'views_test_age' => 'age', )); } + } diff --git a/sites/all/modules/contrib/views/views/tests/views_cache.test b/sites/all/modules/contrib/views/views/tests/views_cache.test index 28534a2..cb1fdfb 100644 --- a/sites/all/modules/contrib/views/views/tests/views_cache.test +++ b/sites/all/modules/contrib/views/views/tests/views_cache.test @@ -11,11 +11,15 @@ * @see views_plugin_cache */ class ViewsCacheTest extends ViewsSqlTest { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Cache', 'description' => 'Tests pluggable caching for views.', - 'group' => 'Views Plugins' + 'group' => 'Views Plugins', ); } @@ -153,9 +157,9 @@ class ViewsCacheTest extends ViewsSqlTest { * Tests css/js storage and restoring mechanism. */ function testHeaderStorage() { - // Create a view with output caching enabled. - // Some hook_views_pre_render in views_test.module adds the test css/js file. - // so they should be added to the css/js storage. + // Create a view with output caching enabled. Some hook_views_pre_render in + // views_test.module adds the test css/js file, so they should be added to + // the css/js storage. $view = $this->getBasicView(); $view->init_display(); $view->name = 'test_cache_header_storage'; diff --git a/sites/all/modules/contrib/views/views/tests/views_cache.test.js b/sites/all/modules/contrib/views/views/tests/views_cache.test.js index 8dd17c1..26644cf 100644 --- a/sites/all/modules/contrib/views/views/tests/views_cache.test.js +++ b/sites/all/modules/contrib/views/views/tests/views_cache.test.js @@ -1,5 +1,6 @@ /** * @file * Just a placeholder file for the test. + * * @see ViewsCacheTest::testHeaderStorage */ diff --git a/sites/all/modules/contrib/views/views/tests/views_exposed_form.test b/sites/all/modules/contrib/views/views/tests/views_exposed_form.test index 72baf2c..b202564 100644 --- a/sites/all/modules/contrib/views/views/tests/views_exposed_form.test +++ b/sites/all/modules/contrib/views/views/tests/views_exposed_form.test @@ -9,6 +9,10 @@ * Tests exposed forms. */ class ViewsExposedFormTest extends ViewsSqlTest { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Exposed forms', @@ -17,10 +21,13 @@ class ViewsExposedFormTest extends ViewsSqlTest { ); } + /** + * + */ public function setUp() { parent::setUp('views_ui'); module_enable(array('views_ui')); - // @TODO Figure out why it's required to clear the cache here. + // @todo Figure out why it's required to clear the cache here. views_module_include('views_default', TRUE); views_get_all_views(TRUE); menu_rebuild(); @@ -56,6 +63,39 @@ class ViewsExposedFormTest extends ViewsSqlTest { $this->helperButtonHasLabel('edit-reset', $expected_label); } + /** + * Tests that exposed values are correctly stored. + */ + public function testRemember() { + $account = $this->drupalCreateUser(); + $this->drupalLogin($account); + // Create some random nodes. + for ($i = 0; $i < 5; $i++) { + $this->drupalCreateNode(); + } + + // Set the exposed filter. + $this->drupalGet('test_exposed_remember', array('query' => array('type' => 'page'))); + $this->assertFieldByName('type', 'page'); + + // Request the page again, should still be set. + $this->drupalGet('test_exposed_remember'); + $this->assertFieldByName('type', 'page'); + + // Request the page with an unrelated GET argument, filter should still be + // set. + $this->drupalGet('test_exposed_remember', array('query' => array('argument' => 'value'))); + $this->assertFieldByName('type', 'page'); + + // Change the remembered exposed value. + $this->drupalGet('test_exposed_remember', array('query' => array('type' => 'article'))); + $this->assertFieldByName('type', 'article'); + + // Request the page again, should have remembered the new value. + $this->drupalGet('test_exposed_remember'); + $this->assertFieldByName('type', 'article'); + } + /** * Tests the admin interface of exposed filter and sort items. */ @@ -69,8 +109,8 @@ class ViewsExposedFormTest extends ViewsSqlTest { // Be sure that the button is called exposed. $this->helperButtonHasLabel('edit-options-expose-button-button', t('Expose filter')); - // The first time the filter UI is displayed, the operator and the - // value forms should be shown. + // The first time the filter UI is displayed, the operator and the value + // forms should be shown. $this->assertFieldById('edit-options-operator-in', '', 'Operator In exists'); $this->assertFieldById('edit-options-operator-not-in', '', 'Operator Not In exists'); $this->assertFieldById('edit-options-value-page', '', 'Checkbox for Page exists'); @@ -80,10 +120,10 @@ class ViewsExposedFormTest extends ViewsSqlTest { $this->drupalPost('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type', $edit, t('Expose filter')); // Check the label of the expose button. $this->helperButtonHasLabel('edit-options-expose-button-button', t('Hide filter')); - // Check the label of the grouped exposed button + // Check the label of the grouped exposed button. $this->helperButtonHasLabel('edit-options-group-button-button', t('Grouped filters')); - // After Expose the filter, Operator and Value should be still here + // After Expose the filter, Operator and Value should be still here. $this->assertFieldById('edit-options-operator-in', '', 'Operator In exists'); $this->assertFieldById('edit-options-operator-not-in', '', 'Operator Not In exists'); $this->assertFieldById('edit-options-value-page', '', 'Checkbox for Page exists'); @@ -109,18 +149,18 @@ class ViewsExposedFormTest extends ViewsSqlTest { $this->drupalGet('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type'); $this->drupalPost(NULL, array(), t('Grouped filters')); - // After click on 'Grouped Filters' standard operator and value should not be displayed + // After click on 'Grouped Filters' standard operator and value should not + // be displayed. $this->assertNoFieldById('edit-options-operator-in', '', 'Operator In not exists'); $this->assertNoFieldById('edit-options-operator-not-in', '', 'Operator Not In not exists'); $this->assertNoFieldById('edit-options-value-page', '', 'Checkbox for Page not exists'); $this->assertNoFieldById('edit-options-value-article', '', 'Checkbox for Article not exists'); - // Check that after click on 'Grouped Filters', a new button is shown to // add more items to the list. $this->helperButtonHasLabel('edit-options-group-info-add-group', t('Add another item')); - // Create a grouped filter + // Create a grouped filter. $this->drupalGet('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type'); $edit = array(); $edit["options[group_info][group_items][1][title]"] = 'Is Article'; @@ -134,13 +174,13 @@ class ViewsExposedFormTest extends ViewsSqlTest { $edit["options[group_info][group_items][3][value][page]"] = TRUE; $this->drupalPost(NULL, $edit, t('Apply')); - // Validate that all the titles are defined for each group + // Validate that all the titles are defined for each group. $this->drupalGet('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type'); $edit = array(); $edit["options[group_info][group_items][1][title]"] = 'Is Article'; $edit["options[group_info][group_items][1][value][article]"] = TRUE; - // This should trigger an error + // This should trigger an error. $edit["options[group_info][group_items][2][title]"] = ''; $edit["options[group_info][group_items][2][value][page]"] = TRUE; @@ -150,11 +190,11 @@ class ViewsExposedFormTest extends ViewsSqlTest { $this->drupalPost(NULL, $edit, t('Apply')); $this->assertRaw(t('The title is required if value for this item is defined.'), t('Group items should have a title')); - // Un-Expose the filter + // Un-Expose the filter. $this->drupalGet('admin/structure/views/nojs/config-item/test_exposed_admin_ui/default/filter/type'); $this->drupalPost(NULL, array(), t('Hide filter')); - // After Un-Expose the filter, Operator and Value should be shown again + // After Un-Expose the filter, Operator and Value should be shown again. $this->assertFieldById('edit-options-operator-in', '', 'Operator In exists after hide filter'); $this->assertFieldById('edit-options-operator-not-in', '', 'Operator Not In exists after hide filter'); $this->assertFieldById('edit-options-value-page', '', 'Checkbox for Page exists after hide filter'); @@ -167,4 +207,5 @@ class ViewsExposedFormTest extends ViewsSqlTest { $this->helperButtonHasLabel('edit-options-expose-button-button', t('Hide sort')); $this->assertFieldById('edit-options-expose-label', '', t('Make sure a label field is shown')); } + } diff --git a/sites/all/modules/contrib/views/views/tests/views_glossary.test b/sites/all/modules/contrib/views/views/tests/views_glossary.test index 0fe0fba..d7d7c64 100644 --- a/sites/all/modules/contrib/views/views/tests/views_glossary.test +++ b/sites/all/modules/contrib/views/views/tests/views_glossary.test @@ -37,7 +37,7 @@ class ViewsGlossaryTestCase extends ViewsSqlTest { ); foreach ($nodes_per_char as $char => $count) { $setting = array( - 'type' => $type->type + 'type' => $type->type, ); for ($i = 0; $i < $count; $i++) { $node = $setting; @@ -46,7 +46,7 @@ class ViewsGlossaryTestCase extends ViewsSqlTest { } } - // Execute glossary view + // Execute glossary view. $view = views_get_view('glossary'); $view->set_display('attachment'); $view->execute_display('attachment'); @@ -57,4 +57,5 @@ class ViewsGlossaryTestCase extends ViewsSqlTest { $this->assertEqual($nodes_per_char[$item->title_truncated], $item->num_records); } } + } diff --git a/sites/all/modules/contrib/views/views/tests/views_groupby.test b/sites/all/modules/contrib/views/views/tests/views_groupby.test index 718d8dc..364e61b 100644 --- a/sites/all/modules/contrib/views/views/tests/views_groupby.test +++ b/sites/all/modules/contrib/views/views/tests/views_groupby.test @@ -2,20 +2,103 @@ /** * @file - * Tests aggregate functionality of Views. + * Definitions of ViewsQueryGroupByTest and ViewsUiGroupbyTestCase. */ /** * Tests aggregate functionality of views, for example count. */ class ViewsQueryGroupByTest extends ViewsSqlTest { + + /** + * Test meta data. + */ public static function getInfo() { return array( 'name' => 'Groupby', 'description' => 'Tests aggregate functionality of views, for example count.', 'group' => 'Views', ); + } + // tests ambiguous group by column error (postgresql) + public function testAggregateAmbiguity() { + // Create 4 nodes of type1 + $type1 = $this->drupalCreateContentType(); + + $node_1 = array( + 'type' => $type1->type, + ); + $this->drupalCreateNode($node_1); + $this->drupalCreateNode($node_1); + $this->drupalCreateNode($node_1); + $this->drupalCreateNode($node_1); + + $view = $this->viewsAggregateAmbiguityView(); + $output = $view->execute_display(); + + $this->assertEqual(count($view->result), 1, 'Make sure there are no ambiguity problems with the group by operation.'); + } + + public function viewsAggregateAmbiguityView() { + $view = new view(); + $view->name = 'aggregate_ambiguity'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'node'; + $view->human_name = ''; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['group_by'] = TRUE; + $handler->display->display_options['access']['type'] = 'none'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'full'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'fields'; + /* Field: COUNT(Content revision: Nid) */ + $handler->display->display_options['fields']['nid']['id'] = 'nid'; + $handler->display->display_options['fields']['nid']['table'] = 'node_revision'; + $handler->display->display_options['fields']['nid']['field'] = 'nid'; + $handler->display->display_options['fields']['nid']['group_type'] = 'count'; + $handler->display->display_options['fields']['nid']['alter']['alter_text'] = 0; + $handler->display->display_options['fields']['nid']['alter']['make_link'] = 0; + $handler->display->display_options['fields']['nid']['alter']['word_boundary'] = 1; + $handler->display->display_options['fields']['nid']['alter']['ellipsis'] = 1; + $handler->display->display_options['fields']['nid']['alter']['strip_tags'] = 0; + $handler->display->display_options['fields']['nid']['alter']['trim'] = 0; + $handler->display->display_options['fields']['nid']['alter']['html'] = 0; + $handler->display->display_options['fields']['nid']['hide_empty'] = 0; + $handler->display->display_options['fields']['nid']['empty_zero'] = 0; + /* Field: Content: Nid */ + $handler->display->display_options['fields']['nid_1']['id'] = 'nid_1'; + $handler->display->display_options['fields']['nid_1']['table'] = 'node'; + $handler->display->display_options['fields']['nid_1']['field'] = 'nid'; + $handler->display->display_options['fields']['nid_1']['alter']['alter_text'] = 0; + $handler->display->display_options['fields']['nid_1']['alter']['make_link'] = 0; + $handler->display->display_options['fields']['nid_1']['alter']['word_boundary'] = 1; + $handler->display->display_options['fields']['nid_1']['alter']['ellipsis'] = 1; + $handler->display->display_options['fields']['nid_1']['alter']['strip_tags'] = 0; + $handler->display->display_options['fields']['nid_1']['alter']['trim'] = 0; + $handler->display->display_options['fields']['nid_1']['alter']['html'] = 0; + $handler->display->display_options['fields']['nid_1']['hide_empty'] = 0; + $handler->display->display_options['fields']['nid_1']['empty_zero'] = 0; + /* Contextual filter: Content: Type */ + $handler->display->display_options['arguments']['type']['id'] = 'type'; + $handler->display->display_options['arguments']['type']['table'] = 'node'; + $handler->display->display_options['arguments']['type']['field'] = 'type'; + $handler->display->display_options['arguments']['type']['default_action'] = 'summary'; + $handler->display->display_options['arguments']['type']['default_argument_type'] = 'fixed'; + $handler->display->display_options['arguments']['type']['summary']['format'] = 'default_summary'; + + + return $view; } /** @@ -48,7 +131,7 @@ class ViewsQueryGroupByTest extends ViewsSqlTest { $types = array(); foreach ($view->result as $item) { - // num_records is a alias for nid. + // 'num_records' is a alias for nid. $types[$item->node_type] = $item->num_records; } @@ -56,9 +139,15 @@ class ViewsQueryGroupByTest extends ViewsSqlTest { $this->assertEqual($types[$type2->type], 3); } - //public function testAggregateSum() { - //} + /** + * + */ + // public function testAggregateSum() { + // } + /** + * + */ public function viewsAggregateCountView() { $view = new view; $view->name = 'aggregate_count'; @@ -103,16 +192,18 @@ class ViewsQueryGroupByTest extends ViewsSqlTest { $handler->display->display_options['arguments']['type']['default_argument_type'] = 'fixed'; $handler->display->display_options['arguments']['type']['summary']['format'] = 'default_summary'; - return $view; } /** - * @param $group_by - * Which group_by function should be used, for example sum or count. + * @param string|null $group_by + * (optional) Which group_by function should be used, for example sum or + * count. If omitted, the aggregation is tested with no group function. + * @param array|null $values + * (optional) Expected values. */ - function GroupByTestHelper($group_by, $values) { - // Create 2 nodes of type1 and 3 nodes of type2 + function GroupByTestHelper($group_by = NULL, $values = NULL) { + // Create 4 nodes of type1 and 3 nodes of type2 $type1 = $this->drupalCreateContentType(); $type2 = $this->drupalCreateContentType(); @@ -136,6 +227,21 @@ class ViewsQueryGroupByTest extends ViewsSqlTest { $output = $view->execute_display(); $this->assertEqual(count($view->result), 2, 'Make sure the count of items is right.'); + + $results = array(); + // There's no need for a function in order to have aggregation. + if (empty($group_by)) { + $types = array($type1->type, $type2->type); + $results = array_map(function ($item) { + return $item->node_type; + }, $view->result); + sort($types); + sort($results); + $this->assertIdentical($results, $types); + // Exit here with no aggregation function. + return; + } + // Group by nodetype to identify the right count. foreach ($view->result as $item) { $results[$item->node_type] = $item->nid; @@ -144,7 +250,10 @@ class ViewsQueryGroupByTest extends ViewsSqlTest { $this->assertEqual($results[$type2->type], $values[1]); } - function viewsGroupByViewHelper($group_by) { + /** + * + */ + function viewsGroupByViewHelper($group_by = NULL) { $view = new view; $view->name = 'group_by_count'; $view->description = ''; @@ -164,21 +273,27 @@ class ViewsQueryGroupByTest extends ViewsSqlTest { $handler->display->display_options['pager']['type'] = 'some'; $handler->display->display_options['style_plugin'] = 'default'; $handler->display->display_options['row_plugin'] = 'fields'; - /* Field: Content: Nid */ - $handler->display->display_options['fields']['nid']['id'] = 'nid'; - $handler->display->display_options['fields']['nid']['table'] = 'node'; - $handler->display->display_options['fields']['nid']['field'] = 'nid'; - $handler->display->display_options['fields']['nid']['group_type'] = $group_by; - $handler->display->display_options['fields']['nid']['alter']['alter_text'] = 0; - $handler->display->display_options['fields']['nid']['alter']['make_link'] = 0; - $handler->display->display_options['fields']['nid']['alter']['trim'] = 0; - $handler->display->display_options['fields']['nid']['alter']['word_boundary'] = 1; - $handler->display->display_options['fields']['nid']['alter']['ellipsis'] = 1; - $handler->display->display_options['fields']['nid']['alter']['strip_tags'] = 0; - $handler->display->display_options['fields']['nid']['alter']['html'] = 0; - $handler->display->display_options['fields']['nid']['hide_empty'] = 0; - $handler->display->display_options['fields']['nid']['empty_zero'] = 0; - $handler->display->display_options['fields']['nid']['link_to_node'] = 0; + + // The test view has 2 fields ('nid' and 'type'). Don't add 'nid' when + // having no aggregation function. We just want to aggregate on node type. + if (!empty($group_by)) { + /* Field: Content: Nid */ + $handler->display->display_options['fields']['nid']['id'] = 'nid'; + $handler->display->display_options['fields']['nid']['table'] = 'node'; + $handler->display->display_options['fields']['nid']['field'] = 'nid'; + $handler->display->display_options['fields']['nid']['group_type'] = $group_by; + $handler->display->display_options['fields']['nid']['alter']['alter_text'] = 0; + $handler->display->display_options['fields']['nid']['alter']['make_link'] = 0; + $handler->display->display_options['fields']['nid']['alter']['trim'] = 0; + $handler->display->display_options['fields']['nid']['alter']['word_boundary'] = 1; + $handler->display->display_options['fields']['nid']['alter']['ellipsis'] = 1; + $handler->display->display_options['fields']['nid']['alter']['strip_tags'] = 0; + $handler->display->display_options['fields']['nid']['alter']['html'] = 0; + $handler->display->display_options['fields']['nid']['hide_empty'] = 0; + $handler->display->display_options['fields']['nid']['empty_zero'] = 0; + $handler->display->display_options['fields']['nid']['link_to_node'] = 0; + } + /* Field: Content: Type */ $handler->display->display_options['fields']['type']['id'] = 'type'; $handler->display->display_options['fields']['type']['table'] = 'node'; @@ -197,27 +312,51 @@ class ViewsQueryGroupByTest extends ViewsSqlTest { return $view; } + /** + * + */ public function testGroupByCount() { $this->GroupByTestHelper('count', array(4, 3)); } - function testGroupBySum() { + /** + * + */ + public function testGroupBySum() { $this->GroupByTestHelper('sum', array(10, 18)); } - - function testGroupByAverage() { + /** + * + */ + public function testGroupByAverage() { $this->GroupByTestHelper('avg', array(2.5, 6)); } - function testGroupByMin() { + /** + * + */ + public function testGroupByMin() { $this->GroupByTestHelper('min', array(1, 5)); } - function testGroupByMax() { + /** + * {@inheritdoc} + */ + public function testGroupByMax() { $this->GroupByTestHelper('max', array(4, 7)); } + /** + * + */ + public function testGroupByNone() { + $this->GroupByTestHelper(); + } + + /** + * + */ public function testGroupByCountOnlyFilters() { // Check if GROUP BY and HAVING are included when a view // Doesn't display SUM, COUNT, MAX... functions in SELECT statment @@ -238,6 +377,9 @@ class ViewsQueryGroupByTest extends ViewsSqlTest { $this->assertTrue(strpos($view->build_info['query'], 'HAVING'), t('Make sure that HAVING is in the query')); } + /** + * + */ function viewsGroupByCountViewOnlyFilters() { $view = new view; $view->name = 'group_by_in_filters'; @@ -282,12 +424,17 @@ class ViewsQueryGroupByTest extends ViewsSqlTest { return $view; } + } /** - * Tests UI of aggregate functionality.. + * Tests UI of aggregate functionality. */ -class viewsUiGroupbyTestCase extends DrupalWebTestCase { +class ViewsUiGroupbyTestCase extends DrupalWebTestCase { + + /** + * {@inheritdoc} + */ function setUp() { // Enable views_ui. parent::setUp('views_ui', 'views_test'); @@ -297,6 +444,9 @@ class viewsUiGroupbyTestCase extends DrupalWebTestCase { $this->drupalLogin($views_admin); } + /** + * Test meta data. + */ public static function getInfo() { return array( 'name' => 'Groupby UI', @@ -323,4 +473,5 @@ class viewsUiGroupbyTestCase extends DrupalWebTestCase { $this->drupalGet('admin/structure/views/nojs/display/test_views_groupby_save/default/group_by'); } + } diff --git a/sites/all/modules/contrib/views/views/tests/views_handler_filter.test b/sites/all/modules/contrib/views/views/tests/views_handler_filter.test new file mode 100644 index 0000000..e41b35a --- /dev/null +++ b/sites/all/modules/contrib/views/views/tests/views_handler_filter.test @@ -0,0 +1,161 @@ + 'Handler filter test', + 'description' => 'test filter handler definitions', + 'group' => 'Views', + ); + } + + /** + * {@inheritdoc} + */ + protected function setUp() { + // The Views and Views UI modules will be enabled with this. + parent::setUp(); + + // Assign vocabulary 'tag' to user entity. + $field_definition = field_read_field('field_tags'); + $instance_definition = array( + 'field_name' => $field_definition['field_name'], + 'entity_type' => 'user', + 'bundle' => 'user', + 'widget' => array( + 'type' => 'taxonomy_autocomplete', + ), + 'display' => array( + 'default' => array( + 'type' => 'taxonomy_term_reference_link', + 'weight' => 10, + ), + 'teaser' => array( + 'type' => 'taxonomy_term_reference_link', + 'weight' => 10, + ), + ), + ); + field_create_instance($instance_definition); + } + + /** + * Tests "is all of" of filter operation. + */ + function testFilterInOperatorUi() { + $term = $this->drupalCreateTerm(1); + + $node1 = $this->drupalCreateNode(array('type' => 'article','field_tags_tid' => $term->tid, 'created' => REQUEST_TIME)); + $node2 = $this->drupalCreateNode(array('type' => 'article', 'created' => REQUEST_TIME + 1)); + $user2 = $this->drupalCreateUser(array('access content')); + // $this->drupalLogin($this->drupalCreateUser(array('administer users')); + $this->drupalLogin($this->drupalCreateUser(array('administer users', 'access administration pages', 'administer site configuration', 'administer nodes', 'bypass node access'))); + + $this->drupalGet('node/1/edit'); + $edit['field_tags' . '[' . LANGUAGE_NONE . ']'] = $term->name; + $this->drupalPost('node/' . $node1->nid . '/edit', $edit, t('Save')); + + $edit['field_tags' . '[' . LANGUAGE_NONE . ']'] = $term->name; + $this->drupalPost('user/' . $user2->uid . '/edit', $edit, t('Save')); + + $result[] = array('nid' => $node1->nid); + $view = $this->get_sample_view(); + $this->executeView($view); + $this->assertIdenticalResultset($view, $result); + } + + /** + * Sample view. + * + * @return \view + */ + protected function get_sample_view() { + $view = new view(); + $view->name = 'article'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'node'; + $view->human_name = 'Article'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Article'; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'full'; + $handler->display->display_options['pager']['options']['items_per_page'] = '10'; + $handler->display->display_options['style_plugin'] = 'table'; + $handler->display->display_options['style_options']['columns'] = array( + 'title' => 'title', + ); + $handler->display->display_options['style_options']['default'] = '-1'; + $handler->display->display_options['style_options']['info'] = array( + 'title' => array( + 'sortable' => 0, + 'default_sort_order' => 'asc', + 'align' => '', + 'separator' => '', + 'empty_column' => 0, + ), + ); + /* Field: Content: Nid */ + $handler->display->display_options['fields']['nid']['id'] = 'nid'; + $handler->display->display_options['fields']['nid']['table'] = 'node'; + $handler->display->display_options['fields']['nid']['field'] = 'nid'; + $handler->display->display_options['fields']['nid']['label'] = ''; + $handler->display->display_options['fields']['nid']['element_label_colon'] = FALSE; + /* Sort criterion: Content: Post date */ + $handler->display->display_options['sorts']['created']['id'] = 'created'; + $handler->display->display_options['sorts']['created']['table'] = 'node'; + $handler->display->display_options['sorts']['created']['field'] = 'created'; + $handler->display->display_options['sorts']['created']['order'] = 'DESC'; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + /* Filter criterion: Field: Tags (field_tags) */ + $handler->display->display_options['filters']['field_tags_tid']['id'] = 'field_tags_tid'; + $handler->display->display_options['filters']['field_tags_tid']['table'] = 'field_data_field_tags'; + $handler->display->display_options['filters']['field_tags_tid']['field'] = 'field_tags_tid'; + $handler->display->display_options['filters']['field_tags_tid']['operator'] = 'and'; + $handler->display->display_options['filters']['field_tags_tid']['value'] = array( + 0 => '1', + ); + $handler->display->display_options['filters']['field_tags_tid']['expose']['operator_id'] = 'field_tags_tid_op'; + $handler->display->display_options['filters']['field_tags_tid']['expose']['label'] = 'Tags (field_tags)'; + $handler->display->display_options['filters']['field_tags_tid']['expose']['operator'] = 'field_tags_tid_op'; + $handler->display->display_options['filters']['field_tags_tid']['expose']['identifier'] = 'field_tags_tid'; + $handler->display->display_options['filters']['field_tags_tid']['expose']['remember_roles'] = array( + 2 => '2', + ); + $handler->display->display_options['filters']['field_tags_tid']['vocabulary'] = 'tags'; + + /* Display: Page */ + $handler = $view->new_display('page', 'Page', 'page'); + $handler->display->display_options['path'] = 'article'; + + return $view; + } + +} diff --git a/sites/all/modules/contrib/views/views/tests/views_handlers.test b/sites/all/modules/contrib/views/views/tests/views_handlers.test index d54a7df..e0ace98 100644 --- a/sites/all/modules/contrib/views/views/tests/views_handlers.test +++ b/sites/all/modules/contrib/views/views/tests/views_handlers.test @@ -48,13 +48,13 @@ class ViewsHandlersTest extends ViewsSqlTest { $empty_stdclass->value = array(); $null = NULL; - // check defaults + // check defaults. $this->assertEqual($empty_stdclass, views_break_phrase_string('', $null)); $handler = views_get_handler('node', 'title', 'argument'); $this->assertEqual($handler, views_break_phrase_string('', $handler)); - // test ors + // test ors. $handler = views_break_phrase_string('word1 word2+word'); $this->assertEqualValue(array('word1', 'word2', 'word'), $handler); $this->assertEqual('or', $handler->operator); @@ -88,7 +88,7 @@ class ViewsHandlersTest extends ViewsSqlTest { $this->assertEqualValue(array('wõrd1', 'wõrd2', 'wõrd'), $handler); $this->assertEqual('and', $handler->operator); - // test a single word + // test a single word. $handler = views_break_phrase_string('word'); $this->assertEqualValue(array('word'), $handler); $this->assertEqual('and', $handler->operator); @@ -103,7 +103,7 @@ class ViewsHandlersTest extends ViewsSqlTest { $empty_stdclass->value = array(); $null = NULL; - // check defaults + // check defaults. $this->assertEqual($empty_stdclass, views_break_phrase('', $null)); $handler = views_get_handler('node', 'title', 'argument'); @@ -113,7 +113,7 @@ class ViewsHandlersTest extends ViewsSqlTest { $n1 = rand(0, 100); $n2 = rand(0, 100); $n3 = rand(0, 100); - // test ors + // test ors. $this->assertEqualValue(array($n1, $n2, $n3), views_break_phrase("$n1 $n2+$n3", $handler)); $this->assertEqual('or', $handler->operator); $this->assertEqualValue(array($n1, $n2, $n3), views_break_phrase("$n1+$n2+$n3", $handler)); @@ -133,7 +133,7 @@ class ViewsHandlersTest extends ViewsSqlTest { /** * Check to see if two values are equal. * - * @param $first + * @param string $first * The first value to check. * @param views_handler $handler * @param string $message @@ -147,4 +147,5 @@ class ViewsHandlersTest extends ViewsSqlTest { protected function assertEqualValue($first, $handler, $message = '', $group = 'Other') { return $this->assert($first == $handler->value, $message ? $message : t('First value is equal to second value'), $group); } + } diff --git a/sites/all/modules/contrib/views/views/tests/views_module.test b/sites/all/modules/contrib/views/views/tests/views_module.test index 6a27443..c3dd994 100644 --- a/sites/all/modules/contrib/views/views/tests/views_module.test +++ b/sites/all/modules/contrib/views/views/tests/views_module.test @@ -45,7 +45,7 @@ class ViewsModuleTest extends ViewsSqlTest { 'khoảng cách từ đại lí đến', 'của hãng bao gồm ba dòng', 'сд асд асд ас', - 'асд асд асд ас' + 'асд асд асд ас', ); // Just test maxlength without word boundry. $alter = array( @@ -91,7 +91,8 @@ class ViewsModuleTest extends ViewsSqlTest { */ function testModuleTemplates() { $views_status = variable_get('views_defaults', array()); - $views_status['frontpage'] = FALSE; // false is enabled + $views_status['frontpage'] = FALSE; + // false is enabled. variable_set('views_defaults', $views_status); $existing = array(); @@ -127,7 +128,6 @@ class ViewsModuleTest extends ViewsSqlTest { } // Test the automatic conversion feature. - // Test the automatic table renaming. $handler = views_get_handler('views_test_previous', 'id', 'field'); $this->assertInstanceHandler($handler, 'views_test', 'id', 'field'); @@ -194,6 +194,29 @@ class ViewsModuleTest extends ViewsSqlTest { $this->assertEqual(variable_get('views_test_views_data_count', 0), 1, 'Views data rebuilt once'); $this->assertFalse(drupal_static('_views_fetch_data_fully_loaded'), 'Views data is not fully loaded'); + // Test if the cache consistency is ensured. There was an issue where + // calling _views_fetch_data() first with a table would prevent the function + // from properly rebuilt a missing the general cache entry. + // See https://www.drupal.org/node/2475669 for details. + // Make sure we start with a empty cache. + $this->resetStaticViewsDataCache(); + cache_clear_all('*', 'cache_views', TRUE); + + // Prime the static cache of _views_fetch_data() by calling it with a table + // first. + views_fetch_data('views_test'); + // Now remove the general cache. + cache_clear_all('views_data:en', 'cache_views'); + // Reset the static cache to see if fetches from the persistent cache + // properly rebuild the static cache. + $this->resetStaticViewsDataCache(); + // Prime the static cache of _views_fetch_data() by calling it with a table + // first. + views_fetch_data('views_test'); + // Fetch the general cache, which was deleted, an see if it is rebuild + // properly. + views_fetch_data(); + $this->assertTrue(cache_get('views_data:en', 'cache_views'), 'Cache for all tables was properly rebuild.'); } /** @@ -214,4 +237,5 @@ class ViewsModuleTest extends ViewsSqlTest { drupal_static_reset('_views_fetch_data_recursion_protected'); drupal_static_reset('_views_fetch_data_fully_loaded'); } + } diff --git a/sites/all/modules/contrib/views/views/tests/views_pager.test b/sites/all/modules/contrib/views/views/tests/views_pager.test index fef4915..7a99fb6 100644 --- a/sites/all/modules/contrib/views/views/tests/views_pager.test +++ b/sites/all/modules/contrib/views/views/tests/views_pager.test @@ -9,6 +9,10 @@ * Tests the pluggable pager system. */ class ViewsPagerTest extends ViewsSqlTest { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Pager', @@ -17,6 +21,9 @@ class ViewsPagerTest extends ViewsSqlTest { ); } + /** + * + */ public function setUp() { parent::setUp('views', 'views_ui', 'views_test'); } @@ -29,11 +36,10 @@ class ViewsPagerTest extends ViewsSqlTest { public function testStorePagerSettings() { $admin_user = $this->drupalCreateUser(array('administer views', 'administer site configuration')); $this->drupalLogin($admin_user); - // Test behaviour described in http://drupal.org/node/652712#comment-2354918. - + // Test behaviour described in + // http://drupal.org/node/652712#comment-2354918. $this->drupalGet('admin/structure/views/view/frontpage/edit'); - $edit = array( 'pager_options[items_per_page]' => 20, ); @@ -70,8 +76,8 @@ class ViewsPagerTest extends ViewsSqlTest { $this->drupalPost('admin/structure/views/nojs/display/test_store_pager_settings/default/pager_options', $edit, t('Apply')); $this->assertText('20 items'); - // add new display and test the settings again, by override it. - $edit = array( ); + // Add new display and test the settings again, by override it. + $edit = array(); // Add a display and override the pager settings. $this->drupalPost('admin/structure/views/view/test_store_pager_settings/edit', $edit, t('Add Page')); $edit = array( @@ -91,11 +97,13 @@ class ViewsPagerTest extends ViewsSqlTest { ); $this->drupalPost('admin/structure/views/nojs/display/test_store_pager_settings/default/pager_options', $edit, t('Apply')); $this->assertText('20 items'); - } + /** + * + */ public function viewsStorePagerSettings() { - $view = new view; + $view = new view(); $view->name = 'test_store_pager_settings'; $view->description = ''; $view->tag = ''; @@ -120,8 +128,8 @@ class ViewsPagerTest extends ViewsSqlTest { * Tests the none-pager-query. */ public function testNoLimit() { - // Create 11 nodes and make sure that everyone is returned. - // We create 11 nodes, because the default pager plugin had 10 items per page. + // Create 11 nodes and make sure that everyone is returned. We create 11 + // nodes, because the default pager plugin had 10 items per page. for ($i = 0; $i < 11; $i++) { $this->drupalCreateNode(); } @@ -153,15 +161,18 @@ class ViewsPagerTest extends ViewsSqlTest { $this->assertEqual($view->query->pager->get_items_per_page(), 0); } + /** + * + */ public function viewsPagerNoLimit() { - $view = new view; + $view = new view(); $view->name = 'test_pager_none'; $view->description = ''; $view->tag = ''; $view->view_php = ''; $view->base_table = 'node'; $view->is_cacheable = FALSE; - $view->api_version =3; + $view->api_version = 3; $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ /* Display: Master */ @@ -175,6 +186,9 @@ class ViewsPagerTest extends ViewsSqlTest { return $view; } + /** + * + */ public function testViewTotalRowsWithoutPager() { $this->createNodes(23); @@ -186,6 +200,9 @@ class ViewsPagerTest extends ViewsSqlTest { $this->assertEqual($view->total_rows, 23, "'total_rows' is calculated when pager type is 'none' and 'get_total_rows' is TRUE."); } + /** + * + */ public function createNodes($count) { if ($count >= 0) { for ($i = 0; $i < $count; $i++) { @@ -198,8 +215,8 @@ class ViewsPagerTest extends ViewsSqlTest { * Tests the some pager plugin. */ public function testLimit() { - // Create 11 nodes and make sure that everyone is returned. - // We create 11 nodes, because the default pager plugin had 10 items per page. + // Create 11 nodes and make sure that everyone is returned. We create 11 + // nodes, because the default pager plugin had 10 items per page. for ($i = 0; $i < 11; $i++) { $this->drupalCreateNode(); } @@ -229,8 +246,11 @@ class ViewsPagerTest extends ViewsSqlTest { $this->assertFalse($view->query->pager->use_count_query()); } + /** + * + */ public function viewsPagerLimit() { - $view = new view; + $view = new view(); $view->name = 'test_pager_some'; $view->description = ''; $view->tag = ''; @@ -257,8 +277,8 @@ class ViewsPagerTest extends ViewsSqlTest { * Tests the normal pager. */ public function testNormalPager() { - // Create 11 nodes and make sure that everyone is returned. - // We create 11 nodes, because the default pager plugin had 10 items per page. + // Create 11 nodes and make sure that everyone is returned. We create 11 + // nodes, because the default pager plugin had 10 items per page. for ($i = 0; $i < 11; $i++) { $this->drupalCreateNode(); } @@ -290,8 +310,7 @@ class ViewsPagerTest extends ViewsSqlTest { $this->assertEqual(count($view->result), 11, 'All items are return'); - // TODO test number of pages. - + // @todo test number of pages. // Test items per page = 0. $view->destroy(); @@ -313,8 +332,11 @@ class ViewsPagerTest extends ViewsSqlTest { $this->assertEqual(count($view->result), 11); } + /** + * + */ function viewPagerFullZeroItemsPerPage() { - $view = new view; + $view = new view(); $view->name = 'view_pager_full_zero_items_per_page'; $view->description = ''; $view->tag = ''; @@ -353,8 +375,11 @@ class ViewsPagerTest extends ViewsSqlTest { return $view; } + /** + * + */ function viewsPagerFull() { - $view = new view; + $view = new view(); $view->name = 'test_pager_full'; $view->description = ''; $view->tag = ''; @@ -379,8 +404,11 @@ class ViewsPagerTest extends ViewsSqlTest { return $view; } + /** + * + */ function viewsPagerFullFields() { - $view = new view; + $view = new view(); $view->name = 'test_pager_full'; $view->description = ''; $view->tag = ''; @@ -421,22 +449,24 @@ class ViewsPagerTest extends ViewsSqlTest { * Tests the minipager. */ public function testMiniPager() { - // the functionality is the same as the normal pager, so i don't know what to test here. + // The functionality is the same as the normal pager, so i don't know what + // to test here. } /** * Tests rendering with NULL pager. */ public function testRenderNullPager() { - // Create 11 nodes and make sure that everyone is returned. - // We create 11 nodes, because the default pager plugin had 10 items per page. + // Create 11 nodes and make sure that everyone is returned. We create 11 + // nodes, because the default pager plugin had 10 items per page. for ($i = 0; $i < 11; $i++) { $this->drupalCreateNode(); } $view = $this->viewsPagerFullFields(); $view->set_display('default'); $this->executeView($view); - $view->use_ajax = TRUE; // force the value again here + $view->use_ajax = TRUE; + // force the value again here. $view->query->pager = NULL; $output = $view->render(); $this->assertEqual(preg_match('/
    /', $output), 0, t('The pager is not rendered.')); @@ -448,7 +478,6 @@ class ViewsPagerTest extends ViewsSqlTest { function testPagerApi() { $view = $this->viewsPagerFull(); // On the first round don't initialize the pager. - $this->assertEqual($view->get_items_per_page(), NULL, 'If the pager is not initialized and no manual override there is no items per page.'); $rand_number = rand(1, 5); $view->set_items_per_page($rand_number); @@ -491,6 +520,6 @@ class ViewsPagerTest extends ViewsSqlTest { $rand_number = rand(6, 11); $view->query->pager->set_current_page($rand_number); $this->assertEqual($view->get_current_page(), $rand_number, 'Make sure get_current_page uses the settings of set_current_page.'); - } + } diff --git a/sites/all/modules/contrib/views/views/tests/views_plugin_localization_test.inc b/sites/all/modules/contrib/views/views/tests/views_plugin_localization_test.inc index 1987fd8..ce90dff 100644 --- a/sites/all/modules/contrib/views/views/tests/views_plugin_localization_test.inc +++ b/sites/all/modules/contrib/views/views/tests/views_plugin_localization_test.inc @@ -9,15 +9,17 @@ * A stump localisation plugin which has static variables to cache the input. */ class views_plugin_localization_test extends views_plugin_localization { + /** * Store the strings which was translated. */ - var $translated_strings; + public $translated_strings; + /** * Return the string and take sure that the test can find out whether the * string got translated. */ - function translate_string($string, $keys = array(), $format = '') { + public function translate_string($string, $keys = array(), $format = '') { $this->translated_strings[] = $string; return $string . "-translated"; } @@ -25,7 +27,7 @@ class views_plugin_localization_test extends views_plugin_localization { /** * Store the export strings. */ - function export($source) { + public function export($source) { if (!empty($source['value'])) { $this->export_strings[] = $source['value']; } @@ -34,7 +36,8 @@ class views_plugin_localization_test extends views_plugin_localization { /** * Return the stored strings for the simpletest. */ - function get_export_strings() { + public function get_export_strings() { return $this->export_strings; } + } diff --git a/sites/all/modules/contrib/views/views/tests/views_query.test b/sites/all/modules/contrib/views/views/tests/views_query.test index 735df0e..5acf01e 100644 --- a/sites/all/modules/contrib/views/views/tests/views_query.test +++ b/sites/all/modules/contrib/views/views/tests/views_query.test @@ -2,13 +2,24 @@ /** * @file - * Tests for Views query features. + * Abstract class for views testing. */ /** - * Abstract class for views testing. + * */ abstract class ViewsTestCase extends DrupalWebTestCase { + + /** + * + */ + protected $sort_column = NULL; + + /** + * + */ + protected $sort_order = 1; + /** * Helper function: verify a result set returned by view. * @@ -16,13 +27,13 @@ abstract class ViewsTestCase extends DrupalWebTestCase { * column map, taking the order of the rows into account, but not the order * of the columns. * - * @param $view - * An executed View. - * @param $expected_result - * An expected result set. - * @param $column_map - * An associative array mapping the columns of the result set from the view - * (as keys) and the expected result set (as values). + * @param view $view + * An executed View. + * @param array $expected_result + * An expected result set. + * @param array $column_map + * An associative array mapping the columns of the result set from the view + * (as keys) and the expected result set (as values). */ protected function assertIdenticalResultset($view, $expected_result, $column_map = array(), $message = 'Identical result set') { return $this->assertIdenticalResultsetHelper($view, $expected_result, $column_map, $message, 'assertIdentical'); @@ -33,25 +44,29 @@ abstract class ViewsTestCase extends DrupalWebTestCase { * * Inverse of ViewsTestCase::assertIdenticalResultset(). * - * @param $view - * An executed View. - * @param $expected_result - * An expected result set. - * @param $column_map - * An associative array mapping the columns of the result set from the view - * (as keys) and the expected result set (as values). + * @param view $view + * An executed View. + * @param array $expected_result + * An expected result set. + * @param array $column_map + * An associative array mapping the columns of the result set from the view + * (as keys) and the expected result set (as values). */ protected function assertNotIdenticalResultset($view, $expected_result, $column_map = array(), $message = 'Identical result set') { return $this->assertIdenticalResultsetHelper($view, $expected_result, $column_map, $message, 'assertNotIdentical'); } + /** + * + */ protected function assertIdenticalResultsetHelper($view, $expected_result, $column_map, $message, $assert_method) { // Convert $view->result to an array of arrays. $result = array(); foreach ($view->result as $key => $value) { $row = array(); foreach ($column_map as $view_column => $expected_column) { - // The comparison will be done on the string representation of the value. + // The comparison will be done on the string representation of the + // value. $row[$expected_column] = (string) $value->$view_column; } $result[$key] = $row; @@ -61,7 +76,8 @@ abstract class ViewsTestCase extends DrupalWebTestCase { foreach ($expected_result as $key => $value) { $row = array(); foreach ($column_map as $expected_column) { - // The comparison will be done on the string representation of the value. + // The comparison will be done on the string representation of the + // value. $row[$expected_column] = (string) (is_object($value) ? $value->$expected_column : $value[$expected_column]); } $expected_result[$key] = $row; @@ -71,14 +87,14 @@ abstract class ViewsTestCase extends DrupalWebTestCase { $result = array_values($result); $expected_result = array_values($expected_result); - $this->verbose('
    Returned data set: ' . print_r($result, TRUE) . "\n\nExpected: ". print_r($expected_result, TRUE));
    +    $this->verbose('
    Returned data set: ' . print_r($result, TRUE) . "\n\nExpected: " . print_r($expected_result, TRUE));
     
         // Do the actual comparison.
         return $this->$assert_method($result, $expected_result, $message);
       }
     
       /**
    -   * Helper function: order an array of array based on a column.
    +   * Order an array of array based on a column.
        */
       protected function orderResultSet($result_set, $column, $reverse = FALSE) {
         $this->sort_column = $column;
    @@ -87,9 +103,6 @@ abstract class ViewsTestCase extends DrupalWebTestCase {
         return $result_set;
       }
     
    -  protected $sort_column = NULL;
    -  protected $sort_order = 1;
    -
       /**
        * Helper comparison function for orderResultSet().
        */
    @@ -97,20 +110,20 @@ abstract class ViewsTestCase extends DrupalWebTestCase {
         $value1 = $a[$this->sort_column];
         $value2 = $b[$this->sort_column];
         if ($value1 == $value2) {
    -        return 0;
    +      return 0;
         }
         return $this->sort_order * (($value1 < $value2) ? -1 : 1);
       }
     
       /**
    -   * Helper function to check whether a button with a certain id exists and has a certain label.
    +   * Check whether a button with a certain id exists and has a certain label.
        */
       protected function helperButtonHasLabel($id, $expected_label, $message = 'Label has the expected value: %label.') {
         return $this->assertFieldById($id, $expected_label, t($message, array('%label' => $expected_label)));
       }
     
       /**
    -   * Helper function to execute a view with debugging.
    +   * Execute a view with debugging.
        *
        * @param view $view
        * @param array $args
    @@ -121,18 +134,42 @@ abstract class ViewsTestCase extends DrupalWebTestCase {
         $view->execute();
         $this->verbose('
    Executed view: ' . ((string) $view->build_info['query']) . '
    '); } + + /** + * Log in as user 1. + */ + protected function loginUser1() { + $password = user_password(); + // Reset the user 1 password. + $account = user_load(1); + $edit = array( + 'pass' => $password, + ); + $account = user_save($account, $edit); + $account->pass_raw = $password; + + // Log in as user 1. + $this->drupalLogin($account); + } + } +/** + * + */ abstract class ViewsSqlTest extends ViewsTestCase { + /** + * {@inheritdoc} + */ protected function setUp() { parent::setUp('views', 'views_ui'); - // Define the schema and views data variable before enabling the test module. + // Define the schema and views data variable before enabling the test + // module. variable_set('views_test_schema', $this->schemaDefinition()); variable_set('views_test_views_data', $this->viewsData()); variable_set('views_test_views_plugins', $this->viewsPlugins()); - module_enable(array('views_test')); $this->resetAll(); @@ -148,14 +185,32 @@ abstract class ViewsSqlTest extends ViewsTestCase { } /** - * This function allows to enable views ui from a higher class which can't change the setup function anymore. + * Create a term. * - * @TODO - * Convert existing setUp functions. + * @param int $vid + * The vocabulary ID that the term is to be added to. + * + * @return object + * A full term object with a random name. + */ + protected function drupalCreateTerm($vid) { + $term = new stdClass(); + $term->name = $this->randomName(); + $term->description = $this->randomName(); + $term->vid = $vid; + taxonomy_term_save($term); + return $term; + } + + /** + * This function allows to enable views ui from a higher class which can't + * change the setup function anymore. + * + * @todo Convert existing setUp functions. */ function enableViewsUi() { module_enable(array('views_ui')); - // @TODO Figure out why it's required to clear the cache here. + // @todo Figure out why it's required to clear the cache here. views_module_include('views_default', TRUE); views_get_all_views(TRUE); menu_rebuild(); @@ -203,7 +258,7 @@ abstract class ViewsSqlTest extends ViewsTestCase { ), 'primary key' => array('id'), 'unique keys' => array( - 'name' => array('name') + 'name' => array('name'), ), 'indexes' => array( 'ages' => array('age'), @@ -315,6 +370,9 @@ abstract class ViewsSqlTest extends ViewsTestCase { return $data; } + /** + * + */ protected function viewsPlugins() { return array(); } @@ -423,11 +481,12 @@ abstract class ViewsSqlTest extends ViewsTestCase { views_include('view'); $view = $this->getBasicView(); - // In order to test exposed filters, we have to disable - // the exposed forms cache. + // In order to test exposed filters, we have to disable the exposed forms + // cache. drupal_static_reset('views_exposed_form_cache'); $display = $view->new_display('page', 'Page', 'page_1'); return $view; } + } diff --git a/sites/all/modules/contrib/views/views/tests/views_test.info b/sites/all/modules/contrib/views/views/tests/views_test.info index b090daa..5095b7f 100644 --- a/sites/all/modules/contrib/views/views/tests/views_test.info +++ b/sites/all/modules/contrib/views/views/tests/views_test.info @@ -5,9 +5,8 @@ core = 7.x dependencies[] = views hidden = TRUE -; Information added by Drupal.org packaging script on 2015-02-11 -version = "7.x-3.10" +; Information added by Drupal.org packaging script on 2019-04-03 +version = "7.x-3.22" core = "7.x" project = "views" -datestamp = "1423648085" - +datestamp = "1554307093" diff --git a/sites/all/modules/contrib/views/views/tests/views_test.module b/sites/all/modules/contrib/views/views/tests/views_test.module index a746069..caa87b9 100644 --- a/sites/all/modules/contrib/views/views/tests/views_test.module +++ b/sites/all/modules/contrib/views/views/tests/views_test.module @@ -23,7 +23,7 @@ function views_test_permission() { function views_test_views_api() { return array( 'api' => 3.0, - 'template path' => drupal_get_path('module', 'views_test') . '/templates', + 'template path' => drupal_get_path('module', 'views') . '/test_templates', ); } @@ -35,7 +35,7 @@ function views_test_views_data() { $count = variable_get('views_test_views_data_count', 0); $count++; variable_set('views_test_views_data_count', $count); - return variable_get('views_test_views_data', array()); + return variable_get('views_test_views_data', array()); } /** diff --git a/sites/all/modules/contrib/views/views/tests/views_test.views_default.inc b/sites/all/modules/contrib/views/views/tests/views_test.views_default.inc index 0448705..a494a4e 100644 --- a/sites/all/modules/contrib/views/views/tests/views_test.views_default.inc +++ b/sites/all/modules/contrib/views/views/tests/views_test.views_default.inc @@ -9,7 +9,7 @@ * Implements hook_views_default_views(). */ function views_test_views_default_views() { - $view = new view; + $view = new view(); $view->name = 'test_views_groupby_save'; $view->description = ''; $view->tag = ''; @@ -31,7 +31,7 @@ function views_test_views_default_views() { $views[$view->name] = $view; - $view = new view; + $view = new view(); $view->name = 'test_rename_reset_button'; $view->description = ''; $view->tag = ''; @@ -70,7 +70,7 @@ function views_test_views_default_views() { $views[$view->name] = $view; - $view = new view; + $view = new view(); $view->name = 'test_exposed_admin_ui'; $view->description = ''; $view->tag = ''; @@ -110,7 +110,7 @@ function views_test_views_default_views() { $views[$view->name] = $view; - $view = new view; + $view = new view(); $view->name = 'test_filter_in_operator_ui'; $view->description = ''; $view->tag = ''; @@ -142,7 +142,7 @@ function views_test_views_default_views() { $views[$view->name] = $view; - $view = new view; + $view = new view(); $view->name = 'test_argument_default_current_user'; $view->description = ''; $view->tag = ''; @@ -218,5 +218,113 @@ function views_test_views_default_views() { $views[$view->name] = $view; + $view = new view(); + $view->name = 'test_exposed_remember'; + $view->description = ''; + $view->tag = ''; + $view->base_table = 'node'; + $view->human_name = 'test_exposed_remember'; + $view->core = 0; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'none'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['exposed_form']['options']['reset_button'] = TRUE; + $handler->display->display_options['pager']['type'] = 'none'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'node'; + /* Sort criterion: Content: Post date */ + $handler->display->display_options['sorts']['created']['id'] = 'created'; + $handler->display->display_options['sorts']['created']['table'] = 'node'; + $handler->display->display_options['sorts']['created']['field'] = 'created'; + /* Filter criterion: Content: Type */ + $handler->display->display_options['filters']['type']['id'] = 'type'; + $handler->display->display_options['filters']['type']['table'] = 'node'; + $handler->display->display_options['filters']['type']['field'] = 'type'; + $handler->display->display_options['filters']['type']['exposed'] = TRUE; + $handler->display->display_options['filters']['type']['expose']['operator_id'] = 'type_op'; + $handler->display->display_options['filters']['type']['expose']['label'] = 'Type'; + $handler->display->display_options['filters']['type']['expose']['operator'] = 'type_op'; + $handler->display->display_options['filters']['type']['expose']['identifier'] = 'type'; + $handler->display->display_options['filters']['type']['expose']['remember'] = TRUE; + $handler->display->display_options['filters']['type']['expose']['remember_roles'] = array( + 2 => '2', + ); + + /* Display: Page */ + $handler = $view->new_display('page', 'Page', 'page_1'); + $handler->display->display_options['path'] = 'test_exposed_remember'; + $translatables['test_exposed_remember'] = array( + t('Master'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Type'), + t('Page'), + ); + + $views[$view->name] = $view; + + $view = new view(); + $view->name = 'test_ajax_view'; + $view->description = ''; + $view->tag = ''; + $view->base_table = 'node'; + $view->human_name = ''; + $view->core = 0; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['use_ajax'] = TRUE; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'none'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'none'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'node'; + + /* Display: Page */ + $handler = $view->new_display('page', 'Page', 'page_1'); + $handler->display->display_options['path'] = 'test_ajax_view'; + + $views[$view->name] = $view; + + $view = new view(); + $view->name = 'test_noajax_view'; + $view->description = ''; + $view->tag = ''; + $view->base_table = 'node'; + $view->human_name = ''; + $view->core = 0; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['use_ajax'] = FALSE; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'none'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'none'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'node'; + + $views[$view->name] = $view; + return $views; } diff --git a/sites/all/modules/contrib/views/views/tests/views_translatable.test b/sites/all/modules/contrib/views/views/tests/views_translatable.test index 983a97e..9c3422c 100644 --- a/sites/all/modules/contrib/views/views/tests/views_translatable.test +++ b/sites/all/modules/contrib/views/views/tests/views_translatable.test @@ -31,7 +31,7 @@ class ViewsTranslatableTest extends ViewsSqlTest { 'help' => t('This is a test description.'), 'handler' => 'views_plugin_localization_test', 'parent' => 'parent', - 'path' => drupal_get_path('module', 'views') .'/tests', + 'path' => drupal_get_path('module', 'views') . '/tests', ), ), ); @@ -100,7 +100,6 @@ class ViewsTranslatableTest extends ViewsSqlTest { $view->init_display(); // Don't run translation. We just want to get the right keys. - foreach ($view->display as $display_id => $display) { $translatables = array(); $display->handler->unpack_translatables($translatables); @@ -145,7 +144,7 @@ class ViewsTranslatableTest extends ViewsSqlTest { } public function view_unpack_translatable() { - $view = new view; + $view = new view(); $view->name = 'view_unpack_translatable'; $view->description = ''; $view->tag = ''; @@ -218,4 +217,5 @@ class ViewsTranslatableTest extends ViewsSqlTest { return $view; } + } diff --git a/sites/all/modules/contrib/views/views/tests/views_ui.test b/sites/all/modules/contrib/views/views/tests/views_ui.test index 8785539..8a7e0e1 100644 --- a/sites/all/modules/contrib/views/views/tests/views_ui.test +++ b/sites/all/modules/contrib/views/views/tests/views_ui.test @@ -9,6 +9,10 @@ * Views UI wizard tests. */ class ViewsUIWizardHelper extends DrupalWebTestCase { + + /** + * + */ function setUp() { // Enable views_ui. parent::setUp('views_ui'); @@ -17,12 +21,17 @@ class ViewsUIWizardHelper extends DrupalWebTestCase { $views_admin = $this->drupalCreateUser(array('administer views', 'administer blocks', 'bypass node access', 'access user profiles', 'view revisions')); $this->drupalLogin($views_admin); } + } /** * Tests creating views with the wizard and viewing them on the listing page. */ class ViewsUIWizardBasicTestCase extends ViewsUIWizardHelper { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Views UI wizard basic functionality', @@ -31,6 +40,9 @@ class ViewsUIWizardBasicTestCase extends ViewsUIWizardHelper { ); } + /** + * + */ function testViewsWizardAndListing() { // Check if we can access the main views admin page. $this->drupalGet('admin/structure/views'); @@ -46,7 +58,7 @@ class ViewsUIWizardBasicTestCase extends ViewsUIWizardHelper { $this->assertText(t('Your view was saved. You may edit it from the list below.')); $this->assertText($view1['human_name']); $this->assertText($view1['description']); - foreach(array('delete', 'clone', 'edit') as $operation) { + foreach (array('delete', 'clone', 'edit') as $operation) { $this->assertLinkByHref(url('admin/structure/views/view/' . $view1['name'] . '/' . $operation)); } @@ -146,12 +158,17 @@ class ViewsUIWizardBasicTestCase extends ViewsUIWizardHelper { // Make sure the listing page doesn't show disabled default views. $this->assertNoText('tracker', t('Default tracker view does not show on the listing page.')); } + } /** * Tests enabling, disabling, and reverting default views via the listing page. */ class ViewsUIWizardDefaultViewsTestCase extends ViewsUIWizardHelper { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Views UI default views functionality', @@ -168,10 +185,9 @@ class ViewsUIWizardDefaultViewsTestCase extends ViewsUIWizardHelper { // the listing page). $edit_href = 'admin/structure/views/view/frontpage/edit'; $this->drupalGet('admin/structure/views'); - // TODO: Disabled default views do now appear on the front page. Test this + // @todo Disabled default views do now appear on the front page. Test this // behavior with templates instead. // $this->assertNoLinkByHref($edit_href); - // Enable the front page view, and make sure it is now visible on the main // listing page. $this->drupalGet('admin/structure/views/templates'); @@ -205,7 +221,7 @@ class ViewsUIWizardDefaultViewsTestCase extends ViewsUIWizardHelper { // Now disable the view, and make sure it stops appearing on the main view // listing page but instead goes back to displaying on the disabled views // listing page. - // TODO: Test this behavior with templates instead. + // @todo Test this behavior with templates instead. $this->drupalGet('admin/structure/views'); $this->clickViewsOperationLink(t('Disable'), '/frontpage/'); // $this->assertUrl('admin/structure/views'); @@ -225,15 +241,15 @@ class ViewsUIWizardDefaultViewsTestCase extends ViewsUIWizardHelper { * various views listing pages, and they might have tokens in them. So we * need special code to find the correct one to click. * - * @param $label + * @param string $label * Text between the anchor tags of the desired link. - * @param $unique_href_part + * @param string $unique_href_part * A unique string that is expected to occur within the href of the desired * link. For example, if the link URL is expected to look like * "admin/structure/views/view/frontpage/...", then "/frontpage/" could be * passed as the expected unique string. * - * @return + * @return string * The page content that results from clicking on the link, or FALSE on * failure. Failure also results in a failed assertion. */ @@ -254,18 +270,42 @@ class ViewsUIWizardDefaultViewsTestCase extends ViewsUIWizardHelper { return FALSE; } } + } /** * Tests the ability of the views wizard to create views filtered by taxonomy. */ class ViewsUIWizardTaggedWithTestCase extends ViewsUIWizardHelper { + + /** + * + */ protected $node_type_with_tags; + + /** + * + */ protected $node_type_without_tags; + + /** + * + */ protected $tag_vocabulary; + + /** + * + */ protected $tag_field; + + /** + * + */ protected $tag_instance; + /** + * + */ public static function getInfo() { return array( 'name' => 'Views UI wizard taxonomy functionality', @@ -274,6 +314,9 @@ class ViewsUIWizardTaggedWithTestCase extends ViewsUIWizardHelper { ); } + /** + * {@inheritdoc} + */ function setUp() { parent::setUp(); @@ -392,7 +435,7 @@ class ViewsUIWizardTaggedWithTestCase extends ViewsUIWizardHelper { } /** - * Tests that the "tagged with" form element only shows for node types that support it. + * Test the "tagged with" form element only shows for node types that support it. */ function testTaggedWithByNodeType() { // The tagging field is associated with one of our node types only. So the @@ -422,12 +465,17 @@ class ViewsUIWizardTaggedWithTestCase extends ViewsUIWizardHelper { $this->drupalPost(NULL, $view, t('Update "of type" choice')); $this->assertFieldByXpath($tags_xpath); } + } /** * Tests the ability of the views wizard to create views with sorts. */ class ViewsUIWizardSortingTestCase extends ViewsUIWizardHelper { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Views UI wizard sorting functionality', @@ -492,12 +540,17 @@ class ViewsUIWizardSortingTestCase extends ViewsUIWizardHelper { $pos1 = strpos($content, $node1->title); $this->assertTrue($pos3 < $pos2 && $pos2 < $pos1, t('The nodes appear in the expected order in a view that sorts by newest first.')); } + } /** - * Tests the ability of the views wizard to specify the number of items per page. + * Tests the ability of the wizard to specify the number of items per page. */ class ViewsUIWizardItemsPerPageTestCase extends ViewsUIWizardHelper { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Views UI wizard items per page functionality', @@ -577,12 +630,17 @@ class ViewsUIWizardItemsPerPageTestCase extends ViewsUIWizardHelper { $pos3 = strpos($content, $node3->title); $this->assertTrue($pos5 < $pos4 && $pos4 < $pos3, t('The nodes appear in the expected order in the block display.')); } + } /** * Tests the ability of the views wizard to put views in a menu. */ class ViewsUIWizardMenuTestCase extends ViewsUIWizardHelper { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Views UI wizard menu functionality', @@ -625,12 +683,17 @@ class ViewsUIWizardMenuTestCase extends ViewsUIWizardHelper { } $this->assertTrue($found, t('Found a link to %path in the main menu', array('%path' => $view['page[path]']))); } + } /** - * Tests the ability of the views wizard to create views with a jump menu style plugin. + * Tests the ability of the wizard to create views with a jump menu style. */ class ViewsUIWizardJumpMenuTestCase extends ViewsUIWizardHelper { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Views UI wizard jump menu functionality', @@ -683,7 +746,6 @@ class ViewsUIWizardJumpMenuTestCase extends ViewsUIWizardHelper { // Submit the jump menu form, and check that we are redirected to the // expected URL. - $edit = array(); $edit['jump'] = url($path, $options); @@ -786,12 +848,17 @@ class ViewsUIWizardJumpMenuTestCase extends ViewsUIWizardHelper { node_save($node); return 'node/' . $node->nid . '/revisions/' . $node->vid . '/view'; } + } /** * Tests that displays can be correctly overridden via the user interface. */ class ViewsUIWizardOverrideDisplaysTestCase extends ViewsUIWizardHelper { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Views UI overridden displays', @@ -948,9 +1015,8 @@ class ViewsUIWizardOverrideDisplaysTestCase extends ViewsUIWizardHelper { * Tests that the revert to all displays select-option works as expected. */ function testRevertAllDisplays() { - // Create a basic view with a page, block. - // Because there is both a title on page and block we expect the title on - // the block be overriden. + // Create a basic view with a page, block. Because there is both a title on + // page and block we expect the title on the block be overriden. $view['human_name'] = $this->randomName(16); $view['name'] = strtolower($this->randomName(16)); $view['page[create]'] = 1; @@ -970,4 +1036,5 @@ class ViewsUIWizardOverrideDisplaysTestCase extends ViewsUIWizardHelper { $this->drupalPost("admin/structure/views/view/{$view['name']}/edit/block", array(), t('Save')); $this->assertText($view['page[title]']); } + } diff --git a/sites/all/modules/contrib/views/views/tests/views_upgrade.test b/sites/all/modules/contrib/views/views/tests/views_upgrade.test index 3f453db..0c4da8f 100644 --- a/sites/all/modules/contrib/views/views/tests/views_upgrade.test +++ b/sites/all/modules/contrib/views/views/tests/views_upgrade.test @@ -11,6 +11,10 @@ * You can find all conversions by searching for "moved to". */ class ViewsUpgradeTestCase extends ViewsSqlTest { + + /** + * + */ public static function getInfo() { return array( 'name' => 'Views Upgrade test', @@ -19,14 +23,21 @@ class ViewsUpgradeTestCase extends ViewsSqlTest { ); } + /** + * {@inheritdoc} + */ protected function setUp() { -// // To import a view the user needs use PHP for settings rights, so enable php module. + // To import a view the user needs use PHP for settings rights, so enable + // PHP module. parent::setUp(); module_enable(array('php')); $this->resetAll(); } + /** + * + */ function viewsData() { $data = parent::viewsData(); $data['views_test']['old_field_1']['moved to'] = array('views_test', 'id'); @@ -41,6 +52,9 @@ class ViewsUpgradeTestCase extends ViewsSqlTest { return $data; } + /** + * + */ function debugField($field) { $keys = array('id', 'table', 'field', 'actual_field', 'original_field', 'real_field'); $info = array(); @@ -59,8 +73,11 @@ class ViewsUpgradeTestCase extends ViewsSqlTest { $view->update(); $view->build(); -// $this->assertEqual('old_field_1', $view->field['old_field_1']->options['id'], "Id shouldn't change during conversion"); -// $this->assertEqual('id', $view->field['old_field_1']->field, 'The field should change during conversion'); + // $this->assertEqual('old_field_1', + // $view->field['old_field_1']->options['id'], + // "Id shouldn't change during conversion"); + // $this->assertEqual('id', $view->field['old_field_1']->field, + // 'The field should change during conversion'); $this->assertEqual('id', $view->field['old_field_1']->real_field); $this->assertEqual('views_test', $view->field['old_field_1']->table); $this->assertEqual('old_field_1', $view->field['old_field_1']->original_field, 'The field should have stored the original_field'); @@ -70,11 +87,13 @@ class ViewsUpgradeTestCase extends ViewsSqlTest { $view->update(); $view->build(); -// $this->assertEqual('old_field_2', $view->field['old_field_2']->options['id']); + // $this->assertEqual('old_field_2', + // $view->field['old_field_2']->options['id']); $this->assertEqual('name', $view->field['old_field_2']->real_field); $this->assertEqual('views_test', $view->field['old_field_2']->table); -// $this->assertEqual('old_field_3', $view->filter['old_field_3']->options['id']); + // $this->assertEqual('old_field_3', + // $view->filter['old_field_3']->options['id']); $this->assertEqual('age', $view->filter['old_field_3']->real_field); $this->assertEqual('views_test', $view->filter['old_field_3']->table); @@ -84,7 +103,8 @@ class ViewsUpgradeTestCase extends ViewsSqlTest { $view->build(); $this->assertEqual('views_test', $view->base_table, 'Make sure that view->base_table gets automatically converted.'); -// $this->assertEqual('id', $view->field['id']->field, 'If we move a whole table fields of this table should work, too.'); + // $this->assertEqual('id', $view->field['id']->field, + // 'If we move a whole table fields of this table should work, too.'); $this->assertEqual('id', $view->field['id']->real_field, 'To run the query right the real_field has to be set right.'); $this->assertEqual('views_test', $view->field['id']->table); } @@ -106,8 +126,11 @@ class ViewsUpgradeTestCase extends ViewsSqlTest { $this->assertText('Recent comments'); } + /** + * + */ public function viewsMovedToField() { - $view = new view; + $view = new view(); $view->name = 'test_views_move_to_field'; $view->description = ''; $view->tag = ''; @@ -127,8 +150,11 @@ class ViewsUpgradeTestCase extends ViewsSqlTest { return $view; } + /** + * + */ public function viewsMovedToHandler() { - $view = new view; + $view = new view(); $view->name = 'test_views_move_to_handler'; $view->description = ''; $view->tag = ''; @@ -152,8 +178,11 @@ class ViewsUpgradeTestCase extends ViewsSqlTest { return $view; } + /** + * + */ public function viewsMovedToTable() { - $view = new view; + $view = new view(); $view->name = 'test_views_move_to_table'; $view->description = ''; $view->tag = ''; @@ -173,6 +202,9 @@ class ViewsUpgradeTestCase extends ViewsSqlTest { return $view; } + /** + * + */ protected function viewUpgradeImport() { $import = ' $view = new view; @@ -272,6 +304,7 @@ class ViewsUpgradeTestCase extends ViewsSqlTest { $handler->display->display_options["block_description"] = "Recent comments view" ;'; - return $import; + return $import; } + } diff --git a/sites/all/modules/contrib/views/views/tests/views_view.test b/sites/all/modules/contrib/views/views/tests/views_view.test index d268a0c..489864a 100644 --- a/sites/all/modules/contrib/views/views/tests/views_view.test +++ b/sites/all/modules/contrib/views/views/tests/views_view.test @@ -2,23 +2,27 @@ /** * @file - * Definition of ViewsViewTest. + * Views class tests. */ /** - * Views class tests. + * */ class ViewsViewTest extends ViewsSqlTest { + + /** + * Provide the test's meta information. + */ public static function getInfo() { return array( 'name' => 'Test the view class', - 'description' => 'Tests some functionality of the view class', + 'description' => 'Tests some functionality of the view class', 'group' => 'Views', ); } /** - * Tests the deconstructor to be sure that every kind of heavy objects are removed. + * Ensure that every kind of heavy objects are removed by the destructor. */ function testDestroy() { $view = $this->view_test_destroy(); @@ -36,6 +40,12 @@ class ViewsViewTest extends ViewsSqlTest { $this->assertViewDestroy($view); } + /** + * Assert that a given view is destroyed properly. + * + * @param object $view + * The view to destroy. + */ function assertViewDestroy($view) { $this->assertFalse(isset($view->display['default']->handler), 'Make sure all displays are destroyed.'); $this->assertFalse(isset($view->display['attachment_1']->handler), 'Make sure all displays are destroyed.'); @@ -58,8 +68,11 @@ class ViewsViewTest extends ViewsSqlTest { $this->assertEqual($view->attachment_after, ''); } + /** + * Test deleting a view. + */ function testDelete() { - // Delete a database view + // Delete a database view. $view = $this->view_test_delete(); $view->save(); $view = views_get_view($view->name); @@ -72,10 +85,13 @@ class ViewsViewTest extends ViewsSqlTest { $this->assertNull($view, "Make sure that the old view gets cleared by the reset parameter."); } + /** + * Test validation. + */ function testValidate() { // Test a view with multiple displays. // Validating a view shouldn't change the active display. - // @todo: Create an extra validation view. + // @todo Create an extra validation view. $view = $this->view_test_destroy(); $view->set_display('page_1'); @@ -83,17 +99,20 @@ class ViewsViewTest extends ViewsSqlTest { $this->assertEqual('page_1', $view->current_display, "The display should be constant while validating"); - // @todo: Write real tests for the validation. + // @todo Write real tests for the validation. // In general the following things could be tested: - // - Deleted displays shouldn't be validated + // - Deleted displays shouldn't be validated. // - Multiple displays are validating and the errors are merged together. } /** - * This view provides some filters, fields, arguments, relationships, sorts, areas and attachments. + * Generate an example view. + * + * Includes: + * filters, fields, arguments, relationships, sorts, areas and attachments. */ function view_test_destroy() { - $view = new view; + $view = new view(); $view->name = 'test_destroy'; $view->description = ''; $view->tag = ''; @@ -227,6 +246,8 @@ class ViewsViewTest extends ViewsSqlTest { 'default' => 'default', 'page_1' => 'page_1', ); + + // @codingStandardsIgnoreLine $translatables['test_destroy'] = array( t('Master'), t('more'), @@ -252,8 +273,12 @@ class ViewsViewTest extends ViewsSqlTest { return $view; } + + /** + * Creates a test view. + */ function view_test_delete() { - $view = new view; + $view = new view(); $view->name = 'test_view_delete'; $view->description = ''; $view->tag = ''; @@ -272,6 +297,8 @@ class ViewsViewTest extends ViewsSqlTest { $handler->display->display_options['pager']['type'] = 'full'; $handler->display->display_options['style_plugin'] = 'default'; $handler->display->display_options['row_plugin'] = 'fields'; + + // @codingStandardsIgnoreLine $translatables['test_view_delete'] = array( t('Defaults'), t('more'), @@ -287,4 +314,5 @@ class ViewsViewTest extends ViewsSqlTest { return $view; } + } diff --git a/sites/all/modules/contrib/views/views/theme/theme.inc b/sites/all/modules/contrib/views/views/theme/theme.inc index e7f7a15..7382f01 100644 --- a/sites/all/modules/contrib/views/views/theme/theme.inc +++ b/sites/all/modules/contrib/views/views/theme/theme.inc @@ -8,11 +8,11 @@ /** * Provide a full array of possible themes to try for a given hook. * - * @param $hook + * @param string $hook * The hook to use. This is the base theme/template name. - * @param $view + * @param object $view * The view being rendered. - * @param $display + * @param object $display * The display being rendered, if applicable. */ function _views_theme_functions($hook, $view, $display = NULL) { @@ -52,7 +52,7 @@ function template_preprocess_views_view(&$vars) { $vars['name'] = $view->name; $vars['display_id'] = $view->current_display; - // Basic classes + // Basic classes. $vars['css_class'] = ''; $vars['classes_array'] = array(); @@ -81,12 +81,12 @@ function template_preprocess_views_view(&$vars) { $vars['pager'] = ''; - // @todo: Figure out whether this belongs into views_ui_preprocess_views_view. + // @todo Figure out whether this belongs into views_ui_preprocess_views_view. // Render title for the admin preview. $vars['title'] = !empty($view->views_ui_context) ? filter_xss_admin($view->get_title()) : ''; if ($view->display_handler->render_pager()) { - $exposed_input = isset($view->exposed_raw_input) ? $view->exposed_raw_input : NULL; + $exposed_input = $view->get_exposed_input(); $vars['pager'] = $view->query->render_pager($exposed_input); } @@ -104,15 +104,15 @@ function template_preprocess_views_view(&$vars) { // Attachments are always updated with the outer view, never by themselves, // so they do not have dom ids. if (empty($view->is_attachment)) { - // Our JavaScript needs to have some means to find the HTML belonging to this - // view. + // Our JavaScript needs to have some means to find the HTML belonging to + // this view. // // It is true that the DIV wrapper has classes denoting the name of the view // and its display ID, but this is not enough to unequivocally match a view // with its HTML, because one view may appear several times on the page. So - // we set up a hash with the current time, $dom_id, to issue a "unique" identifier for - // each view. This identifier is written to both Drupal.settings and the DIV - // wrapper. + // we set up a hash with the current time, $dom_id, to issue a "unique" + // identifier for each view. This identifier is written to both + // Drupal.settings and the DIV wrapper. $vars['dom_id'] = $view->dom_id; $vars['classes_array'][] = 'view-dom-id-' . $vars['dom_id']; } @@ -129,7 +129,9 @@ function template_preprocess_views_view(&$vars) { 'view_args' => check_plain(implode('/', $view->args)), 'view_path' => check_plain($_GET['q']), // Pass through URL to ensure we get e.g. language prefixes. -// 'view_base_path' => isset($view->display['page']) ? substr(url($view->display['page']->display_options['path']), strlen($base_path)) : '', + // 'view_base_path' => isset($view->display['page']) ? + // substr(url($view->display['page']->display_options['path']), + // strlen($base_path)) : '', 'view_base_path' => $view->get_path(), 'view_dom_id' => $vars['dom_id'], // To fit multiple views on a page, the programmer may have @@ -138,6 +140,10 @@ function template_preprocess_views_view(&$vars) { ), ), ), + // Support for AJAX path validation in core 7.39. + 'urlIsAjaxTrusted' => array( + url('views/ajax') => TRUE, + ), ); drupal_add_js($settings, 'setting'); @@ -175,16 +181,17 @@ function template_process_views_view(&$vars) { } /** - * Preprocess theme function to print a single record from a row, with fields + * Preprocess theme function to print a single record from a row, with fields. */ function template_preprocess_views_view_fields(&$vars) { $view = $vars['view']; // Loop through the fields for this view. $previous_inline = FALSE; - $vars['fields'] = array(); // ensure it's at least an empty array. + $vars['fields'] = array(); + // Ensure it's at least an empty array. foreach ($view->field as $id => $field) { - // render this even if set to exclude so it can be used elsewhere. + // Render this even if set to exclude so it can be used elsewhere. $field_output = $view->style_plugin->get_field($view->row_index, $id); $empty = $field->is_value_empty($field_output, $field->options['empty_zero']); if (empty($field->options['exclude']) && (!$empty || (empty($field->options['hide_empty']) && empty($vars['options']['hide_empty'])))) { @@ -203,7 +210,7 @@ function template_preprocess_views_view_fields(&$vars) { if ($class) { $class .= ' '; } - $class .= $classes; + $class .= $classes; } $pre = '<' . $object->element_type; @@ -214,7 +221,8 @@ function template_preprocess_views_view_fields(&$vars) { } // Protect ourself somewhat for backward compatibility. This will prevent - // old templates from producing invalid HTML when no element type is selected. + // old templates from producing invalid HTML when no element type is + // selected. if (empty($object->element_type)) { $object->element_type = 'span'; } @@ -224,7 +232,8 @@ function template_preprocess_views_view_fields(&$vars) { $object->raw = $vars['row']->{$view->field[$id]->field_alias}; } else { - $object->raw = NULL; // make sure it exists to reduce NOTICE + // Make sure it exists to reduce NOTICE. + $object->raw = NULL; } if (!empty($vars['options']['separator']) && $previous_inline && $object->inline && $object->content) { @@ -264,8 +273,8 @@ function template_preprocess_views_view_fields(&$vars) { $object->wrapper_suffix = 'inline_html . '>'; } - // Set up the label for the value and the HTML to make it easier - // on the template. + // Set up the label for the value and the HTML to make it easier on the + // template. $object->label = check_plain($view->field[$id]->label()); $object->label_html = ''; if ($object->label) { @@ -303,7 +312,6 @@ function template_preprocess_views_view_fields(&$vars) { $vars['fields'][$id] = $object; } } - } /** @@ -316,7 +324,7 @@ function theme_views_view_grouping($vars) { $output = '
    '; $output .= '
    ' . $title . '
    '; - $output .= '
    ' . $content . '
    ' ; + $output .= '
    ' . $content . '
    '; $output .= '
    '; return $output; @@ -334,7 +342,7 @@ function template_preprocess_views_view_grouping(&$vars) { * * Interesting bits of info: * $field->field_alias says what the raw value in $row will be. Reach it like - * this: @code { $row->{$field->field_alias} @endcode + * this: @code { $row->{$field->field_alias} @endcode. */ function theme_views_view_field($vars) { $view = $vars['view']; @@ -355,7 +363,7 @@ function template_preprocess_views_view_field(&$vars) { } /** - * Preprocess theme function to print a single record from a row, with fields + * Preprocess theme function to print a single record from a row, with fields. */ function template_preprocess_views_view_summary(&$vars) { $view = $vars['view']; @@ -369,12 +377,15 @@ function template_preprocess_views_view_summary(&$vars) { } $active_urls = drupal_map_assoc(array( - url($_GET['q'], array('alias' => TRUE)), // force system path - url($_GET['q']), // could be an alias + // Force system path. + url($_GET['q'], array('alias' => TRUE)), + // Could be an alias. + url($_GET['q']), )); - // Collect all arguments foreach row, to be able to alter them for example by the validator. - // This is not done per single argument value, because this could cause performance problems. + // Collect all arguments foreach row, to be able to alter them for example by + // the validator. This is not done per single argument value, because this + // could cause performance problems. $row_args = array(); foreach ($vars['rows'] as $id => $row) { @@ -402,8 +413,7 @@ function template_preprocess_views_view_summary(&$vars) { } /** - * Template preprocess theme function to print summary basically - * unformatted. + * Template preprocess theme function to print summary basically unformatted. */ function template_preprocess_views_view_summary_unformatted(&$vars) { $view = $vars['view']; @@ -418,12 +428,15 @@ function template_preprocess_views_view_summary_unformatted(&$vars) { $count = 0; $active_urls = drupal_map_assoc(array( - url($_GET['q'], array('alias' => TRUE)), // force system path - url($_GET['q']), // could be an alias + // Force system path. + url($_GET['q'], array('alias' => TRUE)), + // Could be an alias. + url($_GET['q']), )); - // Collect all arguments foreach row, to be able to alter them for example by the validator. - // This is not done per single argument value, because this could cause performance problems. + // Collect all arguments foreach row, to be able to alter them for example by + // the validator. This is not done per single argument value, because this + // could cause performance problems. $row_args = array(); foreach ($vars['rows'] as $id => $row) { $row_args[$id] = $argument->summary_argument($row); @@ -431,7 +444,7 @@ function template_preprocess_views_view_summary_unformatted(&$vars) { $argument->process_summary_arguments($row_args); foreach ($vars['rows'] as $id => $row) { - // only false on first time: + // Only false on first time. if ($count++) { $vars['rows'][$id]->separator = filter_xss_admin($vars['options']['separator']); } @@ -457,11 +470,11 @@ function template_preprocess_views_view_summary_unformatted(&$vars) { function template_preprocess_views_view_table(&$vars) { $view = $vars['view']; - // We need the raw data for this grouping, which is passed in as $vars['rows']. - // However, the template also needs to use for the rendered fields. We - // therefore swap the raw data out to a new variable and reset $vars['rows'] - // so that it can get rebuilt. - // Store rows so that they may be used by further preprocess functions. + // We need the raw data for this grouping, which is passed in as + // $vars['rows']. However, the template also needs to use for the rendered + // fields. We therefore swap the raw data out to a new variable and reset + // $vars['rows'] so that it can get rebuilt. Store rows so that they may be + // used by further preprocess functions. $result = $vars['result'] = $vars['rows']; $vars['rows'] = array(); $vars['field_classes'] = array(); @@ -489,14 +502,14 @@ function template_preprocess_views_view_table(&$vars) { $renders = $handler->render_fields($result); foreach ($columns as $field => $column) { - // Create a second variable so we can easily find what fields we have and what the - // CSS classes should be. + // Create a second variable so we can easily find what fields we have and + // what the CSS classes should be. $vars['fields'][$field] = drupal_clean_css_identifier($field); if ($active == $field) { $vars['fields'][$field] .= ' active'; } - // render the header labels + // Render the header labels. if ($field == $column && empty($fields[$field]->options['exclude'])) { $label = check_plain(!empty($fields[$field]) ? $fields[$field]->label() : ''); if (empty($options['info'][$field]['sortable']) || !$fields[$field]->click_sortable()) { @@ -536,7 +549,7 @@ function template_preprocess_views_view_table(&$vars) { } $vars['header_classes'][$field] .= $class; } - // Add a CSS align class to each field if one was set + // Add a CSS align class to each field if one was set. if (!empty($options['info'][$field]['align'])) { $vars['header_classes'][$field] .= ' ' . drupal_clean_css_identifier($options['info'][$field]['align']); } @@ -548,17 +561,16 @@ function template_preprocess_views_view_table(&$vars) { $vars['header'][$field] = '<' . $element_label_type . '>' . $vars['header'][$field] . ''; } } - } - // Add a CSS align class to each field if one was set + // Add a CSS align class to each field if one was set. if (!empty($options['info'][$field]['align'])) { $vars['fields'][$field] .= ' ' . drupal_clean_css_identifier($options['info'][$field]['align']); } // Render each field into its appropriate column. foreach ($result as $num => $row) { - // Add field classes + // Add field classes. $vars['field_classes'][$field][$num] = ''; if ($fields[$field]->options['element_default_classes']) { $vars['field_classes'][$field][$num] = "views-field views-field-" . $vars['fields'][$field]; @@ -598,7 +610,8 @@ function template_preprocess_views_view_table(&$vars) { } } - // Remove columns if the option is hide empty column is checked and the field is not empty. + // Remove columns if the option is hide empty column is checked and the + // field is not empty. if (!empty($options['info'][$field]['empty_column'])) { $empty = TRUE; foreach ($vars['rows'] as $num => $columns) { @@ -642,12 +655,11 @@ function template_preprocess_views_view_table(&$vars) { $vars['field_classes'][0][0] = 'views-empty'; } - if (!empty($options['sticky'])) { drupal_add_js('misc/tableheader.js'); $vars['classes_array'][] = "sticky-enabled"; } - $vars['classes_array'][] = 'cols-'. count($vars['header']); + $vars['classes_array'][] = 'cols-' . count($vars['header']); // Add the summary to the list if set. if (!empty($handler->options['summary'])) { @@ -735,25 +747,25 @@ function template_preprocess_views_view_grid(&$vars) { } } - // Apply the row classes + // Apply the row classes. foreach ($rows as $row_number => $row) { $row_classes = array(); if ($default_row_class) { - $row_classes[] = 'row-' . ($row_number + 1); + $row_classes[] = 'row-' . ($row_number + 1); } if ($row_class_special) { if ($row_number == 0) { - $row_classes[] = 'row-first'; + $row_classes[] = 'row-first'; } if (count($rows) == ($row_number + 1)) { - $row_classes[] = 'row-last'; + $row_classes[] = 'row-last'; } } $vars['row_classes'][$row_number] = implode(' ', $row_classes); foreach ($rows[$row_number] as $column_number => $item) { $column_classes = array(); if ($default_row_class) { - $column_classes[] = 'col-'. ($column_number + 1); + $column_classes[] = 'col-' . ($column_number + 1); } if ($row_class_special) { if ($column_number == 0) { @@ -787,7 +799,7 @@ function template_preprocess_views_view_grid(&$vars) { } /** - * Display the simple view of rows one after another + * Display the simple view of rows one after another. */ function template_preprocess_views_view_unformatted(&$vars) { $view = $vars['view']; @@ -828,7 +840,7 @@ function template_preprocess_views_view_unformatted(&$vars) { } /** - * Display the view as an HTML list element + * Display the view as an HTML list element. */ function template_preprocess_views_view_list(&$vars) { $handler = $vars['view']->style_plugin; @@ -857,7 +869,7 @@ function template_preprocess_views_view_list(&$vars) { } /** - * Preprocess an RSS feed + * Preprocess an RSS feed. */ function template_preprocess_views_view_rss(&$vars) { global $base_url; @@ -885,8 +897,8 @@ function template_preprocess_views_view_rss(&$vars) { } $vars['title'] = check_plain($title); - // Figure out which display which has a path we're using for this feed. If there isn't - // one, use the global $base_url + // Figure out which display which has a path we're using for this feed. If + // there isn't one, use the global $base_url. $link_display_id = $view->display_handler->get_link_display(); if ($link_display_id && !empty($view->display[$link_display_id])) { $path = $view->display[$link_display_id]->handler->get_path(); @@ -899,7 +911,8 @@ function template_preprocess_views_view_rss(&$vars) { $url_options['query'] = $view->exposed_raw_input; } - // Compare the link to the default home page; if it's the default home page, just use $base_url. + // Compare the link to the default home page; if it's the default home + // page, just use $base_url. if ($path == variable_get('site_frontpage', 'node')) { $path = ''; } @@ -953,8 +966,8 @@ function template_preprocess_views_exposed_form(&$vars) { $checkboxes .= drupal_render($form[$info['value']]); continue; } - $widget = new stdClass; - // set up defaults so that there's always something there. + $widget = new stdClass(); + // Set up defaults so that there's always something there. $widget->label = $widget->operator = $widget->widget = $widget->description = NULL; $widget->id = isset($form[$info['value']]['#id']) ? $form[$info['value']]['#id'] : ''; @@ -977,8 +990,8 @@ function template_preprocess_views_exposed_form(&$vars) { // Wrap up all the checkboxes we set aside into a widget. if ($checkboxes) { - $widget = new stdClass; - // set up defaults so that there's always something there. + $widget = new stdClass(); + // Set up defaults so that there's always something there. $widget->label = $widget->operator = $widget->widget = NULL; $widget->id = 'checkboxes'; $widget->widget = $checkboxes; @@ -1034,6 +1047,9 @@ function theme_views_form_views_form($variables) { return drupal_render_children($form); } +/** + * theme function for a mini pager. + */ function theme_views_mini_pager($vars) { global $pager_page_array, $pager_total; @@ -1041,12 +1057,11 @@ function theme_views_mini_pager($vars) { $element = $vars['element']; $parameters = $vars['parameters']; - // current is the page we are currently paged to + // Current is the page we are currently paged to. $pager_current = $pager_page_array[$element] + 1; - // max is the maximum page number + // Max is the maximum page number. $pager_max = $pager_total[$element]; // End of marker calculations. - if ($pager_total[$element] > 1) { $li_previous = theme('pager_previous', @@ -1088,6 +1103,7 @@ function theme_views_mini_pager($vars) { 'class' => array('pager-next'), 'data' => $li_next, ); + return theme('item_list', array( 'items' => $items, diff --git a/sites/all/modules/contrib/views/views/theme/views-more.tpl.php b/sites/all/modules/contrib/views/views/theme/views-more.tpl.php index 0b7080b..1adfa3e 100644 --- a/sites/all/modules/contrib/views/views/theme/views-more.tpl.php +++ b/sites/all/modules/contrib/views/views/theme/views-more.tpl.php @@ -7,13 +7,15 @@ * - $view: The view object. * - $more_url: the url for the more link. * - $link_text: the text for the more link. + * - $new_window: The flag that indicates if link should be opened in a new + * window. * * @ingroup views_templates */ ?> diff --git a/sites/all/modules/contrib/views/views/theme/views-ui-display-tab-bucket.tpl.php b/sites/all/modules/contrib/views/views/theme/views-ui-display-tab-bucket.tpl.php index 6d51a1d..079f579 100644 --- a/sites/all/modules/contrib/views/views/theme/views-ui-display-tab-bucket.tpl.php +++ b/sites/all/modules/contrib/views/views/theme/views-ui-display-tab-bucket.tpl.php @@ -7,7 +7,7 @@ ?>
    > - + diff --git a/sites/all/modules/contrib/views/views/theme/views-ui-edit-item.tpl.php b/sites/all/modules/contrib/views/views/theme/views-ui-edit-item.tpl.php deleted file mode 100644 index bf90ec1..0000000 --- a/sites/all/modules/contrib/views/views/theme/views-ui-edit-item.tpl.php +++ /dev/null @@ -1,45 +0,0 @@ - - - -
    - - -
    - -
    - -
    - -
    - - $field): ?> - - - -
    - - -
    - - -
    diff --git a/sites/all/modules/contrib/views/views/theme/views-ui-edit-view.tpl.php b/sites/all/modules/contrib/views/views/theme/views-ui-edit-view.tpl.php index 5c3732c..f433332 100644 --- a/sites/all/modules/contrib/views/views/theme/views-ui-edit-view.tpl.php +++ b/sites/all/modules/contrib/views/views/theme/views-ui-edit-view.tpl.php @@ -8,10 +8,11 @@
    - break this lock.', array('!user' => $locked, '!age' => $lock_age, '!break' => $break)); ?> + break this lock.', + array('!user' => $locked, '!age' => $lock_age, '!break' => $break)); ?>
    -
    "> +
    vid)): ?>
    @@ -28,7 +29,8 @@
    - +
    $columns): ?> - > + class=""> $item): ?> - > + class=""> diff --git a/sites/all/modules/contrib/views/views/theme/views-view-list.tpl.php b/sites/all/modules/contrib/views/views/theme/views-view-list.tpl.php index 601279a..27e2736 100644 --- a/sites/all/modules/contrib/views/views/theme/views-view-list.tpl.php +++ b/sites/all/modules/contrib/views/views/theme/views-view-list.tpl.php @@ -6,6 +6,7 @@ * * - $title : The title of this group of rows. May be empty. * - $options['type'] will either be ul or ol. + * * @ingroup views_templates */ ?> diff --git a/sites/all/modules/contrib/views/views/theme/views-view-row-comment.tpl.php b/sites/all/modules/contrib/views/views/theme/views-view-row-comment.tpl.php index 7fe2e81..dc1aa39 100644 --- a/sites/all/modules/contrib/views/views/theme/views-view-row-comment.tpl.php +++ b/sites/all/modules/contrib/views/views/theme/views-view-row-comment.tpl.php @@ -10,7 +10,7 @@ * a views template, which is why it's not used here, but is a template * 'suggestion' given to the comment template, and is used exactly * the same as any other variant of the comment template file, such as - * node-nodeTYPE.tpl.php + * node-nodeTYPE.tpl.php. * * @ingroup views_templates */ diff --git a/sites/all/modules/contrib/views/views/theme/views-view-summary-unformatted.tpl.php b/sites/all/modules/contrib/views/views/theme/views-view-summary-unformatted.tpl.php index 306d76f..e200893 100644 --- a/sites/all/modules/contrib/views/views/theme/views-view-summary-unformatted.tpl.php +++ b/sites/all/modules/contrib/views/views/theme/views-view-summary-unformatted.tpl.php @@ -11,7 +11,7 @@ ?> $row): ?> '; ?> - separator)) { print $row->separator; } ?> + separator)):?>separator; ?> >link; ?> (count; ?>) diff --git a/sites/all/modules/contrib/views/views/theme/views-view-summary.tpl.php b/sites/all/modules/contrib/views/views/theme/views-view-summary.tpl.php index 22969eb..2b61f2d 100644 --- a/sites/all/modules/contrib/views/views/theme/views-view-summary.tpl.php +++ b/sites/all/modules/contrib/views/views/theme/views-view-summary.tpl.php @@ -10,7 +10,7 @@
      $row): ?> -
    • >link; ?> +
    • >link; ?> (count?>) diff --git a/sites/all/modules/contrib/views/views/theme/views-view-table.tpl.php b/sites/all/modules/contrib/views/views/theme/views-view-table.tpl.php index 4fec9fa..370ecd7 100644 --- a/sites/all/modules/contrib/views/views/theme/views-view-table.tpl.php +++ b/sites/all/modules/contrib/views/views/theme/views-view-table.tpl.php @@ -16,18 +16,19 @@ * $rows are keyed by row number, fields within rows are keyed by field ID. * - $field_classes: An array of classes to apply to each field, indexed by * field id, then row number. This matches the index in $rows. + * * @ingroup views_templates */ ?> -> - +
      class=""> + $label): ?> - @@ -36,9 +37,9 @@ $row): ?> - > + class=""> $content): ?> - diff --git a/sites/all/modules/contrib/views/views/theme/views-view-unformatted.tpl.php b/sites/all/modules/contrib/views/views/theme/views-view-unformatted.tpl.php index f1cccb8..fc8cfc4 100644 --- a/sites/all/modules/contrib/views/views/theme/views-view-unformatted.tpl.php +++ b/sites/all/modules/contrib/views/views/theme/views-view-unformatted.tpl.php @@ -11,7 +11,7 @@

      $row): ?> - > + class=""> diff --git a/sites/all/modules/contrib/views/views/theme/views-view.tpl.php b/sites/all/modules/contrib/views/views/theme/views-view.tpl.php index 579cf12..96edaab 100644 --- a/sites/all/modules/contrib/views/views/theme/views-view.tpl.php +++ b/sites/all/modules/contrib/views/views/theme/views-view.tpl.php @@ -22,7 +22,7 @@ * - $pager: The pager next/prev links to display, if any * - $exposed: Exposed widget form/info to display * - $feed_icon: Feed icon to display, if any - * - $more: A link to view more, if any + * - $more: A link to view more, if any. * * @ingroup views_templates */ diff --git a/sites/all/modules/contrib/views/views/views.api.php b/sites/all/modules/contrib/views/views/views.api.php index 70c5dc8..ea53a37 100644 --- a/sites/all/modules/contrib/views/views/views.api.php +++ b/sites/all/modules/contrib/views/views/views.api.php @@ -87,7 +87,7 @@ * $this->value_title = t('Node type'); * $types = node_get_types(); * foreach ($types as $type => $info) { - * $options[$type] = $info->name; + * $options[$type] = $info->name; * } * $this->value_options = $options; * } @@ -143,7 +143,7 @@ * responsible for building the query. Instead, they are objects that are used * to display the view or make other modifications. * - * There are 10 types of plugins in Views: + * There are several types of plugins in Views: * - Display: Display plugins are responsible for controlling *where* a view * lives; that is, how they are being exposed to other parts of Drupal. Page * and block are the most common displays, as well as the ubiquitous 'master' @@ -244,9 +244,11 @@ * 'title' => t('Node'), * 'help' => t('Display the node with standard node view.'), * 'handler' => 'views_plugin_row_node_view', - * 'path' => drupal_get_path('module', 'views') . '/modules/node', // not necessary for most modules + * // Not necessary for most modules. + * 'path' => drupal_get_path('module', 'views') . '/modules/node', * 'theme' => 'views_view_row_node', - * 'base' => array('node'), // only works with 'node' as base. + * // Only works with 'node' as base. + * 'base' => array('node'), * 'uses options' => TRUE, * 'type' => 'normal', * ), @@ -292,12 +294,12 @@ /** * Describes data tables (or the equivalent) to Views. * - * This hook should be placed in MODULENAME.views.inc and it will be - * auto-loaded. MODULENAME.views.inc must be in the directory specified by the - * 'path' key returned by MODULENAME_views_api(), or the same directory as the - * .module file, if 'path' is unspecified. + * This hook should be placed in MODULENAME.views.inc and it will be auto + * loaded. MODULENAME.views.inc must be in the directory specified by the 'path' + * key returned by MODULENAME_views_api(), or the same directory as the .module + * file, if 'path' is unspecified. * - * @return + * @return array * An associative array describing the data structure. Primary key is the * name used internally by Views for the table(s) – usually the actual table * name. The values for the key entries are described in detail below. @@ -307,17 +309,15 @@ function hook_views_data() { // table: // // CREATE TABLE example_table ( - // nid INT(11) NOT NULL COMMENT 'Primary key; refers to {node}.nid.', + // nid INT(11) NOT NULL COMMENT 'Primary key; refers to {node}.nid.', // plain_text_field VARCHAR(32) COMMENT 'Just a plain text field.', - // numeric_field INT(11) COMMENT 'Just a numeric field.', - // boolean_field INT(1) COMMENT 'Just an on/off field.', - // timestamp_field INT(8) COMMENT 'Just a timestamp field.', + // numeric_field INT(11) COMMENT 'Just a numeric field.', + // boolean_field INT(1) COMMENT 'Just an on/off field.', + // timestamp_field INT(8) COMMENT 'Just a timestamp field.', // PRIMARY KEY(nid) // ); - // First, the entry $data['example_table']['table'] describes properties of // the actual table – not its content. - // The 'group' index will be used as a prefix in the UI for any of this // table's fields, sort criteria, etc. so it's easy to tell where they came // from. @@ -328,7 +328,8 @@ function hook_views_data() { // is not very useful for this table, as it isn't really a distinct object of // its own, but it makes a good example. $data['example_table']['table']['base'] = array( - 'field' => 'nid', // This is the identifier field for the view. + // This is the identifier field for the view. + 'field' => 'nid', 'title' => t('Example table'), 'help' => t('Example table contains example content and can be related to nodes.'), 'weight' => -10, @@ -339,10 +340,10 @@ function hook_views_data() { // table, the fields are automatically available. $data['example_table']['table']['join'] = array( // Index this array by the table name to which this table refers. - // 'left_field' is the primary key in the referenced table. - // 'field' is the foreign key in this table. 'node' => array( + // The primary key in the referenced table. 'left_field' => 'nid', + // The foreign key in this table. 'field' => 'nid', ), ); @@ -362,7 +363,6 @@ function hook_views_data() { // footer or as no result behaviour. // // The handler descriptions are described with examples below. - // Node ID table field. $data['example_table']['nid'] = array( 'title' => t('Example content'), @@ -372,8 +372,10 @@ function hook_views_data() { // other direction, use hook_views_data_alter(), or use the 'implicit' join // method described above. 'relationship' => array( - 'base' => 'node', // The name of the table to join with. - 'base field' => 'nid', // The name of the field on the joined table. + // The name of the table to join with. + 'base' => 'node', + // The name of the field on the joined table. + 'base field' => 'nid', // 'field' => 'nid' -- see hook_views_data_alter(); not needed here. 'handler' => 'views_handler_relationship', 'label' => t('Default label for the relationship'), @@ -388,7 +390,8 @@ function hook_views_data() { 'help' => t('Just a plain text field.'), 'field' => array( 'handler' => 'views_handler_field', - 'click sortable' => TRUE, // This is use by the table display plugin. + // This is use by the table display plugin. + 'click sortable' => TRUE, ), 'sort' => array( 'handler' => 'views_handler_sort', @@ -408,7 +411,7 @@ function hook_views_data() { 'field' => array( 'handler' => 'views_handler_field_numeric', 'click sortable' => TRUE, - ), + ), 'filter' => array( 'handler' => 'views_handler_filter_numeric', ), @@ -427,11 +430,11 @@ function hook_views_data() { ), 'filter' => array( 'handler' => 'views_handler_filter_boolean_operator', - // Note that you can override the field-wide label: + // Note that you can override the field-wide label. 'label' => t('Published'), // This setting is used by the boolean filter handler, as possible option. 'type' => 'yes-no', - // use boolean_field = 1 instead of boolean_field <> 0 in WHERE statment. + // use boolean_field = 1 instead of boolean_field <> 0 in WHERE statement. 'use equal' => TRUE, ), 'sort' => array( @@ -468,7 +471,7 @@ function hook_views_data() { * 'path' key returned by MODULENAME_views_api(), or the same directory as the * .module file, if 'path' is unspecified. * - * @param $data + * @param array $data * An array of all Views data, passed by reference. See hook_views_data() for * structure. * @@ -500,9 +503,12 @@ function hook_views_data_alter(&$data) { 'title' => t('Example relationship'), 'help' => t('Example help'), 'relationship' => array( - 'base' => 'example_table', // Table we're joining to. - 'base field' => 'eid', // Field on the joined table. - 'field' => 'fid', // Real field name on the 'foo' table. + // Table we're joining to. + 'base' => 'example_table', + // Field on the joined table. + 'base field' => 'eid', + // Real field name on the 'foo' table. + 'field' => 'fid', 'handler' => 'views_handler_relationship', 'label' => t('Default label for relationship'), 'title' => t('Title seen when adding relationship'), @@ -516,26 +522,26 @@ function hook_views_data_alter(&$data) { /** * Override the default data for a Field API field. * - * Field module's implementation of hook_views_data() invokes this for each + * Field module's Implements hook_views_data() invokes this for each * field in the module that defines the field type (as declared in the field * array). It is not invoked in other modules. * * If no hook implementation exists, hook_views_data() falls back to * field_views_field_default_views_data(). * + * @param array $field + * A field definition array, as returned by field_info_fields(). + * + * @return array + * An array of views data, in the same format as the return value of + * hook_views_data(). + * * @see field_views_data() * @see hook_field_views_data_alter() * @see hook_field_views_data_views_data_alter() - * - * @param $field - * A field definition array, as returned by field_info_fields(). - * - * @return - * An array of views data, in the same format as the return value of - * hook_views_data(). */ function hook_field_views_data($field) { - + return array(); } /** @@ -545,13 +551,13 @@ function hook_field_views_data($field) { * the field, and therefore may be used to alter the default data that * field_views_field_default_views_data() supplies for the field. * - * @param $result - * An array of views table data provided for a single field. This has the same - * format as the return value of hook_views_data(). - * @param $field - * A field definition array, as returned by field_info_fields(). - * @param $module - * The module that defines the field type. + * @param array $result + * An array of views table data provided for a single field. This has the same + * format as the return value of hook_views_data(). + * @param array $field + * A field definition array, as returned by field_info_fields(). + * @param string $module + * The module that defines the field type. * * @see field_views_data() * @see hook_field_views_data() @@ -564,7 +570,7 @@ function hook_field_views_data_alter(&$result, $field, $module) { /** * Alter the views data on a per field basis. * - * Field module's implementation of hook_views_data_alter() invokes this for + * Field module's Implements hook_views_data_alter() invokes this for * each field in the module that defines the field type (as declared in the * field array). It is not invoked in other modules. * @@ -597,12 +603,12 @@ function hook_field_views_data_views_data_alter(&$data, $field) { * .module file, if 'path' is unspecified. All plugin files need to be * referenced in MODULENAME.info with the files[] directive. * - * @return + * @return array * An array on the form $plugins['PLUGIN TYPE']['PLUGIN NAME']. The plugin * must be one of row, display, display_extender, style, argument default, * argument validator, access, query, cache, pager, exposed_form or * localization. The plugin name should be prefixed with your module name. - * The value for each entry is an associateive array that may contain the + * The value for each entry is an associative array that may contain the * following entries: * - Used by all plugin types: * - title (required): The name of the plugin, as shown in Views. Wrap in @@ -619,7 +625,8 @@ function hook_field_views_data_views_data_alter(&$data, $field) { * selectable in the ui, though on the api side they still exists. * - uses options: Set to TRUE to denote that the plugin has an additional * options form. - * - help: A short help text, wrapped in t() used as description on the plugin settings form. + * - help: A short help text, wrapped in t() used as description on the + * plugin settings form. * - help topic: The name of an entry by advanced help for the plugin. * - theme: The name of a theme suggestion to use for the display. * - js: An array with paths to js files that should be included for the @@ -646,8 +653,8 @@ function hook_field_views_data_views_data_alter(&$data, $field) { * should be added. Can for example be 'page' or 'block'. If you don't * specify it there will be contextual links around the rendered view. If * this is not set or regions have been specified, views will display an - * option to 'hide contextual links'. Use an empty array if you do not want - * this. + * option to 'hide contextual links'. Use an empty array if you do not + * want this. * - uses hook menu: Set to TRUE to have the display included by * views_menu_alter(). views_menu_alter executes then execute_hook_menu * on the display object. @@ -664,8 +671,8 @@ function hook_field_views_data_views_data_alter(&$data, $field) { * - uses fields: Set to TRUE to have the style plugin accept field * handlers. * - uses grouping: Set to TRUE to allow the grouping settings for rows. - * - even empty: May have the value 'even empty' to tell Views that the style - * should be rendered even if there are no results. + * - even empty: May have the value 'even empty' to tell Views that the + * style should be rendered even if there are no results. * * - Used by row plugins: * - uses fields: Set to TRUE to have the row plugin accept field handlers. @@ -682,12 +689,14 @@ function hook_views_plugins() { ); return array( - 'module' => 'views', // This just tells our themes are elsewhere. + // This just tells our themes are elsewhere. + 'module' => 'views', 'argument validator' => array( 'taxonomy_term' => array( 'title' => t('Taxonomy term'), 'handler' => 'views_plugin_argument_validate_taxonomy_term', - 'path' => drupal_get_path('module', 'views') . '/modules/taxonomy', // not necessary for most modules + // Declaring path explicitly not necessary for most modules. + 'path' => drupal_get_path('module', 'views') . '/modules/taxonomy', ), ), 'argument default' => array( @@ -711,19 +720,75 @@ function hook_views_plugins_alter(&$plugins) { $plugins['row']['node']['base'][] = 'apachesolr'; } +/** + * Alter existing plugin option definitions. + * + * This can be used to edit default or add new option definitions to existing + * plugins. The reason for doing this is that only overriding the relevent form + * with hook_form_alter() is insufficent because submitted form values will be + * ignored if they haven't been declared as an available option. + * + * An alternative approach you could also take is to extend each plugin + * individually. However if your goal is to override many, or even all plugins, + * this results in a lot of additional code and files. This makes it a lot more + * troublesome to maintain the codebase, as well as interoperability with other + * modules. + * + * @param array $options + * The option definitions to be altered. + * @param $plugin + * A views object of the plugin where the default options are defined. + * + * @see views_object::option_definition() + * @see hook_views_handler_option_definition_alter() + * @see hook_form_alter() + */ +function hook_views_plugin_option_definition_alter(&$options, $plugin) { + // Add a new option definition. + $options['option_name'] = array('default' => ''); +} + +/** + * Alter existing handler option definitions. + * + * This can be used to edit default or add new option definitions to existing + * handers. The reason for doing this is that only overriding the relevent form + * with hook_form_alter() is insufficent because submitted form values will be + * ignored if they haven't been declared as an available option. + * + * An alternative approach you could also take is to extend each handler + * individually. However if your goal is to override many, or even all handlers, + * this results in a lot of additional code and files. This makes it a lot more + * troublesome to maintain the codebase, as well as interoperability with other + * modules. + * + * @param array $options + * The option definitions to be altered. + * @param $handler + * A views object of the handler where the default options are defined. + * + * @see views_handler::option_definition() + * @see hook_views_plugin_option_definition_alter() + * @see hook_form_alter() + */ +function hook_views_handler_option_definition_alter(&$options, $handler) { + // Add a new option definition. + $options['option_name'] = array('default' => ''); +} + /** * Register View API information. * * This is required for your module to have its include files loaded; for * example, when implementing hook_views_default_views(). * - * @return + * @return array * An array with the following possible keys: * - api: (required) The version of the Views API the module implements. * - path: (optional) If includes are stored somewhere other than within the * root module directory, specify its path here. * - template path: (optional) A path where the module has stored it's views - * template files. When you have specificed this key views automatically + * template files. When you have specified this key views automatically * uses the template files for the views. You can use the same naming * conventions like for normal views template files. */ @@ -736,8 +801,9 @@ function hook_views_api() { } /** - * This hook allows modules to provide their own views which can either be used - * as-is or as a "starter" for users to build from. + * Allows modules to provide their own views. + * + * These can either be used as-is or as a "starter" for users to build from. * * This hook should be placed in MODULENAME.views_default.inc and it will be * auto-loaded. MODULENAME.views_default.inc must be in the directory specified @@ -747,7 +813,7 @@ function hook_views_api() { * The $view->disabled boolean flag indicates whether the View should be * enabled (FALSE) or disabled (TRUE) by default. * - * @return + * @return array * An associative array containing the structures of views, as generated from * the Export tab, keyed by the view name. A best practice is to go through * and add t() to all title and label strings, with the exception of menu @@ -755,7 +821,7 @@ function hook_views_api() { */ function hook_views_default_views() { // Begin copy and paste of output from the Export tab of a view. - $view = new view; + $view = new view(); $view->name = 'frontpage'; $view->description = 'Emulates the default Drupal front page; you may set the default home page path to this view to make it your front page.'; $view->tag = 'default'; @@ -819,13 +885,11 @@ function hook_views_default_views() { $handler->display->display_options['sitename_title'] = '1'; // (Export ends here.) - // Add view to list of views to provide. $views[$view->name] = $view; - // ...Repeat all of the above for each view the module should provide. - - // At the end, return array of default views. + // Repeat all of the above for each view the module should provide. At the + // end, return array of default views. return $views; } @@ -855,11 +919,12 @@ function hook_views_default_views_alter(&$views) { /** * Performs replacements in the query before being performed. * - * @param $view + * @param object $view * The View being executed. - * @return + * + * @return array * An array with keys being the strings to replace, and the values the strings - * to replace them with. The strings to replace are ofted surrounded with + * to replace them with. The strings to replace are often surrounded with * '***', as illustrated in the example implementation. */ function hook_views_query_substitutions($view) { @@ -874,10 +939,11 @@ function hook_views_query_substitutions($view) { } /** - * This hook is called to get a list of placeholders and their substitutions, - * used when preprocessing a View with form elements. + * This hook is called to get a list of placeholders and their substitutions. * - * @return + * Used when preprocessing a View with form elements. + * + * @return array * An array with keys being the strings to replace, and the values the strings * to replace them with. */ @@ -888,16 +954,31 @@ function hook_views_form_substitutions() { } /** - * Allows altering a view at the very beginning of views processing, before - * anything is done. + * Allows altering a view at the very beginning of processing a preview. + * + * Occurs before anything is done. + * + * This hook is only triggered when the one of the following are invoked: + * - $view->execute_display() + * - $view->preview() + * + * As such code placed in this hook will not fire during: + * - $view->build() + * - $view->execute() + * - $view->render() + * + * Likely, hook_views_pre_build() or hook_views_pre_execute() are much better + * choices for most use cases since they are always invoked, not just when + * previewing a display. * * Adding output to the view can be accomplished by placing text on * $view->attachment_before and $view->attachment_after. - * @param $view + * + * @param object $view * The view object about to be processed. - * @param $display_id + * @param string $display_id * The machine name of the active display. - * @param $args + * @param array $args * An array of arguments passed into the view. */ function hook_views_pre_view(&$view, &$display_id, &$args) { @@ -906,25 +987,25 @@ function hook_views_pre_view(&$view, &$display_id, &$args) { // (Note that this is not necessarily the best way to solve that task. Feel // free to contribute another example!) if ( - $view->name == 'my_special_view' && - user_access('administer site configuration') && - $display_id == 'public_display' + $view->name == 'my_special_view' + && user_access('administer site configuration') + && $display_id == 'public_display' ) { $view->set_display('private_display'); } } /** - * This hook is called right before the build process, but after displays - * are attached and the display performs its pre_execute phase. + * Called after the display's pre_execute phase but before the build process. * * Adding output to the view can be accomplished by placing text on * $view->attachment_before and $view->attachment_after. - * @param $view + * + * @param object $view * The view object about to be processed. */ function hook_views_pre_build(&$view) { - // Because of some unexplicable business logic, we should remove all + // Because of some inexplicable business logic, we should remove all // attachments from all views on Mondays. // (This alter could be done later in the execution process as well.) if (date('D') == 'Mon') { @@ -934,12 +1015,15 @@ function hook_views_pre_build(&$view) { } /** - * This hook is called right after the build process. The query is now fully - * built, but it has not yet been run through db_rewrite_sql. + * This hook is called right after the build process. + * + * The query is now fully built, but it has not yet been run through + * db_rewrite_sql. * * Adding output to the view can be accomplished by placing text on * $view->attachment_before and $view->attachment_after. - * @param $view + * + * @param object $view * The view object about to be processed. */ function hook_views_post_build(&$view) { @@ -957,12 +1041,15 @@ function hook_views_post_build(&$view) { } /** - * This hook is called right before the execute process. The query is now fully - * built, but it has not yet been run through db_rewrite_sql. + * This hook is called right before the execute process. + * + * The query is now fully built, but it has not yet been run through + * db_rewrite_sql. * * Adding output to the view can be accomplished by placing text on * $view->attachment_before and $view->attachment_after. - * @param $view + * + * @param object $view * The view object about to be processed. */ function hook_views_pre_execute(&$view) { @@ -976,14 +1063,16 @@ function hook_views_pre_execute(&$view) { } /** - * This hook is called right after the execute process. The query has - * been executed, but the pre_render() phase has not yet happened for - * handlers. + * This hook is called right after the execute process. + * + * The query has been executed, but the pre_render() phase has not yet happened + * for handlers. * * Adding output to the view can be accomplished by placing text on - * $view->attachment_before and $view->attachment_after. Altering the - * content can be achieved by editing the items of $view->result. - * @param $view + * $view->attachment_before and $view->attachment_after. Altering the content + * can be achieved by editing the items of $view->result. + * + * @param object $view * The view object about to be processed. */ function hook_views_post_execute(&$view) { @@ -997,16 +1086,18 @@ function hook_views_post_execute(&$view) { } /** - * This hook is called right before the render process. The query has been - * executed, and the pre_render() phase has already happened for handlers, so - * all data should be available. + * This hook is called right before the render process. + * + * The query has been executed, and the pre_render() phase has already happened + * for handlers, so all data should be available. * * Adding output to the view can be accomplished by placing text on * $view->attachment_before and $view->attachment_after. Altering the content * can be achieved by editing the items of $view->result. * * This hook can be utilized by themes. - * @param $view + * + * @param object $view * The view object about to be processed. */ function hook_views_pre_render(&$view) { @@ -1037,11 +1128,12 @@ function hook_views_pre_render(&$view) { * so all ids used in the query should be discoverable. * * This hook can be utilized by themes. - * @param $view + * + * @param object $view * The view object about to be processed. - * @param $output + * @param string $output * A flat string with the rendered output of the view. - * @param $cache + * @param array $cache * The cache settings. */ function hook_views_post_render(&$view, &$output, &$cache) { @@ -1061,10 +1153,11 @@ function hook_views_post_render(&$view, &$output, &$cache) { * 'path' key returned by MODULENAME_views_api(), or the same directory as the * .module file, if 'path' is unspecified. * - * @param $view + * @param object $view * The view object about to be processed. - * @param $query + * @param object $query * An object describing the query. + * * @see hook_views_query_substitutions() */ function hook_views_query_alter(&$view, &$query) { @@ -1075,7 +1168,7 @@ function hook_views_query_alter(&$view, &$query) { // Traverse through the 'where' part of the query. foreach ($query->where as &$condition_group) { foreach ($condition_group['conditions'] as &$condition) { - // If this is the part of the query filtering on title, chang the + // If this is the part of the query filtering on title, change the // condition to filter on node ID. if ($condition['field'] == 'node.title') { $condition = array( @@ -1090,8 +1183,9 @@ function hook_views_query_alter(&$view, &$query) { } /** - * Alter the information box that (optionally) appears with a view preview, - * including query and performance statistics. + * Alter the information box that (optionally) appears with a view preview. + * + * Includes query and performance statistics. * * This hook should be placed in MODULENAME.views.inc and it will be * auto-loaded. MODULENAME.views.inc must be in the directory specified by the @@ -1101,14 +1195,15 @@ function hook_views_query_alter(&$view, &$query) { * Warning: $view is not a reference in PHP4 and cannot be modified here. But it * IS a reference in PHP5, and can be modified. Please be careful with it. * - * @param $rows + * @param array $rows * An associative array with two keys: * - query: An array of rows suitable for theme('table'), containing * information about the query and the display title and path. * - statistics: An array of rows suitable for theme('table'), containing * performance statistics. - * @param $view + * @param object $view * The view object. + * * @see theme_table() */ function hook_views_preview_info_alter(&$rows, $view) { @@ -1121,15 +1216,16 @@ function hook_views_preview_info_alter(&$rows, $view) { } /** - * This hooks allows to alter the links at the top of the view edit form. Some - * modules might want to add links there. + * This hooks allows to alter the links at the top of the view edit form. * - * @param $links + * Some modules might want to add links there. + * + * @param array $links * An array of links which will be displayed at the top of the view edit form. * Each entry should be on a form suitable for theme('link'). - * @param view $view + * @param object $view * The full view object which is currently edited. - * @param $display_id + * @param string $display_id * The current display id which is edited. For example that's 'default' or * 'page_1'. */ @@ -1141,20 +1237,19 @@ function hook_views_ui_display_top_links_alter(&$links, $view, $display_id) { } /** - * This hook allows to alter the commands which are used on a views ajax - * request. + * Allows altering the commands which are used on a views AJAX request. * - * @param $commands - * An array of ajax commands - * @param $view view + * @param array $commands + * An array of ajax commands. + * @param object $view * The view which is requested. */ function hook_views_ajax_data_alter(&$commands, $view) { // Replace Views' method for scrolling to the top of the element with your // custom scrolling method. foreach ($commands as &$command) { - if ($command['method'] == 'viewsScrollTop') { - $command['method'] .= 'myScrollTop'; + if ($command['command'] == 'viewsScrollTop') { + $command['command'] .= 'myScrollTop'; } } } @@ -1165,12 +1260,41 @@ function hook_views_ajax_data_alter(&$commands, $view) { * This hook should fire whenever a view is enabled, disabled, created, * updated, or deleted. * + * @param string $cid + * The cache identifier that is being cleared. + * * @see views_invalidate_cache() */ -function hook_views_invalidate_cache() { +function hook_views_invalidate_cache($cid) { cache_clear_all('views:*', 'cache_mymodule', TRUE); } +/** + * Allow modules to alter a view prior to being saved. + */ +function hook_views_view_presave($view) { + // Do some adjustments to the view. Handle with care. + if (mymodule_check_view($view)) { + mymodule_do_some_voodoo($view); + } +} + +/** + * Allow modules to respond to a view being saved. + */ +function hook_views_view_save($view) { + // Make a watchdog entry. + watchdog('views', 'The view @name was deleted by @user at @time', array('@name' => $view->name, '@user' => $GLOBALS['user']->name, '@time' => format_date(time()))); +} + +/** + * Allow modules to respond to a view being deleted or reverted. + */ +function hook_views_view_delete($view) { + // Make a watchdog entry. + watchdog('views', 'The view @name was deleted by @user at @time', array('@name' => $view->name, '@user' => $GLOBALS['user']->name, '@time' => format_date(time()))); +} + /** * @} */ diff --git a/sites/all/modules/contrib/views/views/views.info b/sites/all/modules/contrib/views/views/views.info index 87b01b9..d9d1c11 100644 --- a/sites/all/modules/contrib/views/views/views.info +++ b/sites/all/modules/contrib/views/views/views.info @@ -2,7 +2,6 @@ name = Views description = Create customized lists and queries from your database. package = Views core = 7.x -php = 5.2 ; Always available CSS stylesheets[all][] = css/views.css @@ -27,9 +26,11 @@ files[] = handlers/views_handler_field.inc files[] = handlers/views_handler_field_counter.inc files[] = handlers/views_handler_field_boolean.inc files[] = handlers/views_handler_field_contextual_links.inc +files[] = handlers/views_handler_field_ctools_dropdown.inc files[] = handlers/views_handler_field_custom.inc files[] = handlers/views_handler_field_date.inc files[] = handlers/views_handler_field_entity.inc +files[] = handlers/views_handler_field_links.inc files[] = handlers/views_handler_field_markup.inc files[] = handlers/views_handler_field_math.inc files[] = handlers/views_handler_field_numeric.inc @@ -116,6 +117,7 @@ files[] = modules/locale/views_handler_field_locale_link_edit.inc files[] = modules/locale/views_handler_filter_locale_group.inc files[] = modules/locale/views_handler_filter_locale_language.inc files[] = modules/locale/views_handler_filter_locale_version.inc +files[] = modules/locale/views_handler_sort_node_language.inc files[] = modules/node/views_handler_argument_dates_various.inc files[] = modules/node/views_handler_argument_node_language.inc files[] = modules/node/views_handler_argument_node_nid.inc @@ -133,11 +135,14 @@ files[] = modules/node/views_handler_field_node_revision_link_delete.inc files[] = modules/node/views_handler_field_node_revision_link_revert.inc files[] = modules/node/views_handler_field_node_path.inc files[] = modules/node/views_handler_field_node_type.inc +files[] = modules/node/views_handler_field_node_version_count.inc files[] = modules/node/views_handler_filter_history_user_timestamp.inc files[] = modules/node/views_handler_filter_node_access.inc files[] = modules/node/views_handler_filter_node_status.inc files[] = modules/node/views_handler_filter_node_type.inc files[] = modules/node/views_handler_filter_node_uid_revision.inc +files[] = modules/node/views_handler_filter_node_version_count.inc +files[] = modules/node/views_handler_sort_node_version_count.inc files[] = modules/node/views_plugin_argument_default_node.inc files[] = modules/node/views_plugin_argument_validate_node.inc files[] = modules/node/views_plugin_row_node_rss.inc @@ -151,6 +156,8 @@ files[] = modules/search/views_handler_filter_search.inc files[] = modules/search/views_handler_sort_search_score.inc files[] = modules/search/views_plugin_row_search_view.inc files[] = modules/statistics/views_handler_field_accesslog_path.inc +files[] = modules/statistics/views_handler_field_node_counter_timestamp.inc +files[] = modules/statistics/views_handler_field_statistics_numeric.inc files[] = modules/system/views_handler_argument_file_fid.inc files[] = modules/system/views_handler_field_file.inc files[] = modules/system/views_handler_field_file_extension.inc @@ -161,6 +168,7 @@ files[] = modules/system/views_handler_filter_file_status.inc files[] = modules/taxonomy/views_handler_argument_taxonomy.inc files[] = modules/taxonomy/views_handler_argument_term_node_tid.inc files[] = modules/taxonomy/views_handler_argument_term_node_tid_depth.inc +files[] = modules/taxonomy/views_handler_argument_term_node_tid_depth_join.inc files[] = modules/taxonomy/views_handler_argument_term_node_tid_depth_modifier.inc files[] = modules/taxonomy/views_handler_argument_vocabulary_vid.inc files[] = modules/taxonomy/views_handler_argument_vocabulary_machine_name.inc @@ -169,6 +177,7 @@ files[] = modules/taxonomy/views_handler_field_term_node_tid.inc files[] = modules/taxonomy/views_handler_field_term_link_edit.inc files[] = modules/taxonomy/views_handler_filter_term_node_tid.inc files[] = modules/taxonomy/views_handler_filter_term_node_tid_depth.inc +files[] = modules/taxonomy/views_handler_filter_term_node_tid_depth_join.inc files[] = modules/taxonomy/views_handler_filter_vocabulary_vid.inc files[] = modules/taxonomy/views_handler_filter_vocabulary_machine_name.inc files[] = modules/taxonomy/views_handler_relationship_node_term_data.inc @@ -292,12 +301,14 @@ files[] = tests/styles/views_plugin_style_unformatted.test files[] = tests/views_access.test files[] = tests/views_analyze.test files[] = tests/views_basic.test +files[] = tests/views_ajax.test files[] = tests/views_argument_default.test files[] = tests/views_argument_validator.test files[] = tests/views_exposed_form.test files[] = tests/field/views_fieldapi.test files[] = tests/views_glossary.test files[] = tests/views_groupby.test +files[] = tests/views_handler_filter.test files[] = tests/views_handlers.test files[] = tests/views_module.test files[] = tests/views_pager.test @@ -318,9 +329,8 @@ files[] = tests/views_cache.test files[] = tests/views_view.test files[] = tests/views_ui.test -; Information added by Drupal.org packaging script on 2015-02-11 -version = "7.x-3.10" +; Information added by Drupal.org packaging script on 2019-04-03 +version = "7.x-3.22" core = "7.x" project = "views" -datestamp = "1423648085" - +datestamp = "1554307093" diff --git a/sites/all/modules/contrib/views/views/views.install b/sites/all/modules/contrib/views/views/views.install index b69f410..92c7abc 100644 --- a/sites/all/modules/contrib/views/views/views.install +++ b/sites/all/modules/contrib/views/views/views.install @@ -19,20 +19,18 @@ function views_install() { /** * Implements hook_schema(). - * - * Generate the current version of the database schema from - * the sequence of schema update functions. Uses a similar - * method to install.inc's drupal_get_schema_versions() to - * establish the update sequence. - * - * To change the schema, add a new views_schema_N() - * function to match the associated views_update_N() - * - * @param $caller_function - * The name of the function that called us. - * Used internally, if requesting a specific schema version. */ -function views_schema($caller_function = FALSE) { +function views_schema($caller_function = NULL) { + // Generate the current version of the database schema from the sequence of + // schema update functions. Uses a similar method to install.inc's + // drupal_get_schema_versions() to establish the update sequence. + // + // To change the schema, add a new views_schema_N() function to match the + // associated views_update_N(). + // + // @param string $caller_function + // The name of the function that called us. Used internally, if requesting a + // specific schema version. static $get_current; static $schemas = array(); @@ -44,31 +42,30 @@ function views_schema($caller_function = FALSE) { // Generate a sorted list of available schema update functions. if ($get_current || empty($schemas)) { $get_current = FALSE; - $functions = get_defined_functions(); - foreach ($functions['user'] as $function) { - if (strpos($function, 'views_schema_') === 0) { - $version = substr($function, strlen('views_schema_')); - if (is_numeric($version)) { - $schemas[] = $version; - } + // Provide a worst-case scenario range. + $start_schema = 6000; + $end_schema = 7999; + for ($i = $start_schema; $i <= $end_schema; $i++) { + if (function_exists('views_schema_' . $i)) { + $schemas[] = $i; } } if ($schemas) { sort($schemas, SORT_NUMERIC); - // If a specific version was requested, drop any later - // updates from the sequence. + // If a specific version was requested, drop any later updates from the + // sequence. if ($caller_function) { do { $schema = array_pop($schemas); - } while ($schemas && $caller_function != 'views_schema_'. $schema); + } while ($schemas && $caller_function != 'views_schema_' . $schema); } } } // Call views_schema_, for the highest available . if ($schema = array_pop($schemas)) { - $function = 'views_schema_'. $schema; + $function = 'views_schema_' . $schema; return $function(); } @@ -77,12 +74,14 @@ function views_schema($caller_function = FALSE) { /** * Views 2's initial schema. + * * Called directly by views_update_6000() for updates from Drupal 5. * * Important: Do not edit this schema! * - * Updates to the views schema must be provided as views_schema_6xxx() functions, - * which views_schema() automatically sees and applies. See below for examples. + * Updates to the views schema must be provided as views_schema_6xxx() + * functions, which views_schema() automatically sees and applies. See below for + * examples. * * Please do document updates with comments in this function, however. */ @@ -103,11 +102,11 @@ function views_schema_6000() { 'current_version' => '3.0', ), 'object' => 'view', - // the callback to load the displays + // the callback to load the displays. 'subrecords callback' => 'views_load_display_records', - // the variable that holds enabled/disabled status + // the variable that holds enabled/disabled status. 'status' => 'views_defaults', - // CRUD callbacks + // CRUD callbacks. 'create callback' => 'views_new_view', 'save callback' => 'views_save_view', 'delete callback' => 'views_delete_view', @@ -149,7 +148,8 @@ function views_schema_6000() { ), 'base_table' => array( 'type' => 'varchar', - 'length' => '32', // Updated to '64' in views_schema_6005() + 'length' => '32', + // Updated to '64' in views_schema_6005() 'default' => '', 'not null' => TRUE, 'description' => 'What table this view is based on, such as node, user, comment, or term.', @@ -162,7 +162,8 @@ function views_schema_6000() { ), ), 'primary key' => array('vid'), - 'unique key' => array('name' => array('name')), // Updated to 'unique keys' in views_schema_6003() + 'unique key' => array('name' => array('name')), + // Updated to 'unique keys' in views_schema_6003() ); $schema['views_display'] = array( @@ -242,7 +243,8 @@ function views_schema_6000() { 'description' => 'The time this cache was created or updated.', ), 'data' => array( - 'type' => 'blob', // Updated to 'text' (with size => 'big') in views_schema_6004() + 'type' => 'blob', + // Updated to 'text' (with size => 'big') in views_schema_6004() 'description' => 'Serialized data being stored.', 'serialize' => TRUE, ), @@ -253,8 +255,7 @@ function views_schema_6000() { ), ); - // $schema['cache_views_data'] added in views_schema_6006() - + // $schema['cache_views_data'] added in views_schema_6006(). return $schema; } @@ -296,8 +297,10 @@ function views_update_6001() { update_sql("UPDATE {blocks} SET delta = CONCAT(delta, '-block_1') WHERE module = 'views'"); } -// NOTE: Update 6002 removed because it did not always work. -// Update 6004 implements the change correctly. +/** + * NOTE: Update 6002 removed because it did not always work. + * Update 6004 implements the change correctly. + */ /** * Add missing unique key. @@ -337,7 +340,7 @@ function views_update_6004() { } /** - * Enlarge the base_table column + * Enlarge the base_table column. */ function views_schema_6005() { $schema = views_schema(__FUNCTION__); @@ -402,7 +405,7 @@ function views_update_6008() { } /** - * Enlarge the views_display.display_options field to accomodate a larger set + * Enlarge the views_display.display_options field to accommodate a larger set * of configurations (e. g. fields, filters, etc.) on a display. */ function views_schema_6009() { @@ -444,7 +447,7 @@ function views_update_6009() { } /** - * Remove the view_php field + * Remove the view_php field. */ function views_schema_6010() { $schema = views_schema(__FUNCTION__); @@ -454,7 +457,7 @@ function views_schema_6010() { } /** - * Remove the view_php and is_cacheable field + * Remove the view_php and is_cacheable field. */ function views_update_6010() { db_drop_field('views_view', 'view_php'); @@ -488,7 +491,7 @@ function views_update_6011() { */ function views_update_6012() { // There is only one simple query to run. - $update = db_update('blocks') + db_update('blocks') ->condition('module', 'views') ->condition('delta', db_like('-exp-') . '%', 'LIKE') ->fields(array('cache' => DRUPAL_NO_CACHE)); @@ -578,7 +581,7 @@ function views_update_7000() { } /** - * Fix missing items from Views administrative breadcrumb + * Fix missing items from Views administrative breadcrumb. */ function views_update_7001() { $depth = db_select('menu_links') @@ -619,7 +622,7 @@ function views_schema_7301() { } /** - * Enlarge the name column + * Enlarge the name column. */ function views_update_7301() { $new_field = array( @@ -631,3 +634,17 @@ function views_update_7301() { ); db_change_field('views_view', 'name', 'name', $new_field); } + +/** + * Remove headers field from cache tables. + * + * @see system_update_7054() + */ +function views_update_7302() { + if (db_field_exists('cache_views', 'headers')) { + db_drop_field('cache_views', 'headers'); + } + if (db_field_exists('cache_views_data', 'headers')) { + db_drop_field('cache_views_data', 'headers'); + } +} diff --git a/sites/all/modules/contrib/views/views/views.module b/sites/all/modules/contrib/views/views/views.module index 9cdcfb5..58cfed4 100644 --- a/sites/all/modules/contrib/views/views/views.module +++ b/sites/all/modules/contrib/views/views/views.module @@ -10,7 +10,33 @@ */ /** - * Advertise the current views api version + * Implements hook_help(). + */ +function views_help($path, $arg) { + switch ($path) { + case 'admin/help#views': + $output = ''; + $output .= '

      ' . t('About') . '

      '; + $output .= '

      ' . t('The Views module provides a back end to fetch information from content, user accounts, taxonomy terms, and other entities from the database and present it to the user as a grid, HTML list, table, unformatted list, etc. The resulting displays are known generally as views.') . '

      '; + $output .= '

      ' . t('For more information, see the online documentation for the Views.', array('@views' => 'https://www.drupal.org/documentation/modules/views')) . '

      '; + $output .= '

      ' . t('In order to create and modify your own views using the administration and configuration user interface, you will need to enable either the Views UI module in core or a contributed module that provides a user interface for Views. See the Views UI module help page for more information.') . '

      '; + + $output .= '

      ' . t('Uses') . '

      '; + $output .= '
      '; + $output .= '
      ' . t('Adding functionality to administrative pages') . '
      '; + $output .= '
      ' . t('The Views module adds functionality to some core administration pages. For example, admin/content uses Views to filter and sort content. With Views uninstalled, admin/content is more limited.') . '
      '; + + $output .= '
      ' . t('Expanding Views functionality') . '
      '; + $output .= '
      ' . t('Contributed projects that support the Views module can be found in the online documentation for Views-related contributed modules..', array('@views-related' => 'https://www.drupal.org/documentation/modules/views/add-ons')) . '
      '; + + $output .= '
      ' . t('Improving table accessibility') . '
      '; + $output .= '
      ' . t('Views tables include semantic markup to improve accessibility. Data cells are automatically associated with header cells through id and header attributes. To improve the accessibility of your tables you can add descriptive elements within the Views table settings. The caption element can introduce context for a table, making it easier to understand. The summary element can provide an overview of how the data has been organized and how to navigate the table. Both the caption and summary are visible by default and also implemented according to HTML5 guidelines.') . '
      '; + return $output; + } +} + +/** + * Advertise the current views api version. */ function views_api_version() { return '3.0'; @@ -55,7 +81,9 @@ function views_api_minimum_version() { } /** - * Implement hook_theme(). Register views theming functions. + * Implements hook_theme(). + * + * Register views theming functions. */ function views_theme($existing, $type, $theme, $path) { $path = drupal_get_path('module', 'views'); @@ -67,9 +95,13 @@ function views_theme($existing, $type, $theme, $path) { 'path' => $path . '/theme', ); - // Our extra version of pager from pager.inc + // Our extra version of pager from pager.inc. $hooks['views_mini_pager'] = $base + array( - 'variables' => array('tags' => array(), 'element' => 0, 'parameters' => array()), + 'variables' => array( + 'tags' => array(), + 'element' => 0, + 'parameters' => array(), + ), 'pattern' => 'views_mini_pager__', ); @@ -78,28 +110,48 @@ function views_theme($existing, $type, $theme, $path) { // $view is an object but the core contextual_preprocess() function only // attaches contextual links when the primary theme argument is an array. 'display' => array('view_array' => array(), 'view' => NULL), - 'style' => array('view' => NULL, 'options' => NULL, 'rows' => NULL, 'title' => NULL), - 'row' => array('view' => NULL, 'options' => NULL, 'row' => NULL, 'field_alias' => NULL), + 'style' => array( + 'view' => NULL, + 'options' => NULL, + 'rows' => NULL, + 'title' => NULL, + ), + 'row' => array( + 'view' => NULL, + 'options' => NULL, + 'row' => NULL, + 'field_alias' => NULL, + ), 'exposed_form' => array('view' => NULL, 'options' => NULL), 'pager' => array( - 'view' => NULL, 'options' => NULL, - 'tags' => array(), 'quantity' => 10, 'element' => 0, 'parameters' => array() + 'view' => NULL, + 'options' => NULL, + 'tags' => array(), + 'quantity' => 10, + 'element' => 0, + 'parameters' => array(), ), ); - // Default view themes + // Default view themes. $hooks['views_view_field'] = $base + array( 'pattern' => 'views_view_field__', 'variables' => array('view' => NULL, 'field' => NULL, 'row' => NULL), ); $hooks['views_view_grouping'] = $base + array( 'pattern' => 'views_view_grouping__', - 'variables' => array('view' => NULL, 'grouping' => NULL, 'grouping_level' => NULL, 'rows' => NULL, 'title' => NULL), + 'variables' => array( + 'view' => NULL, + 'grouping' => NULL, + 'grouping_level' => NULL, + 'rows' => NULL, + 'title' => NULL, + ), ); $plugins = views_fetch_plugin_data(); - // Register theme functions for all style plugins + // Register theme functions for all style plugins. foreach ($plugins as $type => $info) { foreach ($info as $plugin => $def) { if (isset($def['theme']) && (!isset($def['register theme']) || !empty($def['register theme']))) { @@ -154,7 +206,11 @@ function views_theme($existing, $type, $theme, $path) { $hooks['views_more'] = $base + array( 'template' => 'views-more', 'pattern' => 'views_more__', - 'variables' => array('more_url' => NULL, 'link_text' => 'more', 'view' => NULL), + 'variables' => array( + 'more_url' => NULL, + 'link_text' => 'more', + 'view' => NULL, + ), ); // Add theme suggestions which are part of modules. @@ -169,16 +225,16 @@ function views_theme($existing, $type, $theme, $path) { /** * Scans a directory of a module for template files. * - * @param $cache + * @param array $cache * The existing cache of theme hooks to test against. - * @param $path + * @param string $path * The path to search. * * @see drupal_find_theme_templates() */ function _views_find_module_templates($cache, $path) { $templates = array(); - $regex = '/' . '\.tpl\.php' . '$' . '/'; + $regex = '/\.tpl\.php$/'; // Because drupal_system_listing works the way it does, we check for real // templates separately from checking for patterns. @@ -216,11 +272,12 @@ function _views_find_module_templates($cache, $path) { // for the purposes of searching. $pattern = strtr($info['pattern'], '_', '-'); - $matches = preg_grep('/^'. $pattern .'/', $patterns); + $matches = preg_grep('/^' . $pattern . '/', $patterns); if ($matches) { foreach ($matches as $match) { $file = substr($match, 0, strpos($match, '.')); - // Put the underscores back in for the hook name and register this pattern. + // Put the underscores back in for the hook name and register this + // pattern. $templates[strtr($file, '-', '_')] = array( 'template' => $file, 'path' => dirname($files[$match]->uri), @@ -289,6 +346,8 @@ function views_plugin_list() { } /** + * Preprocess a node. + * * A theme preprocess function to automatically allow view-based node * templates if called from a view. * @@ -304,8 +363,8 @@ function views_preprocess_node(&$vars) { if (!empty($vars['node']->view->current_display)) { $vars['theme_hook_suggestions'][] = 'node__view__' . $vars['node']->view->name . '__' . $vars['node']->view->current_display; - // If a node is being rendered in a view, and the view does not have a path, - // prevent drupal from accidentally setting the $page variable: + // If a node is being rendered in a view, and the view does not have a + // path, prevent drupal from accidentally setting the $page variable. if ($vars['page'] && $vars['view_mode'] == 'full' && !$vars['view']->display_handler->has_path()) { $vars['page'] = FALSE; } @@ -319,11 +378,14 @@ function views_preprocess_node(&$vars) { } /** + * Preprocess a comment. + * * A theme preprocess function to automatically allow view-based node * templates if called from a view. */ function views_preprocess_comment(&$vars) { - // The 'view' attribute of the node is added in template_preprocess_views_view_row_comment() + // The 'view' attribute of the node is added in + // template_preprocess_views_view_row_comment(). if (!empty($vars['node']->view) && !empty($vars['node']->view->name)) { $vars['view'] = &$vars['node']->view; $vars['theme_hook_suggestions'][] = 'comment__view__' . $vars['node']->view->name; @@ -334,7 +396,7 @@ function views_preprocess_comment(&$vars) { } /** - * Implement hook_permission(). + * Implements hook_permission(). */ function views_permission() { return array( @@ -352,7 +414,7 @@ function views_permission() { } /** - * Implement hook_menu(). + * Implements hook_menu(). */ function views_menu() { $items = array(); @@ -366,8 +428,8 @@ function views_menu() { 'type' => MENU_CALLBACK, 'file' => 'includes/ajax.inc', ); - // Path is not admin/structure/views due to menu complications with the wildcards from - // the generic ajax callback. + // Path is not admin/structure/views due to menu complications with the + // wildcards from the generic ajax callback. $items['admin/views/ajax/autocomplete/user'] = array( 'page callback' => 'views_ajax_autocomplete_user', 'theme callback' => 'ajax_base_page_theme', @@ -377,7 +439,7 @@ function views_menu() { 'file' => 'includes/ajax.inc', ); // Define another taxonomy autocomplete because the default one of drupal - // does not support a vid a argument anymore + // does not support a vid a argument anymore. $items['admin/views/ajax/autocomplete/taxonomy'] = array( 'page callback' => 'views_ajax_autocomplete_taxonomy', 'theme callback' => 'ajax_base_page_theme', @@ -390,7 +452,7 @@ function views_menu() { } /** - * Implement hook_menu_alter(). + * Implements hook_menu_alter(). */ function views_menu_alter(&$callbacks) { $our_paths = array(); @@ -399,18 +461,14 @@ function views_menu_alter(&$callbacks) { list($view, $display_id) = $data; $result = $view->execute_hook_menu($display_id, $callbacks); if (is_array($result)) { - // The menu system doesn't support having two otherwise - // identical paths with different placeholders. So we - // want to remove the existing items from the menu whose - // paths would conflict with ours. - - // First, we must find any existing menu items that may - // conflict. We use a regular expression because we don't - // know what placeholders they might use. Note that we - // first construct the regex itself by replacing %views_arg - // in the display path, then we use this constructed regex - // (which will be something like '#^(foo/%[^/]*/bar)$#') to - // search through the existing paths. + // The menu system doesn't support having two otherwise identical paths + // with different placeholders. So we want to remove the existing items + // from the menu whose paths would conflict with ours. First, we must find + // any existing menu items that may conflict. We use a regular expression + // because we don't know what placeholders they might use. Note that we + // first construct the regex itself by replacing %views_arg in the display + // path, then we use this constructed regex (which will be something like + // '#^(foo/%[^/]*/bar)$#') to search through the existing paths. $regex = '#^(' . preg_replace('#%views_arg#', '%[^/]*', implode('|', array_keys($result))) . ')$#'; $matches = preg_grep($regex, array_keys($callbacks)); @@ -431,10 +489,10 @@ function views_menu_alter(&$callbacks) { // This item already exists, so it must be one that we added. // We change the various callback arguments to pass an array // of possible display IDs instead of a single ID. - $callbacks[$path]['page arguments'][1] = (array)$callbacks[$path]['page arguments'][1]; + $callbacks[$path]['page arguments'][1] = (array) $callbacks[$path]['page arguments'][1]; $callbacks[$path]['page arguments'][1][] = $display_id; $callbacks[$path]['access arguments'][] = $item['access arguments'][0]; - $callbacks[$path]['load arguments'][1] = (array)$callbacks[$path]['load arguments'][1]; + $callbacks[$path]['load arguments'][1] = (array) $callbacks[$path]['load arguments'][1]; $callbacks[$path]['load arguments'][1][] = $display_id; } $our_paths[$path] = TRUE; @@ -450,22 +508,24 @@ function views_menu_alter(&$callbacks) { } /** + * Load a views argument. + * * Helper function for menu loading. This will automatically be * called in order to 'load' a views argument; primarily it * will be used to perform validation. * - * @param $value + * @param string $value * The actual value passed. - * @param $name + * @param string $name * The name of the view. This needs to be specified in the 'load function' * of the menu entry. - * @param $display_id + * @param string $display_id * The display id that will be loaded for this menu item. - * @param $index + * @param int $index * The menu argument index. This counts from 1. */ function views_arg_load($value, $name, $display_id, $index) { - static $views = array(); + static $views = array(); $display_ids = is_array($display_id) ? $display_id : array($display_id); $display_id = reset($display_ids); @@ -521,12 +581,12 @@ function views_arg_load($value, $name, $display_id, $index) { /** * Page callback: Displays a page view, given a name and display id. * - * @param $name + * @param string $name * The name of a view. - * @param $display_id + * @param string $display_id * The display id of a view. * - * @return + * @return string|int * Either the HTML of a fully-executed view, or MENU_NOT_FOUND. */ function views_page($name, $display_id) { @@ -590,8 +650,8 @@ function views_preprocess_html(&$variables) { } /** -* Implements hook_preprocess_HOOK() for page.tpl.php. -*/ + * Implements hook_preprocess_HOOK() for page.tpl.php. + */ function views_preprocess_page(&$variables) { // If the page contains a view as its main content, contextual links may have // been attached to the page as a whole; for example, by views_page_alter(). @@ -623,7 +683,7 @@ function views_contextual_links_view_alter(&$element, $items) { } /** - * Implement hook_block_info(). + * Implements hook_block_info(). */ function views_block_info() { // Try to avoid instantiating all the views just to get the blocks info. @@ -636,7 +696,7 @@ function views_block_info() { $items = array(); $views = views_get_all_views(); foreach ($views as $view) { - // disabled views get nothing. + // Disabled views get nothing. if (!empty($view->disabled)) { continue; } @@ -665,7 +725,7 @@ function views_block_info() { // can also be 32. So for very long deltas, change to md5 hashes. $hashes = array(); - // get the keys because we're modifying the array and we don't want to + // Get the keys because we're modifying the array and we don't want to // confuse PHP too much. $keys = array_keys($items); foreach ($keys as $delta) { @@ -693,11 +753,10 @@ function views_block_info() { } /** - * Implement hook_block_view(). + * Implements hook_block_view(). */ function views_block_view($delta) { - $start = microtime(TRUE); - // if this is 32, this should be an md5 hash. + // If this is 32, this should be an md5 hash. if (strlen($delta) == 32) { $hashes = variable_get('views_block_hashes', array()); if (!empty($hashes[$delta])) { @@ -732,7 +791,7 @@ function views_block_view($delta) { return; } list($name, $display_id) = $explode; - // Load the view + // Load the view. if ($view = views_get_view($name)) { if ($view->access($display_id)) { $output = $view->execute_display($display_id); @@ -749,18 +808,18 @@ function views_block_view($delta) { /** * Converts Views block content to a renderable array with contextual links. * - * @param $block + * @param array $block * An array representing the block, with the same structure as the return * value of hook_block_view(). This will be modified so as to force * $block['content'] to be a renderable array, containing the optional * '#contextual_links' property (if there are any contextual links associated * with the block). - * @param $view + * @param object $view * The view that was used to generate the block content. - * @param $display_id + * @param string $display_id * The ID of the display within the view that was used to generate the block * content. - * @param $block_type + * @param string $block_type * The type of the block. If it's block it's a regular views display, * but 'special_block_-exp' exist as well. */ @@ -807,12 +866,12 @@ function views_add_block_contextual_links(&$block, $view, $display_id, $block_ty * later on (for example, alter hooks which run later during the same page * request). * - * @param $render_element + * @param array $render_element * The renderable array to which contextual links will be added. This array * should be suitable for passing in to drupal_render() and will normally * contain a representation of the view display whose contextual links are * being requested. - * @param $location + * @param string $location * The location in which the calling function intends to render the view and * its contextual links. The core system supports three options for this * parameter: @@ -832,9 +891,9 @@ function views_add_block_contextual_links(&$block, $view, $display_id, $block_ty * declare, via the 'contextual links locations' array key, which view * displays support having their contextual links rendered in the location * you have defined. - * @param $view + * @param object $view * The view whose contextual links will be added. - * @param $display_id + * @param string $display_id * The ID of the display within $view whose contextual links will be added. * * @see hook_views_plugins() @@ -852,7 +911,7 @@ function views_add_contextual_links(&$render_element, $location, $view, $display $plugin = views_fetch_plugin_data('display', $view->display[$display_id]->display_plugin); // If contextual links locations are not set, provide a sane default. (To // avoid displaying any contextual links at all, a display plugin can still - // set 'contextual links locations' to, e.g., an empty array.) + // set 'contextual links locations' to, e.g., an empty array). $plugin += array('contextual links locations' => array('view')); // On exposed_forms blocks contextual links should always be visible. $plugin['contextual links locations'][] = 'special_block_-exp'; @@ -894,13 +953,14 @@ function views_add_contextual_links(&$render_element, $location, $view, $display /** * Returns an array of language names. * - * This is a one to one copy of locale_language_list because we can't rely on enabled locale module. + * This is a one to one copy of locale_language_list because we can't rely on + * enabled locale module. * - * @param $field - * 'name' => names in current language, localized - * 'native' => native names - * @param $all - * Boolean to return all languages or only enabled ones + * @param string $field + * Either 'name' for localized names in current language or 'native' for + * native names. + * @param bool $all + * Boolean to return all languages or only enabled ones. * * @see locale_language_list() */ @@ -927,7 +987,7 @@ function views_flush_caches() { } /** - * Implements hook_field_create_instance. + * Implements hook_field_create_instance(). */ function views_field_create_instance($instance) { cache_clear_all('*', 'cache_views', TRUE); @@ -935,7 +995,7 @@ function views_field_create_instance($instance) { } /** - * Implements hook_field_update_instance. + * Implements hook_field_update_instance(). */ function views_field_update_instance($instance, $prior_instance) { cache_clear_all('*', 'cache_views', TRUE); @@ -943,7 +1003,7 @@ function views_field_update_instance($instance, $prior_instance) { } /** - * Implements hook_field_delete_instance. + * Implements hook_field_delete_instance(). */ function views_field_delete_instance($instance) { cache_clear_all('*', 'cache_views', TRUE); @@ -952,10 +1012,14 @@ function views_field_delete_instance($instance) { /** * Invalidate the views cache, forcing a rebuild on the next grab of table data. + * + * @param string $cid + * The cache identifier we want to clear. If no given, it will default to '*' + * which will clear the entire cache_views bin. */ -function views_invalidate_cache() { +function views_invalidate_cache($cid = '*') { // Clear the views cache. - cache_clear_all('*', 'cache_views', TRUE); + cache_clear_all($cid, 'cache_views', TRUE); // Clear the page and block cache. cache_clear_all(); @@ -964,7 +1028,7 @@ function views_invalidate_cache() { variable_set('menu_rebuild_needed', TRUE); // Allow modules to respond to the Views cache being cleared. - module_invoke_all('views_invalidate_cache'); + module_invoke_all('views_invalidate_cache', $cid); } /** @@ -1020,13 +1084,26 @@ function views_access() { * permissions. If the $account argument is omitted, the current user * is used. */ -function views_check_perm($perm, $account = NULL) { - return user_access($perm, $account) || user_access('access all views', $account); +function views_check_perm($perms, $account = NULL) { + // Backward compatibility to ensure also a single permission string is + // properly processed. + $perms = is_array($perms) ? $perms : array($perms); + if (user_access('access all views', $account)) { + return TRUE; + } + // Perms are handled as OR, as soon one permission allows access TRUE is + // returned. + foreach ($perms as $perm) { + if (user_access($perm, $account)) { + return TRUE; + } + } + return FALSE; } /** * Access callback for the views_plugin_access_role access plugin. - + * * Determine if the specified user has access to a view on the basis of any of * the requested roles. If the $account argument is omitted, the current user * is used. @@ -1038,10 +1115,10 @@ function views_check_roles($rids, $account = NULL) { $roles[] = $account->uid ? DRUPAL_AUTHENTICATED_RID : DRUPAL_ANONYMOUS_RID; return user_access('access all views', $account) || array_intersect(array_filter($rids), $roles); } -// ------------------------------------------------------------------ -// Functions to help identify views that are running or ran /** + * Set page view. + * * Set the current 'page view' that is being displayed so that it is easy * for other modules or the theme to identify. */ @@ -1055,6 +1132,8 @@ function &views_set_page_view($view = NULL) { } /** + * Get page view. + * * Find out what, if any, page view is currently in use. Please note that * this returns a reference, so be careful! You can unintentionally modify the * $view object. @@ -1067,10 +1146,13 @@ function &views_get_page_view() { } /** + * Set current view. + * * Set the current 'current view' that is being built/rendered so that it is - * easy for other modules or items in drupal_eval to identify + * easy for other modules or items in drupal_eval to identify. * * @return view + * The current view. */ function &views_set_current_view($view = NULL) { static $cache = NULL; @@ -1082,24 +1164,28 @@ function &views_set_current_view($view = NULL) { } /** + * Get current view. + * * Find out what, if any, current view is currently in use. Please note that * this returns a reference, so be careful! You can unintentionally modify the * $view object. * * @return view + * The current view. */ function &views_get_current_view() { return views_set_current_view(); } -// ------------------------------------------------------------------ -// Include file helpers - /** * Include views .inc files as necessary. */ function views_include($file) { - ctools_include($file, 'views'); + static $views_path; + if (!isset($views_path)) { + $views_path = DRUPAL_ROOT . '/' . drupal_get_path('module', 'views'); + } + include_once $views_path . '/includes/' . $file . '.inc'; } /** @@ -1136,7 +1222,7 @@ function views_get_module_apis($api = 'views', $reset = FALSE) { function views_add_css($file) { // We set preprocess to FALSE because we are adding the files conditionally, // and we don't want to generate duplicate cache files. - // TODO: at some point investigate adding some files unconditionally and + // @todo at some point investigate adding some files unconditionally and // allowing preprocess. drupal_add_css(drupal_get_path('module', 'views') . "/css/$file.css", array('preprocess' => FALSE)); } @@ -1180,22 +1266,18 @@ function views_include_handlers($reset = FALSE) { $finished = TRUE; } -// ----------------------------------------------------------------------- -// Views handler functions - /** * Fetch a handler from the data cache. * - * @param $table + * @param string $table * The name of the table this handler is from. - * @param $field + * @param string $field * The name of the field this handler is from. - * @param $key - * The type of handler. i.e, sort, field, argument, filter, relationship - * @param $override - * Override the actual handler object with this class. Used for - * aggregation when the handler is redirected to the aggregation - * handler. + * @param string $key + * The type of handler. i.e, sort, field, argument, filter, relationship. + * @param mixed $override + * Override the actual handler object with this class. Used for aggregation + * when the handler is redirected to the aggregation handler. * * @return views_handler * An instance of a handler object. May be views_handler_broken. @@ -1207,8 +1289,6 @@ function views_get_handler($table, $field, $key, $override = NULL) { $handler = NULL; views_include('handlers'); - // Support old views_data entries conversion. - // Support conversion on table level. if (isset($data['moved to'])) { $moved = array($data['moved to'], $field); @@ -1226,7 +1306,7 @@ function views_get_handler($table, $field, $key, $override = NULL) { if (!empty($moved)) { list($moved_table, $moved_field) = $moved; if (!empty($recursion_protection[$moved_table][$moved_field])) { - // recursion detected! + // Recursion detected! return NULL; } @@ -1234,7 +1314,7 @@ function views_get_handler($table, $field, $key, $override = NULL) { $handler = views_get_handler($moved_table, $moved_field, $key, $override); $recursion_protection = array(); if ($handler) { - // store these values so we know what we were originally called. + // Store these values so we know what we were originally called. $handler->original_table = $table; $handler->original_field = $field; if (empty($handler->actual_table)) { @@ -1245,7 +1325,7 @@ function views_get_handler($table, $field, $key, $override = NULL) { return $handler; } - // Set up a default handler: + // Set up a default handler. if (empty($data[$field][$key]['handler'])) { $data[$field][$key]['handler'] = 'views_handler_' . $key; } @@ -1261,8 +1341,9 @@ function views_get_handler($table, $field, $key, $override = NULL) { return $handler; } - // DEBUG -- identify missing handlers - vpr("Missing handler: @table @field @key", array('@table' => $table, '@field' => $field, '@key' => $key)); + // DEBUG -- identify missing handlers. + $placeholders = array('@table' => $table, '@field' => $field, '@key' => $key); + vpr("Missing handler: @table @field @key", $placeholders); $broken = array( 'title' => t('Broken handler @table.@field', array('@table' => $table, '@field' => $field)), 'handler' => 'views_handler_' . $key . '_broken', @@ -1273,16 +1354,13 @@ function views_get_handler($table, $field, $key, $override = NULL) { } /** - * Fetch Views' data from the cache + * Fetch Views' data from the cache. */ function views_fetch_data($table = NULL, $move = TRUE, $reset = FALSE) { views_include('cache'); return _views_fetch_data($table, $move, $reset); } -// ----------------------------------------------------------------------- -// Views plugin functions - /** * Fetch the plugin data from cache. */ @@ -1292,17 +1370,17 @@ function views_fetch_plugin_data($type = NULL, $plugin = NULL, $reset = FALSE) { } /** - * Fetch a list of all base tables available + * Fetch a list of all base tables available. * - * @param $type - * Either 'display', 'style' or 'row' - * @param $key - * For style plugins, this is an optional type to restrict to. May be 'normal', - * 'summary', 'feed' or others based on the neds of the display. - * @param $base + * @param string $type + * Either 'display', 'style' or 'row'. + * @param string $key + * For style plugins, this is an optional type to restrict to. May be + * 'normal', 'summary', 'feed' or others based on the needs of the display. + * @param array $base * An array of possible base tables. * - * @return + * @return array * A keyed array of in the form of 'base_table' => 'Description'. */ function views_fetch_plugin_names($type, $key = NULL, $base = array()) { @@ -1324,16 +1402,16 @@ function views_fetch_plugin_names($type, $key = NULL, $base = array()) { asort($plugins[$type]); return $plugins[$type]; } - // fall-through + + // Fall-through. return array(); } /** - * Get a handler for a plugin + * Get a handler for a plugin. * * @return views_plugin - * - * The created plugin object. + * The created plugin object. */ function views_get_plugin($type, $plugin, $reset = FALSE) { views_include('handlers'); @@ -1346,7 +1424,8 @@ function views_get_plugin($type, $plugin, $reset = FALSE) { /** * Load the current enabled localization plugin. * - * @return The name of the localization plugin. + * @return string + * The name of the localization plugin. */ function views_get_localization_plugin() { $plugin = variable_get('views_localization_plugin', ''); @@ -1363,9 +1442,6 @@ function views_get_localization_plugin() { return $plugin; } -// ----------------------------------------------------------------------- -// Views database functions - /** * Get all view templates. * @@ -1406,19 +1482,20 @@ function views_new_view() { } /** - * Return a list of all views and display IDs that have a particular - * setting in their display's plugin settings. + * Get applicable views. * - * @return - * @code - * array( - * array($view, $display_id), - * array($view, $display_id), - * ); - * @endcode + * Return a list of all views and display IDs that have a particular setting in + * their display's plugin settings. + * + * @return array + * An array with the following structure. + * array( + * array($view, $display_id), + * array($view, $display_id), + * ); */ function views_get_applicable_views($type) { - // @todo: Use a smarter flagging system so that we don't have to + // @todo Use a smarter flagging system so that we don't have to // load every view for this. $result = array(); $views = views_get_all_views(); @@ -1459,7 +1536,7 @@ function views_get_applicable_views($type) { /** * Return an array of all views as fully loaded $view objects. * - * @param $reset + * @param bool $reset * If TRUE, reset the static cache forcing views to be reloaded. */ function views_get_all_views($reset = FALSE) { @@ -1484,29 +1561,31 @@ function views_get_disabled_views() { } /** + * Get options array. + * * Return an array of view as options array, that can be used by select, * checkboxes and radios as #options. * * @param bool $views_only - * If TRUE, only return views, not displays. + * If TRUE, only return views, not displays. * @param string $filter - * Filters the views on status. Can either be 'all' (default), 'enabled' or - * 'disabled' - * @param mixed $exclude_view - * view or current display to exclude - * either a - * - views object (containing $exclude_view->name and $exclude_view->current_display) - * - views name as string: e.g. my_view - * - views name and display id (separated by ':'): e.g. my_view:default + * Filters the views on status. Can either be 'all' (default), 'enabled' or + * 'disabled'. + * @param mixed $exclude_view + * View or current display to exclude + * either a + * - views object (containing name and current_display) + * - views name as string: e.g. my_view + * - views name and display id (separated by ':'): e.g. my_view:default. * @param bool $optgroup - * If TRUE, returns an array with optgroups for each view (will be ignored for - * $views_only = TRUE). Can be used by select + * If TRUE, returns an array with optgroups for each view (will be ignored for + * $views_only = TRUE). Can be used by select. * @param bool $sort - * If TRUE, the list of views is sorted ascending. + * If TRUE, the list of views is sorted ascending. * * @return array - * an associative array for use in select. - * - key: view name and display id separated by ':', or the view name only + * An associative array for use in select. + * - key: view name and display id separated by ':', or the view name only */ function views_get_views_as_options($views_only = FALSE, $filter = 'all', $exclude_view = NULL, $optgroup = FALSE, $sort = FALSE) { @@ -1518,6 +1597,7 @@ function views_get_views_as_options($views_only = FALSE, $filter = 'all', $exclu $func = "views_get_{$filter}_views"; $views = $func(); break; + default: return array(); } @@ -1582,10 +1662,11 @@ function views_view_is_disabled($view) { * isn't called 'views_load()' primarily because it might get a view * from the default views which aren't technically loaded from the database. * - * @param $name + * @param string $name * The name of the view. - * @param $reset + * @param bool $reset * If TRUE, reset this entry in the load cache. + * * @return view * A reference to the $view object. Use $reset if you're sure you want * a fresh one. @@ -1691,22 +1772,19 @@ function views_export_status($view, $status) { views_invalidate_cache(); } -// ------------------------------------------------------------------ -// Views debug helper functions - /** * Provide debug output for Views. * * This relies on devel.module * or on the debug() function if you use a simpletest. * - * @param $message + * @param mixed $message * The message/variable which should be debugged. * This either could be * * an array/object which is converted to pretty output - * * a translation source string which is used together with the parameter placeholders. - * - * @param $placeholder + * * a translation source string which is used together with the parameter + * placeholders. + * @param array $placeholders * The placeholders which are used for the translation source string. */ function views_debug($message, $placeholders = array()) { @@ -1719,7 +1797,7 @@ function views_debug($message, $placeholders = array()) { $output = $message; watchdog('views_logging', $output, $placeholders); } - else if ($devel_region == 'drupal_debug') { + elseif ($devel_region == 'drupal_debug') { $output = empty($output) ? t($message, $placeholders) : $output; dd($output); } @@ -1735,14 +1813,14 @@ function views_debug($message, $placeholders = array()) { } /** - * Shortcut to views_debug() + * Shortcut to views_debug(). */ function vpr($message, $placeholders = array()) { views_debug($message, $placeholders); } /** - * Debug messages + * Debug messages. */ function vsm($message) { if (module_exists('devel')) { @@ -1753,7 +1831,8 @@ function vsm($message) { function views_trace() { $message = ''; foreach (debug_backtrace() as $item) { - if (!empty($item['file']) && !in_array($item['function'], array('vsm_trace', 'vpr_trace', 'views_trace'))) { + $traces = array('vsm_trace', 'vpr_trace', 'views_trace'); + if (!empty($item['file']) && !in_array($item['function'], $traces)) { $message .= basename($item['file']) . ": " . (empty($item['class']) ? '' : ($item['class'] . '->')) . "$item[function] line $item[line]" . "\n"; } } @@ -1768,10 +1847,9 @@ function vpr_trace() { dpr(views_trace()); } -// ------------------------------------------------------------------ -// Views form (View with form elements) - /** + * Determine whether the view has form elements. + * * Returns TRUE if the passed-in view contains handlers with views form * implementations, FALSE otherwise. */ @@ -1793,6 +1871,7 @@ function views_view_has_form_elements($view) { /** * This is the entry function. Just gets the form for the current step. + * * The form is always assumed to be multistep, even if it has only one * step (the default 'views_form_views_form' step). That way it is actually * possible for modules to have a multistep form if they need to. @@ -1820,6 +1899,7 @@ function views_form($form, &$form_state, $view, $output) { /** * Callback for the main step of a Views form. + * * Invoked by views_form(). */ function views_form_views_form($form, &$form_state, $view, $output) { @@ -1909,6 +1989,7 @@ function views_form_views_form($form, &$form_state, $view, $output) { /** * Validate handler for the first step of the views form. + * * Calls any existing views_form_validate functions located * on the views fields. */ @@ -1934,6 +2015,7 @@ function views_form_views_form_validate($form, &$form_state) { /** * Submit handler for the first step of the views form. + * * Calls any existing views_form_submit functions located * on the views fields. */ @@ -1957,9 +2039,6 @@ function views_form_views_form_submit($form, &$form_state) { } } -// ------------------------------------------------------------------ -// Exposed widgets form - /** * Form builder for the exposed widgets form. * @@ -1969,7 +2048,8 @@ function views_exposed_form($form, &$form_state) { // Don't show the form when batch operations are in progress. if ($batch = batch_get() && isset($batch['current_set'])) { return array( - // Set the theme callback to be nothing to avoid errors in template_preprocess_views_exposed_form(). + // Set the theme callback to be nothing to avoid errors in + // template_preprocess_views_exposed_form(). '#theme' => '', ); } @@ -1984,7 +2064,7 @@ function views_exposed_form($form, &$form_state) { // Let form plugins know this is for exposed widgets. $form_state['exposed'] = TRUE; - // Check if the form was already created + // Check if the form was already created. if ($cache = views_exposed_form_cache($view->name, $view->current_display)) { return $cache; } @@ -2021,8 +2101,9 @@ function views_exposed_form($form, &$form_state) { } } + // Form submit, #name is an empty string to prevent showing up in $_GET. $form['submit'] = array( - '#name' => '', // prevent from showing up in $_GET. + '#name' => '', '#type' => 'submit', '#value' => t('Apply'), '#id' => drupal_html_id('edit-submit-' . $view->name), @@ -2031,7 +2112,6 @@ function views_exposed_form($form, &$form_state) { $form['#action'] = url($view->display_handler->get_url()); $form['#theme'] = views_theme_functions('views_exposed_form', $view, $display); $form['#id'] = drupal_clean_css_identifier('views_exposed_form-' . check_plain($view->name) . '-' . check_plain($display->id)); -// $form['#attributes']['class'] = array('views-exposed-form'); // If using AJAX, we need the form plugin. if ($view->use_ajax) { @@ -2042,14 +2122,14 @@ function views_exposed_form($form, &$form_state) { $exposed_form_plugin = $form_state['exposed_form_plugin']; $exposed_form_plugin->exposed_form_alter($form, $form_state); - // Save the form + // Save the form. views_exposed_form_cache($view->name, $view->current_display, $form); return $form; } /** - * Implement hook_form_alter for the exposed form. + * Implements hook_form_alter() for views_exposed_form(). * * Since the exposed form is a GET form, we don't want it to send a wide * variety of information. @@ -2061,7 +2141,7 @@ function views_form_views_exposed_form_alter(&$form, &$form_state) { } /** - * Validate handler for exposed filters + * Validate handler for exposed filters. */ function views_exposed_form_validate(&$form, &$form_state) { foreach (array('field', 'filter') as $type) { @@ -2075,7 +2155,7 @@ function views_exposed_form_validate(&$form, &$form_state) { } /** - * Submit handler for exposed filters + * Submit handler for exposed filters. */ function views_exposed_form_submit(&$form, &$form_state) { foreach (array('field', 'filter') as $type) { @@ -2087,8 +2167,16 @@ function views_exposed_form_submit(&$form, &$form_state) { $form_state['view']->exposed_data = $form_state['values']; $form_state['view']->exposed_raw_input = array(); - - $exclude = array('q', 'submit', 'form_build_id', 'form_id', 'form_token', 'exposed_form_plugin', '', 'reset'); + $exclude = array( + 'q', + 'submit', + 'form_build_id', + 'form_id', + 'form_token', + 'exposed_form_plugin', + '', + 'reset', + ); $exposed_form_plugin = $form_state['exposed_form_plugin']; $exposed_form_plugin->exposed_form_submit($form, $form_state, $exclude); @@ -2102,13 +2190,14 @@ function views_exposed_form_submit(&$form, &$form_state) { /** * Save the Views exposed form for later use. * - * @param $views_name - * String. The views name. - * @param $display_name - * String. The current view display name. - * @param $form_output - * Array (optional). The form structure. Only needed when inserting the value. - * @return + * @param string $views_name + * The views name. + * @param string $display_name + * The current view display name. + * @param array $form_output + * An optional form structure. Only needed when inserting the value. + * + * @return array|bool * Array. The form structure, if any. Otherwise, return FALSE. */ function views_exposed_form_cache($views_name, $display_name, $form_output = NULL) { @@ -2116,19 +2205,15 @@ function views_exposed_form_cache($views_name, $display_name, $form_output = NUL // be cleared between each test. $views_exposed = &drupal_static(__FUNCTION__); - // Save the form output + // Save the form output. if (!empty($form_output)) { $views_exposed[$views_name][$display_name] = $form_output; - return; } - // Return the form output, if any + // Return the form output, if any. return empty($views_exposed[$views_name][$display_name]) ? FALSE : $views_exposed[$views_name][$display_name]; } -// ------------------------------------------------------------------ -// Misc helpers - /** * Build a list of theme function names for use most everywhere. */ @@ -2213,9 +2298,9 @@ function _views_query_tag_alter_condition(QueryAlterableInterface $query, &$cond * to do that, you will need to do what this function does manually, by * loading the view, getting the preview and then getting $view->get_title(). * - * @param $name + * @param string $name * The name of the view to embed. - * @param $display_id + * @param string $display_id * The display id to embed. If unsure, use 'default', as it will always be * valid. But things like 'page' or 'block' should work here. * @param ... @@ -2223,9 +2308,11 @@ function _views_query_tag_alter_condition(QueryAlterableInterface $query, &$cond */ function views_embed_view($name, $display_id = 'default') { $args = func_get_args(); - array_shift($args); // remove $name + // Remove $name. + array_shift($args); if (count($args)) { - array_shift($args); // remove $display_id + // Remove $display_id. + array_shift($args); } $view = views_get_view($name); @@ -2250,14 +2337,17 @@ function views_embed_view($name, $display_id = 'default') { * Everything after #views-tab- is the display ID, e.g. page_1. * @param ... * Any additional parameters will be passed as arguments. + * * @return array * An array containing an object for each view item. */ function views_get_view_result($name, $display_id = NULL) { $args = func_get_args(); - array_shift($args); // remove $name + // Remove $name. + array_shift($args); if (count($args)) { - array_shift($args); // remove $display_id + // Remove $display_id. + array_shift($args); } $view = views_get_view($name); @@ -2322,22 +2412,28 @@ function views_var_export($var, $prefix = '', $init = TRUE) { } /** - * Prepare a string for use as a valid CSS identifier (element, class or ID name). + * Prepare a string for use as a valid CSS identifier. + * * This function is similar to a core version but with more sane filter values. - * * http://www.w3.org/TR/CSS21/syndata.html#characters shows the syntax for valid - * CSS identifiers (including element names, classes, and IDs in selectors.) + * CSS identifiers (including element names, classes, and IDs in selectors). * - * @param $identifier + * @param string $identifier * The identifier to clean. - * @param $filter + * @param array $filter * An array of string replacements to use on the identifier. - * @return + * + * @return string * The cleaned identifier. * * @see drupal_clean_css_identifier() */ -function views_clean_css_identifier($identifier, $filter = array(' ' => '-', '/' => '-', '[' => '-', ']' => '')) { +function views_clean_css_identifier($identifier, $filter = array( + ' ' => '-', + '/' => '-', + '[' => '-', + ']' => '', +)) { // By default, we filter using Drupal's coding standards. $identifier = strtr($identifier, $filter); @@ -2355,19 +2451,19 @@ function views_clean_css_identifier($identifier, $filter = array(' ' => '-', '/' } /** - * Implement hook_views_exportables(). + * Implements hook_views_exportables(). */ function views_views_exportables($op = 'list', $views = NULL, $name = 'foo') { $all_views = views_get_all_views(); if ($op == 'list') { foreach ($all_views as $name => $view) { - // in list, $views is a list of tags. + // In list, $views is a list of tags. if (empty($views) || in_array($view->tag, $views)) { $return[$name] = array( 'name' => check_plain($name), 'desc' => check_plain($view->description), - 'tag' => check_plain($view->tag) + 'tag' => check_plain($view->tag), ); } } @@ -2394,7 +2490,7 @@ function views_views_exportables($op = 'list', $views = NULL, $name = 'foo') { } /** - * #process callback to see if we need to check_plain() the options. + * Process callback to see if we need to check_plain() the options. * * Since FAPI is inconsistent, the #options are sanitized for you in all cases * _except_ checkboxes. We have form elements that are sometimes 'select' and @@ -2412,19 +2508,18 @@ function views_process_check_options($element, &$form_state) { /** * Trim the field down to the specified length. * - * @param $alter - * - max_length: Maximum lenght of the string, the rest gets truncated. + * @param array $alter + * - max_length: Maximum length of the string, the rest gets truncated. * - word_boundary: Trim only on a word boundary. * - ellipsis: Show an ellipsis (...) at the end of the trimmed string. * - html: Take sure that the html is correct. - * - * @param $value + * @param string $value * The string which should be trimmed. */ function views_trim_text($alter, $value) { if (drupal_strlen($value) > $alter['max_length']) { $value = drupal_substr($value, 0, $alter['max_length']); - // TODO: replace this with cleanstring of ctools + // @todo Replace this with cleanstring of CTools. if (!empty($alter['word_boundary'])) { $regex = "(.*)\b.+"; if (function_exists('mb_ereg')) { @@ -2438,7 +2533,7 @@ function views_trim_text($alter, $value) { $value = $matches[1]; } } - // Remove scraps of HTML entities from the end of a strings + // Remove scraps of HTML entities from the end of a strings. $value = rtrim(preg_replace('/(?:<(?!.+>)|&(?!.+;)).*$/us', '', $value)); if (!empty($alter['ellipsis'])) { @@ -2461,7 +2556,7 @@ function views_array_key_plus($array) { $keys = array_keys($array); rsort($keys); foreach ($keys as $key) { - $array[$key+1] = $array[$key]; + $array[$key + 1] = $array[$key]; unset($array[$key]); } asort($array); @@ -2469,14 +2564,15 @@ function views_array_key_plus($array) { } /** - * Report to CTools that we use hook_views_api instead of hook_ctools_plugin_api() + * Implements hook_ctools_plugin_api_hook_name(). + * + * Report to CTools that we use hook_views_api instead of + * hook_ctools_plugin_api(). */ function views_ctools_plugin_api_hook_name() { return 'views_api'; } -// Declare API compatibility on behalf of core modules: - /** * Implements hook_views_api(). * @@ -2484,84 +2580,179 @@ function views_ctools_plugin_api_hook_name() { */ function views_views_api() { return array( - // in your modules do *not* use views_api_version()!!! + // In your modules do *not* use views_api_version()!!! 'api' => views_api_version(), 'path' => drupal_get_path('module', 'views') . '/modules', ); } if (!function_exists('aggregator_views_api')) { - function aggregator_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Aggregator module. + */ + function aggregator_views_api() { + return views_views_api(); + } } if (!function_exists('book_views_api')) { - function book_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Book module. + */ + function book_views_api() { + return views_views_api(); + } } if (!function_exists('comment_views_api')) { - function comment_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Comment module. + */ + function comment_views_api() { + return views_views_api(); + } } if (!function_exists('field_views_api')) { - function field_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Field module. + */ + function field_views_api() { + return views_views_api(); + } } if (!function_exists('file_views_api')) { - function file_views_api() { return views_views_api(); } + /** + * Provide Views integration for the File module. + */ + function file_views_api() { + return views_views_api(); + } } if (!function_exists('filter_views_api')) { - function filter_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Filter module. + */ + function filter_views_api() { + return views_views_api(); + } } if (!function_exists('image_views_api')) { - function image_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Image module. + */ + function image_views_api() { + return views_views_api(); + } } if (!function_exists('locale_views_api')) { - function locale_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Locale module. + */ + function locale_views_api() { + return views_views_api(); + } } if (!function_exists('node_views_api')) { - function node_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Node module. + */ + function node_views_api() { + return views_views_api(); + } } if (!function_exists('poll_views_api')) { - function poll_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Poll module. + */ + function poll_views_api() { + return views_views_api(); + } } if (!function_exists('profile_views_api')) { - function profile_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Profile module. + */ + function profile_views_api() { + return views_views_api(); + } } if (!function_exists('search_views_api')) { - function search_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Search module. + */ + function search_views_api() { + return views_views_api(); + } } if (!function_exists('statistics_views_api')) { - function statistics_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Statistics module. + */ + function statistics_views_api() { + return views_views_api(); + } } if (!function_exists('system_views_api')) { - function system_views_api() { return views_views_api(); } + /** + * Provide Views integration for the System module. + */ + function system_views_api() { + return views_views_api(); + } } if (!function_exists('tracker_views_api')) { - function tracker_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Tracker module. + */ + function tracker_views_api() { + return views_views_api(); + } } if (!function_exists('taxonomy_views_api')) { - function taxonomy_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Taxonomy module. + */ + function taxonomy_views_api() { + return views_views_api(); + } } if (!function_exists('translation_views_api')) { - function translation_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Translation module. + */ + function translation_views_api() { + return views_views_api(); + } } if (!function_exists('user_views_api')) { - function user_views_api() { return views_views_api(); } + /** + * Provide Views integration for the User module. + */ + function user_views_api() { + return views_views_api(); + } } if (!function_exists('contact_views_api')) { - function contact_views_api() { return views_views_api(); } + /** + * Provide Views integration for the Contact module. + */ + function contact_views_api() { + return views_views_api(); + } } diff --git a/sites/all/modules/contrib/views/views/views.tokens.inc b/sites/all/modules/contrib/views/views/views.tokens.inc index cc45b5c..bdd0da1 100644 --- a/sites/all/modules/contrib/views/views/views.tokens.inc +++ b/sites/all/modules/contrib/views/views/views.tokens.inc @@ -48,7 +48,6 @@ function views_tokens($type, $tokens, array $data = array(), array $options = ar $url_options['language'] = $options['language']; } $sanitize = !empty($options['sanitize']); - $langcode = isset($options['language']) ? $options['language']->language : NULL; $replacements = array(); diff --git a/sites/all/modules/contrib/views/views/views_ui.info b/sites/all/modules/contrib/views/views/views_ui.info index d8be6e4..3053db9 100644 --- a/sites/all/modules/contrib/views/views/views_ui.info +++ b/sites/all/modules/contrib/views/views/views_ui.info @@ -4,12 +4,12 @@ package = Views core = 7.x configure = admin/structure/views dependencies[] = views +# @codingStandardsIgnoreLine files[] = views_ui.module files[] = plugins/views_wizard/views_ui_base_views_wizard.class.php -; Information added by Drupal.org packaging script on 2015-02-11 -version = "7.x-3.10" +; Information added by Drupal.org packaging script on 2019-04-03 +version = "7.x-3.22" core = "7.x" project = "views" -datestamp = "1423648085" - +datestamp = "1554307093" diff --git a/sites/all/modules/contrib/views/views/views_ui.module b/sites/all/modules/contrib/views/views/views_ui.module index 5366f77..387e669 100644 --- a/sites/all/modules/contrib/views/views/views_ui.module +++ b/sites/all/modules/contrib/views/views/views_ui.module @@ -5,6 +5,29 @@ * Provide structure for the administrative interface to Views. */ +/** + * Implements hook_help(). + */ +function views_ui_help($path, $arg) { + switch ($path) { + case 'admin/help#views_ui': + $output = ''; + $output .= '

      ' . t('About') . '

      '; + $output .= '

      ' . t('The Views UI module provides an interface for managing views for the Views module. For more information, see the online documentation for the Views UI module.', array('@views' => 'https://www.drupal.org/documentation/modules/views')) . '

      '; + $output .= '

      ' . t('Uses') . '

      '; + $output .= '
      '; + $output .= '
      ' . t('Creating and managing views') . '
      '; + $output .= '
      ' . t('Views can be created from the Views list page by using the "Add view" action. Existing views can be managed from the Views list page by locating the view in the "Enabled" or "Disabled" list and selecting the desired operation action, for example "Edit".') . '
      '; + + $output .= '
      ' . t('Enabling and disabling views') . '
      '; + $output .= '
      ' . t('Views can be enabled or disabled from the Views list page. To enable a view, find the view within the "Disabled" list and select the "Enable" operation. To disable a view find the view within the "Enabled" list and select the "Disable" operation.') . '
      '; + + $output .= '
      ' . t('Exporting and importing views') . '
      '; + $output .= '
      ' . t('Views can be exported and imported as configuration files by using the Configuration Manager module.') . '
      '; + return $output; + } +} + /** * Implements hook_menu(). */ @@ -96,7 +119,6 @@ function views_ui_menu() { ) + $base; // Additional pages for acting on a View. - $items['admin/structure/views/view/%views_ui_cache/break-lock'] = array( 'title' => 'Break lock', 'page callback' => 'drupal_get_form', @@ -143,7 +165,7 @@ function views_ui_menu() { 'type' => MENU_CALLBACK, ) + $base; - // A page in the Reports section to show usage of fields in all views + // A page in the Reports section to show usage of fields in all views. $items['admin/reports/fields/list'] = array( 'title' => 'List', 'type' => MENU_DEFAULT_LOCAL_TASK, @@ -175,9 +197,17 @@ function views_ui_theme() { require_once DRUPAL_ROOT . "/$path/includes/admin.inc"; return array( - // edit a view + // Edit a view. 'views_ui_display_tab_setting' => array( - 'variables' => array('description' => '', 'link' => '', 'settings_links' => array(), 'overridden' => FALSE, 'defaulted' => FALSE, 'description_separator' => TRUE, 'class' => array()), + 'variables' => array( + 'description' => '', + 'link' => '', + 'settings_links' => array(), + 'overridden' => FALSE, + 'defaulted' => FALSE, + 'description_separator' => TRUE, + 'class' => array(), + ), 'template' => 'views-ui-display-tab-setting', 'path' => "$path/theme", ), @@ -186,11 +216,6 @@ function views_ui_theme() { 'template' => 'views-ui-display-tab-bucket', 'path' => "$path/theme", ), - 'views_ui_edit_item' => array( - 'variables' => array('type' => NULL, 'view' => NULL, 'display' => NULL, 'no_fields' => FALSE), - 'template' => 'views-ui-edit-item', - 'path' => "$path/theme", - ), 'views_ui_rearrange_form' => array( 'render element' => 'form', ), @@ -203,7 +228,7 @@ function views_ui_theme() { 'file' => 'includes/admin.inc', ), - // list views + // List views. 'views_ui_view_info' => array( 'variables' => array('view' => NULL, 'base' => NULL), 'file' => "includes/admin.inc", @@ -215,7 +240,7 @@ function views_ui_theme() { 'file' => 'includes/admin.inc', ), - // tab themes + // Tab themes. 'views_tabset' => array( 'variables' => array('tabs' => NULL), ), @@ -227,15 +252,19 @@ function views_ui_theme() { 'file' => 'includes/admin.inc', ), - - // On behalf of a plugin + // On behalf of a plugin. 'views_ui_style_plugin_table' => array( 'render element' => 'form', ), // When previewing a view. 'views_ui_view_preview_section' => array( - 'variables' => array('view' => NULL, 'section' => NULL, 'content' => NULL, 'links' => ''), + 'variables' => array( + 'view' => NULL, + 'section' => NULL, + 'content' => NULL, + 'links' => '', + ), ), // Generic container wrapper, to use instead of theme_container when an id @@ -248,7 +277,7 @@ function views_ui_theme() { } /** - * Impements hook_custom_theme() + * Implements hook_custom_theme(). */ function views_ui_custom_theme() { $theme = variable_get('views_ui_custom_theme', '_default'); @@ -279,10 +308,10 @@ function views_ui_edit_page_title($view) { /** * Specialized menu callback to load a view and check its locked status. * - * @param $name + * @param string $name * The machine name of the view. * - * @return + * @return object * The view object, with a "locked" property indicating whether or not * someone else is already editing the view. */ @@ -320,6 +349,8 @@ function views_ui_cache_load($name) { } /** + * Cache set. + * * Specialized cache function to add a flag to our view, include an appropriate * include, and cache more easily. */ @@ -329,7 +360,8 @@ function views_ui_cache_set(&$view) { return; } ctools_include('object-cache'); - $view->changed = TRUE; // let any future object know that this view has changed. + // Let any future object know that this view has changed. + $view->changed = TRUE; if (isset($view->current_display)) { // Add the knowledge of the changed display, too. @@ -337,7 +369,7 @@ function views_ui_cache_set(&$view) { unset($view->current_display); } - // Unset handlers; we don't want to write these into the cache + // Unset handlers; we don't want to write these into the cache. unset($view->display_handler); unset($view->default_display); $view->query = NULL; @@ -348,8 +380,9 @@ function views_ui_cache_set(&$view) { ctools_object_cache_set('view', $view->name, $view); } - /** + * Default Load. + * * Specialized menu callback to load a view that is only a default * view. */ @@ -369,7 +402,21 @@ function views_ui_preprocess_views_view(&$vars) { $view = $vars['view']; if (!empty($view->views_ui_context) && module_exists('contextual')) { $view->hide_admin_links = TRUE; - foreach (array('title', 'header', 'exposed', 'rows', 'pager', 'more', 'footer', 'empty', 'attachment_after', 'attachment_before') as $section) { + + $sections = array( + 'title', + 'header', + 'exposed', + 'rows', + 'pager', + 'more', + 'footer', + 'empty', + 'attachment_after', + 'attachment_before', + ); + + foreach ($sections as $section) { if (!empty($vars[$section])) { $vars[$section] = array( '#theme' => 'views_ui_view_preview_section', @@ -388,8 +435,7 @@ function views_ui_preprocess_views_view(&$vars) { /** * Theme preprocess for theme_views_ui_view_preview_section(). * - * @TODO - * Perhaps move this to includes/admin.inc or theme/theme.inc + * @todo Perhaps move this to includes/admin.inc or theme/theme.inc. */ function template_preprocess_views_ui_view_preview_section(&$vars) { switch ($vars['section']) { @@ -397,42 +443,51 @@ function template_preprocess_views_ui_view_preview_section(&$vars) { $vars['title'] = t('Title'); $links = views_ui_view_preview_section_display_category_links($vars['view'], 'title', $vars['title']); break; + case 'header': $vars['title'] = t('Header'); $links = views_ui_view_preview_section_handler_links($vars['view'], $vars['section']); break; + case 'empty': $vars['title'] = t('No results behavior'); $links = views_ui_view_preview_section_handler_links($vars['view'], $vars['section']); break; + case 'exposed': // @todo Sorts can be exposed too, so we may need a better title. $vars['title'] = t('Exposed Filters'); $links = views_ui_view_preview_section_display_category_links($vars['view'], 'exposed_form_options', $vars['title']); break; + case 'rows': // @todo The title needs to depend on what is being viewed. $vars['title'] = t('Content'); $links = views_ui_view_preview_section_rows_links($vars['view']); break; + case 'pager': $vars['title'] = t('Pager'); $links = views_ui_view_preview_section_display_category_links($vars['view'], 'pager_options', $vars['title']); break; + case 'more': $vars['title'] = t('More'); $links = views_ui_view_preview_section_display_category_links($vars['view'], 'use_more', $vars['title']); break; + case 'footer': $vars['title'] = t('Footer'); $links = views_ui_view_preview_section_handler_links($vars['view'], $vars['section']); break; + case 'attachment_before': - // @todo: Add links to the attachment configuration page. + // @todo Add links to the attachment configuration page. $vars['title'] = t('Attachment before'); break; + case 'attachment_after': - // @todo: Add links to the attachment configuration page. + // @todo Add links to the attachment configuration page. $vars['title'] = t('Attachment after'); break; } @@ -459,18 +514,17 @@ function template_preprocess_views_ui_view_preview_section(&$vars) { function theme_views_ui_view_preview_section($vars) { return '

      ' . $vars['title'] . '

      ' . $vars['links'] - . '
      '. $vars['content'] . '
      '; + . '
      ' . $vars['content'] . '
      '; } /** * Returns contextual links for each handler of a certain section. * - * @TODO - * Bring in relationships - * Refactor this function to use much stuff of views_ui_edit_form_get_bucket. - * - * @param $title + * @param string $title * Add a bolded title of this section. + * + * @todo Bring in relationships. + * @todo Refactor this function to use much of views_ui_edit_form_get_bucket. */ function views_ui_view_preview_section_handler_links($view, $type, $title = FALSE) { $display = $view->display_handler->display; @@ -521,8 +575,9 @@ function views_ui_view_preview_section_display_category_links($view, $type, $tit * Returns all contextual links for the main content part of the view. */ function views_ui_view_preview_section_rows_links($view) { - $display = $view->display_handler->display; + $links = array(); + $links = array_merge($links, views_ui_view_preview_section_handler_links($view, 'filter', TRUE)); $links = array_merge($links, views_ui_view_preview_section_handler_links($view, 'field', TRUE)); $links = array_merge($links, views_ui_view_preview_section_handler_links($view, 'sort', TRUE)); @@ -532,7 +587,6 @@ function views_ui_view_preview_section_rows_links($view) { return $links; } - /** * Implments hook_ctools_plugin_directory(). * @@ -547,10 +601,10 @@ function views_ui_ctools_plugin_directory($module, $plugin) { /** * Fetch metadata on a specific views ui wizard plugin. * - * @param $wizard_type + * @param string $wizard_type * Name of a wizard, or name of a base table. * - * @return + * @return array * An array with information about the requested wizard type. */ function views_ui_get_wizard($wizard_type) { @@ -576,14 +630,14 @@ function views_ui_get_wizard($wizard_type) { /** * Fetch metadata for all content_type plugins. * - * @return + * @return array * An array of arrays with information about all available views wizards. */ function views_ui_get_wizards() { ctools_include('plugins'); $wizard_plugins = ctools_get_plugins('views_ui', 'views_wizard'); $wizard_tables = array(); - foreach ($wizard_plugins as $name => $info) { + foreach ($wizard_plugins as $info) { $wizard_tables[$info['base_table']] = TRUE; } $base_tables = views_fetch_base_tables(); @@ -604,7 +658,7 @@ function views_ui_get_wizards() { /** * Helper function to define the default values for a Views wizard plugin. * - * @return + * @return array * An array of defaults for a views wizard. */ function views_ui_views_wizard_defaults() { @@ -612,7 +666,7 @@ function views_ui_views_wizard_defaults() { // The children may, for example, be a different variant for each node type. 'get children' => NULL, 'get child' => NULL, - // title and base table must be populated. They are empty here just + // Title and base table must be populated. They are empty here just // so they are documented. 'title' => '', 'base_table' => NULL, @@ -641,6 +695,9 @@ function views_ui_ctools_plugin_type() { ); } +/** + * Get form wizard instance. + */ function views_ui_get_form_wizard_instance($wizard) { if (isset($wizard['form_wizard_class']['class'])) { $class = $wizard['form_wizard_class']['class']; @@ -710,7 +767,7 @@ function views_ui_contextual_links_suppress($set = NULL) { * @see views_ui_contextual_links_suppress_pop() */ function views_ui_contextual_links_suppress_push() { - views_ui_contextual_links_suppress(((int) views_ui_contextual_links_suppress())+1); + views_ui_contextual_links_suppress(((int) views_ui_contextual_links_suppress()) + 1); } /** @@ -719,13 +776,16 @@ function views_ui_contextual_links_suppress_push() { * @see views_ui_contextual_links_suppress_push() */ function views_ui_contextual_links_suppress_pop() { - views_ui_contextual_links_suppress(((int) views_ui_contextual_links_suppress())-1); + views_ui_contextual_links_suppress(((int) views_ui_contextual_links_suppress()) - 1); } /** - * Menu callback; handles AJAX form submissions similar to ajax_form_callback(), but can be used for uncached forms. + * Menu callback. * - * ajax_form_callback(), the menu callback for the system/ajax path, requires + * Handles AJAX form submissions similar to ajax_form_callback(), but can be + * used for uncached forms. + * + * Ajax_form_callback(), the menu callback for the system/ajax path, requires * the form to be retrievable from the form cache, because it lacks a trusted * $form_id argument with which to call drupal_retrieve_form(). When AJAX is * wanted on a non-cacheable form, #ajax['path'] can be set to a path whose @@ -765,16 +825,18 @@ function views_ui_ajax_get_form($form_id) { return $callback($form, $form_state); } } -// @todo move these when we can +/** + * @todo move these when we can + */ /** * Helper function to get a list of paths assigned to a view. * - * @param $view + * @param object $view * The view. * - * @return + * @return array * An array of links to this view's display paths. */ function _views_ui_get_paths($view) { @@ -783,14 +845,14 @@ function _views_ui_get_paths($view) { $all_paths[] = t('Edit this view to add a display.'); } else { - $view->init_display(); // Make sure all the handlers are set up + // Make sure all the handlers are set up. + $view->init_display(); foreach ($view->display as $display) { if (!empty($display->handler) && $display->handler->has_path()) { $one_path = $display->handler->get_option('path'); - if (empty($path_sort)) { - $path_sort = strtolower($one_path); - } + if (empty($view->disabled) && strpos($one_path, '%') === FALSE) { + // @codingStandardsIgnoreLine $all_paths[] = l('/' . $one_path, $one_path); } else { @@ -806,10 +868,10 @@ function _views_ui_get_paths($view) { /** * Helper function to get a list of displays included in a view. * - * @param $view + * @param object $view * The view. * - * @return + * @return array * An array of display types that this view includes. */ function _views_ui_get_displays_list($view) { @@ -828,21 +890,22 @@ function _views_ui_get_displays_list($view) { } /** - * This is part of a patch to address a jQueryUI bug. The bug is responsible - * for the inability to scroll a page when a modal dialog is active. If the content - * of the dialog extends beyond the bottom of the viewport, the user is only able - * to scroll with a mousewheel or up/down keyboard keys. + * This is part of a patch to address a jQueryUI bug. + * + * The bug is responsible + * for the inability to scroll a page when a modal dialog is active. If the + * content of the dialog extends beyond the bottom of the viewport, the user is + * only able to scroll with a mousewheel or up/down keyboard keys. * * @see http://bugs.jqueryui.com/ticket/4671 * @see https://bugs.webkit.org/show_bug.cgi?id=19033 * @see /js/jquery.ui.dialog.patch.js * @see /js/jquery.ui.dialog.min.js * - * The javascript patch overwrites the $.ui.dialog.overlay.events object to remove - * the mousedown, mouseup and click events from the list of events that are bound - * in $.ui.dialog.overlay.create. + * The javascript patch overwrites the $.ui.dialog.overlay.events object to + * remove the mousedown, mouseup and click events from the list of events that + * are bound in $.ui.dialog.overlay.create. */ - function views_ui_library_alter(&$libraries, $module) { if ($module == 'system' && isset($libraries['ui.dialog'])) { // Only apply the fix, if we don't have an up to date jQueryUI version. diff --git a/sites/all/modules/contrib/views/views_bulk_operations/LICENSE.txt b/sites/all/modules/contrib/views/views_bulk_operations/LICENSE.txt old mode 100755 new mode 100644 diff --git a/sites/all/modules/contrib/views/views_bulk_operations/actions/archive.action.inc b/sites/all/modules/contrib/views/views_bulk_operations/actions/archive.action.inc index 7667e49..ef36acd 100644 --- a/sites/all/modules/contrib/views/views_bulk_operations/actions/archive.action.inc +++ b/sites/all/modules/contrib/views/views_bulk_operations/actions/archive.action.inc @@ -3,10 +3,14 @@ /** * @file * Provides an action for creating a zip archive of selected files. + * * An entry in the {file_managed} table is created for the newly created archive, * and it is marked as permanent or temporary based on the operation settings. */ +/** + * Implements hook_action_info(). + */ function views_bulk_operations_archive_action_info() { $actions = array(); if (function_exists('zip_open')) { @@ -18,6 +22,7 @@ function views_bulk_operations_archive_action_info() { // "Create an advanced action" dropdown on admin/config/system/actions. 'configurable' => FALSE, 'vbo_configurable' => TRUE, + 'behavior' => array('views_property'), 'triggers' => array('any'), ); } @@ -70,6 +75,10 @@ function views_bulk_operations_archive_action($file, $context) { $archive_file->filemime = file_get_mimetype($destination); $archive_file->uid = $user->uid; $archive_file->status = $context['settings']['temporary'] ? FALSE : FILE_STATUS_PERMANENT; + // Clear filesize() cache to avoid private file system differences in + // filesize. + // @see https://www.drupal.org/node/2743999 + clearstatcache(); file_save($archive_file); $url = file_create_url($archive_file->uri); @@ -99,8 +108,11 @@ function views_bulk_operations_archive_action_form($context) { } /** - * Assembles a sanitized and unique URI for the archive, and returns it for - * usage by the action callback (views_bulk_operations_archive_action). + * Assembles a sanitized and unique URI for the archive. + * + * @returns array + * A URI array used by the action callback + * (views_bulk_operations_archive_action). */ function views_bulk_operations_archive_action_submit($form, $form_state) { // Validate the scheme, fallback to public if it's somehow invalid. @@ -155,10 +167,12 @@ function views_bulk_operations_archive_action_views_bulk_operations_form($option /** * Create a sanitized and unique version of the provided filename. * - * @param $filename - * String filename + * @param string $filename + * The filename to create. + * @param array $archive_list + * The list of files already in the archive. * - * @return + * @return string * The new filename. */ function _views_bulk_operations_archive_action_create_filename($filename, $archive_list) { @@ -166,7 +180,7 @@ function _views_bulk_operations_archive_action_create_filename($filename, $archi // some filesystems, not many applications handle them well. $filename = preg_replace('/[\x00-\x1F]/u', '_', $filename); if (substr(PHP_OS, 0, 3) == 'WIN') { - // These characters are not allowed in Windows filenames + // These characters are not allowed in Windows filenames. $filename = str_replace(array(':', '*', '?', '"', '<', '>', '|'), '_', $filename); } diff --git a/sites/all/modules/contrib/views/views_bulk_operations/actions/book.action.inc b/sites/all/modules/contrib/views/views_bulk_operations/actions/book.action.inc index add893e..4621dcd 100644 --- a/sites/all/modules/contrib/views/views_bulk_operations/actions/book.action.inc +++ b/sites/all/modules/contrib/views/views_bulk_operations/actions/book.action.inc @@ -13,11 +13,13 @@ function views_bulk_operations_book_action_info() { 'label' => t('Move to book'), 'configurable' => TRUE, 'behavior' => array('changes_property'), + 'triggers' => array('any'), ); $actions['views_bulk_operations_remove_from_book_action'] = array( 'type' => 'node', 'label' => t('Remove from book'), 'configurable' => FALSE, + 'triggers' => array('any'), ); } @@ -56,9 +58,9 @@ function views_bulk_operations_move_to_book_action_submit($form, $form_state) { function views_bulk_operations_move_to_book_action($node, $context = array()) { if (isset($context['book'])) { $book_node = node_load($context['book']); - $mlid = db_select('menu_links' , 'ml') - ->condition('ml.link_path' , 'node/' . $node->nid) - ->fields('ml' , array('mlid')) + $mlid = db_select('menu_links', 'ml') + ->condition('ml.link_path', 'node/' . $node->nid) + ->fields('ml', array('mlid')) ->execute() ->fetchField(); $node->book['mlid'] = $mlid; @@ -69,9 +71,10 @@ function views_bulk_operations_move_to_book_action($node, $context = array()) { } /** - * Adds the action 'Remove node from a parent book' + * Adds the action 'Remove node from a parent book'. */ -function views_bulk_operations_remove_from_book_action($node, $context) { - $book = $node->book['mlid']; +function views_bulk_operations_remove_from_book_action($node) { book_node_delete($node); + // Remove book to avoid book_node_update() from building the links again. + unset($node->book); } diff --git a/sites/all/modules/contrib/views/views_bulk_operations/actions/change_owner.action.inc b/sites/all/modules/contrib/views/views_bulk_operations/actions/change_owner.action.inc new file mode 100644 index 0000000..697670d --- /dev/null +++ b/sites/all/modules/contrib/views/views_bulk_operations/actions/change_owner.action.inc @@ -0,0 +1,65 @@ + array( + 'type' => 'entity', + 'label' => t('Change owner'), + 'configurable' => TRUE, + 'behavior' => array('changes_property'), + 'triggers' => array('any'), + ), + ); +} + +/** + * Action function. + */ +function views_bulk_operations_change_owner_action($entity, $context) { + $entity->uid = $context['owner_uid']; +} + +/** + * Action form function. + */ +function views_bulk_operations_change_owner_action_form($context, &$form_state) { + $form['owner_username'] = array( + '#type' => 'textfield', + '#maxlength' => USERNAME_MAX_LENGTH, + '#title' => t('Owner'), + '#required' => TRUE, + '#description' => t('Choose the user you would like to set as the owner.'), + '#autocomplete_path' => 'user/autocomplete', + ); + + return $form; +} + +/** + * Action form validate function. + * + * Checks that the submitted text is a valid username. + */ +function views_bulk_operations_change_owner_action_validate($form, $form_state) { + if (!user_load_by_name($form_state['values']['owner_username'])) { + form_set_error('owner_username', t('Valid username required.')); + } +} + +/** + * Action form submit function. + * + * Pass submitted username back to views_bulk_operations_change_owner. + */ +function views_bulk_operations_change_owner_action_submit($form, $form_state) { + $user = user_load_by_name($form_state['values']['owner_username']); + return array('owner_uid' => $user->uid); +} diff --git a/sites/all/modules/contrib/views/views_bulk_operations/actions/delete.action.inc b/sites/all/modules/contrib/views/views_bulk_operations/actions/delete.action.inc index 1106ab0..439a504 100644 --- a/sites/all/modules/contrib/views/views_bulk_operations/actions/delete.action.inc +++ b/sites/all/modules/contrib/views/views_bulk_operations/actions/delete.action.inc @@ -19,15 +19,51 @@ function views_bulk_operations_delete_action_info() { 'label' => t('Delete revision'), 'configurable' => FALSE, 'behavior' => array('deletes_property'), + 'triggers' => array('any'), ), ); } +function views_bulk_operations_delete_item_views_bulk_operations_form($settings) { + $form = array(); + $form['log'] = array( + '#type' => 'checkbox', + '#title' => t('Log individual deletions'), + '#description' => t('Note: Deleting large amounts of entities will generate large amounts of log messages.'), + '#default_value' => !empty($settings['log']), + ); + + return $form; +} + function views_bulk_operations_delete_item($entity, $context) { $info = entity_get_info($context['entity_type']); $entity_id = $entity->{$info['entity keys']['id']}; entity_delete($context['entity_type'], $entity_id); + + // Add a message to the watchdog if we've been configured to do so. + if (!empty($context['settings']['log'])) { + // Log an appropriate message for this entity type, using the format from + // the node, taxonomy and user module for their entity types. + switch ($context['entity_type']) { + case 'node': + watchdog('content', '@type: deleted %title.', array('@type' => $entity->type, '%title' => $entity->title)); + break; + + case 'taxonomy_term': + watchdog('taxonomy', 'Deleted term %name.', array('%name' => $entity->name), WATCHDOG_NOTICE); + break; + + case 'user': + watchdog('user', 'Deleted user: %name %email.', array('%name' => $entity->name, '%email' => '<' . $entity->mail . '>'), WATCHDOG_NOTICE); + break; + + default: + watchdog('entity', 'Deleted @type %label.', array('@type' => $context['entity_type'], '%label' => entity_label($context['entity_type'], $entity))); + break; + } + } } function views_bulk_operations_delete_revision($entity, $context) { diff --git a/sites/all/modules/contrib/views/views_bulk_operations/actions/modify.action.inc b/sites/all/modules/contrib/views/views_bulk_operations/actions/modify.action.inc index 71b6181..e46268d 100644 --- a/sites/all/modules/contrib/views/views_bulk_operations/actions/modify.action.inc +++ b/sites/all/modules/contrib/views/views_bulk_operations/actions/modify.action.inc @@ -1,24 +1,30 @@ array( - 'type' => 'entity', - 'label' => t('Modify entity values'), - 'behavior' => array('changes_property'), - // This action only works when invoked through VBO. That's why it's - // declared as non-configurable to prevent it from being shown in the - // "Create an advanced action" dropdown on admin/config/system/actions. - 'configurable' => FALSE, - 'vbo_configurable' => TRUE, - 'triggers' => array('any'), - )); + return array( + 'views_bulk_operations_modify_action' => array( + 'type' => 'entity', + 'label' => t('Modify entity values'), + 'behavior' => array('changes_property'), + // This action only works when invoked through VBO. That's why it's + // declared as non-configurable to prevent it from being shown in the + // "Create an advanced action" dropdown on admin/config/system/actions. + 'configurable' => FALSE, + 'vbo_configurable' => TRUE, + 'triggers' => array('any'), + ), + ); } /** @@ -28,7 +34,7 @@ function views_bulk_operations_modify_action_info() { * replacing the existing values, or appending to them (based on user input). */ function views_bulk_operations_modify_action($entity, $context) { - list(,,$bundle_name) = entity_extract_ids($context['entity_type'], $entity); + list(,, $bundle_name) = entity_extract_ids($context['entity_type'], $entity); // Handle Field API fields. if (!empty($context['selected']['bundle_' . $bundle_name])) { // The pseudo entity is cloned so that changes to it don't get carried @@ -38,7 +44,7 @@ function views_bulk_operations_modify_action($entity, $context) { // Get this field's language. We can just pull it from the pseudo entity // as it was created using field_attach_form and entity_language so it's // already been figured out if this field is translatable or not and - // applied the appropriate language code to the field + // applied the appropriate language code to the field. $language = key($pseudo_entity->{$key}); // Replace any tokens that might exist in the field columns. foreach ($pseudo_entity->{$key}[$language] as $delta => &$item) { @@ -49,7 +55,7 @@ function views_bulk_operations_modify_action($entity, $context) { } } - if (in_array($key, $context['append']['bundle_' . $bundle_name]) && !empty($entity->$key)) { + if (in_array($key, $context['append']['bundle_' . $bundle_name]) && !empty($entity->{$key})) { $entity->{$key}[$language] = array_merge($entity->{$key}[$language], $pseudo_entity->{$key}[$language]); // Check if we breached cardinality, and notify the user. @@ -58,9 +64,11 @@ function views_bulk_operations_modify_action($entity, $context) { if ($field_info['cardinality'] != FIELD_CARDINALITY_UNLIMITED && $field_count > $field_info['cardinality']) { $entity_label = entity_label($context['entity_type'], $entity); $warning = t('Tried to set !field_count values for field !field_name that supports a maximum of !cardinality.', - array('!field_count' => $field_count, - '!field_name' => $field_info['field_name'], - '!cardinality' => $field_info['cardinality'])); + array( + '!field_count' => $field_count, + '!field_name' => $field_info['field_name'], + '!cardinality' => $field_info['cardinality'], + )); drupal_set_message($warning, 'warning', FALSE); } @@ -76,25 +84,36 @@ function views_bulk_operations_modify_action($entity, $context) { } // Handle properties. + // Use the wrapper to set property values, since some properties need + // additional massaging by their setter callbacks. + // The wrapper will automatically modify $entity itself. + $wrapper = entity_metadata_wrapper($context['entity_type'], $entity); + // The default setting for 'revision' property (create new revisions) should + // be respected for nodes. This requires some special treatment. + if ($context['entity_type'] == 'node' && in_array('revision', variable_get('node_options_' . $bundle_name)) && !in_array('revision', $context['selected']['properties'])) { + $wrapper->revision->set(1); + } + if (!empty($context['selected']['properties'])) { - // Use the wrapper to set property values, since some properties need - // additional massaging by their setter callbacks. - // The wrapper will automatically modify $entity itself. - $wrapper = entity_metadata_wrapper($context['entity_type'], $entity); foreach ($context['selected']['properties'] as $key) { + if (!$wrapper->{$key}->access('update')) { + // No access. + continue; + } + if (in_array($key, $context['append']['properties'])) { - $old_values = $wrapper->$key->value(); - $wrapper->$key->set($context['properties'][$key]); + $old_values = $wrapper->{$key}->value(); + $wrapper->{$key}->set($context['properties'][$key]); $new_values = $wrapper->{$key}->value(); $all_values = array_merge($old_values, $new_values); - $wrapper->$key->set($all_values); + $wrapper->{$key}->set($all_values); } else { $value = $context['properties'][$key]; if (is_string($value)) { $value = token_replace($value, array($context['entity_type'] => $entity), array('sanitize' => FALSE)); } - $wrapper->$key->set($value); + $wrapper->{$key}->set($value); } } } @@ -108,7 +127,8 @@ function views_bulk_operations_modify_action($entity, $context) { * entity bundle, as provided by field_attach_form(). */ function views_bulk_operations_modify_action_form($context, &$form_state) { - // This action form uses admin-provided settings. If they were not set, pull the defaults now. + // This action form uses admin-provided settings. If they were not set, pull + // the defaults now. if (!isset($context['settings'])) { $context['settings'] = views_bulk_operations_modify_action_views_bulk_operations_form_options(); } @@ -121,7 +141,8 @@ function views_bulk_operations_modify_action_form($context, &$form_state) { // and filled with form data. // After submit, the pseudo-entities get passed to the actual action // (views_bulk_operations_modify_action()) which copies the data from the - // relevant pseudo-entity constructed here to the actual entity being modified. + // relevant pseudo-entity constructed here to the actual entity being + // modified. $form_state['entities'] = array(); $info = entity_get_info($entity_type); @@ -134,7 +155,7 @@ function views_bulk_operations_modify_action_form($context, &$form_state) { if (!empty($properties)) { $form['properties'] = array( '#type' => 'fieldset', - '#title' => 'Properties', + '#title' => t('Properties'), ); $form['properties']['show_value'] = array( '#suffix' => '
      ', @@ -146,7 +167,16 @@ function views_bulk_operations_modify_action_form($context, &$form_state) { '#title' => $property['label'], ); - $determined_type = ($property['type'] == 'boolean') ? 'checkbox' : 'textfield'; + // According to _views_bulk_operations_modify_action_get_properties + // we have fixed list of supported types. Most of these types are string + // and only some of them has options list. + if (isset($property['options list'])) { + $determined_type = ($property['type'] == 'list') ? 'checkboxes' : 'select'; + } + else { + $determined_type = ($property['type'] == 'boolean') ? 'checkbox' : 'textfield'; + } + $form['properties'][$key] = array( '#type' => $determined_type, '#title' => $property['label'], @@ -163,9 +193,9 @@ function views_bulk_operations_modify_action_form($context, &$form_state) { $form['properties'][$key]['#maxlength'] = 255; } - if (!empty($property['options list'])) { + if (!empty($property['options list']) && is_callable($property['options list'])) { $form['properties'][$key]['#type'] = 'select'; - $form['properties'][$key]['#options'] = $property['options list']($key, array()); + $form['properties'][$key]['#options'] = call_user_func_array($property['options list'], array($key, array())); if ($property['type'] == 'list') { $form['properties'][$key]['#type'] = 'checkboxes'; @@ -184,7 +214,7 @@ function views_bulk_operations_modify_action_form($context, &$form_state) { } } - // Going to need this for multilingual nodes + // Going to need this for multilingual nodes. global $language; foreach ($bundles as $bundle_name => $bundle) { $bundle_key = $info['entity keys']['bundle']; @@ -197,8 +227,8 @@ function views_bulk_operations_modify_action_form($context, &$form_state) { $entity = entity_create($context['entity_type'], $default_values); $form_state['entities'][$bundle_name] = $entity; - // Show the more detailed label only if the entity type has multiple bundles. - // Otherwise, it would just be confusing. + // Show the more detailed label only if the entity type has multiple + // bundles. Otherwise, it would just be confusing. if (count($info['bundles']) > 1) { $label = t('Fields for @bundle_key @label', array('@bundle_key' => $bundle_key, '@label' => $bundle['label'])); } @@ -298,7 +328,7 @@ function views_bulk_operations_modify_action_form($context, &$form_state) { $token_type = str_replace('_', '-', $entity_type); $form['tokens'] = array( '#type' => 'fieldset', - '#title' => 'Available tokens', + '#title' => t('Available tokens'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => 998, @@ -375,7 +405,7 @@ function views_bulk_operations_modify_action_validate($form, &$form_state) { $properties = _views_bulk_operations_modify_action_get_properties($form_state['entity_type']); foreach ($form_state['selected']['properties'] as $key) { $value = $form_state['values']['properties'][$key]; - if (!$wrapper->$key->validate($value)) { + if (!$wrapper->{$key}->validate($value)) { $label = $properties[$key]['label']; form_set_error('properties][' . $key, t('%label contains an invalid value.', array('%label' => $label))); } @@ -412,9 +442,9 @@ function views_bulk_operations_modify_action_submit($form, $form_state) { * Properties that can't be changed are entity keys, timestamps, and the ones * without a setter callback. * - * @param $entity_type + * @param string $entity_type * The entity type whose properties will be fetched. - * @param $display_values + * @param array $display_values * An optional, admin-provided list of properties and fields that should be * displayed for editing, used to filter the returned list of properties. */ @@ -430,8 +460,17 @@ function _views_bulk_operations_modify_action_get_properties($entity_type, $disp } } // List of supported types. - $supported_types = array('text', 'token', 'integer', 'decimal', 'date', 'duration', - 'boolean', 'uri', 'list'); + $supported_types = array( + 'text', + 'token', + 'integer', + 'decimal', + 'date', + 'duration', + 'boolean', + 'uri', + 'list', + ); $property_info = entity_get_property_info($entity_type); if (empty($property_info['properties'])) { // Stop here if no properties were found. @@ -479,9 +518,9 @@ function _views_bulk_operations_modify_action_get_properties($entity_type, $disp * (through the action settings) then only bundles that have at least one field * selected are returned. * - * @param $entity_type + * @param string $entity_type * The entity type whose bundles will be fetched. - * @param $context + * @param array $context * The VBO context variable. */ function _views_bulk_operations_modify_action_get_bundles($entity_type, $context) { @@ -589,8 +628,8 @@ function views_bulk_operations_modify_action_views_bulk_operations_form($options } foreach ($info['bundles'] as $bundle_name => $bundle) { $bundle_key = $info['entity keys']['bundle']; - // Show the more detailed label only if the entity type has multiple bundles. - // Otherwise, it would just be confusing. + // Show the more detailed label only if the entity type has multiple + // bundles. Otherwise, it would just be confusing. if (count($info['bundles']) > 1) { $label = t('Fields for @bundle_key @label', array('@bundle_key' => $bundle_key, '@label' => $bundle['label'])); } diff --git a/sites/all/modules/contrib/views/views_bulk_operations/actions/user_cancel.action.inc b/sites/all/modules/contrib/views/views_bulk_operations/actions/user_cancel.action.inc index ea8e8ee..3637e39 100644 --- a/sites/all/modules/contrib/views/views_bulk_operations/actions/user_cancel.action.inc +++ b/sites/all/modules/contrib/views/views_bulk_operations/actions/user_cancel.action.inc @@ -1,16 +1,19 @@ array( - 'type' => 'user', - 'label' => t('Cancel user account'), - 'configurable' => TRUE, - 'behavior' => array('deletes_property'), - )); + return array( + 'views_bulk_operations_user_cancel_action' => array( + 'type' => 'user', + 'label' => t('Cancel user account'), + 'configurable' => TRUE, + 'behavior' => array('deletes_property'), + 'triggers' => array('any'), + ), + ); } function views_bulk_operations_user_cancel_action_form($context) { @@ -74,7 +77,17 @@ function views_bulk_operations_user_cancel_action($account, $context) { if (!empty($context['user_cancel_notify'])) { _user_mail_notify('status_canceled', $account); } - user_delete($account->uid); + // In cases when nodes are to be reassigned to UID 0, the user_delete must + // not run until *after* the user_cancel has been invoked, otherwise the + // nodes are deleted before they can be reassigned. Adding the user delete + // to the batch queue ensures things happen in the correct sequence. + $batch = array( + 'operations' => array( + array('user_delete', array($account->uid)), + ), + 'file' => drupal_get_path('module', 'node') . '/node.admin.inc', + ); + batch_set($batch); watchdog('user', 'Deleted user: %name %email.', array('%name' => $account->name, '%email' => '<' . $account->mail . '>'), WATCHDOG_NOTICE); break; } diff --git a/sites/all/modules/contrib/views/views_bulk_operations/actions/user_roles.action.inc b/sites/all/modules/contrib/views/views_bulk_operations/actions/user_roles.action.inc index 394597c..616f13c 100644 --- a/sites/all/modules/contrib/views/views_bulk_operations/actions/user_roles.action.inc +++ b/sites/all/modules/contrib/views/views_bulk_operations/actions/user_roles.action.inc @@ -45,24 +45,19 @@ function views_bulk_operations_user_roles_action_submit($form, $form_state) { ); } -function views_bulk_operations_user_roles_action(&$user, $context) { - $roles = $user->roles; - $selected = (is_array($context['add_roles']) ? $context['add_roles'] : array()) + - (is_array($context['remove_roles']) ? $context['remove_roles'] : array()); - $result = db_query("SELECT rid, name FROM {role} WHERE rid IN (:selected)", array(':selected' => array_keys($selected))); - foreach ($result as $role) { - if (isset($context['add_roles'][$role->rid])) { - $add_roles[$role->rid] = $role->name; - } - if (isset($context['remove_roles'][$role->rid])) { - $remove_roles[$role->rid] = $role->name; - } +function views_bulk_operations_user_roles_action($user, $context) { + $wrapper = entity_metadata_wrapper('user', $user); + if (!$wrapper->roles->access("update")) { + // No access. + return; } - if (!empty($add_roles)) { - $roles += $add_roles; + $roles = $wrapper->roles->value(); + if (is_array($context['add_roles'])) { + $roles = array_merge($roles, $context['add_roles']); } - if (!empty($remove_roles)) { - $roles = array_diff($roles, $remove_roles); + if (is_array($context['remove_roles'])) { + $roles = array_diff($roles, $context['remove_roles']); } - user_save($user, array('roles' => $roles)); + $wrapper->roles->set($roles); + $wrapper->save(); } diff --git a/sites/all/modules/contrib/views/views_bulk_operations/actions_permissions.info b/sites/all/modules/contrib/views/views_bulk_operations/actions_permissions.info index e57077b..1f97bd5 100644 --- a/sites/all/modules/contrib/views/views_bulk_operations/actions_permissions.info +++ b/sites/all/modules/contrib/views/views_bulk_operations/actions_permissions.info @@ -3,9 +3,8 @@ description = Provides permission-based access control for actions. Used by View package = Administration core = 7.x -; Information added by Drupal.org packaging script on 2013-12-23 -version = "7.x-3.2" +; Information added by Drupal.org packaging script on 2018-05-08 +version = "7.x-3.5" core = "7.x" project = "views_bulk_operations" -datestamp = "1387798183" - +datestamp = "1525821486" diff --git a/sites/all/modules/contrib/views/views_bulk_operations/css/views_bulk_operations.css b/sites/all/modules/contrib/views/views_bulk_operations/css/views_bulk_operations.css index a93cf22..d26da62 100644 --- a/sites/all/modules/contrib/views/views_bulk_operations/css/views_bulk_operations.css +++ b/sites/all/modules/contrib/views/views_bulk_operations/css/views_bulk_operations.css @@ -1,4 +1,5 @@ -.vbo-select-all-markup, .vbo-table-select-all-markup { +.vbo-select-all-markup, +.vbo-table-select-all-markup { display: none; } @@ -15,9 +16,10 @@ .views-table-row-select-all td { text-align: center; } -.vbo-table-select-all-pages, .vbo-table-select-this-page { - margin: 0 !important; - padding: 2px 5px !important; +.vbo-views-form .vbo-table-select-all-pages, +.vbo-views-form .vbo-table-select-this-page { + margin: 0; + padding: 2px 5px; } /* Generic "select all" */ @@ -30,6 +32,6 @@ margin-bottom: 0; } .vbo-fieldset-select-all div { - padding: 0 !important; - margin: 0 !important; + padding: 0; + margin: 0; } diff --git a/sites/all/modules/contrib/views/views_bulk_operations/js/views_bulk_operations.js b/sites/all/modules/contrib/views/views_bulk_operations/js/views_bulk_operations.js index aeeecc6..62218be 100644 --- a/sites/all/modules/contrib/views/views_bulk_operations/js/views_bulk_operations.js +++ b/sites/all/modules/contrib/views/views_bulk_operations/js/views_bulk_operations.js @@ -1,9 +1,17 @@ (function ($) { + // Polyfill for jQuery less than 1.6. + if (typeof $.fn.prop != 'function') { + jQuery.fn.extend({ + prop: jQuery.fn.attr + }); + } + Drupal.behaviors.vbo = { attach: function(context) { $('.vbo-views-form', context).each(function() { Drupal.vbo.initTableBehaviors(this); Drupal.vbo.initGenericBehaviors(this); + Drupal.vbo.toggleButtonsState(this); }); } } @@ -30,9 +38,10 @@ $('.vbo-table-select-all', form).show(); // This is the "select all" checkbox in (each) table header. - $('.vbo-table-select-all', form).click(function() { - var table = $(this).closest('table')[0]; - $('input[id^="edit-views-bulk-operations"]:not(:disabled)', table).attr('checked', this.checked); + $('input.vbo-table-select-all', form).click(function() { + var table = $(this).closest('table:not(.sticky-header)')[0]; + $('.vbo-select:not(:disabled)', table).prop('checked', this.checked); + Drupal.vbo.toggleButtonsState(form); // Toggle the visibility of the "select all" row (if any). if (this.checked) { @@ -46,21 +55,19 @@ }); // Set up the ability to click anywhere on the row to select it. - $('.views-table tbody tr', form).click(function(event) { - if (event.target.tagName.toLowerCase() != 'input' && event.target.tagName.toLowerCase() != 'a') { - $('input[id^="edit-views-bulk-operations"]:not(:disabled)', this).each(function() { - var checked = this.checked; - // trigger() toggles the checkmark *after* the event is set, - // whereas manually clicking the checkbox toggles it *beforehand*. - // that's why we manually set the checkmark first, then trigger the - // event (so that listeners get notified), then re-set the checkmark - // which the trigger will have toggled. yuck! - this.checked = !checked; - $(this).trigger('click'); - this.checked = !checked; - }); - } - }); + if (Drupal.settings.vbo.row_clickable) { + $('.views-table tbody tr', form).click(function(event) { + var tagName = event.target.tagName.toLowerCase(); + if (tagName != 'input' && tagName != 'a' && tagName != 'label') { + $('.vbo-select:not(:disabled)', this).each(function() { + // Always return true for radios, you cannot de-select a radio by clicking on it, + // it should be the same when clicking on a row. + this.checked = $(this).is(':radio') ? true : !this.checked; + $(this).trigger('change'); + }); + } + }); + } } Drupal.vbo.tableSelectAllPages = function(form) { @@ -81,35 +88,44 @@ $('.vbo-select-all-markup', form).show(); $('.vbo-select-this-page', form).click(function() { - $('input[id^="edit-views-bulk-operations"]', form).attr('checked', this.checked); - $('.vbo-select-all-pages', form).attr('checked', false); + $('.vbo-select', form).prop('checked', this.checked); + Drupal.vbo.toggleButtonsState(form); + $('.vbo-select-all-pages', form).prop('checked', false); // Toggle the "select all" checkbox in grouped tables (if any). - $('.vbo-table-select-all', form).attr('checked', this.checked); + $('.vbo-table-select-all', form).prop('checked', this.checked); }); $('.vbo-select-all-pages', form).click(function() { - $('input[id^="edit-views-bulk-operations"]', form).attr('checked', this.checked); - $('.vbo-select-this-page', form).attr('checked', false); + $('.vbo-select', form).prop('checked', this.checked); + Drupal.vbo.toggleButtonsState(form); + $('.vbo-select-this-page', form).prop('checked', false); // Toggle the "select all" checkbox in grouped tables (if any). - $('.vbo-table-select-all', form).attr('checked', this.checked); + $('.vbo-table-select-all', form).prop('checked', this.checked); // Modify the value of the hidden form field. $('.select-all-rows', form).val(this.checked); }); - $('.vbo-select', form).click(function() { + // Toggle submit buttons' "disabled" states with the state of the operation + // selectbox. + $('select[name="operation"]', form).change(function () { + Drupal.vbo.toggleButtonsState(form); + }); + + // Handle a "change" event originating either from a row click or an actual checkbox click. + $('.vbo-select', form).change(function() { // If a checkbox was deselected, uncheck any "select all" checkboxes. if (!this.checked) { - $('.vbo-select-this-page', form).attr('checked', false); - $('.vbo-select-all-pages', form).attr('checked', false); + $('.vbo-select-this-page', form).prop('checked', false); + $('.vbo-select-all-pages', form).prop('checked', false); // Modify the value of the hidden form field. $('.select-all-rows', form).val('0') var table = $(this).closest('table')[0]; if (table) { // Uncheck the "select all" checkbox in the table header. - $('.vbo-table-select-all', table).attr('checked', false); + $('.vbo-table-select-all', table).prop('checked', false); // If there's a "select all" row, hide it. if ($('.vbo-table-select-this-page', table).length) { @@ -119,7 +135,26 @@ } } } + + Drupal.vbo.toggleButtonsState(form); }); } + Drupal.vbo.toggleButtonsState = function(form) { + // If no rows are checked, disable any form submit actions. + var selectbox = $('select[name="operation"]', form); + var checkedCheckboxes = $('.vbo-select:checked', form); + // The .vbo-prevent-toggle CSS class is added to buttons to prevent toggling + // between disabled and enabled. For example the case of an 'add' button. + var buttons = $('[id^="edit-select"] [type="submit"]:not(.vbo-prevent-toggle)', form); + + if (selectbox.length) { + var has_selection = checkedCheckboxes.length && selectbox.val() !== '0'; + buttons.prop('disabled', !has_selection); + } + else { + buttons.prop('disabled', !checkedCheckboxes.length); + } + }; + })(jQuery); diff --git a/sites/all/modules/contrib/views/views_bulk_operations/plugins/operation_types/action.class.php b/sites/all/modules/contrib/views/views_bulk_operations/plugins/operation_types/action.class.php index c74d90c..0be5785 100644 --- a/sites/all/modules/contrib/views/views_bulk_operations/plugins/operation_types/action.class.php +++ b/sites/all/modules/contrib/views/views_bulk_operations/plugins/operation_types/action.class.php @@ -20,7 +20,7 @@ class ViewsBulkOperationsAction extends ViewsBulkOperationsBaseOperation { */ public function getAccessMask() { // Assume edit by default. - if (!isset($this->operationInfo['behavior'])) { + if (empty($this->operationInfo['behavior'])) { $this->operationInfo['behavior'] = array('changes_property'); } @@ -128,7 +128,12 @@ class ViewsBulkOperationsAction extends ViewsBulkOperationsBaseOperation { actions_list(); $submit_callback = $this->operationInfo['callback'] . '_submit'; - $this->formOptions = $submit_callback($form, $form_state); + // If the return value from the callback is an options array, store it for + // later union onto the context. + $options = $submit_callback($form, $form_state); + if ($options && is_array($options)) { + $this->formOptions = $options; + } } /** diff --git a/sites/all/modules/contrib/views/views_bulk_operations/plugins/operation_types/rules_component.class.php b/sites/all/modules/contrib/views/views_bulk_operations/plugins/operation_types/rules_component.class.php index 624c850..c40da8b 100644 --- a/sites/all/modules/contrib/views/views_bulk_operations/plugins/operation_types/rules_component.class.php +++ b/sites/all/modules/contrib/views/views_bulk_operations/plugins/operation_types/rules_component.class.php @@ -124,6 +124,8 @@ class ViewsBulkOperationsRulesComponent extends ViewsBulkOperationsBaseOperation else { $element = rules_action('component_' . $this->operationInfo['parameters']['component_key']); } - $element->execute($data); + $wrapper_type = is_array($data) ? "list<{$this->entityType}>" : $this->entityType; + $wrapper = entity_metadata_wrapper($wrapper_type, $data); + $element->execute($wrapper); } } diff --git a/sites/all/modules/contrib/views/views_bulk_operations/views/views_bulk_operations.views.inc b/sites/all/modules/contrib/views/views_bulk_operations/views/views_bulk_operations.views.inc index 1c7078a..e6c685a 100644 --- a/sites/all/modules/contrib/views/views_bulk_operations/views/views_bulk_operations.views.inc +++ b/sites/all/modules/contrib/views/views_bulk_operations/views/views_bulk_operations.views.inc @@ -6,7 +6,8 @@ function views_bulk_operations_views_data_alter(&$data) { foreach (entity_get_info() as $entity_type => $info) { if (isset($info['base table']) && isset($data[$info['base table']]['table'])) { - $data[$info['base table']]['views_bulk_operations'] = array( + $data[$info['base table']]['views_bulk_operations']['moved to'] = array('views_entity_' . $entity_type, 'views_bulk_operations'); + $data['views_entity_' . $entity_type]['views_bulk_operations'] = array( 'title' => $data[$info['base table']]['table']['group'], 'group' => t('Bulk operations'), 'help' => t('Provide a checkbox to select the row for bulk operations.'), diff --git a/sites/all/modules/contrib/views/views_bulk_operations/views/views_bulk_operations_handler_field_operations.inc b/sites/all/modules/contrib/views/views_bulk_operations/views/views_bulk_operations_handler_field_operations.inc index 9bb983f..9b1f88e 100644 --- a/sites/all/modules/contrib/views/views_bulk_operations/views/views_bulk_operations_handler_field_operations.inc +++ b/sites/all/modules/contrib/views/views_bulk_operations/views/views_bulk_operations_handler_field_operations.inc @@ -6,7 +6,7 @@ * Implements the Views Form API. */ -class views_bulk_operations_handler_field_operations extends views_handler_field { +class views_bulk_operations_handler_field_operations extends views_handler_field_entity { var $revision = FALSE; function init(&$view, &$options) { @@ -46,6 +46,12 @@ class views_bulk_operations_handler_field_operations extends views_handler_field unset($operation_options['use_queue']); } } + + // Check whether this is a revision. + $table_data = views_fetch_data($this->table); + if (!empty($table_data['table']['revision'])) { + $this->revision = TRUE; + } } function option_definition() { @@ -55,6 +61,7 @@ class views_bulk_operations_handler_field_operations extends views_handler_field 'contains' => array( 'display_type' => array('default' => 0), 'enable_select_all_pages' => array('default' => TRUE), + 'row_clickable' => array('default' => TRUE), 'force_single' => array('default' => FALSE), 'entity_load_capacity' => array('default' => 10), 'skip_batching' => array('default' => 0), @@ -63,11 +70,26 @@ class views_bulk_operations_handler_field_operations extends views_handler_field $options['vbo_operations'] = array( 'default' => array(), 'unpack_translatable' => 'unpack_operations', + 'export' => 'export_vbo_operations', ); return $options; } + function export_vbo_operations($indent, $prefix, $storage, $option, $definition, $parents) { + // Anti-recursion, since we use the parent export helper. + unset($definition['export']); + + // Find and remove all unselected/disabled operations. + foreach ($storage['vbo_operations'] as $operation_id => $operation) { + if (empty($operation['selected'])) { + unset($storage['vbo_operations'][$operation_id]); + } + } + + return parent::export_option($indent, $prefix, $storage, $option, $definition, $parents); + } + function unpack_operations(&$translatable, $storage, $option, $definition, $parents, $keys) { $translatable[] = array( 'value' => t('- Choose an operation -'), @@ -107,6 +129,12 @@ class views_bulk_operations_handler_field_operations extends views_handler_field '#default_value' => $this->options['vbo_settings']['enable_select_all_pages'], '#description' => t('Check this box to enable the ability to select all items on all pages.'), ); + $form['vbo_settings']['row_clickable'] = array( + '#type' => 'checkbox', + '#title' => t('Make the whole row clickable'), + '#default_value' => $this->options['vbo_settings']['row_clickable'], + '#description' => t('Check this box to select an item when its row has been clicked. Requires JavaScript.'), + ); $form['vbo_settings']['force_single'] = array( '#type' => 'checkbox', '#title' => t('Force single'), @@ -164,6 +192,14 @@ class views_bulk_operations_handler_field_operations extends views_handler_field $dom_id . '-selected' => array(1), ), ); + $form['vbo_operations'][$operation_id]['skip_permission_check'] = array( + '#type' => 'checkbox', + '#title' => t('Skip permission step'), + '#default_value' => !empty($operation_options['skip_permission_check']), + '#dependency' => array( + $dom_id . '-selected' => array(1), + ), + ); $form['vbo_operations'][$operation_id] += $operation->adminOptionsForm($dom_id, $this); } @@ -241,19 +277,21 @@ class views_bulk_operations_handler_field_operations extends views_handler_field // At this point, the query has already been run, so we can access the results // in order to get the base key value (for example, nid for nodes). foreach ($this->view->result as $row_index => $row) { - $entity_id = $this->get_value($row); + $this->view->row_index = $row_index; + $id = $this->get_value($row, $this->real_field); if ($this->options['vbo_settings']['force_single']) { $form[$this->options['id']][$row_index] = array( '#type' => 'radio', '#parents' => array($this->options['id']), - '#return_value' => $entity_id, + '#return_value' => $id, + '#attributes' => array('class' => array('vbo-select')), ); } else { $form[$this->options['id']][$row_index] = array( '#type' => 'checkbox', - '#return_value' => $entity_id, + '#return_value' => $id, '#default_value' => FALSE, '#attributes' => array('class' => array('vbo-select')), ); @@ -271,9 +309,12 @@ class views_bulk_operations_handler_field_operations extends views_handler_field if (empty($options['selected'])) { continue; } - $operation = views_bulk_operations_get_operation($operation_id, $entity_type, $options); - if (!$operation || !$operation->access($user)) { + if (!$operation) { + continue; + } + $skip_permission_check = $operation->getAdminOption('skip_permission_check', FALSE); + if (!$operation->access($user) && !$skip_permission_check) { continue; } $selected[$operation_id] = $operation; @@ -296,29 +337,7 @@ class views_bulk_operations_handler_field_operations extends views_handler_field * the entity type that VBO is operating on. */ public function get_entity_type() { - $base_table = $this->view->base_table; - - // If the current field is under a relationship you can't be sure that the - // base table of the view is the base table of the current field. - // For example a field from a node author on a node view does have users as base table. - if (!empty($this->options['relationship']) && $this->options['relationship'] != 'none') { - $relationships = $this->view->display_handler->get_option('relationships'); - $options = $relationships[$this->options['relationship']]; - $data = views_fetch_data($options['table']); - $base_table = $data[$options['field']]['relationship']['base']; - } - // The base table is now known, use it to determine the entity type. - foreach (entity_get_info() as $entity_type => $info) { - if (isset($info['base table']) && $info['base table'] == $base_table) { - return $entity_type; - } - elseif (isset($info['revision table']) && $info['revision table'] == $base_table) { - $this->revision = TRUE; - return $entity_type; - } - } - // This should never happen. - _views_bulk_operations_report_error("Could not determine the entity type for VBO field on views base table %table", array('%table' => $base_table)); - return FALSE; + return $this->entity_type; } + } diff --git a/sites/all/modules/contrib/views/views_bulk_operations/views_bulk_operations.drush.inc b/sites/all/modules/contrib/views/views_bulk_operations/views_bulk_operations.drush.inc index 09c4fb6..e9ca192 100644 --- a/sites/all/modules/contrib/views/views_bulk_operations/views_bulk_operations.drush.inc +++ b/sites/all/modules/contrib/views/views_bulk_operations/views_bulk_operations.drush.inc @@ -154,7 +154,7 @@ function views_bulk_operations_drush_execute($vid = NULL, $operation_id = NULL) $current = 1; foreach ($view->result as $row_index => $result) { $rows[$row_index] = array( - 'entity_id' => $vbo->get_value($result), + 'entity_id' => $result->{$vbo->real_field}, 'views_row' => array(), 'position' => array( 'current' => $current++, diff --git a/sites/all/modules/contrib/views/views_bulk_operations/views_bulk_operations.info b/sites/all/modules/contrib/views/views_bulk_operations/views_bulk_operations.info index 2f03a14..058bef7 100644 --- a/sites/all/modules/contrib/views/views_bulk_operations/views_bulk_operations.info +++ b/sites/all/modules/contrib/views/views_bulk_operations/views_bulk_operations.info @@ -1,7 +1,7 @@ name = Views Bulk Operations description = Provides a way of selecting multiple rows and applying operations to them. dependencies[] = entity -dependencies[] = views +dependencies[] = views (>=3.12) package = Views core = 7.x php = 5.2.9 @@ -9,9 +9,8 @@ php = 5.2.9 files[] = plugins/operation_types/base.class.php files[] = views/views_bulk_operations_handler_field_operations.inc -; Information added by Drupal.org packaging script on 2013-12-23 -version = "7.x-3.2" +; Information added by Drupal.org packaging script on 2018-05-08 +version = "7.x-3.5" core = "7.x" project = "views_bulk_operations" -datestamp = "1387798183" - +datestamp = "1525821486" diff --git a/sites/all/modules/contrib/views/views_bulk_operations/views_bulk_operations.module b/sites/all/modules/contrib/views/views_bulk_operations/views_bulk_operations.module index b25b661..081e540 100644 --- a/sites/all/modules/contrib/views/views_bulk_operations/views_bulk_operations.module +++ b/sites/all/modules/contrib/views/views_bulk_operations/views_bulk_operations.module @@ -13,6 +13,7 @@ define('VBO_ACCESS_OP_DELETE', 0x08); /** * Implements hook_action_info(). + * * Registers custom VBO actions as Drupal actions. */ function views_bulk_operations_action_info() { @@ -20,9 +21,14 @@ function views_bulk_operations_action_info() { $files = views_bulk_operations_load_action_includes(); foreach ($files as $filename) { $action_info_fn = 'views_bulk_operations_'. str_replace('.', '_', basename($filename, '.inc')).'_info'; - $action_info = call_user_func($action_info_fn); - if (is_array($action_info)) { - $actions += $action_info; + if (is_callable($action_info_fn)) { + $action_info = call_user_func($action_info_fn); + if (is_array($action_info)) { + $actions += $action_info; + } + } + else { + watchdog('views bulk operations', 'views_bulk_operations_action_info() expects action filenames to have a matching valid callback function named: %function', array('%function' => $action_info_fn), WATCHDOG_WARNING); } } @@ -41,21 +47,21 @@ function views_bulk_operations_load_action_includes() { // The list of VBO actions is fairly static, so it's hardcoded for better // performance (hitting the filesystem with file_scan_directory(), and then // caching the result has its cost). - $path = drupal_get_path('module', 'views_bulk_operations') . '/actions/'; $files = array( - 'archive.action.inc', - 'argument_selector.action.inc', - 'book.action.inc', - 'delete.action.inc', - 'modify.action.inc', - 'script.action.inc', - 'user_roles.action.inc', - 'user_cancel.action.inc', + 'archive.action', + 'argument_selector.action', + 'book.action', + 'change_owner.action', + 'delete.action', + 'modify.action', + 'script.action', + 'user_roles.action', + 'user_cancel.action', ); if (!$loaded) { foreach ($files as $file) { - include_once $path . $file; + module_load_include('inc', 'views_bulk_operations', 'actions/' . $file); } $loaded = TRUE; } @@ -76,8 +82,8 @@ function views_bulk_operations_load_action_includes() { */ function views_bulk_operations_cron() { db_delete('queue') - ->condition('name', db_like('views_bulk_operations_active_queue_'), 'LIKE') - ->condition('created', REQUEST_TIME - 864000, '<') + ->condition('name', db_like('views_bulk_operations_active_queue_') . '%', 'LIKE') + ->condition('created', REQUEST_TIME - 86400, '<') ->execute(); } @@ -190,7 +196,7 @@ function views_bulk_operations_get_operation_info($operation_id = NULL) { $operations += $plugin['list callback'](); } - uasort($operations, create_function('$a, $b', 'return strcasecmp($a["label"], $b["label"]);')); + uasort($operations, '_views_bulk_operations_sort_operations_by_label'); } if (!empty($operation_id)) { @@ -201,6 +207,16 @@ function views_bulk_operations_get_operation_info($operation_id = NULL) { } } +/** + * Sort function used by uasort in views_bulk_operations_get_operation_info(). + * + * A closure would be better suited for this, but closure support was added in + * PHP 5.3 and D7 supports 5.2. + */ +function _views_bulk_operations_sort_operations_by_label($a, $b) { + return strcasecmp($a['label'], $b['label']); +} + /** * Returns an operation instance. * @@ -215,7 +231,12 @@ function views_bulk_operations_get_operation_info($operation_id = NULL) { function views_bulk_operations_get_operation($operation_id, $entity_type, $options) { $operations = &drupal_static(__FUNCTION__); - if (!isset($operations[$operation_id])) { + // Create a unique hash of the options. + $cid = md5(serialize($options)); + + // See if there's a cached copy of the operation, including entity type and + // options. + if (!isset($operations[$operation_id][$entity_type][$cid])) { // Intentionally not using views_bulk_operations_get_operation_info() here // since it's an expensive function that loads all the operations on the // system, despite the fact that we might only need a few. @@ -224,14 +245,14 @@ function views_bulk_operations_get_operation($operation_id, $entity_type, $optio $operation_info = $plugin['list callback']($operation_id); if ($operation_info) { - $operations[$operation_id] = new $plugin['handler']['class']($operation_id, $entity_type, $operation_info, $options); + $operations[$operation_id][$entity_type][$cid] = new $plugin['handler']['class']($operation_id, $entity_type, $operation_info, $options); } else { - $operations[$operation_id] = FALSE; + $operations[$operation_id][$entity_type][$cid] = FALSE; } } - return $operations[$operation_id]; + return $operations[$operation_id][$entity_type][$cid]; } /** @@ -358,7 +379,7 @@ function views_bulk_operations_form_alter(&$form, &$form_state, $form_id) { */ function views_bulk_operations_views_post_build(&$view) { $vbo = _views_bulk_operations_get_field($view); - if ($vbo && $vbo->get_selected_operations() < 1) { + if ($vbo && count($vbo->get_selected_operations()) < 1) { $vbo->options['exclude'] = TRUE; } } @@ -420,7 +441,7 @@ function theme_views_bulk_operations_select_all($variables) { if ($enable_select_all_pages) { $form['select_all']['or'] = array( '#type' => 'markup', - '#markup' => 'OR', + '#markup' => '' . t('OR') . '', ); $form['select_all']['all_pages'] = array( '#type' => 'checkbox', @@ -443,6 +464,13 @@ function theme_views_bulk_operations_select_all($variables) { */ function views_bulk_operations_form($form, &$form_state, $vbo) { $form['#attached']['js'][] = drupal_get_path('module', 'views_bulk_operations') . '/js/views_bulk_operations.js'; + $form['#attached']['js'][] = array( + 'data' => array('vbo' => array( + 'row_clickable' => $vbo->get_vbo_option('row_clickable'), + )), + 'type' => 'setting', + ); + $form['#attached']['css'][] = drupal_get_path('module', 'views_bulk_operations') . '/css/views_bulk_operations.css'; // Wrap the form in a div with specific classes for JS targeting and theming. $class = 'vbo-views-form'; @@ -511,7 +539,7 @@ function views_bulk_operations_form($form, &$form_state, $vbo) { $enable_select_all_pages = FALSE; // If the view is paginated, and "select all items on all pages" is // enabled, tell that to the theme function. - if (count($vbo->view->result) != $vbo->view->total_rows && $vbo->get_vbo_option('enable_select_all_pages')) { + if (isset($vbo->view->total_rows) && count($vbo->view->result) != $vbo->view->total_rows && $vbo->get_vbo_option('enable_select_all_pages')) { $enable_select_all_pages = TRUE; } $form['select_all_markup'] = array( @@ -595,14 +623,23 @@ function views_bulk_operations_confirm_form($form, &$form_state, $view, $output) $operation = $form_state['operation']; $rows = $form_state['selection']; $query = drupal_get_query_parameters($_GET, array('q')); + $title = t('Are you sure you want to perform %operation on the selected items?', array('%operation' => $operation->label())); $form = confirm_form($form, - t('Are you sure you want to perform %operation on the selected items?', array('%operation' => $operation->label())), + $title, array('path' => $view->get_url(), 'query' => $query), theme('views_bulk_operations_confirmation', array('rows' => $rows, 'vbo' => $vbo, 'operation' => $operation, 'select_all_pages' => $form_state['select_all_pages'])) ); // Add VBO's submit handler to the Confirm button added by config_form(). $form['actions']['submit']['#submit'] = array('views_bulk_operations_form_submit'); + // We can't set the View title here as $view is just a copy of the original, + // and our settings changes won't "stick" for the first page load of the + // confirmation form. We also can't just call drupal_set_title() directly + // because our title will be clobbered by the actual View title later. So + // let's tuck the title away in the form for use later. + // @see views_bulk_operations_preprocess_views_view() + $form['#vbo_confirm_form_title'] = $title; + return $form; } @@ -618,19 +655,42 @@ function theme_views_bulk_operations_confirmation($variables) { // Load the entities from the current page, and show their titles. $entities = _views_bulk_operations_entity_load($entity_type, array_values($rows), $vbo->revision); foreach ($entities as $entity) { - $items[] = check_plain(_views_bulk_operations_entity_label($entity_type, $entity)); + $items[] = check_plain(entity_label($entity_type, $entity)); } // All rows on all pages have been selected, so show a count of additional items. if ($select_all_pages) { $more_count = $vbo->view->total_rows - count($vbo->view->result); - $items[] = t('...and !count more.', array('!count' => $more_count)); + $items[] = t('...and %count more.', array('%count' => $more_count)); } $count = format_plural(count($entities), 'item', '@count items'); - $output = theme('item_list', array('items' => $items, 'title' => t('You selected the following !count:', array('!count' => $count)))); + $output = theme('item_list', array('items' => $items, 'title' => t('You selected the following %count:', array('%count' => $count)))); return $output; } +/** + * Implements hook_preprocess_page(). + * + * Hide action links on the configure and confirm pages. + */ +function views_bulk_operations_preprocess_page(&$variables) { + if (isset($_POST['select_all'], $_POST['operation'])) { + $variables['action_links'] = array(); + } +} + +/** + * Implements hook_preprocess_views_view(). + */ +function views_bulk_operations_preprocess_views_view($variables) { + // If we've stored a title for the confirmation form, retrieve it here and + // retitle the View. + // @see views_bulk_operations_confirm_form() + if (array_key_exists('rows', $variables) && is_array($variables['rows']) && array_key_exists('#vbo_confirm_form_title', $variables['rows'])) { + $variables['view']->set_title($variables['rows']['#vbo_confirm_form_title']); + } +} + /** * Goes through the submitted values, and returns * an array of selected rows, in the form of @@ -798,7 +858,7 @@ function views_bulk_operations_execute($vbo, $operation, $selection, $select_all // All items on all pages should be selected, add a batch job to gather // and enqueue them. - if ($select_all_pages && $vbo->view->query->pager->has_more_records()) { + if ($select_all_pages && ($vbo->view->query->pager->has_more_records() || $vbo->view->query->pager->get_current_page() > 0)) { $total_rows = $vbo->view->total_rows; $batch['operations'][] = array( @@ -864,14 +924,20 @@ function views_bulk_operations_adjust_selection($queue_name, $operation, $option } $vbo = _views_bulk_operations_get_field($view); + + // Call views_handler_field_entity::pre_render() to get the entities. + $vbo->pre_render($view->result); + $rows = array(); foreach ($view->result as $row_index => $result) { + // Set the row index. + $view->row_index = $row_index; $rows[$row_index] = array( - 'entity_id' => $vbo->get_value($result), + 'entity_id' => $vbo->get_value($result, $vbo->real_field), 'views_row' => array(), 'position' => array( 'current' => ++$context['sandbox']['progress'], - 'total' => $view->total_rows, + 'total' => $context['sandbox']['max'], ), ); // Some operations require full selected rows. @@ -1037,12 +1103,13 @@ function views_bulk_operations_queue_item_process($queue_item_data, &$log = NULL } // If the current entity can't be accessed, skip it and log a notice. - if (!_views_bulk_operations_entity_access($operation, $entity_type, $entity, $account)) { + $skip_permission_check = $operation->getAdminOption('skip_permission_check'); + if (!$skip_permission_check && !_views_bulk_operations_entity_access($operation, $entity_type, $entity, $account)) { $message = 'Skipped %operation on @type %title due to insufficient permissions.'; $arguments = array( '%operation' => $operation->label(), '@type' => $entity_type, - '%title' => _views_bulk_operations_entity_label($entity_type, $entity), + '%title' => entity_label($entity_type, $entity), ); if ($log) { @@ -1089,12 +1156,22 @@ function views_bulk_operations_direct_adjust(&$selection, $vbo) { if ($field_name != $vbo->options['id']) { unset($view->field[$field_name]); } + else { + // Get hold of the new VBO field. + $new_vbo = $view->field[$field_name]; + } } $view->execute($vbo->view->current_display); + + // Call views_handler_field_entity::pre_render() to get the entities. + $new_vbo->pre_render($view->result); + $results = array(); foreach ($view->result as $row_index => $result) { - $results[$row_index] = $vbo->get_value($result); + // Set the row index. + $view->row_index = $row_index; + $results[$row_index] = $new_vbo->get_value($result, $new_vbo->real_field); } $selection = $results; } @@ -1122,13 +1199,14 @@ function views_bulk_operations_direct_process($operation, $rows, $options) { } $entities = _views_bulk_operations_entity_load($entity_type, $entity_ids, $options['revision']); + $skip_permission_check = $operation->getAdminOption('skip_permission_check'); // Filter out entities that can't be accessed. foreach ($entities as $id => $entity) { - if (!_views_bulk_operations_entity_access($operation, $entity_type, $entity)) { + if (!$skip_permission_check && !_views_bulk_operations_entity_access($operation, $entity_type, $entity, $user)) { $context['results']['log'][] = t('Skipped %operation on @type %title due to insufficient permissions.', array( '%operation' => $operation->label(), '@type' => $entity_type, - '%title' => _views_bulk_operations_entity_label($entity_type, $entity), + '%title' => entity_label($entity_type, $entity), )); unset($entities[$id]); } @@ -1236,29 +1314,6 @@ function _views_bulk_operations_entity_load($entity_type, $ids, $revision = FALS return $entities; } -/** - * Label function for entities. - * Core entities don't declare the "label" key, so entity_label() fails, - * and a fallback is needed. This function provides that fallback. - */ -function _views_bulk_operations_entity_label($entity_type, $entity) { - $label = entity_label($entity_type, $entity); - if (!$label) { - $entity_info = entity_get_info($entity_type); - $id_key = $entity_info['entity keys']['id']; - // Many entity types (e.g. "user") have a name which fits the label perfectly. - if (isset($entity->name)) { - $label = $entity->name; - } - elseif (isset($entity->{$id_key})) { - // Fallback to the id key. - $label = $entity->{$id_key}; - } - } - - return $label; -} - /** * Helper function to report an error. */ diff --git a/sites/all/modules/contrib/views/views_bulk_operations/views_bulk_operations.rules.inc b/sites/all/modules/contrib/views/views_bulk_operations/views_bulk_operations.rules.inc index b3a6418..78fae20 100644 --- a/sites/all/modules/contrib/views/views_bulk_operations/views_bulk_operations.rules.inc +++ b/sites/all/modules/contrib/views/views_bulk_operations/views_bulk_operations.rules.inc @@ -114,15 +114,25 @@ function views_bulk_operations_rules_action_info() { function views_bulk_operations_views_list() { $selectable_displays = array(); foreach (views_get_enabled_views() as $name => $base_view) { + $view = $base_view->clone_view(); foreach ($base_view->display as $display_name => $display) { - $view = $base_view->clone_view(); - $view->build($display_name); - $vbo = _views_bulk_operations_get_field($view); - if ($vbo) { - $selectable_displays[$view->name . '|' . $display_name] = check_plain($view->human_name) . ' | ' . check_plain($display->display_title); + if (!$view->set_display($display_name)) { + continue; + } + + // Initialize the style plugin and only continue to initialize handlers + // if the style uses fields. + if (!$view->init_style() || !$view->style_plugin->uses_fields()) { + continue; + } + + $view->init_handlers($display_name); + if (_views_bulk_operations_get_field($view)) { + $selectable_displays[$view->name . '|' . $display_name] = check_plain($view->human_name . ' | ' . $display->display_title); } } } + return $selectable_displays; } @@ -163,7 +173,11 @@ function views_bulk_operations_action_load_list($view, $args) { $entity_type = $vbo->get_entity_type(); $entities = entity_metadata_wrapper("list<$entity_type>", array()); foreach ($vbo->view->result as $row_index => $result) { - $entities[] = entity_metadata_wrapper($entity_type, $vbo->get_value($result)); + // Grab the entire entity if it's already loaded or fall back to the + // entity identifier. + $entity = $vbo->get_value($result); + $data = $entity ? $entity : $result->{$vbo->real_field}; + $entities[] = entity_metadata_wrapper($entity_type, $data); } return array('entity_list' => $entities);
      > + class="" scope="col">
      > + class="">