public
Description: The ultra-lightweight ultra-flexible blogging engine with a fetish for birds and misspellings.
Homepage: http://chyrp.net/
Clone URL: git://github.com/vito/chyrp.git
Search Repo:
Click here to lend your support to: chyrp and make a donation at www.pledgie.com !
Fixed WP importer, and moved Chyrps to the Admin area.
vito (author)
Sat Jul 05 23:57:33 -0700 2008
commit  7219c543ce6b2d8049b485ab5f7c01feeb4f660f
tree    c0a6ffc71291ab09f027ab37b98396bab92e6a37
parent  3f237a21559f2c10e078b93e5837d501f2bf81f1
...
4
5
6
7
 
8
9
10
11
 
 
 
 
 
 
 
 
 
12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
14
15
...
4
5
6
 
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
0
@@ -4,12 +4,53 @@
0
 
0
 {% block content %}
0
       {% if success_wordpress %}
0
- <p class="message yay">${ "Wordpress content successfully imported!" | translate }</p>
0
+ <p class="message yay">${ "WordPress content successfully imported!" | translate }</p>
0
       {% endif %}
0
       {% if invalid_wordpress %}
0
       <p class="message boo">${ "File does not seem to be a valid WordPress export file." | translate }</p>
0
       {% endif %}
0
+ {% if success_chyrp %}
0
+ <p class="message yay">${ "Chyrp content successfully imported!" | translate }</p>
0
+ {% endif %}
0
+ {% if invalid_chyrp_posts %}
0
+ <p class="message boo">${ "Posts file does not seem to be a valid Chyrp export file." | translate }</p>
0
+ {% endif %}
0
+ {% if invalid_chyrp_pages %}
0
+ <p class="message boo">${ "Pages file does not seem to be a valid Chyrp export file." | translate }</p>
0
+ {% endif %}
0
       <h1>${ "Import" | translate }</h1>
0
+ <h2>${ "Chyrp" | translate }</h2>
0
+ <form id="import_chyrp_form" class="split" action="{% admin "import_chyrp" %}" method="post" accept-charset="utf-8" enctype="multipart/form-data">
0
+ <fieldset>
0
+ <p>
0
+ <label for="posts_file">${ "Posts .atom File" | translate }</label>
0
+ <input type="file" name="posts_file" value="" id="posts_file" />
0
+ </p>
0
+ <p>
0
+ <label for="pages_file">${ "Pages .atom File" | translate }</label>
0
+ <input type="file" name="pages_file" value="" id="pages_file" />
0
+ </p>
0
+ <p>
0
+ <label for="media_url">${ "What URL is used for embedded media?" | translate }</label>
0
+ <input class="text" type="text" name="media_url" value="$POST.media_url" id="media_url" />
0
+ <span class="sub">${ "(optional)" | translate }</span>
0
+ <small>
0
+ ${ "Usually something like <code>http://example.com/uploads/</code>" | translate }
0
+ </small>
0
+ </p>
0
+
0
+ ${ trigger.call("import_choose") }
0
+
0
+ <p class="buttons">
0
+ <button type="submit" class="yay"><img src="images/icons/success.png" alt="success" />${ "Import" | translate }</button>
0
+ </p>
0
+
0
+ <input type="hidden" name="hash" value="$site.secure_hashkey" id="hash" />
0
+ </fieldset>
0
+ </form>
0
+ <br />
0
+ <hr />
0
+ <br />
0
       <h2>${ "WordPress" | translate }</h2>
0
       <form id="import_wordpress_form" class="split" action="{% admin "import_wordpress" %}" method="post" accept-charset="utf-8" enctype="multipart/form-data">
0
         <fieldset>
...
62
63
64
65
 
66
67
...
62
63
64
 
65
66
67
0
@@ -62,6 +62,6 @@
0
     }
0
     public function set_feed_url($url, $post) {
0
       if ($post->feather != "link") return;
0
- return $post->source;
0
+ $url = $post->source;
0
     }
0
   }
...
694
695
696
697
 
698
699
700
...
771
772
773
774
 
775
776
777
...
805
806
807
 
808
809
 
810
811
812
...
822
823
824
825
 
 
 
 
 
826
827
828
829
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
830
831
832
833
834
 
835
836
837
838
839
 
840
841
842
...
694
695
696
 
697
698
699
700
...
771
772
773
 
774
775
776
777
...
805
806
807
808
809
 
810
811
812
813
...
823
824
825
 
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
 
900
901
902
903
0
@@ -694,7 +694,7 @@
0
           $posts_atom.= '    <id>tag:'.$tagged.'</id>'."\r";
0
           $posts_atom.= '    <updated>'.when("c", $updated).'</updated>'."\r";
0
           $posts_atom.= '    <published>'.when("c", $post->created_at).'</published>'."\r";
0
- $posts_atom.= ' <link href="'.fix($trigger->filter($url, "feed_url"), false).'" />'."\r";
0
+ $posts_atom.= ' <link href="'.fix($trigger->filter($url, "post_export_url", $post), false).'" />'."\r";
0
           $posts_atom.= '    <author chyrp:user_id="'.$post->user_id.'">'."\r";
0
           $posts_atom.= '      <name>'.fix(fallback($post->user()->full_name, $post->user()->login, true), false).'</name>'."\r";
0
 
0
@@ -771,7 +771,7 @@
0
           $pages_atom.= '    <id>tag:'.$tagged.'</id>'."\r";
0
           $pages_atom.= '    <updated>'.when("c", $updated).'</updated>'."\r";
0
           $pages_atom.= '    <published>'.when("c", $page->created_at).'</published>'."\r";
0
- $pages_atom.= ' <link href="'.fix($trigger->filter($url, "feed_url"), false).'" />'."\r";
0
+ $pages_atom.= ' <link href="'.fix($trigger->filter($url, "page_export_url", $page), false).'" />'."\r";
0
           $pages_atom.= '    <author chyrp:user_id="'.fix($page->user_id).'">'."\r";
0
           $pages_atom.= '      <name>'.fix(fallback($page->user()->full_name, $page->user()->login, true), false).'</name>'."\r";
0
 
0
@@ -805,8 +805,9 @@
0
 
0
       $zip_contents = $zip->file();
0
 
0
+ $filename = sanitize(camelize($config->name), false, true)."_Export_".now()->format("Y-m-d");
0
       header("Content-type: application/octet-stream");
0
- header("Content-Disposition: attachment; filename=\"".sanitize(camelize($config->name), false, true)."_Export_".now()->format("Y-m-d").".zip\"");
0
+ header("Content-Disposition: attachment; filename=\"".$filename.".zip\"");
0
       header("Content-length: ".strlen($zip_contents)."\n\n");
0
 
0
       echo $zip_contents;
0
@@ -822,21 +823,81 @@
0
       if (!Visitor::current()->group()->can("add_post"))
0
         show_403(__("Access Denied"), __("You do not have sufficient privileges to import content."));
0
 
0
- foreach (array("success_wordpress", "invalid_wordpress") as $message)
0
+ foreach (array("success_wordpress",
0
+ "invalid_wordpress",
0
+ "success_chyrp",
0
+ "invalid_chyrp_posts",
0
+ "invalid_chyrp_pages") as $message)
0
         $this->context[$message] = isset($_GET[$message]);
0
     }
0
 
0
     /**
0
+ * Function: import_chyrp
0
+ * Chyrp importing.
0
+ */
0
+ public function import_chyrp() {
0
+ $trigger = Trigger::current();
0
+
0
+ if (isset($_FILES['posts_file']) and $_FILES['posts_file']['error'] == 0) {
0
+ $posts = simplexml_load_file($_FILES['posts_file']['tmp_name']);
0
+
0
+ if (!$posts or $posts->generator != "Chyrp")
0
+ redirect("/admin/?action=import&invalid_chyrp_posts");
0
+ }
0
+
0
+ if (isset($_FILES['pages_file']) and $_FILES['pages_file']['error'] == 0) {
0
+ $pages = simplexml_load_string(file_get_contents($_FILES['pages_file']['tmp_name']));
0
+
0
+ if (!$pages or $pages->generator != "Chyrp")
0
+ redirect("/admin/?action=import&invalid_chyrp_pages");
0
+ }
0
+
0
+ if (isset($_FILES['posts_file']) and $_FILES['posts_file']['error'] == 0)
0
+ foreach ($posts->entry as $entry) {
0
+ $chyrp = $entry->children("http://chyrp.net/export/1.0/");
0
+
0
+ $_POST['feather'] = $chyrp->feather;
0
+ $_POST['status'] = $chyrp->status;
0
+ $_POST['pinned'] = (bool) (int) $chyrp->pinned;
0
+ $_POST['created_at'] = $chyrp->created_at;
0
+ $_POST['updated_at'] = $chyrp->updated_at;
0
+
0
+ $data = Post::xml2arr($entry->content->post);
0
+ $post = Post::add($data, $chyrp->clean, Post::check_url($chyrp->url));
0
+
0
+ $trigger->call("import_chyrp_post", $entry, $post);
0
+ }
0
+
0
+ if (isset($_FILES['pages_file']) and $_FILES['pages_file']['error'] == 0)
0
+ foreach ($pages->entry as $entry) {
0
+ $chyrp = $entry->children("http://chyrp.net/export/1.0/");
0
+ $attr = $entry->attributes("http://chyrp.net/export/1.0/");
0
+ $page = Page::add($entry->title,
0
+ $entry->content,
0
+ $attr->parent_id,
0
+ (bool) (int) $chyrp->show_in_list,
0
+ $chyrp->list_order,
0
+ $chyrp->clean,
0
+ Page::check_url($chyrp->url));
0
+
0
+ $trigger->call("import_chyrp_page", $entry, $page);
0
+ }
0
+
0
+ redirect("/admin/?action=import&success_chyrp");
0
+ }
0
+
0
+ /**
0
      * Function: import_wordpress
0
      * WordPress importing.
0
      */
0
     public function import_wordpress() {
0
       $trigger = Trigger::current();
0
+ $config = Config::current();
0
 
0
       if (empty($_POST))
0
         redirect("/admin/?action=import");
0
 
0
- if (!in_array("text", Config::current()->enabled_feathers))
0
+ if (!in_array("text", $config->enabled_feathers))
0
         error(__("Missing Feather"), __("Importing from WordPress requires the Text feather to be installed and enabled."));
0
 
0
       if (ini_get("memory_limit") < 20) # Some imports are relatively large.

Comments

    No one has commented yet.