OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Plugin and version.xml

OJS development discussion, enhancement requests, third-party patches and plug-ins.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
The Public Knowledge Project Support Forum is moving to http://forum.pkp.sfu.ca

This forum will be maintained permanently as an archived historical resource, but all new questions should be added to the new forum. Questions will no longer be monitored on this old forum after March 30, 2015.

Plugin and version.xml

Postby MartinEve » Sun Sep 11, 2011 12:31 pm

Hi,

I'm starting work on a basic plugin. I have a version.xml file that looks like this:

Code: Select all
 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE version SYSTEM "../../../lib/pkp/dtd/pluginVersion.dtd">
<version>
   <application>MEXMLGalley</application>
   <type>plugins.generic</type>
   <release>1.0.0.0</release>
   <date>2011-09-11</date>
   <lazy-load>1</lazy-load>
   <class>MEXMLGalleyPlugin</class>
</version>


an index.php file that looks like this:

Code: Select all
<?php
/**
 * @defgroup plugins_generic_MExmlGalley
 */
 
/**
 * @file plugins/generic/MExmlGalley/index.php
 *
 * Copyright (c) 2011 Martin Paul Eve
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
 *
 * @ingroup plugins_generic_MExmlGalley
 * @brief Wrapper for MEXMLGalleyPlugin
 *
 */

// $Id$


require_once('MEXMLGalleyPlugin.inc.php');

return new MEXMLGalleyPlugin();
?>


and finally, my MEXMLGalleyPlugin.inc.php:

Code: Select all
<?php

/**
 * @file MEXMLGalleyPlugin.inc.php
 *
 * Copyright (c) 2011 Martin Paul Eve
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
 *
 * @class MEXMLGalleyPlugin
 * @ingroup plugins_generic_MEXMLGalley
 *
 * @brief Martin Eve's modified XML Galley Plugin
 */

// $Id$


import('lib.pkp.classes.plugins.GenericPlugin');

// this plugin is symbiotic with xmlGalley; it can't function independently
//include_once('plugins/generic/xmlGalley/ArticleXMLGalleyDAO.inc.php');

class MEXMLGalleyPlugin extends GenericPlugin {
   function register($category, $path) {
      if (parent::register($category, $path)) {
         if ($this->getEnabled()) {
            error_log("Registered");
            HookRegistry::register('ArticleGalleyDAO::insertNewGalley', array($this, 'insertXMLGalleys') );
         }

         return true;
      }
      return false;
   }

   function getDisplayName() {
      return "Martin Eve's modified XML Galley Plugin";
   }

   function getDescription() {
      return "Allows PDF galleys to be generated from XML";
   }

   function insertXMLGalleys($hookName, $args) {

      error_log("Function called");

      return false;
   }



   /**
    * Set the enabled/disabled state of this plugin
    */
   function setEnabled($enabled) {
      error_log("Set to " . $enabled);
      parent::setEnabled($enabled);
      $journal =& Request::getJournal();
      if ($journal) {
         return true;
      }
      return false;
   }

   /*
     * Execute a management verb on this plugin
     * @param $verb string
     * @param $args array
    * @param $message string Location for the plugin to put a result msg
     * @return boolean
     */
   function manage($verb, $args, &$message) {
      error_log("Verb " . $verb);
      if (!parent::manage($verb, $args, $message)) { return false; } else { return true; }
   }
}
?>


Now, after reading [url="http://pkp.sfu.ca/support/forum/viewtopic.php?f=9&t=7386"]this thread[/url] I realised that I have to run tools/upgrade.php upgrade in order to have the plugin's information written into the version table. When I do so, however, I receive:

Code: Select all
  [pre-install]
[load: upgrade.xml]
[version: 2.3.6.0]
[schema: lib/pkp/xml/schema/signoff.xml]
[schema: lib/pkp/xml/schema/common.xml]
[schema: lib/pkp/xml/schema/groups.xml]
[schema: lib/pkp/xml/schema/announcements.xml]
[schema: lib/pkp/xml/schema/scheduledTasks.xml]
[schema: lib/pkp/xml/schema/temporaryFiles.xml]
[schema: lib/pkp/xml/schema/metadata.xml]
[schema: lib/pkp/xml/schema/reviews.xml]
[schema: lib/pkp/xml/schema/reviewForms.xml]
[schema: lib/pkp/xml/schema/controlledVocab.xml]
[schema: lib/pkp/xml/schema/submissions.xml]
[schema: lib/pkp/xml/schema/comments.xml]
[schema: lib/pkp/xml/schema/notes.xml]
[schema: dbscripts/xml/ojs_schema.xml]
[code: Installer Installer::addPluginVersions]
 PHP Fatal error:  Call to a member function getCurrent() on a non-object in /home/martinev/public_html/new_excursions/lib/pkp/classes/site/VersionDAO.inc.php on line 131


Any ideas what's going wrong, please?
MartinEve
 
Posts: 11
Joined: Sun Jul 10, 2011 6:33 am

Re: Plugin and version.xml

Postby MartinEve » Mon Sep 12, 2011 2:04 am

Ok, so further to this, I supposed that I needed to properly install the plugin the first time. I know receive, though, this error:

The uploaded plugin archive does not contain a folder that corresponds to the plugin name.

I've got as far as packaging up my structure into a .tar.gz, which now looks like this:

plugins/generic/meXml/index.php
plugins/generic/meXml/MeXml.inc.php
plugins/generic/meXml/version.xml

Any thoughts on what's happening would be greatly appreciated; as far as I can see, all "names" are set to meXml. The permissions on my OJS folder have been set to 777, just to rule out any permission problems.

index.php:
Code: Select all
 <?php

/**
 * @defgroup plugins_generic_meXml
 */
 
/**
 * @file plugins/generic/meXml/index.php
 *
 * Copyright (c) 2011 Martin Paul Eve
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
 *
 * @ingroup plugins_generic_meXml
 * @brief Wrapper for meXml
 *
 */

// $Id$


require_once('meXml.inc.php');

return new meXml();

?>


meXml.inc.php:
Code: Select all
<?php

/**
 * @file meXml.inc.php
 *
 * Copyright (c) 2011 Martin Paul Eve
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
 *
 * @class meXml
 * @ingroup plugins_generic_meXml
 *
 * @brief Martin Eve's modified XML Galley Plugin
 */

// $Id$


import('lib.pkp.classes.plugins.GenericPlugin');

// this plugin is symbiotic with xmlGalley; it can't function independently
//include_once('plugins/generic/xmlGalley/ArticleXMLGalleyDAO.inc.php');

class meXml extends GenericPlugin {
   function register($category, $path) {
      if (parent::register($category, $path)) {
         if ($this->getEnabled()) {
            error_log("Registered");
            HookRegistry::register('ArticleGalleyDAO::insertNewGalley', array($this, 'insertXMLGalleys') );
         }

         return true;
      }
      return false;
   }

   function getName() {
      return 'meXml';
   }

   function getDisplayName() {
      return "Martin Eve's modified XML Galley Plugin";
   }

   function getDescription() {
      return "Allows PDF galleys to be generated from XML";
   }

   function insertXMLGalleys($hookName, $args) {

      error_log("Function called");

      return false;
   }



   /**
    * Set the enabled/disabled state of this plugin
    */
   function setEnabled($enabled) {
      error_log("Set to " . $enabled);
      parent::setEnabled($enabled);
      $journal =& Request::getJournal();
      if ($journal) {
         return true;
      }
      return false;
   }

   /*
     * Execute a management verb on this plugin
     * @param $verb string
     * @param $args array
    * @param $message string Location for the plugin to put a result msg
     * @return boolean
     */
   function manage($verb, $args, &$message) {
      error_log("Verb " . $verb);
      if (!parent::manage($verb, $args, $message)) { return false; } else { return true; }
   }
}
?>


version.xml:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE version SYSTEM "../../../lib/pkp/dtd/pluginVersion.dtd">
<version>
   <application>meXml</application>
   <type>plugins.generic</type>
   <release>1.0.0.0</release>
   <date>2011-09-11</date>
   <lazy-load>1</lazy-load>
   <class>meXml</class>
</version>
MartinEve
 
Posts: 11
Joined: Sun Jul 10, 2011 6:33 am

Re: Plugin and version.xml

Postby MartinEve » Mon Sep 12, 2011 7:34 am

Answer to this was far simpler than I supposed.

Rather than the plugins/generic/pluginName which I had assumed was necessary, all that is required is for the .tar.gz to contain pluginName/files
MartinEve
 
Posts: 11
Joined: Sun Jul 10, 2011 6:33 am


Return to OJS Development

Who is online

Users browsing this forum: No registered users and 2 guests