comparison sites/all/modules/quicktabs/quicktabs.install @ 13:134d4b2e75f6

updated quicktabs and google analytics modules
author danieleb <danielebarchiesi@me.com>
date Tue, 29 Oct 2013 13:48:59 +0000
parents a75ead649730
children
comparison
equal deleted inserted replaced
12:a8522bbbfcb0 13:134d4b2e75f6
94 /** 94 /**
95 * Update to 7.x-3.x 95 * Update to 7.x-3.x
96 */ 96 */
97 function quicktabs_update_7300() { 97 function quicktabs_update_7300() {
98 98
99 $output = array();
100
101 if (!db_field_exists('quicktabs', 'renderer')) {
102 // Add the renderer field
103 $renderer_field = array(
104 'description' => 'The rendering mechanism.',
105 'type' => 'varchar',
106 'length' => 255,
107 'not null' => TRUE,
108 'default' => 'quicktabs',
109 );
110 db_add_field('quicktabs', 'renderer', $renderer_field);
111 $output[] = "Added the renderer field";
112 }
113
99 if (!db_field_exists('quicktabs', 'machine_name')) { 114 if (!db_field_exists('quicktabs', 'machine_name')) {
100 // Pull all existing quicktabs, and then delete existing quicktabs. We will reinsert. 115 // Pull all existing quicktabs, and then delete existing quicktabs. We will reinsert.
101 $result = db_query("SELECT * FROM {quicktabs}"); 116 $result = db_query("SELECT * FROM {quicktabs}");
102 if (!db_query("DELETE FROM {quicktabs}")) { 117 if (!db_query("DELETE FROM {quicktabs}")) {
103 throw new DrupalUpdateException(t('Could not complete the update.')); 118 throw new DrupalUpdateException(t('Could not complete the update.'));
111 'not null' => TRUE, 126 'not null' => TRUE,
112 ); 127 );
113 db_add_field('quicktabs', 'machine_name', $name_field); 128 db_add_field('quicktabs', 'machine_name', $name_field);
114 db_add_primary_key('quicktabs', array('machine_name')); 129 db_add_primary_key('quicktabs', array('machine_name'));
115 130
116 $output = $used = array(); 131 $used = array();
117 foreach ($result as $qt) { 132 foreach ($result as $qt) {
118 $row = (array)$qt; 133 $row = (array)$qt;
119 // Generate a machine-readable string 134 // Generate a machine-readable string
120 $qt_name = strtolower(preg_replace('/[^a-zA-Z0-9_]+/', '_', $row['title'])); 135 $qt_name = strtolower(preg_replace('/[^a-zA-Z0-9_]+/', '_', $row['title']));
121 $i = 0; 136 $i = 0;
122 while (in_array($i == 0 ? $qt_name : "{$qt_name}_{$i}", $used)) { 137 while (in_array($i == 0 ? $qt_name : "{$qt_name}_{$i}", $used)) {
123 $i++; 138 $i++;
124 } 139 }
125 $row['machine_name'] = $used[] = $i == 0 ? $qt_name : "{$qt_name}_{$i}"; 140 $row['machine_name'] = $used[] = $i == 0 ? $qt_name : "{$qt_name}_{$i}";
126 unset($row['qtid']); 141 unset($row['qtid']);
127 unset($row['style']); 142 $row['style'] = '';
128 $row['renderer'] = 'tabs'; 143 $row['renderer'] = 'tabs';
129 $placeholders = implode(', ', array_keys($row)); 144 $placeholders = implode(', ', array_keys($row));
130 $values = array(); 145 $values = array();
131 // Ugh - really?? Somebody tell me there's a better way to do this :-/ 146 // Ugh - really?? Somebody tell me there's a better way to do this :-/
132 foreach ($row as $name => $value) { 147 foreach ($row as $name => $value) {
137 152
138 $output[] = "Converted quicktab {$row['machine_name']}."; 153 $output[] = "Converted quicktab {$row['machine_name']}.";
139 } 154 }
140 } 155 }
141 156
142 // Add the renderer field
143 $renderer_field = array(
144 'description' => 'The rendering mechanism.',
145 'type' => 'varchar',
146 'length' => 255,
147 'not null' => TRUE,
148 'default' => 'quicktabs',
149 );
150 db_add_field('quicktabs', 'renderer', $renderer_field);
151 $output[] = "Added the renderer field";
152
153
154 return implode('<br />', $output); 157 return implode('<br />', $output);
155 } 158 }
156 159
157 /** 160 /**
158 * Add the options field which will hold renderer-specific options. 161 * Add the options field which will hold renderer-specific options.