public function processform()
 {
     $downloaditems = tdownloaditems::i();
     if ($this->name == 'addurl') {
         $url = trim($_POST['url']);
         if ($url == '') {
             return '';
         }
         if ($downloaditem = taboutparser::parse($url)) {
             $id = $downloaditems->add($downloaditem);
             litepublisher::$urlmap->redir(tadminhtml::getadminlink('/admin/downloaditems/editor/', "id={$id}"));
         }
         return '';
     }
     $status = isset($_POST['publish']) ? 'published' : (isset($_POST['setdraft']) ? 'draft' : 'delete');
     foreach ($_POST as $key => $id) {
         if (!is_numeric($id)) {
             continue;
         }
         $id = (int) $id;
         if ($status == 'delete') {
             $downloaditems->delete($id);
         } else {
             $downloaditem = tdownloaditem::i($id);
             $downloaditem->status = $status;
             $downloaditems->edit($downloaditem);
         }
     }
 }
 public function processform()
 {
     /*
     echo "<pre>\n";
     var_dump($_POST);
     echo "</pre>\n";
     return;
     */
     extract($_POST, EXTR_SKIP);
     $this->basename = 'downloaditems';
     $html = $this->html;
     $lang = tlocal::i('editor');
     if (empty($_POST['title'])) {
         return $html->h2->emptytitle;
     }
     $downloaditem = tdownloaditem::i((int) $id);
     $this->set_post($downloaditem);
     $downloaditem->version = $version;
     $downloaditem->type = $type;
     $downloaditem->downloadurl = $downloadurl;
     $downloaditem->authorname = $authorname;
     $downloaditem->authorurl = $authorurl;
     $downloaditems = tdownloaditems::i();
     if ($downloaditem->id == 0) {
         $id = $downloaditems->add($downloaditem);
         $_GET['id'] = $id;
         $_POST['id'] = $id;
     } else {
         $downloaditems->edit($downloaditem);
     }
     $lang = tlocal::i('downloaditems');
     return $html->h2->successedit;
 }
 public function getcont()
 {
     $result = '';
     $theme = ttheme::i();
     if (litepublisher::$urlmap->page == 1 && $this->content != '') {
         $result .= $theme->simple($theme->parse($this->rawcontent));
     }
     $perpage = litepublisher::$options->perpage;
     $downloaditems = tdownloaditems::i();
     $d = litepublisher::$db->prefix . $downloaditems->childtable;
     $p = litepublisher::$db->posts;
     $where = $this->type == '' ? '' : " and {$d}.type = '{$this->type}'";
     $count = $downloaditems->getchildscount($where);
     $from = (litepublisher::$urlmap->page - 1) * $perpage;
     if ($from <= $count) {
         $items = $downloaditems->select("{$p}.status = 'published' {$where}", " order by {$p}.posted desc limit {$from}, {$perpage}");
         ttheme::$vars['lang'] = tlocal::i('downloaditem');
         $tml = $theme->templates['custom']['downloadexcerpt'];
         if (count($items) > 0) {
             $result .= $theme->templates['custom']['siteform'];
             foreach ($items as $id) {
                 ttheme::$vars['post'] = tdownloaditem::i($id);
                 $result .= $theme->parse($tml);
             }
         }
     }
     $result .= $theme->getpages($this->url, litepublisher::$urlmap->page, ceil($count / $perpage));
     return $result;
 }