public function templates($component, $input) { // todo: psr0 need verify $ctr_type = fx::getComponentNameByClass(get_class($component)); $this->response->submenu->setSubactive('templates'); if (isset($input['params'][2])) { $res = $this->template(array('template_full_id' => $input['params'][2])); if ($res === false) { return array('reload' => '#admin.' . $ctr_type . '.edit(' . $input['params'][0] . ',templates)'); } return $res; } $templates = $this->getComponentTemplates($component); $visuals = fx::data('infoblock_visual')->where('template', $templates->getValues('full_id'))->all(); $field = array('type' => 'list', 'filter' => true); $field['labels'] = array('name' => fx::alang('Name', 'system'), 'action' => fx::alang('Action', 'system'), 'inherited' => fx::alang('Inherited', 'system'), 'source' => fx::alang('Source', 'system'), 'file' => fx::alang('File', 'system'), 'used' => fx::alang('Used', 'system')); $field['values'] = array(); foreach ($templates as $tpl) { $r = array('id' => $tpl['full_id'], 'name' => array('name' => $tpl['name'], 'url' => $ctr_type . '.edit(' . $component['id'] . ',templates,' . $tpl['full_id'] . ')'), 'action' => preg_replace("~^.+\\:~", '', $tpl['of']), 'used' => count($visuals->find('template', $tpl['full_id']))); $owner_ctr_match = null; preg_match("~^(component_|widget_)?(.+?)\\..+\$~", $tpl['of'], $owner_ctr_match); $owner_ctr = $owner_ctr_match ? $owner_ctr_match[2] : null; if ($owner_ctr == $component['keyword']) { $r['inherited'] = ' '; } else { $r['inherited'] = $owner_ctr; } // example: theme.floxim.phototeam:featured_news_list if (preg_match("#^theme\\.(\\w+)\\.(\\w+)\\:.+\$#i", $tpl['full_id'], $match)) { // todo: psr0 need use $match[1] for define vendor template $r['source'] = fx::data('layout')->where('keyword', $match[1] . '.' . $match[2])->one()->get('name') . ' (layout)'; } else { // todo: psr0 need verify $c_parts = fx::getComponentParts($tpl['full_id']); $r['source'] = fx::data($ctr_type, $c_parts['vendor'] . '.' . $c_parts['module'] . '.' . $c_parts['component'])->get('name'); } $r['file'] = fx::path()->http($tpl['file']); $field['values'][] = $r; } return array('fields' => array('templates' => $field)); }