Changeset 11871
- Timestamp:
- 08/30/07 15:35:49 (1 year ago)
- Files:
-
- trunk/midcom/org.routamc.gallery/config/manifest.inc (modified) (1 diff)
- trunk/midcom/org.routamc.gallery/config/schemadb_config.inc (modified) (2 diffs)
- trunk/midcom/org.routamc.gallery/navigation.php (modified) (1 diff)
- trunk/midcom/org.routamc.gallery/organizer.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/midcom/org.routamc.gallery/config/manifest.inc
r11649 r11871 1 1 'name' => 'org.routamc.gallery', 2 2 'purecode' => false, 3 'version' => '1.1.0beta 3',3 'version' => '1.1.0beta2', 4 4 'state' => 'beta', 5 5 'privileges' => array (), trunk/midcom/org.routamc.gallery/config/schemadb_config.inc
r11646 r11871 28 28 ), 29 29 'widget' => 'select', 30 'start_fieldgroup' => array 31 ( 32 'title' => 'groovy', 33 ), 30 34 ), 31 35 'handpicked_photos' => array … … 63 67 ), 64 68 ), 69 'end_fieldgroup' => '', 65 70 ), 66 71 'photos_per_page' => array trunk/midcom/org.routamc.gallery/navigation.php
r5989 r11871 61 61 foreach ($organizer->get_sorted() as $link_id => $photo) 62 62 { 63 if (version_compare(mgd_version(), '1.8.0', '>='))64 {65 $creator = $photo->metadata->creator;66 $revisor = $photo->metadata->revisor;67 $created = $photo->metadata->created;68 $revised = $photo->metadata->revised;69 }70 else71 {72 $creator = $photo->creator;73 $revisor = $photo->revisor;74 $created = $photo->created;75 $revised = $photo->revised;76 }77 78 63 $leaves[$link_id] = array 79 64 ( 80 MIDCOM_NAV_SITE => Array 81 ( 82 MIDCOM_NAV_URL => "photo/{$photo->guid}.html", 83 MIDCOM_NAV_NAME => $photo->title 84 ), 65 MIDCOM_NAV_URL => "photo/{$photo->guid}.html", 66 MIDCOM_NAV_NAME => $photo->title, 85 67 MIDCOM_NAV_ADMIN => null, 86 68 MIDCOM_NAV_GUID => $photo->guid, 87 69 MIDCOM_NAV_OBJECT => $photo, 88 MIDCOM_META_CREATOR => $creator,89 MIDCOM_META_EDITOR => $revisor,90 MIDCOM_META_CREATED => $created,91 MIDCOM_META_EDITED => $revised,92 70 ); 93 71 trunk/midcom/org.routamc.gallery/organizer.php
r11646 r11871 32 32 33 33 /** 34 * Should post processing be done to photo links (pre Midgard 1.8.2)35 *36 * @access private37 */38 var $_post_processing = true;39 40 /**41 * Should legacy support be enabled (i.e. pre Midgard 1.8.2)42 *43 * @access private44 * @var boolean $_legacy45 */46 var $_legacy = true;47 48 /**49 34 * Limit the request to a certain number 50 35 * … … 77 62 function org_routamc_gallery_organizer($sort_string = null) 78 63 { 79 if (version_compare(mgd_version(), '1.8.2', '>='))80 {81 $this->_legacy = false;82 $this->_post_processing = false;83 }84 85 64 if ($sort_string) 86 65 { … … 106 85 function sort_by($string) 107 86 { 108 debug_push_class(__CLASS__, __FUNCTION__);109 110 87 if (trim($string) === '') 111 88 { 112 debug_add('No sorting string set, using default');113 debug_pop();114 115 89 return true; 116 90 } … … 136 110 $domain = $regs[0]; 137 111 $string = $regs[1]; 138 $post_processing = true;139 112 } 140 113 … … 142 115 { 143 116 case 'score': 144 if ($this->_legacy) 145 { 146 $sort = 'score'; 147 $post_processing = false; 148 } 149 else 150 { 151 $sort = 'metadata.score'; 152 } 117 $sort = 'metadata.score'; 153 118 154 119 break; 155 120 156 121 default: 157 if ($this->_legacy) 158 { 159 $sort = $string; 160 } 161 else 162 { 163 $sort = strtolower("{$domain}{$string}"); 164 } 122 $sort = strtolower("{$domain}{$string}"); 165 123 } 166 124 167 125 $this->sort = $sort; 168 126 169 debug_add("Sorting will be done according to property '{$this->sort}'");170 171 if (isset($post_processing))172 {173 debug_add('Pre Midgard 1.8.2 post processing is required');174 $this->_post_processing = $post_processing;175 }176 177 debug_pop();178 127 return true; 179 128 } … … 188 137 { 189 138 // Initialize the query builder 190 $qb = org_routamc_gallery_photolink_dba::new_query_builder(); 191 $qb->add_constraint('node', '=', $this->node); 139 $mc = org_routamc_gallery_photolink_dba::new_collector('node', $this->node); 140 $mc->add_value_property('id'); 141 $mc->add_value_property('node'); 142 $mc->add_value_property('photo'); 143 144 $mc->add_constraint('censored', '=', 0); 145 $mc->add_order($this->sort); 192 146 193 147 // Set the offset 194 148 $offset = $this->limit * $this->page; 195 149 196 // Shorten the variable name 197 $sort = $this->sort; 150 // Set limit 151 if ($this->limit) 152 { 153 $mc->set_limit($this->limit); 154 } 155 156 // Add offset 157 if ($this->page) 158 { 159 $mc->add_offset($offset); 160 } 161 162 // Execute the collector 163 $mc->execute(); 164 165 $links = $mc->list_keys(); 198 166 199 167 // Initialize results set 200 168 $results = array (); 201 169 202 // No post processing required, get the results straight 203 if (!$this->_post_processing) 170 foreach ($links as $guid => $array) 204 171 { 205 $qb->add_order($this->sort); 206 207 // Set limit 208 if ($this->limit) 209 { 210 $qb->set_limit($this->limit); 211 } 212 213 // Add offset 214 if ($this->page) 215 { 216 $qb->add_offset($offset); 217 } 218 219 // Get the results 220 $results = array(); 221 222 foreach ($qb->execute() as $link) 223 { 224 $photo[$link->id] = new org_routamc_photostream_photo_dba($link->photo); 225 226 if (@$photo->censored) 227 { 228 continue; 229 } 230 231 $results[$link->id] =& $photo[$link->id]; 232 } 233 234 // Return reversed results 235 if ($this->reverse) 236 { 237 return array_reverse($results, true); 238 } 239 240 return $results; 172 $results[$mc->get_subkey($guid, 'id')] = new org_routamc_photostream_photo_dba($mc->get_subkey($guid, 'photo')); 241 173 } 242 else 174 175 // Return reversed results 176 if ($this->reverse) 243 177 { 244 $links = array (); 245 $photos = array (); 246 247 foreach ($qb->execute() as $link) 248 { 249 $photo = new org_routamc_photostream_photo_dba($link->photo); 250 251 if (@$photo->censored) 252 { 253 continue; 254 } 255 256 // QUICKFIX: the sort is specified in QB format, but of course it's not a valid property name 257 if (strpos($sort, '.') !== false) 258 { 259 list ($prop1, $prop2) = explode('.', $sort, 2); 260 $links[$link->id] = $photo->$prop1->$prop2; 261 } 262 else 263 { 264 $links[$link->id] = $photo->$sort; 265 } 266 $photos[$link->id] = $photo; 267 } 268 269 // Sort the links 270 if ($this->reverse) 271 { 272 arsort($links); 273 } 274 else 275 { 276 asort($links); 277 } 278 279 // Set limit 280 if ($this->limit) 281 { 282 $limit = $this->limit; 283 } 284 else 285 { 286 $limit = count($links); 287 } 288 289 $i = 0; 290 291 foreach ($links as $link_id => $value) 292 { 293 // Skip due to paging 294 if ($i < $offset) 295 { 296 continue; 297 } 298 299 // Break due to paging 300 if ($i > $offset + $limit) 301 { 302 break; 303 } 304 305 $results[$link_id] =& $photos[$link_id]; 306 } 178 return array_reverse($results, true); 307 179 } 308 180
