Dotclear


Ignore:
Timestamp:
09/29/13 23:10:54 (12 years ago)
Author:
Denis Jean-Chirstian <contact@…>
Branch:
dcRepo
Message:

Add rest service to get more module info on modules list through ajax

File:
1 edited

Legend:

Unmodified
Added
Removed
  • admin/services.php

    r1699 r2156  
    2727$core->rest->addFunction('searchMeta',array('dcRestMethods','searchMeta')); 
    2828$core->rest->addFunction('setSectionFold',array('dcRestMethods','setSectionFold')); 
     29$core->rest->addFunction('getModuleById',array('dcRestMethods','getModuleById')); 
    2930 
    3031$core->rest->serve(); 
     
    442443          return true; 
    443444     } 
    444            
    445       
     445      
     446     public static function getModuleById($core, $get, $post) 
     447     { 
     448          if (empty($get['id'])) { 
     449                    throw new Exception('No module ID'); 
     450          } 
     451          if (empty($get['list'])) { 
     452                    throw new Exception('No list ID'); 
     453          } 
     454 
     455          $id = $get['id']; 
     456          $list = $get['list']; 
     457          $module = array(); 
     458 
     459          if ($list == 'plugin-activate') { 
     460               $modules = $core->plugins->getModules(); 
     461               if (empty($modules) || !isset($modules[$id])) { 
     462                    throw new Exception('Unknow module ID'); 
     463               } 
     464               $module = $modules[$id]; 
     465          } 
     466          elseif ($list == 'plugin-new') { 
     467               $repository = new dcRepository( 
     468                    $core->plugins,  
     469                    $core->blog->settings->system->repository_plugin_url 
     470               ); 
     471               $repository->check(); 
     472 
     473               $modules = $repository->get(); 
     474               if (empty($modules) || !isset($modules[$id])) { 
     475                    throw new Exception('Unknow module ID'); 
     476               } 
     477               $module = $modules[$id]; 
     478          } 
     479          else { 
     480               // behavior not implemented yet 
     481          } 
     482 
     483          if (empty($module)) { 
     484                    throw new Exception('Unknow module ID'); 
     485          } 
     486 
     487          $module = adminModulesList::setModuleInfo($id, $module); 
     488 
     489          $rsp = new xmlTag('module'); 
     490          $rsp->id = $id; 
     491           
     492          foreach($module as $k => $v) { 
     493               $rsp->{$k}((string) $v); 
     494          } 
     495 
     496          return $rsp; 
     497     } 
    446498} 
    447499?> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map