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 listPermissionsAction() { $form = new \Control\Forms(); $form->setTitle('Разрешения для пользователей'); $modules = $this->em->getrepository('Modules\\Entities\\Module')->findBy(array()); 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 = "border-bottom:1px dashed grey"; $form->addObject($link); $form->addHTML('<br/><ul id="module_permissions_' . $module->name . '" style="display:block; list-style:none">'); foreach ($permissions as $permission) { $form->addHTML('<li>'); $edit = new \stdClass(); $edit->type = 'link_img_edit'; $edit->href = '#Users/editPermission/' . $permission->id; $form->addObject($edit); $delete = new \stdClass(); $delete->type = 'link_img_delete'; $delete->action = "javascript: if (MsgOkCancel('Действительно удалить?')) { delete_item('UserPermission','" . $permission->id . "'); }"; $form->addObject($delete); $link = new \stdClass(); $link->type = 'link'; $link->href = '#Users/editPermission/' . $permission->id; $link->text = $permission->title; $form->addObject($link); $form->addHTML('</li>'); } $form->addHTML('</ul><br/>'); } } return $form->render(); }