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 !
* Greatly increased model has_many/belongs_to flexibility.
* Updated the README.
* Fixed a logic error in Trigger calls.
* For a trigger call to override a Controller's call, they should return
  "override".
* If $id is not set in a model grab but it's in the "where" option,
  that'll be used so we can keep the caching.
vito (author)
Thu Nov 20 19:35:51 -0800 2008
commit  fc6d342a56651dae8a93077187963df9f57361fc
tree    19af6b3cb233353dabb0515c097e881e5a05825f
parent  ad0af46a4d2b7b5ec8a63f3ac2962de14b6a0339
...
36
37
38
 
 
39
40
41
...
92
93
94
95
96
 
...
36
37
38
39
40
41
42
43
...
94
95
96
 
97
98
0
@@ -36,6 +36,8 @@ Keeping Chyrp up to date is important to make sure that your blog is as safe and
0
 4. Overwrite your current Chyrp installation files with the new ones.
0
 5. Restore your config files<sup>1</sup> back to /includes/.
0
 6. Upgrade by navigating to [upgrade.php](), and restore any backups.
0
+7. Re-enable your Modules/Feathers.
0
+8. Run the upgrader again. It will run the Module/Feather upgrade tasks.
0
 
0
 <sup>1</sup> The config files vary depending on what you're upgrading from. Any of these in are considered "config files":
0
 
0
@@ -92,4 +94,4 @@ Chyrp is multilingual! If your first language isn't English, you can apply a new
0
 1. Download and unzip the localization.
0
 1. Upload the `.mo` file to the `includes/locale/` folder. You don't need anything else for the translation to work.
0
 1. Open your web browser and navigate to your Chyrp administration panel.
0
-1. Click on the *Settings* tab, and change the *Language* option to the language you just uploaded.
0
\ No newline at end of file
0
+1. Click on the *Settings* tab, and change the *Language* option to the language you just uploaded.
...
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
...
109
110
111
 
 
 
112
113
114
...
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
...
123
124
125
126
127
128
129
130
131
0
@@ -31,35 +31,49 @@
0
          *     @mixed@
0
          */
0
         public function __get($name) {
0
-            if (isset($this->$name))
0
-                return $this->$name;
0
-            else {
0
-                $model_name = get_class($this);
0
-                $placeholders = (isset($this->__placeholders) and $this->__placeholders);
0
-
0
-                Trigger::current()->filter($filtered, $model_name."_".$name."_attr", $this);
0
-                if ($filtered !== false)
0
-                    $this->$name = $filtered;
0
-
0
-                $this->belongs_to = (array) $this->belongs_to;
0
-                $this->has_many   = (array) $this->has_many;
0
-                $this->has_one    = (array) $this->has_one;
0
-                if (in_array($name, $this->belongs_to) or isset($this->belongs_to[$name])) {
0
-                    $class = (isset($this->belongs_to[$name])) ? $this->belongs_to[$name] : $name ;
0
-                    return $this->$name = new $class($this->{$name."_id"});
0
-                } elseif (in_array($name, $this->has_many) or isset($this->has_many[$name])) {
0
-                    if (isset($this->has_many[$name]))
0
-                        list($class, $by) = $this->has_many[$name];
0
-                    else
0
-                        list($class, $by) = array(depluralize($name), $model_name);
0
-
0
-                    return $this->$name = call_user_func(array($class, "find"),
0
-                                                         array("where" => array(strtolower($by)."_id" => $this->id),
0
-                                                               "placeholders" => $placeholders));
0
-                } elseif (in_array($name, $this->has_one)) {
0
-                    $class = depluralize($name);
0
-                    return $this->$name = new $class(null, array("where" => array(strtolower($model_name)."_id" => $this->id)));
0
+            $model_name = get_class($this);
0
+            $placeholders = (isset($this->__placeholders) and $this->__placeholders);
0
+
0
+            Trigger::current()->filter($filtered, $model_name."_".$name."_attr", $this);
0
+            if ($filtered !== false)
0
+                $this->$name = $filtered;
0
+
0
+            $this->belongs_to = (array) $this->belongs_to;
0
+            $this->has_many   = (array) $this->has_many;
0
+            $this->has_one    = (array) $this->has_one;
0
+            if (in_array($name, $this->belongs_to) or isset($this->belongs_to[$name])) {
0
+                $class = (isset($this->belongs_to[$name])) ? $this->belongs_to[$name] : $name ;
0
+                if (isset($this->belongs_to[$name])) {
0
+                    $opts =& $this->belongs_to[$name];
0
+                    $model = oneof(@$opts["model"], $name);
0
+                    $match = oneof(@$opts["by"], strtolower($name));
0
+                    $where = array_merge(array("id" => $this->{$match."_id"}),
0
+                                         (array) @$opts["where"]);
0
+                } else {
0
+                    $model = $name;
0
+                    $where = array("id" => $this->{$name."_id"});
0
+                }
0
+
0
+                return $this->$name = new $model(null, array("where" => $where));
0
+            } elseif (in_array($name, $this->has_many) or isset($this->has_many[$name])) {
0
+                if (isset($this->has_many[$name])) {
0
+                    $opts =& $this->has_many[$name];
0
+                    $model = oneof($opts["model"], $name);
0
+                    $match = oneof(@$opts["by"], strtolower($name));
0
+                    $where = array_merge(array($match."_id" => $this->id),
0
+                                         (array) @$opts["where"]);
0
+                } else {
0
+                    $model = depluralize($name);
0
+                    $match = $model_name;
0
+                    $where = array(strtolower($match)."_id" => $this->id);
0
                 }
0
+
0
+                return $this->$name = call_user_func(array($model, "find"),
0
+                                                     array("where" => $where,
0
+                                                           "placeholders" => $placeholders));
0
+            } elseif (in_array($name, $this->has_one)) {
0
+                $class = depluralize($name);
0
+                return $this->$name = new $class(null, array("where" => array(strtolower($model_name)."_id" => $this->id)));
0
             }
0
         }
0
 
0
@@ -109,6 +123,9 @@
0
             if ($model_name == "visitor")
0
                 $model_name = "user";
0
 
0
+            if (!isset($id) and isset($options["where"]["id"]))
0
+                $id = $options["where"]["id"];
0
+
0
             $cache = (is_numeric($id) and isset(self::$caches[$model_name][$id])) ? 
0
                          self::$caches[$model_name][$id] :
0
                          ((isset($options["read_from"]["id"]) and isset(self::$caches[$model_name][$options["read_from"]["id"]])) ?
...
95
96
97
98
 
99
100
101
...
95
96
97
 
98
99
100
101
0
@@ -95,7 +95,7 @@
0
                 else
0
                     $call = false;
0
 
0
-                if ($call === false and method_exists($this->controller, $method))
0
+                if ($call != "override" and method_exists($this->controller, $method))
0
                     $response = call_user_func_array(array($this->controller, $method), $args);
0
                 else
0
                     $response = false;
...
40
41
42
43
 
44
45
46
...
52
53
54
55
 
56
57
58
...
40
41
42
 
43
44
45
46
...
52
53
54
 
55
56
57
58
0
@@ -40,7 +40,7 @@
0
                     $args = func_get_args();
0
                     $args[0] = $call;
0
                     if ($index + 1 == count($name))
0
-                        return $return == $this->exists($call) ? call_user_func_array(array($this, "call"), $args) : $return ;
0
+                        return $this->exists($call) ? call_user_func_array(array($this, "call"), $args) : $return ;
0
                     else
0
                         $return = $this->exists($call) ? call_user_func_array(array($this, "call"), $args) : $return ;
0
                 }
0
@@ -52,7 +52,7 @@
0
             $arguments = func_get_args();
0
             array_shift($arguments);
0
 
0
-            $return = false;
0
+            $return = null;
0
 
0
             $this->called[$name] = array();
0
             if (isset($this->priorities[$name])) { # Predefined priorities?
...
9
10
11
12
 
13
14
15
...
9
10
11
 
12
13
14
15
0
@@ -9,7 +9,7 @@
0
     class Page extends Model {
0
         public $belongs_to = array("user", "parent" => array("model" => "page"));
0
 
0
-        public $has_many = array("children" => array("page", "parent"));
0
+        public $has_many = array("children" => array("model" => "page", "by" => "parent"));
0
 
0
         /**
0
          * Function: __construct
...
626
627
628
629
 
630
631
632
...
645
646
647
648
 
649
650
651
...
626
627
628
 
629
630
631
632
...
645
646
647
 
648
649
650
651
0
@@ -626,7 +626,7 @@
0
                                              array("COUNT(post_id) AS total", "post_id"),
0
                                              null,
0
                                              null,
0
-                                             null,
0
+                                             array(),
0
                                              null,
0
                                              null,
0
                                              "post_id");
0
@@ -645,7 +645,7 @@
0
                                             array("MAX(created_at) AS latest", "post_id"),
0
                                             null,
0
                                             null,
0
-                                            null,
0
+                                            array(),
0
                                             null,
0
                                             null,
0
                                             "post_id");

Comments