security update for views
This commit is contained in:
parent
57376251fa
commit
85772b4ca7
@ -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
|
||||
|
@ -3,7 +3,7 @@
|
||||
* in the Bartik theme.
|
||||
*/
|
||||
|
||||
/* @group Lists */
|
||||
/* @group Lists */
|
||||
|
||||
.views-display-top .secondary .action-list {
|
||||
padding-right: 0;
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
|
@ -10,7 +10,7 @@
|
||||
}
|
||||
|
||||
.ctools-dropbutton .ctools-link {
|
||||
border-right: 1px solid #ffffff;
|
||||
border-right: 1px solid #fff;
|
||||
}
|
||||
|
||||
.ctools-dropbutton li {
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -3,11 +3,11 @@
|
||||
* in the Garland theme.
|
||||
*/
|
||||
|
||||
/* @group Lists */
|
||||
/* @group Lists */
|
||||
|
||||
.views-displays .secondary .action-list {
|
||||
left: auto;
|
||||
right: 1px;
|
||||
}
|
||||
|
||||
/* @end */
|
||||
/* @end */
|
||||
|
@ -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 */
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
.views-exposed-form .views-exposed-widget {
|
||||
float: right; /* RTL */
|
||||
padding: .5em 1em 0 0; /* RTL */
|
||||
|
@ -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();
|
||||
@ -70,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".',
|
||||
@ -143,10 +147,10 @@ function views_revert_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);
|
||||
$is_overridden = array_key_exists($viewname, $overridden);
|
||||
|
||||
// Check if the provided view name is in the system
|
||||
if ($viewname && !key_exists($viewname, $views)) {
|
||||
// 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.
|
||||
@ -158,7 +162,7 @@ function views_revert_views() {
|
||||
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.",
|
||||
@ -168,19 +172,20 @@ function views_revert_views() {
|
||||
}
|
||||
}
|
||||
|
||||
// The user neither selected the "--all" option, nor provided a list of views to revert.
|
||||
// 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++;
|
||||
@ -189,7 +194,7 @@ function views_revert_views() {
|
||||
|
||||
}
|
||||
|
||||
// final results output
|
||||
// Final results output.
|
||||
if ($i == 0) {
|
||||
drush_log(dt('No views were reverted.'), 'ok');
|
||||
}
|
||||
@ -199,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;
|
||||
@ -219,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();
|
||||
@ -269,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();
|
||||
@ -281,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;
|
||||
@ -304,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'),
|
||||
@ -325,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;
|
||||
}
|
||||
@ -343,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;
|
||||
@ -379,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";
|
||||
@ -412,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;
|
||||
@ -440,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -448,7 +458,7 @@ function drush_views_analyze() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables views
|
||||
* Enables views.
|
||||
*/
|
||||
function drush_views_enable() {
|
||||
$viewnames = _convert_csv_to_array(func_get_args());
|
||||
@ -460,7 +470,7 @@ function drush_views_enable() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables views
|
||||
* Disables views.
|
||||
*/
|
||||
function drush_views_disable() {
|
||||
$viewnames = _convert_csv_to_array(func_get_args());
|
||||
@ -472,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)) {
|
||||
@ -492,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();
|
||||
@ -504,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';
|
||||
|
@ -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' => '<div class="form-item description">',
|
||||
'#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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains views_handler_area_messages.
|
||||
* Definition of views_handler_area_messages.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -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,7 +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();
|
||||
// @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);
|
||||
@ -81,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};
|
||||
@ -92,4 +106,5 @@ class views_handler_area_result extends views_handler_area {
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 = '<p>' . 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.' . '</p>');
|
||||
$output = '<p>'
|
||||
. 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.")
|
||||
. '</p>';
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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,9 +50,9 @@ class views_handler_area_view extends views_handler_area {
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the area
|
||||
* Render the area.
|
||||
*/
|
||||
function render($empty = FALSE) {
|
||||
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);
|
||||
|
@ -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' => '<div id="edit-options-validate-options-' . $id . '-wrapper">',
|
||||
'#suffix' => '</div>',
|
||||
'#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;
|
||||
}
|
||||
@ -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' => '</div>',
|
||||
'#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;
|
||||
@ -1089,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'];
|
||||
@ -1113,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'];
|
||||
@ -1137,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';
|
||||
@ -1162,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];
|
||||
}
|
||||
@ -1206,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'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1218,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' => '<div class="form-item description">' . 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.') . '</div>',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the handler is considered 'broken'
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function broken() { return TRUE; }
|
||||
public function broken() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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'));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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'));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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,7 +42,7 @@ 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'))) {
|
||||
return parent::default_actions($which);
|
||||
@ -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) {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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'));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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']);
|
||||
}
|
||||
|
||||
|
@ -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,13 +384,14 @@ 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) {
|
||||
$alias = isset($field) ? $this->aliases[$field] : $this->field_alias;
|
||||
public function get_value($values, $field = NULL) {
|
||||
// $alias = isset($field) ? $this->aliases[$field] : $this->field_alias;
|
||||
$alias = isset($field) && isset($this->aliases[$field]) ? $this->aliases[$field] : $this->field_alias;
|
||||
if (isset($values->{$alias})) {
|
||||
return $values->{$alias};
|
||||
}
|
||||
@ -383,13 +402,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 +469,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 +502,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 +611,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 +733,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 +752,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 +826,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 +850,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 +1028,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 +1061,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 +1126,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 +1134,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 +1156,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 +1171,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 +1202,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 +1223,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 +1234,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 +1245,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 +1276,9 @@ If you would like to have the characters \'[\' and \']\' please use the html ent
|
||||
|
||||
// strip_tags() removes <front>, so check whether its different to front.
|
||||
if ($path != '<front>') {
|
||||
// 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 +1299,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 +1353,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 +1409,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 +1424,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 +1483,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 +1519,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 +1582,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 +1597,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' => '<div class="form-item description">' . 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.') . '</div>',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the handler is considered 'broken'
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function broken() { return TRUE; }
|
||||
public function broken() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1576,7 +1643,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 +1655,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 +1670,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 +1688,7 @@ class views_handler_field_file_size extends views_handler_field {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1619,10 +1697,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');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,11 @@
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_contextual_links extends views_handler_field_links {
|
||||
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'])) {
|
||||
@ -22,7 +26,10 @@ class views_handler_field_contextual_links extends views_handler_field_links {
|
||||
}
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@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.');
|
||||
@ -32,7 +39,7 @@ class views_handler_field_contextual_links extends views_handler_field_links {
|
||||
/**
|
||||
* Render the contextual fields.
|
||||
*/
|
||||
function render($values) {
|
||||
public function render($values) {
|
||||
$links = $this->get_links();
|
||||
if (!empty($links)) {
|
||||
$build = array(
|
||||
@ -52,4 +59,5 @@ class views_handler_field_contextual_links extends views_handler_field_links {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,14 +11,21 @@
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_counter extends views_handler_field {
|
||||
function option_definition() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['counter_start'] = array('default' => 1);
|
||||
$options['reverse'] = array('default' => FALSE);
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
$form['counter_start'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Starting value'),
|
||||
@ -37,24 +44,31 @@ class views_handler_field_counter extends views_handler_field {
|
||||
parent::options_form($form, $form_state);
|
||||
}
|
||||
|
||||
function query() {
|
||||
// do nothing -- to override the parent query.
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
// Do nothing -- to override the parent query.
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render($values) {
|
||||
$reverse = empty($this->options['reverse']) ? 1 : -1;
|
||||
|
||||
// Note: 1 is subtracted from the counter start value below because the
|
||||
// Note: 1 is subtracted from the counter start value below because the
|
||||
// counter value is incremented by 1 at the end of this function.
|
||||
$counter_start = is_numeric($this->options['counter_start']) ? $this->options['counter_start'] : 0;
|
||||
$count = ($reverse == -1) ? count($this->view->result) + $counter_start : $counter_start -1;
|
||||
$count = ($reverse == -1) ? count($this->view->result) + $counter_start : $counter_start - 1;
|
||||
$pager = $this->view->query->pager;
|
||||
|
||||
// Get the base count of the pager.
|
||||
if ($pager->use_pager()) {
|
||||
if ($reverse == -1) {
|
||||
$count = ($pager->total_items + $counter_start - ($pager->get_current_page() * $pager->get_items_per_page()) + $pager->get_offset());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$count += (($pager->get_items_per_page() * $pager->get_current_page() + $pager->get_offset())) * $reverse;
|
||||
}
|
||||
}
|
||||
@ -63,4 +77,5 @@ class views_handler_field_counter extends views_handler_field {
|
||||
|
||||
return $count;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,11 @@
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_ctools_dropdown extends views_handler_field_links {
|
||||
function option_definition() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['views_admin_css'] = array('default' => TRUE, 'bool' => TRUE);
|
||||
@ -19,7 +23,10 @@ class views_handler_field_ctools_dropdown extends views_handler_field_links {
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$form['fields']['#description'] = t('Fields to be included as ctools dropdown button.');
|
||||
$form['destination']['#description'] = t('Include a "destination" parameter in the link to return the user to the original view upon completing a link action.');
|
||||
@ -35,7 +42,7 @@ class views_handler_field_ctools_dropdown extends views_handler_field_links {
|
||||
/**
|
||||
* Render the dropdown button.
|
||||
*/
|
||||
function render($values) {
|
||||
public function render($values) {
|
||||
static $added_admin_css;
|
||||
$links = $this->get_links();
|
||||
|
||||
@ -46,10 +53,20 @@ class views_handler_field_ctools_dropdown extends views_handler_field_links {
|
||||
$added_admin_css = TRUE;
|
||||
}
|
||||
|
||||
return theme('links__ctools_dropbutton', array('links' => $links, 'attributes' => array('class' => array('links', 'inline'))));
|
||||
$vars = array(
|
||||
'links' => $links,
|
||||
'attributes' => array(
|
||||
'class' => array(
|
||||
'links',
|
||||
'inline',
|
||||
),
|
||||
),
|
||||
);
|
||||
return theme('links__ctools_dropbutton', $vars);
|
||||
}
|
||||
else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,11 +11,18 @@
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_custom extends views_handler_field {
|
||||
function query() {
|
||||
// do nothing -- to override the parent query.
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
// Do nothing -- to override the parent query.
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
// Override the alter text option to always alter the text.
|
||||
@ -24,10 +31,13 @@ class views_handler_field_custom 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);
|
||||
|
||||
// Remove the checkbox
|
||||
// Remove the checkbox.
|
||||
unset($form['alter']['alter_text']);
|
||||
unset($form['alter']['text']['#dependency']);
|
||||
unset($form['alter']['text']['#process']);
|
||||
@ -36,10 +46,14 @@ class views_handler_field_custom extends views_handler_field {
|
||||
$form['#pre_render'][] = 'views_handler_field_custom_pre_render_move_text';
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render($values) {
|
||||
// Return the text, so the code never thinks the value is empty.
|
||||
return $this->options['alter']['text'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -11,7 +11,11 @@
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_date extends views_handler_field {
|
||||
function option_definition() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['date_format'] = array('default' => 'small');
|
||||
@ -23,8 +27,10 @@ class views_handler_field_date extends views_handler_field {
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
$date_formats = array();
|
||||
$date_types = system_get_date_types();
|
||||
foreach ($date_types as $key => $value) {
|
||||
@ -52,66 +58,106 @@ class views_handler_field_date extends views_handler_field {
|
||||
'#title' => t('Custom date format'),
|
||||
'#description' => t('If "Custom", see the <a href="@url" target="_blank">PHP manual</a> for date formats. Otherwise, enter the number of different time units to display, which defaults to 2.', array('@url' => 'http://php.net/manual/function.date.php')),
|
||||
'#default_value' => isset($this->options['custom_date_format']) ? $this->options['custom_date_format'] : '',
|
||||
'#dependency' => array('edit-options-date-format' => array('custom', 'raw time ago', 'time ago', 'today time ago', 'raw time hence', 'time hence', 'raw time span', 'time span', 'raw time span', 'inverse time span', 'time span')),
|
||||
'#dependency' => array(
|
||||
'edit-options-date-format' => $this->supported_date_types(),
|
||||
),
|
||||
);
|
||||
$form['second_date_format'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Second date format'),
|
||||
'#options' => $date_formats + array(
|
||||
'custom' => t('Custom'),
|
||||
),
|
||||
'#description' => t('The date format which will be used for rendering dates other than today.'),
|
||||
'#default_value' => isset($this->options['second_date_format']) ? $this->options['second_date_format'] : 'small',
|
||||
'#dependency' => array('edit-options-date-format' => array('today time ago')),
|
||||
);
|
||||
$form['second_date_format_custom'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Custom date format of second date'),
|
||||
'#description' => t('If "Custom" is selected in "Second date format", see the <a href="@url" target="_blank">PHP manual</a> for date formats. Otherwise, enter the number of different time units to display, which defaults to 2.', array('@url' => 'http://php.net/manual/function.date.php')),
|
||||
'#default_value' => isset($this->options['second_date_format_custom']) ? $this->options['second_date_format_custom'] : '',
|
||||
// We have to use states instead of ctools dependency because dependency
|
||||
// doesn't handle multiple conditions.
|
||||
'#states' => array(
|
||||
'visible' => array(
|
||||
'#edit-options-date-format' => array('value' => 'today time ago'),
|
||||
'#edit-options-second-date-format' => array('value' => 'custom'),
|
||||
),
|
||||
),
|
||||
// We have to use ctools dependency too because states doesn't add the
|
||||
// correct left margin to the element's wrapper.
|
||||
'#dependency' => array(
|
||||
// This condition is handled by form API's states.
|
||||
// 'edit-options-date-format' => array('today time ago'),
|
||||
'edit-options-second-date-format' => array('custom'),
|
||||
),
|
||||
);
|
||||
'#type' => 'select',
|
||||
'#title' => t('Second date format'),
|
||||
'#options' => $date_formats + array(
|
||||
'custom' => t('Custom'),
|
||||
),
|
||||
'#description' => t('The date format which will be used for rendering dates other than today.'),
|
||||
'#default_value' => isset($this->options['second_date_format']) ? $this->options['second_date_format'] : 'small',
|
||||
'#dependency' => array(
|
||||
'edit-options-date-format' => array('today time ago'),
|
||||
),
|
||||
);
|
||||
$form['second_date_format_custom'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Custom date format of second date'),
|
||||
'#description' => t('If "Custom" is selected in "Second date format", see the <a href="@url" target="_blank">PHP manual</a> for date formats. Otherwise, enter the number of different time units to display, which defaults to 2.', array('@url' => 'http://php.net/manual/function.date.php')),
|
||||
'#default_value' => isset($this->options['second_date_format_custom']) ? $this->options['second_date_format_custom'] : '',
|
||||
// We have to use states instead of ctools dependency because dependency
|
||||
// doesn't handle multiple conditions.
|
||||
'#states' => array(
|
||||
'visible' => array(
|
||||
'#edit-options-date-format' => array('value' => 'today time ago'),
|
||||
'#edit-options-second-date-format' => array('value' => 'custom'),
|
||||
),
|
||||
),
|
||||
// We have to use ctools dependency too because states doesn't add the
|
||||
// correct left margin to the element's wrapper.
|
||||
'#dependency' => array(
|
||||
// This condition is handled by form API's states.
|
||||
// 'edit-options-date-format' => array('today time ago'),
|
||||
'edit-options-second-date-format' => array('custom'),
|
||||
),
|
||||
);
|
||||
$form['timezone'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Timezone'),
|
||||
'#description' => t('Timezone to be used for date output.'),
|
||||
'#options' => array('' => t('- Default site/user timezone -')) + system_time_zones(FALSE),
|
||||
'#options' => array(
|
||||
'' => t('- Default site/user timezone -'),
|
||||
) + system_time_zones(FALSE),
|
||||
'#default_value' => $this->options['timezone'],
|
||||
'#dependency' => array('edit-options-date-format' => array_merge(array('custom'), array_keys($date_formats))),
|
||||
'#dependency' => array(
|
||||
'edit-options-date-format' => array_merge(array('custom'), array_keys($date_formats)),
|
||||
),
|
||||
);
|
||||
|
||||
parent::options_form($form, $form_state);
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
/**
|
||||
* Provide a list of all of the supported standard date types.
|
||||
*
|
||||
* @return array
|
||||
* The list of supported formats.
|
||||
*/
|
||||
private function supported_date_types() {
|
||||
return array(
|
||||
'custom',
|
||||
'raw time ago',
|
||||
'time ago',
|
||||
'today time ago',
|
||||
'raw time hence',
|
||||
'time hence',
|
||||
'raw time span',
|
||||
'time span',
|
||||
'raw time span',
|
||||
'inverse time span',
|
||||
'time span',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render($values) {
|
||||
$value = $this->get_value($values);
|
||||
$format = $this->options['date_format'];
|
||||
if (in_array($format, array('custom', 'raw time ago', 'time ago', 'today time ago', 'raw time hence', 'time hence', 'raw time span', 'time span', 'raw time span', 'inverse time span', 'time span'))) {
|
||||
if (in_array($format, $this->supported_date_types())) {
|
||||
$custom_format = $this->options['custom_date_format'];
|
||||
}
|
||||
|
||||
if ($value) {
|
||||
$timezone = !empty($this->options['timezone']) ? $this->options['timezone'] : NULL;
|
||||
$time_diff = REQUEST_TIME - $value; // will be positive for a datetime in the past (ago), and negative for a datetime in the future (hence)
|
||||
// Will be positive for a datetime in the past (ago), and negative for a
|
||||
// datetime in the future (hence).
|
||||
$time_diff = REQUEST_TIME - $value;
|
||||
switch ($format) {
|
||||
case 'raw time ago':
|
||||
return format_interval($time_diff, is_numeric($custom_format) ? $custom_format : 2);
|
||||
|
||||
case 'time ago':
|
||||
return t('%time ago', array('%time' => format_interval($time_diff, is_numeric($custom_format) ? $custom_format : 2)));
|
||||
$t_args = array(
|
||||
'%time' => format_interval($time_diff, is_numeric($custom_format) ? $custom_format : 2),
|
||||
);
|
||||
return t('%time ago', $t_args);
|
||||
|
||||
case 'today time ago':
|
||||
$second_format = $this->options['second_date_format'];
|
||||
$second_custom_format = $this->options['second_date_format_custom'];
|
||||
@ -127,24 +173,32 @@ class views_handler_field_date extends views_handler_field {
|
||||
else {
|
||||
return format_date($value, $this->options['second_date_format'], '', $timezone);
|
||||
}
|
||||
|
||||
case 'raw time hence':
|
||||
return format_interval(-$time_diff, is_numeric($custom_format) ? $custom_format : 2);
|
||||
|
||||
case 'time hence':
|
||||
return t('%time hence', array('%time' => format_interval(-$time_diff, is_numeric($custom_format) ? $custom_format : 2)));
|
||||
|
||||
case 'raw time span':
|
||||
return ($time_diff < 0 ? '-' : '') . format_interval(abs($time_diff), is_numeric($custom_format) ? $custom_format : 2);
|
||||
|
||||
case 'inverse time span':
|
||||
return ($time_diff > 0 ? '-' : '') . format_interval(abs($time_diff), is_numeric($custom_format) ? $custom_format : 2);
|
||||
|
||||
case 'time span':
|
||||
return t(($time_diff < 0 ? '%time hence' : '%time ago'), array('%time' => format_interval(abs($time_diff), is_numeric($custom_format) ? $custom_format : 2)));
|
||||
|
||||
case 'custom':
|
||||
if ($custom_format == 'r') {
|
||||
return format_date($value, $format, $custom_format, $timezone, 'en');
|
||||
}
|
||||
return format_date($value, $format, $custom_format, $timezone);
|
||||
|
||||
default:
|
||||
return format_date($value, $format, '', $timezone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Fields based upon this handler work with all query-backends if the tables
|
||||
* used by the query backend have an 'entity type' specified. In order to
|
||||
* make fields based upon this handler automatically available to all compatible
|
||||
* query backends, the views field can be defined in the table
|
||||
* query backends, the views field can be defined in the table.
|
||||
* @code views_entity_{ENTITY_TYPE} @endcode.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
@ -47,7 +47,7 @@ class views_handler_field_entity extends views_handler_field {
|
||||
/**
|
||||
* Overriden to add the field for the entity id.
|
||||
*/
|
||||
function query() {
|
||||
public function query() {
|
||||
$this->table_alias = $base_table = $this->view->base_table;
|
||||
$this->base_field = $this->view->base_field;
|
||||
|
||||
@ -75,16 +75,16 @@ class views_handler_field_entity extends views_handler_field {
|
||||
/**
|
||||
* Load the entities for all rows that are about to be displayed.
|
||||
*/
|
||||
function pre_render(&$values) {
|
||||
public function pre_render(&$values) {
|
||||
if (!empty($values)) {
|
||||
list($this->entity_type, $this->entities) = $this->query->get_result_entities($values, !empty($this->relationship) ? $this->relationship : NULL, $this->field_alias);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Overridden to return the entity object, or a certain property of the entity.
|
||||
* Return the entity object or a certain property of the entity.
|
||||
*/
|
||||
function get_value($values, $field = NULL) {
|
||||
public function get_value($values, $field = NULL) {
|
||||
if (isset($this->entities[$this->view->row_index])) {
|
||||
$entity = $this->entities[$this->view->row_index];
|
||||
// Support to get a certain part of the entity.
|
||||
@ -101,4 +101,5 @@ class views_handler_field_entity extends views_handler_field {
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,9 +13,9 @@
|
||||
class views_handler_field_links extends views_handler_field {
|
||||
|
||||
/**
|
||||
* Overrides views_handler_field::option_definition().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function option_definition() {
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['fields'] = array('default' => array());
|
||||
@ -26,9 +26,9 @@ class views_handler_field_links extends views_handler_field {
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides views_handler_field::options_form().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
$all_fields = $this->view->display_handler->get_field_labels();
|
||||
@ -59,9 +59,9 @@ class views_handler_field_links extends views_handler_field {
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides views_handler_field::options_form().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function options_submit(&$form, &$form_state) {
|
||||
public function options_submit(&$form, &$form_state) {
|
||||
// Remove unselected options.
|
||||
$form_state['values']['options']['fields'] = array_filter($form_state['values']['options']['fields']);
|
||||
}
|
||||
@ -72,7 +72,7 @@ class views_handler_field_links extends views_handler_field {
|
||||
* @return array
|
||||
* The links which are used by the render function.
|
||||
*/
|
||||
function get_links() {
|
||||
public function get_links() {
|
||||
$links = array();
|
||||
foreach ($this->options['fields'] as $field) {
|
||||
if (empty($this->view->field[$field]->last_render_text)) {
|
||||
@ -121,7 +121,6 @@ class views_handler_field_links extends views_handler_field {
|
||||
}
|
||||
|
||||
// Omit tweaks of query, fragment, and link_class.
|
||||
|
||||
$alt = strtr($alter['alt'], $tokens);
|
||||
if ($alt && $alt != $title) {
|
||||
// Set the title attribute only if it improves accessibility.
|
||||
@ -148,8 +147,9 @@ class views_handler_field_links extends views_handler_field {
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides views_handler_field::query().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function query() { }
|
||||
public function query() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,16 +10,21 @@
|
||||
* @ingroup views_field_handlers
|
||||
*
|
||||
* Definition items:
|
||||
* - options callback: The function to call in order to generate the value options. If omitted, the options 'Yes' and 'No' will be used.
|
||||
* - options callback: The function to call in order to generate the value
|
||||
* options. If omitted, the options 'Yes' and 'No' will be used.
|
||||
* - options arguments: An array of arguments to pass to the options callback.
|
||||
*/
|
||||
class views_handler_field_machine_name extends views_handler_field {
|
||||
|
||||
/**
|
||||
* @var array Stores the available options.
|
||||
*/
|
||||
var $value_options;
|
||||
public $value_options;
|
||||
|
||||
function get_value_options() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_value_options() {
|
||||
if (isset($this->value_options)) {
|
||||
return;
|
||||
}
|
||||
@ -37,14 +42,20 @@ class views_handler_field_machine_name extends views_handler_field {
|
||||
}
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['machine_name'] = 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['machine_name'] = array(
|
||||
@ -55,11 +66,17 @@ class views_handler_field_machine_name extends views_handler_field {
|
||||
);
|
||||
}
|
||||
|
||||
function pre_render(&$values) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function pre_render(&$values) {
|
||||
$this->get_value_options();
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render($values) {
|
||||
$value = $values->{$this->field_alias};
|
||||
if (!empty($this->options['machine_name']) || !isset($this->value_options[$value])) {
|
||||
$result = check_plain($value);
|
||||
@ -70,4 +87,5 @@ class views_handler_field_machine_name extends views_handler_field {
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,17 +10,18 @@
|
||||
* format field.
|
||||
*
|
||||
* - format: (REQUIRED) Either a string format id to use for this field or an
|
||||
* array('field' => {$field}) where $field is the field in this table
|
||||
* used to control the format such as the 'format' field in the node,
|
||||
* which goes with the 'body' field.
|
||||
* array('field' => {$field}) where $field is the field in this table used to
|
||||
* control the format such as the 'format' field in the node, which goes with
|
||||
* the 'body' field.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_markup extends views_handler_field {
|
||||
|
||||
/**
|
||||
* Constructor; calls to base object constructor.
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function construct() {
|
||||
public function construct() {
|
||||
parent::construct();
|
||||
|
||||
$this->format = $this->definition['format'];
|
||||
@ -31,7 +32,10 @@ class views_handler_field_markup extends views_handler_field {
|
||||
}
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render($values) {
|
||||
$value = $this->get_value($values);
|
||||
if (is_array($this->format)) {
|
||||
$format = $this->get_value($values, 'format');
|
||||
@ -45,7 +49,10 @@ class views_handler_field_markup extends views_handler_field {
|
||||
}
|
||||
}
|
||||
|
||||
function element_type($none_supported = FALSE, $default_empty = FALSE, $inline = FALSE) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function element_type($none_supported = FALSE, $default_empty = FALSE, $inline = FALSE) {
|
||||
if ($inline) {
|
||||
return 'span';
|
||||
}
|
||||
@ -56,4 +63,5 @@ class views_handler_field_markup extends views_handler_field {
|
||||
|
||||
return 'div';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,14 +15,21 @@
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_math extends views_handler_field_numeric {
|
||||
function option_definition() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['expression'] = array('default' => '');
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
$form['expression'] = array(
|
||||
'#type' => 'textarea',
|
||||
'#title' => t('Expression'),
|
||||
@ -30,17 +37,20 @@ class views_handler_field_math extends views_handler_field_numeric {
|
||||
'#default_value' => $this->options['expression'],
|
||||
);
|
||||
|
||||
// Create a place for the help
|
||||
// Create a place for the help.
|
||||
$form['expression_help'] = array();
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
// Then move the existing help:
|
||||
// Then move the existing help.
|
||||
$form['expression_help'] = $form['alter']['help'];
|
||||
unset($form['expression_help']['#dependency']);
|
||||
unset($form['alter']['help']);
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render($values) {
|
||||
ctools_include('math-expr');
|
||||
$tokens = array_map('floatval', $this->get_render_tokens(array()));
|
||||
$value = strtr($this->options['expression'], $tokens);
|
||||
@ -80,5 +90,10 @@ class views_handler_field_math extends views_handler_field_numeric {
|
||||
return $this->sanitize_value($this->options['prefix'] . $value . $this->options['suffix']);
|
||||
}
|
||||
|
||||
function query() { }
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,16 +6,20 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Render a field as a numeric value
|
||||
* Render a field as a numeric value.
|
||||
*
|
||||
* Definition terms:
|
||||
* - float: If true this field contains a decimal value. If unset this field
|
||||
* will be assumed to be integer.
|
||||
* will be assumed to be integer.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_numeric extends views_handler_field {
|
||||
function option_definition() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['set_precision'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
@ -31,7 +35,10 @@ class views_handler_field_numeric extends views_handler_field {
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
if (!empty($this->definition['float'])) {
|
||||
$form['set_precision'] = array(
|
||||
'#type' => 'checkbox',
|
||||
@ -105,7 +112,10 @@ class views_handler_field_numeric extends views_handler_field {
|
||||
parent::options_form($form, $form_state);
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render($values) {
|
||||
$value = $this->get_value($values);
|
||||
|
||||
// Hiding should happen before rounding or adding prefix/suffix.
|
||||
@ -135,4 +145,5 @@ class views_handler_field_numeric extends views_handler_field {
|
||||
. $this->sanitize_value($value)
|
||||
. $this->sanitize_value($this->options['suffix'], 'xss');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,17 +16,22 @@
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_prerender_list extends views_handler_field {
|
||||
|
||||
/**
|
||||
* Stores all items which are used to render the items.
|
||||
*
|
||||
* It should be keyed first by the id of the base table, for example nid.
|
||||
* The second key is the id of the thing which is displayed multiple times
|
||||
* per row, for example the tid.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $items = array();
|
||||
public $items = array();
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['type'] = array('default' => 'separator');
|
||||
@ -35,7 +40,10 @@ class views_handler_field_prerender_list extends views_handler_field {
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
$form['type'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Display type'),
|
||||
@ -63,7 +71,7 @@ class views_handler_field_prerender_list extends views_handler_field {
|
||||
* yet or won't update their prerender list fields. If a render_item method
|
||||
* exists, this will not get used by advanced_render.
|
||||
*/
|
||||
function render($values) {
|
||||
public function render($values) {
|
||||
$field = $this->get_value($values);
|
||||
if (!empty($this->items[$field])) {
|
||||
if ($this->options['type'] == 'separator') {
|
||||
@ -74,7 +82,7 @@ class views_handler_field_prerender_list extends views_handler_field {
|
||||
array(
|
||||
'items' => $this->items[$field],
|
||||
'title' => NULL,
|
||||
'type' => $this->options['type']
|
||||
'type' => $this->options['type'],
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -86,7 +94,7 @@ class views_handler_field_prerender_list extends views_handler_field {
|
||||
* When using advanced render, each possible item in the list is rendered
|
||||
* individually. Then the items are all pasted together.
|
||||
*/
|
||||
function render_items($items) {
|
||||
public function render_items($items) {
|
||||
if (!empty($items)) {
|
||||
if ($this->options['type'] == 'separator') {
|
||||
return implode($this->sanitize_value($this->options['separator'], 'xss_admin'), $items);
|
||||
@ -96,7 +104,7 @@ class views_handler_field_prerender_list extends views_handler_field {
|
||||
array(
|
||||
'items' => $items,
|
||||
'title' => NULL,
|
||||
'type' => $this->options['type']
|
||||
'type' => $this->options['type'],
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -105,14 +113,18 @@ class views_handler_field_prerender_list extends views_handler_field {
|
||||
/**
|
||||
* Return an array of items for the field.
|
||||
*
|
||||
* Items should be stored in the result array, if possible, as an array
|
||||
* with 'value' as the actual displayable value of the item, plus
|
||||
* any items that might be found in the 'alter' options array for
|
||||
* creating links, such as 'path', 'fragment', 'query' etc, such a thing
|
||||
* is to be made. Additionally, items that might be turned into tokens
|
||||
* should also be in this array.
|
||||
* Items should be stored in the result array, if possible, as an array with
|
||||
* 'value' as the actual displayable value of the item, plus any items that
|
||||
* might be found in the 'alter' options array for creating links, such as
|
||||
* 'path', 'fragment', 'query' etc, such a thing is to be made. Additionally,
|
||||
* items that might be turned into tokens should also be in this array.
|
||||
*
|
||||
* @param mixed $values
|
||||
*
|
||||
* @return array
|
||||
* The items.
|
||||
*/
|
||||
function get_items($values) {
|
||||
public function get_items($values) {
|
||||
// Only the parent get_value returns a single field.
|
||||
$field = parent::get_value($values);
|
||||
if (!empty($this->items[$field])) {
|
||||
@ -125,14 +137,14 @@ class views_handler_field_prerender_list extends views_handler_field {
|
||||
/**
|
||||
* Get the value that's supposed to be rendered.
|
||||
*
|
||||
* @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.
|
||||
* @param $raw
|
||||
* @param bool $raw
|
||||
* Use the raw data and not the data defined in pre_render
|
||||
*/
|
||||
function get_value($values, $field = NULL, $raw = FALSE) {
|
||||
public function get_value($values, $field = NULL, $raw = FALSE) {
|
||||
if ($raw) {
|
||||
return parent::get_value($values, $field);
|
||||
}
|
||||
@ -149,10 +161,14 @@ class views_handler_field_prerender_list extends views_handler_field {
|
||||
*
|
||||
* By default, advanced rendering will NOT be allowed if the class
|
||||
* inheriting from this does not implement a 'render_items' method.
|
||||
*
|
||||
* @return bool
|
||||
* Whether or not the the render method exists.
|
||||
*/
|
||||
function allow_advanced_render() {
|
||||
public function allow_advanced_render() {
|
||||
// Note that the advanced render bits also use the presence of
|
||||
// this method to determine if it needs to render items as a list.
|
||||
return method_exists($this, 'render_item');
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,15 +12,20 @@
|
||||
*/
|
||||
class views_handler_field_serialized extends views_handler_field {
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['format'] = array('default' => 'unserialized');
|
||||
$options['key'] = 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['format'] = array(
|
||||
@ -42,14 +47,20 @@ class views_handler_field_serialized extends views_handler_field {
|
||||
);
|
||||
}
|
||||
|
||||
function options_validate(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_validate(&$form, &$form_state) {
|
||||
// Require a key if the format is key.
|
||||
if ($form_state['values']['options']['format'] == 'key' && $form_state['values']['options']['key'] == '') {
|
||||
form_error($form['key'], t('You have to enter a key if you want to display a key of the data.'));
|
||||
}
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render($values) {
|
||||
$value = $values->{$this->field_alias};
|
||||
|
||||
if ($this->options['format'] == 'unserialized') {
|
||||
@ -62,4 +73,5 @@ class views_handler_field_serialized extends views_handler_field {
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,11 @@
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_time_interval extends views_handler_field {
|
||||
function option_definition() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['granularity'] = array('default' => 2);
|
||||
@ -19,7 +23,10 @@ class views_handler_field_time_interval 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['granularity'] = array(
|
||||
@ -30,8 +37,12 @@ class views_handler_field_time_interval extends views_handler_field {
|
||||
);
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render($values) {
|
||||
$value = $values->{$this->field_alias};
|
||||
return format_interval($value, isset($this->options['granularity']) ? $this->options['granularity'] : 2);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,12 +6,16 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Field handler to provide simple renderer that turns a URL into a clickable link.
|
||||
* Field handler that turns a URL into a clickable link.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_url extends views_handler_field {
|
||||
function option_definition() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['display_as_link'] = array('default' => TRUE, 'bool' => TRUE);
|
||||
@ -22,7 +26,7 @@ class views_handler_field_url extends views_handler_field {
|
||||
/**
|
||||
* Provide link to the page being visited.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
public function options_form(&$form, &$form_state) {
|
||||
$form['display_as_link'] = array(
|
||||
'#title' => t('Display as link'),
|
||||
'#type' => 'checkbox',
|
||||
@ -31,7 +35,10 @@ class views_handler_field_url 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['display_as_link'])) {
|
||||
$this->options['alter']['make_link'] = TRUE;
|
||||
@ -43,4 +50,5 @@ class views_handler_field_url extends views_handler_field {
|
||||
return $this->sanitize_value($value, 'url');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @todo.
|
||||
* Definitions of views_handler_filter and views_handler_filter_broken.
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -32,39 +32,49 @@
|
||||
* @ingroup views_filter_handlers
|
||||
*/
|
||||
class views_handler_filter extends views_handler {
|
||||
|
||||
/**
|
||||
* Contains the actual value of the field,either configured in the views ui
|
||||
* or entered in the exposed filters.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
var $value = NULL;
|
||||
public $value = NULL;
|
||||
|
||||
/**
|
||||
* Contains the operator which is used on the query.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $operator = '=';
|
||||
public $operator = '=';
|
||||
|
||||
/**
|
||||
* Contains the information of the selected item in a gruped filter.
|
||||
*
|
||||
* @var array|null
|
||||
*/
|
||||
var $group_info = NULL;
|
||||
public $group_info = NULL;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
* Disable the possibility to force a single value.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
var $always_multiple = FALSE;
|
||||
public $always_multiple = FALSE;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
* Disable the possibility to use operators.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
var $no_operator = FALSE;
|
||||
public $no_operator = FALSE;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
* Disable the possibility to allow a exposed input to be optional.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
var $always_required = FALSE;
|
||||
public $always_required = FALSE;
|
||||
|
||||
/**
|
||||
* Provide some extra help to get the operator/value easier to use.
|
||||
@ -72,7 +82,7 @@ class views_handler_filter extends views_handler {
|
||||
* This likely has to be overridden by filters which are more complex
|
||||
* than simple operator/value.
|
||||
*/
|
||||
function init(&$view, &$options) {
|
||||
public function init(&$view, &$options) {
|
||||
parent::init($view, $options);
|
||||
|
||||
$this->operator = $this->options['operator'];
|
||||
@ -107,7 +117,10 @@ class views_handler_filter extends views_handler {
|
||||
}
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['operator'] = array('default' => '=');
|
||||
@ -160,39 +173,43 @@ class views_handler_filter extends views_handler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the filter on the administrative summary
|
||||
* Display the filter on the administrative summary.
|
||||
*/
|
||||
function admin_summary() {
|
||||
public function admin_summary() {
|
||||
return check_plain((string) $this->operator) . ' ' . check_plain((string) $this->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a filter can be exposed.
|
||||
*/
|
||||
function can_expose() { return TRUE; }
|
||||
public function can_expose() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a filter can be converted into a group.
|
||||
*
|
||||
* Only exposed filters with operators available can be converted into groups.
|
||||
*/
|
||||
function can_build_group() {
|
||||
public function can_build_group() {
|
||||
return $this->is_exposed() && (count($this->operator_options()) > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if the exposed filter works like a grouped filter.
|
||||
*/
|
||||
function is_a_group() {
|
||||
public function is_a_group() {
|
||||
return $this->is_exposed() && !empty($this->options['is_grouped']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide the basic form which calls through to subforms.
|
||||
*
|
||||
* If overridden, it is best to call through to the parent,
|
||||
* or to at least make sure all of the functions in this form
|
||||
* are called.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
if ($this->can_expose()) {
|
||||
$this->show_expose_button($form, $form_state);
|
||||
@ -233,7 +250,7 @@ class views_handler_filter extends views_handler {
|
||||
/**
|
||||
* Simple validate handler
|
||||
*/
|
||||
function options_validate(&$form, &$form_state) {
|
||||
public function options_validate(&$form, &$form_state) {
|
||||
$this->operator_validate($form, $form_state);
|
||||
$this->value_validate($form, $form_state);
|
||||
if (!empty($this->options['exposed']) && !$this->is_a_group()) {
|
||||
@ -245,11 +262,13 @@ class views_handler_filter extends views_handler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple submit handler
|
||||
* Simple submit handler.
|
||||
*/
|
||||
function options_submit(&$form, &$form_state) {
|
||||
unset($form_state['values']['expose_button']); // don't store this.
|
||||
unset($form_state['values']['group_button']); // don't store this.
|
||||
public function options_submit(&$form, &$form_state) {
|
||||
// Don't store these.
|
||||
unset($form_state['values']['expose_button']);
|
||||
unset($form_state['values']['group_button']);
|
||||
|
||||
if (!$this->is_a_group()) {
|
||||
$this->operator_submit($form, $form_state);
|
||||
$this->value_submit($form, $form_state);
|
||||
@ -265,7 +284,7 @@ class views_handler_filter extends views_handler {
|
||||
/**
|
||||
* Shortcut to display the operator form.
|
||||
*/
|
||||
function show_operator_form(&$form, &$form_state) {
|
||||
public function show_operator_form(&$form, &$form_state) {
|
||||
$this->operator_form($form, $form_state);
|
||||
$form['operator']['#prefix'] = '<div class="views-group-box views-left-30">';
|
||||
$form['operator']['#suffix'] = '</div>';
|
||||
@ -279,7 +298,7 @@ class views_handler_filter extends views_handler {
|
||||
*
|
||||
* @see options_form()
|
||||
*/
|
||||
function operator_form(&$form, &$form_state) {
|
||||
public function operator_form(&$form, &$form_state) {
|
||||
$options = $this->operator_options();
|
||||
if (!empty($options)) {
|
||||
$form['operator'] = array(
|
||||
@ -293,25 +312,31 @@ class views_handler_filter extends views_handler {
|
||||
|
||||
/**
|
||||
* Provide a list of options for the default operator form.
|
||||
*
|
||||
* Should be overridden by classes that don't override operator_form
|
||||
*/
|
||||
function operator_options() { return array(); }
|
||||
public function operator_options() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the operator form.
|
||||
*/
|
||||
function operator_validate($form, &$form_state) { }
|
||||
public function operator_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 operator_submit($form, &$form_state) { }
|
||||
public function operator_submit($form, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut to display the value form.
|
||||
*/
|
||||
function show_value_form(&$form, &$form_state) {
|
||||
public function show_value_form(&$form, &$form_state) {
|
||||
$this->value_form($form, $form_state);
|
||||
if (empty($this->no_operator)) {
|
||||
$form['value']['#prefix'] = '<div class="views-group-box views-right-70">' . (isset($form['value']['#prefix']) ? $form['value']['#prefix'] : '');
|
||||
@ -322,28 +347,33 @@ class views_handler_filter extends views_handler {
|
||||
/**
|
||||
* Options form subform for setting options.
|
||||
*
|
||||
* This should be overridden by all child classes and it must
|
||||
* define $form['value']
|
||||
* This should be overridden by all child classes and it must define
|
||||
* $form['value'].
|
||||
*
|
||||
* @see options_form()
|
||||
*/
|
||||
function value_form(&$form, &$form_state) { $form['value'] = array(); }
|
||||
public function value_form(&$form, &$form_state) {
|
||||
$form['value'] = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the options form.
|
||||
*/
|
||||
function value_validate($form, &$form_state) { }
|
||||
public function value_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 value_submit($form, &$form_state) { }
|
||||
public function value_submit($form, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut to display the exposed options form.
|
||||
*/
|
||||
function show_build_group_form(&$form, &$form_state) {
|
||||
public function show_build_group_form(&$form, &$form_state) {
|
||||
if (empty($this->options['is_grouped'])) {
|
||||
return;
|
||||
}
|
||||
@ -366,8 +396,7 @@ class views_handler_filter extends views_handler {
|
||||
/**
|
||||
* Shortcut to display the build_group/hide button.
|
||||
*/
|
||||
function show_build_group_button(&$form, &$form_state) {
|
||||
|
||||
public function show_build_group_button(&$form, &$form_state) {
|
||||
$form['group_button'] = array(
|
||||
'#prefix' => '<div class="views-grouped clearfix">',
|
||||
'#suffix' => '</div>',
|
||||
@ -412,10 +441,11 @@ class views_handler_filter extends views_handler {
|
||||
$form['group_button']['radios']['radios']['#default_value'] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut to display the expose/hide button.
|
||||
*/
|
||||
function show_expose_button(&$form, &$form_state) {
|
||||
public function show_expose_button(&$form, &$form_state) {
|
||||
$form['expose_button'] = array(
|
||||
'#prefix' => '<div class="views-expose clearfix">',
|
||||
'#suffix' => '</div>',
|
||||
@ -423,8 +453,8 @@ class views_handler_filter extends views_handler {
|
||||
'#weight' => -200,
|
||||
);
|
||||
|
||||
// Add a checkbox for JS users, which will have behavior attached to it
|
||||
// so it can replace the button.
|
||||
// Add a checkbox for JS users, which will have behavior attached to it so
|
||||
// it can replace the button.
|
||||
$form['expose_button']['checkbox'] = array(
|
||||
'#theme_wrappers' => array('container'),
|
||||
'#attributes' => array('class' => array('js-only')),
|
||||
@ -466,7 +496,7 @@ class views_handler_filter extends views_handler {
|
||||
*
|
||||
* @see options_form()
|
||||
*/
|
||||
function expose_form(&$form, &$form_state) {
|
||||
public function expose_form(&$form, &$form_state) {
|
||||
$form['#theme'] = 'views_ui_expose_filter_form';
|
||||
// #flatten will move everything from $form['expose'][$key] to $form[$key]
|
||||
// prior to rendering. That's why the pre_render for it needs to run first,
|
||||
@ -566,7 +596,7 @@ class views_handler_filter extends views_handler {
|
||||
'#description' => t('Remember exposed selection only for the selected user role(s). If you select no roles, the exposed data will never be stored.'),
|
||||
'#default_value' => $this->options['expose']['remember_roles'],
|
||||
'#options' => $role_options,
|
||||
'#dependency' => array(
|
||||
'#dependency' => array(
|
||||
'edit-options-expose-remember' => array(1),
|
||||
),
|
||||
);
|
||||
@ -584,7 +614,7 @@ class views_handler_filter extends views_handler {
|
||||
/**
|
||||
* Validate the options form.
|
||||
*/
|
||||
function expose_validate($form, &$form_state) {
|
||||
public function expose_validate($form, &$form_state) {
|
||||
if (empty($form_state['values']['options']['expose']['identifier'])) {
|
||||
form_error($form['expose']['identifier'], t('The identifier is required if the filter is exposed.'));
|
||||
}
|
||||
@ -601,10 +631,10 @@ class views_handler_filter extends views_handler {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Validate the build group options form.
|
||||
*/
|
||||
function build_group_validate($form, &$form_state) {
|
||||
public function build_group_validate($form, &$form_state) {
|
||||
if (!empty($form_state['values']['options']['group_info'])) {
|
||||
if (empty($form_state['values']['options']['group_info']['identifier'])) {
|
||||
form_error($form['group_info']['identifier'], t('The identifier is required if the filter is exposed.'));
|
||||
@ -625,13 +655,12 @@ class views_handler_filter extends views_handler {
|
||||
if (!empty($form_state['values']['options']['group_info']['group_items'])) {
|
||||
foreach ($form_state['values']['options']['group_info']['group_items'] as $id => $group) {
|
||||
if (empty($group['remove'])) {
|
||||
|
||||
// Check if the title is defined but value wasn't defined.
|
||||
if (!empty($group['title'])) {
|
||||
if ((!is_array($group['value']) && trim($group['value']) == "") ||
|
||||
(is_array($group['value']) && count(array_filter($group['value'], '_views_array_filter_zero')) == 0)) {
|
||||
form_error($form['group_info']['group_items'][$id]['value'],
|
||||
t('The value is required if title for this item is defined.'));
|
||||
t('The value is required if title for this item is defined.'));
|
||||
}
|
||||
}
|
||||
|
||||
@ -640,7 +669,7 @@ class views_handler_filter extends views_handler {
|
||||
(is_array($group['value']) && count(array_filter($group['value'], '_views_array_filter_zero')) > 0)) {
|
||||
if (empty($group['title'])) {
|
||||
form_error($form['group_info']['group_items'][$id]['title'],
|
||||
t('The title is required if value for this item is defined.'));
|
||||
t('The title is required if value for this item is defined.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -651,11 +680,11 @@ class views_handler_filter extends views_handler {
|
||||
/**
|
||||
* Save new group items, re-enumerates and remove groups marked to delete.
|
||||
*/
|
||||
function build_group_submit($form, &$form_state) {
|
||||
public function build_group_submit($form, &$form_state) {
|
||||
$groups = array();
|
||||
uasort($form_state['values']['options']['group_info']['group_items'], 'drupal_sort_weight');
|
||||
// Filter out removed items.
|
||||
|
||||
// Filter out removed items.
|
||||
// Start from 1 to avoid problems with #default_value in the widget.
|
||||
$new_id = 1;
|
||||
$new_default = 'All';
|
||||
@ -684,7 +713,7 @@ class views_handler_filter extends views_handler {
|
||||
/**
|
||||
* Provide default options for exposed filters.
|
||||
*/
|
||||
function expose_options() {
|
||||
public function expose_options() {
|
||||
$this->options['expose'] = array(
|
||||
'use_operator' => FALSE,
|
||||
'operator' => $this->options['id'] . '_op',
|
||||
@ -697,10 +726,10 @@ class views_handler_filter extends views_handler {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Provide default options for exposed filters.
|
||||
*/
|
||||
function build_group_options() {
|
||||
public function build_group_options() {
|
||||
$this->options['group_info'] = array(
|
||||
'label' => $this->definition['title'],
|
||||
'description' => NULL,
|
||||
@ -716,12 +745,10 @@ class views_handler_filter extends views_handler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a form containing a group of operator | values to apply as a
|
||||
* single filter.
|
||||
* Build a form with a group of operator | values to apply as a single filter.
|
||||
*/
|
||||
function group_form(&$form, &$form_state) {
|
||||
public function group_form(&$form, &$form_state) {
|
||||
if (!empty($this->options['group_info']['optional']) && !$this->multiple_exposed_input()) {
|
||||
|
||||
$old_any = $this->options['group_info']['widget'] == 'select' ? '<Any>' : '<Any>';
|
||||
$any_label = variable_get('views_exposed_filter_any_label', 'new_any') == 'old_any' ? $old_any : t('- Any -');
|
||||
$groups = array('All' => $any_label);
|
||||
@ -750,7 +777,7 @@ class views_handler_filter extends views_handler {
|
||||
$form[$value]['#multiple'] = TRUE;
|
||||
}
|
||||
unset($form[$value]['#default_value']);
|
||||
if (empty($form_state['input'])) {
|
||||
if (empty($form_state['input'][$value])) {
|
||||
$form_state['input'][$value] = $this->group_info;
|
||||
}
|
||||
}
|
||||
@ -765,7 +792,7 @@ class views_handler_filter extends views_handler {
|
||||
*
|
||||
* You can override this if it doesn't do what you expect.
|
||||
*/
|
||||
function exposed_form(&$form, &$form_state) {
|
||||
public function exposed_form(&$form, &$form_state) {
|
||||
if (empty($this->options['exposed'])) {
|
||||
return;
|
||||
}
|
||||
@ -811,18 +838,19 @@ class views_handler_filter extends views_handler {
|
||||
|
||||
/**
|
||||
* Build the form to let users create the group of exposed filters.
|
||||
*
|
||||
* This form is displayed when users click on button 'Build group'
|
||||
*/
|
||||
function build_group_form(&$form, &$form_state) {
|
||||
public function build_group_form(&$form, &$form_state) {
|
||||
if (empty($this->options['exposed']) || empty($this->options['is_grouped'])) {
|
||||
return;
|
||||
}
|
||||
$form['#theme'] = 'views_ui_build_group_filter_form';
|
||||
|
||||
// #flatten will move everything from $form['group_info'][$key] to $form[$key]
|
||||
// prior to rendering. That's why the pre_render for it needs to run first,
|
||||
// so that when the next pre_render (the one for fieldsets) runs, it gets
|
||||
// the flattened data.
|
||||
// #flatten will move everything from $form['group_info'][$key] to
|
||||
// $form[$key] prior to rendering. That's why the pre_render for it needs
|
||||
// to run first, so that when the next pre_render (the one for fieldsets)
|
||||
// runs, it gets the flattened data.
|
||||
array_unshift($form['#pre_render'], 'views_ui_pre_render_flatten_data');
|
||||
$form['group_info']['#flatten'] = TRUE;
|
||||
|
||||
@ -925,7 +953,9 @@ class views_handler_filter extends views_handler {
|
||||
'#default_value' => $this->options['group_info']['remember'],
|
||||
);
|
||||
|
||||
$groups = array('All' => '- Any -'); // The string '- Any -' will not be rendered see @theme_views_ui_build_group_filter_form
|
||||
// The string '- Any -' will not be rendered.
|
||||
// @see theme_views_ui_build_group_filter_form()
|
||||
$groups = array('All' => '- Any -');
|
||||
|
||||
// Provide 3 options to start when we are in a new group.
|
||||
if (count($this->options['group_info']['group_items']) == 0) {
|
||||
@ -939,10 +969,11 @@ class views_handler_filter extends views_handler {
|
||||
continue;
|
||||
}
|
||||
// Each rows contains three widgets:
|
||||
// a) The title, where users define how they identify a pair of operator | value
|
||||
// b) The operator
|
||||
// c) The value (or values) to use in the filter with the selected operator
|
||||
|
||||
// a) The title, where users define how they identify a pair of operator
|
||||
// | value.
|
||||
// b) The operator.
|
||||
// c) The value (or values) to use in the filter with the selected
|
||||
// operator.
|
||||
// In each row, we have to display the operator form and the value from
|
||||
// $row acts as a fake form to render each widget in a row.
|
||||
$row = array();
|
||||
@ -954,11 +985,10 @@ class views_handler_filter extends views_handler {
|
||||
$row['operator']['#title'] = '';
|
||||
$this->value_form($row, $form_state);
|
||||
|
||||
// Fix the dependencies to update value forms when operators
|
||||
// changes. This is needed because forms are inside a new form and
|
||||
// their ids changes. Dependencies are used when operator changes
|
||||
// from to 'Between', 'Not Between', etc, and two or more widgets
|
||||
// are displayed.
|
||||
// Fix the dependencies to update value forms when operators changes.
|
||||
// This is needed because forms are inside a new form and their ids
|
||||
// changes. Dependencies are used when operator changes from to
|
||||
// 'Between', 'Not Between', etc, and two or more widgets are displayed.
|
||||
$without_children = TRUE;
|
||||
foreach (element_children($row['value']) as $children) {
|
||||
if (isset($row['value'][$children]['#dependency']['edit-options-operator'])) {
|
||||
@ -1005,7 +1035,7 @@ class views_handler_filter extends views_handler {
|
||||
),
|
||||
'weight' => array(
|
||||
'#type' => 'weight',
|
||||
'#delta' => 10,
|
||||
'#delta' => count($this->options['group_info']['group_items']),
|
||||
'#default_value' => $default_weight++,
|
||||
'#attributes' => array('class' => array('weight')),
|
||||
),
|
||||
@ -1058,10 +1088,9 @@ class views_handler_filter extends views_handler {
|
||||
|
||||
|
||||
/**
|
||||
* Make some translations to a form item to make it more suitable to
|
||||
* exposing.
|
||||
* Make some translations to a form item to make it more suitable to exposing.
|
||||
*/
|
||||
function exposed_translate(&$form, $type) {
|
||||
public function exposed_translate(&$form, $type) {
|
||||
if (!isset($form['#type'])) {
|
||||
return;
|
||||
}
|
||||
@ -1083,7 +1112,8 @@ class views_handler_filter extends views_handler {
|
||||
$form['#size'] = NULL;
|
||||
}
|
||||
|
||||
// Cleanup in case the translated element's (radios or checkboxes) display value contains html.
|
||||
// Cleanup in case the translated element's (radios or checkboxes) display
|
||||
// value contains html.
|
||||
if ($form['#type'] == 'select') {
|
||||
$this->prepare_filter_select_options($form['#options']);
|
||||
}
|
||||
@ -1099,21 +1129,19 @@ class views_handler_filter extends views_handler {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sanitizes the HTML select element's options.
|
||||
*
|
||||
* The function is recursive to support optgroups.
|
||||
*/
|
||||
function prepare_filter_select_options(&$options) {
|
||||
public function prepare_filter_select_options(&$options) {
|
||||
foreach ($options as $value => $label) {
|
||||
// Recurse for optgroups.
|
||||
if (is_array($label)) {
|
||||
$this->prepare_filter_select_options($options[$value]);
|
||||
}
|
||||
// FAPI has some special value to allow hierarchy.
|
||||
// @see _form_options_flatten
|
||||
// @see _form_options_flatten()
|
||||
elseif (is_object($label)) {
|
||||
$this->prepare_filter_select_options($options[$value]->option);
|
||||
}
|
||||
@ -1124,8 +1152,10 @@ class views_handler_filter extends views_handler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell the renderer about our exposed form. This only needs to be
|
||||
* overridden for particularly complex forms. And maybe not even then.
|
||||
* Tell the renderer about our exposed form.
|
||||
*
|
||||
* This only needs to be overridden for particularly complex forms. And maybe
|
||||
* not even then.
|
||||
*
|
||||
* @return array|null
|
||||
* For standard exposed filters. An array with the following keys:
|
||||
@ -1136,7 +1166,7 @@ class views_handler_filter extends views_handler {
|
||||
* - value: The $form key of the value. Set to NULL if no value.
|
||||
* - label: The label to use for this piece.
|
||||
*/
|
||||
function exposed_info() {
|
||||
public function exposed_info() {
|
||||
if (empty($this->options['exposed'])) {
|
||||
return;
|
||||
}
|
||||
@ -1157,7 +1187,7 @@ class views_handler_filter extends views_handler {
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Transform the input from a grouped filter into a standard filter.
|
||||
*
|
||||
* When a filter is a group, find the set of operator and values
|
||||
@ -1168,10 +1198,10 @@ class views_handler_filter extends views_handler {
|
||||
* checkboxes widget, and this function will be called for each item
|
||||
* choosed in the checkboxes.
|
||||
*/
|
||||
function convert_exposed_input(&$input, $selected_group_id = NULL) {
|
||||
public function convert_exposed_input(&$input, $selected_group_id = NULL) {
|
||||
if ($this->is_a_group()) {
|
||||
// If it is already defined the selected group, use it. Only valid
|
||||
// when the filter uses checkboxes for widget.
|
||||
// If it is already defined the selected group, use it. Only valid when
|
||||
// the filter uses checkboxes for widget.
|
||||
if (!empty($selected_group_id)) {
|
||||
$selected_group = $selected_group_id;
|
||||
}
|
||||
@ -1187,7 +1217,8 @@ class views_handler_filter extends views_handler {
|
||||
if (isset($selected_group) && isset($this->options['group_info']['group_items'][$selected_group])) {
|
||||
$input[$this->options['expose']['operator']] = $this->options['group_info']['group_items'][$selected_group]['operator'];
|
||||
|
||||
// Value can be optional, For example for 'empty' and 'not empty' filters.
|
||||
// Value can be optional, For example for 'empty' and 'not empty'
|
||||
// filters.
|
||||
if (!empty($this->options['group_info']['group_items'][$selected_group]['value'])) {
|
||||
$input[$this->options['expose']['identifier']] = $this->options['group_info']['group_items'][$selected_group]['value'];
|
||||
}
|
||||
@ -1207,7 +1238,7 @@ class views_handler_filter extends views_handler {
|
||||
* as widget, and therefore has to be applied several times, one per
|
||||
* item selected.
|
||||
*/
|
||||
function group_multiple_exposed_input(&$input) {
|
||||
public function group_multiple_exposed_input(&$input) {
|
||||
if (!empty($input[$this->options['group_info']['identifier']])) {
|
||||
return array_filter($input[$this->options['group_info']['identifier']]);
|
||||
}
|
||||
@ -1215,10 +1246,13 @@ class views_handler_filter extends views_handler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TRUE if users can select multiple groups items of a
|
||||
* grouped exposed filter.
|
||||
*
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if users can select multiple groups items of a grouped exposed
|
||||
* filter.
|
||||
*/
|
||||
function multiple_exposed_input() {
|
||||
public function multiple_exposed_input() {
|
||||
return $this->is_a_group() && !empty($this->options['group_info']['multiple']);
|
||||
}
|
||||
|
||||
@ -1227,7 +1261,7 @@ class views_handler_filter extends views_handler {
|
||||
* This function is similar to store_exposed_input but modified to
|
||||
* work properly when the filter is a group.
|
||||
*/
|
||||
function store_group_input($input, $status) {
|
||||
public function store_group_input($input, $status) {
|
||||
if (!$this->is_a_group() || empty($this->options['group_info']['identifier'])) {
|
||||
return TRUE;
|
||||
}
|
||||
@ -1236,12 +1270,12 @@ class views_handler_filter extends views_handler {
|
||||
return;
|
||||
}
|
||||
|
||||
// Figure out which display id is responsible for the filters, so we
|
||||
// know where to look for session stored values.
|
||||
// Figure out which display id is responsible for the filters, so we know
|
||||
// where to look for session stored values.
|
||||
$display_id = ($this->view->display_handler->is_defaulted('filters')) ? 'default' : $this->view->current_display;
|
||||
|
||||
// false means that we got a setting that means to recuse ourselves,
|
||||
// so we should erase whatever happened to be there.
|
||||
// False means that we got a setting that means to recuse ourselves, so we
|
||||
// should erase whatever happened to be there.
|
||||
if ($status === FALSE && isset($_SESSION['views'][$this->view->name][$display_id])) {
|
||||
$session = &$_SESSION['views'][$this->view->name][$display_id];
|
||||
|
||||
@ -1262,15 +1296,13 @@ class views_handler_filter extends views_handler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if input from the exposed filters should change
|
||||
* the behavior of this filter.
|
||||
* Check to see if input from the exposed filters should change the behavior.
|
||||
*/
|
||||
function accept_exposed_input($input) {
|
||||
public function accept_exposed_input($input) {
|
||||
if (empty($this->options['exposed'])) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
if (!empty($this->options['expose']['use_operator']) && !empty($this->options['expose']['operator_id']) && isset($input[$this->options['expose']['operator_id']])) {
|
||||
$this->operator = $input[$this->options['expose']['operator_id']];
|
||||
}
|
||||
@ -1295,7 +1327,6 @@ class views_handler_filter extends views_handler {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isset($value)) {
|
||||
$this->value = $value;
|
||||
if (empty($this->always_multiple) && empty($this->options['expose']['multiple'])) {
|
||||
@ -1310,7 +1341,10 @@ class views_handler_filter extends views_handler {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function store_exposed_input($input, $status) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function store_exposed_input($input, $status) {
|
||||
if (empty($this->options['exposed']) || empty($this->options['expose']['identifier'])) {
|
||||
return TRUE;
|
||||
}
|
||||
@ -1327,15 +1361,15 @@ class views_handler_filter extends views_handler {
|
||||
return;
|
||||
}
|
||||
|
||||
// Figure out which display id is responsible for the filters, so we
|
||||
// know where to look for session stored values.
|
||||
// Figure out which display id is responsible for the filters, so we know
|
||||
// where to look for session stored values.
|
||||
$display_id = ($this->view->display_handler->is_defaulted('filters')) ? 'default' : $this->view->current_display;
|
||||
|
||||
// shortcut test.
|
||||
// Shortcut test.
|
||||
$operator = !empty($this->options['expose']['use_operator']) && !empty($this->options['expose']['operator_id']);
|
||||
|
||||
// false means that we got a setting that means to recuse ourselves,
|
||||
// so we should erase whatever happened to be there.
|
||||
// False means that we got a setting that means to recuse ourselves, so we
|
||||
// should erase whatever happened to be there.
|
||||
if (!$status && isset($_SESSION['views'][$this->view->name][$display_id])) {
|
||||
$session = &$_SESSION['views'][$this->view->name][$display_id];
|
||||
if ($operator && isset($session[$this->options['expose']['operator_id']])) {
|
||||
@ -1366,10 +1400,10 @@ class views_handler_filter extends views_handler {
|
||||
* Add this filter to the query.
|
||||
*
|
||||
* Due to the nature of fapi, the value and the operator have an unintended
|
||||
* level of indirection. You will find them in $this->operator
|
||||
* and $this->value respectively.
|
||||
* level of indirection. You will find them in $this->operator and
|
||||
* $this->value respectively.
|
||||
*/
|
||||
function query() {
|
||||
public function query() {
|
||||
$this->ensure_my_table();
|
||||
$this->query->add_where($this->options['group'], "$this->table_alias.$this->real_field", $this->value, $this->operator);
|
||||
}
|
||||
@ -1377,16 +1411,18 @@ class views_handler_filter extends views_handler {
|
||||
/**
|
||||
* Can this filter be used in OR groups?
|
||||
*
|
||||
* Some filters have complicated where clauses that cannot be easily used
|
||||
* with OR groups. Some filters must also use HAVING which also makes
|
||||
* them not groupable. These filters will end up in a special group
|
||||
* if OR grouping is in use.
|
||||
* Some filters have complicated where clauses that cannot be easily used with
|
||||
* OR groups. Some filters must also use HAVING which also makes them not
|
||||
* groupable. These filters will end up in a special group if OR grouping is
|
||||
* in use.
|
||||
*
|
||||
* @return bool
|
||||
* Whether the filter can be used in OR groups.
|
||||
*/
|
||||
function can_group() {
|
||||
public function can_group() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1396,27 +1432,51 @@ class views_handler_filter extends views_handler {
|
||||
* @ingroup views_filter_handlers
|
||||
*/
|
||||
class views_handler_filter_broken extends views_handler_filter {
|
||||
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' => '<div class="form-item description">' . 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.') . '</div>',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the handler is considered 'broken'
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function broken() { return TRUE; }
|
||||
public function broken() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter by no empty values, though allow to use "0".
|
||||
* @param $var
|
||||
*
|
||||
* @param string $var
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function _views_array_filter_zero($var) {
|
||||
|
@ -22,14 +22,26 @@
|
||||
* @ingroup views_filter_handlers
|
||||
*/
|
||||
class views_handler_filter_boolean_operator extends views_handler_filter {
|
||||
// exposed filter options
|
||||
var $always_multiple = TRUE;
|
||||
// Don't display empty space where the operator would be.
|
||||
var $no_operator = TRUE;
|
||||
// Whether to accept NULL as a false value or not
|
||||
var $accept_null = FALSE;
|
||||
|
||||
function construct() {
|
||||
/**
|
||||
* Exposed filter options.
|
||||
*/
|
||||
public $always_multiple = TRUE;
|
||||
|
||||
/**
|
||||
* Don't display empty space where the operator would be.
|
||||
*/
|
||||
public $no_operator = TRUE;
|
||||
|
||||
/**
|
||||
* Whether to accept NULL as a false value or not.
|
||||
*/
|
||||
public $accept_null = FALSE;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function construct() {
|
||||
$this->value_value = t('True');
|
||||
if (isset($this->definition['label'])) {
|
||||
$this->value_value = $this->definition['label'];
|
||||
@ -37,7 +49,7 @@ class views_handler_filter_boolean_operator extends views_handler_filter {
|
||||
if (isset($this->definition['accept null'])) {
|
||||
$this->accept_null = (bool) $this->definition['accept null'];
|
||||
}
|
||||
else if (isset($this->definition['accept_null'])) {
|
||||
elseif (isset($this->definition['accept_null'])) {
|
||||
$this->accept_null = (bool) $this->definition['accept_null'];
|
||||
}
|
||||
$this->value_options = NULL;
|
||||
@ -56,7 +68,7 @@ class views_handler_filter_boolean_operator extends views_handler_filter {
|
||||
* dynamic for some reason, child classes should use a guard to reduce
|
||||
* database hits as much as possible.
|
||||
*/
|
||||
function get_value_options() {
|
||||
public function get_value_options() {
|
||||
if (isset($this->definition['type'])) {
|
||||
if ($this->definition['type'] == 'yes-no') {
|
||||
$this->value_options = array(1 => t('Yes'), 0 => t('No'));
|
||||
@ -75,7 +87,10 @@ class views_handler_filter_boolean_operator extends views_handler_filter {
|
||||
}
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['value']['default'] = FALSE;
|
||||
@ -83,11 +98,17 @@ class views_handler_filter_boolean_operator extends views_handler_filter {
|
||||
return $options;
|
||||
}
|
||||
|
||||
function operator_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function operator_form(&$form, &$form_state) {
|
||||
$form['operator'] = array();
|
||||
}
|
||||
|
||||
function value_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function value_form(&$form, &$form_state) {
|
||||
if (empty($this->value_options)) {
|
||||
// Initialize the array of possible values for this filter.
|
||||
$this->get_value_options();
|
||||
@ -122,13 +143,19 @@ class views_handler_filter_boolean_operator extends views_handler_filter {
|
||||
}
|
||||
}
|
||||
|
||||
function value_validate($form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function value_validate($form, &$form_state) {
|
||||
if ($form_state['values']['options']['value'] == 'All' && !empty($form_state['values']['options']['expose']['required'])) {
|
||||
form_set_error('value', t('You must select a value unless this is an non-required exposed filter.'));
|
||||
}
|
||||
}
|
||||
|
||||
function admin_summary() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function admin_summary() {
|
||||
if ($this->is_a_group()) {
|
||||
return t('grouped');
|
||||
}
|
||||
@ -145,14 +172,20 @@ class views_handler_filter_boolean_operator extends views_handler_filter {
|
||||
return $this->value_options[!empty($this->value)];
|
||||
}
|
||||
|
||||
function expose_options() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function expose_options() {
|
||||
parent::expose_options();
|
||||
$this->options['expose']['operator_id'] = '';
|
||||
$this->options['expose']['label'] = $this->value_value;
|
||||
$this->options['expose']['required'] = TRUE;
|
||||
}
|
||||
|
||||
function query() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$this->ensure_my_table();
|
||||
$field = "$this->table_alias.$this->real_field";
|
||||
|
||||
@ -176,4 +209,5 @@ class views_handler_filter_boolean_operator extends views_handler_filter {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,7 +17,11 @@
|
||||
* @ingroup views_filter_handlers
|
||||
*/
|
||||
class views_handler_filter_boolean_operator_string extends views_handler_filter_boolean_operator {
|
||||
function query() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$this->ensure_my_table();
|
||||
$where = "$this->table_alias.$this->real_field ";
|
||||
|
||||
@ -32,4 +36,5 @@ class views_handler_filter_boolean_operator_string extends views_handler_filter_
|
||||
}
|
||||
$this->query->add_where_expression($this->options['group'], $where);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,19 +11,26 @@
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_filter_combine extends views_handler_filter_string {
|
||||
|
||||
/**
|
||||
* @var views_plugin_query_default
|
||||
*/
|
||||
public $query;
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['fields'] = array('default' => array());
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$this->view->init_style();
|
||||
|
||||
@ -49,7 +56,10 @@ class views_handler_filter_combine extends views_handler_filter_string {
|
||||
}
|
||||
}
|
||||
|
||||
function query() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$this->view->_build('field');
|
||||
$fields = array();
|
||||
// Only add the fields if they have a proper field and table alias.
|
||||
@ -86,20 +96,28 @@ class views_handler_filter_combine extends views_handler_filter_string {
|
||||
}
|
||||
}
|
||||
|
||||
// By default things like op_equal uses add_where, that doesn't support
|
||||
// complex expressions, so override all operators.
|
||||
function op_equal($field) {
|
||||
/**
|
||||
* By default things like op_equal uses add_where, that doesn't support
|
||||
* complex expressions, so override all operators.
|
||||
*/
|
||||
public function op_equal($field) {
|
||||
$placeholder = $this->placeholder();
|
||||
$operator = $this->operator();
|
||||
$this->query->add_where_expression($this->options['group'], "$field $operator $placeholder", array($placeholder => $this->value));
|
||||
}
|
||||
|
||||
function op_contains($field) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function op_contains($field) {
|
||||
$placeholder = $this->placeholder();
|
||||
$this->query->add_where_expression($this->options['group'], "$field LIKE $placeholder", array($placeholder => '%' . db_like($this->value) . '%'));
|
||||
}
|
||||
|
||||
function op_word($field) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function op_word($field) {
|
||||
$where = $this->operator == 'word' ? db_or() : db_and();
|
||||
|
||||
// Don't filter on empty strings.
|
||||
@ -132,37 +150,58 @@ class views_handler_filter_combine extends views_handler_filter_string {
|
||||
$this->query->add_where($this->options['group'], $where);
|
||||
}
|
||||
|
||||
function op_starts($field) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function op_starts($field) {
|
||||
$placeholder = $this->placeholder();
|
||||
$this->query->add_where_expression($this->options['group'], "$field LIKE $placeholder", array($placeholder => db_like($this->value) . '%'));
|
||||
}
|
||||
|
||||
function op_not_starts($field) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function op_not_starts($field) {
|
||||
$placeholder = $this->placeholder();
|
||||
$this->query->add_where_expression($this->options['group'], "$field NOT LIKE $placeholder", array($placeholder => db_like($this->value) . '%'));
|
||||
}
|
||||
|
||||
function op_ends($field) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function op_ends($field) {
|
||||
$placeholder = $this->placeholder();
|
||||
$this->query->add_where_expression($this->options['group'], "$field LIKE $placeholder", array($placeholder => '%' . db_like($this->value)));
|
||||
}
|
||||
|
||||
function op_not_ends($field) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function op_not_ends($field) {
|
||||
$placeholder = $this->placeholder();
|
||||
$this->query->add_where_expression($this->options['group'], "$field NOT LIKE $placeholder", array($placeholder => '%' . db_like($this->value)));
|
||||
}
|
||||
|
||||
function op_not($field) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function op_not($field) {
|
||||
$placeholder = $this->placeholder();
|
||||
$this->query->add_where_expression($this->options['group'], "$field NOT LIKE $placeholder", array($placeholder => '%' . db_like($this->value) . '%'));
|
||||
}
|
||||
|
||||
function op_regex($field) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function op_regex($field) {
|
||||
$placeholder = $this->placeholder();
|
||||
$this->query->add_where_expression($this->options['group'], "$field RLIKE $placeholder", array($placeholder => $this->value));
|
||||
}
|
||||
|
||||
function op_empty($field) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function op_empty($field) {
|
||||
if ($this->operator == 'empty') {
|
||||
$operator = "IS NULL";
|
||||
}
|
||||
@ -172,4 +211,5 @@ class views_handler_filter_combine extends views_handler_filter_string {
|
||||
|
||||
$this->query->add_where_expression($this->options['group'], "$field $operator");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,19 +11,23 @@
|
||||
* @ingroup views_filter_handlers
|
||||
*/
|
||||
class views_handler_filter_date extends views_handler_filter_numeric {
|
||||
function option_definition() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
// value is already set up properly, we're just adding our new field to it.
|
||||
// Value is already set up properly, we're just adding our new field to it.
|
||||
$options['value']['contains']['type']['default'] = 'date';
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a type selector to the value form
|
||||
* Add a type selector to the value form.
|
||||
*/
|
||||
function value_form(&$form, &$form_state) {
|
||||
public function value_form(&$form, &$form_state) {
|
||||
if (empty($form_state['exposed'])) {
|
||||
$form['value']['type'] = array(
|
||||
'#type' => 'radios',
|
||||
@ -38,7 +42,10 @@ class views_handler_filter_date extends views_handler_filter_numeric {
|
||||
parent::value_form($form, $form_state);
|
||||
}
|
||||
|
||||
function options_validate(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_validate(&$form, &$form_state) {
|
||||
parent::options_validate($form, $form_state);
|
||||
|
||||
if (!empty($this->options['exposed']) && empty($form_state['values']['options']['expose']['required'])) {
|
||||
@ -49,7 +56,10 @@ class views_handler_filter_date extends views_handler_filter_numeric {
|
||||
$this->validate_valid_time($form['value'], $form_state['values']['options']['operator'], $form_state['values']['options']['value']);
|
||||
}
|
||||
|
||||
function exposed_validate(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function exposed_validate(&$form, &$form_state) {
|
||||
if (empty($this->options['exposed'])) {
|
||||
return;
|
||||
}
|
||||
@ -74,7 +84,7 @@ class views_handler_filter_date extends views_handler_filter_numeric {
|
||||
/**
|
||||
* Validate that the time values convert to something usable.
|
||||
*/
|
||||
function validate_valid_time(&$form, $operator, $value) {
|
||||
public function validate_valid_time(&$form, $operator, $value) {
|
||||
$operators = $this->operators();
|
||||
|
||||
if ($operators[$operator]['values'] == 1) {
|
||||
@ -98,7 +108,7 @@ class views_handler_filter_date extends views_handler_filter_numeric {
|
||||
/**
|
||||
* Validate the build group options form.
|
||||
*/
|
||||
function build_group_validate($form, &$form_state) {
|
||||
public function build_group_validate($form, &$form_state) {
|
||||
// Special case to validate grouped date filters, this is because the
|
||||
// $group['value'] array contains the type of filter (date or offset)
|
||||
// and therefore the number of items the comparission has to be done
|
||||
@ -122,8 +132,10 @@ class views_handler_filter_date extends views_handler_filter_numeric {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function accept_exposed_input($input) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function accept_exposed_input($input) {
|
||||
if (empty($this->options['exposed'])) {
|
||||
return TRUE;
|
||||
}
|
||||
@ -152,30 +164,39 @@ class views_handler_filter_date extends views_handler_filter_numeric {
|
||||
}
|
||||
}
|
||||
|
||||
// restore what got overwritten by the parent.
|
||||
// Restore what got overwritten by the parent.
|
||||
$this->value['type'] = $type;
|
||||
return $rc;
|
||||
}
|
||||
|
||||
function op_between($field) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function op_between($field) {
|
||||
// Use the substitutions to ensure a consistent timestamp.
|
||||
$query_substitutions = views_views_query_substitutions($this->view);
|
||||
$a = intval(strtotime($this->value['min'], $query_substitutions['***CURRENT_TIME***']));
|
||||
$b = intval(strtotime($this->value['max'], $query_substitutions['***CURRENT_TIME***']));
|
||||
|
||||
// This is safe because we are manually scrubbing the values.
|
||||
// It is necessary to do it this way because $a and $b are formulas when using an offset.
|
||||
// This is safe because we are manually scrubbing the values. It is
|
||||
// necessary to do it this way because $a and $b are formulas when using an
|
||||
// offset.
|
||||
$operator = strtoupper($this->operator);
|
||||
$this->query->add_where_expression($this->options['group'], "$field $operator $a AND $b");
|
||||
}
|
||||
|
||||
function op_simple($field) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function op_simple($field) {
|
||||
// Use the substitutions to ensure a consistent timestamp.
|
||||
$query_substitutions = views_views_query_substitutions($this->view);
|
||||
$value = intval(strtotime($this->value['value'], $query_substitutions['***CURRENT_TIME***']));
|
||||
|
||||
// This is safe because we are manually scrubbing the value.
|
||||
// It is necessary to do it this way because $value is a formula when using an offset.
|
||||
// This is safe because we are manually scrubbing the value. It is
|
||||
// necessary to do it this way because $value is a formula when using an
|
||||
// offset.
|
||||
$this->query->add_where_expression($this->options['group'], "$field $this->operator $value");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of views_handler_filter_entity_bundle
|
||||
* Definition of views_handler_filter_entity_bundle.
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -13,6 +13,7 @@
|
||||
* @ingroup views_filter_handlers
|
||||
*/
|
||||
class views_handler_filter_entity_bundle extends views_handler_filter_in_operator {
|
||||
|
||||
/**
|
||||
* Stores the entity type on which the filter filters.
|
||||
*
|
||||
@ -20,7 +21,10 @@ class views_handler_filter_entity_bundle extends views_handler_filter_in_operato
|
||||
*/
|
||||
public $entity_type;
|
||||
|
||||
function init(&$view, &$options) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init(&$view, &$options) {
|
||||
parent::init($view, $options);
|
||||
|
||||
$this->get_entity_type();
|
||||
@ -32,16 +36,17 @@ class views_handler_filter_entity_bundle extends views_handler_filter_in_operato
|
||||
* @return string
|
||||
* The entity type on the filter.
|
||||
*/
|
||||
function get_entity_type() {
|
||||
public function get_entity_type() {
|
||||
if (!isset($this->entity_type)) {
|
||||
$data = views_fetch_data($this->table);
|
||||
if (isset($data['table']['entity type'])) {
|
||||
$this->entity_type = $data['table']['entity type'];
|
||||
}
|
||||
|
||||
// If the current filter is under a relationship you can't be sure that the
|
||||
// entity type of the view is the entity type of the current filter
|
||||
// For example a filter from a node author on a node view does have users as entity type.
|
||||
// If the current filter is under a relationship you can't be sure that
|
||||
// the entity type of the view is the entity type of the current filter
|
||||
// For example a filter from a node author on a node view does have users
|
||||
// as entity type.
|
||||
if (!empty($this->options['relationship']) && $this->options['relationship'] != 'none') {
|
||||
$relationships = $this->view->display_handler->get_option('relationships');
|
||||
if (!empty($relationships[$this->options['relationship']])) {
|
||||
@ -55,8 +60,10 @@ class views_handler_filter_entity_bundle extends views_handler_filter_in_operato
|
||||
return $this->entity_type;
|
||||
}
|
||||
|
||||
|
||||
function get_value_options() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_value_options() {
|
||||
if (!isset($this->value_options)) {
|
||||
$info = entity_get_info($this->entity_type);
|
||||
$types = $info['bundles'];
|
||||
@ -76,7 +83,7 @@ class views_handler_filter_entity_bundle extends views_handler_filter_in_operato
|
||||
* bundle, though these two need an additional join to node/vocab table
|
||||
* to work as required.
|
||||
*/
|
||||
function query() {
|
||||
public function query() {
|
||||
$this->ensure_my_table();
|
||||
|
||||
// Adjust the join for the comment case.
|
||||
@ -119,4 +126,5 @@ class views_handler_filter_entity_bundle extends views_handler_filter_in_operato
|
||||
}
|
||||
parent::query();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,18 +6,21 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Simple filter to handle equal to / not equal to filters
|
||||
* Simple filter to handle equal to / not equal to filters.
|
||||
*
|
||||
* @ingroup views_filter_handlers
|
||||
*/
|
||||
class views_handler_filter_equality extends views_handler_filter {
|
||||
// exposed filter options
|
||||
var $always_multiple = TRUE;
|
||||
|
||||
/**
|
||||
* Provide simple equality operator
|
||||
* Exposed filter options.
|
||||
*/
|
||||
function operator_options() {
|
||||
public $always_multiple = TRUE;
|
||||
|
||||
/**
|
||||
* Provide simple equality operator.
|
||||
*/
|
||||
public function operator_options() {
|
||||
return array(
|
||||
'=' => t('Is equal to'),
|
||||
'!=' => t('Is not equal to'),
|
||||
@ -25,9 +28,9 @@ class views_handler_filter_equality extends views_handler_filter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a simple textfield for equality
|
||||
* Provide a simple textfield for equality.
|
||||
*/
|
||||
function value_form(&$form, &$form_state) {
|
||||
public function value_form(&$form, &$form_state) {
|
||||
$form['value'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Value'),
|
||||
@ -42,4 +45,5 @@ class views_handler_filter_equality extends views_handler_filter {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,17 +10,19 @@
|
||||
*
|
||||
* @ingroup views_filter_handlers
|
||||
*/
|
||||
|
||||
class views_handler_filter_fields_compare extends views_handler_filter {
|
||||
|
||||
function can_expose() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function can_expose() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides views_handler_filter#option_definition().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function option_definition() {
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['left_field'] = $options['right_field'] = array('default' => '');
|
||||
@ -31,21 +33,21 @@ class views_handler_filter_fields_compare extends views_handler_filter {
|
||||
/**
|
||||
* Provide a list of all operators.
|
||||
*/
|
||||
function fields_operator_options() {
|
||||
public function fields_operator_options() {
|
||||
return array(
|
||||
'<' => t('Is less than'),
|
||||
'<=' => t('Is less than or equal to'),
|
||||
'=' => t('Is equal to'),
|
||||
'<>' => t('Is not equal to'),
|
||||
'<>' => t('Is not equal to'),
|
||||
'>=' => t('Is greater than or equal to'),
|
||||
'>' => t('Is greater than')
|
||||
'>' => t('Is greater than'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a list of available fields.
|
||||
*/
|
||||
function field_options() {
|
||||
public function field_options() {
|
||||
$options = array();
|
||||
|
||||
$field_handlers = $this->view->display_handler->get_handlers('field');
|
||||
@ -59,9 +61,9 @@ class views_handler_filter_fields_compare extends views_handler_filter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides views_handler_filter#options_form().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
$field_options = $this->field_options();
|
||||
@ -93,11 +95,10 @@ class views_handler_filter_fields_compare extends views_handler_filter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides views_handler_filter#query().
|
||||
*
|
||||
* Build extra condition from existing fields (from existing joins).
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function query() {
|
||||
public function query() {
|
||||
// Build extra condition from existing fields (from existing joins).
|
||||
$left = $this->options['left_field'];
|
||||
$right = $this->options['right_field'];
|
||||
|
||||
@ -120,22 +121,21 @@ class views_handler_filter_fields_compare extends views_handler_filter {
|
||||
$right_table_alias = $this->query->ensure_table($right_handler->table, $right_handler->relationship);
|
||||
|
||||
// Build piece of SQL.
|
||||
$snippet =
|
||||
$left_table_alias . '.' . $left_handler->real_field .
|
||||
' ' . $this->options['operator'] . ' ' .
|
||||
$right_table_alias . '.' . $right_handler->real_field;
|
||||
$snippet = $left_table_alias . '.' . $left_handler->real_field
|
||||
. ' ' . $this->options['operator'] . ' '
|
||||
. $right_table_alias . '.' . $right_handler->real_field;
|
||||
|
||||
$this->query->add_where_expression($this->options['group'], $snippet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides views_handler_filter#admin_summary().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function admin_summary() {
|
||||
public function admin_summary() {
|
||||
return check_plain(
|
||||
$this->options['left_field'] . ' ' .
|
||||
$this->options['operator'] . ' ' .
|
||||
$this->options['right_field']
|
||||
$this->options['left_field'] . ' '
|
||||
. $this->options['operator'] . ' '
|
||||
. $this->options['right_field']
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,11 @@
|
||||
* @ingroup views_filter_handlers
|
||||
*/
|
||||
class views_handler_filter_group_by_numeric extends views_handler_filter_numeric {
|
||||
function query() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$this->ensure_my_table();
|
||||
$field = $this->get_field();
|
||||
|
||||
@ -20,7 +24,11 @@ class views_handler_filter_group_by_numeric extends views_handler_filter_numeric
|
||||
$this->{$info[$this->operator]['method']}($field);
|
||||
}
|
||||
}
|
||||
function op_between($field) {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function op_between($field) {
|
||||
$placeholder_min = $this->placeholder();
|
||||
$placeholder_max = $this->placeholder();
|
||||
if ($this->operator == 'between') {
|
||||
@ -32,12 +40,18 @@ class views_handler_filter_group_by_numeric extends views_handler_filter_numeric
|
||||
}
|
||||
}
|
||||
|
||||
function op_simple($field) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function op_simple($field) {
|
||||
$placeholder = $this->placeholder();
|
||||
$this->query->add_having_expression($this->options['group'], "$field $this->operator $placeholder", array($placeholder => $this->value['value']));
|
||||
}
|
||||
|
||||
function op_empty($field) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function op_empty($field) {
|
||||
if ($this->operator == 'empty') {
|
||||
$operator = "IS NULL";
|
||||
}
|
||||
@ -48,9 +62,18 @@ class views_handler_filter_group_by_numeric extends views_handler_filter_numeric
|
||||
$this->query->add_having_expression($this->options['group'], "$field $operator");
|
||||
}
|
||||
|
||||
function ui_name($short = FALSE) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function ui_name($short = FALSE) {
|
||||
return $this->get_field(parent::ui_name($short));
|
||||
}
|
||||
|
||||
function can_group() { return FALSE; }
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function can_group() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,24 +6,32 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Simple filter to handle matching of multiple options selectable via checkboxes
|
||||
* Simple filter to handle matching of multiple options using checkboxes.
|
||||
*
|
||||
* Definition items:
|
||||
* - options callback: The function to call in order to generate the value options. If omitted, the options 'Yes' and 'No' will be used.
|
||||
* - options callback: The function to call in order to generate the value
|
||||
* options. If omitted, the options 'Yes' and 'No' will be used.
|
||||
* - options arguments: An array of arguments to pass to the options callback.
|
||||
*
|
||||
* @ingroup views_filter_handlers
|
||||
*/
|
||||
class views_handler_filter_in_operator extends views_handler_filter {
|
||||
var $value_form_type = 'checkboxes';
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public $value_form_type = 'checkboxes';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* Stores all operations which are available on the form.
|
||||
*/
|
||||
var $value_options = NULL;
|
||||
public $value_options = NULL;
|
||||
|
||||
function construct() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function construct() {
|
||||
parent::construct();
|
||||
$this->value_title = t('Options');
|
||||
$this->value_options = NULL;
|
||||
@ -40,7 +48,7 @@ class views_handler_filter_in_operator extends views_handler_filter {
|
||||
* @return
|
||||
* Return the stored values in $this->value_options if someone expects it.
|
||||
*/
|
||||
function get_value_options() {
|
||||
public function get_value_options() {
|
||||
if (isset($this->value_options)) {
|
||||
return;
|
||||
}
|
||||
@ -60,22 +68,32 @@ class views_handler_filter_in_operator extends views_handler_filter {
|
||||
return $this->value_options;
|
||||
}
|
||||
|
||||
function expose_options() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function expose_options() {
|
||||
parent::expose_options();
|
||||
$this->options['expose']['reduce'] = FALSE;
|
||||
}
|
||||
|
||||
function expose_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function expose_form(&$form, &$form_state) {
|
||||
parent::expose_form($form, $form_state);
|
||||
$form['expose']['reduce'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Limit list to selected items'),
|
||||
'#description' => t('If checked, the only items presented to the user will be the ones selected here.'),
|
||||
'#default_value' => !empty($this->options['expose']['reduce']), // safety
|
||||
// Safety.
|
||||
'#default_value' => !empty($this->options['expose']['reduce']),
|
||||
);
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['operator']['default'] = 'in';
|
||||
@ -86,11 +104,11 @@ class views_handler_filter_in_operator extends views_handler_filter {
|
||||
}
|
||||
|
||||
/**
|
||||
* This kind of construct makes it relatively easy for a child class
|
||||
* to add or remove functionality by overriding this function and
|
||||
* adding/removing items from this array.
|
||||
* This kind of construct makes it relatively easy for a child class to add or
|
||||
* remove functionality by overriding this function and adding/removing items
|
||||
* from this array.
|
||||
*/
|
||||
function operators() {
|
||||
public function operators() {
|
||||
$operators = array(
|
||||
'in' => array(
|
||||
'title' => t('Is one of'),
|
||||
@ -129,9 +147,9 @@ class views_handler_filter_in_operator extends views_handler_filter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Build strings from the operators() for 'select' options
|
||||
* Build strings from the operators() for 'select' options.
|
||||
*/
|
||||
function operator_options($which = 'title') {
|
||||
public function operator_options($which = 'title') {
|
||||
$options = array();
|
||||
foreach ($this->operators() as $id => $info) {
|
||||
$options[$id] = $info[$which];
|
||||
@ -140,7 +158,10 @@ class views_handler_filter_in_operator extends views_handler_filter {
|
||||
return $options;
|
||||
}
|
||||
|
||||
function operator_values($values = 1) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function operator_values($values = 1) {
|
||||
$options = array();
|
||||
foreach ($this->operators() as $id => $info) {
|
||||
if (isset($info['values']) && $info['values'] == $values) {
|
||||
@ -151,7 +172,10 @@ class views_handler_filter_in_operator extends views_handler_filter {
|
||||
return $options;
|
||||
}
|
||||
|
||||
function value_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function value_form(&$form, &$form_state) {
|
||||
$form['value'] = array();
|
||||
$options = array();
|
||||
|
||||
@ -172,7 +196,7 @@ class views_handler_filter_in_operator extends views_handler_filter {
|
||||
$identifier = $this->options['expose']['identifier'];
|
||||
|
||||
if (empty($this->options['expose']['use_operator']) || empty($this->options['expose']['operator_id'])) {
|
||||
// exposed and locked.
|
||||
// Exposed and locked.
|
||||
$which = in_array($this->operator, $this->operator_values(1)) ? 'value' : 'none';
|
||||
}
|
||||
else {
|
||||
@ -229,7 +253,7 @@ class views_handler_filter_in_operator extends views_handler_filter {
|
||||
/**
|
||||
* When using exposed filters, we may be required to reduce the set.
|
||||
*/
|
||||
function reduce_value_options($input = NULL) {
|
||||
public function reduce_value_options($input = NULL) {
|
||||
if (!isset($input)) {
|
||||
$input = $this->value_options;
|
||||
}
|
||||
@ -257,9 +281,12 @@ class views_handler_filter_in_operator extends views_handler_filter {
|
||||
return $options;
|
||||
}
|
||||
|
||||
function accept_exposed_input($input) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function accept_exposed_input($input) {
|
||||
// A very special override because the All state for this type of
|
||||
// filter could have a default:
|
||||
// filter could have a default.
|
||||
if (empty($this->options['exposed'])) {
|
||||
return TRUE;
|
||||
}
|
||||
@ -276,7 +303,10 @@ class views_handler_filter_in_operator extends views_handler_filter {
|
||||
return parent::accept_exposed_input($input);
|
||||
}
|
||||
|
||||
function value_submit($form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function value_submit($form, &$form_state) {
|
||||
// Drupal's FAPI system automatically puts '0' in for any checkbox that
|
||||
// was not set, and the key to the checkbox if it is set.
|
||||
// Unfortunately, this means that if the key to that checkbox is 0,
|
||||
@ -289,7 +319,10 @@ class views_handler_filter_in_operator extends views_handler_filter {
|
||||
$form_state['values']['options']['value'] = $form['value']['#value'];
|
||||
}
|
||||
|
||||
function admin_summary() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function admin_summary() {
|
||||
if ($this->is_a_group()) {
|
||||
return t('grouped');
|
||||
}
|
||||
@ -317,7 +350,7 @@ class views_handler_filter_in_operator extends views_handler_filter {
|
||||
if (count($this->value) == 0) {
|
||||
$values = t('Unknown');
|
||||
}
|
||||
else if (count($this->value) == 1) {
|
||||
elseif (count($this->value) == 1) {
|
||||
// If any, use the 'single' short name of the operator instead.
|
||||
if (isset($info[$this->operator]['short_single'])) {
|
||||
$operator = check_plain($info[$this->operator]['short_single']);
|
||||
@ -351,14 +384,20 @@ class views_handler_filter_in_operator extends views_handler_filter {
|
||||
return $operator . (($values !== '') ? ' ' . $values : '');
|
||||
}
|
||||
|
||||
function query() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$info = $this->operators();
|
||||
if (!empty($info[$this->operator]['method'])) {
|
||||
$this->{$info[$this->operator]['method']}();
|
||||
}
|
||||
}
|
||||
|
||||
function op_simple() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function op_simple() {
|
||||
if (empty($this->value)) {
|
||||
return;
|
||||
}
|
||||
@ -369,7 +408,10 @@ class views_handler_filter_in_operator extends views_handler_filter {
|
||||
$this->query->add_where($this->options['group'], "$this->table_alias.$this->real_field", array_values($this->value), $this->operator);
|
||||
}
|
||||
|
||||
function op_empty() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function op_empty() {
|
||||
$this->ensure_my_table();
|
||||
if ($this->operator == 'empty') {
|
||||
$operator = "IS NULL";
|
||||
@ -381,7 +423,10 @@ class views_handler_filter_in_operator extends views_handler_filter {
|
||||
$this->query->add_where($this->options['group'], "$this->table_alias.$this->real_field", NULL, $operator);
|
||||
}
|
||||
|
||||
function validate() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validate() {
|
||||
$this->get_value_options();
|
||||
$errors = array();
|
||||
|
||||
@ -396,11 +441,13 @@ class views_handler_filter_in_operator extends views_handler_filter {
|
||||
}
|
||||
if (is_array($this->value)) {
|
||||
if (!isset($this->value_options)) {
|
||||
// Don't validate if there are none value options provided, for example for special handlers.
|
||||
// Don't validate if there are none value options provided, for example
|
||||
// for special handlers.
|
||||
return $errors;
|
||||
}
|
||||
if ($this->options['exposed'] && !$this->options['expose']['required'] && empty($this->value)) {
|
||||
// Don't validate if the field is exposed and no default value is provided.
|
||||
// Don't validate if the field is exposed and no default value is
|
||||
// provided.
|
||||
return $errors;
|
||||
}
|
||||
|
||||
@ -423,4 +470,5 @@ class views_handler_filter_in_operator extends views_handler_filter {
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,8 +6,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Complex filter to handle filtering for many to one relationships,
|
||||
* such as terms (many terms per node) or roles (many roles per user).
|
||||
* Complex filter to handle filtering for many to one relationships.
|
||||
*
|
||||
* Examples: terms (many terms per node), roles (many roles per user).
|
||||
*
|
||||
* The construct method needs to be overridden to provide a list of options;
|
||||
* alternately, the value_form and admin_summary methods need to be overriden
|
||||
@ -16,19 +17,31 @@
|
||||
* @ingroup views_filter_handlers
|
||||
*/
|
||||
class views_handler_filter_many_to_one extends views_handler_filter_in_operator {
|
||||
|
||||
/**
|
||||
* @var views_many_to_one_helper
|
||||
*
|
||||
* Stores the Helper object which handles the many_to_one complexity.
|
||||
*/
|
||||
var $helper = NULL;
|
||||
public $helper = NULL;
|
||||
|
||||
function init(&$view, &$options) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public $value_form_type = 'select';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init(&$view, &$options) {
|
||||
parent::init($view, $options);
|
||||
$this->helper = new views_many_to_one_helper($this);
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['operator']['default'] = 'or';
|
||||
@ -45,7 +58,10 @@ class views_handler_filter_many_to_one extends views_handler_filter_in_operator
|
||||
return $options;
|
||||
}
|
||||
|
||||
function operators() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function operators() {
|
||||
$operators = array(
|
||||
'or' => array(
|
||||
'title' => t('Is one of'),
|
||||
@ -93,8 +109,10 @@ class views_handler_filter_many_to_one extends views_handler_filter_in_operator
|
||||
return $operators;
|
||||
}
|
||||
|
||||
var $value_form_type = 'select';
|
||||
function value_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function value_form(&$form, &$form_state) {
|
||||
parent::value_form($form, $form_state);
|
||||
|
||||
if (empty($form_state['exposed'])) {
|
||||
@ -106,7 +124,7 @@ class views_handler_filter_many_to_one extends views_handler_filter_in_operator
|
||||
* 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() {
|
||||
// Defer to helper if the operator specifies it.
|
||||
$info = $this->operators();
|
||||
if (isset($info[$this->operator]['ensure_my_table']) && $info[$this->operator]['ensure_my_table'] == 'helper') {
|
||||
@ -116,10 +134,14 @@ class views_handler_filter_many_to_one extends views_handler_filter_in_operator
|
||||
return parent::ensure_my_table();
|
||||
}
|
||||
|
||||
function op_helper() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function op_helper() {
|
||||
if (empty($this->value)) {
|
||||
return;
|
||||
}
|
||||
$this->helper->add_filter();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,8 +11,16 @@
|
||||
* @ingroup views_filter_handlers
|
||||
*/
|
||||
class views_handler_filter_numeric extends views_handler_filter {
|
||||
var $always_multiple = TRUE;
|
||||
function option_definition() {
|
||||
|
||||
/**
|
||||
* Exposed filter options.
|
||||
*/
|
||||
public $always_multiple = TRUE;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['value'] = array(
|
||||
@ -26,7 +34,10 @@ class views_handler_filter_numeric extends views_handler_filter {
|
||||
return $options;
|
||||
}
|
||||
|
||||
function operators() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function operators() {
|
||||
$operators = array(
|
||||
'<' => array(
|
||||
'title' => t('Is less than'),
|
||||
@ -114,7 +125,7 @@ class views_handler_filter_numeric extends views_handler_filter {
|
||||
/**
|
||||
* Provide a list of all the numeric operators
|
||||
*/
|
||||
function operator_options($which = 'title') {
|
||||
public function operator_options($which = 'title') {
|
||||
$options = array();
|
||||
foreach ($this->operators() as $id => $info) {
|
||||
$options[$id] = $info[$which];
|
||||
@ -123,7 +134,10 @@ class views_handler_filter_numeric extends views_handler_filter {
|
||||
return $options;
|
||||
}
|
||||
|
||||
function operator_values($values = 1) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function operator_values($values = 1) {
|
||||
$options = array();
|
||||
foreach ($this->operators() as $id => $info) {
|
||||
if ($info['values'] == $values) {
|
||||
@ -133,10 +147,11 @@ class views_handler_filter_numeric extends views_handler_filter {
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a simple textfield for equality
|
||||
*/
|
||||
function value_form(&$form, &$form_state) {
|
||||
public function value_form(&$form, &$form_state) {
|
||||
$form['value']['#tree'] = TRUE;
|
||||
|
||||
// We have to make some choices when creating this as an exposed
|
||||
@ -223,7 +238,10 @@ class views_handler_filter_numeric extends views_handler_filter {
|
||||
}
|
||||
}
|
||||
|
||||
function query() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$this->ensure_my_table();
|
||||
$field = "$this->table_alias.$this->real_field";
|
||||
|
||||
@ -233,7 +251,10 @@ class views_handler_filter_numeric extends views_handler_filter {
|
||||
}
|
||||
}
|
||||
|
||||
function op_between($field) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function op_between($field) {
|
||||
if ($this->operator == 'between') {
|
||||
$this->query->add_where($this->options['group'], $field, array($this->value['min'], $this->value['max']), 'BETWEEN');
|
||||
}
|
||||
@ -242,11 +263,17 @@ class views_handler_filter_numeric extends views_handler_filter {
|
||||
}
|
||||
}
|
||||
|
||||
function op_simple($field) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function op_simple($field) {
|
||||
$this->query->add_where($this->options['group'], $field, $this->value['value'], $this->operator);
|
||||
}
|
||||
|
||||
function op_empty($field) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function op_empty($field) {
|
||||
if ($this->operator == 'empty') {
|
||||
$operator = "IS NULL";
|
||||
}
|
||||
@ -257,11 +284,17 @@ class views_handler_filter_numeric extends views_handler_filter {
|
||||
$this->query->add_where($this->options['group'], $field, NULL, $operator);
|
||||
}
|
||||
|
||||
function op_regex($field) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function op_regex($field) {
|
||||
$this->query->add_where($this->options['group'], $field, $this->value['value'], 'RLIKE');
|
||||
}
|
||||
|
||||
function admin_summary() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function admin_summary() {
|
||||
if ($this->is_a_group()) {
|
||||
return t('grouped');
|
||||
}
|
||||
@ -281,15 +314,15 @@ class views_handler_filter_numeric extends views_handler_filter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Do some minor translation of the exposed input
|
||||
* Do some minor translation of the exposed input.
|
||||
*/
|
||||
function accept_exposed_input($input) {
|
||||
public function accept_exposed_input($input) {
|
||||
if (empty($this->options['exposed'])) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// rewrite the input value so that it's in the correct format so that
|
||||
// the parent gets the right data.
|
||||
// Rewrite the input value so that it's in the correct format so that the
|
||||
// parent gets the right data.
|
||||
if (!empty($this->options['expose']['identifier'])) {
|
||||
$value = &$input[$this->options['expose']['identifier']];
|
||||
if (!is_array($value)) {
|
||||
@ -311,6 +344,7 @@ class views_handler_filter_numeric extends views_handler_filter {
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if ($value['min'] === '' && $value['max'] === '') {
|
||||
return FALSE;
|
||||
@ -322,4 +356,5 @@ class views_handler_filter_numeric extends views_handler_filter {
|
||||
|
||||
return $rc;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,10 +12,16 @@
|
||||
* @ingroup views_filter_handlers
|
||||
*/
|
||||
class views_handler_filter_string extends views_handler_filter {
|
||||
// exposed filter options
|
||||
var $always_multiple = TRUE;
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* Exposed filter options.
|
||||
*/
|
||||
public $always_multiple = TRUE;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['expose']['contains']['required'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
@ -24,11 +30,11 @@ class views_handler_filter_string extends views_handler_filter {
|
||||
}
|
||||
|
||||
/**
|
||||
* This kind of construct makes it relatively easy for a child class
|
||||
* to add or remove functionality by overriding this function and
|
||||
* adding/removing items from this array.
|
||||
* This kind of construct makes it relatively easy for a child class to add or
|
||||
* remove functionality by overriding this function and adding/removing items
|
||||
* from this array.
|
||||
*/
|
||||
function operators() {
|
||||
public function operators() {
|
||||
$operators = array(
|
||||
'=' => array(
|
||||
'title' => t('Is equal to'),
|
||||
@ -103,7 +109,7 @@ class views_handler_filter_string extends views_handler_filter {
|
||||
'values' => 1,
|
||||
),
|
||||
);
|
||||
// if the definition allows for the empty operator, add it.
|
||||
// If the definition allows for the empty operator, add it.
|
||||
if (!empty($this->definition['allow empty'])) {
|
||||
$operators += array(
|
||||
'empty' => array(
|
||||
@ -136,9 +142,9 @@ class views_handler_filter_string extends views_handler_filter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Build strings from the operators() for 'select' options
|
||||
* Build strings from the operators() for 'select' options.
|
||||
*/
|
||||
function operator_options($which = 'title') {
|
||||
public function operator_options($which = 'title') {
|
||||
$options = array();
|
||||
foreach ($this->operators() as $id => $info) {
|
||||
$options[$id] = $info[$which];
|
||||
@ -147,7 +153,10 @@ class views_handler_filter_string extends views_handler_filter {
|
||||
return $options;
|
||||
}
|
||||
|
||||
function admin_summary() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function admin_summary() {
|
||||
if ($this->is_a_group()) {
|
||||
return t('grouped');
|
||||
}
|
||||
@ -157,7 +166,7 @@ class views_handler_filter_string extends views_handler_filter {
|
||||
|
||||
$options = $this->operator_options('short');
|
||||
$output = '';
|
||||
if(!empty($options[$this->operator])) {
|
||||
if (!empty($options[$this->operator])) {
|
||||
$output = check_plain($options[$this->operator]);
|
||||
}
|
||||
if (in_array($this->operator, $this->operator_values(1))) {
|
||||
@ -166,7 +175,10 @@ class views_handler_filter_string extends views_handler_filter {
|
||||
return $output;
|
||||
}
|
||||
|
||||
function operator_values($values = 1) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function operator_values($values = 1) {
|
||||
$options = array();
|
||||
foreach ($this->operators() as $id => $info) {
|
||||
if (isset($info['values']) && $info['values'] == $values) {
|
||||
@ -178,13 +190,12 @@ class views_handler_filter_string extends views_handler_filter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a simple textfield for equality
|
||||
* Provide a simple textfield for equality.
|
||||
*/
|
||||
function value_form(&$form, &$form_state) {
|
||||
// We have to make some choices when creating this as an exposed
|
||||
// filter form. For example, if the operator is locked and thus
|
||||
// not rendered, we can't render dependencies; instead we only
|
||||
// render the form items we need.
|
||||
public function value_form(&$form, &$form_state) {
|
||||
// We have to make some choices when creating this as an exposed filter
|
||||
// form. For example, if the operator is locked and thus not rendered, we
|
||||
// can't render dependencies; instead we only render the form items we need.
|
||||
$which = 'all';
|
||||
if (!empty($form['operator'])) {
|
||||
$source = ($form['operator']['#type'] == 'radios') ? 'radio:options[operator]' : 'edit-options-operator';
|
||||
@ -223,23 +234,26 @@ class views_handler_filter_string extends views_handler_filter {
|
||||
// Ensure there is something in the 'value'.
|
||||
$form['value'] = array(
|
||||
'#type' => 'value',
|
||||
'#value' => NULL
|
||||
'#value' => NULL,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function operator() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function operator() {
|
||||
return $this->operator == '=' ? 'LIKE' : 'NOT LIKE';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add this filter to the query.
|
||||
*
|
||||
* Due to the nature of fapi, the value and the operator have an unintended
|
||||
* level of indirection. You will find them in $this->operator
|
||||
* and $this->value respectively.
|
||||
* Due to the nature of FAPI, the value and the operator have an unintended
|
||||
* level of indirection. You will find them in $this->operator and
|
||||
* $this->value respectively.
|
||||
*/
|
||||
function query() {
|
||||
public function query() {
|
||||
$this->ensure_my_table();
|
||||
$field = "$this->table_alias.$this->real_field";
|
||||
|
||||
@ -249,15 +263,24 @@ class views_handler_filter_string extends views_handler_filter {
|
||||
}
|
||||
}
|
||||
|
||||
function op_equal($field) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function op_equal($field) {
|
||||
$this->query->add_where($this->options['group'], $field, $this->value, $this->operator());
|
||||
}
|
||||
|
||||
function op_contains($field) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function op_contains($field) {
|
||||
$this->query->add_where($this->options['group'], $field, '%' . db_like($this->value) . '%', 'LIKE');
|
||||
}
|
||||
|
||||
function op_word($field) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function op_word($field) {
|
||||
$where = $this->operator == 'word' ? db_or() : db_and();
|
||||
|
||||
// Don't filter on empty strings.
|
||||
@ -267,11 +290,11 @@ class views_handler_filter_string extends views_handler_filter {
|
||||
|
||||
preg_match_all('/ (-?)("[^"]+"|[^" ]+)/i', ' ' . $this->value, $matches, PREG_SET_ORDER);
|
||||
foreach ($matches as $match) {
|
||||
$phrase = false;
|
||||
$phrase = FALSE;
|
||||
// Strip off phrase quotes
|
||||
if ($match[2]{0} == '"') {
|
||||
$match[2] = substr($match[2], 1, -1);
|
||||
$phrase = true;
|
||||
$phrase = TRUE;
|
||||
}
|
||||
$words = trim($match[2], ',?!();:-');
|
||||
$words = $phrase ? array($words) : preg_split('/ /', $words, -1, PREG_SPLIT_NO_EMPTY);
|
||||
@ -285,46 +308,73 @@ class views_handler_filter_string extends views_handler_filter {
|
||||
return;
|
||||
}
|
||||
|
||||
// previously this was a call_user_func_array but that's unnecessary
|
||||
// as views will unpack an array that is a single arg.
|
||||
// Previously this was a call_user_func_array but that's unnecessary as
|
||||
// Views will unpack an array that is a single arg.
|
||||
$this->query->add_where($this->options['group'], $where);
|
||||
}
|
||||
|
||||
function op_starts($field) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function op_starts($field) {
|
||||
$this->query->add_where($this->options['group'], $field, db_like($this->value) . '%', 'LIKE');
|
||||
}
|
||||
|
||||
function op_not_starts($field) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function op_not_starts($field) {
|
||||
$this->query->add_where($this->options['group'], $field, db_like($this->value) . '%', 'NOT LIKE');
|
||||
}
|
||||
|
||||
function op_ends($field) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function op_ends($field) {
|
||||
$this->query->add_where($this->options['group'], $field, '%' . db_like($this->value), 'LIKE');
|
||||
}
|
||||
|
||||
function op_not_ends($field) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function op_not_ends($field) {
|
||||
$this->query->add_where($this->options['group'], $field, '%' . db_like($this->value), 'NOT LIKE');
|
||||
}
|
||||
|
||||
function op_not($field) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function op_not($field) {
|
||||
$this->query->add_where($this->options['group'], $field, '%' . db_like($this->value) . '%', 'NOT LIKE');
|
||||
}
|
||||
|
||||
function op_shorter($field) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function op_shorter($field) {
|
||||
$placeholder = $this->placeholder();
|
||||
$this->query->add_where_expression($this->options['group'], "LENGTH($field) < $placeholder", array($placeholder => $this->value));
|
||||
}
|
||||
|
||||
function op_longer($field) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function op_longer($field) {
|
||||
$placeholder = $this->placeholder();
|
||||
$this->query->add_where_expression($this->options['group'], "LENGTH($field) > $placeholder", array($placeholder => $this->value));
|
||||
}
|
||||
|
||||
function op_regex($field) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function op_regex($field) {
|
||||
$this->query->add_where($this->options['group'], $field, $this->value, 'RLIKE');
|
||||
}
|
||||
|
||||
function op_empty($field) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function op_empty($field) {
|
||||
if ($this->operator == 'empty') {
|
||||
$operator = "IS NULL";
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Views' relationship handlers.
|
||||
* Definition of views_handler_relationship.
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -12,12 +12,11 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Simple relationship handler that allows a new version of the primary table
|
||||
* to be linked in.
|
||||
* Relationship handler, allows a new version of the primary table to be linked.
|
||||
*
|
||||
* The base relationship handler can only handle a single join. Some relationships
|
||||
* are more complex and might require chains of joins; for those, you must
|
||||
* utilize a custom relationship handler.
|
||||
* The base relationship handler can only handle a single join. Some
|
||||
* relationships are more complex and might require chains of joins; for those,
|
||||
* you must use a custom relationship handler.
|
||||
*
|
||||
* Definition items:
|
||||
* - base: The new base table this relationship will be adding. This does not
|
||||
@ -36,18 +35,18 @@
|
||||
* @ingroup views_relationship_handlers
|
||||
*/
|
||||
class views_handler_relationship extends views_handler {
|
||||
|
||||
/**
|
||||
* Init handler to let relationships live on tables other than
|
||||
* the table they operate on.
|
||||
* Let relationships live on tables other than the table they operate on.
|
||||
*/
|
||||
function init(&$view, &$options) {
|
||||
public function init(&$view, &$options) {
|
||||
parent::init($view, $options);
|
||||
if (isset($this->definition['relationship table'])) {
|
||||
$this->table = $this->definition['relationship table'];
|
||||
}
|
||||
if (isset($this->definition['relationship field'])) {
|
||||
// Set both real_field and field so custom handler
|
||||
// can rely on the old field value.
|
||||
// Set both real_field and field so custom handler can rely on the old
|
||||
// field value.
|
||||
$this->real_field = $this->field = $this->definition['relationship field'];
|
||||
}
|
||||
}
|
||||
@ -55,18 +54,22 @@ class views_handler_relationship extends views_handler {
|
||||
/**
|
||||
* Get this field's label.
|
||||
*/
|
||||
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();
|
||||
|
||||
|
||||
// Relationships definitions should define a default label, but if they aren't get another default value.
|
||||
// Relationships definitions should define a default label, but if they
|
||||
// aren't get another default value.
|
||||
if (!empty($this->definition['label'])) {
|
||||
$label = $this->definition['label'];
|
||||
}
|
||||
@ -81,10 +84,9 @@ class views_handler_relationship extends views_handler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Default options form that provides the label widget that all fields
|
||||
* should have.
|
||||
* Provide 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',
|
||||
@ -105,7 +107,7 @@ class views_handler_relationship extends views_handler {
|
||||
/**
|
||||
* Called to implement a relationship in a query.
|
||||
*/
|
||||
function query() {
|
||||
public function query() {
|
||||
// Figure out what base table this relationship brings to the party.
|
||||
$table_data = views_fetch_data($this->definition['base']);
|
||||
$base_field = empty($this->definition['base field']) ? $table_data['table']['base']['field'] : $this->definition['base field'];
|
||||
@ -126,7 +128,7 @@ class views_handler_relationship extends views_handler {
|
||||
}
|
||||
|
||||
if (!empty($def['join_handler']) && class_exists($def['join_handler'])) {
|
||||
$join = new $def['join_handler'];
|
||||
$join = new $def['join_handler']();
|
||||
}
|
||||
else {
|
||||
$join = new views_join();
|
||||
@ -137,7 +139,7 @@ class views_handler_relationship extends views_handler {
|
||||
$join->construct();
|
||||
$join->adjusted = TRUE;
|
||||
|
||||
// use a short alias for this:
|
||||
// Use a short alias for this.
|
||||
$alias = $def['table'] . '_' . $this->table;
|
||||
|
||||
$this->alias = $this->query->add_relationship($alias, $join, $this->definition['base'], $this->relationship);
|
||||
@ -152,9 +154,10 @@ class views_handler_relationship extends views_handler {
|
||||
/**
|
||||
* You can't groupby a relationship.
|
||||
*/
|
||||
function use_group_by() {
|
||||
public function use_group_by() {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -163,22 +166,44 @@ class views_handler_relationship extends views_handler {
|
||||
* @ingroup views_relationship_handlers
|
||||
*/
|
||||
class views_handler_relationship_broken extends views_handler_relationship {
|
||||
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() { /* No query to run */ }
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function ensure_my_table() {
|
||||
// No table to ensure!
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
// No query to run.
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
$form['markup'] = array(
|
||||
'#markup' => '<div class="form-item description">' . 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.') . '</div>',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the handler is considered 'broken'
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function broken() { return TRUE; }
|
||||
public function broken() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,11 +2,12 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Relationship for groupwise maximum handler.
|
||||
* Definition of views_handler_relationship_groupwise_max.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Relationship handler that allows a groupwise maximum of the linked in table.
|
||||
*
|
||||
* For a definition, see:
|
||||
* http://dev.mysql.com/doc/refman/5.0/en/example-maximum-column-group-row.html
|
||||
* In lay terms, instead of joining to get all matching records in the linked
|
||||
@ -58,7 +59,7 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi
|
||||
/**
|
||||
* Defines default values for options.
|
||||
*/
|
||||
function option_definition() {
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['subquery_sort'] = array('default' => NULL);
|
||||
@ -72,10 +73,11 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi
|
||||
}
|
||||
|
||||
/**
|
||||
* Extends the relationship's basic options, allowing the user to pick
|
||||
* a sort and an order for it.
|
||||
* Extends the relationship's basic options.
|
||||
*
|
||||
* Allows the user to pick a sort and an order for it.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
// Get the sorts that apply to our base.
|
||||
@ -92,7 +94,7 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi
|
||||
'#default_value' => !empty($this->options['subquery_sort']) ? $this->options['subquery_sort'] : $this->definition['base'] . '.' . $base_table_data['table']['base']['field'],
|
||||
'#options' => $sort_options,
|
||||
'#description' => theme('advanced_help_topic', array('module' => 'views', 'topic' => 'relationship-representative')) .
|
||||
t("The sort criteria is applied to the data brought in by the relationship to determine how a representative item is obtained for each row. For example, to show the most recent node for each user, pick 'Content: Updated date'."),
|
||||
t("The sort criteria is applied to the data brought in by the relationship to determine how a representative item is obtained for each row. For example, to show the most recent node for each user, pick 'Content: Updated date'."),
|
||||
);
|
||||
|
||||
$form['subquery_order'] = array(
|
||||
@ -110,8 +112,7 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi
|
||||
'#default_value' => $this->options['subquery_namespace'],
|
||||
);
|
||||
|
||||
|
||||
// WIP: This stuff doens't work yet: namespacing issues.
|
||||
// WIP: This stuff doesn't work yet: namespacing issues.
|
||||
// A list of suitable views to pick one as the subview.
|
||||
$views = array('' => '<none>');
|
||||
$all_views = views_get_all_views();
|
||||
@ -120,7 +121,7 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi
|
||||
// - base must the base that our relationship joins towards
|
||||
// - must have fields.
|
||||
if ($view->base_table == $this->definition['base'] && !empty($view->display['default']->display_options['fields'])) {
|
||||
// TODO: check the field is the correct sort?
|
||||
// @todo check the field is the correct sort?
|
||||
// or let users hang themselves at this stage and check later?
|
||||
if ($view->type == 'Default') {
|
||||
$views[t('Default Views')][$view->name] = $view->name;
|
||||
@ -152,10 +153,11 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi
|
||||
*
|
||||
* We use this to obtain our subquery SQL.
|
||||
*/
|
||||
function get_temporary_view() {
|
||||
public function get_temporary_view() {
|
||||
views_include('view');
|
||||
$view = new view();
|
||||
$view->vid = 'new'; // @todo: what's this?
|
||||
// @todo What's this?
|
||||
$view->vid = 'new';
|
||||
$view->base_table = $this->definition['base'];
|
||||
$view->add_display('default');
|
||||
return $view;
|
||||
@ -164,7 +166,7 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi
|
||||
/**
|
||||
* When the form is submitted, take sure to clear the subquery string cache.
|
||||
*/
|
||||
function options_form_submit(&$form, &$form_state) {
|
||||
public function options_form_submit(&$form, &$form_state) {
|
||||
$cid = 'views_relationship_groupwise_max:' . $this->view->name . ':' . $this->view->current_display . ':' . $this->options['id'];
|
||||
cache_clear_all($cid, 'cache_views_data');
|
||||
}
|
||||
@ -175,18 +177,19 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi
|
||||
* generate the subquery when the options are saved, rather than when the view
|
||||
* is run. This saves considerable time.
|
||||
*
|
||||
* @param $options
|
||||
* An array of options:
|
||||
* - subquery_sort: the id of a views sort.
|
||||
* - subquery_order: either ASC or DESC.
|
||||
* @return
|
||||
* @param array $options
|
||||
* An array of options that contains the following items:
|
||||
* - subquery_sort: the id of a views sort.
|
||||
* - subquery_order: either ASC or DESC.
|
||||
*
|
||||
* @return string
|
||||
* The subquery SQL string, ready for use in the main query.
|
||||
*/
|
||||
function left_query($options) {
|
||||
public function left_query($options) {
|
||||
// Either load another view, or create one on the fly.
|
||||
if ($options['subquery_view']) {
|
||||
$temp_view = views_get_view($options['subquery_view']);
|
||||
// Remove all fields from default display
|
||||
// Remove all fields from default display.
|
||||
unset($temp_view->display['default']->display_options['fields']);
|
||||
}
|
||||
else {
|
||||
@ -195,18 +198,14 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi
|
||||
$temp_view = $this->get_temporary_view();
|
||||
|
||||
// Add the sort from the options to the default display.
|
||||
// This is broken, in that the sort order field also gets added as a
|
||||
// select field. See http://drupal.org/node/844910.
|
||||
// We work around this further down.
|
||||
$sort = $options['subquery_sort'];
|
||||
list($sort_table, $sort_field) = explode('.', $sort);
|
||||
list($sort_table, $sort_field) = explode('.', $options['subquery_sort']);
|
||||
$sort_options = array('order' => $options['subquery_order']);
|
||||
$temp_view->add_item('default', 'sort', $sort_table, $sort_field, $sort_options);
|
||||
}
|
||||
|
||||
// Get the namespace string.
|
||||
$temp_view->namespace = (!empty($options['subquery_namespace'])) ? '_'. $options['subquery_namespace'] : '_INNER';
|
||||
$this->subquery_namespace = (!empty($options['subquery_namespace'])) ? '_'. $options['subquery_namespace'] : 'INNER';
|
||||
$temp_view->namespace = (!empty($options['subquery_namespace'])) ? '_' . $options['subquery_namespace'] : '_INNER';
|
||||
$this->subquery_namespace = (!empty($options['subquery_namespace'])) ? '_' . $options['subquery_namespace'] : 'INNER';
|
||||
|
||||
// The value we add here does nothing, but doing this adds the right tables
|
||||
// and puts in a WHERE clause with a placeholder we can grab later.
|
||||
@ -217,14 +216,16 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi
|
||||
$base_field = $views_data['table']['base']['field'];
|
||||
$temp_view->add_item('default', 'field', $this->definition['base'], $this->definition['field']);
|
||||
|
||||
// Add the correct argument for our relationship's base
|
||||
// ie the 'how to get back to base' argument.
|
||||
// The relationship definition tells us which one to use.
|
||||
// Add the correct argument for our relationship's base ie the "how to get
|
||||
// back to base" argument; the relationship definition defines which one to
|
||||
// use.
|
||||
$temp_view->add_item(
|
||||
'default',
|
||||
'argument',
|
||||
$this->definition['argument table'], // eg 'term_node',
|
||||
$this->definition['argument field'] // eg 'tid'
|
||||
// For example, 'term_node',
|
||||
$this->definition['argument table'],
|
||||
// For example, 'tid'.
|
||||
$this->definition['argument field']
|
||||
);
|
||||
|
||||
// Build the view. The creates the query object and produces the query
|
||||
@ -235,7 +236,7 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi
|
||||
// somewhat so we can get the SQL query from it.
|
||||
$subquery = $temp_view->build_info['query'];
|
||||
|
||||
// Workaround until http://drupal.org/node/844910 is fixed:
|
||||
// Workaround until http://drupal.org/node/844910 is fixed.
|
||||
// Remove all fields from the SELECT except the base id.
|
||||
$fields =& $subquery->getFields();
|
||||
foreach (array_keys($fields) as $field_name) {
|
||||
@ -245,8 +246,8 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi
|
||||
}
|
||||
}
|
||||
|
||||
// Make every alias in the subquery safe within the outer query by
|
||||
// appending a namespace to it, '_inner' by default.
|
||||
// Make every alias in the subquery safe within the outer query by appending
|
||||
// a namespace to it, '_inner' by default.
|
||||
$tables =& $subquery->getTables();
|
||||
foreach (array_keys($tables) as $table_name) {
|
||||
$tables[$table_name]['alias'] .= $this->subquery_namespace;
|
||||
@ -264,32 +265,49 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi
|
||||
$where =& $subquery->conditions();
|
||||
$this->alter_subquery_condition($subquery, $where);
|
||||
// Not sure why, but our sort order clause doesn't have a table.
|
||||
// TODO: the call to add_item() above to add the sort handler is probably
|
||||
// @todo The call to add_item() above to add the sort handler is probably
|
||||
// wrong -- needs attention from someone who understands it.
|
||||
// In the meantime, this works, but with a leap of faith...
|
||||
// In the meantime, this works, but with a leap of faith.
|
||||
$orders =& $subquery->getOrderBy();
|
||||
$orders_tmp = array();
|
||||
foreach ($orders as $order_key => $order) {
|
||||
// But if we're using a whole view, we don't know what we have!
|
||||
if ($options['subquery_view']) {
|
||||
list($sort_table, $sort_field) = explode('.', $order_key);
|
||||
}
|
||||
$orders[$sort_table . $this->subquery_namespace . '.' . $sort_field] = $order;
|
||||
unset($orders[$order_key]);
|
||||
// Until http://drupal.org/node/844910 is fixed, $order_key is a field
|
||||
// alias from SELECT. De-alias it using the View object.
|
||||
$sort_table = $temp_view->query->fields[$order_key]['table'];
|
||||
$sort_field = $temp_view->query->fields[$order_key]['field'];
|
||||
$orders_tmp[$sort_table . $this->subquery_namespace . '.' . $sort_field] = $order;
|
||||
}
|
||||
$orders = $orders_tmp;
|
||||
|
||||
// The query we get doesn't include the LIMIT, so add it here.
|
||||
$subquery->range(0, 1);
|
||||
// Clone the query object to force recompilation of the underlying where and
|
||||
// having objects on the next step.
|
||||
$subquery = clone $subquery;
|
||||
|
||||
// Add in Views Query Substitutions such as ***CURRENT_TIME***.
|
||||
views_query_views_alter($subquery);
|
||||
|
||||
// Extract the SQL the temporary view built.
|
||||
$subquery_sql = $subquery->__toString();
|
||||
|
||||
// Replace the placeholder with the outer, correlated field.
|
||||
// Eg, change the placeholder ':users_uid' into the outer field 'users.uid'.
|
||||
// We have to work directly with the SQL, because putting a name of a field
|
||||
// into a SelectQuery that it does not recognize (because it's outer) just
|
||||
// makes it treat it as a string.
|
||||
$outer_placeholder = ':' . str_replace('.', '_', $this->definition['outer field']);
|
||||
$subquery_sql = str_replace($outer_placeholder, $this->definition['outer field'], $subquery_sql);
|
||||
// Replace subquery argument placeholders.
|
||||
$quoted = $subquery->getArguments();
|
||||
$connection = Database::getConnection();
|
||||
foreach ($quoted as $key => $val) {
|
||||
if (is_array($val)) {
|
||||
$quoted[$key] = implode(', ', array_map(array($connection, 'quote'), $val));
|
||||
}
|
||||
// If the correlated placeholder has been located, replace it with the
|
||||
// outer field name.
|
||||
elseif ($val === '**CORRELATED**') {
|
||||
$quoted[$key] = $this->definition['outer field'];
|
||||
}
|
||||
else {
|
||||
$quoted[$key] = $connection->quote($val);
|
||||
}
|
||||
}
|
||||
$subquery_sql = strtr($subquery_sql, $quoted);
|
||||
|
||||
return $subquery_sql;
|
||||
}
|
||||
@ -301,7 +319,7 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi
|
||||
*
|
||||
* (Though why is the condition we get in a simple query 3 levels deep???)
|
||||
*/
|
||||
function alter_subquery_condition(QueryAlterableInterface $query, &$conditions) {
|
||||
public function alter_subquery_condition(QueryAlterableInterface $query, &$conditions) {
|
||||
foreach ($conditions as $condition_id => &$condition) {
|
||||
// Skip the #conjunction element.
|
||||
if (is_numeric($condition_id)) {
|
||||
@ -321,7 +339,7 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi
|
||||
*
|
||||
* Turns 'foo.bar' into 'foo_NAMESPACE.bar'.
|
||||
*/
|
||||
function condition_namespace($string) {
|
||||
public function condition_namespace($string) {
|
||||
return str_replace('.', $this->subquery_namespace . '.', $string);
|
||||
}
|
||||
|
||||
@ -330,7 +348,7 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi
|
||||
* This is mostly a copy of our parent's query() except for this bit with
|
||||
* the join class.
|
||||
*/
|
||||
function query() {
|
||||
public function query() {
|
||||
// Figure out what base table this relationship brings to the party.
|
||||
$table_data = views_fetch_data($this->definition['base']);
|
||||
$base_field = empty($this->definition['base field']) ? $table_data['table']['base']['field'] : $this->definition['base field'];
|
||||
@ -374,9 +392,10 @@ class views_handler_relationship_groupwise_max extends views_handler_relationshi
|
||||
$join->construct();
|
||||
$join->adjusted = TRUE;
|
||||
|
||||
// use a short alias for this:
|
||||
// Use a short alias for this.
|
||||
$alias = $def['table'] . '_' . $this->table;
|
||||
|
||||
$this->alias = $this->query->add_relationship($alias, $join, $this->definition['base'], $this->relationship);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @todo.
|
||||
* Definition of views_handler_sort.
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -21,18 +21,23 @@ class views_handler_sort extends views_handler {
|
||||
/**
|
||||
* Determine if a sort can be exposed.
|
||||
*/
|
||||
function can_expose() { return TRUE; }
|
||||
public function can_expose() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to add the sort to a query.
|
||||
*/
|
||||
function query() {
|
||||
public function query() {
|
||||
$this->ensure_my_table();
|
||||
// Add the field.
|
||||
$this->query->add_orderby($this->table_alias, $this->real_field, $this->options['order']);
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['order'] = array('default' => 'ASC');
|
||||
@ -48,7 +53,7 @@ class views_handler_sort extends views_handler {
|
||||
/**
|
||||
* Display whether or not the sort order is ascending or descending
|
||||
*/
|
||||
function admin_summary() {
|
||||
public function admin_summary() {
|
||||
if (!empty($this->options['exposed'])) {
|
||||
return t('Exposed');
|
||||
}
|
||||
@ -57,18 +62,17 @@ class views_handler_sort extends views_handler {
|
||||
case 'asc':
|
||||
default:
|
||||
return t('asc');
|
||||
break;
|
||||
|
||||
case 'DESC';
|
||||
case 'desc';
|
||||
return t('desc');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic options for all sort criteria
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
if ($this->can_expose()) {
|
||||
$this->show_expose_button($form, $form_state);
|
||||
@ -84,11 +88,11 @@ class views_handler_sort extends views_handler {
|
||||
/**
|
||||
* Shortcut to display the expose/hide button.
|
||||
*/
|
||||
function show_expose_button(&$form, &$form_state) {
|
||||
public function show_expose_button(&$form, &$form_state) {
|
||||
$form['expose_button'] = array(
|
||||
'#prefix' => '<div class="views-expose clearfix">',
|
||||
'#suffix' => '</div>',
|
||||
// Should always come first
|
||||
// Should always come first.
|
||||
'#weight' => -1000,
|
||||
);
|
||||
|
||||
@ -131,9 +135,9 @@ class views_handler_sort extends views_handler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple validate handler
|
||||
* Simple validate handler.
|
||||
*/
|
||||
function options_validate(&$form, &$form_state) {
|
||||
public function options_validate(&$form, &$form_state) {
|
||||
$this->sort_validate($form, $form_state);
|
||||
if (!empty($this->options['exposed'])) {
|
||||
$this->expose_validate($form, $form_state);
|
||||
@ -142,10 +146,12 @@ class views_handler_sort extends views_handler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple submit handler
|
||||
* Simple submit handler.
|
||||
*/
|
||||
function options_submit(&$form, &$form_state) {
|
||||
unset($form_state['values']['expose_button']); // don't store this.
|
||||
public function options_submit(&$form, &$form_state) {
|
||||
// Don't store this.
|
||||
unset($form_state['values']['expose_button']);
|
||||
|
||||
$this->sort_submit($form, $form_state);
|
||||
if (!empty($this->options['exposed'])) {
|
||||
$this->expose_submit($form, $form_state);
|
||||
@ -155,7 +161,7 @@ class views_handler_sort extends views_handler {
|
||||
/**
|
||||
* Shortcut to display the value form.
|
||||
*/
|
||||
function show_sort_form(&$form, &$form_state) {
|
||||
public function show_sort_form(&$form, &$form_state) {
|
||||
$options = $this->sort_options();
|
||||
if (!empty($options)) {
|
||||
$form['order'] = array(
|
||||
@ -166,22 +172,34 @@ class views_handler_sort extends views_handler {
|
||||
}
|
||||
}
|
||||
|
||||
function sort_validate(&$form, &$form_state) { }
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function sort_validate(&$form, &$form_state) {
|
||||
}
|
||||
|
||||
function sort_submit(&$form, &$form_state) { }
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function sort_submit(&$form, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a list of options for the default sort form.
|
||||
* Should be overridden by classes that don't override sort_form
|
||||
*
|
||||
* Should be overridden by classes that don't override sort_form.
|
||||
*/
|
||||
function sort_options() {
|
||||
public function sort_options() {
|
||||
return array(
|
||||
'ASC' => t('Sort ascending'),
|
||||
'DESC' => t('Sort descending'),
|
||||
);
|
||||
}
|
||||
|
||||
function expose_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function expose_form(&$form, &$form_state) {
|
||||
// #flatten will move everything from $form['expose'][$key] to $form[$key]
|
||||
// prior to rendering. That's why the pre_render for it needs to run first,
|
||||
// so that when the next pre_render (the one for fieldsets) runs, it gets
|
||||
@ -196,18 +214,19 @@ class views_handler_sort extends views_handler {
|
||||
'#required' => TRUE,
|
||||
'#size' => 40,
|
||||
'#weight' => -1,
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide default options for exposed sorts.
|
||||
*/
|
||||
function expose_options() {
|
||||
public function expose_options() {
|
||||
$this->options['expose'] = array(
|
||||
'order' => $this->options['order'],
|
||||
'label' => $this->definition['title'],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -216,22 +235,44 @@ class views_handler_sort extends views_handler {
|
||||
* @ingroup views_sort_handlers
|
||||
*/
|
||||
class views_handler_sort_broken extends views_handler_sort {
|
||||
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' => '<div class="form-item description">' . 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.') . '</div>',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the handler is considered 'broken'
|
||||
* Determine if the handler is considered 'broken'.
|
||||
*/
|
||||
function broken() { return TRUE; }
|
||||
public function broken() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,7 +14,11 @@
|
||||
* @ingroup views_sort_handlers
|
||||
*/
|
||||
class views_handler_sort_date extends views_handler_sort {
|
||||
function option_definition() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['granularity'] = array('default' => 'second');
|
||||
@ -22,7 +26,10 @@ class views_handler_sort_date extends views_handler_sort {
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
$form['granularity'] = array(
|
||||
@ -42,27 +49,32 @@ class views_handler_sort_date extends views_handler_sort {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to add the sort to a query.
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function query() {
|
||||
public function query() {
|
||||
$this->ensure_my_table();
|
||||
switch ($this->options['granularity']) {
|
||||
case 'second':
|
||||
default:
|
||||
$this->query->add_orderby($this->table_alias, $this->real_field, $this->options['order']);
|
||||
return;
|
||||
|
||||
case 'minute':
|
||||
$formula = views_date_sql_format('YmdHi', "$this->table_alias.$this->real_field");
|
||||
break;
|
||||
|
||||
case 'hour':
|
||||
$formula = views_date_sql_format('YmdH', "$this->table_alias.$this->real_field");
|
||||
break;
|
||||
|
||||
case 'day':
|
||||
$formula = views_date_sql_format('Ymd', "$this->table_alias.$this->real_field");
|
||||
break;
|
||||
|
||||
case 'month':
|
||||
$formula = views_date_sql_format('Ym', "$this->table_alias.$this->real_field");
|
||||
break;
|
||||
|
||||
case 'year':
|
||||
$formula = views_date_sql_format('Y', "$this->table_alias.$this->real_field");
|
||||
break;
|
||||
@ -71,4 +83,5 @@ class views_handler_sort_date extends views_handler_sort {
|
||||
// Add the field.
|
||||
$this->query->add_orderby(NULL, $formula, $this->options['order'], $this->table_alias . '_' . $this->field . '_' . $this->options['granularity']);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,11 @@
|
||||
* @ingroup views_sort_handlers
|
||||
*/
|
||||
class views_handler_sort_group_by_numeric extends views_handler_sort {
|
||||
function init(&$view, &$options) {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init(&$view, &$options) {
|
||||
parent::init($view, $options);
|
||||
|
||||
// Initialize the original handler.
|
||||
@ -20,9 +24,9 @@ class views_handler_sort_group_by_numeric extends views_handler_sort {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to add the field to a query.
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function query() {
|
||||
public function query() {
|
||||
$this->ensure_my_table();
|
||||
|
||||
$params = array(
|
||||
@ -32,7 +36,11 @@ class views_handler_sort_group_by_numeric extends views_handler_sort {
|
||||
$this->query->add_orderby($this->table_alias, $this->real_field, $this->options['order'], NULL, $params);
|
||||
}
|
||||
|
||||
function ui_name($short = FALSE) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function ui_name($short = FALSE) {
|
||||
return $this->get_field(parent::ui_name($short));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,13 +17,20 @@
|
||||
* @ingroup views_sort_handlers
|
||||
*/
|
||||
class views_handler_sort_menu_hierarchy extends views_handler_sort {
|
||||
function option_definition() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['sort_within_level'] = array('default' => FALSE);
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$form['sort_within_level'] = array(
|
||||
'#type' => 'checkbox',
|
||||
@ -33,7 +40,10 @@ class views_handler_sort_menu_hierarchy extends views_handler_sort {
|
||||
);
|
||||
}
|
||||
|
||||
function query() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$this->ensure_my_table();
|
||||
$max_depth = isset($this->definition['max depth']) ? $this->definition['max depth'] : MENU_MAX_DEPTH;
|
||||
for ($i = 1; $i <= $max_depth; ++$i) {
|
||||
@ -51,4 +61,5 @@ class views_handler_sort_menu_hierarchy extends views_handler_sort {
|
||||
$this->query->add_orderby($this->table_alias, $this->field . $i, $this->options['order']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,12 +11,20 @@
|
||||
* @ingroup views_sort_handlers
|
||||
*/
|
||||
class views_handler_sort_random extends views_handler_sort {
|
||||
function query() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$this->query->add_orderby('rand');
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
$form['order']['#access'] = FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,8 +4,9 @@ As a consequence, it *always* thinks the value was submitted, even if it was not
|
||||
|
||||
<pre>
|
||||
<?php
|
||||
if (empty($form_state['view']->exposed_input[$identifier])) .
|
||||
{ $form_state['input'][$identifier] = $default_value; }
|
||||
if (empty($form_state['view']->exposed_input[$identifier])) {
|
||||
$form_state['input'][$identifier] = $default_value;
|
||||
}
|
||||
?>
|
||||
</pre>
|
||||
|
||||
@ -18,10 +19,10 @@ To do this, I used the following function, where geoip_redirect_get_tid() loads
|
||||
<pre>
|
||||
<?php
|
||||
function MODULENAME_form_views_exposed_form_alter(&$form, $form_state) {
|
||||
if(strpos($form['#id'], 'volunteer-directory') !== FALSE) {
|
||||
if (strpos($form['#id'], 'volunteer-directory') !== FALSE) {
|
||||
$city_tid = geoip_redirect_get_tid();
|
||||
if(is_numeric($city_tid) && $city_tid != 7660) {
|
||||
if (empty($form_state['view']->exposed_input['tid'])) {
|
||||
if (is_numeric($city_tid) && $city_tid != 7660) {
|
||||
if (empty($form_state['view']->exposed_input['tid'])) {
|
||||
$form_state['input']['tid'] = $city_tid;
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ Below is the contents of a simple node_example.views.inc file that allows you to
|
||||
* @endcode
|
||||
*/
|
||||
|
||||
function node_example_views_data() {
|
||||
function node_example_views_data() {
|
||||
// Basic table information.
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
@ -169,8 +169,10 @@ Each field is described in the view data with an array, keyed to the database na
|
||||
|
||||
<pre>
|
||||
$data['node']['nid'] = array(
|
||||
// The item it appears as on the UI,
|
||||
'title' => t('Nid'),
|
||||
'help' => t('The node ID of the node.'), // The help that appears on the UI,
|
||||
// The help that appears on the UI,
|
||||
'help' => t('The node ID of the node.'),
|
||||
// Information for displaying the nid
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_node',
|
||||
@ -179,7 +181,8 @@ $data['node']['nid'] = array(
|
||||
// Information for accepting a nid as an argument
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_node_nid',
|
||||
'name field' => 'title', // the field to display in the summary.
|
||||
// The field to display in the summary.
|
||||
'name field' => 'title',
|
||||
'numeric' => TRUE,
|
||||
'validate type' => 'nid',
|
||||
),
|
||||
|
@ -113,9 +113,9 @@ The views_handler class got two new functions:
|
||||
/**
|
||||
* Get the value that's supposed to be rendered.
|
||||
*
|
||||
* @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) {
|
||||
@ -128,9 +128,9 @@ function get_value($values, $field = NULL) {
|
||||
/**
|
||||
* Sanitize the value for output.
|
||||
*
|
||||
* @param $value
|
||||
* @param string $value
|
||||
* The value being rendered.
|
||||
* @param $type
|
||||
* @param string $type
|
||||
* The type of sanitization needed. If not provided, check_plain() is used.
|
||||
*/
|
||||
function sanitize_value($value, $type = NULL) {
|
||||
@ -138,9 +138,11 @@ function sanitize_value($value, $type = NULL) {
|
||||
case 'xss':
|
||||
$value = filter_xss($value);
|
||||
break;
|
||||
|
||||
case 'url':
|
||||
$value = check_url($value);
|
||||
break;
|
||||
|
||||
default:
|
||||
$value = check_plain($value);
|
||||
break;
|
||||
|
@ -10,9 +10,9 @@ easiest way is to use the function <strong>views_embed_view()</strong>:
|
||||
* solution and doesn't really offer a lot of options, but breaking the function
|
||||
* apart is pretty easy, and this provides a worthwhile guide to doing so.
|
||||
*
|
||||
* @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 ...
|
||||
|
@ -13,7 +13,7 @@ This section originally stems from <a href="http://drupal.org/node/346662">this
|
||||
Some modules may add PHP improperly, disrupting normal jQuery operation. Errors may look like
|
||||
|
||||
<code>
|
||||
<? session_module_name("files"); ?>{ "default": "default" }
|
||||
<?php session_module_name("files"); ?>{ "default": "default" }
|
||||
</code>
|
||||
|
||||
This can also be a server configuration issue. In one case, this was solved by commenting out
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -25,7 +25,8 @@ function views_ajax() {
|
||||
|
||||
$commands = array();
|
||||
|
||||
// Remove all of this stuff from $_GET so it doesn't end up in pagers and tablesort URLs.
|
||||
// Remove all of this stuff from $_GET so it doesn't end up in pagers and
|
||||
// tablesort URLs.
|
||||
foreach (array('view_name', 'view_display_id', 'view_args', 'view_path', 'view_dom_id', 'pager_element', 'view_base_path', 'ajax_html_ids', 'ajax_page_state') as $key) {
|
||||
if (isset($_GET[$key])) {
|
||||
unset($_GET[$key]);
|
||||
@ -40,17 +41,17 @@ function views_ajax() {
|
||||
|
||||
// Load the view.
|
||||
$view = views_get_view($name);
|
||||
if ($view && $view->access($display_id)) {
|
||||
if ($view && $view->access($display_id) && $view->set_display($display_id) && $view->display_handler->use_ajax()) {
|
||||
// Fix 'q' for paging.
|
||||
if (!empty($path)) {
|
||||
$_GET['q'] = $path;
|
||||
}
|
||||
|
||||
// If page parameter is in the $_POST exclude it from $_GET,
|
||||
// otherwise support views_ajax requests using $_GET.
|
||||
// If page parameter is in the $_POST exclude it from $_GET, otherwise
|
||||
// support views_ajax requests using $_GET.
|
||||
$exclude = isset($_POST['page']) ? array('page') : array();
|
||||
// Add all $_POST data to $_GET as many things,
|
||||
// such as tablesorts, exposed filters and paging assume $_GET.
|
||||
// Add all $_POST data to $_GET as many things, such as tablesorts,
|
||||
// exposed filters and paging assume $_GET.
|
||||
$_GET = $_POST + drupal_get_query_parameters($_GET, $exclude);
|
||||
|
||||
// Overwrite the destination.
|
||||
@ -81,14 +82,14 @@ function views_ajax() {
|
||||
/**
|
||||
* Creates a Drupal AJAX 'viewsSetForm' command.
|
||||
*
|
||||
* @param $output
|
||||
* @param string $output
|
||||
* The form to display in the modal.
|
||||
* @param $title
|
||||
* @param string $title
|
||||
* The title.
|
||||
* @param $url
|
||||
* @param string $url
|
||||
* An optional URL.
|
||||
*
|
||||
* @return
|
||||
* @return array
|
||||
* An array suitable for use with the ajax_render() function.
|
||||
*/
|
||||
function views_ajax_command_set_form($output, $title, $url = NULL) {
|
||||
@ -106,7 +107,7 @@ function views_ajax_command_set_form($output, $title, $url = NULL) {
|
||||
/**
|
||||
* Creates a Drupal AJAX 'viewsDismissForm' command.
|
||||
*
|
||||
* @return
|
||||
* @return array
|
||||
* An array suitable for use with the ajax_render() function.
|
||||
*/
|
||||
function views_ajax_command_dismiss_form() {
|
||||
@ -119,8 +120,8 @@ function views_ajax_command_dismiss_form() {
|
||||
/**
|
||||
* Creates a Drupal AJAX 'viewsHilite' command.
|
||||
*
|
||||
* @param $selector
|
||||
* The selector to highlight
|
||||
* @param string $selector
|
||||
* The selector to highlight.
|
||||
*
|
||||
* @return
|
||||
* An array suitable for use with the ajax_render() function.
|
||||
@ -135,14 +136,14 @@ function views_ajax_command_hilite($selector) {
|
||||
/**
|
||||
* Creates a Drupal AJAX 'addTab' command.
|
||||
*
|
||||
* @param $id
|
||||
* @param string $id
|
||||
* The DOM ID.
|
||||
* @param $title
|
||||
* @param string $title
|
||||
* The title.
|
||||
* @param $body
|
||||
* @param string $body
|
||||
* The body.
|
||||
*
|
||||
* @return
|
||||
* @return array
|
||||
* An array suitable for use with the ajax_render() function.
|
||||
*/
|
||||
function views_ajax_command_add_tab($id, $title, $body) {
|
||||
@ -158,7 +159,7 @@ function views_ajax_command_add_tab($id, $title, $body) {
|
||||
/**
|
||||
* Scroll to top of the current view.
|
||||
*
|
||||
* @return
|
||||
* @return array
|
||||
* An array suitable for use with the ajax_render() function.
|
||||
*/
|
||||
function views_ajax_command_scroll_top($selector) {
|
||||
@ -175,7 +176,7 @@ function views_ajax_command_scroll_top($selector) {
|
||||
* @param bool $changed
|
||||
* Whether of not the view has changed.
|
||||
*
|
||||
* @return
|
||||
* @return array
|
||||
* An array suitable for use with the ajax_render() function.
|
||||
*/
|
||||
function views_ajax_command_show_buttons($changed) {
|
||||
@ -189,7 +190,7 @@ function views_ajax_command_show_buttons($changed) {
|
||||
/**
|
||||
* Trigger the Views live preview.
|
||||
*
|
||||
* @return
|
||||
* @return array
|
||||
* An array suitable for use with the ajax_render() function.
|
||||
*/
|
||||
function views_ajax_command_trigger_preview() {
|
||||
@ -202,7 +203,7 @@ function views_ajax_command_trigger_preview() {
|
||||
/**
|
||||
* Replace the page title.
|
||||
*
|
||||
* @return
|
||||
* @return array
|
||||
* An array suitable for use with the ajax_render() function.
|
||||
*/
|
||||
function views_ajax_command_replace_title($title) {
|
||||
@ -216,6 +217,12 @@ function views_ajax_command_replace_title($title) {
|
||||
|
||||
/**
|
||||
* Return an AJAX error.
|
||||
*
|
||||
* @param string $message
|
||||
* The message to display.
|
||||
*
|
||||
* @return array
|
||||
* An array suitable for use with the ajax_render() function.
|
||||
*/
|
||||
function views_ajax_error($message) {
|
||||
$commands = array();
|
||||
@ -225,6 +232,7 @@ function views_ajax_error($message) {
|
||||
|
||||
/**
|
||||
* Wrapper around drupal_build_form to handle some AJAX stuff automatically.
|
||||
*
|
||||
* This makes some assumptions about the client.
|
||||
*/
|
||||
function views_ajax_form_wrapper($form_id, &$form_state) {
|
||||
@ -243,15 +251,15 @@ function views_ajax_form_wrapper($form_id, &$form_state) {
|
||||
$form = drupal_build_form($form_id, $form_state);
|
||||
$output = drupal_render($form);
|
||||
|
||||
// These forms have the title built in, so set the title here:
|
||||
// These forms have the title built in, so set the title here.
|
||||
if (empty($form_state['ajax']) && !empty($form_state['title'])) {
|
||||
drupal_set_title($form_state['title']);
|
||||
drupal_add_css(drupal_get_path('module', 'views_ui') . '/css/views-admin.css');
|
||||
}
|
||||
|
||||
if (!empty($form_state['ajax']) && (empty($form_state['executed']) || !empty($form_state['rerender']))) {
|
||||
// If the form didn't execute and we're using ajax, build up a
|
||||
// Ajax command list to execute.
|
||||
// If the form didn't execute and we're using ajax, build up a AJAX command
|
||||
// list to execute.
|
||||
$commands = array();
|
||||
|
||||
$display = '';
|
||||
@ -279,7 +287,7 @@ function views_ajax_form_wrapper($form_id, &$form_state) {
|
||||
return $commands;
|
||||
}
|
||||
|
||||
// These forms have the title built in, so set the title here:
|
||||
// These forms have the title built in, so set the title here.
|
||||
if (empty($form_state['ajax']) && !empty($form_state['title'])) {
|
||||
drupal_set_title($form_state['title']);
|
||||
}
|
||||
@ -289,13 +297,14 @@ function views_ajax_form_wrapper($form_id, &$form_state) {
|
||||
|
||||
|
||||
/**
|
||||
* Page callback for views user autocomplete
|
||||
* Page callback for views user autocomplete.
|
||||
*/
|
||||
function views_ajax_autocomplete_user($string = '') {
|
||||
// The user enters a comma-separated list of user name. We only autocomplete the last name.
|
||||
// The user enters a comma-separated list of user name. We only autocomplete
|
||||
// the last name.
|
||||
$array = drupal_explode_tags($string);
|
||||
|
||||
// Fetch last name
|
||||
// Fetch last name.
|
||||
$last_string = trim(array_pop($array));
|
||||
$matches = array();
|
||||
if ($last_string != '') {
|
||||
@ -328,16 +337,16 @@ function views_ajax_autocomplete_user($string = '') {
|
||||
/**
|
||||
* Page callback for views taxonomy autocomplete.
|
||||
*
|
||||
* @param $vid
|
||||
* @param int $vid
|
||||
* The vocabulary id of the tags which should be returned.
|
||||
*
|
||||
* @param $tags_typed
|
||||
* @param string $tags_typed
|
||||
* The typed string of the user.
|
||||
*
|
||||
* @see taxonomy_autocomplete()
|
||||
*/
|
||||
function views_ajax_autocomplete_taxonomy($vid, $tags_typed = '') {
|
||||
// The user enters a comma-separated list of tags. We only autocomplete the last tag.
|
||||
// The user enters a comma-separated list of tags. We only autocomplete the
|
||||
// last tag.
|
||||
$tags_typed = drupal_explode_tags($tags_typed);
|
||||
$tag_last = drupal_strtolower(array_pop($tags_typed));
|
||||
|
||||
|
@ -16,8 +16,8 @@
|
||||
* Analyze a review and return the results.
|
||||
*
|
||||
* @return
|
||||
* An array of analyze results organized into arrays keyed by 'ok',
|
||||
* 'warning' and 'error'.
|
||||
* An array of analyze results organized into arrays keyed by 'ok', 'warning'
|
||||
* and 'error'.
|
||||
*/
|
||||
function views_analyze_view(&$view) {
|
||||
$view->init_display();
|
||||
@ -79,12 +79,12 @@ function views_analyze_format_result($view, $messages) {
|
||||
* that may be broken unless the user knows what he or she is doing,
|
||||
* and 'error' for items that are definitely broken are much more useful.
|
||||
*
|
||||
* @param $messages
|
||||
* @param string $message
|
||||
* The message to report.
|
||||
* @param $type
|
||||
* @param string $type
|
||||
* The type of message. This should be "ok", "warning" or "error". Other
|
||||
* values can be used but how they are treated by the output routine
|
||||
* is undefined.
|
||||
* values can be used but how they are treated by the output routine is
|
||||
* undefined.
|
||||
*/
|
||||
function views_ui_analysis($message, $type = 'error') {
|
||||
return array('message' => $message, 'type' => $type);
|
||||
@ -99,7 +99,7 @@ function views_ui_analysis($message, $type = 'error') {
|
||||
*/
|
||||
function views_ui_views_analyze($view) {
|
||||
$ret = array();
|
||||
// Check for something other than the default display:
|
||||
// Check for something other than the default display.
|
||||
if (count($view->display) < 2) {
|
||||
$ret[] = views_ui_analysis(t('This view has only a default display and therefore will not be placed anywhere on your site; perhaps you want to add a page or a block display.'), 'warning');
|
||||
}
|
||||
|
@ -2,34 +2,36 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provides the basic object definitions used by plugins and handlers.
|
||||
* Definition of views_object.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Basic definition for many views objects.
|
||||
* Provides the basic object definitions used by plugins and handlers.
|
||||
*/
|
||||
class views_object {
|
||||
|
||||
/**
|
||||
* Except for displays, options for the object will be held here.
|
||||
*/
|
||||
var $options = array();
|
||||
public $options = array();
|
||||
|
||||
/**
|
||||
* The top object of a view.
|
||||
*
|
||||
* @var view
|
||||
*/
|
||||
var $view = NULL;
|
||||
public $view = NULL;
|
||||
|
||||
/**
|
||||
* Handler's definition
|
||||
* Handler's definition.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
var $definition;
|
||||
public $definition;
|
||||
|
||||
/**
|
||||
* Information about options for all kinds of purposes will be held here.
|
||||
*
|
||||
* @code
|
||||
* 'option_name' => array(
|
||||
* - 'default' => default value,
|
||||
@ -52,35 +54,69 @@ class views_object {
|
||||
* @see views_object::export_option_always()
|
||||
* @see views_object::unpack_translatable()
|
||||
*/
|
||||
function option_definition() { return array(); }
|
||||
public function option_definition() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Views handlers use a special construct function so that we can more
|
||||
* easily construct them with variable arguments.
|
||||
* Collect this handler's option definition and alter them, ready for use.
|
||||
*
|
||||
* @return array
|
||||
* Returns the options of this handler/plugin after allowing for alters.
|
||||
*
|
||||
* @see hook_views_plugin_option_definition_alter()
|
||||
* @see hook_views_handler_option_definition_alter()
|
||||
*/
|
||||
function construct() { $this->set_default_options(); }
|
||||
function altered_option_definition() {
|
||||
$definition = $this->option_definition();
|
||||
if (!empty($this->is_plugin)) {
|
||||
// Trigger hook_views_plugin_option_definition_alter().
|
||||
drupal_alter('views_plugin_option_definition', $definition, $this);
|
||||
}
|
||||
else {
|
||||
// Trigger hook_views_handler_option_definition_alter().
|
||||
drupal_alter('views_handler_option_definition', $definition, $this);
|
||||
}
|
||||
return $definition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default options on this object. Called by the constructor in a
|
||||
* complex chain to deal with backward compatibility.
|
||||
* Views handlers use a special construct function.
|
||||
*
|
||||
* Allows it to more easily construct them with variable arguments.
|
||||
*/
|
||||
public function construct() {
|
||||
$this->set_default_options();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default options on this object.
|
||||
*
|
||||
* Called by the constructor in a complex chain to deal with backward
|
||||
* compatibility.
|
||||
*
|
||||
* @deprecated since views2
|
||||
*/
|
||||
function options(&$options) { }
|
||||
public function options(&$options) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default options.
|
||||
* For backward compatibility, it sends the options array; this is a
|
||||
* feature that will likely disappear at some point.
|
||||
*
|
||||
* For backward compatibility, it sends the options array; this is a feature
|
||||
* that will likely disappear at some point.
|
||||
*/
|
||||
function set_default_options() {
|
||||
$this->_set_option_defaults($this->options, $this->option_definition());
|
||||
public function set_default_options() {
|
||||
$this->_set_option_defaults($this->options, $this->altered_option_definition());
|
||||
|
||||
// Retained for complex defaults plus backward compatibility.
|
||||
$this->options($this->options);
|
||||
}
|
||||
|
||||
function _set_option_defaults(&$storage, $options, $level = 0) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function _set_option_defaults(&$storage, $options, $level = 0) {
|
||||
foreach ($options as $option => $definition) {
|
||||
if (isset($definition['contains']) && is_array($definition['contains'])) {
|
||||
$storage[$option] = array();
|
||||
@ -96,28 +132,28 @@ class views_object {
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpack options over our existing defaults, drilling down into arrays
|
||||
* so that defaults don't get totally blown away.
|
||||
* Unpack options over our existing defaults, drilling down into arrays so
|
||||
* that defaults don't get totally blown away.
|
||||
*/
|
||||
function unpack_options(&$storage, $options, $definition = NULL, $all = TRUE, $check = TRUE, $localization_keys = array()) {
|
||||
public function unpack_options(&$storage, $options, $definition = NULL, $all = TRUE, $check = TRUE, $localization_keys = array()) {
|
||||
if ($check && !is_array($options)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isset($definition)) {
|
||||
$definition = $this->option_definition();
|
||||
$definition = $this->altered_option_definition();
|
||||
}
|
||||
|
||||
if (!empty($this->view)) {
|
||||
// Ensure we have a localization plugin.
|
||||
$this->view->init_localization();
|
||||
|
||||
// Set up default localization keys. Handlers and such set this for us
|
||||
// Set up default localization keys. Handlers and such set this for us.
|
||||
if (empty($localization_keys) && isset($this->localization_keys)) {
|
||||
$localization_keys = $this->localization_keys;
|
||||
}
|
||||
// but plugins don't because there isn't a common init() these days.
|
||||
else if (!empty($this->is_plugin) && empty($localization_keys)) {
|
||||
elseif (!empty($this->is_plugin) && empty($localization_keys)) {
|
||||
if ($this->plugin_type != 'display') {
|
||||
$localization_keys = array($this->view->current_display);
|
||||
$localization_keys[] = $this->plugin_type;
|
||||
@ -146,9 +182,9 @@ class views_object {
|
||||
|
||||
$this->unpack_options($storage[$key], $value, isset($definition[$key]['contains']) ? $definition[$key]['contains'] : array(), $all, FALSE, array_merge($localization_keys, array($key)));
|
||||
}
|
||||
// Don't localize strings during editing. When editing, we need to work with
|
||||
// the original data, not the translated version.
|
||||
else if (empty($this->view->editing) && !empty($definition[$key]['translatable']) && !empty($value) || !empty($definition['contains'][$key]['translatable']) && !empty($value)) {
|
||||
// Don't localize strings during editing. When editing, we need to work
|
||||
// with the original data, not the translated version.
|
||||
elseif (empty($this->view->editing) && !empty($definition[$key]['translatable']) && !empty($value) || !empty($definition['contains'][$key]['translatable']) && !empty($value)) {
|
||||
if (!empty($this->view) && $this->view->is_translatable()) {
|
||||
// Allow other modules to make changes to the string before it's
|
||||
// sent for translation.
|
||||
@ -170,7 +206,7 @@ class views_object {
|
||||
$storage[$key] = t($value);
|
||||
}
|
||||
}
|
||||
else if ($all || !empty($definition[$key])) {
|
||||
elseif ($all || !empty($definition[$key])) {
|
||||
$storage[$key] = $value;
|
||||
}
|
||||
}
|
||||
@ -179,14 +215,17 @@ class views_object {
|
||||
/**
|
||||
* Let the handler know what its full definition is.
|
||||
*/
|
||||
function set_definition($definition) {
|
||||
public function set_definition($definition) {
|
||||
$this->definition = $definition;
|
||||
if (isset($definition['field'])) {
|
||||
$this->real_field = $definition['field'];
|
||||
}
|
||||
}
|
||||
|
||||
function destroy() {
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
public function destroy() {
|
||||
if (isset($this->view)) {
|
||||
unset($this->view);
|
||||
}
|
||||
@ -200,16 +239,22 @@ class views_object {
|
||||
}
|
||||
}
|
||||
|
||||
function export_options($indent, $prefix) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function export_options($indent, $prefix) {
|
||||
$output = '';
|
||||
foreach ($this->option_definition() as $option => $definition) {
|
||||
foreach ($this->altered_option_definition() as $option => $definition) {
|
||||
$output .= $this->export_option($indent, $prefix, $this->options, $option, $definition, array());
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
function export_option($indent, $prefix, $storage, $option, $definition, $parents) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function export_option($indent, $prefix, $storage, $option, $definition, $parents) {
|
||||
// Do not export options for which we have no settings.
|
||||
if (!isset($storage[$option])) {
|
||||
return;
|
||||
@ -220,7 +265,7 @@ class views_object {
|
||||
return;
|
||||
}
|
||||
|
||||
// Special handling for some items
|
||||
// Special handling for some items.
|
||||
if (method_exists($this, $definition['export'])) {
|
||||
return $this->{$definition['export']}($indent, $prefix, $storage, $option, $definition, $parents);
|
||||
}
|
||||
@ -262,7 +307,7 @@ class views_object {
|
||||
/**
|
||||
* Always exports the option, regardless of the default value.
|
||||
*/
|
||||
function export_option_always($indent, $prefix, $storage, $option, $definition, $parents) {
|
||||
public function export_option_always($indent, $prefix, $storage, $option, $definition, $parents) {
|
||||
// If there is no default, the option will always be exported.
|
||||
unset($definition['default']);
|
||||
// Unset our export method to prevent recursion.
|
||||
@ -273,8 +318,8 @@ class views_object {
|
||||
/**
|
||||
* Unpacks each handler to store translatable texts.
|
||||
*/
|
||||
function unpack_translatables(&$translatable, $parents = array()) {
|
||||
foreach ($this->option_definition() as $option => $definition) {
|
||||
public function unpack_translatables(&$translatable, $parents = array()) {
|
||||
foreach ($this->altered_option_definition() as $option => $definition) {
|
||||
$this->unpack_translatable($translatable, $this->options, $option, $definition, $parents, array());
|
||||
}
|
||||
}
|
||||
@ -284,21 +329,21 @@ class views_object {
|
||||
*
|
||||
* This function run's through all suboptions recursive.
|
||||
*
|
||||
* @param $translatable
|
||||
* @param array $translatable
|
||||
* Stores all available translatable items.
|
||||
* @param $storage
|
||||
* @param $option
|
||||
* @param $definition
|
||||
* @param $parents
|
||||
* @param $keys
|
||||
* @param array $storage
|
||||
* @param string $option
|
||||
* @param string $definition
|
||||
* @param array $parents
|
||||
* @param array $keys
|
||||
*/
|
||||
function unpack_translatable(&$translatable, $storage, $option, $definition, $parents, $keys = array()) {
|
||||
public function unpack_translatable(&$translatable, $storage, $option, $definition, $parents, $keys = array()) {
|
||||
// Do not export options for which we have no settings.
|
||||
if (!isset($storage[$option])) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Special handling for some items
|
||||
// Special handling for some items.
|
||||
if (isset($definition['unpack_translatable']) && method_exists($this, $definition['unpack_translatable'])) {
|
||||
return $this->{$definition['unpack_translatable']}($translatable, $storage, $option, $definition, $parents, $keys);
|
||||
}
|
||||
@ -328,8 +373,8 @@ class views_object {
|
||||
if (is_array($value)) {
|
||||
$this->unpack_translatable($translatable, $options, $key, $definition, $parents, $translation_keys);
|
||||
}
|
||||
else if (!empty($definition[$key]['translatable']) && !empty($value)) {
|
||||
// Build source data and add to the array
|
||||
elseif (!empty($definition[$key]['translatable']) && !empty($value)) {
|
||||
// Build source data and add to the array.
|
||||
$format = NULL;
|
||||
if (isset($definition['format_key']) && isset($options[$definition['format_key']])) {
|
||||
$format = $options[$definition['format_key']];
|
||||
@ -342,9 +387,9 @@ class views_object {
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!empty($definition['translatable']) && !empty($options)) {
|
||||
elseif (!empty($definition['translatable']) && !empty($options)) {
|
||||
$value = $options;
|
||||
// Build source data and add to the array
|
||||
// Build source data and add to the array.
|
||||
$format = NULL;
|
||||
if (isset($definition['format_key']) && isset($storage[$definition['format_key']])) {
|
||||
$format = $storage[$definition['format_key']];
|
||||
@ -356,4 +401,5 @@ class views_object {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,11 +6,13 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fetch Views' data from the cache
|
||||
* Fetch Views' data from the cache.
|
||||
*
|
||||
* @param $move
|
||||
* Under certain circumstances it makes sense to not get the moved table, but the old one.
|
||||
* One example is views_get_handler.
|
||||
* @param string $table
|
||||
* @param bool $move
|
||||
* Under certain circumstances it makes sense to not get the moved table, but
|
||||
* the old one. One example is views_get_handler.
|
||||
* @param bool $reset
|
||||
*/
|
||||
function _views_fetch_data($table = NULL, $move = TRUE, $reset = FALSE) {
|
||||
$cache = &drupal_static(__FUNCTION__ . '_cache');
|
||||
@ -100,7 +102,8 @@ function _views_fetch_data_build() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Links tables having an 'entity type' specified to the respective generic entity-type tables.
|
||||
* Links tables having an 'entity type' specified to the respective generic
|
||||
* entity-type tables.
|
||||
*/
|
||||
function _views_data_process_entity_types(&$data) {
|
||||
foreach ($data as $table_name => $table_info) {
|
||||
@ -151,7 +154,7 @@ function _views_fetch_plugin_data($type = NULL, $plugin = NULL, $reset = FALSE)
|
||||
return $cache;
|
||||
}
|
||||
elseif (!$plugin) {
|
||||
// Not in the if above so the else below won't run
|
||||
// Not in the if above so the else below won't run.
|
||||
if (isset($cache[$type])) {
|
||||
return $cache[$type];
|
||||
}
|
||||
@ -169,12 +172,13 @@ function _views_fetch_plugin_data($type = NULL, $plugin = NULL, $reset = FALSE)
|
||||
*
|
||||
* This is just a convenience wrapper around cache_set().
|
||||
*
|
||||
* @param $cid
|
||||
* @param string $cid
|
||||
* The cache ID of the data to store.
|
||||
* @param $data
|
||||
* The data to store in the cache. Complex data types will be automatically serialized before insertion.
|
||||
* Strings will be stored as plain text and not serialized.
|
||||
* @param $use_language
|
||||
* @param mixed $data
|
||||
* The data to store in the cache. Complex data types will be automatically
|
||||
* serialized before insertion. Strings will be stored as plain text and not
|
||||
* serialized.
|
||||
* @param bool $use_language
|
||||
* If TRUE, the data will be cached specific to the currently active language.
|
||||
*/
|
||||
function views_cache_set($cid, $data, $use_language = FALSE) {
|
||||
@ -198,7 +202,8 @@ function views_cache_set($cid, $data, $use_language = FALSE) {
|
||||
* @param int $cid
|
||||
* The cache ID of the data to retrieve.
|
||||
* @param bool $use_language
|
||||
* If TRUE, the data will be requested specific to the currently active language.
|
||||
* If TRUE, the data will be requested specific to the currently active
|
||||
* language.
|
||||
*
|
||||
* @return stdClass|bool
|
||||
* The cache or FALSE on failure.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -5,7 +5,7 @@
|
||||
* Built in plugins for Views output handling.
|
||||
*/
|
||||
|
||||
// @todo: Remove this once update.php can use the registry
|
||||
// @todo Remove this once update.php can use the registry.
|
||||
views_include('base');
|
||||
|
||||
/**
|
||||
@ -101,7 +101,7 @@ function views_views_plugins() {
|
||||
'title' => t('Empty display extender'),
|
||||
'help' => t('Default settings for this view.'),
|
||||
'handler' => 'views_plugin_display_extender',
|
||||
// You can force the plugin to be enabled
|
||||
// You can force the plugin to be enabled.
|
||||
'enabled' => FALSE,
|
||||
'no ui' => TRUE,
|
||||
),
|
||||
@ -160,7 +160,8 @@ function views_views_plugins() {
|
||||
'help' => t('Displays the default summary as a list.'),
|
||||
'handler' => 'views_plugin_style_summary',
|
||||
'theme' => 'views_view_summary',
|
||||
'type' => 'summary', // only shows up as a summary style
|
||||
'type' => 'summary',
|
||||
// only shows up as a summary style.
|
||||
'uses options' => TRUE,
|
||||
'help topic' => 'style-summary',
|
||||
),
|
||||
@ -169,7 +170,8 @@ function views_views_plugins() {
|
||||
'help' => t('Displays the summary unformatted, with option for one after another or inline.'),
|
||||
'handler' => 'views_plugin_style_summary_unformatted',
|
||||
'theme' => 'views_view_summary_unformatted',
|
||||
'type' => 'summary', // only shows up as a summary style
|
||||
'type' => 'summary',
|
||||
// only shows up as a summary style.
|
||||
'uses options' => TRUE,
|
||||
'help topic' => 'style-summary-unformatted',
|
||||
),
|
||||
@ -266,7 +268,7 @@ function views_views_plugins() {
|
||||
'views_query' => array(
|
||||
'title' => t('SQL Query'),
|
||||
'help' => t('Query will be generated and run using the Drupal database API.'),
|
||||
'handler' => 'views_plugin_query_default'
|
||||
'handler' => 'views_plugin_query_default',
|
||||
),
|
||||
),
|
||||
'cache' => array(
|
||||
@ -356,7 +358,7 @@ function views_views_plugins() {
|
||||
'handler' => 'views_plugin_localization',
|
||||
'parent' => '',
|
||||
),
|
||||
'none' => array(
|
||||
'none' => array(
|
||||
'title' => t('None'),
|
||||
'help' => t('Do not pass admin strings for translation.'),
|
||||
'handler' => 'views_plugin_localization_none',
|
||||
@ -381,7 +383,8 @@ function views_views_plugins() {
|
||||
'help' => t('Puts all of the results into a select box and allows the user to go to a different page based upon the results.'),
|
||||
'handler' => 'views_plugin_style_summary_jump_menu',
|
||||
'theme' => 'views_view_summary_jump_menu',
|
||||
'type' => 'summary', // only shows up as a summary style
|
||||
'type' => 'summary',
|
||||
// only shows up as a summary style.
|
||||
'uses options' => TRUE,
|
||||
'help topic' => 'style-summary-jump-menu',
|
||||
);
|
||||
@ -417,7 +420,7 @@ function views_discover_plugins() {
|
||||
}
|
||||
|
||||
$module_dir = isset($result['module']) ? $result['module'] : $module;
|
||||
// Setup automatic path/file finding for theme registration
|
||||
// Setup automatic path/file finding for theme registration.
|
||||
if ($module_dir == 'views') {
|
||||
$theme_path = drupal_get_path('module', $module_dir) . '/theme';
|
||||
$theme_file = 'theme.inc';
|
||||
@ -452,7 +455,7 @@ function views_discover_plugins() {
|
||||
// Set the internal name to be able to read it out later.
|
||||
$def['name'] = $plugin;
|
||||
|
||||
// merge the new data in
|
||||
// merge the new data in.
|
||||
$cache[$type][$plugin] = $def;
|
||||
}
|
||||
}
|
||||
@ -467,29 +470,30 @@ function views_discover_plugins() {
|
||||
* Abstract base class to provide interface common to all plugins.
|
||||
*/
|
||||
class views_plugin extends views_object {
|
||||
|
||||
/**
|
||||
* The top object of a view.
|
||||
*
|
||||
* @var view
|
||||
*/
|
||||
var $view = NULL;
|
||||
public $view = NULL;
|
||||
|
||||
/**
|
||||
* The current used views display.
|
||||
*
|
||||
* @var views_display
|
||||
*/
|
||||
var $display = NULL;
|
||||
public $display = NULL;
|
||||
|
||||
/**
|
||||
* The plugin type of this plugin, for example style or query.
|
||||
*/
|
||||
var $plugin_type = NULL;
|
||||
public $plugin_type = NULL;
|
||||
|
||||
/**
|
||||
* The plugin name of this plugin, for example table or full.
|
||||
*/
|
||||
var $plugin_name = NULL;
|
||||
public $plugin_name = NULL;
|
||||
|
||||
/**
|
||||
* Init will be called after construct, when the plugin is attached to a
|
||||
@ -499,7 +503,7 @@ class views_plugin extends views_object {
|
||||
/**
|
||||
* Provide a form to edit options for this plugin.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
public function options_form(&$form, &$form_state) {
|
||||
// Some form elements belong in a fieldset for presentation, but can't
|
||||
// be moved into one because of the form_state['values'] hierarchy. Those
|
||||
// elements can add a #fieldset => 'fieldset_name' property, and they'll
|
||||
@ -510,22 +514,25 @@ class views_plugin extends views_object {
|
||||
/**
|
||||
* 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) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add anything to the query that we might need to.
|
||||
*/
|
||||
function query() { }
|
||||
public function query() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a full list of possible theme templates used by this style.
|
||||
*/
|
||||
function theme_functions() {
|
||||
public function theme_functions() {
|
||||
if (empty($this->definition['theme'])) {
|
||||
$this->definition['theme'] = 'views_view';
|
||||
}
|
||||
@ -533,9 +540,9 @@ class views_plugin extends views_object {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a list of additional theme functions for the theme information page
|
||||
* Provide a list of additional theme functions for the theme info page.
|
||||
*/
|
||||
function additional_theme_functions() {
|
||||
public function additional_theme_functions() {
|
||||
$funcs = array();
|
||||
if (!empty($this->definition['additional themes'])) {
|
||||
foreach ($this->definition['additional themes'] as $theme => $type) {
|
||||
@ -548,16 +555,18 @@ class views_plugin extends views_object {
|
||||
/**
|
||||
* Validate that the plugin is correct and can be saved.
|
||||
*
|
||||
* @return
|
||||
* @return array
|
||||
* An array of error strings to tell the user what is wrong with this
|
||||
* plugin.
|
||||
*/
|
||||
function validate() { return array(); }
|
||||
public function validate() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the summary of the settings in the display.
|
||||
*/
|
||||
function summary_title() {
|
||||
public function summary_title() {
|
||||
return t('Settings');
|
||||
}
|
||||
/**
|
||||
@ -565,12 +574,13 @@ class views_plugin extends views_object {
|
||||
*
|
||||
* This appears on the ui beside each plugin and beside the settings link.
|
||||
*/
|
||||
function plugin_title() {
|
||||
public function plugin_title() {
|
||||
if (isset($this->definition['short title'])) {
|
||||
return check_plain($this->definition['short title']);
|
||||
}
|
||||
return check_plain($this->definition['title']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -25,7 +25,13 @@
|
||||
});
|
||||
|
||||
$('form', ajax_body).once('views-ajax-submit-processed').each(function() {
|
||||
var element_settings = { 'url': response.url, 'event': 'submit', 'progress': { 'type': 'throbber' } };
|
||||
var element_settings = {
|
||||
'url': response.url,
|
||||
'event': 'submit',
|
||||
'progress': {
|
||||
'type': 'throbber'
|
||||
}
|
||||
};
|
||||
var $form = $(this);
|
||||
var id = $form.attr('id');
|
||||
Drupal.ajax[id] = new Drupal.ajax(id, this, element_settings);
|
||||
@ -90,7 +96,7 @@
|
||||
};
|
||||
|
||||
/**
|
||||
* Get rid of irritating tabledrag messages
|
||||
* Get rid of irritating tabledrag messages.
|
||||
*/
|
||||
Drupal.theme.tableDragChangedWarning = function () {
|
||||
return [];
|
||||
@ -143,7 +149,9 @@
|
||||
|
||||
var base_element_settings = {
|
||||
'event': 'click',
|
||||
'progress': { 'type': 'throbber' }
|
||||
'progress': {
|
||||
'type': 'throbber'
|
||||
}
|
||||
};
|
||||
// Bind AJAX behaviors to all items showing the class.
|
||||
$('a.views-ajax-link', context).once('views-ajax-processed').each(function () {
|
||||
@ -158,23 +166,23 @@
|
||||
|
||||
$('div#views-live-preview a')
|
||||
.once('views-ajax-processed').each(function () {
|
||||
// We don't bind to links without a URL.
|
||||
if (!$(this).attr('href')) {
|
||||
return true;
|
||||
}
|
||||
// We don't bind to links without a URL.
|
||||
if (!$(this).attr('href')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var element_settings = base_element_settings;
|
||||
// Set the URL to go to the anchor.
|
||||
element_settings.url = $(this).attr('href');
|
||||
if (Drupal.Views.getPath(element_settings.url).substring(0, 21) != 'admin/structure/views') {
|
||||
return true;
|
||||
}
|
||||
var element_settings = base_element_settings;
|
||||
// Set the URL to go to the anchor.
|
||||
element_settings.url = $(this).attr('href');
|
||||
if (Drupal.Views.getPath(element_settings.url).substring(0, 21) != 'admin/structure/views') {
|
||||
return true;
|
||||
}
|
||||
|
||||
element_settings.wrapper = 'views-live-preview';
|
||||
element_settings.method = 'html';
|
||||
var base = $(this).attr('id');
|
||||
Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings);
|
||||
});
|
||||
element_settings.wrapper = 'views-live-preview';
|
||||
element_settings.method = 'html';
|
||||
var base = $(this).attr('id');
|
||||
Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings);
|
||||
});
|
||||
|
||||
// Within a live preview, make exposed widget form buttons re-trigger the
|
||||
// Preview button.
|
||||
@ -182,29 +190,29 @@
|
||||
// of the main Edit form.
|
||||
$('div#views-live-preview input[type=submit]')
|
||||
.once('views-ajax-processed').each(function(event) {
|
||||
$(this).click(function () {
|
||||
this.form.clk = this;
|
||||
return true;
|
||||
$(this).click(function () {
|
||||
this.form.clk = this;
|
||||
return true;
|
||||
});
|
||||
var element_settings = base_element_settings;
|
||||
// Set the URL to go to the anchor.
|
||||
element_settings.url = $(this.form).attr('action');
|
||||
if (Drupal.Views.getPath(element_settings.url).substring(0, 21) != 'admin/structure/views') {
|
||||
return true;
|
||||
}
|
||||
|
||||
element_settings.wrapper = 'views-live-preview';
|
||||
element_settings.method = 'html';
|
||||
element_settings.event = 'click';
|
||||
|
||||
var base = $(this).attr('id');
|
||||
Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings);
|
||||
});
|
||||
var element_settings = base_element_settings;
|
||||
// Set the URL to go to the anchor.
|
||||
element_settings.url = $(this.form).attr('action');
|
||||
if (Drupal.Views.getPath(element_settings.url).substring(0, 21) != 'admin/structure/views') {
|
||||
return true;
|
||||
}
|
||||
|
||||
element_settings.wrapper = 'views-live-preview';
|
||||
element_settings.method = 'html';
|
||||
element_settings.event = 'click';
|
||||
|
||||
var base = $(this).attr('id');
|
||||
Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings);
|
||||
});
|
||||
|
||||
if (!this.collapseReplaced && Drupal.collapseScrollIntoView) {
|
||||
this.collapseReplaced = true;
|
||||
Drupal.collapseScrollIntoView = function (node) {
|
||||
for (var $parent = $(node); $parent.get(0) != document && $parent.size() != 0; $parent = $parent.parent()) {
|
||||
for (var $parent = $(node); $parent.get(0) != document && $parent.length != 0; $parent = $parent.parent()) {
|
||||
if ($parent.css('overflow') == 'scroll' || $parent.css('overflow') == 'auto') {
|
||||
if (Drupal.viewsUi.resizeModal) {
|
||||
// If the modal is already at the max height, don't bother with
|
||||
|
@ -4,148 +4,159 @@
|
||||
*/
|
||||
(function ($) {
|
||||
|
||||
/**
|
||||
* Attaches the AJAX behavior to Views exposed filter forms and key View links.
|
||||
*/
|
||||
Drupal.behaviors.ViewsAjaxView = {};
|
||||
Drupal.behaviors.ViewsAjaxView.attach = function() {
|
||||
if (Drupal.settings && Drupal.settings.views && Drupal.settings.views.ajaxViews) {
|
||||
$.each(Drupal.settings.views.ajaxViews, function(i, settings) {
|
||||
Drupal.views.instances[i] = new Drupal.views.ajaxView(settings);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.views = {};
|
||||
Drupal.views.instances = {};
|
||||
|
||||
/**
|
||||
* Javascript object for a certain view.
|
||||
*/
|
||||
Drupal.views.ajaxView = function(settings) {
|
||||
var selector = '.view-dom-id-' + settings.view_dom_id;
|
||||
this.$view = $(selector);
|
||||
|
||||
// Retrieve the path to use for views' ajax.
|
||||
var ajax_path = Drupal.settings.views.ajax_path;
|
||||
|
||||
// If there are multiple views this might've ended up showing up multiple times.
|
||||
if (ajax_path.constructor.toString().indexOf("Array") != -1) {
|
||||
ajax_path = ajax_path[0];
|
||||
}
|
||||
|
||||
// Check if there are any GET parameters to send to views.
|
||||
var queryString = window.location.search || '';
|
||||
if (queryString !== '') {
|
||||
// Remove the question mark and Drupal path component if any.
|
||||
var queryString = queryString.slice(1).replace(/q=[^&]+&?|&?render=[^&]+/, '');
|
||||
if (queryString !== '') {
|
||||
// If there is a '?' in ajax_path, clean url are on and & should be used to add parameters.
|
||||
queryString = ((/\?/.test(ajax_path)) ? '&' : '?') + queryString;
|
||||
/**
|
||||
* Attaches the AJAX behavior to exposed filter forms and key views links.
|
||||
*/
|
||||
Drupal.behaviors.ViewsAjaxView = {};
|
||||
Drupal.behaviors.ViewsAjaxView.attach = function() {
|
||||
if (Drupal.settings && Drupal.settings.views && Drupal.settings.views.ajaxViews) {
|
||||
$.each(Drupal.settings.views.ajaxViews, function(i, settings) {
|
||||
Drupal.views.instances[i] = new Drupal.views.ajaxView(settings);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
this.element_settings = {
|
||||
url: ajax_path + queryString,
|
||||
submit: settings,
|
||||
setClick: true,
|
||||
event: 'click',
|
||||
selector: selector,
|
||||
progress: { type: 'throbber' }
|
||||
};
|
||||
|
||||
this.settings = settings;
|
||||
Drupal.views = {};
|
||||
Drupal.views.instances = {};
|
||||
|
||||
// Add the ajax to exposed forms.
|
||||
this.$exposed_form = $('#views-exposed-form-'+ settings.view_name.replace(/_/g, '-') + '-' + settings.view_display_id.replace(/_/g, '-'));
|
||||
this.$exposed_form.once(jQuery.proxy(this.attachExposedFormAjax, this));
|
||||
/**
|
||||
* Javascript object for a certain view.
|
||||
*/
|
||||
Drupal.views.ajaxView = function(settings) {
|
||||
var selector = '.view-dom-id-' + settings.view_dom_id;
|
||||
this.$view = $(selector);
|
||||
|
||||
// Store Drupal.ajax objects here for all pager links.
|
||||
this.links = [];
|
||||
// Retrieve the path to use for views' ajax.
|
||||
var ajax_path = Drupal.settings.views.ajax_path;
|
||||
|
||||
// Add the ajax to pagers.
|
||||
this.$view
|
||||
// If there are multiple views this might've ended up showing up multiple
|
||||
// times.
|
||||
if (ajax_path.constructor.toString().indexOf("Array") != -1) {
|
||||
ajax_path = ajax_path[0];
|
||||
}
|
||||
|
||||
// Check if there are any GET parameters to send to views.
|
||||
var queryString = window.location.search || '';
|
||||
if (queryString !== '') {
|
||||
// Remove the question mark and Drupal path component if any.
|
||||
var queryString = queryString.slice(1).replace(/q=[^&]+&?|&?render=[^&]+/, '');
|
||||
if (queryString !== '') {
|
||||
// If there is a '?' in ajax_path, clean url are on and & should be
|
||||
// used to add parameters.
|
||||
queryString = ((/\?/.test(ajax_path)) ? '&' : '?') + queryString;
|
||||
}
|
||||
}
|
||||
|
||||
this.element_settings = {
|
||||
url: ajax_path + queryString,
|
||||
submit: settings,
|
||||
setClick: true,
|
||||
event: 'click',
|
||||
selector: selector,
|
||||
progress: {
|
||||
type: 'throbber'
|
||||
}
|
||||
};
|
||||
|
||||
this.settings = settings;
|
||||
|
||||
// Add the ajax to exposed forms.
|
||||
this.$exposed_form = $('#views-exposed-form-' + settings.view_name.replace(/_/g, '-') + '-' + settings.view_display_id.replace(/_/g, '-'));
|
||||
this.$exposed_form.once(jQuery.proxy(this.attachExposedFormAjax, this));
|
||||
|
||||
// Store Drupal.ajax objects here for all pager links.
|
||||
this.links = [];
|
||||
|
||||
// Add the ajax to pagers.
|
||||
this.$view
|
||||
// Don't attach to nested views. Doing so would attach multiple behaviors
|
||||
// to a given element.
|
||||
.filter(jQuery.proxy(this.filterNestedViews, this))
|
||||
.once(jQuery.proxy(this.attachPagerAjax, this));
|
||||
.filter(jQuery.proxy(this.filterNestedViews, this))
|
||||
.once(jQuery.proxy(this.attachPagerAjax, this));
|
||||
|
||||
// Add a trigger to update this view specifically. In order to trigger a
|
||||
// refresh use the following code.
|
||||
//
|
||||
// @code
|
||||
// jQuery('.view-name').trigger('RefreshView');
|
||||
// @endcode
|
||||
// Add a trigger to update this view specifically.
|
||||
var self_settings = this.element_settings;
|
||||
self_settings.event = 'RefreshView';
|
||||
this.refreshViewAjax = new Drupal.ajax(this.selector, this.$view, self_settings);
|
||||
};
|
||||
// Add a trigger to update this view specifically. In order to trigger a
|
||||
// refresh use the following code.
|
||||
//
|
||||
// @code
|
||||
// jQuery('.view-name').trigger('RefreshView');
|
||||
// @endcode
|
||||
// Add a trigger to update this view specifically.
|
||||
var self_settings = this.element_settings;
|
||||
self_settings.event = 'RefreshView';
|
||||
this.refreshViewAjax = new Drupal.ajax(this.selector, this.$view, self_settings);
|
||||
};
|
||||
|
||||
Drupal.views.ajaxView.prototype.attachExposedFormAjax = function() {
|
||||
var button = $('input[type=submit], button[type=submit], input[type=image]', this.$exposed_form);
|
||||
button = button[0];
|
||||
Drupal.views.ajaxView.prototype.attachExposedFormAjax = function() {
|
||||
var button = $('input[type=submit], button[type=submit], input[type=image]', this.$exposed_form);
|
||||
button = button[0];
|
||||
|
||||
this.exposedFormAjax = new Drupal.ajax($(button).attr('id'), button, this.element_settings);
|
||||
};
|
||||
// Call the autocomplete submit before doing AJAX.
|
||||
$(button).click(function () {
|
||||
if (Drupal.autocompleteSubmit) {
|
||||
Drupal.autocompleteSubmit();
|
||||
}
|
||||
});
|
||||
|
||||
Drupal.views.ajaxView.prototype.filterNestedViews= function() {
|
||||
// If there is at least one parent with a view class, this view
|
||||
// is nested (e.g., an attachment). Bail.
|
||||
return !this.$view.parents('.view').size();
|
||||
};
|
||||
this.exposedFormAjax = new Drupal.ajax($(button).attr('id'), button, this.element_settings);
|
||||
};
|
||||
|
||||
/**
|
||||
* Attach the ajax behavior to each link.
|
||||
*/
|
||||
Drupal.views.ajaxView.prototype.attachPagerAjax = function() {
|
||||
this.$view.find('ul.pager > li > a, th.views-field a, .attachment .views-summary a')
|
||||
.each(jQuery.proxy(this.attachPagerLinkAjax, this));
|
||||
};
|
||||
Drupal.views.ajaxView.prototype.filterNestedViews = function() {
|
||||
// If there is at least one parent with a view class, this view
|
||||
// is nested (e.g., an attachment). Bail.
|
||||
return !this.$view.parents('.view').length;
|
||||
};
|
||||
|
||||
/**
|
||||
* Attach the ajax behavior to a singe link.
|
||||
*/
|
||||
Drupal.views.ajaxView.prototype.attachPagerLinkAjax = function(id, link) {
|
||||
var $link = $(link);
|
||||
var viewData = {};
|
||||
var href = $link.attr('href');
|
||||
// Construct an object using the settings defaults and then overriding
|
||||
// with data specific to the link.
|
||||
$.extend(
|
||||
/**
|
||||
* Attach the ajax behavior to each link.
|
||||
*/
|
||||
Drupal.views.ajaxView.prototype.attachPagerAjax = function() {
|
||||
this.$view.find('ul.pager > li > a, th.views-field a, .attachment .views-summary a')
|
||||
.each(jQuery.proxy(this.attachPagerLinkAjax, this));
|
||||
};
|
||||
|
||||
/**
|
||||
* Attach the ajax behavior to a singe link.
|
||||
*/
|
||||
Drupal.views.ajaxView.prototype.attachPagerLinkAjax = function(id, link) {
|
||||
var $link = $(link);
|
||||
var viewData = {};
|
||||
var href = $link.attr('href');
|
||||
// Construct an object using the settings defaults and then overriding
|
||||
// with data specific to the link.
|
||||
$.extend(
|
||||
viewData,
|
||||
this.settings,
|
||||
Drupal.Views.parseQueryString(href),
|
||||
// Extract argument data from the URL.
|
||||
Drupal.Views.parseViewArgs(href, this.settings.view_base_path)
|
||||
);
|
||||
);
|
||||
|
||||
// For anchor tags, these will go to the target of the anchor rather
|
||||
// than the usual location.
|
||||
$.extend(viewData, Drupal.Views.parseViewArgs(href, this.settings.view_base_path));
|
||||
// For anchor tags, these will go to the target of the anchor rather
|
||||
// than the usual location.
|
||||
$.extend(viewData, Drupal.Views.parseViewArgs(href, this.settings.view_base_path));
|
||||
|
||||
this.element_settings.submit = viewData;
|
||||
this.pagerAjax = new Drupal.ajax(false, $link, this.element_settings);
|
||||
this.links.push(this.pagerAjax);
|
||||
};
|
||||
this.element_settings.submit = viewData;
|
||||
this.pagerAjax = new Drupal.ajax(false, $link, this.element_settings);
|
||||
this.links.push(this.pagerAjax);
|
||||
};
|
||||
|
||||
Drupal.ajax.prototype.commands.viewsScrollTop = function (ajax, response, status) {
|
||||
// Scroll to the top of the view. This will allow users
|
||||
// to browse newly loaded content after e.g. clicking a pager
|
||||
// link.
|
||||
var offset = $(response.selector).offset();
|
||||
// We can't guarantee that the scrollable object should be
|
||||
// the body, as the view could be embedded in something
|
||||
// more complex such as a modal popup. Recurse up the DOM
|
||||
// and scroll the first element that has a non-zero top.
|
||||
var scrollTarget = response.selector;
|
||||
while ($(scrollTarget).scrollTop() == 0 && $(scrollTarget).parent()) {
|
||||
scrollTarget = $(scrollTarget).parent();
|
||||
}
|
||||
// Only scroll upward
|
||||
if (offset.top - 10 < $(scrollTarget).scrollTop()) {
|
||||
$(scrollTarget).animate({scrollTop: (offset.top - 10)}, 500);
|
||||
}
|
||||
};
|
||||
Drupal.ajax.prototype.commands.viewsScrollTop = function (ajax, response, status) {
|
||||
// Scroll to the top of the view. This will allow users
|
||||
// to browse newly loaded content after e.g. clicking a pager
|
||||
// link.
|
||||
var offset = $(response.selector).offset();
|
||||
// We can't guarantee that the scrollable object should be
|
||||
// the body, as the view could be embedded in something
|
||||
// more complex such as a modal popup. Recurse up the DOM
|
||||
// and scroll the first element that has a non-zero top.
|
||||
var scrollTarget = response.selector;
|
||||
while ($(scrollTarget).scrollTop() == 0 && $(scrollTarget).parent()) {
|
||||
scrollTarget = $(scrollTarget).parent();
|
||||
}
|
||||
// Only scroll upward.
|
||||
if (offset.top - 10 < $(scrollTarget).scrollTop()) {
|
||||
$(scrollTarget).animate({scrollTop: (offset.top - 10)}, 500);
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
@ -4,112 +4,112 @@
|
||||
*/
|
||||
(function ($) {
|
||||
|
||||
Drupal.Views = {};
|
||||
Drupal.Views = {};
|
||||
|
||||
/**
|
||||
* jQuery UI tabs, Views integration component
|
||||
*/
|
||||
Drupal.behaviors.viewsTabs = {
|
||||
attach: function (context) {
|
||||
if ($.viewsUi && $.viewsUi.tabs) {
|
||||
$('#views-tabset').once('views-processed').viewsTabs({
|
||||
selectedClass: 'active'
|
||||
});
|
||||
}
|
||||
|
||||
$('a.views-remove-link').once('views-processed').click(function(event) {
|
||||
var id = $(this).attr('id').replace('views-remove-link-', '');
|
||||
$('#views-row-' + id).hide();
|
||||
$('#views-removed-' + id).attr('checked', true);
|
||||
event.preventDefault();
|
||||
});
|
||||
/**
|
||||
* Here is to handle display deletion
|
||||
* (checking in the hidden checkbox and hiding out the row)
|
||||
*/
|
||||
$('a.display-remove-link')
|
||||
.addClass('display-processed')
|
||||
.click(function() {
|
||||
var id = $(this).attr('id').replace('display-remove-link-', '');
|
||||
$('#display-row-' + id).hide();
|
||||
$('#display-removed-' + id).attr('checked', true);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
};
|
||||
* JQuery UI tabs, Views integration component.
|
||||
*/
|
||||
Drupal.behaviors.viewsTabs = {
|
||||
attach: function (context) {
|
||||
if ($.viewsUi && $.viewsUi.tabs) {
|
||||
$('#views-tabset').once('views-processed').viewsTabs({
|
||||
selectedClass: 'active'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
$('a.views-remove-link').once('views-processed').click(function(event) {
|
||||
var id = $(this).attr('id').replace('views-remove-link-', '');
|
||||
$('#views-row-' + id).hide();
|
||||
$('#views-removed-' + id).attr('checked', true);
|
||||
event.preventDefault();
|
||||
});
|
||||
/**
|
||||
* Here is to handle display deletion
|
||||
* (checking in the hidden checkbox and hiding out the row).
|
||||
*/
|
||||
$('a.display-remove-link')
|
||||
.addClass('display-processed')
|
||||
.click(function() {
|
||||
var id = $(this).attr('id').replace('display-remove-link-', '');
|
||||
$('#display-row-' + id).hide();
|
||||
$('#display-removed-' + id).attr('checked', true);
|
||||
return false;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper function to parse a querystring.
|
||||
*/
|
||||
Drupal.Views.parseQueryString = function (query) {
|
||||
var args = {};
|
||||
var pos = query.indexOf('?');
|
||||
if (pos != -1) {
|
||||
query = query.substring(pos + 1);
|
||||
}
|
||||
var pairs = query.split('&');
|
||||
for(var i in pairs) {
|
||||
if (typeof(pairs[i]) == 'string') {
|
||||
var pair = pairs[i].split('=');
|
||||
// Ignore the 'q' path argument, if present.
|
||||
if (pair[0] != 'q' && pair[1]) {
|
||||
args[decodeURIComponent(pair[0].replace(/\+/g, ' '))] = decodeURIComponent(pair[1].replace(/\+/g, ' '));
|
||||
Drupal.Views.parseQueryString = function (query) {
|
||||
var args = {};
|
||||
var pos = query.indexOf('?');
|
||||
if (pos != -1) {
|
||||
query = query.substring(pos + 1);
|
||||
}
|
||||
var pairs = query.split('&');
|
||||
for (var i in pairs) {
|
||||
if (typeof(pairs[i]) == 'string') {
|
||||
var pair = pairs[i].split('=');
|
||||
// Ignore the 'q' path argument, if present.
|
||||
if (pair[0] != 'q' && pair[1]) {
|
||||
args[decodeURIComponent(pair[0].replace(/\+/g, ' '))] = decodeURIComponent(pair[1].replace(/\+/g, ' '));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return args;
|
||||
};
|
||||
return args;
|
||||
};
|
||||
|
||||
/**
|
||||
/**
|
||||
* Helper function to return a view's arguments based on a path.
|
||||
*/
|
||||
Drupal.Views.parseViewArgs = function (href, viewPath) {
|
||||
Drupal.Views.parseViewArgs = function (href, viewPath) {
|
||||
|
||||
// Provide language prefix.
|
||||
if (Drupal.settings.pathPrefix) {
|
||||
var viewPath = Drupal.settings.pathPrefix + viewPath;
|
||||
}
|
||||
var returnObj = {};
|
||||
var path = Drupal.Views.getPath(href);
|
||||
// Ensure we have a correct path.
|
||||
if (viewPath && path.substring(0, viewPath.length + 1) == viewPath + '/') {
|
||||
var args = decodeURIComponent(path.substring(viewPath.length + 1, path.length));
|
||||
returnObj.view_args = args;
|
||||
returnObj.view_path = path;
|
||||
}
|
||||
return returnObj;
|
||||
};
|
||||
// Provide language prefix.
|
||||
if (Drupal.settings.pathPrefix) {
|
||||
var viewPath = Drupal.settings.pathPrefix + viewPath;
|
||||
}
|
||||
var returnObj = {};
|
||||
var path = Drupal.Views.getPath(href);
|
||||
// Ensure we have a correct path.
|
||||
if (viewPath && path.substring(0, viewPath.length + 1) == viewPath + '/') {
|
||||
var args = decodeURIComponent(path.substring(viewPath.length + 1, path.length));
|
||||
returnObj.view_args = args;
|
||||
returnObj.view_path = path;
|
||||
}
|
||||
return returnObj;
|
||||
};
|
||||
|
||||
/**
|
||||
/**
|
||||
* Strip off the protocol plus domain from an href.
|
||||
*/
|
||||
Drupal.Views.pathPortion = function (href) {
|
||||
// Remove e.g. http://example.com if present.
|
||||
var protocol = window.location.protocol;
|
||||
if (href.substring(0, protocol.length) == protocol) {
|
||||
// 2 is the length of the '//' that normally follows the protocol
|
||||
href = href.substring(href.indexOf('/', protocol.length + 2));
|
||||
}
|
||||
return href;
|
||||
};
|
||||
Drupal.Views.pathPortion = function (href) {
|
||||
// Remove e.g. http://example.com if present.
|
||||
var protocol = window.location.protocol;
|
||||
if (href.substring(0, protocol.length) == protocol) {
|
||||
// 2 is the length of the '//' that normally follows the protocol.
|
||||
href = href.substring(href.indexOf('/', protocol.length + 2));
|
||||
}
|
||||
return href;
|
||||
};
|
||||
|
||||
/**
|
||||
/**
|
||||
* Return the Drupal path portion of an href.
|
||||
*/
|
||||
Drupal.Views.getPath = function (href) {
|
||||
href = Drupal.Views.pathPortion(href);
|
||||
href = href.substring(Drupal.settings.basePath.length, href.length);
|
||||
// 3 is the length of the '?q=' added to the url without clean urls.
|
||||
if (href.substring(0, 3) == '?q=') {
|
||||
href = href.substring(3, href.length);
|
||||
}
|
||||
var chars = ['#', '?', '&'];
|
||||
for (var i in chars) {
|
||||
if (href.indexOf(chars[i]) > -1) {
|
||||
href = href.substr(0, href.indexOf(chars[i]));
|
||||
Drupal.Views.getPath = function (href) {
|
||||
href = Drupal.Views.pathPortion(href);
|
||||
href = href.substring(Drupal.settings.basePath.length, href.length);
|
||||
// 3 is the length of the '?q=' added to the url without clean urls.
|
||||
if (href.substring(0, 3) == '?q=') {
|
||||
href = href.substring(3, href.length);
|
||||
}
|
||||
}
|
||||
return href;
|
||||
};
|
||||
var chars = ['#', '?', '&'];
|
||||
for (var i in chars) {
|
||||
if (href.indexOf(chars[i]) > -1) {
|
||||
href = href.substr(0, href.indexOf(chars[i]));
|
||||
}
|
||||
}
|
||||
return href;
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
@ -1,4 +1,5 @@
|
||||
/**
|
||||
* @file
|
||||
* 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
|
||||
@ -15,13 +16,16 @@
|
||||
*
|
||||
* The original code for this object:
|
||||
* $.ui.dialog.overlay.events: $.map('focus,mousedown,mouseup,keydown,keypress,click'.split(','),
|
||||
* function(event) { return event + '.dialog-overlay'; }).join(' '),
|
||||
*
|
||||
* function(event) {
|
||||
* return event + '.dialog-overlay';
|
||||
* }).join(' '),
|
||||
*/
|
||||
|
||||
(function ($, undefined) {
|
||||
if ($.ui && $.ui.dialog && $.ui.dialog.overlay) {
|
||||
$.ui.dialog.overlay.events = $.map('focus,keydown,keypress'.split(','),
|
||||
function(event) { return event + '.dialog-overlay'; }).join(' ');
|
||||
function(event) {
|
||||
return event + '.dialog-overlay';
|
||||
}).join(' ');
|
||||
}
|
||||
}(jQuery));
|
||||
|
@ -187,7 +187,8 @@ Drupal.viewsUi.addItemForm.prototype.handleCheck = function (event) {
|
||||
else {
|
||||
var length = this.checkedItems.length;
|
||||
var position = jQuery.inArray(label, this.checkedItems);
|
||||
// Delete the item from the list and take sure that the list doesn't have undefined items left.
|
||||
// Delete the item from the list and take sure that the list doesn't have
|
||||
// undefined items left.
|
||||
for (var i = 0; i < this.checkedItems.length; i++) {
|
||||
if (i == position) {
|
||||
this.checkedItems.splice(i, 1);
|
||||
@ -245,7 +246,7 @@ Drupal.behaviors.viewsUiRenderAddViewButton.attach = function (context, settings
|
||||
});
|
||||
$addDisplayDropdown.appendTo($menu);
|
||||
|
||||
// Add the click handler for the add display button
|
||||
// Add the click handler for the add display button.
|
||||
$('li.add > a', $menu).bind('click', function (event) {
|
||||
event.preventDefault();
|
||||
var $trigger = $(this);
|
||||
@ -668,7 +669,7 @@ Drupal.viewsUi.rearrangeFilterHandler.prototype.modifyTableDrag = function () {
|
||||
|
||||
// Make sure the "group" dropdown is properly updated when rows are dragged
|
||||
// into an empty filter group. This is borrowed heavily from the block.js
|
||||
// implementation of tableDrag.onDrop().
|
||||
// Implements tableDrag.onDrop().
|
||||
var groupRow = $(this.rowObject.element).prevAll('tr.group-message').get(0);
|
||||
var groupName = groupRow.className.replace(/([^ ]+[ ]+)*group-([^ ]+)-message([ ]+[^ ]+)*/, '$2');
|
||||
var groupField = $('select.views-group-select', this.rowObject.element);
|
||||
@ -769,14 +770,14 @@ Drupal.behaviors.viewsFilterConfigSelectAll.attach = function(context) {
|
||||
$('#views-ui-config-item-form div.form-item-options-value-all', context).once(function() {
|
||||
$(this).show();
|
||||
})
|
||||
.find('input[type=checkbox]')
|
||||
.click(function() {
|
||||
var checked = $(this).is(':checked');
|
||||
// Update all checkbox beside the select all checkbox.
|
||||
$(this).parents('.form-checkboxes').find('input[type=checkbox]').each(function() {
|
||||
$(this).attr('checked', checked);
|
||||
.find('input[type=checkbox]')
|
||||
.click(function() {
|
||||
var checked = $(this).is(':checked');
|
||||
// Update all checkbox beside the select all checkbox.
|
||||
$(this).parents('.form-checkboxes').find('input[type=checkbox]').each(function() {
|
||||
$(this).attr('checked', checked);
|
||||
});
|
||||
});
|
||||
});
|
||||
// Uncheck the select all checkbox if any of the others are unchecked.
|
||||
$('#views-ui-config-item-form div.form-type-checkbox').not($('.form-item-options-value-all')).find('input[type=checkbox]').each(function() {
|
||||
$(this).click(function() {
|
||||
@ -926,7 +927,7 @@ Drupal.behaviors.viewsUiOverrideSelect.attach = function (context, settings) {
|
||||
$submit.val(Drupal.t('Apply (this display)'));
|
||||
}
|
||||
})
|
||||
.trigger('change');
|
||||
.trigger('change');
|
||||
});
|
||||
|
||||
};
|
||||
@ -935,13 +936,14 @@ Drupal.viewsUi.resizeModal = function (e, no_shrink) {
|
||||
var $ = jQuery;
|
||||
var $modal = $('.views-ui-dialog');
|
||||
var $scroll = $('.scroll', $modal);
|
||||
if ($modal.size() == 0 || $modal.css('display') == 'none') {
|
||||
if ($modal.length == 0 || $modal.css('display') == 'none') {
|
||||
return;
|
||||
}
|
||||
|
||||
var maxWidth = parseInt($(window).width() * .85); // 70% of window
|
||||
var minWidth = parseInt($(window).width() * .6); // 70% of window
|
||||
|
||||
var maxWidth = parseInt($(window).width() * .85);
|
||||
// 70% of window.
|
||||
var minWidth = parseInt($(window).width() * .6);
|
||||
// 70% of window.
|
||||
// Set the modal to the minwidth so that our width calculation of
|
||||
// children works.
|
||||
$modal.css('width', minWidth);
|
||||
@ -976,7 +978,6 @@ Drupal.viewsUi.resizeModal = function (e, no_shrink) {
|
||||
|
||||
// Now, calculate what the difference between the scroll and the modal
|
||||
// will be.
|
||||
|
||||
var difference = 0;
|
||||
difference += parseInt($scroll.css('padding-top'));
|
||||
difference += parseInt($scroll.css('padding-bottom'));
|
||||
@ -1001,7 +1002,7 @@ Drupal.viewsUi.resizeModal = function (e, no_shrink) {
|
||||
width = maxWidth;
|
||||
}
|
||||
|
||||
// Get where we should move content to
|
||||
// Get where we should move content to.
|
||||
var top = ($(window).height() / 2) - (height / 2);
|
||||
var left = ($(window).width() / 2) - (width / 2);
|
||||
|
||||
|
@ -4,13 +4,13 @@
|
||||
*/
|
||||
(function ($) {
|
||||
|
||||
Drupal.behaviors.viewsContextualLinks = {
|
||||
attach: function (context) {
|
||||
// If there are views-related contextual links attached to the main page
|
||||
// content, find the smallest region that encloses both the links and the
|
||||
// view, and display it as a contextual links region.
|
||||
$('.views-contextual-links-page', context).closest(':has(".view"):not("body")').addClass('contextual-links-region');
|
||||
}
|
||||
};
|
||||
Drupal.behaviors.viewsContextualLinks = {
|
||||
attach: function (context) {
|
||||
// If there are views-related contextual links attached to the main page
|
||||
// content, find the smallest region that encloses both the links and the
|
||||
// view, and display it as a contextual links region.
|
||||
$('.views-contextual-links-page', context).closest(':has(".view"):not("body")').addClass('contextual-links-region');
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
@ -4,18 +4,18 @@
|
||||
*/
|
||||
(function ($) {
|
||||
|
||||
Drupal.behaviors.viewsUIList = {
|
||||
attach: function (context) {
|
||||
$('#ctools-export-ui-list-items thead a').once('views-ajax-processed').each(function() {
|
||||
$(this).click(function() {
|
||||
var query = $.deparam.querystring(this.href);
|
||||
$('#ctools-export-ui-list-form select[name=order]').val(query['order']);
|
||||
$('#ctools-export-ui-list-form select[name=sort]').val(query['sort']);
|
||||
$('#ctools-export-ui-list-form input.ctools-auto-submit-click').trigger('click');
|
||||
return false;
|
||||
Drupal.behaviors.viewsUIList = {
|
||||
attach: function (context) {
|
||||
$('#ctools-export-ui-list-items thead a').once('views-ajax-processed').each(function() {
|
||||
$(this).click(function() {
|
||||
var query = $.deparam.querystring(this.href);
|
||||
$('#ctools-export-ui-list-form select[name=order]').val(query['order']);
|
||||
$('#ctools-export-ui-list-form select[name=sort]').val(query['sort']);
|
||||
$('#ctools-export-ui-list-form input.ctools-auto-submit-click').trigger('click');
|
||||
return false;
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
@ -12,13 +12,12 @@
|
||||
*/
|
||||
function aggregator_views_data() {
|
||||
// ----------------------------------------------------------------------
|
||||
// Main Aggregator Item base table
|
||||
|
||||
// Define the base group of this table. Fields that don't
|
||||
// have a group defined will go into this field by default.
|
||||
// Main Aggregator Item base table.
|
||||
// Define the base group of this table. Fields that don't have a group
|
||||
// defined will go into this field by default.
|
||||
$data['aggregator_item']['table']['group'] = t('Aggregator');
|
||||
|
||||
// Advertise this table as a possible base table
|
||||
// Advertise this table as a possible base table.
|
||||
$data['aggregator_item']['table']['base'] = array(
|
||||
'field' => 'iid',
|
||||
'title' => t('Aggregator item'),
|
||||
@ -27,43 +26,25 @@ function aggregator_views_data() {
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// Fields
|
||||
|
||||
// item id.
|
||||
$data['aggregator_item']['iid'] = array(
|
||||
'title' => t('Feed Item ID'),
|
||||
'help' => t('The unique ID of the aggregator item.'),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_numeric',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_numeric',
|
||||
'numeric' => TRUE,
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_numeric',
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
);
|
||||
|
||||
// iid
|
||||
// Item ID / 'iid'.
|
||||
$data['aggregator_item']['iid'] = array(
|
||||
// The item it appears as on the UI,
|
||||
'title' => t('Item ID'),
|
||||
'help' => t('The unique ID of the aggregator item.'), // The help that appears on the UI,
|
||||
// Information for displaying the iid
|
||||
// The help that appears on the UI,
|
||||
'help' => t('The unique ID of the aggregator item.'),
|
||||
// Information for displaying the iid.
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_numeric',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
// Information for accepting a iid as an argument
|
||||
// Information for accepting a iid as an argument.
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_aggregator_iid',
|
||||
'name field' => 'title', // the field to display in the summary.
|
||||
'name field' => 'title',
|
||||
// The field to display in the summary.
|
||||
'numeric' => TRUE,
|
||||
),
|
||||
// Information for accepting a nid as a filter
|
||||
// Information for accepting a nid as a filter.
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_numeric',
|
||||
),
|
||||
@ -73,55 +54,58 @@ function aggregator_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
// title
|
||||
// Title.
|
||||
$data['aggregator_item']['title'] = array(
|
||||
'title' => t('Title'), // The item it appears as on the UI,
|
||||
// The item it appears as on the UI,
|
||||
'title' => t('Title'),
|
||||
'help' => t('The title of the aggregator item.'),
|
||||
// Information for displaying a title as a field
|
||||
// Information for displaying a title as a field.
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_aggregator_title_link',
|
||||
'extra' => array('link'),
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
// Information for accepting a title as a filter
|
||||
// Information for accepting a title as a filter.
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
);
|
||||
|
||||
// link
|
||||
// Link.
|
||||
$data['aggregator_item']['link'] = array(
|
||||
'title' => t('Link'), // The item it appears as on the UI,
|
||||
// The item it appears as on the UI,
|
||||
'title' => t('Link'),
|
||||
'help' => t('The link to the original source URL of the item.'),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_url',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
// Information for accepting a title as a filter
|
||||
// Information for accepting a title as a filter.
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
);
|
||||
|
||||
// author
|
||||
// Author.
|
||||
$data['aggregator_item']['author'] = array(
|
||||
'title' => t('Author'), // The item it appears as on the UI,
|
||||
// The item it appears as on the UI,
|
||||
'title' => t('Author'),
|
||||
'help' => t('The author of the original imported item.'),
|
||||
// Information for displaying a title as a field
|
||||
// Information for displaying a title as a field.
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_aggregator_xss',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
// Information for accepting a title as a filter
|
||||
// Information for accepting a title as a filter.
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
@ -130,19 +114,20 @@ function aggregator_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
// guid
|
||||
// 'guid'.
|
||||
$data['aggregator_item']['guid'] = array(
|
||||
'title' => t('GUID'), // The item it appears as on the UI,
|
||||
// The item it appears as on the UI,
|
||||
'title' => t('GUID'),
|
||||
'help' => t('The guid of the original imported item.'),
|
||||
// Information for displaying a title as a field
|
||||
// Information for displaying a title as a field.
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_xss',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
// Information for accepting a title as a filter
|
||||
// Information for accepting a title as a filter.
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
@ -151,34 +136,36 @@ function aggregator_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
// feed body
|
||||
// Feed body.
|
||||
$data['aggregator_item']['description'] = array(
|
||||
'title' => t('Body'), // The item it appears as on the UI,
|
||||
// The item it appears as on the UI,
|
||||
'title' => t('Body'),
|
||||
'help' => t('The actual content of the imported item.'),
|
||||
// Information for displaying a title as a field
|
||||
// Information for displaying a title as a field.
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_aggregator_xss',
|
||||
'click sortable' => FALSE,
|
||||
),
|
||||
// Information for accepting a title as a filter
|
||||
),
|
||||
// Information for accepting a title as a filter.
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
);
|
||||
|
||||
// item timestamp
|
||||
// Item timestamp.
|
||||
$data['aggregator_item']['timestamp'] = array(
|
||||
'title' => t('Timestamp'), // The item it appears as on the UI,
|
||||
// The item it appears as on the UI,
|
||||
'title' => t('Timestamp'),
|
||||
'help' => t('The date the original feed item was posted. (With some feeds, this will be the date it was imported.)'),
|
||||
// Information for displaying a title as a field
|
||||
// Information for displaying a title as a field.
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_date',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort_date',
|
||||
),
|
||||
// Information for accepting a title as a filter
|
||||
// Information for accepting a title as a filter.
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_date',
|
||||
),
|
||||
@ -187,10 +174,8 @@ function aggregator_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Aggregator feed table
|
||||
|
||||
// Aggregator feed table.
|
||||
$data['aggregator_feed']['table']['group'] = t('Aggregator feed');
|
||||
|
||||
// Explain how this table joins to others.
|
||||
@ -201,22 +186,25 @@ function aggregator_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
// fid
|
||||
// Feed ID / 'fid'.
|
||||
$data['aggregator_feed']['fid'] = array(
|
||||
// The item it appears as on the UI,
|
||||
'title' => t('Feed ID'),
|
||||
'help' => t('The unique ID of the aggregator feed.'), // The help that appears on the UI,
|
||||
// Information for displaying the fid
|
||||
// The help that appears on the UI,
|
||||
'help' => t('The unique ID of the aggregator feed.'),
|
||||
// Information for displaying the fid.
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_numeric',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
// Information for accepting a fid as an argument
|
||||
// Information for accepting a fid as an argument.
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_aggregator_fid',
|
||||
'name field' => 'title', // the field to display in the summary.
|
||||
'name field' => 'title',
|
||||
// The field to display in the summary.
|
||||
'numeric' => TRUE,
|
||||
),
|
||||
// Information for accepting a nid as a filter
|
||||
// Information for accepting a nid as a filter.
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_numeric',
|
||||
),
|
||||
@ -226,20 +214,22 @@ function aggregator_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
// title
|
||||
// Title.
|
||||
$data['aggregator_feed']['title'] = array(
|
||||
'title' => t('Title'), // The item it appears as on the UI,
|
||||
// The item it appears as on the UI,
|
||||
'title' => t('Title'),
|
||||
// The help that appears on the UI,
|
||||
'help' => t('The title of the aggregator feed.'),
|
||||
// Information for displaying a title as a field
|
||||
// Information for displaying a title as a field.
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_aggregator_title_link',
|
||||
'extra' => array('link'),
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
// Information for accepting a title as a filter
|
||||
// Information for accepting a title as a filter.
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
@ -248,15 +238,16 @@ function aggregator_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
// link
|
||||
// Link.
|
||||
$data['aggregator_feed']['link'] = array(
|
||||
'title' => t('Link'), // The item it appears as on the UI,
|
||||
// The item it appears as on the UI,
|
||||
'title' => t('Link'),
|
||||
'help' => t('The link to the source URL of the feed.'),
|
||||
// Information for displaying a title as a field
|
||||
// Information for displaying a title as a field.
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_url',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
@ -265,15 +256,16 @@ function aggregator_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
// feed last updated
|
||||
// Feed last updated.
|
||||
$data['aggregator_feed']['checked'] = array(
|
||||
'title' => t('Last checked'), // The item it appears as on the UI,
|
||||
// The item it appears as on the UI,
|
||||
'title' => t('Last checked'),
|
||||
'help' => t('The date the feed was last checked for new content.'),
|
||||
// Information for displaying a title as a field
|
||||
// Information for displaying a title as a field.
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_date',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort_date',
|
||||
),
|
||||
@ -285,33 +277,35 @@ function aggregator_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
// feed description
|
||||
// Feed description.
|
||||
$data['aggregator_feed']['description'] = array(
|
||||
'title' => t('Description'), // The item it appears as on the UI,
|
||||
// The item it appears as on the UI,
|
||||
'title' => t('Description'),
|
||||
'help' => t('The description of the aggregator feed.'),
|
||||
// Information for displaying a title as a field
|
||||
// Information for displaying a title as a field.
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_xss',
|
||||
'click sortable' => FALSE,
|
||||
),
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
);
|
||||
|
||||
// feed last updated
|
||||
// Feed last updated.
|
||||
$data['aggregator_feed']['modified'] = array(
|
||||
'title' => t('Last modified'), // The item it appears as on the UI,
|
||||
// The item it appears as on the UI,
|
||||
'title' => t('Last modified'),
|
||||
'help' => t('The date of the most recent new content on the feed.'),
|
||||
// Information for displaying a title as a field
|
||||
// Information for displaying a title as a field.
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_date',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort_date',
|
||||
),
|
||||
// Information for accepting a title as a filter
|
||||
// Information for accepting a title as a filter.
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_date',
|
||||
),
|
||||
@ -321,8 +315,7 @@ function aggregator_views_data() {
|
||||
);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Aggregator category feed table
|
||||
|
||||
// Aggregator category feed table.
|
||||
$data['aggregator_category_feed']['table']['join'] = array(
|
||||
'aggregator_item' => array(
|
||||
'left_field' => 'fid',
|
||||
@ -331,8 +324,7 @@ function aggregator_views_data() {
|
||||
);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Aggregator category table
|
||||
|
||||
// Aggregator category table.
|
||||
$data['aggregator_category']['table']['group'] = t('Aggregator category');
|
||||
|
||||
$data['aggregator_category']['table']['join'] = array(
|
||||
@ -343,7 +335,7 @@ function aggregator_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
// cid
|
||||
// Category ID / 'cid'.
|
||||
$data['aggregator_category']['cid'] = array(
|
||||
'title' => t('Category ID'),
|
||||
'help' => t('The unique ID of the aggregator category.'),
|
||||
@ -364,14 +356,14 @@ function aggregator_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
// title
|
||||
// Title.
|
||||
$data['aggregator_category']['title'] = array(
|
||||
'title' => t('Category'),
|
||||
'help' => t('The title of the aggregator category.'),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_aggregator_category',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
@ -388,15 +380,18 @@ function aggregator_views_data() {
|
||||
*/
|
||||
function aggregator_views_plugins() {
|
||||
return array(
|
||||
'module' => 'views', // This just tells our themes are elsewhere.
|
||||
'module' => 'views',
|
||||
// This just tells our themes are elsewhere.
|
||||
'row' => array(
|
||||
'aggregator_rss' => array(
|
||||
'title' => t('Aggregator item'),
|
||||
'help' => t('Display the aggregator item using the data from the original source.'),
|
||||
'handler' => 'views_plugin_row_aggregator_rss',
|
||||
'path' => drupal_get_path('module', 'views') . '/modules/node', // not necessary for most modules
|
||||
'path' => drupal_get_path('module', 'views') . '/modules/node',
|
||||
// Not necessary for most modules.
|
||||
'theme' => 'views_view_row_rss',
|
||||
'base' => array('aggregator_item'), // only works with 'node' as base.
|
||||
'base' => array('aggregator_item'),
|
||||
// Only works with 'node' as base.
|
||||
'uses options' => TRUE,
|
||||
'type' => 'feed',
|
||||
'help topic' => 'style-aggregator-rss',
|
||||
|
@ -11,10 +11,11 @@
|
||||
* @ingroup views_argument_handlers
|
||||
*/
|
||||
class views_handler_argument_aggregator_category_cid extends views_handler_argument_numeric {
|
||||
|
||||
/**
|
||||
* Override the behavior of title(). Get the title of the category.
|
||||
*/
|
||||
function title_query() {
|
||||
public function title_query() {
|
||||
$titles = array();
|
||||
|
||||
$result = db_query("SELECT c.title FROM {aggregator_category} c WHERE c.cid IN (:cid)", array(':cid' => $this->value));
|
||||
@ -23,4 +24,5 @@ class views_handler_argument_aggregator_category_cid extends views_handler_argum
|
||||
}
|
||||
return $titles;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,10 +11,11 @@
|
||||
* @ingroup views_argument_handlers
|
||||
*/
|
||||
class views_handler_argument_aggregator_fid extends views_handler_argument_numeric {
|
||||
|
||||
/**
|
||||
* Override the behavior of title(). Get the title of the feed.
|
||||
*/
|
||||
function title_query() {
|
||||
public function title_query() {
|
||||
$titles = array();
|
||||
|
||||
$result = db_query("SELECT f.title FROM {aggregator_feed} f WHERE f.fid IN (:fids)", array(':fids' => $this->value));
|
||||
@ -23,4 +24,5 @@ class views_handler_argument_aggregator_fid extends views_handler_argument_numer
|
||||
}
|
||||
return $titles;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,10 +11,11 @@
|
||||
* @ingroup views_argument_handlers
|
||||
*/
|
||||
class views_handler_argument_aggregator_iid extends views_handler_argument_numeric {
|
||||
|
||||
/**
|
||||
* Override the behavior of title(). Get the title of the category.
|
||||
*/
|
||||
function title_query() {
|
||||
public function title_query() {
|
||||
$titles = array();
|
||||
$placeholders = implode(', ', array_fill(0, sizeof($this->value), '%d'));
|
||||
|
||||
@ -27,4 +28,5 @@ class views_handler_argument_aggregator_iid extends views_handler_argument_numer
|
||||
}
|
||||
return $titles;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,15 +12,19 @@
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_aggregator_category extends views_handler_field {
|
||||
|
||||
/**
|
||||
* Constructor to provide additional field to add.
|
||||
*/
|
||||
function construct() {
|
||||
public function construct() {
|
||||
parent::construct();
|
||||
$this->additional_fields['cid'] = 'cid';
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['link_to_category'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
return $options;
|
||||
@ -29,7 +33,7 @@ class views_handler_field_aggregator_category extends views_handler_field {
|
||||
/**
|
||||
* Provide link to category option
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
public function options_form(&$form, &$form_state) {
|
||||
$form['link_to_category'] = array(
|
||||
'#title' => t('Link this field to its aggregator category page'),
|
||||
'#description' => t('This will override any other link you have set.'),
|
||||
@ -44,7 +48,7 @@ class views_handler_field_aggregator_category extends views_handler_field {
|
||||
*
|
||||
* Data should be made XSS safe prior to calling this function.
|
||||
*/
|
||||
function render_link($data, $values) {
|
||||
public function render_link($data, $values) {
|
||||
$cid = $this->get_value($values, 'cid');
|
||||
if (!empty($this->options['link_to_category']) && !empty($cid) && $data !== NULL && $data !== '') {
|
||||
$this->options['alter']['make_link'] = TRUE;
|
||||
@ -53,8 +57,12 @@ class views_handler_field_aggregator_category extends views_handler_field {
|
||||
return $data;
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render($values) {
|
||||
$value = $this->get_value($values);
|
||||
return $this->render_link($this->sanitize_value($value), $values);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,18 +6,25 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Field handler that turns an item's title into a clickable link to the original
|
||||
* source article.
|
||||
* Field handler that turns an item's title into a clickable link to the
|
||||
* original source article.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_aggregator_title_link extends views_handler_field {
|
||||
function construct() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function construct() {
|
||||
parent::construct();
|
||||
$this->additional_fields['link'] = 'link';
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['display_as_link'] = array('default' => TRUE, 'bool' => TRUE);
|
||||
@ -28,7 +35,7 @@ class views_handler_field_aggregator_title_link extends views_handler_field {
|
||||
/**
|
||||
* Provide link to the page being visited.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
public function options_form(&$form, &$form_state) {
|
||||
$form['display_as_link'] = array(
|
||||
'#title' => t('Display as link'),
|
||||
'#type' => 'checkbox',
|
||||
@ -37,12 +44,18 @@ class views_handler_field_aggregator_title_link extends views_handler_field {
|
||||
parent::options_form($form, $form_state);
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render($values) {
|
||||
$value = $this->get_value($values);
|
||||
return $this->render_link($this->sanitize_value($value), $values);
|
||||
}
|
||||
|
||||
function render_link($data, $values) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render_link($data, $values) {
|
||||
$link = $this->get_value($values, 'link');
|
||||
if (!empty($this->options['display_as_link'])) {
|
||||
$this->options['alter']['make_link'] = TRUE;
|
||||
@ -52,4 +65,5 @@ class views_handler_field_aggregator_title_link extends views_handler_field {
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,8 +11,13 @@
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_aggregator_xss extends views_handler_field {
|
||||
function render($values) {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render($values) {
|
||||
$value = $this->get_value($values);
|
||||
return aggregator_filter_xss($value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,11 @@
|
||||
* @ingroup views_filter_handlers
|
||||
*/
|
||||
class views_handler_filter_aggregator_category_cid extends views_handler_filter_in_operator {
|
||||
function get_value_options() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_value_options() {
|
||||
if (isset($this->value_options)) {
|
||||
return;
|
||||
}
|
||||
@ -23,4 +27,5 @@ class views_handler_filter_aggregator_category_cid extends views_handler_filter_
|
||||
$this->value_options[$category->cid] = $category->title;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,17 +2,28 @@
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the Aggregator Item RSS row style plugin.
|
||||
* Definition of views_plugin_row_aggregator_rss.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plugin which loads an aggregator item and formats it as an RSS item.
|
||||
*/
|
||||
class views_plugin_row_aggregator_rss extends views_plugin_row {
|
||||
var $base_table = 'aggregator_item';
|
||||
var $base_field = 'iid';
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public $base_table = 'aggregator_item';
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public $base_field = 'iid';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['item_length'] = array('default' => 'default');
|
||||
@ -20,7 +31,10 @@ class views_plugin_row_aggregator_rss extends views_plugin_row {
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_form(&$form, &$form_state) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function options_form(&$form, &$form_state) {
|
||||
$form['item_length'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Display type'),
|
||||
@ -34,7 +48,10 @@ class views_plugin_row_aggregator_rss extends views_plugin_row {
|
||||
);
|
||||
}
|
||||
|
||||
function render($row) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render($row) {
|
||||
$iid = $row->{$this->field_alias};
|
||||
$sql = "SELECT ai.iid, ai.fid, ai.title, ai.link, ai.author, ai.description, ";
|
||||
$sql .= "ai.timestamp, ai.guid, af.title AS feed_title, ai.link AS feed_LINK ";
|
||||
@ -71,4 +88,5 @@ class views_plugin_row_aggregator_rss extends views_plugin_row {
|
||||
'row' => $item
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,8 +12,7 @@
|
||||
*/
|
||||
function book_views_data() {
|
||||
// ----------------------------------------------------------------------
|
||||
// book table
|
||||
|
||||
// 'book' table.
|
||||
$data['book']['table']['group'] = t('Book');
|
||||
$data['book']['table']['join'] = array(
|
||||
'node' => array(
|
||||
@ -35,8 +34,7 @@ function book_views_data() {
|
||||
);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// menu_links table -- this is aliased so we can get just book relations
|
||||
|
||||
// 'menu_links' table -- this is aliased so we can get just book relations.
|
||||
// Book hierarchy and weight data are now in {menu_links}.
|
||||
$data['book_menu_links']['table']['group'] = t('Book');
|
||||
$data['book_menu_links']['table']['join'] = array(
|
||||
@ -87,9 +85,8 @@ function book_views_data() {
|
||||
);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// book_parent table -- this is an alias of the book table which
|
||||
// 'book_parent' table -- this is an alias of the book table which
|
||||
// represents the parent book.
|
||||
|
||||
// The {book} record for the parent node.
|
||||
$data['book_parent']['table']['group'] = t('Book');
|
||||
$data['book_parent']['table']['join'] = array(
|
||||
@ -119,13 +116,13 @@ function book_views_data() {
|
||||
* Implements hook_views_plugins().
|
||||
*/
|
||||
function book_views_plugins() {
|
||||
return array(
|
||||
'module' => 'views',
|
||||
'argument default' => array(
|
||||
'book_root' => array(
|
||||
'title' => t('Book root from current node'),
|
||||
'handler' => 'views_plugin_argument_default_book_root'
|
||||
),
|
||||
),
|
||||
);
|
||||
return array(
|
||||
'module' => 'views',
|
||||
'argument default' => array(
|
||||
'book_root' => array(
|
||||
'title' => t('Book root from current node'),
|
||||
'handler' => 'views_plugin_argument_default_book_root',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -1,14 +1,19 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains the book root from current node argument default plugin.
|
||||
* Definition of views_plugin_argument_default_book_root.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Default argument plugin to get the current node's book root.
|
||||
*/
|
||||
class views_plugin_argument_default_book_root extends views_plugin_argument_default_node {
|
||||
function get_argument() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_argument() {
|
||||
// Use the argument_default_node plugin to get the nid argument.
|
||||
$nid = parent::get_argument();
|
||||
if (!empty($nid)) {
|
||||
@ -18,4 +23,5 @@ class views_plugin_argument_default_book_root extends views_plugin_argument_defa
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,13 +10,12 @@
|
||||
/**
|
||||
* Implements hook_views_data().
|
||||
*/
|
||||
|
||||
function comment_views_data() {
|
||||
$data['comments']['moved to'] = 'comment';
|
||||
$data['comment']['comment']['moved to'] = array('field_data_comment_body', 'comment_body');
|
||||
$data['comment']['comment']['field']['moved to'] = array('field_data_comment_body', 'comment_body');
|
||||
// Define the base group of this table. Fields that don't
|
||||
// have a group defined will go into this field by default.
|
||||
// Define the base group of this table. Fields that don't have a group
|
||||
// defined will go into this field by default.
|
||||
$data['comment']['table']['group'] = t('Comment');
|
||||
|
||||
$data['comment']['table']['base'] = array(
|
||||
@ -36,9 +35,8 @@ function comment_views_data() {
|
||||
);
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// Fields
|
||||
|
||||
// subject
|
||||
// Fields.
|
||||
// Subject.
|
||||
$data['comment']['subject'] = array(
|
||||
'title' => t('Title'),
|
||||
'help' => t('The title of the comment.'),
|
||||
@ -57,7 +55,7 @@ function comment_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
// cid
|
||||
// Comment ID / 'cid'.
|
||||
$data['comment']['cid'] = array(
|
||||
'title' => t('ID'),
|
||||
'help' => t('The comment ID of the field'),
|
||||
@ -76,7 +74,7 @@ function comment_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
// name (of comment author)
|
||||
// Username of the comment author.
|
||||
$data['comment']['name'] = array(
|
||||
'title' => t('Author'),
|
||||
'help' => t("The name of the comment's author. Can be rendered as a link to the author's homepage."),
|
||||
@ -95,7 +93,7 @@ function comment_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
// homepage
|
||||
// Homepage.
|
||||
$data['comment']['homepage'] = array(
|
||||
'title' => t("Author's website"),
|
||||
'help' => t("The website address of the comment's author. Can be rendered as a link. Will be empty if the author is a registered user."),
|
||||
@ -114,14 +112,14 @@ function comment_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
// hostname
|
||||
// hostname.
|
||||
$data['comment']['hostname'] = array(
|
||||
'title' => t('Hostname'),
|
||||
'help' => t('Hostname of user that posted the comment.'),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
@ -133,14 +131,14 @@ function comment_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
// mail
|
||||
// Email address.
|
||||
$data['comment']['mail'] = array(
|
||||
'title' => t('Mail'),
|
||||
'help' => t('Email of user that posted the comment. Will be empty if the author is a registered user.'),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
@ -152,7 +150,7 @@ function comment_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
// created (when comment was posted)
|
||||
// Created - when comment was posted.
|
||||
$data['comment']['created'] = array(
|
||||
'title' => t('Post date'),
|
||||
'help' => t('Date and time of when the comment was created.'),
|
||||
@ -222,7 +220,7 @@ function comment_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
// Language field
|
||||
// Language field.
|
||||
if (module_exists('locale')) {
|
||||
$data['comment']['language'] = array(
|
||||
'title' => t('Language'),
|
||||
@ -244,7 +242,7 @@ function comment_views_data() {
|
||||
}
|
||||
|
||||
$data['comments']['timestamp']['moved to'] = array('comment', 'changed');
|
||||
// changed (when comment was last updated)
|
||||
// Changed (when comment was last updated).
|
||||
$data['comment']['changed'] = array(
|
||||
'title' => t('Updated date'),
|
||||
'help' => t('Date and time of when the comment was last updated.'),
|
||||
@ -320,7 +318,7 @@ function comment_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
// status (approved or not)
|
||||
// Status (approved or not).
|
||||
$data['comment']['status'] = array(
|
||||
'title' => t('Approved'),
|
||||
'help' => t('Whether the comment is approved (or still in the moderation queue).'),
|
||||
@ -341,7 +339,7 @@ function comment_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
// link to view comment
|
||||
// Link to view comment.
|
||||
$data['comment']['view_comment'] = array(
|
||||
'field' => array(
|
||||
'title' => t('View link'),
|
||||
@ -350,7 +348,7 @@ function comment_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
// link to edit comment
|
||||
// Link to edit comment.
|
||||
$data['comment']['edit_comment'] = array(
|
||||
'field' => array(
|
||||
'title' => t('Edit link'),
|
||||
@ -359,7 +357,7 @@ function comment_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
// link to delete comment
|
||||
// Link to delete comment.
|
||||
$data['comment']['delete_comment'] = array(
|
||||
'field' => array(
|
||||
'title' => t('Delete link'),
|
||||
@ -368,8 +366,7 @@ function comment_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
// link to approve comment
|
||||
// Link to approve comment.
|
||||
$data['comment']['approve_comment'] = array(
|
||||
'field' => array(
|
||||
'title' => t('Approve link'),
|
||||
@ -378,7 +375,7 @@ function comment_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
// link to reply to comment
|
||||
// Link to reply to comment.
|
||||
$data['comment']['replyto_comment'] = array(
|
||||
'field' => array(
|
||||
'title' => t('Reply-to link'),
|
||||
@ -461,22 +458,21 @@ function comment_views_data() {
|
||||
);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// node_comment_statistics table
|
||||
|
||||
// define the group
|
||||
// 'node_comment_statistics' table.
|
||||
// Define the group.
|
||||
$data['node_comment_statistics']['table']['group'] = t('Content');
|
||||
|
||||
// joins
|
||||
// Joins.
|
||||
$data['node_comment_statistics']['table']['join'] = array(
|
||||
//...to the node table
|
||||
// ...to the node table.
|
||||
'node' => array(
|
||||
'type' => 'INNER',
|
||||
'left_field' => 'nid',
|
||||
'field' => 'nid',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// last_comment_timestamp
|
||||
// Timestamp of the last comment.
|
||||
$data['node_comment_statistics']['last_comment_timestamp'] = array(
|
||||
'title' => t('Last comment time'),
|
||||
'help' => t('Date and time of when the last comment was posted.'),
|
||||
@ -492,7 +488,7 @@ function comment_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
// last_comment_name (author's name)
|
||||
// Last comment author's username.
|
||||
$data['node_comment_statistics']['last_comment_name'] = array(
|
||||
'title' => t("Last comment author"),
|
||||
'help' => t('The name of the author of the last posted comment.'),
|
||||
@ -507,7 +503,7 @@ function comment_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
// comment_count
|
||||
// Comment count.
|
||||
$data['node_comment_statistics']['comment_count'] = array(
|
||||
'title' => t('Comment count'),
|
||||
'help' => t('The number of comments a node has.'),
|
||||
@ -526,7 +522,7 @@ function comment_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
// last_comment_timestamp
|
||||
// Timestamp of when the last comment update happened.
|
||||
$data['node_comment_statistics']['last_updated'] = array(
|
||||
'title' => t('Updated/commented date'),
|
||||
'help' => t('The most recent of last comment posted or node updated time.'),
|
||||
@ -558,7 +554,7 @@ function comment_views_data() {
|
||||
),
|
||||
);
|
||||
|
||||
// last_comment_uid
|
||||
// The user ID / 'uid' of the user who last posted a comment.
|
||||
$data['node_comment_statistics']['last_comment_uid'] = array(
|
||||
'title' => t('Last comment uid'),
|
||||
'help' => t('The User ID of the author of the last comment of a node.'),
|
||||
@ -584,11 +580,12 @@ function comment_views_data() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Use views_data_alter to add items to the node table that are
|
||||
* relevant to comments.
|
||||
* Implements hook_views_data_alter() on behalf of comment.module.
|
||||
*
|
||||
* Add items to the node table that are relevant to comments.
|
||||
*/
|
||||
function comment_views_data_alter(&$data) {
|
||||
// new comments
|
||||
// New comments.
|
||||
$data['node']['new_comments'] = array(
|
||||
'title' => t('New comments'),
|
||||
'help' => t('The number of new comments on the node.'),
|
||||
@ -606,7 +603,7 @@ function comment_views_data_alter(&$data) {
|
||||
),
|
||||
);
|
||||
|
||||
// Comment status of the node
|
||||
// Comment status of the node.
|
||||
$data['node']['comment'] = array(
|
||||
'title' => t('Comment status'),
|
||||
'help' => t('Whether comments are enabled or disabled on the node.'),
|
||||
@ -636,7 +633,7 @@ function comment_views_data_alter(&$data) {
|
||||
'field' => 'uid',
|
||||
'name table' => 'users',
|
||||
'name field' => 'name',
|
||||
'handler' => 'views_handler_filter_comment_user_uid'
|
||||
'handler' => 'views_handler_filter_comment_user_uid',
|
||||
),
|
||||
);
|
||||
|
||||
@ -652,7 +649,6 @@ function comment_views_data_alter(&$data) {
|
||||
'handler' => 'views_handler_relationship',
|
||||
),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -667,8 +663,10 @@ function comment_views_plugins() {
|
||||
'help' => t('Display the comment with standard comment view.'),
|
||||
'handler' => 'views_plugin_row_comment_view',
|
||||
'theme' => 'views_view_row_comment',
|
||||
'path' => drupal_get_path('module', 'views') . '/modules/comment', // not necessary for most modules
|
||||
'base' => array('comment'), // only works with 'comment' as base.
|
||||
'path' => drupal_get_path('module', 'views') . '/modules/comment',
|
||||
// Not necessary for most modules.
|
||||
'base' => array('comment'),
|
||||
// Only works with 'comment' as base.
|
||||
'uses options' => TRUE,
|
||||
'type' => 'normal',
|
||||
'help topic' => 'style-comment',
|
||||
@ -678,8 +676,10 @@ function comment_views_plugins() {
|
||||
'help' => t('Display the comment as RSS.'),
|
||||
'handler' => 'views_plugin_row_comment_rss',
|
||||
'theme' => 'views_view_row_rss',
|
||||
'path' => drupal_get_path('module', 'views') . '/modules/comment', // not necessary for most modules
|
||||
'base' => array('comment'), // only works with 'comment' as base.
|
||||
'path' => drupal_get_path('module', 'views') . '/modules/comment',
|
||||
// Not necessary for most modules.
|
||||
'base' => array('comment'),
|
||||
// Only works with 'comment' as base.
|
||||
'uses options' => TRUE,
|
||||
'type' => 'feed',
|
||||
'help topic' => 'style-comment-rss',
|
||||
@ -689,7 +689,7 @@ function comment_views_plugins() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Template helper for theme_views_view_row_comment
|
||||
* Template helper for theme_views_view_row_comment.
|
||||
*/
|
||||
function template_preprocess_views_view_row_comment(&$vars) {
|
||||
$options = $vars['options'];
|
||||
@ -701,9 +701,9 @@ function template_preprocess_views_view_row_comment(&$vars) {
|
||||
$node->view = &$view;
|
||||
|
||||
$build = comment_view_multiple(array($comment->cid => $comment), $node, $plugin->options['view_mode']);
|
||||
// If we're displaying the comments without links, remove them from the
|
||||
// renderable array. There is no way to avoid building them in the first
|
||||
// place (see comment_build_content()).
|
||||
// If displaying the comments without links, remove them from the renderable
|
||||
// array; there is no way to avoid building them in the first place.
|
||||
// @see comment_build_content()
|
||||
if (empty($options['links'])) {
|
||||
foreach ($build as $cid => &$comment_build) {
|
||||
if (isset($comment_build['links'])) {
|
||||
|
@ -6,12 +6,12 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_views_default_views()
|
||||
* Implements hook_views_default_views().
|
||||
*/
|
||||
function comment_views_default_views() {
|
||||
$views = array();
|
||||
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'comments_recent';
|
||||
$view->description = 'Contains a block and a page to list recent comments; the block will automatically link to the page, which displays the comment body as well as a link to the node.';
|
||||
$view->tag = 'default';
|
||||
@ -122,7 +122,7 @@ function comment_views_default_views() {
|
||||
|
||||
$views['comments_recent'] = $view;
|
||||
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'tracker';
|
||||
$view->description = 'Shows all new activity on system.';
|
||||
$view->tag = 'default';
|
||||
|
@ -12,7 +12,11 @@
|
||||
* @ingroup views_argument_handlers
|
||||
*/
|
||||
class views_handler_argument_comment_user_uid extends views_handler_argument {
|
||||
function title() {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function title() {
|
||||
if (!$this->argument) {
|
||||
$title = variable_get('anonymous', t('Anonymous'));
|
||||
}
|
||||
@ -26,7 +30,10 @@ class views_handler_argument_comment_user_uid extends views_handler_argument {
|
||||
return check_plain($title);
|
||||
}
|
||||
|
||||
function default_actions($which = NULL) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function default_actions($which = NULL) {
|
||||
// Disallow summary views on this argument.
|
||||
if (!$which) {
|
||||
$actions = parent::default_actions();
|
||||
@ -40,7 +47,10 @@ class views_handler_argument_comment_user_uid extends views_handler_argument {
|
||||
}
|
||||
}
|
||||
|
||||
function query($group_by = FALSE) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query($group_by = FALSE) {
|
||||
$this->ensure_my_table();
|
||||
|
||||
$subselect = db_select('comment', 'c');
|
||||
@ -55,7 +65,11 @@ class views_handler_argument_comment_user_uid extends views_handler_argument {
|
||||
$this->query->add_where(0, $condition);
|
||||
}
|
||||
|
||||
function get_sort_name() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_sort_name() {
|
||||
return t('Numerical', array(), array('context' => 'Sort order'));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,10 +11,11 @@
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_comment extends views_handler_field {
|
||||
|
||||
/**
|
||||
* Override init function to provide generic option to link to comment.
|
||||
*/
|
||||
function init(&$view, &$options) {
|
||||
public function init(&$view, &$options) {
|
||||
parent::init($view, $options);
|
||||
if (!empty($this->options['link_to_comment'])) {
|
||||
$this->additional_fields['cid'] = 'cid';
|
||||
@ -22,7 +23,10 @@ class views_handler_field_comment extends views_handler_field {
|
||||
}
|
||||
}
|
||||
|
||||
function option_definition() {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['link_to_comment'] = array('default' => TRUE, 'bool' => TRUE);
|
||||
$options['link_to_node'] = array('default' => FALSE, 'bool' => TRUE);
|
||||
@ -31,9 +35,9 @@ class views_handler_field_comment extends views_handler_field {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide link-to-comment option
|
||||
* Provide link-to-comment option.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
public function options_form(&$form, &$form_state) {
|
||||
$form['link_to_comment'] = array(
|
||||
'#title' => t('Link this field to its comment'),
|
||||
'#description' => t("Enable to override this field's links."),
|
||||
@ -48,7 +52,10 @@ class views_handler_field_comment extends views_handler_field {
|
||||
parent::options_form($form, $form_state);
|
||||
}
|
||||
|
||||
function render_link($data, $values) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render_link($data, $values) {
|
||||
if (!empty($this->options['link_to_comment'])) {
|
||||
$this->options['alter']['make_link'] = TRUE;
|
||||
$nid = $this->get_value($values, 'nid');
|
||||
@ -58,7 +65,7 @@ class views_handler_field_comment extends views_handler_field {
|
||||
$this->options['alter']['fragment'] = "comment-" . $cid;
|
||||
}
|
||||
// If there is no comment link to the node.
|
||||
else if ($this->options['link_to_node']) {
|
||||
elseif ($this->options['link_to_node']) {
|
||||
$this->options['alter']['path'] = "node/" . $nid;
|
||||
}
|
||||
}
|
||||
@ -66,8 +73,12 @@ class views_handler_field_comment extends views_handler_field {
|
||||
return $data;
|
||||
}
|
||||
|
||||
function render($values) {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render($values) {
|
||||
$value = $this->get_value($values);
|
||||
return $this->render_link($this->sanitize_value($value), $values);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,11 +11,13 @@
|
||||
* @ingroup views_field_handlers
|
||||
*/
|
||||
class views_handler_field_comment_depth extends views_handler_field {
|
||||
|
||||
/**
|
||||
* Work out the depth of this comment
|
||||
* Work out the depth of this comment.
|
||||
*/
|
||||
function render($values) {
|
||||
public function render($values) {
|
||||
$comment_thread = $this->get_value($values);
|
||||
return count(explode('.', $comment_thread)) - 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user