source: sipes/0.3-modules/proyectos_operativos_mcti/accion_especifica_mcti.install @ 2fa3319

stableversion-3.0
Last change on this file since 2fa3319 was 303fae2, checked in by José Gregorio Puentes <jpuentes@…>, 9 años ago

se agregaron los modulos

  • Propiedad mode establecida a 100755
File size: 8.6 KB
Línea 
1<?php
2
3  /**
4  * Sistema Integral de Planificación y Presupuesto (SIPP)
5  * @file accion_especifica_mcti.install
6  * Drupal part Module to Sistema Integral de Planificación y Presupuesto (SIPP)
7  * Copyright 2013 Sistema Automatizado para la Planificación Estratégico-Situacional en la Administración Pública Venezolana (CENDITEL)
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22  *
23  * @author Cenditel Merida - Msc. Jose Puentes
24  * @date 2013-02-02 // (a&#241;o-mes-dia)
25  * @version 0.1 // (0.1)
26  *
27  */
28
29/*
30 * Implementation of hook_install()
31 */
32function accion_especifica_mcti_install() {
33  // Notify content module when this module is uninstalled.
34  drupal_load('module', 'content');
35  content_notify('install', 'accion_especifica_mcti');
36}
37
38/*
39 * Implementation of hook_enable()
40 */
41function accion_especifica_mcti_enable() {
42  // Notify content module when this module is uninstalled.
43  drupal_load('module', 'content');
44  drupal_load('module', 'taxonomy');
45  content_notify('enable', 'accion_especifica_mcti');
46  include_once('./'. drupal_get_path('module', 'content') .'/includes/content.crud.inc');
47  _accion_especifica_mcti_install_type_create_field();
48}
49
50/*
51 * Implementation of hook_uninstall()
52 */
53function  accion_especifica_mcti_uninstall() {
54  // Notify content module when this module is uninstalled.
55  include_once('./'. drupal_get_path('module', 'content') .'/includes/content.crud.inc');
56  _accion_especifica_mcti_install_type_remove_field();
57  content_notify('uninstall', 'accion_especifica_mcti');
58}
59
60/*
61 * Implementation of hook_disable()
62 */
63function accion_especifica_mcti_disable() {
64  drupal_load('module', 'content');
65  content_notify('disable', 'accion_especifica_mcti');
66}
67
68/*
69 * elimina los campos
70 */
71function _accion_especifica_mcti_install_type_remove_field() {
72  // Load fields.
73  $accion_especifica_fields = _accion_especifica_mcti_load_fields();
74  $remove_field = FALSE;
75  if (count($accion_especifica_fields['fields'])) {
76    foreach ($accion_especifica_fields['fields'] as $accion_especifica_inserts) {
77      $instances = content_field_instance_read(array(
78        'field_name' => $accion_especifica_inserts['field_name'],
79        'type_name' => $accion_especifica_inserts['type_name']
80      ));
81      if (count($instances)) {
82        // Only add the field if it doesn't exist. Don't overwrite any changes.
83        content_field_instance_delete($accion_especifica_inserts['field_name'], $accion_especifica_inserts['type_name']);
84        drupal_set_message(t("Removed field %typefield in content type %typecontent", array('%typefield' => $accion_especifica_inserts['label'], '%typecontent' => $accion_especifica_inserts['type_name'])));
85      }
86    }
87  }
88}
89
90/*
91 * Crear los tipos de contenidos necesarios para el funcionamiento del modulo
92 */
93function _accion_especifica_mcti_install_type_create_field() {
94  // Load fields.
95  $accion_especifica_fields = _accion_especifica_mcti_load_fields();
96  $create_field = FALSE;
97  if (count($accion_especifica_fields['fields'])) {
98    foreach ($accion_especifica_fields['fields'] as $accion_especifica_inserts) {
99      $instances = content_field_instance_read(array(
100        'field_name' => $accion_especifica_inserts['field_name'],
101        'type_name' => $accion_especifica_inserts['type_name']
102      ));
103      if (count($instances) < 1) {
104        // Only add the field if it doesn't exist. Don't overwrite any changes.
105        $field_create = content_field_instance_create($accion_especifica_inserts, FALSE);
106        drupal_set_message(t("Saved field %typefield in content type %typecontent", array('%typefield' => $accion_especifica_inserts['label'], '%typecontent' => $accion_especifica_inserts['type_name'])));
107      }
108    }
109  }
110}
111
112/*
113 * Definicion de los Campos
114 */
115function _accion_especifica_mcti_load_fields() {
116  $content = array();
117  $content['fields'] = array();
118  $content['fields'][] = array( //andiendo el campo localizacion geografica
119    'label' => 'Ubicación Geografica',
120    'type_name' => 'accion_especifica',
121    'field_name' => 'field_accion_esp_geo',
122    'widget_active' => 1,
123    'type' => 'openlayers_wkt',
124    'required' => 1,
125    'multiple' => 0,
126    'db_storage' => 1,
127    'weight' => 31,
128    'description' => 'Coordenada Geografica donde se ha de ejecutar la acción Especifica',
129    'db_storage' => 1,
130    'module'=> 'openlayers_cck',
131    'active'=> 1,
132    'locked'=> 0,
133    'columns'=> array(
134       'openlayers_wkt'=> array(
135          'type'=> 'text',
136          'size'=> 'big',
137          'not null'=> '',
138          'sortable'=> 1,
139          'views'=> 1,
140        ),
141      ),
142      'openlayers_cck_feature_types'=> array(
143        'point'=> 'point',
144        'polygon' => 'polygon',
145        'path'=> 0,
146      ),
147    'widget' => array(
148      'openlayers_cck_preset_map' => 'default',
149      'openlayers_behaviors' => array(
150        'openlayers_behavior_zoomtolayer' => array(
151          'enabled' => 1,
152          'options' => array(
153            'zoomtolayer' => 'openlayers_cck_vector_layer',
154            'point_zoom_level' => 5,
155          ),
156        ),
157      ),
158      'default_value' => array(
159        '0'=> array(
160          '0'=> array(
161            'openlayers_wkt' => "GEOMETRYCOLLECTION(POINT(-67.324218747312 7.7109916551272))",
162          ),
163        ),
164      ),
165      'default_value_php' => '',
166      'type' => 'openlayers_wkt_widget',
167      'label' => 'Ubicación Geografica',
168      'module' => 'openlayers_cck',
169    ),
170    'display_settings' => array (
171      'label' => array (
172        'format' => 'above',
173        'exclude' => 0,
174      ),
175      'teaser' => array (
176        'format' => 'default',
177        'exclude' => 0,
178      ),
179      'full' => array (
180        'format' => 'default',
181        'exclude' => 0,
182      ),
183      4 => array (
184        'format' => 'default',
185        'exclude' => 0,
186      ),
187      'inline' => array (
188        'format' => 'default',
189        'exclude' => 0,
190      ),
191      'modal' => array (
192        'format' => 'default',
193        'exclude' => 0,
194      ),
195      'token' => array (
196        'format' => 'default',
197        'exclude' => 0,
198      ),
199    ),
200  );
201  //monto total del proyecto
202  $content['fields'][] = array (
203    'label' => 'Total del Financiamiento',
204    'type_name' => 'accion_especifica',
205    'field_name' => 'field_accion_total_financia',
206    'type' => 'number_decimal',
207    'widget_type' => 'number',
208    'change' => 'Change basic information',
209    'weight' => '9',
210    'description' => '',
211    'default_value' =>array (
212      0 => array (
213        'value' => '',
214        '_error_element' => 'default_value_widget][field_accion_total_financia][0][value',
215      ),
216    ),
217    'default_value_php' => '',
218    'default_value_widget' => array (
219      'field_accion_total_financia' => array (
220        0 => array (
221          'value' => '',
222          '_error_element' => 'default_value_widget][field_accion_total_financia][0][value',
223        ),
224      ),
225    ),
226    'required' => 1,
227    'multiple' => '0',
228    'min' => '0',
229    'max' => '',
230    'precision' => '32',
231    'scale' => '0',
232    'decimal' => '.',
233    'allowed_values' => '',
234    'allowed_values_php' => '',
235    'op' => 'Save field settings',
236    'module' => 'number',
237    'widget_module' => 'number',
238    'columns' => array (
239      'value' => array (
240        'type' => 'numeric',
241        'precision' => '32',
242        'scale' => '0',
243        'not null' => false,
244        'sortable' => true,
245      ),
246    ),
247    'display_settings' => array (
248      'label' => array (
249        'format' => 'above',
250        'exclude' => 0,
251      ),
252      'teaser' => array (
253        'format' => 'default',
254        'exclude' => 0,
255      ),
256      'full' => array (
257        'format' => 'default',
258        'exclude' => 0,
259      ),
260      4 => array (
261        'format' => 'default',
262        'exclude' => 0,
263      ),
264      'inline' => array (
265        'format' => 'default',
266        'exclude' => 0,
267      ),
268      'modal' => array (
269        'format' => 'default',
270        'exclude' => 0,
271      ),
272      'token' => array (
273        'format' => 'default',
274        'exclude' => 0,
275      ),
276    ),
277  );
278  return $content;
279}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.