Пример #1
0
 public function getcontent()
 {
     $result = '';
     $istags = $this->name == 'tags' || $this->name == 'addtag';
     $tags = $istags ? litepublisher::$classes->tags : litepublisher::$classes->categories;
     if (dbversion) {
         $tags->loadall();
     }
     $parents = array(0 => '-----');
     foreach ($tags->items as $id => $item) {
         $parents[$id] = $item['title'];
     }
     $this->basename = 'tags';
     $html = $this->html;
     $lang = tlocal::i('tags');
     $id = $this->idget();
     $args = new targs();
     $args->id = $id;
     $args->adminurl = $this->adminurl;
     $ajax = tadminhtml::getadminlink('/admin/ajaxtageditor.htm', sprintf('id=%d&type=%s&get', $id, $istags ? 'tags' : 'categories'));
     $args->ajax = $ajax;
     if (isset($_GET['action']) && $_GET['action'] == 'delete' && $tags->itemexists($id)) {
         if ($this->confirmed) {
             $tags->delete($id);
             $result .= $html->h4->successdeleted;
         } else {
             return $html->confirmdelete($id, $this->adminurl, $lang->confirmdelete);
         }
     }
     $result .= $html->h4(tadminhtml::getlink('/admin/posts/' . ($istags ? 'addtag' : 'addcat') . '/', $lang->add));
     $item = false;
     if ($id && $tags->itemexists($id)) {
         $item = $tags->getitem($id);
         $args->formtitle = $lang->edit;
     } elseif ($this->name == 'addcat' || $this->name == 'addtag') {
         $id = 0;
         $item = array('id' => 0, 'title' => '', 'parent' => 0, 'customorder' => 0);
         $args->formtitle = $lang->add;
     }
     if ($item) {
         $args->add($item);
         $args->parent = tadminhtml::array2combo($parents, $item['parent']);
         $args->order = tadminhtml::array2combo(array_combine(range(0, 9), range(1, 10)), $item['customorder']);
         $tabs = new tuitabs();
         $tabs->add($lang->title, '
   [text=title]
   [combo=parent]
   [combo=order]
   [hidden=id]' . $html->p->ordernote);
         $tabs->ajax($lang->text, "{$ajax}=text");
         $tabs->ajax($lang->view, "{$ajax}=view");
         $tabs->ajax('SEO', "{$ajax}=seo");
         $form = new adminform($args);
         $result .= $html->adminform($tabs->get(), $args) . tuitabs::gethead();
     }
     //table
     $perpage = 20;
     $count = $tags->count;
     $from = $this->getfrom($perpage, $count);
     if ($tags->dbversion) {
         $iditems = $tags->db->idselect("id > 0 order by parent asc, title asc limit {$from}, {$perpage}");
     } else {
         $iditems = array_slice(array_keys($tags->items), $from, $perpage);
     }
     $items = array();
     foreach ($iditems as $id) {
         $item = $tags->items[$id];
         $item['parentname'] = $parents[$item['parent']];
         $items[] = $item;
     }
     $result .= $html->buildtable($items, array(array('right', $lang->count2, '$itemscount'), array('left', $lang->title, '<a href="$link" title="$title">$title</a>'), array('left', $lang->parent, '$parentname'), array('center', $lang->edit, "<a href=\"{$this->adminurl}=\$id\">{$lang->edit}</a>"), array('center', $lang->delete, "<a class=\"confirm-delete-link\" href=\"{$this->adminurl}=\$id&action=delete\">{$lang->delete}</a>")));
     $result = $html->fixquote($result);
     $theme = ttheme::i();
     $result .= $theme->getpages($this->url, litepublisher::$urlmap->page, ceil($count / $perpage));
     return $result;
 }
Пример #2
0
 public function getcontent()
 {
     $result = '';
     switch ($this->name) {
         case 'menu':
             if (isset($_GET['action']) && in_array($_GET['action'], array('delete', 'setdraft', 'publish'))) {
                 $result .= $this->doaction($this->idget(), $_GET['action']);
             }
             $result .= $this->getmenulist();
             return $result;
         case 'edit':
         case 'editfake':
             $id = tadminhtml::idparam();
             $menus = tmenus::i();
             $parents = array(0 => '-----');
             foreach ($menus->items as $item) {
                 $parents[$item['id']] = $item['title'];
             }
             $html = $this->html;
             $lang = tlocal::i('menu');
             $args = new targs();
             $args->adminurl = $this->adminurl;
             $args->ajax = tadminhtml::getadminlink('/admin/ajaxmenueditor.htm', "id={$id}&get");
             $args->editurl = tadminhtml::getadminlink('/admin/menu/edit', 'id');
             if ($id == 0) {
                 $args->id = 0;
                 $args->title = '';
                 $args->parent = tadminhtml::array2combo($parents, 0);
                 $args->order = tadminhtml::array2combo(range(0, 10), 0);
                 $status = 'published';
             } else {
                 if (!$menus->itemexists($id)) {
                     return $this->notfound;
                 }
                 $menuitem = tmenu::i($id);
                 $args->id = $id;
                 $args->title = $menuitem->getownerprop('title');
                 $args->parent = tadminhtml::array2combo($parents, $menuitem->parent);
                 $args->order = tadminhtml::array2combo(range(0, 10), $menuitem->order);
                 $status = $menuitem->status;
             }
             $args->status = tadminhtml::array2combo(array('draft' => $lang->draft, 'published' => $lang->published), $status);
             if ($this->name == 'editfake' || $id > 0 && $menuitem instanceof tfakemenu) {
                 $args->url = $id == 0 ? '' : $menuitem->url;
                 $args->type = 'fake';
                 $args->formtitle = $lang->faketitle;
                 return $html->adminform('[text=title]
     [text=url]
     [combo=parent]
     [combo=order]
     [combo=status]
     [hidden=type]
     [hidden=id]', $args);
             }
             $tabs = new tuitabs();
             $tabs->add($lang->title, '
   [text=title]
   [combo=parent]
   [combo=order]
   [combo=status]
   [hidden=id]
   ');
             $ajaxurl = tadminhtml::getadminlink('/admin/ajaxmenueditor.htm', "id={$id}&get");
             $tabs->ajax($lang->view, "{$ajaxurl}=view");
             $tabs->ajax('SEO', "{$ajaxurl}=seo");
             $ajaxeditor = tajaxmenueditor::i();
             $args->formtitle = $lang->edit;
             return tuitabs::gethead() . $html->adminform($tabs->get() . sprintf('<div>%s</div>', $ajaxeditor->geteditor('raw', $id == 0 ? '' : $menuitem->rawcontent, true)), $args);
     }
 }