Commit 44d72109 authored by Josh Lind's avatar Josh Lind Committed by Hunter Fox
Browse files

Issue #1580938: Fix code style issues

parent 18f6c6bf
Loading
Loading
Loading
Loading
+12 −7
Changes for context_bool_field.module: 12 added lines, 7 removed lines.
Original line number Diff line number Diff line
<?php
/*
 * implemntation of hook_context_plugins()
/**
 * @file
 * Define bool plugin and activate for bool field.
 */

/**
 * Implements hook_context_plugins().
 */
function context_bool_field_context_plugins() {
  $plugins = array();
@@ -16,8 +21,8 @@ function context_bool_field_context_plugins() {
}


/*
 * implemntation of hook_context_registry()
/**
 * Implements hook_context_registry().
 */
function context_bool_field_context_registry() {
  return array(
@@ -31,11 +36,11 @@ function context_bool_field_context_registry() {
  );
}

/*
 * implemntation of hook_process_page()
/**
 * Implements hook_node_view().
 */
function context_bool_field_node_view($node, $view_mode, $langcode) {
  if ($plugin = context_get_plugin('condition', 'field_bool') and  $node == menu_get_object()) {
  if (($plugin = context_get_plugin('condition', 'field_bool')) && ($node == menu_get_object())) {
    $plugin->execute($node, $view_mode, $langcode);
  }
}
+32 −10
Changes for plugins/context_bool_field_condition.inc: 32 added lines, 10 removed lines.
Original line number Diff line number Diff line
<?php
/**
 * @file
 * Define bool condition.
 */

class context_bool_field_condition extends context_condition {

  /**
   * Return all fields that are list booleans.
   */
  function get_bool_fields() {
    $bool_fields = array();
    foreach (field_info_fields() as $id => $field) {
@@ -11,7 +18,10 @@ class context_bool_field_condition extends context_condition {
    }
    return $bool_fields;
  }
  //we are setting a value for each field

  /**
   * We are setting a value for each field.
   */
  function condition_values() {
    $values = array();
    $ids = array_keys($this->get_bool_fields());
@@ -21,7 +31,9 @@ class context_bool_field_condition extends context_condition {
    return $values;
  }

  //we are adding a value option so we can check if a check box is set to a particlar value.
  /**
   * We are adding a value option so we can check if a check box is set to a particlar value.
   */
  function options_form($context) {
    $values = $this->fetch_from_context($context, 'options');
    $form = array();
@@ -29,31 +41,41 @@ class context_bool_field_condition extends context_condition {
      '#title' => t('Value'),
      '#description' => t('Field Value must match this'),
      '#type' => 'radios',
      '#options'=> array(0=>'No', 1=>'Yes'),
      '#options' => array(
        0 => t('No'),
        1 => t('Yes'),
      ),
      '#default_value' => isset($values["bool_field_value"]) ? $values["bool_field_value"] : FALSE,
    );
    return $form;
  }

  /**
   * Don't do anything on submit.
   */
  function options_form_sumbit($values) {
  }

  /**
   * See if any conditions match and active contextes.
   */
  function execute($node, $view_mode, $langcode) {
    //find all of the contextes
    foreach ($this->get_contexts() as $k => $v) {
      // check to see if any of the context use our plugin and if so if 
      // Check to see if any of the context use our plugin and if so if
      // they have set any fields
      if ((isset($v->conditions[$this->plugin])) &&
          ($fields = $v->conditions[$this->plugin]['values'])) {
        // lets go though each field
        // Lets go though each field.
        foreach ($fields as $field) {
          //see if the current node has that field
          if (isset($node->{$field}) && !empty($node->{$field}) ) {
          // See if the current node has that field.
          if (!empty($node->{$field})) {
            //TODO: need to work out lang stuff
            if (!isset($node->{$field}[$langcode])) {
              $langcode = 'und';
              $langcode = LANGUAGE_NONE;
            }
            // see if the value of the courrent nodes field match the bool option
            // sett in context
            // See if the value of the courrent nodes field match the bool option
            // set in context.
            $value = isset($v->conditions[$this->plugin]['options']['bool_field_value']) ? $v->conditions[$this->plugin]['options']['bool_field_value'] : FALSE;
            if ($node->{$field}[$langcode][0]['value'] == $value) {
              $this->condition_met($v, $field);