Projet

Général

Profil

Révision 289c1f45

Ajouté par Florent Torregrosa il y a plus de 10 ans

Remove folder modules in folder modules. Nothing to do here.

Voir les différences:

htmltest/sites/all/modules/modules/views_append/views_append.info
1
name = Append View
2
description = "Views plugin to include (download) a view as a field."
3
dependencies[] = views
4
package = Views
5
core = 7.x
6

  
7
files[] = views_append_handler_append_view.inc
8

  
9

  
10
; Information added by drupal.org packaging script on 2013-08-03
11
version = "7.x-1.1"
12
core = "7.x"
13
project = "views_pdf"
14
datestamp = "1375559497"
15

  
htmltest/sites/all/modules/modules/views_append/views_append.module
1
<?php
2
/**
3
 * @file
4
 * Module for appending PDF views to other PDF views
5
 *
6
 * The module adds a field which can be used to append another view. The view is
7
 * created by calling the View over a HTTP request.
8
 *
9
 */
10

  
11

  
12
/**
13
 * Implementation of hook_views_api().
14
 */
15
function views_append_views_api() {
16
  return array(
17
    'api' => 3,
18
  );
19
}
20

  
21
/**
22
 * This function emulates the request of a browser. This is used to get the
23
 * PDF file to append.
24
 */
25
function views_append_request_with_cookie($url, $save_path) {
26

  
27
  $urlComponents = parse_url($url);
28

  
29
  // Define the specified port
30
  if ($urlComponents['scheme'] === 'http')  {
31
    $port = 80;
32
  }
33
  elseif ($urlComponents['scheme'] === 'https') {
34
    $port = 443;
35
  }
36
  else {
37
    $port = 80;
38
  }
39

  
40
  // Define the host
41
  $host = $urlComponents['host'];
42

  
43
  // Define the path
44
  if (!empty($urlComponents['query'])) {
45
    $path = $urlComponents['path'] . '?' . $urlComponents['query'];
46
  }
47
  else {
48
    $path = $urlComponents['path'];
49
  }
50

  
51
  // Change host if ssl is used:
52
  if ($port == 443) {
53
    $hostUrl = "ssl://" . $host;
54
  }
55
  else {
56
    $hostUrl = $host;
57
  }
58

  
59
  $fp = fsockopen($hostUrl, $port, $errno, $errstr, 30);
60

  
61
  $method = 'GET';
62
  $content = '';
63

  
64
  if (!$fp) {
65
    echo "$errstr ($errno)<br />\n";
66
  }
67
  else {
68
    $out = "$method $path HTTP/1.1\r\n";
69
    $out .= "Host: $host\r\n";
70
    if ($method == 'POST') {
71
      $out .= "Content-Type: application/x-www-form-urlencoded\r\n";
72
    }
73
    $out .= "Content-length: " . strlen($content) . "\r\n";
74
    $out .= "Cookie: " . session_name() . '=' . session_id() . "; \r\n";
75
    $out .= "Connection: Close\r\n\r\n";
76

  
77
    if ($method == 'POST') {
78
      $out .= $content;
79
    }
80

  
81
    fwrite($fp, $out);
82

  
83
    $newFile = fopen($save_path, 'w');
84

  
85
    $header = TRUE;
86

  
87
    while (!feof($fp)) {
88
      $content = fgets($fp, 8096);
89
      if ($content == "\r\n") {
90
        $header = FALSE;
91
      }
92
      elseif (!$header) {
93
        fwrite($newFile, $content);
94
      }
95

  
96
    }
97
    fclose($fp);
98
    fclose($newFile);
99
  }
100

  
101
}
102

  
103
function _views_append_parse_array_to_string($array) {
104

  
105
  if (is_array($array)) {
106
    foreach ($array as $key => $value) {
107
      $string .= $key . '=' . $value . '&';
108
    }
109
    if (!empty($string)) {
110
      $string = substr($string, 0, -1);
111
    }
112

  
113
    return $string;
114
  }
115
  else {
116
    return $array;
117
  }
118
}
htmltest/sites/all/modules/modules/views_append/views_append.views.inc
1
<?php
2
/**
3
 * @file
4
 * This file contains all the views hooks for the appending of a view
5
 * to another view.
6
 */
7

  
8
/**
9
 * Implementaion of hook_views_data()
10
 */
11
function views_append_views_data() {
12

  
13
  $data['views_append']['table']['group'] = t('View');
14
  $data['views_append']['table']['join'] = array(
15
    '#global' => array(),
16
  );
17

  
18
  $data['views_append']['append'] = array(
19
    'title' => t('Append View'),
20
    'help' => t('Appends a view at this view.'),
21
    'field' => array(
22
      'handler' => 'views_append_handler_append_view',
23
      'click sortable' => FALSE,
24
      'notafield' => TRUE,
25
    ),
26
  );
27
  return $data;
28
}
htmltest/sites/all/modules/modules/views_append/views_append_handler_append_view.inc
1
<?php
2
/**
3
 * @file
4
 * Views Append Handler
5
 *
6
 * To append a view to another a field handler is used.
7
 */
8

  
9
/**
10
 * This class contains all the functionality to append a view to another one.
11
 *
12
 */
13
class views_append_handler_append_view extends views_handler_field {
14

  
15
  /**
16
   * This method  is used to query data. In our case
17
   * we want that no data is queried.
18
   *
19
   */
20
  function query() {
21
    // Override parent::query() and don't alter query.
22
    $this->field_alias = 'view_append_' . $this->position;
23
  }
24

  
25
  /**
26
   * This method contains the defintion of the options for appending a view.
27
   */
28
  function option_definition() {
29
    $options = parent::option_definition();
30

  
31
    $options['url'] = array('default' => '');
32

  
33
    return $options;
34
  }
35

  
36
  /**
37
   * Option form
38
   */
39
  function options_form(&$form, &$form_state) {
40
    parent::options_form($form, $form_state);
41

  
42
    $form['url'] = array(
43
      '#type' => 'textfield',
44
      '#title' => t('Enter the URL to the file'),
45
      '#default_value' => $this->options['url'],
46
      '#description' => t('Enter the URL to the file. You can use tokens to replace some parts of the URL.'),
47
    );
48
  }
49

  
50
  /**
51
   * This method renders the other view.
52
   */
53
  function render($values) {
54

  
55
    if ($this->options['exclude'] == '1') {
56
      return '';
57
    }
58

  
59
    $tokens = $this->get_render_tokens('');
60

  
61
    $url = str_replace(array_keys($tokens), $tokens, $this->options['url']);
62
    $data = file_get_contents($url);
63

  
64
    $tmp_file = md5($url . time());
65

  
66
    $files_path = file_directory_temp();
67
    $dir = $files_path . '/views_append_tmp_files';
68

  
69
    if (!is_dir($dir)) {
70
      @mkdir($dir);
71
    }
72

  
73
    if (is_writable($dir)) {
74
      $path = $dir . '/' . $tmp_file;
75
      views_append_request_with_cookie($url, $path);
76

  
77
      if (isset($this->view->pdf) && is_object($this->view->pdf)) {
78
        $this->view->pdf->addPdfDocument($path);
79
      }
80
      else {
81
        return file_get_contents($path);
82
      }
83
    }
84
  }
85

  
86
  /**
87
   * We dont want to use advanced rendering.
88
   */
89
  function allow_advanced_render() {
90
    return FALSE;
91
  }
92
}
htmltest/sites/all/modules/modules/views_view_field/views_view_field.info
1
name = Views Field
2
description = "Views plugin to include a view as a field."
3
dependencies[] = views
4
package = Views
5
core = 7.x
6

  
7
files[] = views_view_field_handler_include_view.inc
8

  
9

  
10
; Information added by drupal.org packaging script on 2013-08-03
11
version = "7.x-1.1"
12
core = "7.x"
13
project = "views_pdf"
14
datestamp = "1375559497"
15

  
htmltest/sites/all/modules/modules/views_view_field/views_view_field.module
1
<?php
2

  
3
/**
4
 * @file
5
 * The views field is used to add a field, which can include another view into
6
 * the current view.
7
 */
8

  
9
/**
10
 * Implementation of hook_views_api().
11
 */
12
function views_view_field_views_api() {
13
  return array(
14
    'api' => 3,
15
  );
16
}
htmltest/sites/all/modules/modules/views_view_field/views_view_field.views.inc
1
<?php
2
/**
3
 * @file
4
 * Views hook implementations
5
 */
6

  
7
/**
8
 * Implemenation of hook_views_data()
9
 */
10
function views_view_field_views_data() {
11

  
12

  
13
  $data['view']['table']['group'] = t('View');
14
  $data['view']['table']['join'] = array(
15
    '#global' => array(),
16
  );
17

  
18
  $data['view']['include'] = array(
19
    'title' => t('Include View'),
20
    'help' => t('Includes a view into this view.'),
21
    'field' => array(
22
      'handler' => 'views_view_field_handler_include_view',
23
      'click sortable' => FALSE,
24
      'notafield' => TRUE,
25
    ),
26
  );
27
  return $data;
28
}
htmltest/sites/all/modules/modules/views_view_field/views_view_field_handler_include_view.inc
1
<?php
2
/**
3
 * @file
4
 * Plugin for the views include field
5
 */
6

  
7
/**
8
 * This class contains the functionality to add a view as a new field in
9
 * another view.
10
 *
11
 */
12
class views_view_field_handler_include_view extends views_handler_field {
13

  
14
  /**
15
   * Query the view. Deactivated because we do not want to query anything.
16
   */
17
  function query() {
18
    // Override parent::query() and don't alter query.
19
    $this->field_alias = 'view_include_' . $this->position;
20
  }
21

  
22
  /**
23
   * Definitions of the views field options.
24
   */
25
  function option_definition() {
26
    $options = parent::option_definition();
27

  
28
    $options['view'] = array('default' => '');
29
    $options['number_of_args'] = array('default' => 1);
30
    $options['args'] = array('default' => array());
31

  
32
    return $options;
33
  }
34

  
35
  /**
36
   * Settings form
37
   */
38
  function options_form(&$form, &$form_state) {
39
    parent::options_form($form, $form_state);
40

  
41
    $views = views_get_all_views();
42

  
43
    foreach ($views as $key => $view) {
44
      if ($this->view->name != $view->name) {
45
        $view_options[$key] = $view->name;
46
      }
47
    }
48

  
49
    $form['view'] = array(
50
      '#type' => 'select',
51
      '#title' => t('View to include'),
52
      '#options' => $view_options,
53
      '#default_value' => $this->options['view'],
54
      '#description' => t('Select the view to include. The display will be automatically determined.'),
55
    );
56

  
57
    $form['number_of_args'] = array(
58
      '#type' => 'textfield',
59
      '#title' => t('Enter the number of arguments'),
60
      '#default_value' => $this->options['number_of_args'],
61
      '#description' => t('Enter the number of arguments you want to pass to the view.'),
62
    );
63

  
64
    for ($i = 0; $this->options['number_of_args'] > $i; $i++) {
65
      $form['args'][$i] = array(
66
        '#type' => 'textfield',
67
        '#title' => t('Argument #%number', array('%number' => ($i+1))),
68
        '#default_value' => $this->options['args'][$i],
69
        '#description' => t('Enter here the argument to pass to the view. If you want to use a value from a field, then use the replacement patterns in <strong>Rewrite results</strong> below.'),
70
      );
71
    }
72

  
73
    // Get a list of the available fields and arguments for token replacement.
74
    $options = array();
75
    foreach ($this->view->display_handler->get_handlers('field') as $field => $handler) {
76

  
77
      // We only use fields up to (and excluding) this one.
78
      if ($field == $this->options['id']) {
79
        break;
80
      }
81
      $options[t('Fields')]["[$field]"] = $handler->ui_name();
82
    }
83
    $count = 0; // This lets us prepare the key as we want it printed.
84
    foreach ($this->view->display_handler->get_handlers('argument') as $arg => $handler) {
85
      $options[t('Arguments')]['%' . ++$count] = t('@argument title', array('@argument' => $handler->ui_name()));
86
      $options[t('Arguments')]['!' . $count] = t('@argument input', array('@argument' => $handler->ui_name()));
87
    }
88

  
89
    $this->document_self_tokens($options[t('Fields')]);
90

  
91
    // Default text.
92
    $output = t('<p>You must add some additional fields to this display before using this field. These fields may be marked as <em>Exclude from display</em> if you prefer. Note that due to rendering order, you cannot use fields that come after this field; if you need a field not listed here, rearrange your fields.</p>');
93
    // We have some options, so make a list.
94
    if (!empty($options)) {
95
      $output = t('<p>The following substitution patterns are available for this display. Use the pattern shown on the left to display the value indicated on the right. Note that due to rendering order, you cannot use fields that come after this field; if you need a field not listed here, rearrange your fields.</p>');
96
      foreach (array_keys($options) as $type) {
97
        if (!empty($options[$type])) {
98
          $items = array();
99
          foreach ($options[$type] as $key => $value) {
100
            $items[] = $key . ' == ' . $value;
101
          }
102
          $output .= theme('item_list', array('items' => $items, 'title' => $type));
103
        }
104
      }
105
    }
106

  
107
    // This construct uses 'hidden' and not markup because process doesn't
108
    // run. It also has an extra div because the dependency wants to hide
109
    // the parent in situations like this, so we need a second div to
110
    // make this work.
111
    $form['alter']['help'] = array(
112
      '#type' => 'hidden',
113
      '#id' => 'views-tokens-help',
114
      '#prefix' => '<div><fieldset id="views-tokens-help"><legend>' . t('Replacement patterns') . '</legend>' . $output . '</fieldset></div>',
115
      /* '#process' => array('views_process_dependency'),
116
      '#dependency' => array(
117
        'edit-options-alter-make-link' => array(1),
118
        'edit-options-alter-alter-text' => array(1),
119
      ), */
120
    );
121

  
122
  }
123

  
124
  /**
125
   * Renders the field. For rendering the new views is created an added. For
126
   * PDF displays the two PDF classes where merged.
127
   */
128
  function render($values) {
129

  
130
    if (!empty($this->options['exclude'])) {
131
      return '';
132
    }
133

  
134
    $displayType = $this->view->display_handler->get_style_type();
135
    $currentDisplay = $this->view->current_display;
136

  
137
    $tokens = $this->get_render_tokens('');
138
    $args = array();
139
    foreach ($this->options['args'] as $arg) {
140
      $args[] = str_replace(array_keys($tokens), $tokens, $arg);
141
    }
142

  
143
    $view_name = $this->options['view'];
144

  
145
    $view = views_get_view($view_name);
146

  
147
    // look for a display named pdf_X.
148
    foreach($view->display as $display) {
149
      if (preg_match('/^pdf_/', $display->id)) {
150
        // found a PDF display so break out of loop.
151
        $pdf_display = $display->id;
152
        break;
153
      }
154
    }
155

  
156
    // Set the found PDF display or automatically revert to default if it's
157
    // not found.
158
    $view->set_display($pdf_display);
159

  
160
    $view->pre_execute($args);
161

  
162
    $view->init_style();
163

  
164
    // Important only for pdf views. With this action we assign the
165
    // PDF document to the new view
166
    if (isset($this->view->pdf) && is_object($this->view->pdf)) {
167
      $view->pdf =& $this->view->pdf;
168

  
169
      $output = $view->render($view->display_handler->display->id);
170
    }
171
    else {
172
      $output = $view->display_handler->execute();
173
    }
174

  
175
    return $output;
176
  }
177

  
178
  function allow_advanced_render() {
179
    return FALSE;
180
  }
181
}

Formats disponibles : Unified diff