Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like FieldEntry_relationship often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use FieldEntry_relationship, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
18 | class FieldEntry_relationship extends Field |
||
19 | { |
||
20 | |||
21 | /** |
||
22 | * |
||
23 | * Name of the field table |
||
24 | * @var string |
||
25 | */ |
||
26 | const FIELD_TBL_NAME = 'tbl_fields_entry_relationship'; |
||
27 | |||
28 | /** |
||
29 | * |
||
30 | * Separator char for values |
||
31 | * @var string |
||
32 | */ |
||
33 | const SEPARATOR = ','; |
||
34 | |||
35 | |||
36 | /** |
||
37 | * |
||
38 | * Current recursive level of output |
||
39 | * @var int |
||
40 | */ |
||
41 | protected $recursiveLevel = 1; |
||
42 | |||
43 | /** |
||
44 | * |
||
45 | * Parent's maximum recursive level of output |
||
46 | * @var int |
||
47 | */ |
||
48 | protected $recursiveDeepness = null; |
||
49 | |||
50 | /** |
||
51 | * |
||
52 | * Constructor for the oEmbed Field object |
||
53 | */ |
||
54 | public function __construct() |
||
55 | { |
||
56 | // call the parent constructor |
||
57 | parent::__construct(); |
||
58 | // set the name of the field |
||
59 | $this->_name = __('Entry Relationship'); |
||
60 | // permits to make it required |
||
61 | $this->_required = true; |
||
62 | // permits the make it show in the table columns |
||
63 | $this->_showcolumn = true; |
||
64 | // permits association |
||
65 | $this->_showassociation = true; |
||
66 | // current recursive level |
||
67 | $this->recursiveLevel = 1; |
||
68 | // parent's maximum recursive level of output |
||
69 | $this->recursiveDeepness = null; |
||
70 | // set as not required by default |
||
71 | $this->set('required', 'no'); |
||
72 | // show association by default |
||
73 | $this->set('show_association', 'yes'); |
||
74 | // no sections |
||
75 | $this->set('sections', null); |
||
76 | // no max deepness |
||
77 | $this->set('deepness', null); |
||
78 | // no included elements |
||
79 | $this->set('elements', null); |
||
80 | // no modes |
||
81 | $this->set('mode', null); |
||
82 | $this->set('mode_table', null); |
||
83 | // no limit |
||
84 | $this->set('min_entries', null); |
||
85 | $this->set('max_entries', null); |
||
86 | // all permissions |
||
87 | $this->set('allow_new', 'yes'); |
||
88 | $this->set('allow_edit', 'yes'); |
||
89 | $this->set('allow_link', 'yes'); |
||
90 | $this->set('allow_delete', 'no'); |
||
91 | $this->set('allow_collapse', 'yes'); |
||
92 | } |
||
93 | |||
94 | public function isSortable() |
||
95 | { |
||
96 | return false; |
||
97 | } |
||
98 | |||
99 | public function canFilter() |
||
100 | { |
||
101 | return true; |
||
102 | } |
||
103 | |||
104 | public function canPublishFilter() |
||
105 | { |
||
106 | return false; |
||
107 | } |
||
108 | |||
109 | public function canImport() |
||
110 | { |
||
111 | return false; |
||
112 | } |
||
113 | |||
114 | public function canPrePopulate() |
||
115 | { |
||
116 | return false; |
||
117 | } |
||
118 | |||
119 | public function mustBeUnique() |
||
120 | { |
||
121 | return false; |
||
122 | } |
||
123 | |||
124 | public function allowDatasourceOutputGrouping() |
||
125 | { |
||
126 | return false; |
||
127 | } |
||
128 | |||
129 | public function requiresSQLGrouping() |
||
130 | { |
||
131 | return false; |
||
132 | } |
||
133 | |||
134 | public function allowDatasourceParamOutput() |
||
135 | { |
||
136 | return true; |
||
137 | } |
||
138 | |||
139 | /** |
||
140 | * @param string $name |
||
141 | */ |
||
142 | public function getInt($name) |
||
143 | { |
||
144 | return General::intval($this->get($name)); |
||
145 | } |
||
146 | |||
147 | /** |
||
148 | * Check if a given property is == 'yes' |
||
149 | * @param string $name |
||
150 | * @return bool |
||
151 | * True if the current field's value is 'yes' |
||
152 | */ |
||
153 | public function is($name) |
||
154 | { |
||
155 | return $this->get($name) == 'yes'; |
||
156 | } |
||
157 | |||
158 | /** |
||
159 | * @return bool |
||
160 | * True if the current field is required |
||
161 | */ |
||
162 | public function isRequired() |
||
163 | { |
||
164 | return $this->is('required'); |
||
165 | } |
||
166 | |||
167 | public static function getEntries(array $data) |
||
168 | { |
||
169 | return array_map(array('General', 'intval'), array_filter(array_map(trim, explode(self::SEPARATOR, $data['entries'])))); |
||
170 | } |
||
171 | |||
172 | /* ********** INPUT AND FIELD *********** */ |
||
173 | |||
174 | |||
175 | /** |
||
176 | * |
||
177 | * Validates input |
||
178 | * Called before <code>processRawFieldData</code> |
||
179 | * @param $data |
||
180 | * @param $message |
||
181 | * @param $entry_id |
||
182 | */ |
||
183 | public function checkPostFieldData($data, &$message, $entry_id=NULL) |
||
184 | { |
||
185 | $message = NULL; |
||
186 | $required = $this->isRequired(); |
||
187 | |||
188 | if ($required && (!is_array($data) || count($data) == 0 || strlen($data['entries']) < 1)) { |
||
189 | $message = __("'%s' is a required field.", array($this->get('label'))); |
||
190 | return self::__MISSING_FIELDS__; |
||
191 | } |
||
192 | |||
193 | $entries = $data['entries']; |
||
194 | |||
195 | if (!is_array($entries)) { |
||
196 | $entries = static::getEntries($data); |
||
197 | } |
||
198 | |||
199 | // enforce limits only if required or it contains data |
||
200 | if ($required || count($entries) > 0) { |
||
201 | if ($this->getInt('min_entries') > 0 && $this->getInt('min_entries') > count($entries)) { |
||
202 | $message = __("'%s' requires a minimum of %s entries.", array($this->get('label'), $this->getInt('min_entries'))); |
||
203 | return self::__INVALID_FIELDS__; |
||
204 | } else if ($this->getInt('max_entries') > 0 && $this->getInt('max_entries') < count($entries)) { |
||
205 | $message = __("'%s' can not contains more than %s entries.", array($this->get('label'), $this->getInt('max_entries'))); |
||
206 | return self::__INVALID_FIELDS__; |
||
207 | } |
||
208 | } |
||
209 | |||
210 | return self::__OK__; |
||
211 | } |
||
212 | |||
213 | |||
214 | /** |
||
215 | * |
||
216 | * Process data before saving into database. |
||
217 | * |
||
218 | * @param array $data |
||
219 | * @param int $status |
||
220 | * @param boolean $simulate |
||
221 | * @param int $entry_id |
||
222 | * |
||
223 | * @return Array - data to be inserted into DB |
||
224 | */ |
||
225 | public function processRawFieldData($data, &$status, &$message = null, $simulate = false, $entry_id = null) |
||
226 | { |
||
227 | $status = self::__OK__; |
||
228 | $entries = null; |
||
229 | |||
230 | if (!is_array($data) && !is_string($data)) { |
||
231 | return null; |
||
232 | } |
||
233 | |||
234 | if (isset($data['entries'])) { |
||
235 | $entries = $data['entries']; |
||
236 | } |
||
237 | else if (is_string($data)) { |
||
238 | $entries = $data; |
||
239 | } |
||
240 | |||
241 | $row = array( |
||
242 | 'entries' => $entries |
||
243 | ); |
||
244 | |||
245 | // return row |
||
246 | return $row; |
||
247 | } |
||
248 | |||
249 | /** |
||
250 | * This function permits parsing different field settings values |
||
251 | * |
||
252 | * @param array $settings |
||
253 | * the data array to initialize if necessary. |
||
254 | */ |
||
255 | public function setFromPOST(Array &$settings = array()) |
||
256 | { |
||
257 | // call the default behavior |
||
258 | parent::setFromPOST($settings); |
||
259 | |||
260 | // declare a new setting array |
||
261 | $new_settings = array(); |
||
262 | |||
263 | // set new settings |
||
264 | $new_settings['sections'] = is_array($settings['sections']) ? |
||
265 | implode(self::SEPARATOR, $settings['sections']) : |
||
266 | (is_string($settings['sections']) ? $settings['sections'] : null); |
||
267 | |||
268 | $new_settings['show_association'] = $settings['show_association'] == 'yes' ? 'yes' : 'no'; |
||
269 | $new_settings['deepness'] = General::intval($settings['deepness']); |
||
270 | $new_settings['deepness'] = $new_settings['deepness'] < 1 ? null : $new_settings['deepness']; |
||
271 | $new_settings['elements'] = empty($settings['elements']) ? null : $settings['elements']; |
||
272 | $new_settings['mode'] = empty($settings['mode']) ? null : $settings['mode']; |
||
273 | $new_settings['mode_table'] = empty($settings['mode_table']) ? null : $settings['mode_table']; |
||
274 | $new_settings['allow_new'] = $settings['allow_new'] == 'yes' ? 'yes' : 'no'; |
||
275 | $new_settings['allow_edit'] = $settings['allow_edit'] == 'yes' ? 'yes' : 'no'; |
||
276 | $new_settings['allow_link'] = $settings['allow_link'] == 'yes' ? 'yes' : 'no'; |
||
277 | $new_settings['allow_delete'] = $settings['allow_delete'] == 'yes' ? 'yes' : 'no'; |
||
278 | $new_settings['allow_collapse'] = $settings['allow_collapse'] == 'yes' ? 'yes' : 'no'; |
||
279 | |||
280 | // save it into the array |
||
281 | $this->setArray($new_settings); |
||
282 | } |
||
283 | |||
284 | |||
285 | /** |
||
286 | * |
||
287 | * Validates the field settings before saving it into the field's table |
||
288 | */ |
||
289 | public function checkFields(Array &$errors, $checkForDuplicates) |
||
290 | { |
||
291 | $parent = parent::checkFields($errors, $checkForDuplicates); |
||
292 | if ($parent != self::__OK__) { |
||
293 | return $parent; |
||
294 | } |
||
295 | |||
296 | $sections = $this->get('sections'); |
||
297 | |||
298 | if (empty($sections)) { |
||
299 | $errors['sections'] = __('At least one section must be chosen'); |
||
300 | } |
||
301 | |||
302 | return (!empty($errors) ? self::__ERROR__ : self::__OK__); |
||
303 | } |
||
304 | |||
305 | /** |
||
306 | * |
||
307 | * Save field settings into the field's table |
||
308 | */ |
||
309 | public function commit() |
||
310 | { |
||
311 | // if the default implementation works... |
||
312 | if(!parent::commit()) return false; |
||
313 | |||
314 | $id = $this->get('id'); |
||
315 | |||
316 | // exit if there is no id |
||
317 | if($id == false) return false; |
||
318 | |||
319 | // we are the child, with multiple parents |
||
320 | $child_field_id = $id; |
||
321 | |||
322 | // delete associations, only where we are the child |
||
323 | self::removeSectionAssociation($child_field_id); |
||
324 | |||
325 | $sections = $this->getSelectedSectionsArray(); |
||
326 | |||
327 | foreach ($sections as $key => $sectionId) { |
||
328 | if (empty($sectionId)) { |
||
329 | continue; |
||
330 | } |
||
331 | $parent_section_id = General::intval($sectionId); |
||
332 | $parent_section = SectionManager::fetch($sectionId); |
||
333 | $fields = $parent_section->fetchVisibleColumns(); |
||
334 | if (empty($fields)) { |
||
335 | // no visible field, revert to all |
||
336 | $fields = $parent_section->fetchFields(); |
||
337 | } |
||
338 | $parent_field_id = current(array_keys($fields)); |
||
339 | // create association |
||
340 | SectionManager::createSectionAssociation( |
||
341 | $parent_section_id, |
||
342 | $child_field_id, |
||
343 | $parent_field_id, |
||
344 | $this->get('show_association') == 'yes' |
||
345 | ); |
||
346 | } |
||
347 | |||
348 | // declare an array contains the field's settings |
||
349 | $settings = array( |
||
350 | 'sections' => $this->get('sections'), |
||
351 | 'show_association' => $this->get('show_association'), |
||
352 | 'deepness' => $this->get('deepness'), |
||
353 | 'elements' => $this->get('elements'), |
||
354 | 'mode' => $this->get('mode'), |
||
355 | 'mode_table' => $this->get('mode_table'), |
||
356 | 'min_entries' => $this->get('min_entries'), |
||
357 | 'max_entries' => $this->get('max_entries'), |
||
358 | 'allow_new' => $this->get('allow_new'), |
||
359 | 'allow_edit' => $this->get('allow_edit'), |
||
360 | 'allow_link' => $this->get('allow_link'), |
||
361 | 'allow_delete' => $this->get('allow_delete'), |
||
362 | 'allow_collapse' => $this->get('allow_collapse'), |
||
363 | ); |
||
364 | |||
365 | return FieldManager::saveSettings($id, $settings); |
||
366 | } |
||
367 | |||
368 | /** |
||
369 | * |
||
370 | * This function allows Fields to cleanup any additional things before it is removed |
||
371 | * from the section. |
||
372 | * @return boolean |
||
373 | */ |
||
374 | public function tearDown() |
||
375 | { |
||
376 | self::removeSectionAssociation($this->get('id')); |
||
377 | return parent::tearDown(); |
||
378 | } |
||
379 | |||
380 | /** |
||
381 | * Generates the where filter for searching by entry id |
||
382 | * |
||
383 | * @param string $value |
||
384 | * @param @optional string $col |
||
385 | * @param @optional boolean $andOperation |
||
386 | */ |
||
387 | public function generateWhereFilter($value, $col = 'd', $andOperation = true) |
||
388 | { |
||
389 | $junction = $andOperation ? 'AND' : 'OR'; |
||
390 | if (!$value) { |
||
391 | return "{$junction} (`{$col}`.`entries` IS NULL)"; |
||
392 | } |
||
393 | return " {$junction} (`{$col}`.`entries` = '{$value}' OR |
||
394 | `{$col}`.`entries` LIKE '{$value},%' OR |
||
395 | `{$col}`.`entries` LIKE '%,{$value}' OR |
||
396 | `{$col}`.`entries` LIKE '%,{$value},%')"; |
||
397 | } |
||
398 | |||
399 | /** |
||
400 | * Fetch the number of associated entries for a particular entry id |
||
401 | * |
||
402 | * @param string $value |
||
403 | */ |
||
404 | public function fetchAssociatedEntryCount($value) |
||
405 | { |
||
406 | if (!$value) { |
||
407 | return 0; |
||
408 | } |
||
409 | $join = sprintf(" INNER JOIN `tbl_entries_data_%s` AS `d` ON `e`.id = `d`.`entry_id`", $this->get('id')); |
||
410 | $where = $this->generateWhereFilter($value); |
||
411 | |||
412 | $entries = EntryManager::fetch(null, $this->get('parent_section'), null, 0, $where, $join, false, false, array()); |
||
413 | |||
414 | return count($entries); |
||
415 | } |
||
416 | |||
417 | public function fetchAssociatedEntrySearchValue($data, $field_id = null, $parent_entry_id = null) |
||
418 | { |
||
419 | return $parent_entry_id; |
||
420 | } |
||
421 | |||
422 | public function findRelatedEntries($entry_id) |
||
423 | { |
||
424 | $joins = ''; |
||
425 | $where = ''; |
||
426 | $this->buildDSRetrievalSQL(array($entry_id), $joins, $where, true); |
||
427 | |||
428 | $entries = EntryManager::fetch(null, $this->get('parent_section'), null, 0, $where, $joins, false, false, array()); |
||
429 | |||
430 | $ids = array(); |
||
431 | foreach ($entries as $key => $e) { |
||
432 | $ids[] = $e['id']; |
||
433 | } |
||
434 | return $ids; |
||
435 | } |
||
436 | |||
437 | public function prepareAssociationsDrawerXMLElement(Entry $e, array $parent_association, $prepolutate = '') |
||
438 | { |
||
439 | $currentSection = SectionManager::fetch($parent_association['child_section_id']); |
||
440 | $visibleCols = $currentSection->fetchVisibleColumns(); |
||
441 | $outputFieldId = current(array_keys($visibleCols)); |
||
442 | $outputField = FieldManager::fetch($outputFieldId); |
||
443 | |||
444 | $value = $outputField->prepareReadableValue($e->getData($outputFieldId), $e->get('id'), true, __('None')); |
||
445 | |||
446 | $li = new XMLElement('li'); |
||
447 | $li->setAttribute('class', 'field-' . $this->get('type')); |
||
448 | $a = new XMLElement('a', strip_tags($value)); |
||
449 | $a->setAttribute('href', SYMPHONY_URL . '/publish/' . $parent_association['handle'] . '/edit/' . $e->get('id') . '/'); |
||
450 | $li->appendChild($a); |
||
451 | |||
452 | return $li; |
||
453 | } |
||
454 | |||
455 | /** |
||
456 | * @param string $joins |
||
457 | * @param string $where |
||
458 | */ |
||
459 | public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation = false) |
||
460 | { |
||
461 | $field_id = $this->get('id'); |
||
462 | |||
463 | // REGEX filtering is a special case, and will only work on the first item |
||
464 | // in the array. You cannot specify multiple filters when REGEX is involved. |
||
465 | if (self::isFilterRegex($data[0])) { |
||
466 | return $this->buildRegexSQL($data[0], array('entries'), $joins, $where); |
||
467 | } |
||
468 | |||
469 | $this->_key++; |
||
470 | |||
471 | $where .= ' AND (1=' . ($andOperation ? '1' : '0') . ' '; |
||
472 | |||
473 | $joins .= " |
||
474 | INNER JOIN |
||
475 | `tbl_entries_data_{$field_id}` AS `t{$field_id}_{$this->_key}` |
||
476 | ON (`e`.`id` = `t{$field_id}_{$this->_key}`.`entry_id`) |
||
477 | "; |
||
478 | |||
479 | foreach ($data as $value) { |
||
480 | $where .= $this->generateWhereFilter($this->cleanValue($value), "t{$field_id}_{$this->_key}", $andOperation); |
||
481 | } |
||
482 | |||
483 | $where .= ')'; |
||
484 | |||
485 | return true; // this tells the DS Manager that filters are OK!! |
||
486 | } |
||
487 | |||
488 | /* ******* EVENTS ******* */ |
||
489 | |||
490 | public function getExampleFormMarkup() |
||
491 | { |
||
492 | $label = Widget::Label($this->get('label')); |
||
493 | $label->appendChild(Widget::Input('fields['.$this->get('element_name').'][entries]', null, 'hidden')); |
||
494 | |||
495 | return $label; |
||
496 | } |
||
497 | |||
498 | |||
499 | /* ******* DATA SOURCE ******* */ |
||
500 | |||
501 | private function fetchEntry($eId, $elements = array()) |
||
509 | |||
510 | public function fetchIncludableElements() |
||
523 | |||
524 | /** |
||
525 | * Appends data into the XML tree of a Data Source |
||
526 | * @param $wrapper |
||
527 | * @param $data |
||
528 | */ |
||
529 | public function appendFormattedElement(&$wrapper, $data, $encode = false, $mode = null, $entry_id = null) |
||
530 | { |
||
531 | if(!is_array($data) || empty($data)) return; |
||
532 | |||
533 | // root for all values |
||
534 | $root = new XMLElement($this->get('element_name')); |
||
535 | |||
536 | // selected items |
||
537 | $entries = static::getEntries($data); |
||
538 | |||
539 | // current linked entries |
||
540 | $root->setAttribute('entries', $data['entries']); |
||
541 | |||
542 | // available sections |
||
543 | $root->setAttribute('sections', $this->get('sections')); |
||
544 | |||
545 | // included elements |
||
546 | $elements = static::parseElements($this); |
||
547 | |||
548 | // cache |
||
549 | $sectionsCache = new CacheableFetch('SectionManager'); |
||
550 | |||
758 | |||
759 | public function getParameterPoolValue(array $data, $entry_id = null) |
||
764 | |||
765 | /* ********* Utils *********** */ |
||
766 | |||
767 | /** |
||
768 | * Return true if $fieldName is allowed in $sectionElements |
||
769 | * @param string $fieldName |
||
770 | * @param string $sectionElements |
||
771 | * @return bool |
||
772 | */ |
||
773 | public static function isFieldIncluded($fieldName, $sectionElements) |
||
777 | |||
778 | public static function getSectionElementName($fieldName, $sectionElements) |
||
792 | |||
793 | public static function parseElements($field) |
||
829 | |||
830 | public static function extractMode($fieldName, $mode) |
||
842 | |||
843 | /** |
||
844 | * @param string $prefix |
||
845 | * @param string $name |
||
846 | * @param @optional bool $multiple |
||
847 | */ |
||
848 | private function createFieldName($prefix, $name, $multiple = false) |
||
856 | |||
857 | /** |
||
858 | * @param string $name |
||
859 | */ |
||
860 | private function createSettingsFieldName($name, $multiple = false) |
||
864 | |||
865 | /** |
||
866 | * @param string $name |
||
867 | */ |
||
868 | private function createPublishFieldName($name, $multiple = false) |
||
872 | |||
873 | private function getSelectedSectionsArray() |
||
886 | |||
887 | private function buildSectionSelect($name) |
||
901 | |||
902 | private function appendSelectionSelect(&$wrapper) |
||
916 | |||
917 | private function createEntriesList($entries) |
||
932 | |||
933 | private function createEntriesHiddenInput($data) |
||
943 | |||
944 | private function createPublishMenu($sections) |
||
977 | |||
978 | /* ********* UI *********** */ |
||
979 | |||
980 | /** |
||
981 | * |
||
982 | * Builds the UI for the field's settings when creating/editing a section |
||
983 | * @param XMLElement $wrapper |
||
984 | * @param array $errors |
||
985 | */ |
||
986 | public function displaySettingsPanel(&$wrapper, $errors=NULL) |
||
1089 | |||
1090 | /** |
||
1091 | * @param string $fieldName |
||
1092 | * @param string $text |
||
1093 | */ |
||
1094 | private function createCheckbox($fieldName, $text) { |
||
1105 | |||
1106 | /** |
||
1107 | * |
||
1108 | * Builds the UI for the publish page |
||
1109 | * @param XMLElement $wrapper |
||
1110 | * @param mixed $data |
||
1111 | * @param mixed $flagWithError |
||
1112 | * @param string $fieldnamePrefix |
||
1113 | * @param string $fieldnamePostfix |
||
1114 | */ |
||
1115 | public function displayPublishPanel(&$wrapper, $data=NULL, $flagWithError=NULL, $fieldnamePrefix=NULL, $fieldnamePostfix=NULL, $entry_id = null) |
||
1166 | |||
1167 | /** |
||
1168 | * @param integer $count |
||
1169 | */ |
||
1170 | private static function formatCount($count) |
||
1179 | |||
1180 | /** |
||
1181 | * |
||
1182 | * Return a plain text representation of the field's data |
||
1183 | * @param array $data |
||
1184 | * @param int $entry_id |
||
1185 | */ |
||
1186 | public function prepareTextValue($data, $entry_id = null) |
||
1193 | |||
1194 | /** |
||
1195 | * Format this field value for display as readable text value. |
||
1196 | * |
||
1197 | * @param array $data |
||
1198 | * an associative array of data for this string. At minimum this requires a |
||
1199 | * key of 'value'. |
||
1200 | * @param integer $entry_id (optional) |
||
1201 | * An option entry ID for more intelligent processing. Defaults to null. |
||
1202 | * @param string $defaultValue (optional) |
||
1203 | * The value to use when no plain text representation of the field's data |
||
1204 | * can be made. Defaults to null. |
||
1205 | * @return string |
||
1206 | * the readable text summary of the values of this field instance. |
||
1207 | */ |
||
1208 | public function prepareReadableValue($data, $entry_id = null, $truncate = false, $defaultValue = 'None') |
||
1228 | |||
1229 | /** |
||
1230 | * Format this field value for display in the publish index tables. |
||
1231 | * |
||
1232 | * @param array $data |
||
1233 | * an associative array of data for this string. At minimum this requires a |
||
1234 | * key of 'value'. |
||
1235 | * @param XMLElement $link (optional) |
||
1236 | * an XML link structure to append the content of this to provided it is not |
||
1237 | * null. it defaults to null. |
||
1238 | * @param integer $entry_id (optional) |
||
1239 | * An option entry ID for more intelligent processing. defaults to null |
||
1240 | * @return string |
||
1241 | * the formatted string summary of the values of this field instance. |
||
1242 | */ |
||
1243 | public function prepareTableValue($data, XMLElement $link = null, $entry_id = null) |
||
1254 | |||
1255 | /* ********* SQL Data Definition ************* */ |
||
1256 | |||
1257 | /** |
||
1258 | * |
||
1259 | * Creates table needed for entries of individual fields |
||
1260 | */ |
||
1261 | public function createTable() |
||
1275 | |||
1276 | /** |
||
1277 | * Creates the table needed for the settings of the field |
||
1278 | */ |
||
1279 | public static function createFieldTable() |
||
1303 | |||
1304 | public static function update_102() |
||
1330 | |||
1331 | public static function update_103() |
||
1341 | |||
1342 | public static function update_200() |
||
1354 | |||
1355 | /** |
||
1356 | * |
||
1357 | * Drops the table needed for the settings of the field |
||
1358 | */ |
||
1359 | public static function deleteFieldTable() |
||
1367 | |||
1368 | private static function removeSectionAssociation($child_field_id) |
||
1372 | } |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.