Exemplo n.º 1
0
 public function trans($key)
 {
     global $conf;
     if (!empty($this->tab_translate[$key])) {
         $str = $this->tab_translate[$key];
         // Overwrite translation (TODO Move this at a higher level when we load tab_translate to avoid doing it for each trans call)
         $overwritekey = 'MAIN_OVERWRITE_TRANS_' . $this->defaultlang;
         if (!empty($conf->global->{$overwritekey})) {
             $tmparray = explode(',', $conf->global->{$overwritekey});
             foreach ($tmparray as $tmp) {
                 $tmparray2 = explode(':', $tmp);
                 if ($tmparray2[0] == $key) {
                     $str = $tmparray2[1];
                     break;
                 }
             }
         }
         // We replace some HTML tags by __xx__ to avoid having them encoded by htmlentities
         $str = str_replace(array('<', '>', '"'), array('__lt__', '__gt__', '__quot__'), $str);
         // Crypt string into HTML
         $str = htmlentities($str, ENT_QUOTES, $this->charset_output);
         // Restore HTML tags
         $str = str_replace(array('__lt__', '__gt__', '__quot__'), array('<', '>', '"'), $str);
         return $str;
     } else {
         if ($key[0] == '$') {
             return dol_eval($key, 1);
         }
         return $this->getTradFromKey($key);
     }
 }
Exemplo n.º 2
0
    // Position
    print '<tr><td>' . $langs->trans('Position') . '</td><td><input type="text" size="5" name="position" value="' . $menu->position . '"></td><td>' . $langs->trans('DetailPosition') . '</td></tr>';
    // Target
    print '<tr><td>' . $langs->trans('Target') . '</td><td><select class="flat" name="target">';
    print '<option value=""' . ($menu->target == "" ? ' selected' : '') . '>' . $langs->trans('') . '</option>';
    print '<option value="_blank"' . ($menu->target == "_blank" ? ' selected' : '') . '>' . $langs->trans('_blank') . '</option>';
    print '</select></td><td>' . $langs->trans('DetailTarget') . '</td></tr>';
    // Enabled
    print '<tr><td>' . $langs->trans('Enabled') . '</td><td><input type="text" size="60" name="enabled" value="' . dol_escape_htmltag($menu->enabled) . '"></td><td>' . $langs->trans('DetailEnabled');
    if (!empty($menu->enabled)) {
        print ' (' . $langs->trans("ConditionIsCurrently") . ': ' . yn(dol_eval($menu->enabled, 1)) . ')';
    }
    print '</td></tr>';
    // Perms
    print '<tr><td>' . $langs->trans('Rights') . '</td><td><input type="text" size="60" name="perms" value="' . dol_escape_htmltag($menu->perms) . '"></td><td>' . $langs->trans('DetailRight');
    if (!empty($menu->perms)) {
        print ' (' . $langs->trans("ConditionIsCurrently") . ': ' . yn(dol_eval($menu->perms, 1)) . ')';
    }
    print '</td></tr>';
    print '</table>';
    // Bouton
    print '<br><div class="center">';
    print '<input type="submit" class="button" name="save" value="' . $langs->trans("Save") . '">';
    print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
    print '<input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
    print '</div>';
    print '</form>';
    print '<br>';
}
$db->close();
llxFooter();
Exemplo n.º 3
0
/**
 * Verify if condition in string is ok or not
 * @param 	string 		$strRights
 * @return 	boolean		true or false
 */
function verifCond($strRights)
{
    global $user, $conf, $langs;
    global $leftmenu;
    global $rights;
    // To export to dol_eval function
    //print $strRights."<br>\n";
    $rights = true;
    if ($strRights != '') {
        //$tab_rights = explode('&&', $strRights);
        //$i = 0;
        //while (($i < count($tab_rights)) && ($rights == true)) {
        $str = 'if(!(' . $strRights . ')) { $rights = false; }';
        dol_eval($str);
        //	$i++;
        //}
    }
    return $rights;
}
Exemplo n.º 4
0
 /**
  *  Return translated value of a text string
  *               Si il n'y a pas de correspondance pour ce texte, on cherche dans fichier alternatif
  *               et si toujours pas trouve, il est retourne tel quel.
  *               No convert to encoding charset of lang object is done.
  *               Parameters of this method must not contains any HTML tags.
  *
  *  @param	string	$key        Key to translate
  *  @param  string	$param1     chaine de param1
  *  @param  string	$param2     chaine de param2
  *  @param  string	$param3     chaine de param3
  *  @param  string	$param4     chaine de param4
  *  @return string      		Translated string
  */
 function transnoentitiesnoconv($key, $param1 = '', $param2 = '', $param3 = '', $param4 = '')
 {
     global $conf;
     if (!empty($this->tab_translate[$key])) {
         $str = $this->tab_translate[$key];
         // Overwrite translation
         $overwritekey = 'MAIN_OVERWRITE_TRANS_' . $this->defaultlang;
         if (!empty($conf->global->{$overwritekey})) {
             $tmparray = explode(',', $conf->global->{$overwritekey});
             foreach ($tmparray as $tmp) {
                 $tmparray2 = explode(':', $tmp);
                 if ($tmparray2[0] == $key) {
                     $str = $tmparray2[1];
                     break;
                 }
             }
         }
         if (!preg_match('/^Format/', $key)) {
             //print $str;
             $str = sprintf($str, $param1, $param2, $param3, $param4);
             // Replace %s and %d except for FormatXXX strings.
         }
         return $str;
     } else {
         if ($key[0] == '$') {
             return dol_eval($key, 1);
         }
         return $this->getTradFromKey($key);
     }
 }
Exemplo n.º 5
0
 /**
  *  Return translated value of a text string
  *               Si il n'y a pas de correspondance pour ce texte, on cherche dans fichier alternatif
  *               et si toujours pas trouve, il est retourne tel quel.
  *               No convert to encoding charset of lang object is done.
  *               Parameters of this method must not contains any HTML tags.
  *
  *  @param	string	$key        Key to translate
  *  @param  string	$param1     chaine de param1
  *  @param  string	$param2     chaine de param2
  *  @param  string	$param3     chaine de param3
  *  @param  string	$param4     chaine de param4
  *  @return string      		Translated string
  */
 function transnoentitiesnoconv($key, $param1 = '', $param2 = '', $param3 = '', $param4 = '')
 {
     global $conf;
     if (!empty($this->tab_translate[$key])) {
         $str = $this->tab_translate[$key];
         // Make some string replacement after translation
         $replacekey = 'MAIN_REPLACE_TRANS_' . $this->defaultlang;
         if (!empty($conf->global->{$replacekey})) {
             $tmparray = explode(';', $conf->global->{$replacekey});
             foreach ($tmparray as $tmp) {
                 $tmparray2 = explode(':', $tmp);
                 $str = preg_replace('/' . preg_quote($tmparray2[0]) . '/', $tmparray2[1], $str);
             }
         }
         if (!preg_match('/^Format/', $key)) {
             //print $str;
             $str = sprintf($str, $param1, $param2, $param3, $param4);
             // Replace %s and %d except for FormatXXX strings.
         }
         return $str;
     } else {
         if ($key[0] == '$') {
             return dol_eval($key, 1);
         }
         return $this->getTradFromKey($key);
     }
 }