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; }
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 settagnames($names) { $names = trim($names); if ($names == '') { $this->tags = array(); return; } $parent = $this->getparenttag(); $tags = ttags::i(); $items = array(); $list = explode(',', trim($names)); foreach ($list as $title) { $title = tcontentfilter::escape($title); if ($title == '') { continue; } $items[] = $tags->add($parent, $title); } $this->tags = $items; }
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(); }
public function gettags() { return ttags::i(); }
public function getowner() { return ttags::i(); }
function clearall() { clearposts(); cleartags(tcategories::i()); cleartags(ttags::i()); clearmenu(); if (dbversion) { $do = tdboptimizer::i(); $do->optimize(); } }
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; }
<?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";
public function getTags($blogid, $username, $password) { $this->auth($username, $password, 'editor'); $tags = ttags::i(); $result = array(); $tags->loadall(); foreach ($tags->items as $id => $item) { $result[] = array('tag_id' => (string) $id, 'name' => $item['title'], 'count' => $item['itemscount'], 'slug' => '', 'html_url' => litepublisher::$site->url . $item['url'], 'rss_url' => litepublisher::$site->url . $item['url']); } return $result; }
/** * Lite Publisher * Copyright (C) 2010 - 2013 Vladimir Yushko http://litepublisher.ru/ http://litepublisher.com/ * Dual licensed under the MIT (mit.txt) * and GPL (gpl.txt) licenses. **/ function tdownloaditemsInstall($self) { if (!dbversion) { die("Downloads require database"); } $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'resource' . DIRECTORY_SEPARATOR; $manager = tdbmanager::i(); $manager->CreateTable($self->childtable, file_get_contents($dir . 'downloaditem.sql')); $manager->addenum('posts', 'class', 'tdownloaditem'); $optimizer = tdboptimizer::i(); $optimizer->lock(); $optimizer->childtables[] = 'downloaditems'; $optimizer->addevent('postsdeleted', get_class($self), 'postsdeleted'); $optimizer->unlock(); tlocalmerger::i()->add('default', "plugins/" . basename(dirname(__FILE__)) . "/resource/" . litepublisher::$options->language . ".ini"); $ini = parse_ini_file($dir . litepublisher::$options->language . '.install.ini', false); $tags = ttags::i(); litepublisher::$options->downloaditem_themetag = $tags->add(0, $ini['themetag']); litepublisher::$options->downloaditem_plugintag = $tags->add(0, $ini['plugintag']); $base = basename(dirname(__FILE__)); $classes = litepublisher::$classes; $classes->lock(); /* //install polls if its needed $plugins = tplugins::i(); if (!isset($plugins->items['polls'])) $plugins->add('polls'); $polls = tpolls::i(); $polls->garbage = false; $polls->save(); */ $classes->Add('tdownloaditem', 'downloaditem.class.php', $base); $classes->Add('tdownloaditemsmenu', 'downloaditems.menu.class.php', $base); $classes->Add('tdownloaditemeditor', 'admin.downloaditem.editor.class.php', $base); $classes->Add('tadmindownloaditems', 'admin.downloaditems.class.php', $base); $classes->Add('tdownloaditemcounter', 'downloaditem.counter.class.php', $base); $classes->Add('taboutparser', 'about.parser.class.php', $base); $classes->unlock(); tadminhtml::i()->inidir(dirname(__FILE__) . '/resource/'); $lang = tlocal::i('downloaditems'); $lang->ini['downloaditems'] = $lang->ini['downloaditem'] + $lang->ini['downloaditems']; $adminmenus = tadminmenus::i(); $adminmenus->lock(); $parent = $adminmenus->createitem(0, 'downloaditems', 'editor', 'tadmindownloaditems'); $adminmenus->items[$parent]['title'] = $lang->downloaditems; $idmenu = $adminmenus->createitem($parent, 'addurl', 'editor', 'tadmindownloaditems'); $adminmenus->items[$idmenu]['title'] = $lang->addurl; $idmenu = $adminmenus->createitem($parent, 'editor', 'editor', 'tdownloaditemeditor'); $adminmenus->items[$idmenu]['title'] = $lang->add; $idmenu = $adminmenus->createitem($parent, 'theme', 'editor', 'tadmindownloaditems'); $adminmenus->items[$idmenu]['title'] = $lang->themes; $idmenu = $adminmenus->createitem($parent, 'plugin', 'editor', 'tadmindownloaditems'); $adminmenus->items[$idmenu]['title'] = $lang->plugins; $adminmenus->unlock(); $menus = tmenus::i(); $menus->lock(); $menu = tdownloaditemsmenu::i(); $menu->type = ''; $menu->url = '/downloads.htm'; $menu->title = $ini['downloads']; $menu->content = ''; $id = $menus->add($menu); litepublisher::$urlmap->db->setvalue($menu->idurl, 'type', 'get'); foreach (array('theme', 'plugin') as $type) { $menu = tdownloaditemsmenu::i(); $menu->type = $type; $menu->parent = $id; $menu->url = sprintf('/downloads/%ss.htm', $type); $menu->title = $lang->__get($type . 's'); $menu->content = ''; $menus->add($menu); litepublisher::$urlmap->db->setvalue($menu->idurl, 'type', 'get'); } $menus->unlock(); tjsmerger::i()->add('default', '/plugins/downloaditem/downloaditem.min.js'); $parser = tthemeparser::i(); $parser->parsed = $self->themeparsed; ttheme::clearcache(); $linkgen = tlinkgenerator::i(); $linkgen->data['downloaditem'] = '/[type]/[title].htm'; $linkgen->save(); litepublisher::$options->savemodified(); }
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; }