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
Click here to lend your support to: chyrp and make a donation at www.pledgie.com !
* Added JS-aided tag selection when writing/editing posts in the admin. [#109 
state:resolved]
* Added an update_post_status_column upgrader function.
vito (author)
Sun Aug 17 15:14:31 -0700 2008
commit  c33efaf5af8bd283233a863567edc8ceabd3bd05
tree    5b4665428eb8bddb53428ecae97676b8409fa806
parent  1203fa4e51119f191077cfe378f5dce80f78faae
...
23
24
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
28
29
30
 
 
 
 
 
31
32
33
34
35
 
36
37
38
39
 
 
 
 
 
40
41
42
...
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
0
@@ -23,20 +23,96 @@
0
       Route::current()->remove("tag/(name)/");
0
     }
0
 
0
+    public function admin_head() {
0
+?>
0
+    <script type="text/javascript">
0
+      $(function(){
0
+        function scanTags(){
0
+          $(".tags_select a").each(function(){
0
+            regexp = new RegExp("(, ?|^)"+ $(this).text() +"(, ?|$)", "g")
0
+            if ($("#tags").val().match(regexp))
0
+              $(this).addClass("tag_added")
0
+            else
0
+              $(this).removeClass("tag_added")
0
+          })
0
+        }
0
+        scanTags()
0
+        $("#tags").livequery("keyup", scanTags)
0
+      })
0
+
0
+      function add_tag(name, link) {
0
+        if ($("#tags").val().match("(, |^)"+ name +"(, |$)")) {
0
+          regexp = new RegExp("(, |^)"+ name +"(, |$)", "g")
0
+          $("#tags").val($("#tags").val().replace(regexp, function(match, before, after){
0
+            if (before == ", " && after == ", ")
0
+              return ", "
0
+            else
0
+              return ""
0
+          }))
0
+
0
+          $(link).removeClass("tag_added")
0
+        } else {
0
+          if ($("#tags").val() == "")
0
+            $("#tags").val(name)
0
+          else
0
+            $("#tags").val($("#tags").val() + ", "+ name)
0
+
0
+          $(link).addClass("tag_added")
0
+        }
0
+      }
0
+    </script>
0
+    <style type="text/css" media="screen">
0
+      .tags_select {
0
+        display: inline-block;
0
+        margin-top: .5em;
0
+      }
0
+      .tags_select a {
0
+        padding: .1em .4em;
0
+        border: .1em solid #DDDDA8;
0
+        background: #FFFFCA;
0
+        text-decoration: none;
0
+        border-top-width: 0;
0
+        border-left-width: 0;
0
+        color: #555;
0
+      }
0
+      .tags_select a.tag_added {
0
+        background: #eee;
0
+        border-top-width: .1em;
0
+        border-bottom: 0;
0
+        border-left-width: .1em;
0
+        border-right: 0;
0
+        border-color: #ddd;
0
+      }
0
+    </style>
0
+<?php
0
+    }
0
+
0
     public function new_post_options() {
0
+      $tags = self::list_tags();
0
 ?>
0
           <p>
0
             <label for="tags"><?php echo __("Tags", "tags"); ?> <span class="sub"><?php echo __("(comma separated)", "tags"); ?></span></label>
0
             <input class="text" type="text" name="tags" value="" id="tags" />
0
+            <span class="tags_select">
0
+<?php foreach ($tags as $tag): ?>
0
+              <a href="javascript:add_tag('<?php echo addslashes($tag["name"]); ?>', '.tag_<?php echo addslashes($tag["url"]); ?>')" class="tag_<?php echo $tag["url"]; ?>"><?php echo $tag["name"]; ?></a>
0
+<?php endforeach; ?>
0
+            </span>
0
           </p>
0
 <?php
0
     }
0
 
0
     public function edit_post_options($post) {
0
+      $tags = self::list_tags();
0
 ?>
0
           <p>
0
             <label for="tags"><?php echo __("Tags", "tags"); ?> <span class="sub"><?php echo __("(comma separated)", "tags"); ?></span></label>
0
             <input class="text" type="text" name="tags" value="<?php echo implode(", ", self::unlinked_tags($post->unclean_tags)) ?>" id="tags" />
0
+            <span class="tags_select">
0
+<?php foreach ($tags as $tag): ?>
0
+              <a href="javascript:add_tag('<?php echo addslashes($tag["name"]); ?>', '.tag_<?php echo addslashes($tag["url"]); ?>')" class="tag_<?php echo $tag["url"]; ?>"><?php echo $tag["name"]; ?></a>
0
+<?php endforeach; ?>
0
+            </span>
0
           </p>
0
 <?php
0
     }
...
514
515
516
 
 
 
 
 
 
 
 
 
 
 
 
 
 
517
518
519
...
673
674
675
 
 
676
677
678
...
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
...
687
688
689
690
691
692
693
694
0
@@ -514,6 +514,20 @@
0
     Config::set("sql", Config::get("database"));
0
     Config::remove("database");
0
   }
0
+
0
+  function update_post_status_column() {
0
+    $sql = SQL::current();
0
+    $column = $sql->query("SHOW COLUMNS FROM __posts WHERE Field = 'status'");
0
+    if (!$column)
0
+         return;
0
+
0
+    $result = $column->fetchObject();
0
+    if ($result->Type == "varchar(32)")
0
+      return;
0
+
0
+    echo __("Updating `status` column on `posts` table...")
0
+         .test($sql->query("ALTER TABLE __posts CHANGE status status VARCHAR(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'public'"));
0
+  }
0
 ?>
0
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
0
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
0
@@ -673,6 +687,8 @@
0
 
0
     rename_database_config();
0
 
0
+    update_post_status_column();
0
+
0
     foreach ((array) Config::get("enabled_modules") as $module)
0
       if (file_exists(MAIN_DIR."/modules/".$module."/upgrades.php")) {
0
         echo _f("Calling \"%s\" module's upgrader...", array($module))."\n";

Comments