public function up()
 {
     $table = Base::table('pages');
     $table2 = Base::table('posts');
     if ($this->has_table_column($table, 'content')) {
         $sql = 'ALTER TABLE `' . $table . '` ';
         $sql .= 'CHANGE `content` `markdown` TEXT';
         DB::ask($sql);
     }
     if (!$this->has_table_column($table, 'html') && $this->has_table_column($table, 'markdown')) {
         $sql = 'ALTER TABLE `' . $table . '` ';
         $sql .= 'ADD `html` TEXT NOT NULL AFTER `markdown`';
         DB::ask($sql);
         $pages = Page::sort('menu_order', 'desc')->get();
         foreach ($pages as $page) {
             Page::update($page->id, array('html' => parse($page->markdown)));
         }
     }
     if (!$this->has_table_column($table2, 'markdown') && $this->has_table_column($table2, 'html')) {
         $sql = 'ALTER TABLE `' . $table2 . '` ';
         $sql .= 'ADD `markdown` TEXT NOT NULL AFTER `description`';
         DB::ask($sql);
         $migrate_data_sql = 'update `' . $table2 . '` set `markdown` = `html`, `html` = "";';
         DB::ask($migrate_data_sql);
         $posts = Post::sort('created', 'desc')->get();
         foreach ($posts as $post) {
             Post::update($post->id, array('html' => parse($post->markdown)));
         }
     }
 }
Example #2
0
File: Admin.php Project: eadz/chyrp
 /**
  * Function: reorder_pages
  * Reorders pages.
  */
 public function reorder_pages()
 {
     foreach ($_POST['list_order'] as $id => $order) {
         $page = new Page($id);
         $page->update($page->title, $page->body, null, $page->parent_id, $page->show_in_list, $order, null, $page->url);
     }
     Flash::notice(__("Pages reordered."), "/admin/?action=manage_pages");
 }
Example #3
0
 public function update($data)
 {
     if (isset($data['stackName'])) {
         $txt = Loader::helper('text');
         $data['cName'] = $data['stackName'];
         $data['cHandle'] = str_replace('-', PAGE_PATH_SEPARATOR, $txt->urlify($data['stackName']));
     }
     parent::update($data);
     if (isset($data['stackName'])) {
         // Make sure the stack path is always up-to-date after a name change
         $this->rescanCollectionPath();
         $db = Loader::db();
         $stackName = $data['stackName'];
         $db->Execute('update Stacks set stName = ? WHERE cID = ?', array($stackName, $this->getCollectionID()));
     }
 }
 public function updateStatut(Page $page)
 {
     /*$page = Page::findOrFail($id);*/
     $page->draft = Input::get('draft');
     $page->update();
     return Redirect::route('admin.pages.index')->withMessage("La page a été modifiée");
 }
Example #5
0
function importer($path, $node, $line)
{
    global $blogid, $migrational, $items, $item;
    switch ($path) {
        case '/blog/setting':
            setProgress($item++ / $items * 100, _t('블로그 설정을 복원하고 있습니다.'));
            $setting = new BlogSetting();
            if (isset($node['title'][0]['.value'])) {
                $setting->title = $node['title'][0]['.value'];
            }
            if (isset($node['description'][0]['.value'])) {
                $setting->description = $node['description'][0]['.value'];
            }
            if (isset($node['banner'][0]['name'][0]['.value'])) {
                $setting->banner = $node['banner'][0]['name'][0]['.value'];
            }
            if (isset($node['useSloganOnPost'][0]['.value'])) {
                $setting->useSloganOnPost = $node['useSloganOnPost'][0]['.value'];
            }
            if (isset($node['postsOnPage'][0]['.value'])) {
                $setting->postsOnPage = $node['postsOnPage'][0]['.value'];
            }
            if (isset($node['postsOnList'][0]['.value'])) {
                $setting->postsOnList = $node['postsOnList'][0]['.value'];
            }
            if (isset($node['postsOnFeed'][0]['.value'])) {
                $setting->postsOnFeed = $node['postsOnFeed'][0]['.value'];
            }
            if (isset($node['publishWholeOnFeed'][0]['.value'])) {
                $setting->publishWholeOnFeed = $node['publishWholeOnFeed'][0]['.value'];
            }
            if (isset($node['acceptGuestComment'][0]['.value'])) {
                $setting->acceptGuestComment = $node['acceptGuestComment'][0]['.value'];
            }
            if (isset($node['acceptcommentOnGuestComment'][0]['.value'])) {
                $setting->acceptcommentOnGuestComment = $node['acceptcommentOnGuestComment'][0]['.value'];
            }
            if (isset($node['language'][0]['.value'])) {
                $setting->language = $node['language'][0]['.value'];
            }
            if (isset($node['timezone'][0]['.value'])) {
                $setting->timezone = $node['timezone'][0]['.value'];
            }
            if (!$setting->save()) {
                user_error(__LINE__ . $setting->error);
            }
            if (!empty($setting->banner) && !empty($node['banner'][0]['content'][0]['.stream'])) {
                Attachment::confirmFolder();
                Utils_Base64Stream::decode($node['banner'][0]['content'][0]['.stream'], Path::combine(ROOT, 'attach', $blogid, $setting->banner));
                Attachment::adjustPermission(Path::combine(ROOT, 'attach', $blogid, $setting->banner));
                fclose($node['banner'][0]['content'][0]['.stream']);
                unset($node['banner'][0]['content'][0]['.stream']);
            }
            return true;
        case '/blog/category':
            setProgress($item++ / $items * 100, _t('분류를 복원하고 있습니다.'));
            $category = new Category();
            $category->name = $node['name'][0]['.value'];
            $category->priority = $node['priority'][0]['.value'];
            if (isset($node['root'][0]['.value'])) {
                $category->id = 0;
            }
            if (!$category->add()) {
                user_error(__LINE__ . $category->error);
            }
            if (isset($node['category'])) {
                for ($i = 0; $i < count($node['category']); $i++) {
                    $childCategory = new Category();
                    $childCategory->parent = $category->id;
                    $cursor =& $node['category'][$i];
                    $childCategory->name = $cursor['name'][0]['.value'];
                    $childCategory->priority = $cursor['priority'][0]['.value'];
                    if (!$childCategory->add()) {
                        user_error(__LINE__ . $childCategory->error);
                    }
                }
            }
            return true;
        case '/blog/post':
            setProgress($item++ / $items * 100, _t('글을 복원하고 있습니다.'));
            $post = new Post();
            $post->id = $node['id'][0]['.value'];
            $post->slogan = @$node['.attributes']['slogan'];
            $post->visibility = $node['visibility'][0]['.value'];
            if (isset($node['starred'][0]['.value'])) {
                $post->starred = $node['starred'][0]['.value'];
            } else {
                $post->starred = 0;
            }
            $post->title = $node['title'][0]['.value'];
            $post->content = $node['content'][0]['.value'];
            $post->contentformatter = isset($node['content'][0]['.attributes']['formatter']) ? $node['content'][0]['.attributes']['formatter'] : 'ttml';
            $post->contenteditor = isset($node['content'][0]['.attributes']['editor']) ? $node['content'][0]['.attributes']['editor'] : 'modern';
            $post->location = $node['location'][0]['.value'];
            $post->password = isset($node['password'][0]['.value']) ? $node['password'][0]['.value'] : null;
            $post->acceptcomment = $node['acceptComment'][0]['.value'];
            $post->accepttrackback = $node['acceptTrackback'][0]['.value'];
            $post->published = $node['published'][0]['.value'];
            if (isset($node['longitude'][0]['.value'])) {
                $post->longitude = $node['longitude'][0]['.value'];
            }
            if (isset($node['latitude'][0]['.value'])) {
                $post->latitude = $node['latitude'][0]['.value'];
            }
            $post->created = @$node['created'][0]['.value'];
            $post->modified = @$node['modified'][0]['.value'];
            if ($post->visibility == 'private' && intval($post->published) > $_SERVER['REQUEST_TIME'] || !empty($node['appointed'][0]['.value']) && $node['appointed'][0]['.value'] == 'true') {
                // for compatibility of appointed entries
                $post->visibility = 'appointed';
            }
            if ($post->slogan == '') {
                $post->slogan = 'Untitled' . $post->id;
            }
            if (!empty($node['category'][0]['.value'])) {
                $post->category = Category::getId($node['category'][0]['.value']);
            }
            if (isset($node['tag'])) {
                $post->tags = array();
                for ($i = 0; $i < count($node['tag']); $i++) {
                    if (!empty($node['tag'][$i]['.value'])) {
                        array_push($post->tags, $node['tag'][$i]['.value']);
                    }
                }
            }
            if (floatval(Setting::getServiceSettingGlobal('newlineStyle')) >= 1.1 && floatval(@$node['.attributes']['format']) < 1.1) {
                $post->content = nl2brWithHTML($post->content);
            }
            if (!$post->add()) {
                user_error(__LINE__ . $post->error);
            }
            if (isset($node['attachment'])) {
                for ($i = 0; $i < count($node['attachment']); $i++) {
                    $attachment = new Attachment();
                    $attachment->parent = $post->id;
                    $cursor =& $node['attachment'][$i];
                    $attachment->name = $cursor['name'][0]['.value'];
                    $attachment->label = $cursor['label'][0]['.value'];
                    $attachment->mime = @$cursor['.attributes']['mime'];
                    $attachment->size = $cursor['.attributes']['size'];
                    $attachment->width = $cursor['.attributes']['width'];
                    $attachment->height = $cursor['.attributes']['height'];
                    $attachment->enclosure = @$cursor['enclosure'][0]['.value'];
                    $attachment->attached = $cursor['attached'][0]['.value'];
                    $attachment->downloads = @$cursor['downloads'][0]['.value'];
                    if (!$attachment->add()) {
                        user_error(__LINE__ . $attachment->error);
                    } else {
                        if ($cursor['name'][0]['.value'] != $attachment->name) {
                            $post2 = new Post();
                            if ($post2->open($post->id, 'id, content')) {
                                $post2->content = str_replace($cursor['name'][0]['.value'], $attachment->name, $post2->content);
                                $post2->loadTags();
                                $post2->update();
                                $post2->close();
                            }
                            unset($post2);
                        }
                    }
                    if (!empty($cursor['content'][0]['.stream'])) {
                        Utils_Base64Stream::decode($cursor['content'][0]['.stream'], Path::combine(ROOT, 'attach', $blogid, $attachment->name));
                        Attachment::adjustPermission(Path::combine(ROOT, 'attach', $blogid, $attachment->name));
                        fclose($cursor['content'][0]['.stream']);
                        unset($cursor['content'][0]['.stream']);
                    }
                }
            }
            if (isset($node['comment'])) {
                for ($i = 0; $i < count($node['comment']); $i++) {
                    $comment = new Comment();
                    $comment->entry = $post->id;
                    $cursor =& $node['comment'][$i];
                    $comment->name = $cursor['commenter'][0]['name'][0]['.value'];
                    if (!empty($cursor['id'][0]['.value'])) {
                        $comment->id = $cursor['id'][0]['.value'];
                    }
                    if (!empty($cursor['commenter'][0]['.attributes']['id'])) {
                        $comment->commenter = $cursor['commenter'][0]['.attributes']['id'];
                    }
                    if (!empty($cursor['commenter'][0]['homepage'][0]['.value'])) {
                        $comment->homepage = $cursor['commenter'][0]['homepage'][0]['.value'];
                    }
                    if (!empty($cursor['commenter'][0]['ip'][0]['.value'])) {
                        $comment->ip = $cursor['commenter'][0]['ip'][0]['.value'];
                    }
                    if (!empty($cursor['commenter'][0]['openid'][0]['.value'])) {
                        $comment->openid = $cursor['commenter'][0]['openid'][0]['.value'];
                    }
                    $comment->password = $cursor['password'][0]['.value'];
                    $comment->secret = $cursor['secret'][0]['.value'];
                    $comment->written = $cursor['written'][0]['.value'];
                    if (isset($cursor['longitude'][0]['.value'])) {
                        $comment->longitude = $cursor['longitude'][0]['.value'];
                    }
                    if (isset($cursor['latitude'][0]['.value'])) {
                        $comment->latitude = $cursor['latitude'][0]['.value'];
                    }
                    $comment->content = $cursor['content'][0]['.value'];
                    if (!empty($cursor['isFiltered'][0]['.value'])) {
                        $comment->isfiltered = $cursor['isFiltered'][0]['.value'];
                    }
                    if (!$comment->add()) {
                        user_error(__LINE__ . $comment->error);
                    }
                    if (isset($node['comment'][$i]['comment'])) {
                        for ($j = 0; $j < count($node['comment'][$i]['comment']); $j++) {
                            $childComment = new Comment();
                            $childComment->entry = $post->id;
                            $childComment->parent = $comment->id;
                            $cursor =& $node['comment'][$i]['comment'][$j];
                            if (!empty($cursor['id'][0]['.value'])) {
                                $childComment->id = $cursor['id'][0]['.value'];
                            }
                            if (!empty($cursor['commenter'][0]['.attributes']['id'])) {
                                $childComment->commenter = $cursor['commenter'][0]['.attributes']['id'];
                            }
                            $childComment->name = $cursor['commenter'][0]['name'][0]['.value'];
                            if (!empty($cursor['commenter'][0]['homepage'][0]['.value'])) {
                                $childComment->homepage = $cursor['commenter'][0]['homepage'][0]['.value'];
                            }
                            if (!empty($cursor['commenter'][0]['ip'][0]['.value'])) {
                                $childComment->ip = $cursor['commenter'][0]['ip'][0]['.value'];
                            }
                            if (!empty($cursor['commenter'][0]['openid'][0]['.value'])) {
                                $childComment->openid = $cursor['commenter'][0]['openid'][0]['.value'];
                            }
                            $childComment->password = $cursor['password'][0]['.value'];
                            $childComment->secret = $cursor['secret'][0]['.value'];
                            $childComment->written = $cursor['written'][0]['.value'];
                            if (isset($cursor['longitude'][0]['.value'])) {
                                $comment->longitude = $cursor['longitude'][0]['.value'];
                            }
                            if (isset($cursor['latitude'][0]['.value'])) {
                                $comment->latitude = $cursor['latitude'][0]['.value'];
                            }
                            $childComment->content = $cursor['content'][0]['.value'];
                            if (!empty($cursor['isFiltered'][0]['.value'])) {
                                $childComment->isfiltered = $cursor['isFiltered'][0]['.value'];
                            }
                            if (!$childComment->add()) {
                                user_error(__LINE__ . $childComment->error);
                            }
                        }
                    }
                }
            }
            if (isset($node['trackback'])) {
                for ($i = 0; $i < count($node['trackback']); $i++) {
                    $trackback = new Trackback();
                    $trackback->entry = $post->id;
                    $cursor =& $node['trackback'][$i];
                    $trackback->url = $cursor['url'][0]['.value'];
                    $trackback->site = $cursor['site'][0]['.value'];
                    $trackback->title = $cursor['title'][0]['.value'];
                    $trackback->excerpt = @$cursor['excerpt'][0]['.value'];
                    if (!empty($cursor['ip'][0]['.value'])) {
                        $trackback->ip = $cursor['ip'][0]['.value'];
                    }
                    if (!empty($cursor['received'][0]['.value'])) {
                        $trackback->received = $cursor['received'][0]['.value'];
                    }
                    if (!empty($cursor['isFiltered'][0]['.value'])) {
                        $trackback->isFiltered = $cursor['isFiltered'][0]['.value'];
                    }
                    if (!$trackback->add()) {
                        user_error(__LINE__ . $trackback->error);
                    }
                }
            }
            if (isset($node['logs'][0]['trackback'])) {
                for ($i = 0; $i < count($node['logs'][0]['trackback']); $i++) {
                    $log = new TrackbackLog();
                    $log->entry = $post->id;
                    $cursor =& $node['logs'][0]['trackback'][$i];
                    $log->url = $cursor['url'][0]['.value'];
                    if (!empty($cursor['sent'][0]['.value'])) {
                        $log->sent = $cursor['sent'][0]['.value'];
                    }
                    if (!$log->add()) {
                        user_error(__LINE__ . $log->error);
                    }
                }
            }
            return true;
        case '/blog/page':
            setProgress($item++ / $items * 100, _t('페이지를 복원하고 있습니다.'));
            $page = new Page();
            $page->id = $node['id'][0]['.value'];
            $page->slogan = @$node['.attributes']['slogan'];
            $page->visibility = $node['visibility'][0]['.value'];
            if (isset($node['starred'][0]['.value'])) {
                $page->starred = $node['starred'][0]['.value'];
            } else {
                $page->starred = 0;
            }
            $page->title = $node['title'][0]['.value'];
            $page->content = $node['content'][0]['.value'];
            $page->contentformatter = isset($node['content']['.attributes']['formatter']) ? $node['content']['.attributes']['formatter'] : getDefaultFormatter();
            $page->contenteditor = isset($node['content']['.attributes']['editor']) ? $node['content']['.attributes']['editor'] : getDefaultEditor();
            $page->published = $node['published'][0]['.value'];
            $page->created = @$node['created'][0]['.value'];
            $page->modified = @$node['modified'][0]['.value'];
            if (floatval(Setting::getServiceSettingGlobal('newlineStyle')) >= 1.1 && floatval(@$node['.attributes']['format']) < 1.1) {
                $page->content = nl2brWithHTML($page->content);
            }
            if (!$page->add()) {
                user_error(__LINE__ . $page->error);
            }
            if (isset($node['attachment'])) {
                for ($i = 0; $i < count($node['attachment']); $i++) {
                    $attachment = new Attachment();
                    $attachment->parent = $page->id;
                    $cursor =& $node['attachment'][$i];
                    $attachment->name = $cursor['name'][0]['.value'];
                    $attachment->label = $cursor['label'][0]['.value'];
                    $attachment->mime = @$cursor['.attributes']['mime'];
                    $attachment->size = $cursor['.attributes']['size'];
                    $attachment->width = $cursor['.attributes']['width'];
                    $attachment->height = $cursor['.attributes']['height'];
                    $attachment->enclosure = @$cursor['enclosure'][0]['.value'];
                    $attachment->attached = $cursor['attached'][0]['.value'];
                    $attachment->downloads = @$cursor['downloads'][0]['.value'];
                    if (Attachment::doesExist($attachment->name)) {
                        if (!$attachment->add()) {
                            user_error(__LINE__ . $attachment->error);
                        }
                        $page2 = new Page();
                        if ($page2->open($page->id, 'id, content')) {
                            $page2->content = str_replace($cursor['name'][0]['.value'], $attachment->name, $page2->content);
                            $page2->update();
                            $page2->close();
                        }
                        unset($page2);
                    } else {
                        if (!$attachment->add()) {
                            user_error(__LINE__ . $attachment->error);
                        }
                    }
                    if (!empty($cursor['content'][0]['.stream'])) {
                        Utils_Base64Stream::decode($cursor['content'][0]['.stream'], Path::combine(ROOT, 'attach', $blogid, $attachment->name));
                        Attachment::adjustPermission(Path::combine(ROOT, 'attach', $blogid, $attachment->name));
                        fclose($cursor['content'][0]['.stream']);
                        unset($cursor['content'][0]['.stream']);
                    }
                }
            }
            return true;
        case '/blog/notice':
            setProgress($item++ / $items * 100, _t('공지를 복원하고 있습니다.'));
            $notice = new Notice();
            $notice->id = $node['id'][0]['.value'];
            $notice->slogan = @$node['.attributes']['slogan'];
            $notice->visibility = $node['visibility'][0]['.value'];
            if (isset($node['starred'][0]['.value'])) {
                $notice->starred = $node['starred'][0]['.value'];
            } else {
                $notice->starred = 0;
            }
            $notice->title = $node['title'][0]['.value'];
            $notice->content = $node['content'][0]['.value'];
            $notice->contentformatter = isset($node['content'][0]['.attributes']['formatter']) ? $node['content'][0]['.attributes']['formatter'] : getDefaultFormatter();
            $notice->contenteditor = isset($node['content'][0]['.attributes']['editor']) ? $node['content'][0]['.attributes']['editor'] : getDefaultEditor();
            $notice->published = intval($node['published'][0]['.value']);
            $notice->created = @$node['created'][0]['.value'];
            $notice->modified = @$node['modified'][0]['.value'];
            if (floatval(Setting::getServiceSettingGlobal('newlineStyle')) >= 1.1 && floatval(@$node['.attributes']['format']) < 1.1) {
                $notice->content = nl2brWithHTML($notice->content);
            }
            if (!$notice->add()) {
                user_error(__LINE__ . $notice->error);
            }
            if (isset($node['attachment'])) {
                for ($i = 0; $i < count($node['attachment']); $i++) {
                    $attachment = new Attachment();
                    $attachment->parent = $notice->id;
                    $cursor =& $node['attachment'][$i];
                    $attachment->name = $cursor['name'][0]['.value'];
                    $attachment->label = $cursor['label'][0]['.value'];
                    $attachment->mime = @$cursor['.attributes']['mime'];
                    $attachment->size = $cursor['.attributes']['size'];
                    $attachment->width = $cursor['.attributes']['width'];
                    $attachment->height = $cursor['.attributes']['height'];
                    $attachment->enclosure = @$cursor['enclosure'][0]['.value'];
                    $attachment->attached = $cursor['attached'][0]['.value'];
                    $attachment->downloads = @$cursor['downloads'][0]['.value'];
                    if (Attachment::doesExist($attachment->name)) {
                        if (!$attachment->add()) {
                            user_error(__LINE__ . $attachment->error);
                        }
                        $notice2 = new Notice();
                        if ($notice2->open($notice->id, 'id, content')) {
                            $notice2->content = str_replace($cursor['name'][0]['.value'], $attachment->name, $notice2->content);
                            $notice2->update();
                            $notice2->close();
                        }
                        unset($notice2);
                    } else {
                        if (!$attachment->add()) {
                            user_error(__LINE__ . $attachment->error);
                        }
                    }
                    if (!empty($cursor['content'][0]['.stream'])) {
                        Utils_Base64Stream::decode($cursor['content'][0]['.stream'], Path::combine(ROOT, 'attach', $blogid, $attachment->name));
                        Attachment::adjustPermission(Path::combine(ROOT, 'attach', $blogid, $attachment->name));
                        fclose($cursor['content'][0]['.stream']);
                        unset($cursor['content'][0]['.stream']);
                    }
                }
            }
            return true;
        case '/blog/keyword':
            setProgress($item++ / $items * 100, _t('키워드를 복원하고 있습니다.'));
            $keyword = new Keyword();
            $keyword->id = $node['id'][0]['.value'];
            $keyword->visibility = $node['visibility'][0]['.value'];
            if (isset($node['starred'][0]['.value'])) {
                $keyword->starred = $node['starred'][0]['.value'];
            } else {
                $keyword->starred = 0;
            }
            $keyword->name = $node['name'][0]['.value'];
            $keyword->description = $node['description'][0]['.value'];
            $keyword->descriptionEditor = isset($node['description'][0]['.attributes']['editor']) ? $node['description'][0]['.attributes']['editor'] : getDefaultEditor();
            $keyword->descriptionFormatter = isset($node['description'][0]['.attributes']['formatter']) ? $node['description'][0]['.attributes']['formatter'] : getDefaultFormatter();
            $keyword->published = intval($node['published'][0]['.value']);
            $keyword->created = @$node['created'][0]['.value'];
            $keyword->modified = @$node['modified'][0]['.value'];
            if (floatval(Setting::getServiceSettingGlobal('newlineStyle')) >= 1.1 && floatval(@$node['.attributes']['format']) < 1.1) {
                $keyword->description = nl2brWithHTML($keyword->description);
            }
            if (!$keyword->add()) {
                user_error(__LINE__ . $keyword->error);
            }
            if (isset($node['attachment'])) {
                for ($i = 0; $i < count($node['attachment']); $i++) {
                    $attachment = new Attachment();
                    $attachment->parent = $keyword->id;
                    $cursor =& $node['attachment'][$i];
                    $attachment->name = $cursor['name'][0]['.value'];
                    $attachment->label = $cursor['label'][0]['.value'];
                    $attachment->mime = @$cursor['.attributes']['mime'];
                    $attachment->size = $cursor['.attributes']['size'];
                    $attachment->width = $cursor['.attributes']['width'];
                    $attachment->height = $cursor['.attributes']['height'];
                    $attachment->enclosure = @$cursor['enclosure'][0]['.value'];
                    $attachment->attached = $cursor['attached'][0]['.value'];
                    $attachment->downloads = @$cursor['downloads'][0]['.value'];
                    if (Attachment::doesExist($attachment->name)) {
                        if (!$attachment->add()) {
                            user_error(__LINE__ . $attachment->error);
                        }
                        $keyword2 = new Keyword();
                        if ($keyword2->open($keyword->id, 'id, content')) {
                            $keyword2->content = str_replace($cursor['name'][0]['.value'], $attachment->name, $keyword2->content);
                            $keyword2->update();
                            $keyword2->close();
                        }
                        unset($keyword2);
                    } else {
                        if (!$attachment->add()) {
                            user_error(__LINE__ . $attachment->error);
                        }
                    }
                    if (!empty($cursor['content'][0]['.stream'])) {
                        Utils_Base64Stream::decode($cursor['content'][0]['.stream'], Path::combine(ROOT, 'attach', $blogid, $attachment->name));
                        Attachment::adjustPermission(Path::combine(ROOT, 'attach', $blogid, $attachment->name));
                        fclose($cursor['content'][0]['.stream']);
                        unset($cursor['content'][0]['.stream']);
                    }
                }
            }
            return true;
        case '/blog/linkCategories':
            setProgress($item++ / $items * 100, _t('링크 카테고리를 복원하고 있습니다.'));
            $linkCategory = new LinkCategories();
            $linkCategory->name = $node['name'][0]['.value'];
            $linkCategory->priority = $node['priority'][0]['.value'];
            $linkCategory->visibility = !isset($node['visibility'][0]['.value']) || empty($node['visibility'][0]['.value']) ? 2 : $node['visibility'][0]['.value'];
            $linkCategory->id = LinkCategories::getId($linkCategory->name);
            if ($linkCategory->id) {
                if (!$linkCategory->update()) {
                    user_error(__LINE__ . $linkCategory->error);
                }
            } else {
                if (!$linkCategory->add()) {
                    user_error(__LINE__ . $linkCategory->error);
                }
            }
            return true;
        case '/blog/link':
            setProgress($item++ / $items * 100, _t('링크를 복원하고 있습니다.'));
            $link = new Link();
            $link->category = empty($node['category'][0]['.value']) ? 0 : $node['category'][0]['.value'];
            $link->url = $node['url'][0]['.value'];
            $link->title = $node['title'][0]['.value'];
            if (!empty($node['feed'][0]['.value'])) {
                $link->feed = $node['feed'][0]['.value'];
            }
            if (!empty($node['registered'][0]['.value'])) {
                $link->registered = $node['registered'][0]['.value'];
            }
            if (!empty($node['xfn'][0]['.value'])) {
                $link->xfn = $node['xfn'][0]['.value'];
            }
            $link->id = Link::getId($link->url);
            if ($link->id) {
                if (!$link->update()) {
                    user_error(__LINE__ . $link->error);
                }
            } else {
                if (!$link->add()) {
                    user_error(__LINE__ . $link->error);
                }
            }
            return true;
        case '/blog/logs/referer':
            setProgress($item++ / $items * 100, _t('리퍼러 로그를 복원하고 있습니다.'));
            $log = new RefererLog();
            if (isset($node['path'][0]['.value'])) {
                $log->url = $node['path'][0]['.value'];
            } else {
                $log->url = $node['url'][0]['.value'];
            }
            $log->referred = $node['referred'][0]['.value'];
            if (!$log->add(false)) {
                user_error(__LINE__ . $log->error);
            }
            return true;
        case '/blog/commentsNotified/comment':
            setProgress($item++ / $items * 100, _t('댓글 알리미 내용을 복원하고 있습니다.'));
            $cmtNotified = new CommentNotified();
            $cmtNotified->id = $node['id'][0]['.value'];
            $cursor =& $node['commenter'][0];
            $cmtNotified->name = $cursor['name'][0]['.value'];
            $cmtNotified->homepage = $cursor['homepage'][0]['.value'];
            $cmtNotified->ip = $cursor['ip'][0]['.value'];
            $cmtNotified->entry = $node['entry'][0]['.value'];
            $cmtNotified->password = $node['password'][0]['.value'];
            $cmtNotified->content = $node['content'][0]['.value'];
            $cmtNotified->parent = $node['parent'][0]['.value'];
            $cmtNotified->secret = $node['secret'][0]['.value'];
            $cmtNotified->written = $node['written'][0]['.value'];
            $cmtNotified->modified = $node['modified'][0]['.value'];
            $cmtNotified->url = $node['url'][0]['.value'];
            $cmtNotified->isnew = $node['isNew'][0]['.value'];
            $site = new CommentNotifiedSiteInfo();
            if (!$site->open("url = '{$node['site'][0]['.value']}'")) {
                $site->title = '';
                $site->name = '';
                $site->modified = 31536000;
                $site->url = $node['site'][0]['.value'];
                $site->add();
            }
            $cmtNotified->siteid = $site->id;
            $site->close();
            $cmtNotified->remoteid = $node['remoteId'][0]['.value'];
            $cmtNotified->entrytitle = !isset($node['entryTitle'][0]['.value']) || empty($node['entryTitle'][0]['.value']) ? 'No title' : $node['entryTitle'][0]['.value'];
            $cmtNotified->entryurl = $node['entryUrl'][0]['.value'];
            if (!$cmtNotified->add()) {
                user_error(__LINE__ . $cmtNotified->error);
            }
            return true;
        case '/blog/commentsNotifiedSiteInfo/site':
            setProgress($item++ / $items * 100, _t('댓글 알리미 내용을 복원하고 있습니다.'));
            $cmtNotifiedSite = new CommentNotifiedSiteInfo();
            if ($cmtNotifiedSite->open("url = '{$node['url'][0]['.value']}'")) {
                if (intval($node['modified'][0]['.value']) > intval($cmtNotifiedSite->modified)) {
                    $cmtNotifiedSite->title = $node['title'][0]['.value'];
                    $cmtNotifiedSite->name = $node['name'][0]['.value'];
                    $cmtNotifiedSite->modified = $node['modified'][0]['.value'];
                }
                if (!$cmtNotifiedSite->update()) {
                    user_error(__LINE__ . $cmtNotifiedSite->error);
                }
            } else {
                $cmtNotifiedSite->url = $node['url'][0]['.value'];
                $cmtNotifiedSite->title = $node['title'][0]['.value'];
                $cmtNotifiedSite->name = $node['name'][0]['.value'];
                $cmtNotifiedSite->modified = $node['modified'][0]['.value'];
                if (!$cmtNotifiedSite->add()) {
                    user_error(__LINE__ . $cmtNotifiedSite->error);
                }
            }
            return true;
        case '/blog/statistics/referer':
            setProgress($item++ / $items * 100, _t('리퍼러 통계를 복원하고 있습니다.'));
            $statistics = new RefererStatistics();
            $statistics->host = $node['host'][0]['.value'];
            $statistics->count = $node['count'][0]['.value'];
            if (!$statistics->add()) {
                user_error(__LINE__ . $statistics->error);
            }
            return true;
        case '/blog/statistics/visits':
            setProgress($item++ / $items * 100, _t('블로그 통계 정보를 복원하고 있습니다.'));
            $statistics = new BlogStatistics();
            $statistics->visits = $node['.value'];
            if (!$statistics->add()) {
                user_error(__LINE__ . $statistics->error);
            }
            return true;
        case '/blog/statistics/daily':
            setProgress($item++ / $items * 100, _t('일별 통계 정보를 복원하고 있습니다.'));
            $statistics = new DailyStatistics();
            $statistics->date = $node['date'][0]['.value'];
            $statistics->visits = $node['visits'][0]['.value'];
            if (!$statistics->add()) {
                user_error(__LINE__ . $statistics->error);
            }
            return true;
        case '/blog/skin':
            setProgress($item++ / $items * 100, _t('스킨 설정을 복원하고 있습니다.'));
            $setting = new SkinSetting();
            if (false) {
                $setting->skin = $node['name'][0]['.value'];
                if (!$setting->save()) {
                    user_error(__LINE__ . $setting->error);
                }
                $setting->skin = null;
            }
            $setting->entriesOnRecent = $node['entriesOnRecent'][0]['.value'];
            $setting->commentsOnRecent = $node['commentsOnRecent'][0]['.value'];
            $setting->trackbacksOnRecent = $node['trackbacksOnRecent'][0]['.value'];
            $setting->commentsOnGuestbook = $node['commentsOnGuestbook'][0]['.value'];
            $setting->tagsOnTagbox = $node['tagsOnTagbox'][0]['.value'];
            $setting->alignOnTagbox = $node['alignOnTagbox'][0]['.value'];
            $setting->expandComment = $node['expandComment'][0]['.value'];
            $setting->expandTrackback = $node['expandTrackback'][0]['.value'];
            if (!empty($node['recentNoticeLength'][0]['.value'])) {
                $setting->recentNoticeLength = $node['recentNoticeLength'][0]['.value'];
            }
            $setting->recentEntryLength = $node['recentEntryLength'][0]['.value'];
            $setting->recentTrackbackLength = $node['recentTrackbackLength'][0]['.value'];
            $setting->linkLength = $node['linkLength'][0]['.value'];
            $setting->showListOnCategory = $node['showListOnCategory'][0]['.value'];
            $setting->showListOnArchive = $node['showListOnArchive'][0]['.value'];
            if (isset($node['tree'])) {
                $cursor =& $node['tree'][0];
                $setting->tree = $cursor['name'][0]['.value'];
                $setting->colorOnTree = $cursor['color'][0]['.value'];
                $setting->bgcolorOnTree = $cursor['bgColor'][0]['.value'];
                $setting->activecolorOnTree = $cursor['activeColor'][0]['.value'];
                $setting->activebgcolorOnTree = $cursor['activeBgColor'][0]['.value'];
                $setting->labelLengthOnTree = $cursor['labelLength'][0]['.value'];
                $setting->showValueOnTree = $cursor['showValue'][0]['.value'];
            }
            if (!$setting->save()) {
                user_error(__LINE__ . $setting->error);
            }
            return true;
        case '/blog/plugin':
            //			setProgress($item++ / $items * 100, _t('플러그인 설정을 복원하고 있습니다.'));
            //			$setting = new PluginSetting();
            //			$setting->name = $node['name'][0]['.value'];
            //			$setting->setting = $node['setting'][0]['.value'];
            //			if (!$setting->add())
            //				user_error(__LINE__ . $setting->error);
            return true;
        case '/blog/personalization':
            //			setProgress($item++ / $items * 100, _t('사용자 편의 설정을 복원하고 있습니다.'));
            //			$setting = new UserSetting();
            //			$setting->name = 'rowsPerPage';
            //			$setting->value = $node['rowsPerPage'][0]['.value'];
            //			if (!$setting->add())
            //				user_error(__LINE__ . $setting->error);
            //			$setting->name = 'readerPannelVisibility';
            //			$setting->value = $node['readerPannelVisibility'][0]['.value'];
            //			if (!$setting->add())
            //				user_error(__LINE__ . $setting->error);
            //			$setting->name = 'readerPannelHeight';
            //			$setting->value = $node['readerPannelHeight'][0]['.value'];
            //			if (!$setting->add())
            //				user_error(__LINE__ . $setting->error);
            //			$setting->name = 'lastVisitNotifiedPage';
            //			$setting->value = $node['lastVisitNotifiedPage'][0]['.value'];
            //			if (!$setting->add())
            //				user_error(__LINE__ . $setting->error);
            return true;
        case '/blog/userSetting':
            //			setProgress($item++ / $items * 100, _t('사용자 편의 설정을 복원하고 있습니다'));
            //			$setting = new UserSetting();
            //			$setting->name = $node['name'][0]['.value'];
            //			$setting->value = $node['value'][0]['.value'];
            //			if (!$setting->add())
            //				user_error(__LINE__ . $setting->error);
            return true;
        case '/blog/guestbook/comment':
            setProgress($item++ / $items * 100, _t('방명록을 복원하고 있습니다.'));
            $comment = new GuestComment();
            $comment->name = $node['commenter'][0]['name'][0]['.value'];
            if (!empty($node['id'][0]['.value'])) {
                $comment->id = $node['id'][0]['.value'];
            }
            if (!empty($node['commenter'][0]['.attributes']['id'])) {
                $comment->commenter = $node['commenter'][0]['.attributes']['id'];
            }
            if (!empty($node['commenter'][0]['homepage'][0]['.value'])) {
                $comment->homepage = $node['commenter'][0]['homepage'][0]['.value'];
            }
            if (!empty($node['commenter'][0]['ip'][0]['.value'])) {
                $comment->ip = $node['commenter'][0]['ip'][0]['.value'];
            }
            if (!empty($node['commenter'][0]['openid'][0]['.value'])) {
                $comment->openid = $node['commenter'][0]['openid'][0]['.value'];
            }
            $comment->password = $node['password'][0]['.value'];
            $comment->secret = @$node['secret'][0]['.value'];
            $comment->written = $node['written'][0]['.value'];
            $comment->content = $node['content'][0]['.value'];
            if (!$comment->add()) {
                user_error(__LINE__ . $comment->error);
            }
            if (isset($node['comment'])) {
                for ($j = 0; $j < count($node['comment']); $j++) {
                    $childComment = new GuestComment();
                    $childComment->parent = $comment->id;
                    $cursor =& $node['comment'][$j];
                    $childComment->name = $cursor['commenter'][0]['name'][0]['.value'];
                    if (!empty($cursor['id'][0]['.value'])) {
                        $comment->id = $cursor['id'][0]['.value'];
                    }
                    if (!empty($cursor['commenter'][0]['.attributes']['id'])) {
                        $childComment->commenter = $cursor['commenter'][0]['.attributes']['id'];
                    }
                    if (!empty($cursor['commenter'][0]['homepage'][0]['.value'])) {
                        $childComment->homepage = $cursor['commenter'][0]['homepage'][0]['.value'];
                    }
                    if (!empty($cursor['commenter'][0]['ip'][0]['.value'])) {
                        $childComment->ip = $cursor['commenter'][0]['ip'][0]['.value'];
                    }
                    if (!empty($cursor['commenter'][0]['openid'][0]['.value'])) {
                        $childComment->openid = $cursor['commenter'][0]['openid'][0]['.value'];
                    }
                    $childComment->password = $cursor['password'][0]['.value'];
                    $childComment->secret = @$cursor['secret'][0]['.value'];
                    $childComment->written = $cursor['written'][0]['.value'];
                    $childComment->content = $cursor['content'][0]['.value'];
                    if (!$childComment->add()) {
                        user_error(__LINE__ . $childComment->error);
                    }
                }
            }
            return true;
        case '/blog/filter':
            setProgress($item++ / $items * 100, _t('필터 설정을 복원하고 있습니다.'));
            $filter = new Filter();
            $filter->type = $node['.attributes']['type'];
            $filter->pattern = $node['pattern'][0]['.value'];
            if (!$filter->add()) {
                user_error(__LINE__ . $filter->error);
            }
            return true;
        case '/blog/feed':
            setProgress($item++ / $items * 100, _t('리더 데이터를 복원하고 있습니다.'));
            $feed = new Feed();
            if (!empty($node['group'][0]['.value'])) {
                $feed->group = FeedGroup::getId($node['group'][0]['.value'], true);
            }
            $feed->url = $node['url'][0]['.value'];
            if (!$feed->add()) {
                user_error(__LINE__ . $feed->error);
            }
            return true;
        case '/blog/line':
            setProgress($item++ / $items * 100, _t('라인을 복원하고 있습니다.'));
            $line = Model_Line::getInstance();
            $line->reset();
            if (!empty($node['author'][0]['.value'])) {
                $line->author = $node['author'][0]['.value'];
            }
            if (!empty($node['category'][0]['.value'])) {
                $line->category = $node['category'][0]['.value'];
            }
            if (!empty($node['root'][0]['.value'])) {
                $line->root = $node['root'][0]['.value'];
            }
            if (!empty($node['permalink'][0]['.value'])) {
                $line->permalink = $node['permalink'][0]['.value'];
            }
            if (!empty($node['content'][0]['.value'])) {
                $line->content = $node['content'][0]['.value'];
            }
            if (!empty($node['created'][0]['.value'])) {
                $line->created = intval($node['created'][0]['.value']);
            }
            if ($line->add()) {
                return true;
            } else {
                user_error(__LINE__ . $line->_error);
            }
    }
}
     $validator->check('slug')->is_max(3, __('pages.slug_missing'))->is_duplicate(__('pages.slug_duplicate'))->not_regex('#^[0-9_-]+$#', __('pages.slug_invalid'));
     if ($input['redirect']) {
         $validator->check('redirect')->is_url(__('pages.redirect_missing'));
     }
     if ($errors = $validator->errors()) {
         Input::flash();
         Notify::error($errors);
         return Response::redirect('admin/pages/edit/' . $id);
     }
     if (empty($input['name'])) {
         $input['name'] = $input['title'];
     }
     // encode title
     $input['title'] = e($input['title'], ENT_COMPAT);
     $input['show_in_menu'] = is_null($input['show_in_menu']) ? 0 : 1;
     Page::update($id, $input);
     Extend::process('page', $id);
     Notify::success(__('pages.updated'));
     return Response::redirect('admin/pages/edit/' . $id);
 });
 /*
 	Add Page
 */
 Route::get('admin/pages/add', function () {
     $vars['messages'] = Notify::read();
     $vars['token'] = Csrf::token();
     $vars['pages'] = Page::dropdown(array('exclude' => array(), 'show_empty_option' => true));
     $vars['statuses'] = array('published' => __('global.published'), 'draft' => __('global.draft'), 'archived' => __('global.archived'));
     // extended fields
     $vars['fields'] = Extend::fields('page');
     return View::create('pages/add', $vars)->partial('header', 'partials/header')->partial('footer', 'partials/footer')->partial('editor', 'partials/editor');
Example #7
0
 static function register($id, $key = false, $value = "")
 {
     // stop if variable already available
     //if(array_key_exists("pages", $GLOBALS['db_schema']) && in_array($key, $GLOBALS['db_schema']['pages'])) return;
     $page = new Page();
     $columns = $GLOBALS['db_schema']['pages'];
     $dbh = $page->getdbh();
     // check if the pages table exists
     $sql = "SELECT name FROM sqlite_master WHERE type='table' and name='pages'";
     $results = $dbh->prepare($sql);
     $results->execute();
     $table = $results->fetch(PDO::FETCH_ASSOC);
     // then check if the table exists
     if (!is_array($table)) {
         $keys = implode(", ", $columns);
         // FIX: The id needs to be setup as autoincrement
         $keys = str_replace("id,", "id INTEGER PRIMARY KEY ASC,", $keys);
         $page->create_table("pages", $keys);
         //$page->create_table("pages", "id INTEGER PRIMARY KEY ASC, title, content, path, date, tags, template");
     }
     // add the column if necessary
     if (array_key_exists("pages", $GLOBALS['db_schema']) && is_array($columns) && !in_array($key, $columns)) {
         $sql = "ALTER TABLE pages ADD COLUMN " . $key;
         $results = $dbh->prepare($sql);
         if ($results) {
             $results->execute();
         }
         // there's a case where the column may already exist, in which case this will be false...
         array_push($columns, $key);
     }
     // get existing page (again?)
     $sql = "SELECT * FROM 'pages' WHERE id='{$id}'";
     $results = $dbh->prepare($sql);
     if ($results) {
         $results->execute();
         $pages = $results->fetch(PDO::FETCH_ASSOC);
     } else {
         $pages = false;
     }
     // just create the key
     if (!$pages) {
         $newpage = new Page();
         $newpage->set('id', "{$id}");
         if ($key) {
             $newpage->set("{$key}", "{$value}");
         }
         $newpage->create();
     } else {
         if ($key) {
             $mypage = new Page($id);
             $existing = $mypage->get("{$key}");
             // allow empty strings to be returned
             if (is_null($existing)) {
                 $mypage->set("{$key}", "{$value}");
                 $mypage->update();
             }
         }
     }
 }
Example #8
0
            $req = ob_get_contents();
            ob_end_clean();
            echo json_encode(array("success" => 0, "message" => urlencode($req)));
            exit;
        }
        // Check if parent exists
        $parent = null;
        if ($val['parent'] != -1) {
            foreach (Page::getList() as $page) {
                if ($page->getID() == $val['parent']) {
                    $parent = $page;
                    break;
                }
            }
            // Parent not found
            if ($parent == null) {
                $_GET['id'] = 7;
                ob_start();
                include 'pages/error.php';
                $req = ob_get_contents();
                ob_end_clean();
                echo json_encode(array("success" => 0, "message" => urlencode($req)));
                exit;
            }
        }
        // Create page
        $page = new Page(-1, $_SESSION['userdata']->getID(), $val['title'], $val['content'], $val['visibility'], new \DateTime(), $parent == null ? null : $parent->getID(), -1);
        $page->update();
        echo json_encode(array("success" => 1, "message" => $page->getID()));
        break;
}
 protected function createPageWithChanges($seed = null)
 {
     $page = new Page();
     $seed = array_merge(array('Title' => 'My Title', 'Content' => 'My Content'), $seed);
     $page->update($seed);
     $page->write();
     $page->publish('Stage', 'Live');
     $page->update(array('Title' => 'Changed: ' . $seed['Title'], 'Content' => 'Changed: ' . $seed['Content']));
     $page->write();
     $page->publish('Stage', 'Live');
     $page->update(array('Title' => 'Changed again: ' . $seed['Title'], 'Content' => 'Changed again: ' . $seed['Content']));
     $page->write();
     $page->publish('Stage', 'Live');
     $page->update(array('Title' => 'Unpublished: ' . $seed['Title'], 'Content' => 'Unpublished: ' . $seed['Content']));
     $page->write();
     return $page;
 }
Example #10
0
 function save($params = array())
 {
     // define/filter the data set
     $fields = array("id", "title", "content", "tags", "template");
     $data = array_fill_keys($fields, "");
     $data = array_merge($data, $params);
     // filter data...
     $page = new Page($data['id']);
     // trigger event
     Event::trigger('admin:save', $data);
     foreach ($data as $k => $v) {
         $page->set($k, $v);
     }
     if (array_key_exists("id", $params)) {
         // Update existing page
         $page->update();
     } else {
         // Create new page
         //$page->set('path', 		$data['path']);
         $page->create();
     }
     // Generate sitemap
     $sitemap = new Sitemap();
 }
    $objPage = new Page($this->objLanguage);
    $page = $objPage->getOne($id);
    if (!empty($page)) {
        $this->addScript('/admin/js/ckeditor/ckeditor.js');
        $this->addScript('/admin/js/ckeditor/adapters/jquery.js');
        $objForm = new Form($this->objUrl);
        $objValidation = new Validation($this->objLanguage);
        $expected = array('name', 'content', 'meta_title', 'meta_description', 'meta_keywords', 'identity');
        $required = array('name', 'content', 'meta_title', 'meta_description', 'meta_keywords', 'identity');
        if (isset($_POST['name'])) {
            $array = $objForm->post2Array($expected, 'content', array('identity' => 'sanitise'));
            if (array_key_exists('identity', $array) && !empty($array['identity']) && $objPage->duplicate($array['identity'], $id)) {
                $objValidation->add2Errors('identity', 'identity_taken');
            }
            if ($objValidation->isValid($array, $required)) {
                if ($objPage->update($array, $id)) {
                    Helper::redirect($this->objUrl->getCurrent(array('a', 'id')) . '/a/index');
                }
            }
        }
        require_once 'header.php';
        ?>

<h1><?php 
        echo $this->objLanguage->labels[20];
        ?>
</h1>

<form method="post">
	<table class="tbl_insert">
		<tr>
Example #12
0
    $layout = $database->escapeString($_POST['layout']);
    $page->setTitle($title);
    $page->setPageName($pageName);
    $page->setUrlTag($urlTag);
    $page->setMetaDesc($metaDesc);
    $page->setMetaKeywords($metaKeywords);
    $page->setPageLayoutId($layout);
    if ($submitPage == "Save") {
        $page->setVisibility(0);
    } else {
        if ($submitPage == "Save & Publish") {
            $page->setVisibility(1);
        }
    }
    if (isset($_POST['pageId'])) {
        $page->setPageId($database->escapeString($_POST['pageId']));
        if ($page->update($database)) {
            redirect("../pages.php?pages=1");
        } else {
            echo "<h2>Something is wrong go back and try again, or contact your administrator</h2>";
        }
    } else {
        if ($page->create($database)) {
            redirect("../pages.php?pages=1");
        } else {
            echo "<h2>Something is wrong go back and try again, or contact your administrator</h2>";
        }
    }
} else {
    echo "Something is wrong go back and try again!";
}
Example #13
0
 /**
  * Перестраивает иерархиую страниц из полученного через Ajax массива вида:
  *
  * @param array $items
  */
 private function rebuildPagesTree($items, $parent_id = 0)
 {
     $i = 0;
     foreach ($items as $item) {
         $page = new Page();
         $page->id = $item['id'];
         if ($page->find()) {
             $page->pid = $parent_id;
             $page->branching(++$i);
             $page->update();
             if (isset($item['children'])) {
                 $this->rebuildPagesTree($item['children'], $page->id);
             }
         }
     }
     return TRUE;
 }