예제 #1
0
 private function findsame($idpost)
 {
     $posts = tposts::i();
     $post = tpost::i($idpost);
     if (count($post->categories) == 0) {
         return array();
     }
     $cats = tcategories::i();
     $cats->loadall();
     $same = array();
     foreach ($post->categories as $idcat) {
         if (!isset($cats->items[$idcat])) {
             continue;
         }
         $itemsposts = $cats->itemsposts->getposts($idcat);
         $itemsposts = $posts->stripdrafts($itemsposts);
         foreach ($itemsposts as $id) {
             if ($id == $idpost) {
                 continue;
             }
             $same[$id] = isset($same[$id]) ? $same[$id] + 1 : 1;
         }
     }
     arsort($same);
     return array_slice(array_keys($same), 0, $this->maxcount);
 }
예제 #2
0
 protected function create()
 {
     parent::create();
     $this->adminclass = 'tadminexcerptslide';
     $this->addmap('items', array());
     $this->tags = tcategories::i();
 }
예제 #3
0
 protected function create()
 {
     parent::create();
     $this->adminclass = 'tadminsingletagwidget';
     $this->basename = 'widget.singletag';
     $this->addmap('items', array());
     $this->tags = tcategories::i();
 }
 public function getcontent()
 {
     $type = tadminhtml::getparam('type', 'tags') == 'tags' ? 'tags' : 'categories';
     $tags = $type == 'tags' ? ttags::i() : tcategories::i();
     if ($err = self::auth()) {
         return $err;
     }
     $id = tadminhtml::idparam();
     if ($id > 0 && !$tags->itemexists($id)) {
         return self::error403();
     }
     $theme = tview::i(tviews::i()->defaults['admin'])->theme;
     $html = tadminhtml::i();
     $html->section = 'tags';
     $lang = tlocal::i('tags');
     if ($id == 0) {
         $views = tviews::i();
         $name = $type == 'tags' ? 'tag' : 'category';
         $item = array('title' => '', 'idview' => isset($views->defaults[$name]) ? $views->defaults[$name] : 1, 'idperm' => 0, 'icon' => 0, 'includechilds' => $tags->includechilds, 'includeparents' => $tags->includeparents, 'invertorder' => false, 'lite' => $tags->lite, 'liteperpage' => 1000, 'url' => '', 'keywords' => '', 'description' => '', 'head' => '');
     } else {
         $item = $tags->getitem($id);
     }
     switch ($_GET['get']) {
         case 'view':
             if ($id > 0) {
                 foreach (array('includechilds', 'includeparents', 'invertorder', 'lite') as $prop) {
                     $item[$prop] = (int) $item[$prop] > 0;
                 }
             }
             $args = new targs();
             $args->add($item);
             $result = $html->parsearg('[checkbox=includechilds] [checkbox=includeparents] [checkbox=invertorder] [checkbox=lite] [text=liteperpage]', $args);
             $result .= $this->getviewicon($item['idview'], $item['icon']);
             $result .= tadminperms::getcombo($item['idperm']);
             break;
         case 'seo':
             $args = targs::i();
             if ($id == 0) {
                 $args->url = '';
                 $args->keywords = '';
                 $args->description = '';
                 $args->head = '';
             } else {
                 $args->add($tags->contents->getitem($id));
                 $args->url = $tags->items[$id]['url'];
             }
             $result = $html->parsearg('[text=url] [text=description] [text=keywords] [editor=head]', $args);
             break;
         case 'text':
             $result = $this->geteditor('raw', $id == 0 ? '' : $tags->contents->getcontent($id), true);
             $result .= $this->gethead();
             break;
         default:
             $result = var_export($_GET, true);
     }
     return turlmap::htmlheader(false) . $result;
 }
예제 #5
0
function migrateposts()
{
    global $data, $man;
    $data->loadfile('posts' . DIRECTORY_SEPARATOR . 'index');
    $posts = tposts::instance();
    $posts->lock();
    if (dbversion) {
        $man = tdbmanager::instance();
        $man->setautoincrement('posts', $data->lastid);
    } else {
        $posts->autoid = $data->lastid;
    }
    $tags = ttags::instance();
    $tags->lock();
    $tags->itemsposts->lock();
    $cats = tcategories::instance();
    $cats->lock();
    $cats->itemsposts->lock();
    $items = $data->data['items'];
    foreach ($items as $id => $item) {
        $post = migratepost($id);
        savepost($post);
        $cats->itemsposts->setitems($post->id, $post->categories);
        $tags->itemsposts->setitems($post->id, $post->tags);
        migratecomments($id);
        if (!dbversion) {
            $posts->items[$post->id] = array('posted' => $post->posted);
            if ($post->status != 'published') {
                $posts->items[$post->id]['status'] = $post->status;
            }
            if ($post->author > 1) {
                $posts->items[$post->id]['author'] = $post->author;
            }
        }
    }
    $posts->UpdateArchives();
    $posts->addrevision();
    $posts->unlock();
    $tags->itemsposts->unlock();
    $tags->unlock();
    $cats->itemsposts->unlock();
    $cats->unlock();
    $arch = tarchives::instance();
    $arch->postschanged();
    //update trust values
    if (dbversion) {
        $db = litepublisher::$db;
        $trusts = $db->res2assoc($db->query("SELECT author as 'author', count(author) as 'count' FROM  {$db->comments} \r\nwhere status = 'approved' GROUP BY  author"));
        $db->table = 'comusers';
        foreach ($trusts as $r) {
            $db->setvalue($r['author'], 'trust', $r['count']);
        }
        unset($trust);
    }
}
 public function deleteCategory($blogid, $username, $password, $id)
 {
     $this->auth($username, $password, 'editor');
     $id = (int) $id;
     $categories = tcategories::i();
     if (!$categories->itemexists($id)) {
         return xerror(404, "Sorry, no such page.");
     }
     $categories->delete($id);
     return true;
 }
예제 #7
0
 protected function create()
 {
     parent::create();
     $this->addmap('tml', array());
     $this->data['showhome'] = true;
     $this->data['showchilds'] = true;
     $this->data['childsortname'] = 'title';
     $this->data['showsimilar'] = true;
     $this->data['breadpos'] = 'before';
     $this->data['similarpos'] = 'after';
     $this->cats = tcategories::i();
 }
예제 #8
0
function tforumUninstall($self)
{
    tcategories::i()->unbind($self);
    tthemeparser::i()->unbind($self);
    ttheme::clearcache();
    tlocalmerger::i()->deleteplugin(basename(dirname(__FILE__)));
    tjsmerger::i()->deletefile('default', '/plugins/forum/forum.min.js');
    $item = tcategories::i()->getitem($self->rootcat);
    $menus = tmenus::i();
    while ($menus->deleteurl($item['url'])) {
    }
    $adminmenus = tadminmenus::i();
    $adminmenus->deletetree($adminmenus->url2id('/admin/plugins/forum/'));
    litepublisher::$classes->delete('tforumeditor');
    $linkgen = tlinkgenerator::i();
    unset($linkgen->data['forum']);
    $linkgen->save();
}
 public function getPostCategories($id, $username, $password)
 {
     $id = (int) $id;
     $this->canedit($username, $password, $id);
     $posts = tposts::i();
     if (!$posts->itemexists($id)) {
         return $this->xerror(404, "Invalid post id.");
     }
     $post = tpost::i($id);
     $categories = tcategories::i();
     $categories->loaditems($post->categories);
     $isPrimary = true;
     $result = array();
     foreach ($post->categories as $idcat) {
         $item = $categories->getitem($idcat);
         $result[] = array('categoryName' => $item['title'], 'categoryId' => (string) $idcat, 'isPrimary' => $isPrimary);
         $isPrimary = false;
     }
     return $result;
 }
 public function getcontent()
 {
     $result = '';
     $this->basename = 'forum';
     $posts = tposts::i();
     $html = $this->html;
     $html->section = 'editor';
     $lang = tlocal::admin('editor');
     if ($this->idpost == 0) {
         $forum = tforum::i();
         if ($forum->moderate && !litepublisher::$options->ingroup('editor')) {
             // if too many drafts then reject
             $hold = $posts->db->getcount('status = \'draft\' and author = ' . litepublisher::$options->user);
             if ($hold >= 3) {
                 $lang = tlocal::admin('forum');
                 return $html->manydrafts;
             }
         }
     }
     $post = tpost::i($this->idpost);
     ttheme::$vars['post'] = $post;
     $args = new targs();
     $args->id = $this->idpost;
     $args->title = tcontentfilter::unescape($post->title);
     $args->raw = $post->rawcontent;
     $cats = tcategories::i();
     $cats->loadall();
     $args->category = tposteditor::getcombocategories($cats->getchilds(tforum::i()->rootcat), $post->idcat);
     if ($post->id > 0) {
         $result .= $html->h4($lang->formhead . ' ' . $post->bookmark);
     }
     $html->section = 'forum';
     $result .= $html->editor($args);
     $result = $html->fixquote($result);
     return $result;
 }
예제 #11
0
 public function import($s)
 {
     require_once litepublisher::$paths->lib . 'domrss.class.php';
     $a = xml2array($s);
     $urlmap = turlmap::i();
     $urlmap->lock();
     $cats = tcategories::i();
     $cats->lock();
     $tags = ttags::i();
     $tags->lock();
     $posts = tposts::i();
     $posts->lock();
     foreach ($a['rss']['channel'][0]['item'] as $item) {
         $post = $this->add($item);
         $posts->add($post);
         if (!tfilestorage::$disabled) {
             $post->free();
         }
     }
     $posts->unlock();
     $tags->unlock();
     $cats->unlock();
     $urlmap->unlock();
 }
function tcategoriesmenuUninstall($self)
{
    tadminviews::replacemenu(get_class($self), 'tmenus');
    $categories = tcategories::i();
    $categories->unbind($self);
}
예제 #13
0
 public function getcategories()
 {
     return tcategories::i();
 }
예제 #14
0
 public function CreateFirstPost()
 {
     $html = tadminhtml::i();
     $html->section = 'installation';
     $lang = tlocal::i();
     $theme = ttheme::i();
     $post = tpost::i(0);
     $post->title = $lang->posttitle;
     $post->catnames = $lang->postcategories;
     $post->tagnames = $lang->posttags;
     $post->content = $theme->parse($lang->postcontent);
     $posts = tposts::i();
     $posts->add($post);
     $icons = ticons::i();
     $cats = tcategories::i();
     $cats->setvalue($post->categories[0], 'icon', $icons->getid('news'));
     $cm = tcommentmanager::i();
     $users = tusers::i();
     $cm->idguest = $users->add(array('email' => '', 'name' => tlocal::get('default', 'guest'), 'status' => 'hold', 'idgroups' => 'commentator'));
     $cm->save();
     $users->setvalue($cm->idguest, 'status', 'approved');
     tcomments::i()->add($post->id, $cm->idguest, $lang->postcomment, 'approved', '127.0.0.1');
     $plugins = tplugins::i();
     $plugins->lock();
     $plugins->add('oldestposts');
     //$plugins->add('adminlinks');
     //$plugins->add('nicedit');
     $plugins->unlock();
 }
예제 #15
0
function clearall()
{
    clearposts();
    cleartags(tcategories::i());
    cleartags(ttags::i());
    clearmenu();
    if (dbversion) {
        $do = tdboptimizer::i();
        $do->optimize();
    }
}
예제 #16
0
 protected function getpostcategories(tpost $post)
 {
     $postitems = $post->categories;
     $categories = tcategories::i();
     if (count($postitems) == 0) {
         $postitems = array($categories->defaultid);
     }
     return self::getcategories($postitems);
 }
예제 #17
0
 public function CreateFirstPost()
 {
     $html = THtmlResource::instance();
     $html->section = 'installation';
     $lang = tlocal::instance();
     $theme = ttheme::instance();
     $post = tpost::instance(0);
     $post->title = $lang->posttitle;
     $post->catnames = $lang->postcategories;
     $post->tagnames = $lang->posttags;
     $post->content = $theme->parse($lang->postcontent);
     $posts = tposts::instance();
     $posts->add($post);
     $icons = ticons::instance();
     $cats = tcategories::instance();
     $cats->setvalue($post->categories[0], 'icon', $icons->getid('news'));
     $comusers = tcomusers::instance($post->id);
     $userid = $comusers->add($lang->author, $lang->email, $lang->homeurl);
     echo "new comuser id = ";
     var_dump($userid);
     echo "<br>";
     litepublisher::$classes->commentmanager->addcomment($post->id, $userid, $lang->postcomment);
     $plugins = tplugins::instance();
     $plugins->lock();
     //$plugins->add('oldestposts');
     //$plugins->add('adminlinks');
     //$plugins->add('nicedit');
     $plugins->unlock();
 }
예제 #18
0
 private function getcategories($values, $type)
 {
     $result = array();
     $tags = $type == 'tag' ? ttags::i() : tcategories::i();
     if (!is_array($values)) {
         if ($type == 'tag') {
             return $result;
         }
         $result[] = $tags->add(0, $values);
         return $result;
     }
     foreach ($values as $item) {
         if (is_array($item)) {
             if (!isset($item['attributes']['domain']) || $item['attributes']['domain'] != $type) {
                 continue;
             }
             $id = $tags->add(0, $item[0]);
         } else {
             if ($type == 'tag') {
                 continue;
             }
             $id = $tags->add(0, $item);
         }
         if (!in_array($id, $result)) {
             $result[] = $id;
         }
     }
     return $result;
 }
 private function getsubtree($parent)
 {
     $result = array();
     $categories = tcategories::i();
     // first step is a find all childs and sort them
     $sort = array();
     foreach ($categories->items as $id => $item) {
         if ($item['parent'] == $parent) {
             $sort[$id] = (int) $item['customorder'];
         }
     }
     arsort($sort, SORT_NUMERIC);
     $sort = array_reverse($sort, true);
     foreach ($sort as $id => $order) {
         $result[$id] = $this->getsubtree($id);
     }
     return $result;
 }
예제 #20
0
<?php

define('litepublisher_mode', 'xmlrpc');
include 'index.php';
$db = litepublisher::$db;
$db->table = 'posts';
$items = $db->res2assoc($db->query("select id, categories, tags from {$db->posts}"));
$tags = ttags::instance();
$tags->lock();
$tags->itemsposts->lock();
$cats = tcategories::instance();
$cats->lock();
$cats->itemsposts->lock();
foreach ($items as $item) {
    $cats->itemsposts->setitems($item['id'], explode(',', $item['categories']));
    $tags->itemsposts->setitems($item['id'], explode(',', $item['tags']));
}
$tags->itemsposts->unlock();
$tags->unlock();
$cats->itemsposts->unlock();
$cats->unlock();
litepublisher::$urlmap->clearcache();
echo "updated<br>\n";
예제 #21
0
 public function addpost(tpost $post)
 {
     $item = $this->domrss->AddItem();
     tnode::addvalue($item, 'title', $post->title);
     tnode::addvalue($item, 'link', $post->link);
     tnode::addvalue($item, 'comments', $post->link . '#comments');
     tnode::addvalue($item, 'pubDate', $post->pubdate);
     $guid = tnode::addvalue($item, 'guid', $post->link);
     tnode::attr($guid, 'isPermaLink', 'true');
     if (class_exists('tprofile')) {
         $profile = tprofile::i();
         tnode::addvalue($item, 'dc:creator', $profile->nick);
     } else {
         tnode::addvalue($item, 'dc:creator', 'admin');
     }
     $categories = tcategories::i();
     $names = $categories->getnames($post->categories);
     foreach ($names as $name) {
         if (empty($name)) {
             continue;
         }
         tnode::addcdata($item, 'category', $name);
     }
     $tags = ttags::i();
     $names = $tags->getnames($post->tags);
     foreach ($names as $name) {
         if (empty($name)) {
             continue;
         }
         tnode::addcdata($item, 'category', $name);
     }
     $content = '';
     $this->callevent('beforepost', array($post->id, &$content));
     if ($this->template == '') {
         $content .= $post->replacemore($post->rss, true);
     } else {
         $content .= ttheme::parsevar('post', $post, $this->template);
     }
     $this->callevent('afterpost', array($post->id, &$content));
     tnode::addcdata($item, 'content:encoded', $content);
     tnode::addcdata($item, 'description', strip_tags($content));
     tnode::addvalue($item, 'wfw:commentRss', $post->rsscomments);
     if (count($post->files) > 0) {
         $files = tfiles::i();
         $files->loaditems($post->files);
         foreach ($post->files as $idfile) {
             $file = $files->getitem($idfile);
             $enclosure = tnode::add($item, 'enclosure');
             tnode::attr($enclosure, 'url', litepublisher::$site->files . '/files/' . $file['filename']);
             tnode::attr($enclosure, 'length', $file['size']);
             tnode::attr($enclosure, 'type', $file['mime']);
         }
     }
     $post->onrssitem($item);
     $this->onpostitem($item, $post);
     return $item;
 }
function tpostcatwidgetUninstall($self)
{
    tcategories::i()->unbind($self);
    $widgets = twidgets::i();
    $widgets->unbind($self);
}