Skip to content

Commit

Permalink
Merge pull request #485 from seamuslee001/civilint-handler-part1
Browse files Browse the repository at this point in the history
Run Civilint against first half of civicrm_handler_field files
  • Loading branch information
eileenmcnaughton authored Sep 18, 2017
2 parents bb8cc34 + bab2a09 commit 74514dd
Show file tree
Hide file tree
Showing 22 changed files with 190 additions and 194 deletions.
12 changes: 6 additions & 6 deletions modules/views/civicrm/civicrm_handler_field.inc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
*/

/**
* Field handler to provide simple renderer that allows linking to a user.
Expand All @@ -33,14 +33,14 @@ class civicrm_handler_field extends views_handler_field {
/**
* Override init function to provide generic option to link to user.
*/
function init(&$view, &$data) {
public function init(&$view, &$data) {
parent::init($view, $data);
}

/**
* Provide link to node option
*/
function options_form(&$form, &$form_state) {
public function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['link_to_civicrm'] = array(
'#title' => t('Link this field to its user'),
Expand All @@ -49,7 +49,7 @@ class civicrm_handler_field extends views_handler_field {
);
}

function render_link($data, $values) {
public function render_link($data, $values) {
$data = str_replace('', ', ', trim($data, ''));
if (!empty($this->options['link_to_civicrm']) && user_access('access CiviCRM') && $values->id) {
return civicrm_views_href($data,
Expand All @@ -62,8 +62,8 @@ class civicrm_handler_field extends views_handler_field {
}
}

function render($values) {
public function render($values) {
return $this->render_link(check_plain($values->{$this->field_alias}), $values);
}
}

}
14 changes: 7 additions & 7 deletions modules/views/civicrm/civicrm_handler_field_activity.inc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
*/

/**
* Field handler for activity contact field
Expand All @@ -30,7 +30,7 @@
*/
class civicrm_handler_field_activity extends civicrm_handler_field {
static $_recordType;
function construct() {
public function construct() {
parent::construct();
if (!self::$_recordType) {
if (!civicrm_initialize()) {
Expand All @@ -40,13 +40,13 @@ class civicrm_handler_field_activity extends civicrm_handler_field {
}
}

function option_definition() {
public function option_definition() {
$options = parent::option_definition();
$options['record_type'] = array('default' => 0);
return $options;
}

function options_form(&$form, &$form_state) {
public function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$recordTypes = array(0 => 'Any');
foreach (self::$_recordType as $id => $type) {
Expand All @@ -65,7 +65,7 @@ class civicrm_handler_field_activity extends civicrm_handler_field {
/**
* Called to link activity contact with civicrm_contact in a query.
*/
function query() {
public function query() {

// Figure out what base table
$table_data = views_fetch_data($this->definition['base']);
Expand All @@ -90,7 +90,7 @@ class civicrm_handler_field_activity extends civicrm_handler_field {
}

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();
Expand All @@ -115,5 +115,5 @@ class civicrm_handler_field_activity extends civicrm_handler_field {

$this->alias = $this->query->add_relationship($alias, $join, $this->definition['base'], $this->relationship);
}
}

}
21 changes: 11 additions & 10 deletions modules/views/civicrm/civicrm_handler_field_address.inc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
*/

/**
* Generic field handler for address and location fields
Expand All @@ -30,13 +30,13 @@
*/
class civicrm_handler_field_address extends civicrm_handler_field_location {

function option_definition() {
public function option_definition() {
$options = parent::option_definition();
$options['is_billing'] = array('default' => 0);
return $options;
}

function options_form(&$form, &$form_state) {
public function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['is_billing'] = array(
'#type' => 'checkbox',
Expand All @@ -48,7 +48,7 @@ class civicrm_handler_field_address extends civicrm_handler_field_location {
);
}

function join_address($join = array()) {
public function join_address($join = array()) {
$extra = array();
if (isset($join->extra)) {
$extra = $join->extra;
Expand All @@ -67,27 +67,28 @@ class civicrm_handler_field_address extends civicrm_handler_field_location {
return $join;
}

function get_join() {
public function get_join() {
$join = parent::get_join();
$join = $this->join_address($join);
return $join;
}

function ensure_my_table() {
public function ensure_my_table() {
if (!isset($this->table_alias)) {
if (!method_exists($this->query, 'ensure_table')) {
vpr_trace();
exit;
}
$join = $this->get_join();
if (empty($this->relationship)) { //https://www.drupal.org/node/2617032
if (empty($this->relationship)) {
//https://www.drupal.org/node/2617032
$this->table_alias = $this->query->add_table($this->table, $this->relationship, $join);
} else {
}
else {
$this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join);
}
}
return $this->table_alias;
}
}


}
7 changes: 3 additions & 4 deletions modules/views/civicrm/civicrm_handler_field_component.inc
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,17 @@
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
*/

/**
* Field handler to provide a human-readable CiviCRM component name
*
* @ingroup civicrm_field_handlers
*/
class civicrm_handler_field_component extends views_handler_field {
function render($values) {
public function render($values) {
$value = $this->get_value($values);
return CRM_Core_Component::getComponentName($value);
}
}


}
8 changes: 4 additions & 4 deletions modules/views/civicrm/civicrm_handler_field_contact_image.inc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

class civicrm_handler_field_contact_image extends views_handler_field {
function option_definition() {
public function option_definition() {
$options = parent::option_definition();
$options['url_only'] = array(
'default' => FALSE,
Expand All @@ -28,7 +28,7 @@ class civicrm_handler_field_contact_image extends views_handler_field {
return $options;
}

function options_form(&$form, &$form_state) {
public function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$directory = $this->get_civi_relative_upload_path();

Expand Down Expand Up @@ -107,7 +107,7 @@ class civicrm_handler_field_contact_image extends views_handler_field {
}
}

function render($values) {
public function render($values) {
$value = $this->get_value($values);
if (empty($value)) {
return;
Expand Down Expand Up @@ -142,7 +142,7 @@ class civicrm_handler_field_contact_image extends views_handler_field {
*
* @return bool|string
*/
function get_civi_relative_upload_path() {
public function get_civi_relative_upload_path() {
civicrm_initialize();
$wrapper = file_stream_wrapper_get_instance_by_uri('public://');
$drupal_upload_path = $wrapper->getDirectoryPath();
Expand Down
16 changes: 8 additions & 8 deletions modules/views/civicrm/civicrm_handler_field_contact_link.inc
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
*/

/*
/**
* Unchanged anonymous code contribution. No claim.
*
* civicrm_handler_field_contact_link.inc
Expand All @@ -35,12 +35,12 @@ class civicrm_handler_field_contact_link extends views_handler_field {
/**
* Constructor to provide additional field to add.
*/
function construct() {
public function construct() {
parent::construct();
$this->additional_fields['id'] = 'id';
}

function option_definition() {
public function option_definition() {
$options = parent::option_definition();
$options['link_to_civicrm_contact'] = array('default' => FALSE);
return $options;
Expand All @@ -49,7 +49,7 @@ class civicrm_handler_field_contact_link extends views_handler_field {
/**
* Provide link to node option
*/
function options_form(&$form, &$form_state) {
public function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['link_to_civicrm_contact'] = array(
'#title' => t('Link this field to its CiviCRM Contact'),
Expand All @@ -63,7 +63,7 @@ class civicrm_handler_field_contact_link 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) {
if (!empty($this->options['link_to_civicrm_contact']) && user_access('access CiviCRM') && $data !== NULL && $data !== '') {
return civicrm_views_href($data,
'civicrm/contact/view',
Expand All @@ -75,8 +75,8 @@ class civicrm_handler_field_contact_link extends views_handler_field {
}
}

function render($values) {
public function render($values) {
return $this->render_link(check_plain($values->{$this->field_alias}), $values);
}
}

}
14 changes: 7 additions & 7 deletions modules/views/civicrm/civicrm_handler_field_country.inc
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
*/


/*
/**
* Heavily based on anonymous code contribution. No claim.
*
* civicrm_handler_field_country.inc
Expand All @@ -34,7 +34,7 @@
class civicrm_handler_field_country extends civicrm_handler_field_address {
static $_countries;
static $_countries_full;
function construct() {
public function construct() {
parent::construct();
if (!self::$_countries) {
if (!civicrm_initialize()) {
Expand All @@ -46,7 +46,7 @@ class civicrm_handler_field_country extends civicrm_handler_field_address {
}
}

function render($values) {
public function render($values) {
$sid = $values->{$this->field_alias};
if (empty($sid) ||
(int ) $sid <= 0
Expand All @@ -62,13 +62,13 @@ class civicrm_handler_field_country extends civicrm_handler_field_address {
}
}

function option_definition() {
public function option_definition() {
$options = parent::option_definition();
$options['country_display'] = array('default' => '');
return $options;
}

function options_form(&$form, &$form_state) {
public function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form['country_display'] = array(
'#type' => 'radios',
Expand All @@ -78,5 +78,5 @@ class civicrm_handler_field_country extends civicrm_handler_field_address {
'#default_value' => $this->options['country_display'],
);
}
}

}
14 changes: 7 additions & 7 deletions modules/views/civicrm/civicrm_handler_field_county.inc
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
*/


/*
/**
* civicrm_handler_field_county.inc
* Displays County after grabbing the label from the database
*
*/
class civicrm_handler_field_county extends civicrm_handler_field_address {
static $_counties;
function construct() {
public function construct() {
parent::construct();
if (!self::$_counties) {
if (!civicrm_initialize()) {
Expand All @@ -42,7 +42,7 @@ class civicrm_handler_field_county extends civicrm_handler_field_address {
}
}

function render($values) {
public function render($values) {
$sid = $values->{$this->field_alias};
if (empty($sid) ||
(int ) $sid <= 0
Expand All @@ -53,13 +53,13 @@ class civicrm_handler_field_county extends civicrm_handler_field_address {
return self::$_counties[$values->{$this->field_alias}];
}

function option_definition() {
public function option_definition() {
$options = parent::option_definition();
return $options;
}

function options_form(&$form, &$form_state) {
public function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
}
}

}
Loading

0 comments on commit 74514dd

Please sign in to comment.