| Conditions | 7 |
| Paths | 3 |
| Total Lines | 30 |
| Code Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 29 | public function updateCMSFields(&$fields) |
||
| 30 | { |
||
| 31 | $fields->removeByName("WishList"); |
||
| 32 | $member = Member::currentUser(); |
||
| 33 | if ($member && $member->IsAdmin()) { |
||
| 34 | $html = ""; |
||
| 35 | $array = unserialize($this->owner->WishList); |
||
| 36 | $links = array(); |
||
| 37 | if (is_array($array) && count($array)) { |
||
| 38 | foreach ($array as $item) { |
||
| 39 | $object = DataObject::get_by_id($item[0], $item[1]); |
||
| 40 | if ($object) { |
||
| 41 | $links[] = "<a href=\"".$object->Link()."\">".$object->Title."</a>"; |
||
| 42 | } else { |
||
| 43 | $links[] = "error in retrieving object ".implode(", ", $item); |
||
| 44 | } |
||
| 45 | } |
||
| 46 | } else { |
||
| 47 | $links[] = "no items on wishlist"; |
||
| 48 | } |
||
| 49 | $html = "<ul><li>".implode("</li><li>", $links)."</li></ul>"; |
||
| 50 | $field = new LiteralField( |
||
| 51 | "WishListOverview", |
||
| 52 | $html |
||
| 53 | ); |
||
| 54 | $fields->addFieldToTab("Root.WishList", $field); |
||
| 55 | } else { |
||
| 56 | $fields->removeByName("WishList"); |
||
| 57 | } |
||
| 58 | } |
||
| 59 | } |
||
| 60 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.