コード例 #1
0
/**
 * Returns a transcoded and trimmed string
 *
 * @param string
 * @return string
 * @author ndiechburg <*****@*****.**>
 * */
function extldap_purify_string($string)
{
    global $extldap_config;
    if (isset($extldap_config['encoding'])) {
        return trim(api_to_system_encoding($string, $extldap_config['encoding']));
    } else {
        return trim($string);
    }
}
コード例 #2
0
 /**
  * Converts to the system encoding all the language-sensitive fields in the imported course.
  */
 public function to_system_encoding()
 {
     foreach ($this->resources as $type => &$resources) {
         if (count($resources) > 0) {
             foreach ($resources as &$resource) {
                 switch ($type) {
                     case RESOURCE_ANNOUNCEMENT:
                         $resource->title = api_to_system_encoding($resource->title, $this->encoding);
                         $resource->content = api_to_system_encoding($resource->content, $this->encoding);
                         break;
                     case RESOURCE_DOCUMENT:
                         $resource->title = api_to_system_encoding($resource->title, $this->encoding);
                         $resource->comment = api_to_system_encoding($resource->comment, $this->encoding);
                         break;
                     case RESOURCE_EVENT:
                         $resource->title = api_to_system_encoding($resource->title, $this->encoding);
                         $resource->content = api_to_system_encoding($resource->content, $this->encoding);
                         break;
                     case RESOURCE_FORUM:
                         $resource->title = api_to_system_encoding($resource->title, $this->encoding);
                         $resource->description = api_to_system_encoding($resource->description, $this->encoding);
                         break;
                     case RESOURCE_FORUMCATEGORY:
                         $resource->title = api_to_system_encoding($resource->title, $this->encoding);
                         $resource->description = api_to_system_encoding($resource->description, $this->encoding);
                         break;
                     case RESOURCE_FORUMPOST:
                         $resource->title = api_to_system_encoding($resource->title, $this->encoding);
                         $resource->text = api_to_system_encoding($resource->text, $this->encoding);
                         $resource->poster_name = api_to_system_encoding($resource->poster_name, $this->encoding);
                         break;
                     case RESOURCE_FORUMTOPIC:
                         $resource->title = api_to_system_encoding($resource->title, $this->encoding);
                         $resource->topic_poster_name = api_to_system_encoding($resource->topic_poster_name, $this->encoding);
                         $resource->title_qualify = api_to_system_encoding($resource->title_qualify, $this->encoding);
                         break;
                     case RESOURCE_GLOSSARY:
                         $resource->name = api_to_system_encoding($resource->name, $this->encoding);
                         $resource->description = api_to_system_encoding($resource->description, $this->encoding);
                         break;
                     case RESOURCE_LEARNPATH:
                         $resource->name = api_to_system_encoding($resource->name, $this->encoding);
                         $resource->description = api_to_system_encoding($resource->description, $this->encoding);
                         $resource->content_maker = api_to_system_encoding($resource->content_maker, $this->encoding);
                         $resource->content_license = api_to_system_encoding($resource->content_license, $this->encoding);
                         break;
                     case RESOURCE_LINK:
                         $resource->title = api_to_system_encoding($resource->title, $this->encoding);
                         $resource->description = api_to_system_encoding($resource->description, $this->encoding);
                         break;
                     case RESOURCE_LINKCATEGORY:
                         $resource->title = api_to_system_encoding($resource->title, $this->encoding);
                         $resource->description = api_to_system_encoding($resource->description, $this->encoding);
                         break;
                     case RESOURCE_QUIZ:
                         $resource->title = api_to_system_encoding($resource->title, $this->encoding);
                         $resource->description = api_to_system_encoding($resource->description, $this->encoding);
                         break;
                     case RESOURCE_QUIZQUESTION:
                         $resource->question = api_to_system_encoding($resource->question, $this->encoding);
                         $resource->description = api_to_system_encoding($resource->description, $this->encoding);
                         if (is_array($resource->answers) && count($resource->answers) > 0) {
                             foreach ($resource->answers as $index => &$answer) {
                                 $answer['answer'] = api_to_system_encoding($answer['answer'], $this->encoding);
                                 $answer['comment'] = api_to_system_encoding($answer['comment'], $this->encoding);
                             }
                         }
                         break;
                     case RESOURCE_TEST_CATEGORY:
                         $resource->title = api_to_system_encoding($resource->title, $this->encoding);
                         $resource->description = api_to_system_encoding($resource->description, $this->encoding);
                         break;
                     case RESOURCE_SCORM:
                         $resource->title = api_to_system_encoding($resource->title, $this->encoding);
                         break;
                     case RESOURCE_SURVEY:
                         $resource->title = api_to_system_encoding($resource->title, $this->encoding);
                         $resource->subtitle = api_to_system_encoding($resource->subtitle, $this->encoding);
                         $resource->author = api_to_system_encoding($resource->author, $this->encoding);
                         $resource->intro = api_to_system_encoding($resource->intro, $this->encoding);
                         $resource->surveythanks = api_to_system_encoding($resource->surveythanks, $this->encoding);
                         break;
                     case RESOURCE_SURVEYQUESTION:
                         $resource->survey_question = api_to_system_encoding($resource->survey_question, $this->encoding);
                         $resource->survey_question_comment = api_to_system_encoding($resource->survey_question_comment, $this->encoding);
                         break;
                     case RESOURCE_TOOL_INTRO:
                         $resource->intro_text = api_to_system_encoding($resource->intro_text, $this->encoding);
                         break;
                     case RESOURCE_WIKI:
                         $resource->title = api_to_system_encoding($resource->title, $this->encoding);
                         $resource->content = api_to_system_encoding($resource->content, $this->encoding);
                         $resource->reflink = api_to_system_encoding($resource->reflink, $this->encoding);
                         break;
                     case RESOURCE_WORK:
                         $resource->url = api_to_system_encoding($resource->url, $this->encoding);
                         $resource->title = api_to_system_encoding($resource->title, $this->encoding);
                         $resource->description = api_to_system_encoding($resource->description, $this->encoding);
                         break;
                     default:
                         break;
                 }
             }
         }
     }
     $this->encoding = api_get_system_encoding();
 }
コード例 #3
0
 if (api_is_multiple_url_enabled()) {
     $access_url_id = api_get_current_access_url_id();
     if ($access_url_id != -1) {
         $url_info = api_get_access_url($access_url_id);
         $url = api_remove_trailing_slash(preg_replace('/https?:\\/\\//i', '', $url_info['url']));
         $clean_url = api_replace_dangerous_char($url);
         $clean_url = str_replace('/', '-', $clean_url);
         $clean_url .= '/';
         $home_old = api_get_path(SYS_APP_PATH) . 'home/';
         $home = api_get_path(SYS_APP_PATH) . 'home/' . $clean_url;
     }
 }
 if (file_exists($home . 'register_top_' . $user_selected_language . '.html')) {
     $home_top_temp = @(string) file_get_contents($home . 'register_top_' . $user_selected_language . '.html');
     $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
     $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
     if (!empty($open)) {
         $content = '<div class="well_border">' . $open . '</div>';
     }
 }
 // Forbidden to self-register
 if ($isNotAllowedHere) {
     api_not_allowed(true, get_lang('RegistrationDisabled'));
 }
 if (api_get_setting('registration.allow_registration') == 'approval') {
     $content .= Display::return_message(get_lang('YourAccountHasToBeApproved'));
 }
 //if openid was not found
 if (!empty($_GET['openid_msg']) && $_GET['openid_msg'] == 'idnotfound') {
     $content .= Display::return_message(get_lang('OpenIDCouldNotBeFoundPleaseRegister'));
 }
コード例 #4
0
/**
 * Returns formatted date/time, correspondent to a given language.
 * The given date should be in the timezone chosen by the administrator and/or user. Use api_get_local_time to get it.
 *
 * @author Patrick Cool <*****@*****.**>, Ghent University
 * @author Christophe Gesche<*****@*****.**>
 *         originally inspired from from PhpMyAdmin
 * @author Ivan Tcholakov, 2009, code refactoring, adding support for predefined date/time formats.
 * @author Guillaume Viguier <*****@*****.**>
 *
 * @param mixed Timestamp or datetime string
 * @param mixed Date format (string or int; see date formats in the Chamilo system: TIME_NO_SEC_FORMAT, DATE_FORMAT_SHORT, DATE_FORMAT_LONG, DATE_TIME_FORMAT_LONG)
 * @param string $language (optional)        Language indentificator. If it is omited, the current interface language is assumed.
 * @return string                            Returns the formatted date.
 *
 * @link http://php.net/manual/en/function.strftime.php
 */
function api_format_date($time, $format = null, $language = null)
{
    if (is_string($time)) {
        $time = strtotime($time);
    }
    if (is_null($format)) {
        $format = DATE_TIME_FORMAT_LONG;
    }
    $datetype = null;
    $timetype = null;
    if (is_int($format)) {
        switch ($format) {
            case DATE_FORMAT_ONLY_DAYNAME:
                $datetype = IntlDateFormatter::SHORT;
                $timetype = IntlDateFormatter::NONE;
                break;
            case DATE_FORMAT_NUMBER_NO_YEAR:
                $datetype = IntlDateFormatter::SHORT;
                $timetype = IntlDateFormatter::NONE;
                break;
            case DATE_FORMAT_NUMBER:
                $datetype = IntlDateFormatter::SHORT;
                $timetype = IntlDateFormatter::NONE;
                break;
            case TIME_NO_SEC_FORMAT:
                $datetype = IntlDateFormatter::NONE;
                $timetype = IntlDateFormatter::SHORT;
                break;
            case DATE_FORMAT_SHORT:
                $datetype = IntlDateFormatter::LONG;
                $timetype = IntlDateFormatter::NONE;
                break;
            case DATE_FORMAT_LONG:
                $datetype = IntlDateFormatter::FULL;
                $timetype = IntlDateFormatter::NONE;
                break;
            case DATE_TIME_FORMAT_LONG:
                $datetype = IntlDateFormatter::FULL;
                $timetype = IntlDateFormatter::SHORT;
                break;
            case DATE_FORMAT_LONG_NO_DAY:
                $datetype = IntlDateFormatter::FULL;
                $timetype = IntlDateFormatter::SHORT;
                break;
            case DATE_TIME_FORMAT_SHORT:
                $datetype = IntlDateFormatter::FULL;
                $timetype = IntlDateFormatter::SHORT;
                break;
            case DATE_TIME_FORMAT_SHORT_TIME_FIRST:
                $datetype = IntlDateFormatter::FULL;
                $timetype = IntlDateFormatter::SHORT;
                break;
            case DATE_TIME_FORMAT_LONG_24H:
                $datetype = IntlDateFormatter::FULL;
                $timetype = IntlDateFormatter::SHORT;
                break;
            default:
                $datetype = IntlDateFormatter::FULL;
                $timetype = IntlDateFormatter::SHORT;
        }
    }
    // Use ICU
    if (is_null($language)) {
        $language = api_get_language_isocode();
    }
    $date_formatter = new IntlDateFormatter($language, $datetype, $timetype, date_default_timezone_get());
    $formatted_date = api_to_system_encoding($date_formatter->format($time), 'UTF-8');
    return $formatted_date;
}
コード例 #5
0
 /**
  * Return the homepage, including announcements
  * @return string The portal's homepage as an HTML string
  * @assert () != ''
  */
 public function returnHomePage()
 {
     // Including the page for the news
     $html = null;
     $home = api_get_path(SYS_DATA_PATH) . api_get_home_path();
     $home_top_temp = null;
     if (!empty($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\\.html$/', $_GET['include'])) {
         $open = @(string) file_get_contents(api_get_path(SYS_PATH) . $home . $_GET['include']);
         $html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
     } else {
         $user_selected_language = api_get_user_language();
         if (!file_exists($home . 'home_news_' . $user_selected_language . '.html')) {
             if (file_exists($home . 'home_top.html')) {
                 $home_top_temp = file($home . 'home_top.html');
             } else {
                 //$home_top_temp = file('home/'.'home_top.html');
             }
             if (!empty($home_top_temp)) {
                 $home_top_temp = implode('', $home_top_temp);
             }
         } else {
             if (file_exists($home . 'home_top_' . $user_selected_language . '.html')) {
                 $home_top_temp = file_get_contents($home . 'home_top_' . $user_selected_language . '.html');
             } else {
                 $home_top_temp = file_get_contents($home . 'home_top.html');
             }
         }
         if (empty($home_top_temp) && api_is_platform_admin()) {
             $home_top_temp = get_lang('PortalHomepageDefaultIntroduction');
         }
         $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
         if (!empty($open)) {
             $html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
         }
     }
     return $html;
 }
コード例 #6
0
/**
 * Returns formatted date/time, correspondent to a given language.
 * The given date should be in the timezone chosen by the administrator
 * and/or user. Use api_get_local_time to get it.
 *
 * @author Patrick Cool <*****@*****.**>, Ghent University
 * @author Christophe Gesche<*****@*****.**>
 *         originally inspired from from PhpMyAdmin
 * @author Ivan Tcholakov, 2009, code refactoring, adding support for predefined date/time formats.
 * @author Guillaume Viguier <*****@*****.**>
 *
 * @param mixed Timestamp or datetime string
 * @param mixed Date format (string or int; see date formats in the Chamilo system: TIME_NO_SEC_FORMAT, DATE_FORMAT_SHORT, DATE_FORMAT_LONG, DATE_TIME_FORMAT_LONG)
 * @param string $language (optional)		Language identificator. If it is omited, the current interface language is assumed.
 * @return string							Returns the formatted date.
 *
 * @link http://php.net/manual/en/function.strftime.php
 */
function api_format_date($time, $format = null, $language = null)
{
    $system_timezone = date_default_timezone_get();
    date_default_timezone_set(_api_get_timezone());
    if (is_string($time)) {
        $time = strtotime($time);
    }
    if (is_null($format)) {
        $format = DATE_TIME_FORMAT_LONG;
    }
    $datetype = null;
    $timetype = null;
    if (is_int($format)) {
        switch ($format) {
            case DATE_FORMAT_ONLY_DAYNAME:
                $date_format = get_lang('dateFormatOnlyDayName', '', $language);
                if (INTL_INSTALLED) {
                    $datetype = IntlDateFormatter::SHORT;
                    $timetype = IntlDateFormatter::NONE;
                }
                break;
            case DATE_FORMAT_NUMBER_NO_YEAR:
                $date_format = get_lang('dateFormatShortNumberNoYear', '', $language);
                if (INTL_INSTALLED) {
                    $datetype = IntlDateFormatter::SHORT;
                    $timetype = IntlDateFormatter::NONE;
                }
                break;
            case DATE_FORMAT_NUMBER:
                $date_format = get_lang('dateFormatShortNumber', '', $language);
                if (INTL_INSTALLED) {
                    $datetype = IntlDateFormatter::SHORT;
                    $timetype = IntlDateFormatter::NONE;
                }
                break;
            case TIME_NO_SEC_FORMAT:
                $date_format = get_lang('timeNoSecFormat', '', $language);
                if (INTL_INSTALLED) {
                    $datetype = IntlDateFormatter::NONE;
                    $timetype = IntlDateFormatter::SHORT;
                }
                break;
            case DATE_FORMAT_SHORT:
                $date_format = get_lang('dateFormatShort', '', $language);
                if (INTL_INSTALLED) {
                    $datetype = IntlDateFormatter::LONG;
                    $timetype = IntlDateFormatter::NONE;
                }
                break;
            case DATE_FORMAT_LONG:
                $date_format = get_lang('dateFormatLong', '', $language);
                if (INTL_INSTALLED) {
                    $datetype = IntlDateFormatter::FULL;
                    $timetype = IntlDateFormatter::NONE;
                }
                break;
            case DATE_TIME_FORMAT_LONG:
                $date_format = get_lang('dateTimeFormatLong', '', $language);
                if (INTL_INSTALLED) {
                    $datetype = IntlDateFormatter::FULL;
                    $timetype = IntlDateFormatter::SHORT;
                }
                break;
            case DATE_FORMAT_LONG_NO_DAY:
                $date_format = get_lang('dateFormatLongNoDay', '', $language);
                if (INTL_INSTALLED) {
                    $datetype = IntlDateFormatter::FULL;
                    $timetype = IntlDateFormatter::SHORT;
                }
                break;
            case DATE_TIME_FORMAT_SHORT:
                $date_format = get_lang('dateTimeFormatShort', '', $language);
                if (INTL_INSTALLED) {
                    $datetype = IntlDateFormatter::FULL;
                    $timetype = IntlDateFormatter::SHORT;
                }
                break;
            case DATE_TIME_FORMAT_SHORT_TIME_FIRST:
                $date_format = get_lang('dateTimeFormatShortTimeFirst', '', $language);
                if (INTL_INSTALLED) {
                    $datetype = IntlDateFormatter::FULL;
                    $timetype = IntlDateFormatter::SHORT;
                }
                break;
            case DATE_TIME_FORMAT_LONG_24H:
                $date_format = get_lang('dateTimeFormatLong24H', '', $language);
                if (INTL_INSTALLED) {
                    $datetype = IntlDateFormatter::FULL;
                    $timetype = IntlDateFormatter::SHORT;
                }
                break;
            default:
                $date_format = get_lang('dateTimeFormatLong', '', $language);
                if (INTL_INSTALLED) {
                    $datetype = IntlDateFormatter::FULL;
                    $timetype = IntlDateFormatter::SHORT;
                }
        }
    } else {
        $date_format = $format;
    }
    if (0) {
        //if using PHP 5.3 format dates like: $dateFormatShortNumber, can't be used
        //
        // Use ICU
        if (is_null($language)) {
            $language = api_get_language_isocode();
        }
        $date_formatter = new IntlDateFormatter($language, $datetype, $timetype, date_default_timezone_get());
        //$date_formatter->setPattern($date_format);
        $formatted_date = api_to_system_encoding($date_formatter->format($time), 'UTF-8');
    } else {
        // We replace %a %A %b %B masks of date format with translated strings
        $translated =& _api_get_day_month_names($language);
        $date_format = str_replace(array('%A', '%a', '%B', '%b'), array($translated['days_long'][(int) strftime('%w', $time)], $translated['days_short'][(int) strftime('%w', $time)], $translated['months_long'][(int) strftime('%m', $time) - 1], $translated['months_short'][(int) strftime('%m', $time) - 1]), $date_format);
        $formatted_date = api_to_system_encoding(strftime($date_format, $time), 'UTF-8');
    }
    date_default_timezone_set($system_timezone);
    return $formatted_date;
}
コード例 #7
0
 /**
  * Reads a CSV-file into an array. The first line of the CSV-file should contain the array-keys.
  * The encoding of the input file is tried to be detected.
  * The elements of the returned array are encoded in the system encoding.
  * Example:
  *   FirstName;LastName;Email
  *   John;Doe;john.doe@mail.com
  *   Adam;Adams;adam@mail.com
  *  returns
  *   $result [0]['FirstName'] = 'John';
  *   $result [0]['LastName'] = 'Doe';
  *   $result [0]['Email'] = 'john.doe@mail. com';
  *   $result [1]['FirstName'] = 'Adam';
  *   ...
  * @param string $filename	The path to the CSV-file which should be imported.
  * @return array			Returns an array (in the system encoding) that contains all data from the CSV-file.
  *
  *
  * @deprecated use cvs_reader instead
  */
 static function csv_to_array($filename, $csv_order = 'vertical')
 {
     $result = array();
     // Encoding detection.
     $handle = fopen($filename, 'r');
     if ($handle === false) {
         return $result;
     }
     $buffer = array();
     $i = 0;
     while (!feof($handle) && $i < 200) {
         // We assume that 200 lines are enough for encoding detection.
         $buffer[] = fgets($handle);
         $i++;
     }
     fclose($handle);
     $buffer = implode("\n", $buffer);
     $from_encoding = api_detect_encoding($buffer);
     unset($buffer);
     // Reading the file, parsing and importing csv data.
     $handle = fopen($filename, 'r');
     if ($handle === false) {
         return $result;
     }
     if ($csv_order == 'vertical') {
         $keys = Text::api_fgetcsv($handle, null, ';');
         foreach ($keys as $key => &$key_value) {
             $key_value = api_to_system_encoding($key_value, $from_encoding);
         }
     }
     while (($row_tmp = Text::api_fgetcsv($handle, null, ';')) !== false) {
         $row = array();
         // Avoid empty lines in csv
         if (is_array($row_tmp) && count($row_tmp) > 0 && $row_tmp[0] != '') {
             if (!is_null($row_tmp[0])) {
                 if ($csv_order == 'vertical') {
                     foreach ($row_tmp as $index => $value) {
                         $row[$keys[$index]] = api_to_system_encoding($value, $from_encoding);
                     }
                 } else {
                     $first = null;
                     $count = 1;
                     foreach ($row_tmp as $index => $value) {
                         if ($count == 1) {
                             $first = $value;
                         } else {
                             $row[$first][] = api_to_system_encoding($value, $from_encoding);
                         }
                         $count++;
                     }
                 }
                 $result[] = $row;
             }
         }
     }
     fclose($handle);
     return $result;
 }
コード例 #8
0
/**
 * Returns formatted date/time, correspondent to a given language.
 * The given date should be in the timezone chosen by the administrator
 * and/or user. Use api_get_local_time to get it.
 *
 * @author Patrick Cool <*****@*****.**>, Ghent University
 * @author Christophe Gesche<*****@*****.**>
 *         originally inspired from from PhpMyAdmin
 * @author Ivan Tcholakov, 2009, code refactoring, adding support for predefined date/time formats.
 * @author Guillaume Viguier <*****@*****.**>
 *
 * @param mixed Timestamp or datetime string
 * @param mixed Date format (string or int; see date formats in the Chamilo system: TIME_NO_SEC_FORMAT, DATE_FORMAT_SHORT, DATE_FORMAT_LONG, DATE_TIME_FORMAT_LONG)
 * @param string $language (optional)		Language identificator. If it is omited, the current interface language is assumed.
 * @return string							Returns the formatted date.
 *
 * @link http://php.net/manual/en/function.strftime.php
 */
function api_format_date($time, $format = null, $language = null)
{
    $system_timezone = date_default_timezone_get();
    date_default_timezone_set(_api_get_timezone());
    if (is_string($time)) {
        $time = strtotime($time);
    }
    if (is_null($format)) {
        $format = DATE_TIME_FORMAT_LONG;
    }
    $datetype = null;
    $timetype = null;
    if (is_int($format)) {
        switch ($format) {
            case DATE_FORMAT_ONLY_DAYNAME:
                //$date_format = get_lang('dateFormatOnlyDayName', '', $language);
                if (INTL_INSTALLED) {
                    $datetype = IntlDateFormatter::SHORT;
                    $timetype = IntlDateFormatter::NONE;
                }
                break;
            case DATE_FORMAT_NUMBER_NO_YEAR:
                //$date_format = get_lang('dateFormatShortNumberNoYear', '', $language);
                if (INTL_INSTALLED) {
                    $datetype = IntlDateFormatter::SHORT;
                    $timetype = IntlDateFormatter::NONE;
                }
                break;
            case DATE_FORMAT_NUMBER:
                //$date_format = get_lang('dateFormatShortNumber', '', $language);
                if (INTL_INSTALLED) {
                    $datetype = IntlDateFormatter::SHORT;
                    $timetype = IntlDateFormatter::NONE;
                }
                break;
            case TIME_NO_SEC_FORMAT:
                //$date_format = get_lang('timeNoSecFormat', '', $language);
                if (INTL_INSTALLED) {
                    $datetype = IntlDateFormatter::NONE;
                    $timetype = IntlDateFormatter::SHORT;
                }
                break;
            case DATE_FORMAT_SHORT:
                //$date_format = get_lang('dateFormatShort', '', $language);
                if (INTL_INSTALLED) {
                    $datetype = IntlDateFormatter::LONG;
                    $timetype = IntlDateFormatter::NONE;
                }
                break;
            case DATE_FORMAT_LONG:
                //$date_format = get_lang('dateFormatLong', '', $language);
                if (INTL_INSTALLED) {
                    $datetype = IntlDateFormatter::FULL;
                    $timetype = IntlDateFormatter::NONE;
                }
                break;
            case DATE_TIME_FORMAT_LONG:
                //$date_format = get_lang('dateTimeFormatLong', '', $language);
                if (INTL_INSTALLED) {
                    $datetype = IntlDateFormatter::FULL;
                    $timetype = IntlDateFormatter::SHORT;
                }
                break;
            case DATE_FORMAT_LONG_NO_DAY:
                //$date_format = get_lang('dateFormatLongNoDay', '', $language);
                if (INTL_INSTALLED) {
                    $datetype = IntlDateFormatter::FULL;
                    $timetype = IntlDateFormatter::SHORT;
                }
                break;
            case DATE_TIME_FORMAT_SHORT:
                //$date_format = get_lang('dateTimeFormatShort', '', $language);
                if (INTL_INSTALLED) {
                    $datetype = IntlDateFormatter::FULL;
                    $timetype = IntlDateFormatter::SHORT;
                }
                break;
            case DATE_TIME_FORMAT_SHORT_TIME_FIRST:
                //$date_format = get_lang('dateTimeFormatShortTimeFirst', '', $language);
                if (INTL_INSTALLED) {
                    $datetype = IntlDateFormatter::FULL;
                    $timetype = IntlDateFormatter::SHORT;
                }
                break;
            case DATE_TIME_FORMAT_LONG_24H:
                //$date_format = get_lang('dateTimeFormatLong24H', '', $language);
                if (INTL_INSTALLED) {
                    $datetype = IntlDateFormatter::FULL;
                    $timetype = IntlDateFormatter::SHORT;
                }
                break;
            default:
                //$date_format = get_lang('dateTimeFormatLong', '', $language);
                if (INTL_INSTALLED) {
                    $datetype = IntlDateFormatter::FULL;
                    $timetype = IntlDateFormatter::SHORT;
                }
        }
    }
    // Use ICU
    if (is_null($language)) {
        $language = api_get_language_isocode();
    }
    $dateFormatter = new IntlDateFormatter($language, $datetype, $timetype, date_default_timezone_get());
    //$date_formatter->setPattern($date_format);
    $formattedDate = api_to_system_encoding($dateFormatter->format($time), 'UTF-8');
    date_default_timezone_set($system_timezone);
    return $formattedDate;
}
コード例 #9
0
    function return_help() {
        $user_selected_language = api_get_interface_language();
        $sys_path               = api_get_path(SYS_PATH);
        $platformLanguage       = api_get_setting('platformLanguage');

        // Help section.
        /* Hide right menu "general" and other parts on anonymous right menu. */

        if (!isset($user_selected_language)) {
            $user_selected_language = $platformLanguage;
        }

        $html = null;
        $home_menu = @(string)file_get_contents($sys_path.$this->home.'home_menu_'.$user_selected_language.'.html');
        if (!empty($home_menu)) {
            $home_menu_content = '<ul class="nav nav-list">';
            $home_menu_content .= api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
            $home_menu_content .= '</ul>';
            $html .= self::show_right_block(get_lang('MenuGeneral'), $home_menu_content, 'help_block');
        }
        return $html;
    }
コード例 #10
0
 if (file_exists($homep . $mtloggedin . '_' . $lang . $ext)) {
     $home_menu = @file($homep . $mtloggedin . '_' . $lang . $ext);
 } else {
     $home_menu = @file($homep . $mtloggedin . $ext);
 }
 if (empty($home_menu)) {
     if (file_exists($homep . $menutabs . '_' . $lang . $ext)) {
         $home_menu = @file($homep . $menutabs . '_' . $lang . $ext);
     }
 }
 if (empty($home_menu)) {
     $home_menu = array();
 }
 if (!empty($home_menu)) {
     $home_menu = implode("\n", $home_menu);
     $home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
     $home_menu = explode("\n", $home_menu);
 }
 $link_list = '';
 $tab_counter = 0;
 foreach ($home_menu as $enreg) {
     $enreg = trim($enreg);
     if (!empty($enreg)) {
         $edit_link = ' <a href="' . $selfUrl . '?action=edit_tabs&amp;link_index=' . $tab_counter . '" ><span>' . Display::return_icon('edit.png', get_lang('Edit')) . '</span></a>';
         $delete_link = ' <a href="' . $selfUrl . '?action=delete_tabs&amp;link_index=' . $tab_counter . '"  onclick="javascript: if(!confirm(\'' . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)) . '\')) return false;"><span>' . Display::return_icon('delete.png', get_lang('Delete')) . '</span></a>';
         $tab_string = str_replace(array('href="' . api_get_path(WEB_PATH) . 'index.php?include=', '</li>'), array('href="' . api_get_path(WEB_CODE_PATH) . 'admin/' . basename($selfUrl) . '?action=open_link&link=', $edit_link . $delete_link . '</li>'), $enreg);
         $tab_string = str_replace(array('<li>', '</li>', 'class="hide_menu"', 'hide_menu'), '', $tab_string);
         $link_list .= Display::tag('li', $tab_string, array('class' => 'list-group-item'));
         $tab_counter++;
     }
 }
コード例 #11
0
function return_menu()
{
    $navigation = return_navigation_array();
    $navigation = $navigation['navigation'];
    // Displaying the tabs
    $lang = '';
    //el for "Edit Language"
    if (!empty($_SESSION['user_language_choice'])) {
        $lang = $_SESSION['user_language_choice'];
    } elseif (!empty($_SESSION['_user']['language'])) {
        $lang = $_SESSION['_user']['language'];
    } else {
        $lang = get_setting('platformLanguage');
    }
    //Preparing home folder for multiple urls
    if (api_get_multiple_access_url()) {
        $access_url_id = api_get_current_access_url_id();
        if ($access_url_id != -1) {
            $url_info = api_get_access_url($access_url_id);
            $url = api_remove_trailing_slash(preg_replace('/https?:\\/\\//i', '', $url_info['url']));
            $clean_url = replace_dangerous_char($url);
            $clean_url = str_replace('/', '-', $clean_url);
            $clean_url .= '/';
            $homep = api_get_path(SYS_PATH) . 'home/' . $clean_url;
            //homep for Home Path
            //we create the new dir for the new sites
            if (!is_dir($homep)) {
                mkdir($homep, api_get_permissions_for_new_directories());
            }
        }
    } else {
        $homep = api_get_path(SYS_PATH) . 'home/';
    }
    $ext = '.html';
    $menutabs = 'home_tabs';
    $mtloggedin = 'home_tabs_logged_in';
    $home_top = '';
    if (is_file($homep . $menutabs . '_' . $lang . $ext) && is_readable($homep . $menutabs . '_' . $lang . $ext)) {
        $home_top = @(string) file_get_contents($homep . $menutabs . '_' . $lang . $ext);
    } elseif (is_file($homep . $menutabs . $lang . $ext) && is_readable($homep . $menutabs . $lang . $ext)) {
        $home_top = @(string) file_get_contents($homep . $menutabs . $lang . $ext);
    } else {
        //$errorMsg = get_lang('HomePageFilesNotReadable');
    }
    $home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top)));
    $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top);
    $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
    $open_mtloggedin = '';
    if (api_get_user_id() && !api_is_anonymous()) {
        if (is_file($homep . $mtloggedin . '_' . $lang . $ext) && is_readable($homep . $mtloggedin . '_' . $lang . $ext)) {
            $home_top = @(string) file_get_contents($homep . $mtloggedin . '_' . $lang . $ext);
            $home_top = str_replace('::private', '', $home_top);
        } elseif (is_file($homep . $mtloggedin . $lang . $ext) && is_readable($homep . $mtloggedin . $lang . $ext)) {
            $home_top = @(string) file_get_contents($homep . $mtloggedin . $lang . $ext);
            $home_top = str_replace('::private', '', $home_top);
        } else {
            //$errorMsg = get_lang('HomePageFilesNotReadable');
        }
        $home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top)));
        $open_mtloggedin = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top);
        $open_mtloggedin = api_to_system_encoding($open_mtloggedin, api_detect_encoding(strip_tags($open_mtloggedin)));
    }
    $lis = '';
    if (!empty($open) or !empty($open_mtloggedin)) {
        if (strpos($open . $open_mtloggedin, 'show_menu') === false) {
            if (api_is_anonymous()) {
                $navigation[SECTION_CAMPUS] = null;
            }
        } else {
            //$lis .= Display::tag('li', $open);
            if (api_get_user_id() && !api_is_anonymous()) {
                $lis .= $open_mtloggedin;
            } else {
                $lis .= $open;
            }
        }
    }
    if (count($navigation) > 0 || !empty($lis)) {
        $pre_lis = '';
        foreach ($navigation as $section => $navigation_info) {
            $key = !empty($navigation_info['key']) ? 'tab-' . $navigation_info['key'] : '';
            if (isset($GLOBALS['this_section'])) {
                $current = $section == $GLOBALS['this_section'] ? ' id="current" class="active ' . $key . '" ' : ' class="' . $key . '"';
            } else {
                $current = '';
            }
            if (!empty($navigation_info['title'])) {
                $pre_lis .= '<li' . $current . '><a  href="' . $navigation_info['url'] . '" target="_top">' . $navigation_info['title'] . '</a></li>';
            }
        }
        $lis = $pre_lis . $lis;
    }
    $menu = null;
    if (!empty($lis)) {
        $menu .= $lis;
    }
    return $menu;
}
コード例 #12
0
ファイル: faq.php プロジェクト: omaoibrahim/chamilo-lms
    echo '&nbsp;<a href="faq.php?edit=true"><img src="' . api_get_path(WEB_IMG_PATH) . 'edit.png" /></a>';
}
echo Display::page_header(get_lang('Faq'));
$faq_file = 'faq.html';
if (!empty($_GET['edit']) && $_GET['edit'] == 'true' && api_is_platform_admin()) {
    $form = new FormValidator('set_faq', 'post', 'faq.php?edit=true');
    $form->addHtmlEditor('faq_content', null, false, false, array('ToolbarSet' => 'FAQ', 'Width' => '100%', 'Height' => '300'));
    $form->addButtonSave(get_lang('Ok'), 'faq_submit');
    $faq_content = @(string) file_get_contents(api_get_path(SYS_APP_PATH) . 'home/faq.html');
    $faq_content = api_to_system_encoding($faq_content, api_detect_encoding(strip_tags($faq_content)));
    $form->setDefaults(array('faq_content' => $faq_content));
    if ($form->validate()) {
        $content = $form->getSubmitValue('faq_content');
        $fpath = api_get_path(SYS_APP_PATH) . 'home/' . $faq_file;
        if (is_file($fpath) && is_writeable($fpath)) {
            $fp = fopen(api_get_path(SYS_APP_PATH) . 'home/' . $faq_file, 'w');
            fwrite($fp, $content);
            fclose($fp);
        } else {
            Display::display_warning_message(get_lang('WarningFaqFileNonWriteable'));
        }
        echo $content;
    } else {
        $form->display();
    }
} else {
    $faq_content = @(string) file_get_contents(api_get_path(SYS_APP_PATH) . 'home/' . $faq_file);
    $faq_content = api_to_system_encoding($faq_content, api_detect_encoding(strip_tags($faq_content)));
    echo $faq_content;
}
Display::display_footer();
コード例 #13
0
ファイル: Template.php プロジェクト: omaoibrahim/chamilo-lms
 /**
  * @return null|string
  */
 public function returnMenu()
 {
     return null;
     $navigation = $this->navigation_array;
     $navigation = $navigation['navigation'];
     // Displaying the tabs
     $lang = api_get_user_language();
     // Preparing home folder for multiple urls
     if (api_get_multiple_access_url()) {
         $access_url_id = api_get_current_access_url_id();
         if ($access_url_id != -1) {
             $url_info = api_get_current_access_url_info();
             $url = api_remove_trailing_slash(preg_replace('/https?:\\/\\//i', '', $url_info['url']));
             $clean_url = api_replace_dangerous_char($url);
             $clean_url = str_replace('/', '-', $clean_url);
             $clean_url .= '/';
             $homep = $this->app['path.data'] . 'home/' . $clean_url;
             //homep for Home Path
             //we create the new dir for the new sites
             if (!is_dir($homep)) {
                 mkdir($homep, api_get_permissions_for_new_directories());
             }
         }
     } else {
         $homep = $this->app['path.data'] . 'home/';
     }
     $ext = '.html';
     $menutabs = 'home_tabs';
     $home_top = '';
     if (is_file($homep . $menutabs . '_' . $lang . $ext) && is_readable($homep . $menutabs . '_' . $lang . $ext)) {
         $home_top = @(string) file_get_contents($homep . $menutabs . '_' . $lang . $ext);
     } elseif (is_file($homep . $menutabs . $lang . $ext) && is_readable($homep . $menutabs . $lang . $ext)) {
         $home_top = @(string) file_get_contents($homep . $menutabs . $lang . $ext);
     }
     $home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top)));
     $open = str_replace('{rel_path}', $this->app['path.data'], $home_top);
     $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
     $lis = '';
     if (!empty($open)) {
         if (strpos($open, 'show_menu') === false) {
             if (api_is_anonymous()) {
                 $navigation[SECTION_CAMPUS] = null;
             }
         } else {
             $lis .= $open;
         }
     }
     if (count($navigation) > 0 || !empty($lis)) {
         $pre_lis = '';
         foreach ($navigation as $section => $navigation_info) {
             if (isset($GLOBALS['this_section'])) {
                 $current = $section == $GLOBALS['this_section'] ? ' id="current" class="active" ' : '';
             } else {
                 $current = '';
             }
             if (!empty($navigation_info['title'])) {
                 $pre_lis .= '<li' . $current . ' ><a  href="' . $navigation_info['url'] . '" target="_top">' . $navigation_info['title'] . '</a></li>';
             }
         }
         $lis = $pre_lis . $lis;
     }
     $menu = null;
     if (!empty($lis)) {
         $menu .= $lis;
     }
     return $menu;
 }