Changeset 2566:9bf417837888 for admin/services.php
- Timestamp:
- 11/17/13 20:25:53 (12 years ago)
- Branch:
- 2.6
- Children:
- 2567:6c11245cbf04, 2568:61c67a7d17fa
- File:
-
- 1 edited
-
admin/services.php (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
admin/services.php
r2227 r2566 39 39 throw new Exception('No post ID'); 40 40 } 41 41 42 42 $params = array('post_id' => (integer) $get['id']); 43 43 44 44 if (isset($get['post_type'])) { 45 45 $params['post_type'] = $get['post_type']; 46 46 } 47 47 48 48 $rs = $core->blog->getPosts($params); 49 49 50 50 if ($rs->isEmpty()) { 51 51 throw new Exception('No post for this ID'); 52 52 } 53 53 54 54 $rsp = new xmlTag('post'); 55 55 $rsp->id = $rs->post_id; 56 56 57 57 $rsp->blog_id($rs->blog_id); 58 58 $rsp->user_id($rs->user_id); … … 83 83 $rsp->cat_title($rs->cat_title); 84 84 $rsp->cat_url($rs->cat_url); 85 85 86 86 $rsp->post_display_content($rs->getContent(true)); 87 87 $rsp->post_display_excerpt($rs->getExcerpt(true)); 88 88 89 89 $metaTag = new xmlTag('meta'); 90 90 if (($meta = @unserialize($rs->post_meta)) !== false) … … 98 98 } 99 99 $rsp->post_meta($metaTag); 100 101 return $rsp; 102 } 103 100 101 return $rsp; 102 } 103 104 104 public static function getCommentById($core,$get) 105 105 { … … 107 107 throw new Exception('No comment ID'); 108 108 } 109 109 110 110 $rs = $core->blog->getComments(array('comment_id' => (integer) $get['id'])); 111 111 112 112 if ($rs->isEmpty()) { 113 113 throw new Exception('No comment for this ID'); 114 114 } 115 115 116 116 $rsp = new xmlTag('post'); 117 117 $rsp->id = $rs->comment_id; 118 118 119 119 $rsp->comment_dt($rs->comment_dt); 120 120 $rsp->comment_upddt($rs->comment_upddt); … … 129 129 $rsp->post_dt($rs->post_dt); 130 130 $rsp->user_id($rs->user_id); 131 131 132 132 $rsp->comment_display_content($rs->getContent(true)); 133 133 134 134 if ($core->auth->userID()) { 135 135 $rsp->comment_ip($rs->comment_ip); … … 137 137 $rsp->comment_spam_disp(dcAntispam::statusMessage($rs)); 138 138 } 139 140 return $rsp; 141 } 142 139 140 return $rsp; 141 } 142 143 143 public static function quickPost($core,$get,$post) 144 144 { 145 145 # Create category 146 146 if (!empty($post['new_cat_title']) && $core->auth->check('categories', $core->blog->id)) { 147 147 148 148 $cur_cat = $core->con->openCursor($core->prefix.'category'); 149 149 $cur_cat->cat_title = $post['new_cat_title']; 150 150 $cur_cat->cat_url = ''; 151 151 152 152 $parent_cat = !empty($post['new_cat_parent']) ? $post['new_cat_parent'] : ''; 153 153 154 154 # --BEHAVIOR-- adminBeforeCategoryCreate 155 155 $core->callBehavior('adminBeforeCategoryCreate', $cur_cat); 156 156 157 157 $post['cat_id'] = $core->blog->addCategory($cur_cat, (integer) $parent_cat); 158 158 159 159 # --BEHAVIOR-- adminAfterCategoryCreate 160 160 $core->callBehavior('adminAfterCategoryCreate', $cur_cat, $post['cat_id']); 161 161 } 162 162 163 163 $cur = $core->con->openCursor($core->prefix.'post'); 164 164 165 165 $cur->post_title = !empty($post['post_title']) ? $post['post_title'] : ''; 166 166 $cur->user_id = $core->auth->userID(); … … 172 172 $cur->post_open_comment = (integer) $core->blog->settings->system->allow_comments; 173 173 $cur->post_open_tb = (integer) $core->blog->settings->system->allow_trackbacks; 174 174 175 175 # --BEHAVIOR-- adminBeforePostCreate 176 176 $core->callBehavior('adminBeforePostCreate',$cur); 177 177 178 178 $return_id = $core->blog->addPost($cur); 179 179 180 180 # --BEHAVIOR-- adminAfterPostCreate 181 181 $core->callBehavior('adminAfterPostCreate',$cur,$return_id); 182 182 183 183 $rsp = new xmlTag('post'); 184 184 $rsp->id = $return_id; 185 185 186 186 $post = $core->blog->getPosts(array('post_id' => $return_id)); 187 187 188 188 $rsp->post_status = $post->post_status; 189 189 $rsp->post_url = $post->getURL(); 190 190 return $rsp; 191 191 } 192 192 193 193 public static function validatePostMarkup($core,$get,$post) 194 194 { … … 196 196 throw new Exception('No entry excerpt'); 197 197 } 198 198 199 199 if (!isset($post['content'])) { 200 200 throw new Exception('No entry content'); 201 201 } 202 202 203 203 if (empty($post['format'])) { 204 204 throw new Exception('No entry format'); 205 205 } 206 206 207 207 if (!isset($post['lang'])) { 208 208 throw new Exception('No entry lang'); 209 209 } 210 210 211 211 $excerpt = $post['excerpt']; 212 212 $excerpt_xhtml = ''; … … 215 215 $format = $post['format']; 216 216 $lang = $post['lang']; 217 217 218 218 $core->blog->setPostContent(0,$format,$lang,$excerpt,$excerpt_xhtml,$content,$content_xhtml); 219 219 220 220 $rsp = new xmlTag('result'); 221 221 222 222 $v = htmlValidator::validate($excerpt_xhtml.$content_xhtml); 223 223 224 224 $rsp->valid($v['valid']); 225 225 $rsp->errors($v['errors']); 226 227 return $rsp; 228 } 229 226 227 return $rsp; 228 } 229 230 230 public static function getZipMediaContent($core,$get,$post) 231 231 { … … 233 233 throw new Exception('No media ID'); 234 234 } 235 235 236 236 $id = (integer) $get['id']; 237 237 238 238 if (!$core->auth->check('media,media_admin',$core->blog)) { 239 239 throw new Exception('Permission denied'); 240 240 } 241 241 242 242 try { 243 243 $core->media = new dcMedia($core); 244 244 $file = $core->media->getFile($id); 245 245 } catch (Exception $e) {} 246 246 247 247 if ($file === null || $file->type != 'application/zip' || !$file->editable) { 248 248 throw new Exception('Not a valid file'); 249 249 } 250 250 251 251 $rsp = new xmlTag('result'); 252 252 $content = $core->media->getZipContent($file); 253 253 254 254 foreach ($content as $k => $v) { 255 255 $rsp->file($k); 256 256 } 257 258 return $rsp; 259 } 260 257 258 return $rsp; 259 } 260 261 261 public static function getMeta($core,$get) 262 262 { … … 265 265 $metaId = !empty($get['metaId']) ? $get['metaId'] : null; 266 266 $metaType = !empty($get['metaType']) ? $get['metaType'] : null; 267 267 268 268 $sortby = !empty($get['sortby']) ? $get['sortby'] : 'meta_type,asc'; 269 269 270 270 $rs = $core->meta->getMetadata(array( 271 271 'meta_type' => $metaType, … … 274 274 'post_id' => $postid)); 275 275 $rs = $core->meta->computeMetaStats($rs); 276 276 277 277 $sortby = explode(',',$sortby); 278 278 $sort = $sortby[0]; 279 279 $order = isset($sortby[1]) ? $sortby[1] : 'asc'; 280 280 281 281 switch ($sort) { 282 282 case 'metaId': … … 292 292 $sort = 'meta_type'; 293 293 } 294 294 295 295 $rs->sort($sort,$order); 296 296 297 297 $rsp = new xmlTag(); 298 298 299 299 while ($rs->fetch()) 300 300 { … … 306 306 $metaTag->roundpercent = $rs->roundpercent; 307 307 $metaTag->CDATA($rs->meta_id); 308 308 309 309 $rsp->insertNode($metaTag); 310 310 } 311 312 return $rsp; 313 } 314 311 312 return $rsp; 313 } 314 315 315 public static function setPostMeta($core,$get,$post) 316 316 { … … 318 318 throw new Exception('No post ID'); 319 319 } 320 320 321 321 if (empty($post['meta']) && $post['meta'] != '0') { 322 322 throw new Exception('No meta'); 323 323 } 324 324 325 325 if (empty($post['metaType'])) { 326 326 throw new Exception('No meta type'); 327 327 } 328 328 329 329 # Get previous meta for post 330 330 $post_meta = $core->meta->getMetadata(array( … … 335 335 $pm[] = $post_meta->meta_id; 336 336 } 337 337 338 338 foreach ($core->meta->splitMetaValues($post['meta']) as $m) 339 339 { … … 342 342 } 343 343 } 344 344 345 345 return true; 346 346 } 347 347 348 348 public static function delMeta($core,$get,$post) 349 349 { … … 351 351 throw new Exception('No post ID'); 352 352 } 353 353 354 354 if (empty($post['metaId']) && $post['metaId'] != '0') { 355 355 throw new Exception('No meta ID'); 356 356 } 357 357 358 358 if (empty($post['metaType'])) { 359 359 throw new Exception('No meta type'); 360 360 } 361 361 362 362 $core->meta->delPostMeta($post['postId'],$post['metaType'],$post['metaId']); 363 363 364 364 return true; 365 365 } 366 366 367 367 public static function searchMeta($core,$get) 368 368 { 369 369 $q = !empty($get['q']) ? $get['q'] : null; 370 370 $metaType = !empty($get['metaType']) ? $get['metaType'] : null; 371 371 372 372 $sortby = !empty($get['sortby']) ? $get['sortby'] : 'meta_type,asc'; 373 373 374 374 $rs = $core->meta->getMetadata(array('meta_type' => $metaType)); 375 375 $rs = $core->meta->computeMetaStats($rs); 376 376 377 377 $sortby = explode(',',$sortby); 378 378 $sort = $sortby[0]; 379 379 $order = isset($sortby[1]) ? $sortby[1] : 'asc'; 380 380 381 381 switch ($sort) { 382 382 case 'metaId': … … 392 392 $sort = 'meta_type'; 393 393 } 394 394 395 395 $rs->sort($sort,$order); 396 396 397 397 $rsp = new xmlTag(); 398 398 399 399 while ($rs->fetch()) 400 400 { … … 407 407 $metaTag->roundpercent = $rs->roundpercent; 408 408 $metaTag->CDATA($rs->meta_id); 409 409 410 410 $rsp->insertNode($metaTag); 411 411 } 412 412 } 413 414 return $rsp; 415 } 416 413 414 return $rsp; 415 } 416 417 417 public static function setSectionFold($core,$get,$post) 418 418 { … … 434 434 if ($k !== false) { 435 435 unset($toggles[$k]); 436 } 436 } 437 437 } else { // false == unfold section ==> add it to unfolded list 438 438 if ($k === false) { 439 439 $toggles[]=$section; 440 }; 440 }; 441 441 } 442 442 $core->auth->user_prefs->toggles->put('unfolded_sections',join(',',$toggles)); 443 443 return true; 444 444 } 445 445 446 446 public static function getModuleById($core, $get, $post) 447 447 { … … 466 466 elseif ($list == 'plugin-new') { 467 467 $store = new dcStore( 468 $core->plugins, 468 $core->plugins, 469 469 $core->blog->settings->system->store_plugin_url 470 470 ); … … 497 497 } 498 498 } 499 ?>
Note: See TracChangeset
for help on using the changeset viewer.
