Example #1
0
 /**
  * @param toiminto Toiminnon nimi jossa kyseinen komponentti sijaitsee.
  */
 function Component($toiminto)
 {
     $this->ID = getID(get_class($this));
     $this->TM = TranslationManager::instance();
     $this->toiminto = $toiminto;
     $_SESSION['IDS'][$this->ID] = 1;
 }
 function grab($param = array())
 {
     $xml = new XMLElement('translations');
     $tm = new TranslationManager($this->_Parent);
     foreach ($tm->listAll() as $lang => $extensions) {
         $temp = $tm->get($lang, $extensions[0]);
         $item = new XMLElement('language');
         $item->setAttribute('handle', $lang);
         $item->setAttribute('name', $temp['about']['name']);
         foreach ($extensions as $extension) {
             $item->appendChild(new XMLElement('extension', NULL, array('handle' => $extension)));
         }
         $xml->appendChild($item);
     }
     return $xml;
 }
Example #3
0
 function View(&$toiminto)
 {
     $this->toiminto =& $toiminto;
     $this->tm = TranslationManager::instance();
     //unset($this->title);
     global $JOUKKUEENNIMI;
     $this->title = $JOUKKUEENNIMI;
     $this->kantaanLaitettu = NULL;
     $errors = $this->toiminto->getErrors();
     $this->hasErrors = ($errors != null and count($errors) > 0);
     $this->ohje = $this->tm->ohje($this->toiminto->toiminnonNimi);
     $this->otsikko = $this->tm->getText($this->toiminto->toiminnonNimi);
     // toiminto == toiminnon tulostettava nimi
     // $menu[toiminto][0] == linkki == L, ulkopuolinen linkki U,väliotsikko == V, T == tyhjärivi
     // $menu[toiminto][1] == linkin toiminto
     // $menu[toiminto][2] == syvyys hierarkiassa default == 1 (ei sisennystä)
     $this->menuPublic = array('main' => array('L', 'main', 'Etusivu'), 'pelit' => array('L', 'pelit', 'Pelit'), 'kokoonpano' => array('L', 'kokoonpano', 'Kauden kokoonpano'), '1' => array('T'), '2' => array('V', '', 'Tilastot'), 'pelaajatilastot' => array('L', 'pelaajatilastot', 'Pelaajat', 2), 'joukkuetilastot' => array('L', 'joukkuetilastot', 'Joukkue', 2), 'sarjatilastot' => array('L', 'sarjatilastot', 'Sarjat', 2), '3' => array('T'), 'uutislista' => array('L', 'uutislista', 'Uutiset'), '3' => array('T'));
     //$this->menuLoggedIn = array_merge($this->menuPublic);
     $this->menuLoggedIn = array('3' => array('T'), '11' => array('V', '', 'Ylläpito'), 'joukkueet' => array('L', 'joukkueet', 'Joukkueet', 2), 'joukkueenlisays' => array('L', 'joukkueenlisays', 'Joukkueen lisäys', 3), '20' => array('T'), 'seurat' => array('L', 'seurat', 'Seurat', 2), 'seuranlisays' => array('L', 'seuranlisays', 'Seuran lisäys', 3), '18' => array('T'), 'sarjanjoukkueet' => array('L', 'sarjanjoukkueet', 'Sarjan joukkueet', 2), 'sarjanpelit' => array('L', 'sarjanpelit', 'Sarjan pelien lisääminen', 2), 'sarjat' => array('L', 'sarjat', 'Sarjat', 2), 'sarjanlisays' => array('L', 'sarjanlisays', 'Sarjan lisäys', 3), '13' => array('T'), 'hallit' => array('L', 'hallit', 'Hallit', 2), 'hallinlisays' => array('L', 'hallinlisays', 'Hallin lisäys', 3), '16' => array('T'), 'kayttajat' => array('L', 'kayttajat', 'Käyttäjät', 2), 'kayttajanlisays' => array('L', 'kayttajanlisays', 'Käyttäjän lisäys', 3), '14' => array('T'), 'henkilot' => array('L', 'henkilot', 'Henkilöt', 2), 'henkilonlisays' => array('L', 'henkilonlisays', 'Henkilön lisäys', 3), '15' => array('T'), 'tapahtumat' => array('L', 'tapahtumat', 'Tapahtumat', 2), 'pelinlisays' => array('L', 'pelinlisays', 'Pelin lisäys', 3), 'tapahtumanlisays' => array('L', 'tapahtumanlisays', 'Tapahtuman lisäys', 3), '26' => array('T'), 'uutiset' => array('L', 'uutiset', 'Uutisen lisäys', 2), '25' => array('T'), '2' => array('V', '', 'Joukkueen alue'), 'intranet' => array('L', 'intranet', 'Intranet', 2), '19' => array('U', 'filethingie.php', 'Tiedostojen lisäys', 2), '27' => array('U', '../koovee2', 'Foorumi', 2));
     /*
     'henkilonlisays'=>array('HenkilonLisays','henkilonlisays','x----'),
     'henkilonmuokkaus'=>array('HenkilonLisays','henkilonlisays','x----'),
     'joukkueet'=>array('Joukkueet','joukkueet','x----'),
     
     'henkilot'=>array('Henkilot','henkilot','x-xx-'),
     'uutiset'=>array('Uutiset','uutiset','x-xx-'),
     'uutislista'=>array('UutisLista','uutislista','x-xxx'),
     'tuloksenlisays'=>array('TuloksenLisays','tuloksenlisays','x-xx-'),
     
     'intranet'=>array('Intranet','intranet','x----')
     */
 }
Example #4
0
 function LomakeElementti()
 {
     // Nopeutetaan niiden lomakeelementtien piirtämistä mitkä eivät tarvitse kääntäjää
     // sillä parentin rakentajaa ei kutsuta automaattisesti
     require_once 'toimintofactory.php';
     $this->TM = TranslationManager::instance();
     if (isset($_SESSION['onkooikeuksia'])) {
         $this->onkoMuokkausOikeuksia = $_SESSION['onkooikeuksia'];
     }
 }
Example #5
0
 function draw($full = FALSE)
 {
     beginFrame();
     print '<table><tr>';
     print '<td align="middle">';
     isoTeksti($this->tiedot['kotijoukkuepitkanimi']);
     if ($this->tiedot['kotijoukkuepitkanimi'] != $this->tiedot['kotijoukkuenimi']) {
         print ' (' . $this->tiedot['kotijoukkuenimi'] . ')';
     }
     print '</td><td align="middle">';
     isoTeksti(' - ');
     print '</td><td align="middle">';
     isoTeksti($this->tiedot['vierasjoukkuepitkanimi']);
     if ($this->tiedot['vierasjoukkuepitkanimi'] != $this->tiedot['vierasjoukkuenimi']) {
         print ' (' . $this->tiedot['vierasjoukkuenimi'] . ')';
     }
     print '</td></tr><td align="middle">';
     $dmaalit = !empty($this->tiedot['kotimaalit']) && !empty($this->tiedot['vierasmaalit']);
     if ($dmaalit) {
         isoTeksti($this->tiedot['kotimaalit']);
     }
     print '</td><td align="middle">';
     if ($dmaalit) {
         isoTeksti(' - ');
     }
     print '</td><td align="middle">';
     if ($dmaalit) {
         isoTeksti($this->tiedot['vierasmaalit']);
     }
     print '</td></tr></table>';
     print '<table> <tr> <td>';
     print $this->tiedot['kausi'] . ', ' . $this->tiedot['sarjanimi'];
     print '</td></tr><tr><td>';
     print $this->tiedot['pvm'];
     print '</td></tr><tr><td>';
     print $this->tiedot['pelipaikka'];
     if ($full) {
         $this->tm = TranslationManager::instance();
         $this->drawInfo('aikalisaa');
         $this->drawInfo('aikalisab');
         $this->drawInfo('tuomari1');
         $this->drawInfo('tuomari2');
         $this->drawInfo('toimitsija1');
         $this->drawInfo('toimitsija2');
         $this->drawInfo('toimitsija3');
         if ($this->tiedot['yleisomaara'] > 0) {
             $this->drawInfo('yleisomaara');
         }
     }
     print '</td></tr>';
     print '</table>';
     endFrame();
     print '<br>';
 }
Example #6
0
 /**
  * Get the TranslationManager instance
  * create it if necessary
  * @return TranslationManager_Instance
  */
 public static function getInstance()
 {
     // $obj=null){
     if (!isset(self::$instance)) {
         if (!isset($obj)) {
             self::$instance = new TranslationManager_Instance();
         } else {
             self::$instance = $obj;
         }
     }
     return self::$instance;
 }
Example #7
0
 function JoukkueTieto($joukkueid, $tyyppi)
 {
     $this->joukkueid = $joukkueid;
     //$this->toiminto = &$toiminto;
     $this->tyyppi = $tyyppi;
     unset($this->maalienlkm);
     unset($this->rangaistustenlkm);
     unset($this->epaonnistuneidenlkm);
     unset($this->nimi);
     unset($this->peliid);
     $this->tm =& TranslationManager::instance();
     $this->select = array(array('-1', $this->tm->getText('Valitse pelaaja'), -1));
     $this->viewOnly = FALSE;
 }
Example #8
0
 function haeTiedot($joukkueid, $kausi = NULL)
 {
     $db = new Tietokanta();
     $db->open();
     $this->tiedot = $db->doQuery("SELECT j.lyhytnimi, j.pitkanimi, j.kuvaus, j.maskotti, j.email, j.logo, " . "s.nimi, s.perustamispvm, s.lisatieto FROM Joukkue j, Seura s WHERE joukkueid = {$joukkueid} and j.seuraid = s.seuraid");
     if ($kausi != NULL) {
         $logotiedot = $db->doQuery("SELECT logo " . " FROM kaudenjoukkue WHERE kausi = {$kausi} " . " and joukkueid = {$joukkueid}");
         if (count($logotiedot) > 0) {
             $this->tiedot[0]['logo'] = $logotiedot[0]['logo'];
         }
     }
     $this->tiedot = $this->tiedot[0];
     $db->close();
     $this->tm = TranslationManager::instance();
 }
Example #9
0
 function Controller()
 {
     global $DEFAULTLANGUAGE;
     // Yleinen joukkueid vaihtuu välillä
     if (!isset($_SESSION['joukkue'])) {
         $_SESSION['joukkue'] = $_SESSION['defaultjoukkue'];
     }
     // toiminto pino
     if (!isset($_SESSION['palaa'])) {
         $_SESSION['palaa'] = array();
         D("<br>ORJL<br>");
     }
     // yleinen kausi joka vaihtuu välilllä
     if (!isset($_SESSION['kausi'])) {
         $_SESSION['kausi'] = $_SESSION['defaultkausi'];
     }
     // yleinen sarjaID joka vaihtuu välilllä
     if (!isset($_SESSION['sarja'])) {
         $_SESSION['sarja'] = $_SESSION['defaultsarjaid'];
     }
     if (!isset($_SESSION['kaikkisarjat'])) {
         $_SESSION['kaikkisarjat'] = false;
     }
     // check language
     if (isset($_REQUEST['kieli'])) {
         $tm =& TranslationManager::instance();
         if ($tm->setLanguage($_REQUEST['kieli'])) {
             $_SESSION['lang'] = $_REQUEST['kieli'];
         }
     }
     if (!isset($_SESSION['lang'])) {
         $tm =& TranslationManager::instance();
         $tm->setLanguage($DEFAULTLANGUAGE);
     } else {
         $tm =& TranslationManager::instance();
         $tm->setLanguage($_SESSION['lang']);
     }
     unset($this->toiminto);
     unset($this->template);
 }
Example #10
0
 function Toiminto($toiminnonNimi)
 {
     $this->toiminnonNimi = $toiminnonNimi;
     unset($this->view);
     unset($this->db);
     unset($this->toiminnot);
     // ladataan vanhat tilatiedot sessiosta
     if (array_key_exists('tilat', $_SESSION)) {
         $this->tilat =& $_SESSION['tilat'];
     } else {
         $this->tilat = array();
         $_SESSION['tilat'] =& $this->tilat;
     }
     // check if user is in session
     if (isset($_SESSION['nimi']) and isset($_SESSION['salasana'])) {
         $this->LOGGED_IN = TRUE;
     } else {
         $this->LOGGED_IN = $this->readCookie();
     }
     $this->refreshlink = '';
     $this->insertedInDB = false;
     $this->asetaTila();
     $this->tm =& TranslationManager::instance();
 }
Example #11
0
 public static function echoMenuEntry($page)
 {
     echo '<li';
     if (HelperFunctions::getActivePage() == $page) {
         echo ' class="active"';
     }
     echo '><a href="./?page=' . $page . '">' . TranslationManager::getText($page) . '</a></li>';
 }
    }
    // new texture
    //TODO reimplement setting texture
    if (isset($_FILES['texture'])) {
        if (!file_exists($_FILES['texture']['tmp_name'])) {
            MessageManager::addWarning(tr('profile_texture_notempfile'));
        } else {
            $imgData = file_get_contents($_FILES['texture']['tmp_name']);
            ServerInterface::getInstance()->updateUserTexture($_SESSION['serverid'], $_SESSION['userid'], $imgData);
        }
    }
}
?>
<div id="content">
	<h1><?php 
echo TranslationManager::getText('profile_head');
?>
</h1>
	<form action="?page=profile&amp;action=doedit" method="post" style="width:420px;"<?php 
if (isset($_GET['action']) && $_GET['action'] == 'edit_texture') {
    echo ' enctype="multipart/form-data"';
}
?>
>
		<table class="fullwidth">
			<tr><?php 
// SERVER Information (not changeable)
?>
				<td class="formitemname"><?php 
echo tr('server');
?>
Example #13
0
 function addUser($srvid, $name, $password, $email = null)
 {
     try {
         $tmpServer = ServerInterface::getInstance()->getServer(intval($srvid));
         if (empty($tmpServer)) {
             echo 'Server could not be found.<br/>';
             die;
         }
         $reg = new MurmurRegistration($srvid, null, $name, $email, null, null, $password);
         $tmpUid = $tmpServer->registerUser($reg->toArray());
         echo TranslationManager::getInstance()->getText('doregister_success') . '<br/>';
     } catch (Murmur_InvalidServerException $exc) {
         // This is depreciated (murmur.ice)
         echo 'Invalid server. Please check your server selection.<br/><a onclick="history.go(-1); return false;" href="?page=register">go back</a><br/>If the problem persists, please contact a server admin or webmaster.<br/>';
     } catch (Murmur_ServerBootedException $exc) {
         echo 'Server is currently not running, but it has to to be able to register.<br/>Please contact a server admin';
     } catch (Murmur_InvalidUserException $exc) {
         echo 'The username you specified is probably already in use or invalid. Please try another one.<br/><a onclick="history.go(-1); return false;" href="?page=register">go back</a>';
     } catch (Ice_UnknownUserException $exc) {
         // This should not happen
         echo $exc->unknown . '<br/>';
         //			echo '<pre>'; var_dump($exc); echo '</pre>';
     }
 }
Example #14
0
table { font-family: tahoma, Verdana, Geneva, sans-serif; font-size: 7pt; border: 1px; border-style: solid; border-color: <? echo $bordercolor; ?>; }
.row { background-color: <? echo $normalcolor; ?>; border: 0px;}
a:link { color: <? echo $textcolor; ?>;  text-decoration: none; } 
a:visited { color: <? echo $textcolor; ?>;  text-decoration: none; } 
a:hover, a:active { color: <? echo $textcolor; ?>;  text-decoration: none; } 
img {border: 0;}
#bottomborder {border: <? echo $bordercolor;?>;border-style: solid;border-top-width: 0px;border-right-width: 0px;border-bottom-width: 1px;border-left-width: 0px}
.copy { text-align: center; color: <? echo $textcolor; ?>; font-family: tahoma, Verdana, Geneva, sans-serif;  font-size: 7pt; text-decoration: underline; }
//-->
</style>
</head>
<body>
*/
$files = array();
$dirs = array();
$tm = TranslationManager::instance();
clearstatcache();
$curDir = $HOMEDIR;
if (isset($_REQUEST['directory'])) {
    $path_parts = pathinfo($_REQUEST['directory']);
    //echo "$path_parts[basename]";
    /*echo $path_parts['dirname'], "<br>\n";
    echo $path_parts['basename'], "<br>\n";
    //echo $path_parts['extension'], "<br>\n";
    */
    if (substr_count($path_parts['dirname'] . "/", $HOMEDIR) == 1 and substr_count($path_parts['dirname'] . "/", "../") == 0 and $path_parts['basename'] != "..") {
        // double check
        $curDir = $path_parts['dirname'] . "/" . $path_parts['basename'] . "/";
    }
}
$PHP_SELF = basename(__FILE__);
    function view()
    {
        $lang = $this->_context[0];
        $extension = $this->_context[1];
        $isSymphony = empty($extension) || $extension == 'symphony';
        if (strlen($lang) < 1) {
            $this->setPageType('form');
            $this->pageAlert(__('Language code is required.'), Alert::ERROR);
            return;
        }
        $default = array('about' => array(), 'dictionary' => $this->_tm->defaultDictionary($extension), 'transliterations' => array());
        $warnings = array_shift($default['dictionary']);
        $translation = $this->_tm->get($lang, $extension);
        if (empty($translation)) {
            $translation = array('about' => array('name' => $lang), 'dictionary' => array(), 'transliterations' => array());
            // Try to find language name in other translations for selected language
            $others = $this->_tm->listExtensions($lang);
            foreach ($others as $t_ext) {
                $t_trans = $this->_tm->get($lang, $t_ext);
                if (!empty($t_trans['about']['name'])) {
                    $translation['about']['name'] = $t_trans['about']['name'];
                    break;
                }
            }
        }
        $dictionary = array();
        $translated = array_intersect_key(array_filter($translation['dictionary'], 'trim'), $default['dictionary']);
        $missing = array_diff_key($default['dictionary'], $translated);
        $obsolete = array_diff_key($translation['dictionary'], $default['dictionary']);
        if (is_array($translated) && count($translated) > 0) {
            $dictionary['%%%%%%TRANSLATED%%%%%%'] = '%%%%%%TRANSLATED%%%%%%';
            $dictionary += $translated;
        }
        if (is_array($missing) && count($missing) > 0) {
            $dictionary['%%%%%%MISSING%%%%%%'] = '%%%%%%MISSING%%%%%%';
            $dictionary += array_fill_keys(array_keys($missing), false);
        }
        if (is_array($obsolete) && count($obsolete) > 0) {
            $dictionary['%%%%%%OBSOLETE%%%%%%'] = '%%%%%%OBSOLETE%%%%%%';
            $dictionary += $obsolete;
        }
        if ((!is_array($translation['transliterations']) || empty($translation['transliterations'])) && $isSymphony) {
            $translation['transliterations'] = TranslationManager::defaultTransliterations();
        }
        if ($isSymphony) {
            $name = 'Symphony';
        } else {
            $temp = $this->_Parent->ExtensionManager->about($extension);
            $name = $temp['name'];
        }
        $path = $isSymphony ? TranslationManager::filePath($lang, 'symphony') : TranslationManager::filePath($lang, $extension);
        $file = basename($path);
        $path = str_replace(DOCROOT, '', dirname($path));
        $php = '<' . "?php\n\n";
        $php .= <<<END
/*
\tThis is translation file for {$name}.
\tTo make it available for Symphony installation, rename it {$file} and upload to {$path}/ directory on server.
*/

END;
        $php .= '$about = ' . var_export($translation['about'], true) . ";\n\n";
        $php .= <<<END
/*
\tDictionary array contains translations of texts (labels, guidelines, titles, etc...) used by Symphony.

\tThere are 3 states of translations:
\t- Translated: already used by Symphony,
\t- Missing: there was no translation available at the time of generating this template file,
\t- Obsolete: translated text which is no longer used by Symphony and can be removed from translation file.

\tTo add missing translations, simply scroll down to part of array marked as "// MISSING"
\tand change each "false" value into something like "'New translation of original text'"
\t(notice single quotes around translated text! Text has to be wrapped either by them or by double quotes).
\tSo instead of something like:

\t\t'Original text' =>
\t\tfalse,

\tYou'll have something like:

\t\t'Original text' =>
\t\t'Tekst oryginału',

\tYou should leave all parts of text which look like "%s" or "%1\$s" (usually there is "s" or "d" character there).
\tThey are placeholders for other text or HTML which will be put in their place when needed by Symphony.
\tYou can move them around inside translated text, but not remove them. For example:

\t\t'Original %s is here' =>
\t\t'Tu jest oryginalny %s'

\tPlaceholders with numbers inside them are used when there are more than one of them inside original text.
\tYou can switch their positions if needed, but do not change numbers into something else.
\tFor example text used in page titles looks like "Symphony - Language - English" and is generated with:

\t\t'%1\$s &ndash; %2\$s &ndash; %3\$s'

\tTo make titles look like "Language: English | Symphony" simply move placeholders around:

\t\t'%2\$s: %3\$s | %1\$s'
*/

END;
        $php .= '$dictionary = ' . str_replace(' => ', " =>\n  ", str_replace(",\n", ",\n\n", preg_replace('/\\n\\s+\'%%%%%%(TRANSLATED|MISSING|OBSOLETE)%%%%%%\'\\s+=>\\s+\'%%%%%%(\\1)%%%%%%\',\\n/', "\n// \\1\n", var_export($dictionary, true)))) . ";\n\n";
        $php .= <<<END
/*
\tTransliterations are used to generate handles of entry fields and filenames.
\tThey specify which characters (or bunch of characters) have to be changed, and what should be put into their place when entry or file is saved.
\tFor example:

\t\t'/_and_/' => '+',

\twill change every instance of "_and_" into "+", so:

\t\tme_and_family.jpg

\twill turn into:

\t\tme+family.jpg

\tPlease notice slashes at the beginning and end of original text. They are required there.
\tYou can change them into different character, but that character cannot be used inside original text or has to be escaped by backslash, like this:

\t\t'/original\\/path/' => 'new/path',

\tYou can use full syntax of regular expressions there too. Read more about it on: http://php.net/manual/en/regexp.reference.php

\tTransliterations are required only inside translations of Symphony. They are not needed for extensions.
*/

END;
        $php .= '$transliterations = ' . var_export($translation['transliterations'], true) . ";\n\n";
        $php .= '?>';
        if (!empty($php)) {
            header('Content-Type: application/x-php; charset=utf-8');
            header('Content-Disposition: attachment; filename="' . $extension . '-lang.' . $lang . '.php"');
            header("Content-Description: File Transfer");
            header("Cache-Control: no-cache, must-revalidate");
            header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
            echo trim($php);
            exit;
        }
    }
Example #16
0
 function exportZIP($lang)
 {
     require_once TOOLKIT . '/class.archivezip.php';
     $zip = new ArchiveZip();
     foreach ($this->_tm->listExtensions($lang) as $extension) {
         $path = TranslationManager::filePath($lang, $extension);
         if (!$zip->addFromFile($path, str_replace(DOCROOT, '', $path))) {
             $this->pageAlert(__('Cannot add <code>%s</code> to ZIP file. Please check file permissions.', array($path)), Alert::ERROR);
             return false;
         }
     }
     $data = $zip->save();
     if (!$data) {
         $this->pageAlert(__('Cannot generate ZIP data.'), Alert::ERROR);
         return false;
     }
     header('Content-Type: application/zip; charset=utf-8');
     header('Content-Disposition: attachment; filename="symphony-language-' . $lang . '.zip"');
     header("Content-Description: File Transfer");
     header("Cache-Control: no-cache, must-revalidate");
     header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
     echo $data;
     exit;
 }
 public function remove($lang, $name = NULL)
 {
     if ($name === NULL) {
         if (!$this->remove($lang, 'symphony')) {
             return false;
         }
         foreach ($this->_Parent->ExtensionManager->listAll() as $extension => $about) {
             if (!$this->remove($lang, $extension)) {
                 return false;
             }
         }
         return true;
     }
     $file = TranslationManager::filePath($lang, $name);
     if (file_exists($file) && !General::deleteFile($file)) {
         return false;
     }
     return true;
 }
Example #18
0
<?php

/**
 * Plugin Name: Automatic Translation
 * Description: Automatically translates all kinds of posts on save and links them for WPML
 * Version: 0.1
 * Author: Martin Schrimpf
 * Author URI: https://github.com/Meash
 * License: MIT
 */
require_once __DIR__ . '/activation.php';
require_once __DIR__ . '/TranslationManager.php';
$translator = new TranslationManager();
$translator->add_save_post_hook();
Example #19
0
 private function toXLIFF($lang, $extension, &$xliff)
 {
     $default = array('about' => array(), 'dictionary' => $this->_tm->defaultDictionary($extension), 'transliterations' => array());
     $warnings = array_shift($default['dictionary']);
     $translation = $this->_tm->get($lang, $extension);
     if (empty($translation)) {
         $translation = array('about' => array('name' => $lang), 'dictionary' => array(), 'transliterations' => array());
         // Try to find language name in other translations for selected language
         $others = $this->_tm->listExtensions($lang);
         foreach ($others as $t_ext) {
             $t_trans = $this->_tm->get($lang, $t_ext);
             if (!empty($t_trans['about']['name'])) {
                 $translation['about']['name'] = $t_trans['about']['name'];
                 break;
             }
         }
     }
     $file = new XMLElement('file');
     $file->setAttribute('original', basename(TranslationManager::filePath($lang, $extension)));
     $file->setAttribute('source-language', 'en');
     $file->setAttribute('target-language', $lang);
     $file->setAttribute('datatype', 'x-symphony');
     $file->setAttribute('xml:space', 'preserve');
     if ($extension) {
         $file->setAttribute('product-name', $extension);
     }
     if (is_array($temp = $this->_Parent->ExtensionManager->about($extension))) {
         $file->setAttribute('product-version', $temp['version']);
     }
     // TODO: Make sure that date is specified in valid format (http://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html#date)?
     if ($translation['about']['release-date']) {
         $file->setAttribute('date', $translation['about']['release-date']);
     }
     if ($translation['about']['name']) {
         $file->setAttribute('category', $translation['about']['name']);
     }
     $header = new XMLElement('header');
     $tool = new XMLElement('tool');
     $tool->setAttribute('tool-id', 'tm');
     $tool->setAttribute('tool-name', 'Symphony - Translation Manager');
     $tool->setAttribute('tool-version', '1.0');
     $header->appendChild($tool);
     if (is_array($translation['about']['author'])) {
         $group = new XMLElement('phase-group');
         $appended = 0;
         if (is_string($translation['about']['author']['name'])) {
             $temp = $translation['about']['author'];
             $translation['about']['author'][$temp['name']] = $temp;
         }
         foreach ($translation['about']['author'] as $name => $author) {
             if (!$author['name']) {
                 continue;
             }
             $phase = new XMLElement('phase');
             $phase->setAttribute('phase-name', $author['name']);
             $phase->setAttribute('phase-process', 'translation');
             $phase->setAttribute('tool-id', 'tm');
             if ($author['release-date']) {
                 $phase->setAttribute('date', $author['release-date']);
             }
             if ($author['name']) {
                 $phase->setAttribute('contact-name', $author['name']);
             }
             if ($author['email']) {
                 $phase->setAttribute('contact-email', $author['email']);
             }
             if ($author['website']) {
                 $phase->setAttribute('company-name', $author['website']);
             }
             $group->appendChild($phase);
             $appended++;
         }
         if ($appended) {
             $header->appendChild($group);
         }
     }
     $body = new XMLElement('body');
     $group = new XMLElement('group');
     $group->setAttribute('resname', 'dictionary');
     $sklDictionary = array();
     $translated = array_intersect_key(array_filter($translation['dictionary'], 'trim'), $default['dictionary']);
     foreach ($translated as $k => $v) {
         $sklDictionary[$k] = md5($k);
         $unit = new XMLElement('trans-unit');
         $unit->setAttribute('id', $sklDictionary[$k]);
         $unit->appendChild(new XMLElement('source', General::sanitize($k)));
         $unit->appendChild(new XMLElement('target', General::sanitize($v), array('state' => 'translated')));
         $group->appendChild($unit);
     }
     $missing = array_diff_key($default['dictionary'], $translated);
     foreach ($missing as $k => $v) {
         $sklDictionary[$k] = md5($k);
         $unit = new XMLElement('trans-unit');
         $unit->setAttribute('id', $sklDictionary[$k]);
         $unit->appendChild(new XMLElement('source', General::sanitize($k)));
         $unit->appendChild(new XMLElement('target', '', array('state' => 'new')));
         $group->appendChild($unit);
     }
     $obsolete = array_diff_key($translation['dictionary'], $default['dictionary']);
     foreach ($obsolete as $k => $v) {
         $sklDictionary[$k] = md5($k);
         $unit = new XMLElement('trans-unit');
         $unit->setAttribute('id', $sklDictionary[$k]);
         $unit->appendChild(new XMLElement('source', General::sanitize($k)));
         $unit->appendChild(new XMLElement('target', General::sanitize($v), array('state' => 'x-obsolete')));
         $group->appendChild($unit);
     }
     $body->appendChild($group);
     $group = new XMLElement('group');
     $group->setAttribute('resname', 'transliterations');
     $sklTransliterations = array();
     if (is_array($translation['transliterations']) && !empty($translation['transliterations'])) {
         foreach ($translation['transliterations'] as $k => $v) {
             $sklTransliterations[$k] = md5($k);
             $unit = new XMLElement('trans-unit');
             $unit->setAttribute('id', $sklTransliterations[$k]);
             $unit->appendChild(new XMLElement('source', General::sanitize($k)));
             $unit->appendChild(new XMLElement('target', General::sanitize($v), array('state' => 'translated')));
             $group->appendChild($unit);
         }
     } else {
         if ($extension == 'symphony' || empty($extension)) {
             foreach (TranslationManager::defaultTransliterations() as $k => $v) {
                 $sklTransliterations[$k] = md5($k);
                 $unit = new XMLElement('trans-unit');
                 $unit->setAttribute('id', $sklTransliterations[$k]);
                 $unit->appendChild(new XMLElement('source', General::sanitize($k)));
                 $unit->appendChild(new XMLElement('target', General::sanitize($v), array('state' => 'new')));
                 $group->appendChild($unit);
             }
         }
     }
     $body->appendChild($group);
     // Generate skeleton
     $skl = new XMLElement('skl');
     $translation['dictionary'] = $sklDictionary;
     $translation['transliterations'] = $sklTransliterations;
     $skl->appendChild(new XMLElement('internal-file', '<![CDATA[' . TranslationManager::toPHP($translation) . ']]>', array('form' => 'application/x-php')));
     $header->appendChild($skl);
     $file->appendChild($header);
     $file->appendChild($body);
     $xliff->appendChild($file);
 }
Example #20
0
 public static function meta_server_information_update()
 {
     $serverId = isset($_POST['serverid']) ? intval($_POST['serverid']) : null;
     // user has rights?
     if (PermissionManager::getInstance()->serverCanEditConf($serverId)) {
         if ($serverId != null && isset($_POST['name']) && isset($_POST['allowlogin']) && isset($_POST['allowregistration']) && isset($_POST['forcemail']) && isset($_POST['authbymail'])) {
             $serverId = intval($_POST['serverid']);
             $name = $_POST['name'];
             $allowLogin = $_POST['allowlogin'];
             $allowRegistration = $_POST['allowregistration'];
             $forcemail = $_POST['forcemail'];
             $authByMail = $_POST['authbymail'];
             SettingsManager::getInstance()->setServerInformation($serverId, $name, $allowLogin, $allowRegistration, $forcemail, $authByMail);
         } else {
             MessageManager::addError(TranslationManager::getInstance()->getText('error_missing_values'));
         }
     } else {
         MessageManager::addError('You don’t have permission to do this.');
     }
 }