Esempio n. 1
0
 /**
  * Toma el valor para el idioma.
  * @param optional string $lang     The language abbriviation.
  *
  * @access public
  *
  */
 function setLang($lang = null)
 {
     include_once Util::base_Path('include/classes/nls.inc.php');
     //Debug::oneVar($lang, __FILE__, __LINE__);
     if (empty($lang) || !NLS::isValid($lang)) {
         if (Session::getValue('lang') != null) {
             $lang = Session::getValue('lang');
         } else {
             if (Session::getContextValue('gettext_lang') != null) {
                 $lang = Session::getContextValue('gettext_lang');
             } else {
                 $lang = 'es_ES';
             }
         }
     }
     Session::setValue('language', $lang);
     //Debug::oneVar($lang, __FILE__, __LINE__);
     /* First try language with the current charset. */
     $lang_charset = $lang . '.' . NLS::getCharset();
     if ($lang_charset != setlocale(LC_ALL, $lang_charset)) {
         /* Next try language with its default charset. */
         global $nls;
         $charset = !empty($nls['charsets'][$lang]) ? $nls['charsets'][$lang] : $nls['defaults']['charset'];
         $lang_charset = $lang . '.' . $charset;
         NLS::_cachedCharset(0, $charset);
         if ($lang_charset != setlocale(LC_ALL, $lang_charset)) {
             /* At last try language solely. */
             $lang_charset = $lang;
             setlocale(LC_ALL, $lang_charset);
         }
     }
     @putenv('LANG=' . $lang_charset);
     @putenv('LANGUAGE=' . $lang_charset);
 }
Esempio n. 2
0
} else {
    $fileroot = $registry->getParam('fileroot', $module);
    $help_file = $fileroot . "/locale/{$language}/help.xml";
    $help_file_fallback = $fileroot . '/locale/en_US/help.xml';
}
if ($show == 'index') {
    require HORDE_TEMPLATES . '/help/index.inc';
} else {
    require HORDE_TEMPLATES . '/common-header.inc';
    if ($show == 'menu') {
        require HORDE_TEMPLATES . '/help/menu.inc';
    } elseif ($show == 'about') {
        require $fileroot . '/lib/version.php';
        eval('$version = "' . ucfirst($module) . ' " . ' . String::upper($module) . '_VERSION;');
        $credits = Util::bufferOutput('include', $fileroot . '/docs/CREDITS');
        $credits = String::convertCharset($credits, 'iso-8859-1', NLS::getCharset());
        require HORDE_TEMPLATES . '/help/about.inc';
    } else {
        require HORDE_TEMPLATES . '/help/header.inc';
        $help = new Help(HELP_SOURCE_FILE, array($help_file, $help_file_fallback));
        if ($show == 'entry' && !empty($topic)) {
            $help->lookup($topic);
            $help->display();
        } else {
            $topics = $help->topics();
            foreach ($topics as $id => $title) {
                $link = Horde::url($registry->getParam('webroot', 'horde') . '/services/help/');
                $link = Util::addParameter($link, array('show' => 'entry', 'module' => $module, 'topic' => $id));
                echo Horde::link($link, '', 'helpitem');
                echo $title . "</a><br />\n";
            }
Esempio n. 3
0
 /**
  * Export this component in vCal format.
  *
  * @param string $base
  *        	The type of the base object.
  *        	
  * @return string vCal format data.
  */
 function _exportvData($base = 'VCALENDAR')
 {
     $result = 'BEGIN:' . strtoupper($base) . $this->_newline;
     // VERSION is not allowed for entries enclosed in VCALENDAR/ICALENDAR,
     // as it is part of the enclosing VCALENDAR/ICALENDAR. See rfc2445
     if ($base !== 'VEVENT' && $base !== 'VTODO' && $base !== 'VALARM' && $base !== 'VJOURNAL' && $base !== 'VFREEBUSY') {
         // Ensure that version is the first attribute.
         $result .= 'VERSION:' . $this->_version . $this->_newline;
     }
     foreach ($this->_attributes as $attribute) {
         $name = $attribute['name'];
         if ($name == 'VERSION') {
             // Already done.
             continue;
         }
         $params_str = '';
         $params = $attribute['params'];
         if ($params) {
             foreach ($params as $param_name => $param_value) {
                 /* Skip CHARSET for iCalendar 2.0 data, not allowed. */
                 if ($param_name == 'CHARSET' && !$this->isOldFormat()) {
                     continue;
                 }
                 /* Skip VALUE=DATE for vCalendar 1.0 data, not allowed. */
                 if ($this->isOldFormat() && $param_name == 'VALUE' && $param_value == 'DATE') {
                     continue;
                 }
                 if ($param_value === null) {
                     $params_str .= ";{$param_name}";
                 } else {
                     $params_str .= ";{$param_name}={$param_value}";
                 }
             }
         }
         $value = $attribute['value'];
         switch ($name) {
             // Date fields.
             case 'COMPLETED':
             case 'CREATED':
             case 'DCREATED':
             case 'LAST-MODIFIED':
                 $value = $this->_exportDateTime($value);
                 break;
             case 'DTEND':
             case 'DTSTART':
             case 'DTSTAMP':
             case 'DUE':
             case 'AALARM':
             case 'RECURRENCE-ID':
                 if (isset($params['VALUE'])) {
                     if ($params['VALUE'] == 'DATE') {
                         $value = $this->_exportDate($value, $name == 'DTEND' ? '235959' : '000000');
                     } else {
                         $value = $this->_exportDateTime($value);
                     }
                 } else {
                     $value = $this->_exportDateTime($value);
                 }
                 break;
                 // Comma seperated dates.
             // Comma seperated dates.
             case 'EXDATE':
             case 'RDATE':
                 $dates = array();
                 foreach ($value as $date) {
                     if (isset($params['VALUE'])) {
                         if ($params['VALUE'] == 'DATE') {
                             $dates[] = $this->_exportDate($date, '000000');
                         } elseif ($params['VALUE'] == 'PERIOD') {
                             $dates[] = $this->_exportPeriod($date);
                         } else {
                             $dates[] = $this->_exportDateTime($date);
                         }
                     } else {
                         $dates[] = $this->_exportDateTime($date);
                     }
                 }
                 $value = implode(',', $dates);
                 break;
             case 'TRIGGER':
                 if (isset($params['VALUE'])) {
                     if ($params['VALUE'] == 'DATE-TIME') {
                         $value = $this->_exportDateTime($value);
                     } elseif ($params['VALUE'] == 'DURATION') {
                         $value = $this->_exportDuration($value);
                     }
                 } else {
                     $value = $this->_exportDuration($value);
                 }
                 break;
                 // Duration fields.
             // Duration fields.
             case 'DURATION':
                 $value = $this->_exportDuration($value);
                 break;
                 // Period of time fields.
             // Period of time fields.
             case 'FREEBUSY':
                 $value_str = '';
                 foreach ($value as $period) {
                     $value_str .= empty($value_str) ? '' : ',';
                     $value_str .= $this->_exportPeriod($period);
                 }
                 $value = $value_str;
                 break;
                 // UTC offset fields.
             // UTC offset fields.
             case 'TZOFFSETFROM':
             case 'TZOFFSETTO':
                 $value = $this->_exportUtcOffset($value);
                 break;
                 // Integer fields.
             // Integer fields.
             case 'PERCENT-COMPLETE':
             case 'PRIORITY':
             case 'REPEAT':
             case 'SEQUENCE':
                 $value = '$value';
                 break;
                 // Geo fields.
             // Geo fields.
             case 'GEO':
                 $value = $value['latitude'] . ',' . $value['longitude'];
                 break;
                 // Recurrence fields.
             // Recurrence fields.
             case 'EXRULE':
             case 'RRULE':
                 break;
             case 'ATTENDEE':
                 // Kronolith creates attendee field in vcalendar2.0 format.
                 // Convert to vcalendar1.0 if necessary.
                 // Example of 1.0 style:
                 // ATTENDEE;ROLE=OWNER;STATUS=CONFIRMED:John Smith <*****@*****.**>
                 if ($this->isOldFormat()) {
                     $value = preg_replace('/MAILTO:/i', '', $value);
                     $value = $value . ' <' . $value . '>';
                     $params_str = str_replace('PARTSTAT=', 'STATUS=', $params_str);
                     $params_str = str_replace('STATUS=NEEDS-ACTION', 'STATUS=NEEDS ACTION', $params_str);
                     $params_str = str_replace('ROLE=REQ-PARTICIPANT', 'EXPECT=REQUIRE', $params_str);
                     $params_str = str_replace('ROLE=OPT-PARTICIPANT', 'EXPECT=REQUEST', $params_str);
                     $params_str = str_replace('ROLE=NON-PARTICIPANT', 'EXPECT=FYI', $params_str);
                     $params_str = str_replace('RSVP=TRUE', 'RSVP=YES', $params_str);
                     $params_str = str_replace('RSVP=FALSE', 'RSVP=NO', $params_str);
                 }
                 break;
             default:
                 if ($this->isOldFormat()) {
                     if (is_array($attribute['values']) && count($attribute['values']) > 1) {
                         $values = $attribute['values'];
                         if ($name == 'N' || $name == 'ADR' || $name == 'ORG') {
                             $glue = ';';
                         } else {
                             $glue = ',';
                         }
                         $values = str_replace(';', '\\;', $values);
                         $value = implode($glue, $values);
                     } else {
                         /*
                          * vcard 2.1 and vcalendar 1.0 escape only semicolons
                          */
                         $value = str_replace(';', '\\;', $value);
                     }
                     if ($name == 'STATUS') {
                         // vcalendar 1.0 has STATUS:NEEDS ACTION while 2.0 has
                         // STATUS:NEEDS-ACTION.
                         $value = str_replace('NEEDS-ACTION', 'NEEDS ACTION', $value);
                     }
                     // Text containing newlines or ASCII >= 127 must be BASE64
                     // or QUOTED-PRINTABLE encoded. Currently we use
                     // QUOTED-PRINTABLE as default.
                     // FIXME: deal with base64 encodings!
                     if (preg_match("/[^ -\r\n]/", $value) && empty($params['ENCODING'])) {
                         $params['ENCODING'] = 'QUOTED-PRINTABLE';
                         $params_str .= ';ENCODING=QUOTED-PRINTABLE';
                         // Add CHARSET as well. At least the synthesis client
                         // gets confused otherwise
                         if (empty($params['CHARSET'])) {
                             $params['CHARSET'] = NLS::getCharset();
                             $params_str .= ';CHARSET=' . $params['CHARSET'];
                         }
                     }
                 } else {
                     if (is_array($attribute['values']) && count($attribute['values']) > 1) {
                         $values = $attribute['values'];
                         if ($name == 'N' || $name == 'ADR' || $name == 'ORG') {
                             $glue = ';';
                         } else {
                             $glue = ',';
                         }
                         // As of rfc 2426 2.5 semicolon and comma must be
                         // escaped.
                         $values = str_replace(array(';', ',', '\\'), array('\\;', '\\,', '\\\\'), $values);
                         $value = implode($glue, $values);
                     } else {
                         // As of rfc 2426 2.5 semicolon and comma must be
                         // escaped.
                         $value = str_replace(array(';', ',', '\\'), array('\\;', '\\,', '\\\\'), $value);
                     }
                 }
                 break;
         }
         if (!empty($params['ENCODING']) && $params['ENCODING'] == 'QUOTED-PRINTABLE' && strlen(trim($value)) > 0) {
             $value = str_replace('\\r', '', $value);
             /*
              * quotedPrintableEncode does not escape CRLFs, but strange enough single LFs. so convert everything to LF only and replace afterwards.
              */
             $result .= $name . $params_str . ':=' . $this->_newline . str_replace('=0A', '=0D=0A', $this->_quotedPrintableEncode($value)) . $this->_newline;
         } else {
             $attr_string = $name . $params_str . ':' . $value;
             $result .= $this->_foldLine($attr_string) . $this->_newline;
         }
     }
     foreach ($this->_components as $component) {
         $result .= $component->exportvCalendar();
     }
     return $result . 'END:' . $base . $this->_newline;
 }
Esempio n. 4
0
 /**
  * Highlights an access key in a label.
  *
  * @param string $label      The label to highlight the access key in.
  * @param string $accessKey  The access key to highlight.
  *
  * @return string  The HTML version of the label with the access key
  *                 highlighted.
  */
 function highlightAccessKey($label, $accessKey)
 {
     $stripped_label = Horde::stripAccessKey($label);
     if (empty($accessKey)) {
         return $stripped_label;
     }
     if (isset($GLOBALS['nls']['multibyte'][NLS::getCharset(true)])) {
         /* Prefix parenthesis with the UTF-8 representation of the LRO
          * (Left-to-Right-Override) Unicode codepoint U+202D. */
         $prefix = NLS::getCharset() == 'UTF-8' ? "‭" : '';
         return $stripped_label . $prefix . '(<span class="accessKey">' . strtoupper($accessKey) . '</span>' . ')';
     } else {
         return str_replace('_' . $accessKey, '<span class="accessKey">' . $accessKey . '</span>', $label);
     }
 }
Esempio n. 5
0
    }
    $url = Horde::applicationUrl('admin/setup/index.php', true);
    header('Location: ' . $url);
    exit;
}
$data = '';
if ($setup == 'conf' && $type == 'php') {
    /* A bit ugly here, save PHP code into a string for creating the script
     * to be run at the command prompt. */
    $data = '#!/usr/local/bin/php' . "\n";
    $data .= '<?php' . "\n";
    foreach ($_SESSION['_config'] as $app => $php) {
        $path = $registry->getParam('fileroot', $app) . '/config';
        $data .= 'if ($fp = @fopen(\'' . $path . '/conf.php\', \'w\')) {' . "\n";
        $data .= '    fwrite($fp, \'';
        $data .= String::convertCharset(addslashes($php), NLS::getCharset(), 'iso-8859-1');
        $data .= '\');' . "\n";
        $data .= '    fclose($fp);' . "\n";
        $data .= '    echo \'' . sprintf(_("Saved %s configuration."), $app) . '\' . "\\n";' . "\n";
        $data .= '} else {' . "\n";
        $data .= '    echo \'' . sprintf(_("Could not save %s configuration."), $app) . '\' . "\\n";' . "\n";
        $data .= '}' . "\n\n";
    }
}
if ($save == 'tmp') {
    $tmp_dir = Horde::getTempDir();
    /* Add self-destruct code. */
    $data .= 'echo \'Self-destructing...\' . "\\n";' . "\n";
    $data .= 'if (unlink(__FILE__)) {' . "\n";
    $data .= '    echo \'' . _("Upgrade script deleted.") . '\' . "\\n";' . "\n";
    $data .= '} else {' . "\n";
Esempio n. 6
0
 array_unshift($_SESSION['_sql_query_cache'], $command);
 while (count($_SESSION['_sql_query_cache']) > 20) {
     array_pop($_SESSION['_sql_query_cache']);
 }
 echo '<div class="header">' . _("SQL Query") . ':</div><br />';
 echo '<table cellpadding="4" border="0"><tr><td class="text"><pre>' . htmlspecialchars($command) . '</pre></td></tr></table>';
 echo '<br /><div class="header">' . _("Results") . ':</div><br />';
 echo '<table cellpadding="2" border="0"><tr><td class="control">';
 // Parse out the query results.
 $dbh =& DB::connect($conf['sql']);
 if (is_a($dbh, 'PEAR_Error')) {
     echo '<pre>';
     var_dump($dbh);
     echo '</pre>';
 } else {
     $result = $dbh->query(String::convertCharset($command, NLS::getCharset(), $conf['sql']['charset']));
     if (is_a($result, 'PEAR_Error')) {
         echo '<pre>';
         var_dump($result);
         echo '</pre>';
     } else {
         if (is_object($result)) {
             echo '<table border="0" cellpadding="1" cellspacing="1">';
             $first = true;
             $i = 0;
             while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) {
                 if ($first) {
                     echo '<tr>';
                     foreach ($row as $key => $val) {
                         echo '<th align="left">' . (empty($key) ? '&nbsp;' : htmlspecialchars(String::convertCharset($key, $conf['sql']['charset']))) . '</th>';
                     }
Esempio n. 7
0
 function appConfig($is_config_ok)
 {
     if ($is_config_ok) {
         $run_config = $this->cli->prompt(_("All the installed applications seem to be configured, reconfigure any app?"), array('y' => _("Yes"), 'n' => _("No")));
         if ($run_config == 'n') {
             return true;
         }
     }
     global $registry;
     $applist = $registry->listApps(array('hidden', 'notoolbar', 'active'));
     sort($applist);
     $apps = array(0 => _("All applications"));
     foreach ($applist as $app) {
         if (@file_exists($registry->getParam('fileroot', $app) . '/config/conf.xml')) {
             array_push($apps, $app);
         }
     }
     $apps = $apps + array('x' => 'exit');
     $app_choice = $this->cli->prompt(_("Which app do you wish to reconfigure?"), $apps);
     if ($app_choice == 'x') {
         return true;
     }
     if ($app_choice > 0) {
         $apps = array($apps[$app_choice]);
     } else {
         $apps = array_slice($apps, 1, count($apps) - 2);
     }
     $vars = Variables::getDefaultVariables();
     foreach ($apps as $app) {
         $config =& new Horde_Config($app);
         $php = $config->generatePHPConfig($vars);
         $fp = @fopen($registry->getParam('fileroot', $app) . '/config/conf.php', 'w');
         if ($fp) {
             fwrite($fp, String::convertCharset($php, NLS::getCharset(), 'iso-8859-1'));
             fclose($fp);
             $this->log(sprintf(_("Wrote configuration file '%s'."), $registry->getParam('fileroot', $app) . '/config/conf.php'), 'success');
         } else {
             $this->log(sprintf(_("Can not write configuration file '%s'."), $registry->getParam('fileroot', $app) . '/config/conf.php'), 'error');
         }
     }
 }
Esempio n. 8
0
    $url = Horde::applicationUrl('admin/setup/index.php', true);
    header('Location: ' . $url);
    exit;
}
$vars = Variables::getDefaultVariables();
$form =& new ConfigForm($vars, $app);
$form->setTitle($title);
$form->setButtons(sprintf(_("Generate %s Configuration"), $appname));
$php = '';
if ($form->validate($vars)) {
    $config =& new Horde_Config($app);
    $php = $config->generatePHPConfig($vars);
    $path = $registry->getParam('fileroot', $app) . '/config';
    if ($fp = @fopen($path . '/conf.php', 'w')) {
        /* Can write, so output to file. */
        fwrite($fp, String::convertCharset($php, NLS::getCharset(), 'iso-8859-1'));
        fclose($fp);
        $notification->push(sprintf(_("Successfully wrote %s"), $path . '/conf.php'), 'horde.success');
    } else {
        /* Can not write. */
        $notification->push(sprintf(_("Writing not possible. You can either use the available upgrade script or copy manually the code below to %s."), $path . '/conf.php'), 'horde.warning');
        /* Save to session. */
        $_SESSION['_config'][$app] = $php;
    }
}
/* Render the configuration form. */
require_once HORDE_LIBS . 'Horde/UI/VarRenderer.php';
$renderer =& new Horde_Form_Renderer();
$renderer->setAttrColumnWidth('50%');
$form = Util::bufferOutput(array($form, 'renderActive'), $renderer, $vars, 'config.php', 'post');
/* Set up the template. */
 /**
  * Define la estructura global de la página
  *
  */
 function body_content()
 {
     $this->set_body_attributes("bgcolor=\"yellow\"");
     //add the header area
     $this->add(html_comment("Header block begins"));
     $this->add($this->header_block());
     $this->add(html_comment("Header block ends"));
     //add it to the page
     //build the outer wrapper div
     //that everything will live under
     $wrapper_div = html_div();
     $wrapper_div->set_id("mainarea");
     //add the main body
     $wrapper_div->add(html_comment("Main block begins"));
     NLS::setTextdomain($this->registry->gettextDomain(), Util::formatPath(MIGUELGETTEXT_DIR), NLS::getCharset());
     $wrapper_div->add($this->main_block());
     $wrapper_div->add(html_comment("Main block ends"));
     $this->add($wrapper_div);
 }
Esempio n. 10
0
 /**
  * Elimina de la pila el módulo, restaurando el siguiente módulo en la pila.
  *
  * @return string  The name of the application that was popped.
  *
  * @access public
  */
 function popApp()
 {
     /* Pop the current application off of the stack. */
     if (count($this->_appStack) > 1) {
         $previous = array_pop($this->_appStack);
         /* Import the new active application's configuration values
            and set the gettext domain and the preferred language. */
         $this->_currentApp = count($this->_appStack) ? end($this->_appStack) : null;
         if ($this->_currentApp) {
             NLS::setLang();
             NLS::setTextdomain($this->modules[$this->_currentApp]['gettext'], Util::formatPath(MIGUELGETTEXT_DIR), NLS::getCharset());
         }
     }
 }
Esempio n. 11
0
 function formatLogMessage($log)
 {
     global $conf;
     $log = Text::toHTML($log, TEXT_HTML_MICRO, NLS::getCharset(), null);
     if (!empty($conf['tickets']['regexp']) && !empty($conf['tickets']['replacement'])) {
         $log = preg_replace($conf['tickets']['regexp'], $conf['tickets']['replacement'], $log);
     }
     return $log;
 }