public function listAction() { $form = new \Control\Forms(); $form->setTitle('Настройки'); $form->setTemplate('form'); $theme = new \Control\Theme(); $themes = $theme->getList(); $settings_save = array(); $settings = $this->repSettings->findBy(array(), array('id' => 'ASC')); foreach ($settings as $setting) { if ($setting->name == 'site_theme') { $options = array(); foreach ($themes['custom'] as $theme) { $options[] = $theme . '=' . $theme; } $setting->options = implode(',', $options); } $setting->id = 'Settings_' . $setting->name; $setting->caption = $setting->title; $form->addObject($setting); $settings_save[] = $setting->name; } $form->addFooter(array('type' => 'button', 'id' => 'save', 'value' => 'Сохранить', 'action' => "settings_save('" . implode($this->conf->ac_sep, $settings_save) . "');")); $output = $form->render(); return $output; }
public function settingsAction() { $conf = \Control\Core::conf(); $form = new \Control\Forms(); $form->setTitle('Wysiwygs'); $form->setTemplate('form'); $obj = new \stdClass(); $obj->type = 'select'; $obj->id = 'wysiwygs_name'; $obj->status = 'db'; $obj->value = !empty($conf->settings['wysiwyg']) ? $conf->settings['wysiwyg'] : ''; $obj->options = 'a:4:{s:6:"module";s:8:"Wysiwygs";s:6:"entity";s:7:"Wysiwyg";s:5:"index";s:4:"name";s:5:"title";s:5:"title";}'; $obj->caption = 'Визивиг'; $form->addObject($obj); $form->addHTML('<div id="wysiwygs_info"><br/><br/><br/></div>'); $form->addFooter(array('type' => 'button', 'id' => 'save', 'value' => 'Сохранить', 'action' => 'wysiwygs_save_settings()')); $output = $form->render(); return $output; }
public function editFieldAction($id = null) { if (empty($id)) { exit(json_encode(array('error' => 'Не указан идентификатор'))); } $conf = \Control\Core::conf(); $id = intval($id); $item = $this->repDataField->find($id); $data_type = $this->repDataType->findOneByName($item->data_name); $module = $this->em->getRepository('\\Modules\\Entities\\Module')->findOneByName($data_type->module); $form = new \Control\Forms(); $form->setTitle('Редактировать поле типа данных.'); $form->setTemplate('form'); $form->addHTML($module->title . ' --> ' . $data_type->title . ' --> <strong>' . $item->title . '</strong>'); $fields = array('options', 'attributes', 'default_value'); $options = new \stdClass(); $options->type = 'textarea'; $options->id = $item->data_name . '_options_' . $id; $options->value = $item->options; $options->attributes = "rows='5' cols='30'"; $options->caption = 'Опции'; $attributes = new \stdClass(); $attributes->type = 'textarea'; $attributes->id = $item->data_name . '_attributes_' . $id; $attributes->value = $item->attributes; $attributes->attributes = "rows='5' cols='30'"; $attributes->caption = 'Аттрибуты'; $form->addObject($options); $form->addObject($attributes); switch ($item->type) { case 'textarea': $default_value = new \stdClass(); $default_value->type = 'textarea'; $default_value->id = $item->data_name . '_default_value_' . $id; $default_value->value = $item->default_value; $default_value->attributes = "rows='5' cols='30'"; $default_value->caption = 'Значение по умолчанию'; $form->addObject($default_value); break; case 'select': $fields[] = 'status'; $status = new \stdClass(); $status->type = 'select'; $status->id = $item->data_name . '_status_' . $id; $status->value = $item->status; $status->options = array('static' => 'статичный', 'db' => 'из базы'); $status->caption = 'Тип'; $form->addObject($status); $default_value = new \stdClass(); $default_value->type = 'select'; $default_value->id = $item->data_name . '_default_value_' . $id; $default_value->value = $item->default_value; $default_value->options = $item->options; $default_value->status = $item->status; $default_value->caption = 'Значение по умолчанию'; $form->addObject($default_value); break; case 'checkbox_list': $fields[] = 'status'; $status = new \stdClass(); $status->type = 'select'; $status->id = $item->data_name . '_status_' . $id; $status->value = $item->status; $status->options = array('static' => 'статичный', 'db' => 'из базы'); $status->caption = 'Тип'; $form->addObject($status); break; } $fields = implode($conf->ac_sep, $fields); $form->addFooter(array('type' => 'button', 'id' => 'ok', 'value' => 'Готово', 'action' => "data_field_edit('" . $item->data_name . "', '{$id}', '{$fields}', 'listFields/" . $item->data_name . "');")); $form->addFooter(array('type' => 'button', 'id' => 'save', 'value' => 'Сохранить', 'action' => "data_field_edit('" . $item->data_name . "', '{$id}', '{$fields}', 'editField/{$id}');")); $form->addFooter(array('type' => 'button', 'id' => 'cancel', 'value' => 'Отмена', 'action' => '#Data/listFields/' . $item->data_name)); $output = $form->render(); return $output; }
public function editForm($options, $id, $footer = '', $form_params = array()) { $id = intval($id); if (is_array($options)) { if (empty($options['fields'])) { $fields = $this->fields; } else { $fields_ = explode($this->conf->ac_sep, $options['fields']); foreach ($fields_ as $field) { $fields[] = $this->fields[$field]; } } $params = !empty($options['params']) ? $options['params'] : array(); $header = !empty($options['header']) ? $options['header'] : ''; $footer = !empty($options['footer']) ? $options['footer'] : ''; $title = !empty($options['title']) ? $options['title'] : ''; } $form = new \Control\Forms(); $form->setTitle($title); $form->setTemplate('form'); if (!empty($header)) { $form->addHTML($header); } $entityName = '\\' . $this->module . '\\Entities\\' . $this->entity; $item = $this->em->find($entityName, $id); foreach ($fields as $field) { $field_name = $field->name; $field->id = $this->module . '_' . $field->name; $field->value = $field->type != 'password' ? $item->{$field_name} : ''; $field->caption = $field->title; $form->addObject($field); } if ($footer == '') { $form->addFooter(array('type' => 'button', 'id' => 'ok', 'value' => 'Готово', 'action' => "save_item('{$this->name}', '{$this->fields_str}', '{$id}', 'list');")); $form->addFooter(array('type' => 'button', 'id' => 'save', 'value' => 'Сохранить', 'action' => "save_item('{$this->name}', '{$this->fields_str}', '{$id}');")); $form->addFooter(array('type' => 'button', 'id' => 'delete', 'value' => 'Удалить', 'action' => "javascript: if (MsgOkCancel('Действительно удалить?')) { delete_item('{$this->name}', '{$id}', '1', 'list'); }")); $form->addFooter(array('type' => 'button', 'id' => 'cancel', 'value' => 'Отмена', 'href' => '#' . $this->module . '/list')); } else { if (is_array($footer)) { foreach ($footer as $foot) { $form->addFooter($foot); } } else { $form->addFooter($footer); } } return $form->render(); }
public function editGroupAction($id = null) { $conf = \Control\Core::conf(); $id = intval($id); $group = $this->repUserGroup->find($id); if (empty($group)) { return 'Группа не найдена'; } $data = new \Data\Data(); $data->setName('UserGroup'); $form = new \Control\Forms(); $form->setTitle('Редактировать группу пользователей'); $form->setTemplate('tabs'); $modules = $this->em->getrepository('Modules\\Entities\\Module')->findBy(array()); $modules_data = array(); foreach ($modules as $module) { $modules_data[$module->name] = $module->title; } $form->addTab('Общие данные'); $form->setTabTemplate('form'); $fields = $this->em->getrepository('Data\\Entities\\DataField')->findBy(array('data_name' => 'UserGroup', 'active' => 1), array('num' => 'ASC')); foreach ($fields as $field) { $field_name = $field->name; $field->id = 'users_' . $field->name; $field->value = $group->{$field_name}; $field->caption = $field->title; $form->addTabObject($field); } $form->addTab('Разрешения'); $form->setTabTemplate('default'); $modules = $this->em->getrepository('Modules\\Entities\\Module')->findBy(array('active' => 1)); foreach ($modules as $module) { $permissions = $this->repUserPermission->findBy(array('module' => $module->name)); if (!empty($permissions)) { $link = new \stdClass(); $link->type = 'link'; $link->action = "if (\$('#module_permissions_" . $module->name . "').css('display')=='block') \$('#module_permissions_" . $module->name . "').hide(); else \$('#module_permissions_" . $module->name . "').show();"; $link->text = $module->title; $link->style = "padding:0; border-bottom:1px dashed grey; text-decoration:none"; $form->addTabObject($link); $form->addTabHTML('<br/><ul id="module_permissions_' . $module->name . '" style="display:block; list-style:none">'); foreach ($permissions as $permission) { $form->addTabHTML('<li>'); $perm = new \stdClass(); $perm->type = 'checkbox'; $perm->id = $permission->id; $perm->value = $permission->access_mask & $id ? 1 : 0; $perm->label = $permission->title; $perm->attributes = 'class="checkbox Users_permissions"'; $form->addTabObject($perm); $form->addTabHTML('</li>'); } $form->addTabHTML('</ul><br/>'); } } $form->addFooter(array('type' => 'button', 'id' => 'ok', 'value' => 'Готово', 'action' => "users_group_edit('{$id}','" . $data->fields_str . "','listGroups')")); $form->addFooter(array('type' => 'button', 'id' => 'save', 'value' => 'Сохранить', 'action' => "users_group_edit('{$id}','" . $data->fields_str . "')")); $form->addFooter(array('type' => 'button', 'id' => 'cancel', 'value' => 'Отмена', 'action' => '#Users/listGroups')); return $form->render(); }