public function items($input) { $entity = $input['entity']; $items = $entity->getAllFields(); $ar = array('type' => 'list', 'filter' => true, 'is_sortable' => true); // todo: psr0 need verify $entity_code = fx::getComponentNameByClass(get_class($entity)); $ar['entity'] = 'field'; $ar['values'] = array(); $ar['labels'] = array('keyword' => fx::alang('Keyword', 'system'), 'name' => fx::alang('Name', 'system'), 'type' => fx::alang('Type', 'system'), 'inherited' => fx::alang('Inherited from', 'system'), 'editable' => fx::alang('Editable', 'system')); foreach ($items as $field) { $r = array('id' => $field->getId(), 'keyword' => array('name' => $field['keyword'], 'url' => '#admin.' . $entity_code . '.edit(' . $field['component_id'] . ',edit_field,' . $field['id'] . ')'), 'name' => $field['name'], 'type' => fx::alang("FX_ADMIN_FIELD_" . strtoupper($field->getTypeKeyword()), 'system')); if ($entity['id'] != $field['component_id']) { $component_name = fx::data('component', $field['component_id'])->get('name'); $r['inherited'] = $component_name; } else { $r['inherited'] = ' '; } switch ($field['type_of_edit']) { case CompField\Entity::EDIT_ALL: $r['editable'] = fx::alang('Yes', 'system'); break; case CompField\Entity::EDIT_NONE: $r['editable'] = fx::alang('No', 'system'); break; case CompField\Entity::EDIT_ADMIN: $r['editable'] = fx::alang('For admin only', 'system'); break; } $ar['values'][] = $r; } $result['fields'] = array($ar); $this->response->addButtons(array(array('key' => 'add', 'title' => fx::alang('Add new field', 'system'), 'url' => '#admin.' . $entity_code . '.edit(' . $entity['id'] . ',add_field)'), "delete")); return $result; }
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)); }
public function __construct($table = null) { parent::__construct($table); $this->setComponent(fx::getComponentNameByClass(get_class($this))); }