[geeklog-cvs] Geeklog-1.x/system lib-plugins.php, 1.134, 1.135 lib-story.php, 1.111, 1.112 lib-webservices.php, 1.19, 1.20

Ramnath Iyer riyer at qs1489.pair.com
Fri Nov 23 03:40:54 EST 2007


Update of /cvsroot/geeklog/Geeklog-1.x/system
In directory qs1489.pair.com:/tmp/cvs-serv98907/system

Modified Files:
	lib-plugins.php lib-story.php lib-webservices.php 
Log Message:
* Webservices introspection document returns a collection for each plugin
* Every plugin that claims to support WS should have a function
      plugin_ws_enabled_XXX()
  that returns true
* PLG_servicesEnabled($type) added that returns true for function that support WS



Index: lib-webservices.php
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/system/lib-webservices.php,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** lib-webservices.php	18 Nov 2007 20:59:22 -0000	1.19
--- lib-webservices.php	23 Nov 2007 08:40:52 -0000	1.20
***************
*** 235,239 ****
  {
      global $WS_PLUGIN, $WS_INTROSPECTION, $WS_ATOM_NS, $WS_APP_NS, $WS_EXTN_NS,
!            $WS_VERBOSE, $_CONF;
  
      if ($WS_VERBOSE) {
--- 235,239 ----
  {
      global $WS_PLUGIN, $WS_INTROSPECTION, $WS_ATOM_NS, $WS_APP_NS, $WS_EXTN_NS,
!            $WS_VERBOSE, $_CONF, $_PLUGINS;
  
      if ($WS_VERBOSE) {
***************
*** 249,258 ****
          $atom_uri = $_CONF['site_url'] . '/webservices/atom/';
  
!         /* 'story' is the default plugin */
!         if (empty($WS_PLUGIN)) {
!             $WS_PLUGIN = 'story';
          }
  
!         $atom_uri .= '?plugin=' . $WS_PLUGIN;
  
          /* It might be simpler to do this part directly :-/ */
--- 249,267 ----
          $atom_uri = $_CONF['site_url'] . '/webservices/atom/';
  
!         /* Determine which plugins have webservices enabled */
!         $_ws_plugins = array();
! 
!         /* Handle the story 'plugin' separately */
!         if (PLG_servicesEnabled('story')) {
!             $_ws_plugins[] = 'story';
          }
  
! 	if (is_array($_PLUGINS)) {
!             foreach ($_PLUGINS as $pi) {
!                 if (PLG_servicesEnabled($pi)) {
!                     $_ws_plugins[] = $pi;
!                 }
!             }
! 	}
  
          /* It might be simpler to do this part directly :-/ */
***************
*** 270,296 ****
          $workspace->appendChild($title);
  
!         $collection = $atom_doc->createElement('app:collection');
!         $collection->setAttribute('href', $atom_uri);
!         $workspace->appendChild($collection);
  
!         $title = $atom_doc->createElement('atom:title', $WS_PLUGIN);
!         $collection->appendChild($title);
  
!         $entry = $atom_doc->createElement('app:accept',
!                                           'application/atom+xml;type=entry');
!         $collection->appendChild($entry);
  
!         $categories = $atom_doc->createElement('app:categories');
!         $categories->setAttribute('fixed', 'yes');
!         $collection->appendChild($categories);
  
!         $topics = array();
!         $msg = array();
!         $ret = PLG_invokeService($WS_PLUGIN, 'getTopicList', null, $topics, $msg);
!         if ($ret == PLG_RET_OK) {
!             foreach ($topics as $t) {
!                 $topic = $atom_doc->createElement('atom:category');
!                 $topic->setAttribute('term', htmlentities($t));
!                 $categories->appendChild($topic);
              }
          }
--- 279,308 ----
          $workspace->appendChild($title);
  
!         foreach ($_ws_plugins as $ws_plugin) {
!             $atom_uri_for_plugin = $atom_uri . '?plugin=' . $ws_plugin;
  
!             $collection = $atom_doc->createElement('app:collection');
!             $collection->setAttribute('href', $atom_uri_for_plugin);
!             $workspace->appendChild($collection);
  
!             $title = $atom_doc->createElement('atom:title', $ws_plugin);
!             $collection->appendChild($title);
  
!             $entry = $atom_doc->createElement('app:accept', 'application/atom+xml;type=entry');
!             $collection->appendChild($entry);
  
!             $categories = $atom_doc->createElement('app:categories');
!             $categories->setAttribute('fixed', 'yes');
!             $collection->appendChild($categories);
! 
!             $topics = array();
!             $msg = array();
!             $ret = PLG_invokeService($ws_plugin, 'getTopicList', null, $topics, $msg);
!             if ($ret == PLG_RET_OK) {
!                 foreach ($topics as $t) {
!                     $topic = $atom_doc->createElement('atom:category');
!                     $topic->setAttribute('term', htmlentities($t));
!                     $categories->appendChild($topic);
!                 }
              }
          }

Index: lib-story.php
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/system/lib-story.php,v
retrieving revision 1.111
retrieving revision 1.112
diff -C2 -d -r1.111 -r1.112
*** lib-story.php	4 Nov 2007 20:19:31 -0000	1.111
--- lib-story.php	23 Nov 2007 08:40:52 -0000	1.112
***************
*** 980,983 ****
--- 980,991 ----
  }
  
+ /**
+  * Return true since this component supports webservices
+  *
+  * @return  bool	True, if webservices are supported
+  */
+ function plugin_ws_enabled_story() {
+     return true;
+ }
  
  /*

Index: lib-plugins.php
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/system/lib-plugins.php,v
retrieving revision 1.134
retrieving revision 1.135
diff -C2 -d -r1.134 -r1.135
*** lib-plugins.php	19 Aug 2007 16:40:50 -0000	1.134
--- lib-plugins.php	23 Nov 2007 08:40:52 -0000	1.135
***************
*** 2307,2315 ****
      // Check if the plugin type and action are valid
      $function = 'service_' . $action . '_' . $type;
!     if (function_exists($function)) {
          $retval = $function($args, $output, $svc_msg);
      }
  
      return $retval;
  }
  
--- 2307,2335 ----
      // Check if the plugin type and action are valid
      $function = 'service_' . $action . '_' . $type;
! 
!     if (function_exists($function) && PLG_servicesEnabled($type)) {
          $retval = $function($args, $output, $svc_msg);
      }
  
      return $retval;
+ }
+ 
+ /**
+  * Returns true if the plugin supports webservices
+  * 
+  * @param   string  type    The plugin type that is to be checked
+  */
+ function PLG_servicesEnabled($type) {
+     global $_CONF;
+ 
+     // ensure we can see the service_XXX_story functions
+     require_once $_CONF['path_system'] . 'lib-story.php';
+ 
+     $function = 'plugin_ws_enabled_' . $type;
+     if (function_exists($function)) {
+         return $function();
+     } else {
+         return false;
+     }
  }
  




More information about the geeklog-cvs mailing list