  |
41 | 41 | | $data[$Qspecific->value('boxes_group')][] = $Qspecific->value('code'); |
| |
42 | 42 | | } |
| |
43 | 43 | | } else { |
  |
44 | | - | $Qboxes = $osC_Database->query('select b2p.boxes_group, b.code from :table_templates_boxes_to_pages b2p, :table_templates_boxes b, :table_templates t where b2p.templates_id = :templates_id and b2p.content_page in (:content_page) and b2p.templates_boxes_id = b.id and b2p.templates_id = t.id order by b2p.boxes_group, b2p.sort_order'); |
| |
| 44 | + | $Qboxes = $osC_Database->query('select b2p.boxes_group, b2p.content_page, b.code from :table_templates_boxes_to_pages b2p, :table_templates_boxes b, :table_templates t where b2p.templates_id = :templates_id and b2p.content_page in (:content_page) and b2p.templates_boxes_id = b.id and b2p.templates_id = t.id order by b2p.boxes_group, b2p.sort_order'); |
|
45 | 45 | | $Qboxes->bindTable(':table_templates_boxes_to_pages', TABLE_TEMPLATES_BOXES_TO_PAGES); |
| |
46 | 46 | | $Qboxes->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES); |
| |
47 | 47 | | $Qboxes->bindTable(':table_templates', TABLE_TEMPLATES); |
| |
|
|
 |
… |
|
50 | 50 | | $Qboxes->execute(); |
| |
51 | 51 | | |
| |
52 | 52 | | while ($Qboxes->next()) { |
  |
53 | | - | $data[$Qboxes->value('boxes_group')][] = $Qboxes->value('code'); |
| |
| 53 | + | $_data[$Qboxes->value('boxes_group')][] = array('code' => $Qboxes->value('code'), |
| |
| 54 | + | 'page' => $Qboxes->value('content_page')); |
|
54 | 55 | | } |
  |
| 56 | + | |
| |
| 57 | + | foreach ($_data as $groups => $boxes) { |
| |
| 58 | + | $clean = array(); |
| |
| 59 | + | |
| |
| 60 | + | foreach ($boxes as $box) { |
| |
| 61 | + | if (isset($clean[$box['code']])) { |
| |
| 62 | + | if (substr_count($box['page'], '/') > substr_count($clean[$box['code']]['page'], '/')) { |
| |
| 63 | + | unset($clean[$box['code']]); |
| |
| 64 | + | } |
| |
| 65 | + | } |
| |
| 66 | + | |
| |
| 67 | + | $clean[$box['code']] = $box; |
| |
| 68 | + | } |
| |
| 69 | + | |
| |
| 70 | + | $_data[$groups] = $clean; |
| |
| 71 | + | } |
| |
| 72 | + | |
| |
| 73 | + | foreach ($_data as $groups => $boxes) { |
| |
| 74 | + | foreach ($boxes as $box) { |
| |
| 75 | + | $data[$groups][] = $box['code']; |
| |
| 76 | + | } |
| |
| 77 | + | } |
  |
55 | 78 | | } |
| |
56 | 79 | | |
| |
57 | 80 | | $osC_Cache->writeBuffer($data); |