public function processform()
 {
     litepublisher::$options->dateformat = $_POST['dateformat'];
     litepublisher::$options->language = $_POST['language'];
     if (litepublisher::$options->timezone != $_POST['timezone']) {
         litepublisher::$options->timezone = $_POST['timezone'];
         $archives = tarchives::i();
         turlmap::unsub($archives);
         $archives->PostsChanged();
     }
     $merger = tlocalmerger::i();
     $merger->lock();
     //$merger->items = array();
     //$merger->install();
     foreach (array_keys($merger->items) as $name) {
         $keys = array_keys($merger->items[$name]['texts']);
         $merger->setfiles($name, $_POST[$name . '_files']);
         foreach ($keys as $key) {
             $merger->addtext($name, $key, $_POST[$name . '_text_' . $key]);
         }
     }
     $merger->html = explode("\n", trim($_POST['adminhtml_files']));
     foreach ($merger->html as $i => $filename) {
         $merger->html[$i] = trim($filename);
     }
     $merger->unlock();
 }
Exemple #2
0
function ExportPosts()
{
    global $wpdb, $from;
    $urlmap = turlmap::i();
    $urlmap->lock();
    $posts = tposts::i();
    $posts->lock();
    if (dbversion) {
        $r = $wpdb->get_results("SELECT max(ID) as autoid FROM {$wpdb->posts} ");
        $autoid = (int) $r[0]->autoid;
        echo "{$autoid} = auto id posts\n";
        $posts->db->exec(sprintf('ALTER TABLE %s AUTO_INCREMENT = %d', $posts->thistable, $autoid));
    }
    $categories = tcategories::i();
    $categories->loadall();
    $categories->lock();
    $tags = ttags::i();
    $tags->loadall();
    $tags->lock();
    if ($from == 0) {
        echo "import categories\n";
        ExportCategories();
        echo "import pages\n";
        ExportPages();
    }
    $cron = tcron::i();
    $cron->disableadd = true;
    //$list = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'post'");
    $list = $wpdb->get_results("SELECT ID FROM {$wpdb->posts} \r\nWHERE post_type = 'post'\r\nand ID > {$from}\r\nlimit 500\r\n");
    echo count($list), " = countposts\n";
    foreach ($list as $index => $idresult) {
        //$itemres= $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE ID = $idresult");
        $itemres = $wpdb->get_results("SELECT * FROM {$wpdb->posts} WHERE ID = {$idresult->ID}");
        $item =& $itemres[0];
        $post = new tpost();
        $post->id = (int) $item->ID;
        echo $post->id, " = id post\n";
        $post->posted = strtotime(mysql2date('Ymd\\TH:i:s', $item->post_date));
        $post->title = $item->post_title;
        $post->categories = wp_get_post_categories($item->ID);
        $taglist = array();
        $wptags = wp_get_post_tags($item->ID);
        foreach ($wptags as $wptag) {
            AddTag($tags, (int) $wptag->term_id, 0, $wptag->name, get_tag_link($wptag->term_id));
            $taglist[] = (int) $wptag->term_id;
        }
        $post->tags = $taglist;
        $UrlArray = parse_url(@get_permalink($item->ID));
        $url = $UrlArray['path'];
        if (!empty($UrlArray['query'])) {
            $url .= '?' . $UrlArray['query'];
        }
        $post->url = $url;
        $post->idurl = litepublisher::$urlmap->add($post->url, get_class($post), $post->id);
        $post->content = $item->post_content;
        $post->commentsenabled = 'open' == $item->comment_status;
        $post->pingenabled = 'open' == $item->ping_status;
        $post->password = $item->post_password;
        $post->status = $item->post_status == 'publish' ? 'published' : 'draft';
        savepost($post);
        $categories->itemsposts->setitems($post->id, $post->categories);
        $tags->itemsposts->setitems($post->id, $post->tags);
        ExportComments($post);
        $post->free();
    }
    $cron->unlock();
    //$CommentManager->SubscribtionEnabled = true;
    //$CommentManager->NotifyModerator = true;
    $tags->unlock();
    $categories->unlock();
    $posts->UpdateArchives();
    $posts->addrevision();
    $posts->unlock();
    $urlmap->clearcache();
    $arch = tarchives::i();
    $arch->postschanged();
    $urlmap->unlock();
    if (count($list) < 500) {
        return false;
    }
    return $item->ID;
}
 public function getcontent($id, $sidebar)
 {
     $arch = tarchives::i();
     if (count($arch->items) == 0) {
         return '';
     }
     $result = '';
     $theme = ttheme::i();
     $tml = $theme->getwidgetitem('archives', $sidebar);
     if ($this->showcount) {
         $counttml = $theme->getwidgettml($sidebar, 'archives', 'subcount');
     }
     $args = targs::i();
     $args->icon = '';
     $args->subcount = '';
     $args->subitems = '';
     $args->rel = 'archives';
     foreach ($arch->items as $date => $item) {
         $args->add($item);
         $args->text = $item['title'];
         if ($this->showcount) {
             $args->subcount = str_replace($counttml, '$itemscount', $item['count']);
         }
         $result .= $theme->parsearg($tml, $args);
     }
     return $theme->getwidgetcontent($result, 'archives', $sidebar);
 }