Dotclear

Changeset 2380


Ignore:
Timestamp:
06/21/10 13:34:53 (13 years ago)
Author:
bruno
Message:

dotAjax 1.1 : added media requests

Location:
plugins/dotajax
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • plugins/dotajax/_define.php

    r1946 r2380  
    2626     /* Description*/         "Ajax/JSON interface for Dotclear2", 
    2727     /* Author */             "Bruno Hondelatte", 
    28      /* Version */            '1.0.1', 
     28     /* Version */            '1.1', 
    2929     /* Permissions */        'usage,contentadmin', 
    3030     /* Priority */           500 
    3131); 
    3232 
    33 /* URL Handlers for REST API */ 
    34 $GLOBALS['core']->url->register('rest','rest','^rest/(.+)$',array('urlRest','rest')); 
    3533 
    3634?> 
  • plugins/dotajax/_public.php

    r1679 r2380  
    2323require dirname(__FILE__).'/class.blogrest.php'; 
    2424 
     25/* URL Handlers for REST API */ 
     26$GLOBALS['core']->url->register('rest','rest','^rest/(.+)$',array('urlRest','rest')); 
     27 
    2528$GLOBALS['core']->pubrest->register('blog','blogRest'); 
    2629 
  • plugins/dotajax/class.blogrest.php

    r1946 r2380  
    203203     } 
    204204 
     205      
     206     public static function getPostMedia($core,$get) 
     207     { 
     208          if (!isset($get['post_id'])) 
     209               throw new Exception ('No post ID specified'); 
     210           
     211          $post_id = (integer) $get['post_id']; 
     212          $media_id=isset($get['media_id'])?(integer)$get['media_id']:null; 
     213 
     214          $rs = $core->media->getPostMedia($post_id,$media_id); 
     215 
     216          $rsp = array(); 
     217          foreach ($rs as $m) 
     218          { 
     219               $media=array( 
     220                    'url'=> $m->file_url, 
     221                    'id'=> $m->media_id, 
     222                    'title'=> $m->media_title, 
     223                    'dt' => $m->media_dt, 
     224                    'thumbs' => $m->media_thumb); 
     225 
     226               $rsp[]=$media; 
     227          } 
     228          return $rsp; 
     229     } 
     230 
     231     public static function getMedia($core,$get) 
     232     { 
     233          if (!isset($get['media_id'])) 
     234               throw new Exception ('No media ID specified'); 
     235           
     236          $media_id = (integer) $get['media_id']; 
     237          $media_id=isset($get['media_id'])?(integer)$get['media_id']:null; 
     238 
     239          $m = $core->media->getFile($media_id); 
     240          if ($m == null) 
     241               throw new Exception ('Media not found'); 
     242          $rsp=array( 
     243               'url'=> $m->file_url, 
     244               'id'=> $m->media_id, 
     245               'title'=> $m->media_title, 
     246               'dt' => $m->media_dt, 
     247               'thumbs' => $m->media_thumb); 
     248 
     249          return $rsp; 
     250     } 
    205251} 
    206252?> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map