includes/plugins.php
changeset 555 ac4c6a7f01d8
parent 536 218a627eb53e
child 560 8981dcf7d485
--- a/includes/plugins.php	Mon May 12 00:59:46 2008 -0400
+++ b/includes/plugins.php	Fri May 16 12:22:26 2008 -0400
@@ -811,6 +811,54 @@
     
     return $return;
   }
+  
+  /**
+   * Re-imports the language strings from a plugin.
+   * @param string File name
+   * @return array Enano JSON response protocol
+   */
+  
+  function reimport_plugin_strings($filename, $plugin_list = null)
+  {
+    global $db, $session, $paths, $template, $plugins; // Common objects
+    global $lang;
+    
+    if ( !$plugin_list )
+      $plugin_list = $this->get_plugin_list();
+    
+    switch ( true ): case true:
+    
+    // is the plugin in the directory and already installed?
+    if ( !isset($plugin_list[$filename]) || (
+        isset($plugin_list[$filename]) && !$plugin_list[$filename]['installed']
+      ))
+    {
+      $return = array(
+        'mode' => 'error',
+        'error' => 'Invalid plugin specified.',
+      );
+      break;
+    }
+    // get plugin data
+    $dataset =& $plugin_list[$filename];
+    
+    $result = $lang->import_plugin(ENANO_ROOT . '/plugins/' . $filename);
+    if ( $result )
+    {
+      return array(
+        'success' => true
+      );
+    }
+    else
+    {
+      return array(
+        'mode' => 'error',
+        'error' => 'Language API returned error'
+      );
+    }
+    
+    endswitch;
+  }
 }
 
 ?>