v.4.0 README hello_world.zip

ab 4.5.3 wird kein plugin-interface mehr bentigt

kleinerer bugfix bei nextid vergabe

***

v.3.0 README hello_world.zip

bentigt:
plugin-interface-contenido-4.4.5.zip

***

v.2.0 README hello_world.zip

bentigt:
plugin-interface-contenido-4.4.4.zip
plugin-interface-contenido-4.5.2.zip

install:
im ordner contenido/plugins/ entzippen
http://yourhost/yourpathto/contenido/plugins/hello_world/install.php
aufrufen...
anmelden...
anweisungen folgen

eine deinstall ist ebenso vorhanden

achtung der plugin installer ist noch eine alpha version...
!PREFIX! und !PID! im install.sql werden automatisch vom plugin installer
ersetzt...
auf bereits installierte plugins wird keine rcksicht bei der vergabe der id nummern
genommen...

optional ist die installation des menuless patch...
zu finden unter -> http://contenido.de/forum/viewtopic.php?p=28497#28497

im install.sql sind beide eintrge fr menuless vorhanden...

***

v.1.0 README hello_world.zip

damit die einbindung in contenido 4.4.x korrekt funktioniert mssen
am contenido code einige nderungen vorgenommen werden.

1.
am ende der datei includes/cfg_language_de.inc.php muss folgendes eingefgt werden...

Code:
/* Include the plugin configuration */
$handle = opendir($cfg['path']['contenido'] . $cfg["path"]['plugins'] );

while ($plugin = readdir($handle))
{
   $configfile = $cfg['path']['contenido'] . $cfg["path"]['plugins'] . $plugin . "/includes/config.plugin.php";
   $localedir = $cfg['path']['contenido'] . $cfg["path"]['plugins'] . $plugin . "/locale/";

   if (@file_exists($localedir) && $plugin != "..")
   {
      i18nRegisterDomain($plugin, $localedir);
   }
   if (@file_exists($configfile))
   {
      include($configfile);
   }
}

****

2.
in der function.i18n.php ergnzen... (ist aus dem CVS_HEAD)
die ersten 3 funktionen kommentiert man am besten aus (also i18n,i18nEmulateGettext,i18nInit)
die letzte ist neu... sonst funktioniert das i18n in den plugins nicht...

Code:
/**
* i18n($string)
*
* gettext wrapper (for future extensions). Usage:
* i18n("Your text which has to be translated");
*
* @param $string string The string to translate
* @param $domain string The domain to look up
* @return string  Returns the translation
*/
function i18n ($string, $domain = "contenido")
{
   global $cfg, $i18nLanguage;

   if ($i18nLanguage == "he_SS")
   {
      return i18nEmulateGettext($string, $domain);
   }

   if (function_exists("dgettext"))
   {
      if ($domain != "contenido")
      {
         $translation = dgettext($domain, $string);
         return ($translation);
      } else {
         return gettext($string);
      }
   }

   return i18nEmulateGettext($string, $domain);


}

/**
* i18nEmulateGettext()
*
* Emulates GNU gettext
*
* @param $string string The string to translate
* @param $domain string The domain to look up
* @return string  Returns the translation
*/
function i18nEmulateGettext ($string, $domain = "contenido")
{
   global $cfg, $i18nLanguage, $transFile, $i18nDomains;

   /* Bad thing, gettext is not available. Let's emulate it */
   if (!file_exists($i18nDomains[$domain].$i18nLanguage."/LC_MESSAGES/".$domain.".po"))
   {
      return $string;
   }

   if (!isset($transFile[$domain]))
   {
      $transFile[$domain] = implode('',file($i18nDomains[$domain].$i18nLanguage."/LC_MESSAGES/".$domain.".po"));
   }

   $stringStart = strpos($transFile[$domain],'"'.$string.'"');

   if ($stringStart === false)
   {
      return $string;
   }


   $searchStart = $stringStart + strlen($string);
   $msgstrStart = strpos($transFile[$domain], 'msgstr', $searchStart);



   $messageStart = strpos($transFile[$domain], '"', $msgstrStart);
   $maxMsgEnd = strpos($transFile[$domain], "\n", $messageStart);

   $tempMessage = substr($transFile[$domain], $messageStart+1, $maxMsgEnd- $messageStart+1);


   $startSearch = 0;
   $endOfMessage = 0;
   while ($pos = strpos($tempMessage,'"',$startSearch+1))
   {
      if ($pos === false)
      {
         return "Error in i18nEmulateGettext";
      }
      if (substr($tempMessage, $pos-1,1) != '\\')
      {
         $endOfMessage = $pos;
      }

      $startSearch = $pos;
   }

   $tempMessage = substr($tempMessage,0,$endOfMessage);
   $tempMessage = str_replace('\\"','"',$tempMessage);

   return ($tempMessage);

}

/**
* i18nInit()
*
* Initializes the i18n stuff.
*
* @param $localePath string Path to the locales
* @param $langCode string Language code to set
* @return string  Returns the translation
*/
function i18nInit ($localePath, $langCode)
{
   global $i18nLanguage;
   global $i18nDomains;

   if (function_exists("bindtextdomain"))
   {
       /* Bind the domain "contenido" to our locale path */
       bindtextdomain("contenido", $localePath);

       /* Set the default text domain to "contenido" */
       textdomain("contenido");

       /* Half brute-force to set the locale. */
       if (!ini_get("safe_mode"))
       {
          putenv("LANG=$langCode");
       }
       setlocale(LC_ALL, $langCode);
   }

   $i18nDomains["contenido"] = $localePath;

   $i18nLanguage = $langCode;
}

/**
* i18nRegisterDomain()
*
* Registers a new i18n domain.
*
* @param $localePath string Path to the locales
* @param $domain string Domain to bind to
* @return string  Returns the translation
*/
function i18nRegisterDomain ($domain, $localePath)
{
   global $i18nDomains;

   if (function_exists("bindtextdomain"))
   {
       /* Bind the domain "contenido" to our locale path */
       bindtextdomain($domain, $localePath);
   }

   $i18nDomains[$domain] = $localePath;
}


****

obrige nderungen sind in der 4.5.x serie nicht notwendig...

sobald man nun die install.sql via phpmyadmin ausfhrt und
contenido neu startet findet man einen neuen menpunkt unter
Extra -> Hello world

weitere anmerkungen zu den plugins findet ihr hier:
http://www.contenido.de/forum/viewtopic.php?t=2844
