Exemplo n.º 1
0
 public static function submenu(Context $ctx, $query, array $pathinfo)
 {
     AdminPage::checkperm($ctx, $pathinfo);
     $router = new Router();
     $router->poll($ctx);
     $menu = new AdminMenu($router->getStatic());
     if (false === ($submenu = $menu->getSubMenu($ctx))) {
         throw new PageNotFoundException();
     }
     if (false === ($content = $submenu->getXML($ctx, 'content', array('type' => 'submenu')))) {
         throw new PageNotFoundException();
     }
     $page = new AdminPage($content);
     return $page->getResponse($ctx);
 }
Exemplo n.º 2
0
 public static function on_get_create_form(Context $ctx)
 {
     $node = Node::create('type', array('parent_id' => $parent_id, 'isdictionary' => true));
     $schema = $node->getFormFields();
     unset($schema['tags']);
     // unset($schema['fields']);
     $schema['isdictionary'] = new HiddenControl(array('value' => 'isdictionary', 'default' => 1));
     $form = $schema->getForm();
     $form->title = t('Добавление справочника');
     $form->addClass('tabbed');
     $form->action = "?q=nodeapi.rpc&action=create&type=type&destination=admin/content/dict";
     $form->addControl(new SubmitControl(array('text' => t('Добавить'))));
     $page = new AdminPage(html::em('content', array('name' => 'create'), $form->getXML($node)));
     return $page->getResponse($ctx);
 }
 public function getHTML($preset = null, array $options = array())
 {
     $this->setUp($preset);
     $data = $this->getData();
     $output = $data;
     $output .= $this->getPager();
     if ($raw = !empty($options['#raw'])) {
         unset($options['#raw']);
     }
     $options = array_merge(array('name' => 'list', 'title' => $this->title, 'preset' => $preset ? $preset : 'default', 'search' => $this->hidesearch ? null : 'yes', 'type' => $this->getType(), 'addlink' => $this->addlink, 'author' => $this->ctx->get('author')), $options);
     $output = html::em('content', $options, $output);
     if ($raw) {
         return $output;
     }
     $page = new AdminPage($output);
     return $page->getResponse($this->ctx);
 }
Exemplo n.º 4
0
 /**
  * Вывод административной страницы. Вызывает обработчик, указанный в next,
  * предварительно проверив права пользователя.
  */
 public static function serve(Context $ctx, $path, array $pathinfo)
 {
     if (class_exists('APIStream')) {
         APIStream::init($ctx);
     }
     try {
         self::checkperm($ctx, $pathinfo);
         if (!$ctx->user->id and empty($pathinfo['anonymous'])) {
             throw new UnauthorizedException();
         }
         if (empty($pathinfo['next'])) {
             if (!empty($pathinfo['xsl'])) {
                 $pathinfo['next'] = 'AdminPage::xsltonly';
             } else {
                 throw new RuntimeException(t('Не указан обработчик для страницы %path (параметр <tt>next</tt>).', array('%path' => $path)));
             }
         }
         if (!is_callable($pathinfo['next'])) {
             throw new RuntimeException(t('Неверный обработчик для страницы %path (<tt>%next()</tt>).', array('%path' => $path, '%next' => $pathinfo['next'])));
         }
         $args = func_get_args();
         $output = call_user_func_array($pathinfo['next'], $args);
         if (!$output instanceof Response) {
             $xsl = empty($pathinfo['xsl']) ? null : implode(DIRECTORY_SEPARATOR, explode('/', $pathinfo['xsl']));
             $tmp = new AdminPage($output, $xsl);
             $output = $tmp->getResponse($ctx);
         }
         return $output;
     } catch (NotConnectedException $e) {
         Logger::trace($e);
         if (is_dir(os::path('lib', 'modules', 'install'))) {
             $ctx->redirect('install?destination=' . urlencode(MCMS_REQUEST_URI));
         } else {
             throw new RuntimeException('Система не проинсталлирована и модуля install нет.');
         }
     } catch (Exception $e) {
         Logger::trace($e);
         $data = array('status' => 500, 'error' => get_class($e), 'message' => $e->getMessage(), 'version' => MCMS_VERSION, 'release' => MCMS_RELEASE, 'base' => $ctx->url()->getBase($ctx), 'prefix' => MCMS_SITE_FOLDER . '/themes', 'back' => urlencode(MCMS_REQUEST_URI), 'next' => urlencode($ctx->get('destination')), 'clean' => !empty($_GET['__cleanurls']));
         if ($e instanceof UserErrorException) {
             $data['status'] = $e->getCode();
         }
         $xsl = os::path('lib', 'modules', 'admin', 'template.xsl');
         xslt::transform(html::em('page', $data), $xsl)->send();
     }
 }
Exemplo n.º 5
0
 public static function settings(Context $ctx, $query, array $pathinfo)
 {
     // Проверяем права, если неверно указан обработчик.
     if ('AdminPage::serve' != $pathinfo['call']) {
         if (empty($pathinfo['perms'])) {
             $pathinfo['perms'] = 'debug';
         }
         AdminPage::checkperm($ctx, $pathinfo);
     }
     $name = substr(strrchr($query, '/'), 1);
     $schema = self::settings_get($ctx, $name);
     $form = $schema->getForm();
     $data = $ctx->config->get('modules/' . $name, array());
     $title = $pathinfo['title'];
     if (empty($form->title)) {
         $form->title = $title;
     }
     $form->action = '?q=modman.rpc&action=configure&module=' . urlencode($name) . '&destination=admin/system/settings';
     $form->addControl(new SubmitControl(array('text' => t('Сохранить'))));
     $result = html::em('content', array('name' => 'form', 'title' => $name, 'mode' => 'config'), $form->getXML(Control::data($data)));
     $page = new AdminPage($result);
     return $page->getResponse($ctx);
 }
Exemplo n.º 6
0
 public static function on_get_create_form(Context $ctx, $path, array $pathinfo, $type, $parent_id = null)
 {
     $node = Node::create(array('class' => $type, 'parent_id' => $parent_id, 'isdictionary' => $ctx->get('dictionary')));
     if ($nodeargs = $ctx->get('node')) {
         foreach ($nodeargs as $k => $v) {
             $node->{$k} = $v;
         }
     }
     $form = $node->formGet();
     $form->addClass('tabbed');
     $form->addClass("node-{$type}-create-form");
     $form->action = "?q=nodeapi.rpc&action=create&type={$type}&destination=" . urlencode($ctx->get('destination'));
     if ($node->parent_id) {
         $form->addControl(new HiddenControl(array('value' => 'parent_id', 'default' => $node->parent_id)));
     }
     if ($ctx->get('dictionary')) {
         if (null !== ($tmp = $form->findControl('tab_general'))) {
             $tmp->intro = t('Вы создаёте первый справочник.  Вы сможете использовать его значения в качестве выпадающих списков (для этого надо будет добавить соответствующее поле в нужный <a href=\'@types\'>тип документа</a>).', array('@types' => '?q=admin&cgroup=structure&mode=list&preset=schema'));
         }
         $form->hideControl('tab_sections');
         if (null !== ($ctl = $form->findControl('title'))) {
             $ctl->label = t('Название справочника');
         }
         if (null !== ($ctl = $form->findControl('name'))) {
             $ctl->label = t('Внутреннее имя справочника');
         }
         $form->addControl(new HiddenControl(array('value' => 'isdictionary', 'default' => 1)));
     }
     $page = new AdminPage(html::em('content', array('name' => 'create'), $form->getXML($node)));
     return $page->getResponse($ctx);
 }