Projet

Général

Profil

Révision 5d12d676

Ajouté par Assos Assos il y a environ 6 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/views/handlers/views_handler_argument.inc
2 2

  
3 3
/**
4 4
 * @file
5
 * @todo.
5
 * Definition of views_handler_argument.
6 6
 */
7 7

  
8 8
/**
......
18 18
 *
19 19
 * Definition terms for this handler:
20 20
 * - name field: The field to use for the name to use in the summary, which is
21
 *               the displayed output. For example, for the node: nid argument,
22
 *               the argument itself is the nid, but node.title is displayed.
21
 *   the displayed output. For example, for the node: nid argument, the argument
22
 *   itself is the nid, but node.title is displayed.
23 23
 * - name table: The table to use for the name, should it not be in the same
24
 *               table as the argument.
24
 *   table as the argument.
25 25
 * - empty field name: For arguments that can have no value, such as taxonomy
26
 *                     which can have "no term", this is the string which
27
 *                     will be displayed for this lack of value. Be sure to use
28
 *                     t().
26
 *   which can have "no term", this is the string which will be displayed for
27
 *   this lack of value. Be sure to use t().
29 28
 * - validate type: A little used string to allow an argument to restrict
30
 *                  which validator is available to just one. Use the
31
 *                  validator ID. This probably should not be used at all,
32
 *                  and may disappear or change.
29
 *   which validator is available to just one. Use the validator ID. This
30
 *   probably should not be used at all, and may disappear or change.
33 31
 * - numeric: If set to TRUE this field is numeric and will use %d instead of
34
 *            %s in queries.
32
 *   %s in queries.
35 33
 *
36 34
 * @ingroup views_argument_handlers
37 35
 */
38 36
class views_handler_argument extends views_handler {
39
  var $validator = NULL;
40
  var $argument = NULL;
41
  var $value = NULL;
42 37

  
43 38
  /**
44
   * The table to use for the name, should it not be in the same table as the argument.
39
   * @var object
40
   */
41
  public $validator = NULL;
42

  
43
  /**
44
   * @var mixed
45
   */
46
  public $argument = NULL;
47

  
48
  /**
49
   * @var mixed
50
   */
51
  public $value = NULL;
52

  
53
  /**
54
   * The table to use for the name, if not the same table as the argument.
55
   *
45 56
   * @var string
46 57
   */
47
  var $name_table;
58
  public $name_table;
48 59

  
49 60
  /**
50
   * The field to use for the name to use in the summary, which is
51
   * the displayed output. For example, for the node: nid argument,
52
   * the argument itself is the nid, but node.title is displayed.
61
   * The field to use for the name to use in the summary.
62
   *
63
   * Used as the displayed output. For example, for the node: nid argument, the
64
   * argument itself is the nid, but node.title is displayed.
65
   *
53 66
   * @var string
54 67
   */
55
  var $name_field;
68
  public $name_field;
56 69

  
57 70
  /**
58
   * Constructor
71
   * {@inheritdoc}
59 72
   */
60
  function construct() {
73
  public function construct() {
61 74
    parent::construct();
62 75

  
63 76
    if (!empty($this->definition['name field'])) {
......
68 81
    }
69 82
  }
70 83

  
71
  function init(&$view, &$options) {
84
  /**
85
   * {@inheritdoc}
86
   */
87
  public function init(&$view, &$options) {
72 88
    parent::init($view, $options);
73 89

  
74 90
    // Compatibility: The new UI changed several settings.
......
132 148

  
133 149
  /**
134 150
   * Give an argument the opportunity to modify the breadcrumb, if it wants.
135
   * This only gets called on displays where a breadcrumb is actually used.
151
   *
152
   * Only gets called on displays where a breadcrumb is actually used.
136 153
   *
137 154
   * The breadcrumb will be in the form of an array, with the keys being
138 155
   * the path and the value being the already sanitized title of the path.
139 156
   */
140
  function set_breadcrumb(&$breadcrumb) { }
157
  public function set_breadcrumb(&$breadcrumb) {
158
  }
141 159

  
142 160
  /**
143 161
   * Determine if the argument can generate a breadcrumb
144 162
   *
145
   * @return TRUE/FALSE
163
   * @return bool
146 164
   */
147
  function uses_breadcrumb() {
165
  public function uses_breadcrumb() {
148 166
    $info = $this->default_actions($this->options['default_action']);
149 167
    return !empty($info['breadcrumb']);
150 168
  }
151 169

  
152
  function is_exception($arg = NULL) {
170
  /**
171
   * {@inheritdoc}
172
   */
173
  public function is_exception($arg = NULL) {
153 174
    if (!isset($arg)) {
154 175
      $arg = isset($this->argument) ? $this->argument : NULL;
155 176
    }
156
    return !empty($this->options['exception']['value']) && $this->options['exception']['value'] === $arg;
177
    return !empty($this->options['exception']['value']) && ($this->options['exception']['value'] === $arg);
157 178
  }
158 179

  
159
  function exception_title() {
180
  /**
181
   * Work out which title to use.
182
   *
183
   * @return string
184
   *   The title string to use.
185
   */
186
  public function exception_title() {
160 187
    // If title overriding is off for the exception, return the normal title.
161 188
    if (empty($this->options['exception']['title_enable'])) {
162 189
      return $this->get_title();
......
167 194
  /**
168 195
   * Determine if the argument needs a style plugin.
169 196
   *
170
   * @return TRUE/FALSE
197
   * @return bool
171 198
   */
172
  function needs_style_plugin() {
199
  public function needs_style_plugin() {
173 200
    $info = $this->default_actions($this->options['default_action']);
174 201
    $validate_info = $this->default_actions($this->options['validate']['fail']);
175 202
    return !empty($info['style plugin']) || !empty($validate_info['style plugin']);
176 203
  }
177 204

  
178
  function option_definition() {
205
  /**
206
   * {@inheritdoc}
207
   */
208
  public function option_definition() {
179 209
    $options = parent::option_definition();
180 210

  
181 211
    $options['default_action'] = array('default' => 'ignore');
......
213 243
    return $options;
214 244
  }
215 245

  
216
  function options_form(&$form, &$form_state) {
246
  /**
247
   * {@inheritdoc}
248
   */
249
  public function options_form(&$form, &$form_state) {
217 250
    parent::options_form($form, $form_state);
218 251

  
219 252
    $argument_text = $this->view->display_handler->get_argument_text();
......
380 413
              '#prefix' => '<div id="edit-options-validate-options-' . $id . '-wrapper">',
381 414
              '#suffix' => '</div>',
382 415
              '#type' => 'item',
383
              // Even if the plugin has no options add the key to the form_state.
384
              '#input' => TRUE, // trick it into checking input to make #process run
416
              // Even if the plugin has no options, add the key to the
417
              // form_state. Trick it into checking input to make #process run.
418
              '#input' => TRUE,
385 419
              '#dependency' => array(
386 420
                'edit-options-specify-validation' => array('1'),
387 421
                'edit-options-validate-type' => array($id),
......
411 445
    );
412 446
  }
413 447

  
414
  function options_validate(&$form, &$form_state) {
448
  /**
449
   * {@inheritdoc}
450
   */
451
  public function options_validate(&$form, &$form_state) {
415 452
    if (empty($form_state['values']['options'])) {
416 453
      return;
417 454
    }
......
440 477

  
441 478
  }
442 479

  
443
  function options_submit(&$form, &$form_state) {
480
  /**
481
   * {@inheritdoc}
482
   */
483
  public function options_submit(&$form, &$form_state) {
444 484
    if (empty($form_state['values']['options'])) {
445 485
      return;
446 486
    }
......
451 491
    if ($plugin) {
452 492
      $options = &$form_state['values']['options']['argument_default'][$default_id];
453 493
      $plugin->options_submit($form['argument_default'][$default_id], $form_state, $options);
454
      // Copy the now submitted options to their final resting place so they get saved.
494
      // Copy the now submitted options to their final resting place so they
495
      // get saved.
455 496
      $form_state['values']['options']['default_argument_options'] = $options;
456 497
    }
457 498

  
......
462 503
      if ($plugin) {
463 504
        $options = &$form_state['values']['options']['summary']['options'][$summary_id];
464 505
        $plugin->options_submit($form['summary']['options'][$summary_id], $form_state, $options);
465
        // Copy the now submitted options to their final resting place so they get saved.
506
        // Copy the now submitted options to their final resting place so they
507
        // get saved.
466 508
        $form_state['values']['options']['summary_options'] = $options;
467 509
      }
468 510
    }
......
472 514
    if ($plugin) {
473 515
      $options = &$form_state['values']['options']['validate']['options'][$validate_id];
474 516
      $plugin->options_submit($form['validate']['options'][$validate_id], $form_state, $options);
475
      // Copy the now submitted options to their final resting place so they get saved.
517
      // Copy the now submitted options to their final resting place so they
518
      // get saved.
476 519
      $form_state['values']['options']['validate_options'] = $options;
477 520
    }
478 521

  
......
489 532
   *
490 533
   * Override this method to provide additional (or fewer) default behaviors.
491 534
   */
492
  function default_actions($which = NULL) {
535
  public function default_actions($which = NULL) {
493 536
    $defaults = array(
494 537
      'ignore' => array(
495 538
        'title' => t('Display all results for the specified field'),
496 539
        'method' => 'default_ignore',
497
        'breadcrumb' => TRUE, // generate a breadcrumb to here
540
        // Generate a breadcrumb to here.
541
        'breadcrumb' => TRUE,
498 542
      ),
499 543
      'default' => array(
500 544
        'title' => t('Provide default value'),
501 545
        'method' => 'default_default',
502 546
        'form method' => 'default_argument_form',
503 547
        'has default argument' => TRUE,
504
        'default only' => TRUE, // this can only be used for missing argument, not validation failure
505
        'breadcrumb' => TRUE, // generate a breadcrumb to here
548
        // This can only be used for missing argument, not validation failure.
549
        'default only' => TRUE,
550
        // Generate a breadcrumb to here.
551
        'breadcrumb' => TRUE,
506 552
      ),
507 553
      'not found' => array(
508 554
        'title' => t('Hide view'),
509 555
        'method' => 'default_not_found',
510
        'hard fail' => TRUE, // This is a hard fail condition
556
        // This is a hard fail condition.
557
        'hard fail' => TRUE,
511 558
      ),
512 559
      'summary' => array(
513 560
        'title' => t('Display a summary'),
514 561
        'method' => 'default_summary',
515 562
        'form method' => 'default_summary_form',
516 563
        'style plugin' => TRUE,
517
        'breadcrumb' => TRUE, // generate a breadcrumb to here
564
        // Generate a breadcrumb to here.
565
        'breadcrumb' => TRUE,
518 566
      ),
519 567
      'empty' => array(
520 568
        'title' => t('Display contents of "No results found"'),
521 569
        'method' => 'default_empty',
522
        'breadcrumb' => TRUE, // generate a breadcrumb to here
570
        // Generate a breadcrumb to here.
571
        'breadcrumb' => TRUE,
523 572
      ),
524 573
      'access denied' => array(
525 574
        'title' => t('Display "Access Denied"'),
526 575
        'method' => 'default_access_denied',
527
        'breadcrumb' => FALSE, // generate a breadcrumb to here
576
        // Generate a breadcrumb to here.
577
        'breadcrumb' => FALSE,
528 578
      ),
529 579
    );
530 580

  
......
543 593
  }
544 594

  
545 595
  /**
546
   * Provide a form for selecting the default argument when the
547
   * default action is set to provide default argument.
596
   * Provide a form for selecting the default argument.
597
   *
598
   * Used when the default action is set to provide default argument.
548 599
   */
549
  function default_argument_form(&$form, &$form_state) {
600
  public function default_argument_form(&$form, &$form_state) {
550 601
    $plugins = views_fetch_plugin_data('argument default');
551 602
    $options = array();
552 603

  
......
554 605
      '#type' => 'checkbox',
555 606
      '#title' => t('Skip default argument for view URL'),
556 607
      '#default_value' => $this->options['default_argument_skip_url'],
557
      '#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.')
608
      '#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.'),
558 609
    );
559 610

  
560 611
    $form['default_argument_type'] = array(
......
564 615
      '#id' => 'edit-options-default-argument-type',
565 616
      '#title' => t('Type'),
566 617
      '#default_value' => $this->options['default_argument_type'],
567

  
568
      '#dependency' => array('radio:options[default_action]' => array('default')),
618
      '#dependency' => array(
619
        'radio:options[default_action]' => array(
620
          'default',
621
        ),
622
      ),
569 623
      // Views custom key, moves this element to the appropriate container
570 624
      // under the radio button.
571 625
      '#argument_option' => 'default',
......
588 642
            '#input' => TRUE,
589 643
            '#dependency' => array(
590 644
              'radio:options[default_action]' => array('default'),
591
              'edit-options-default-argument-type' => array($id)
645
              'edit-options-default-argument-type' => array($id),
592 646
            ),
593 647
            '#dependency_count' => 2,
594 648
          );
......
603 657
  }
604 658

  
605 659
  /**
606
   * Provide a form for selecting further summary options when the
607
   * default action is set to display one.
660
   * Provide a form for selecting further summary options when the default
661
   * action is set to display one.
608 662
   */
609
  function default_summary_form(&$form, &$form_state) {
663
  public function default_summary_form(&$form, &$form_state) {
610 664
    $style_plugins = views_fetch_plugin_data('style');
611 665
    $summary_plugins = array();
612 666
    $format_options = array();
......
635 689
      '#default_value' => $this->options['summary']['number_of_records'],
636 690
      '#options' => array(
637 691
        0 => $this->get_sort_name(),
638
        1 => t('Number of records')
692
        1 => t('Number of records'),
639 693
      ),
640 694
      '#dependency' => array('radio:options[default_action]' => array('summary')),
641 695
    );
......
659 713
          '#suffix' => '</div>',
660 714
          '#id' => 'edit-options-summary-options-' . $id,
661 715
          '#type' => 'item',
662
          '#input' => TRUE, // trick it into checking input to make #process run
716
          // Trick it into checking input to make #process run.
717
          '#input' => TRUE,
663 718
          '#dependency' => array(
664 719
            'radio:options[default_action]' => array('summary'),
665 720
            'radio:options[summary][format]' => array($id),
......
677 732
   *
678 733
   * Override this method only with extreme care.
679 734
   *
680
   * @return
735
   * @return bool
681 736
   *   A boolean value; if TRUE, continue building this view. If FALSE,
682 737
   *   building the view will be aborted here.
683 738
   */
684
  function default_action($info = NULL) {
739
  public function default_action($info = NULL) {
685 740
    if (!isset($info)) {
686 741
      $info = $this->default_actions($this->options['default_action']);
687 742
    }
......
699 754
  }
700 755

  
701 756
  /**
702
   * How to act if validation failes
757
   * How to act if validation fails.
703 758
   */
704
  function validate_fail() {
759
  public function validate_fail() {
705 760
    $info = $this->default_actions($this->options['validate']['fail']);
706 761
    return $this->default_action($info);
707 762
  }
763

  
708 764
  /**
709 765
   * Default action: ignore.
710 766
   *
711
   * If an argument was expected and was not given, in this case, simply
712
   * ignore the argument entirely.
767
   * If an argument was expected and was not given, in this case, simply ignore
768
   * the argument entirely.
713 769
   */
714
  function default_ignore() {
770
  public function default_ignore() {
715 771
    return TRUE;
716 772
  }
717 773

  
718 774
  /**
719 775
   * Default action: not found.
720 776
   *
721
   * If an argument was expected and was not given, in this case, report
722
   * the view as 'not found' or hide it.
777
   * If an argument was expected and was not given, in this case, report the
778
   * view as 'not found' or hide it.
723 779
   */
724
  function default_not_found() {
780
  public function default_not_found() {
725 781
    // Set a failure condition and let the display manager handle it.
726 782
    $this->view->build_info['fail'] = TRUE;
727 783
    return FALSE;
......
730 786
  /**
731 787
   * Default action: access denied.
732 788
   *
733
   * If an argument was expected and was not given, in this case, report
734
   * the view as 'access denied'.
789
   * If an argument was expected and was not given, in this case, report the
790
   * view as 'access denied'.
735 791
   */
736
  function default_access_denied() {
792
  public function default_access_denied() {
737 793
    $this->view->build_info['denied'] = TRUE;
738 794
    return FALSE;
739 795
  }
......
741 797
  /**
742 798
   * Default action: empty
743 799
   *
744
   * If an argument was expected and was not given, in this case, display
745
   * the view's empty text
800
   * If an argument was expected and was not given, in this case, display the
801
   * view's empty text
746 802
   */
747
  function default_empty() {
803
  public function default_empty() {
748 804
    // We return with no query; this will force the empty text.
749 805
    $this->view->built = TRUE;
750 806
    $this->view->executed = TRUE;
......
753 809
  }
754 810

  
755 811
  /**
756
   * This just returns true. The view argument builder will know where
757
   * to find the argument from.
812
   * This just returns true.
813
   *
814
   * The view argument builder will know where to find the argument from.
815
   *
816
   * @todo Why is this needed?
758 817
   */
759
  function default_default() {
818
  public function default_default() {
760 819
    return TRUE;
761 820
  }
762 821

  
763 822
  /**
764 823
   * Determine if the argument is set to provide a default argument.
765 824
   */
766
  function has_default_argument() {
825
  public function has_default_argument() {
767 826
    $info = $this->default_actions($this->options['default_action']);
768 827
    return !empty($info['has default argument']);
769 828
  }
......
771 830
  /**
772 831
   * Get a default argument, if available.
773 832
   */
774
  function get_default_argument() {
833
  public function get_default_argument() {
775 834
    $plugin = $this->get_plugin('argument default');
776 835
    if ($plugin) {
777 836
      return $plugin->get_argument();
......
784 843
   * For example, the validation plugin may want to alter an argument for use in
785 844
   * the URL.
786 845
   */
787
  function process_summary_arguments(&$args) {
846
  public function process_summary_arguments(&$args) {
788 847
    if ($this->options['validate']['type'] != 'none') {
789 848
      if (isset($this->validator) || $this->validator = $this->get_plugin('argument validator')) {
790 849
        $this->validator->process_summary_arguments($args);
......
795 854
  /**
796 855
   * Default action: summary.
797 856
   *
798
   * If an argument was expected and was not given, in this case, display
799
   * a summary query.
857
   * If an argument was expected and was not given, in this case, display a
858
   * summary query.
800 859
   */
801
  function default_summary() {
860
  public function default_summary() {
802 861
    $this->view->build_info['summary'] = TRUE;
803 862
    $this->view->build_info['summary_level'] = $this->options['id'];
804 863

  
805
    // Change the display style to the summary style for this
806
    // argument.
864
    // Change the display style to the summary style for this argument.
807 865
    $this->view->plugin_name = $this->options['summary']['format'];
808 866
    $this->view->style_options = $this->options['summary_options'];
809 867

  
810
    // Clear out the normal primary field and whatever else may have
811
    // been added and let the summary do the work.
868
    // Clear out the normal primary field and whatever else may have been added
869
    // and let the summary do the work.
812 870
    $this->query->clear_fields();
813 871
    $this->summary_query();
814 872

  
......
826 884
   *
827 885
   * This must:
828 886
   * - add_groupby: group on this field in order to create summaries.
829
   * - add_field: add a 'num_nodes' field for the count. Usually it will
830
   *   be a count on $view->base_field
887
   * - add_field: add a 'num_nodes' field for the count. Usually it will be a
888
   *   count on $view->base_field
831 889
   * - set_count_field: Reset the count field so we get the right paging.
832 890
   *
833
   * @return
891
   * @return string
834 892
   *   The alias used to get the number of records (count) for this entry.
835 893
   */
836
  function summary_query() {
894
  public function summary_query() {
837 895
    $this->ensure_my_table();
838 896
    // Add the field.
839 897
    $this->base_alias = $this->query->add_field($this->table_alias, $this->real_field);
......
844 902

  
845 903
  /**
846 904
   * Add the name field, which is the field displayed in summary queries.
905
   *
847 906
   * This is often used when the argument is numeric.
848 907
   */
849
  function summary_name_field() {
850
    // Add the 'name' field. For example, if this is a uid argument, the
851
    // name field would be 'name' (i.e, the username).
852

  
908
  public function summary_name_field() {
909
    // Add the 'name' field. For example, if this is a uid argument, the name
910
    // field would be 'name' (i.e, the username).
853 911
    if (isset($this->name_table)) {
854
      // if the alias is different then we're probably added, not ensured,
855
      // so look up the join and add it instead.
912
      // If the alias is different then we're probably added, not ensured, so
913
      // look up the join and add it instead.
856 914
      if ($this->table_alias != $this->name_table) {
857 915
        $j = views_get_table_join($this->name_table, $this->table);
858 916
        if ($j) {
......
878 936
  }
879 937

  
880 938
  /**
881
   * Some basic summary behavior that doesn't need to be repeated as much as
882
   * code that goes into summary_query()
939
   * Some basic summary behavior.
940
   *
941
   * This doesn't need to be repeated as much as code that goes into
942
   * summary_query().
883 943
   */
884
  function summary_basics($count_field = TRUE) {
885
    // Add the number of nodes counter
944
  public function summary_basics($count_field = TRUE) {
945
    // Add the number of nodes counter.
886 946
    $distinct = ($this->view->display_handler->get_option('distinct') && empty($this->query->no_distinct));
887 947

  
888
    $count_alias = $this->query->add_field($this->query->base_table, $this->query->base_field, 'num_records',
889
                                           array('count' => TRUE, 'distinct' => $distinct));
948
    $count_alias = $this->query->add_field($this->query->base_table,
949
      $this->query->base_field, 'num_records',
950
      array(
951
        'count' => TRUE,
952
        'distinct' => $distinct,
953
      ));
890 954
    $this->query->add_groupby($this->name_alias);
891 955

  
892 956
    if ($count_field) {
......
897 961
  }
898 962

  
899 963
  /**
900
   * Sorts the summary based upon the user's selection. The base variant of
901
   * this is usually adequte.
964
   * Sorts the summary based upon the user's selection.
902 965
   *
903
   * @param $order
966
   * The base variant of this is usually adequte.
967
   *
968
   * @param string $order
904 969
   *   The order selected in the UI.
905 970
   */
906
  function summary_sort($order, $by = NULL) {
971
  public function summary_sort($order, $by = NULL) {
907 972
    $this->query->add_orderby(NULL, NULL, $order, (!empty($by) ? $by : $this->name_alias));
908 973
  }
909 974

  
910 975
  /**
911
   * Provide the argument to use to link from the summary to the next level;
912
   * this will be called once per row of a summary, and used as part of
976
   * Provide the argument to use to link from the summary to the next level.
977
   *
978
   * This will be called once per row of a summary, and used as part of
913 979
   * $view->get_url().
914 980
   *
915
   * @param $data
981
   * @param object $data
916 982
   *   The query results for the row.
917 983
   */
918
  function summary_argument($data) {
984
  public function summary_argument($data) {
919 985
    return $data->{$this->base_alias};
920 986
  }
921 987

  
922 988
  /**
923
   * Provides the name to use for the summary. By default this is just
924
   * the name field.
989
   * Provides the name to use for the summary.
925 990
   *
926
   * @param $data
991
   * By default this is just the name field.
992
   *
993
   * @param object $data
927 994
   *   The query results for the row.
995
   *
996
   * @return string
997
   *   The summary.
928 998
   */
929
  function summary_name($data) {
999
  public function summary_name($data) {
930 1000
    $value = $data->{$this->name_alias};
931 1001
    if (empty($value) && !empty($this->definition['empty field name'])) {
932 1002
      $value = $this->definition['empty field name'];
......
938 1008
   * Set up the query for this argument.
939 1009
   *
940 1010
   * The argument sent may be found at $this->argument.
1011
   *
1012
   * @param bool $group_by
1013
   *   Whether the query uses a group-by.
941 1014
   */
942
  function query($group_by = FALSE) {
1015
  public function query($group_by = FALSE) {
943 1016
    $this->ensure_my_table();
944 1017
    $this->query->add_where(0, "$this->table_alias.$this->real_field", $this->argument);
945 1018
  }
......
949 1022
   *
950 1023
   * This usually needs to be overridden to provide a proper title.
951 1024
   */
952
  function title() {
1025
  public function title() {
953 1026
    return check_plain($this->argument);
954 1027
  }
955 1028

  
956 1029
  /**
957
   * Called by the view object to get the title. This may be set by a
958
   * validator so we don't necessarily call through to title().
1030
   * Called by the view object to get the title.
1031
   *
1032
   * This may be set by a validator so we don't necessarily call through to
1033
   * title().
959 1034
   */
960
  function get_title() {
1035
  public function get_title() {
961 1036
    if (isset($this->validated_title)) {
962 1037
      return $this->validated_title;
963 1038
    }
......
969 1044
  /**
970 1045
   * Validate that this argument works. By default, all arguments are valid.
971 1046
   */
972
  function validate_arg($arg) {
1047
  public function validate_arg($arg) {
973 1048
    // By using % in URLs, arguments could be validated twice; this eases
974 1049
    // that pain.
975 1050
    if (isset($this->argument_validated)) {
......
989 1064
      return $this->argument_validated = $plugin->validate_argument($arg);
990 1065
    }
991 1066

  
992
    // If the plugin isn't found, fall back to the basic validation path:
1067
    // If the plugin isn't found, fall back to the basic validation path.
993 1068
    return $this->argument_validated = $this->validate_argument_basic($arg);
994 1069
  }
995 1070

  
......
997 1072
   * Called by the menu system to validate an argument.
998 1073
   *
999 1074
   * This checks to see if this is a 'soft fail', which means that if the
1000
   * argument fails to validate, but there is an action to take anyway,
1001
   * then validation cannot actually fail.
1075
   * argument fails to validate, but there is an action to take anyway, then
1076
   * validation cannot actually fail.
1002 1077
   */
1003
  function validate_argument($arg) {
1078
  public function validate_argument($arg) {
1004 1079
    $validate_info = $this->default_actions($this->options['validate']['fail']);
1005 1080
    if (empty($validate_info['hard fail'])) {
1006 1081
      return TRUE;
......
1008 1083

  
1009 1084
    $rc = $this->validate_arg($arg);
1010 1085

  
1011
    // If the validator has changed the validate fail condition to a
1012
    // soft fail, deal with that:
1086
    // If the validator has changed the validate fail condition to a soft fail,
1087
    // deal with that.
1013 1088
    $validate_info = $this->default_actions($this->options['validate']['fail']);
1014 1089
    if (empty($validate_info['hard fail'])) {
1015 1090
      return TRUE;
......
1021 1096
  /**
1022 1097
   * Provide a basic argument validation.
1023 1098
   *
1024
   * This can be overridden for more complex types; the basic
1025
   * validator only checks to see if the argument is not NULL
1026
   * or is numeric if the definition says it's numeric.
1099
   * This can be overridden for more complex types; the basic validator only
1100
   * checks to see if the argument is not NULL or is numeric if the definition
1101
   * says it's numeric.
1102
   *
1103
   * @return bool
1104
   *   Whether or not the argument validates.
1027 1105
   */
1028
  function validate_argument_basic($arg) {
1106
  public function validate_argument_basic($arg) {
1029 1107
    if (!isset($arg) || $arg === '') {
1030 1108
      return FALSE;
1031 1109
    }
......
1040 1118
  /**
1041 1119
   * Set the input for this argument
1042 1120
   *
1043
   * @return TRUE if it successfully validates; FALSE if it does not.
1121
   * @return bool
1122
   *   TRUE if it successfully validates; FALSE if it does not.
1044 1123
   */
1045
  function set_argument($arg) {
1124
  public function set_argument($arg) {
1046 1125
    $this->argument = $arg;
1047 1126
    return $this->validate_arg($arg);
1048 1127
  }
1049 1128

  
1050 1129
  /**
1051 1130
   * Get the value of this argument.
1131
   *
1132
   * @return string
1133
   *   The value.
1052 1134
   */
1053
  function get_value() {
1135
  public function get_value() {
1054 1136
    // If we already processed this argument, we're done.
1055 1137
    if (isset($this->argument)) {
1056 1138
      return $this->argument;
......
1089 1171
   *
1090 1172
   * Arguments can have styles for the summary view. This special export
1091 1173
   * handler makes sure this works properly.
1174
   *
1175
   * @return string
1176
   *   The export summary.
1092 1177
   */
1093
  function export_summary($indent, $prefix, $storage, $option, $definition, $parents) {
1178
  public function export_summary($indent, $prefix, $storage, $option, $definition, $parents) {
1094 1179
    $output = '';
1095 1180
    $name = $this->options['summary'][$option];
1096 1181
    $options = $this->options['summary_options'];
......
1113 1198
   *
1114 1199
   * Arguments use validation plugins. This special export handler makes sure
1115 1200
   * this works properly.
1201
   *
1202
   * @return string
1203
   *   The validation response.
1116 1204
   */
1117
  function export_validation($indent, $prefix, $storage, $option, $definition, $parents) {
1205
  public function export_validation($indent, $prefix, $storage, $option, $definition, $parents) {
1118 1206
    $output = '';
1119 1207
    $name = $this->options['validate'][$option];
1120 1208
    $options = $this->options['validate_options'];
......
1137 1225
   *
1138 1226
   * Since style and validation plugins have their own export handlers, this
1139 1227
   * one is currently only used for default argument plugins.
1228
   *
1229
   * @return string
1230
   *   Export string.
1140 1231
   */
1141
  function export_plugin($indent, $prefix, $storage, $option, $definition, $parents) {
1232
  public function export_plugin($indent, $prefix, $storage, $option, $definition, $parents) {
1142 1233
    $output = '';
1143 1234
    if ($option == 'default_argument_type') {
1144 1235
      $type = 'argument default';
......
1162 1253
  /**
1163 1254
   * Get the display or row plugin, if it exists.
1164 1255
   */
1165
  function get_plugin($type = 'argument default', $name = NULL) {
1256
  public function get_plugin($type = 'argument default', $name = NULL) {
1166 1257
    $options = array();
1167 1258
    switch ($type) {
1168 1259
      case 'argument default':
1169 1260
        $plugin_name = $this->options['default_argument_type'];
1170 1261
        $options_name = 'default_argument_options';
1171 1262
        break;
1263

  
1172 1264
      case 'argument validator':
1173 1265
        $plugin_name = $this->options['validate']['type'];
1174 1266
        $options_name = 'validate_options';
1175 1267
        break;
1268

  
1176 1269
      case 'style':
1177 1270
        $plugin_name = $this->options['summary']['format'];
1178 1271
        $options_name = 'summary_options';
1272
        break;
1179 1273
    }
1180 1274

  
1181 1275
    if (!$name) {
1182 1276
      $name = $plugin_name;
1183 1277
    }
1184 1278

  
1185
    // we only fetch the options if we're fetching the plugin actually
1186
    // in use.
1279
    // We only fetch the options if we're fetching the plugin actually in use.
1187 1280
    if ($name == $plugin_name) {
1188 1281
      $options = $this->options[$options_name];
1189 1282
    }
......
1206 1299
   *
1207 1300
   * Subclasses should override this to specify what the default sort order of
1208 1301
   * their argument is (e.g. alphabetical, numeric, date).
1302
   *
1303
   * @return string
1304
   *   The label for the sorter.
1209 1305
   */
1210
  function get_sort_name() {
1306
  public function get_sort_name() {
1211 1307
    return t('Default sort', array(), array('context' => 'Sort order'));
1212 1308
  }
1309

  
1213 1310
}
1214 1311

  
1215 1312
/**
......
1218 1315
 * @ingroup views_argument_handlers
1219 1316
 */
1220 1317
class views_handler_argument_broken extends views_handler_argument {
1221
  function ui_name($short = FALSE) {
1318

  
1319
  /**
1320
   * {@inheritdoc}
1321
   */
1322
  public function ui_name($short = FALSE) {
1222 1323
    return t('Broken/missing handler');
1223 1324
  }
1224 1325

  
1225
  function ensure_my_table() { /* No table to ensure! */ }
1226
  function query($group_by = FALSE) { /* No query to run */ }
1227
  function options_form(&$form, &$form_state) {
1326
  /**
1327
   * {@inheritdoc}
1328
   */
1329
  public function ensure_my_table() {
1330
    // No table to ensure!
1331
  }
1332

  
1333
  /**
1334
   * {@inheritdoc}
1335
   */
1336
  public function query($group_by = FALSE) {
1337
    // No query to run.
1338
  }
1339

  
1340
  /**
1341
   * {@inheritdoc}
1342
   */
1343
  public function options_form(&$form, &$form_state) {
1228 1344
    $form['markup'] = array(
1229 1345
      '#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>',
1230 1346
    );
1231 1347
  }
1232 1348

  
1233 1349
  /**
1234
   * Determine if the handler is considered 'broken'
1350
   * {@inheritdoc}
1235 1351
   */
1236
  function broken() { return TRUE; }
1352
  public function broken() {
1353
    return TRUE;
1354
  }
1355

  
1237 1356
}
1238 1357

  
1239 1358
/**

Formats disponibles : Unified diff