Beispiel #1
0
/**
 * @package ezcast.ezadmin.installer
 */
/**
 * This file is aimed to install EZcast and its components.
 * It creates the tables of the database and sets up the configuration files 
 * according to the user's preferences
 */
require_once '../commons/lib_template.php';
require_once '../commons/lib_database.php';
require_once 'lib_various.php';
require_once 'lib_error.php';
$template_folder = 'tmpl/';
date_default_timezone_set("Europe/Brussels");
template_repository_path($template_folder . get_lang());
template_load_dictionnary('translations.xml');
if (file_exists('config.inc')) {
    echo "Nothing to do here ;-)";
    die;
}
session_name("ezcast_installer");
session_start();
$_SESSION['install'] = true;
$errors = array();
$input = array_merge($_GET, $_POST);
if (!isset($_SESSION['user_logged'])) {
    if (isset($input['action']) && $input['action'] == 'login') {
        if (!isset($input['login']) || !isset($input['passwd'])) {
            error_print_message(template_get_message('empty_username_password', get_lang()));
            die;
        }
Beispiel #2
0
/**
 * Displays the popup with the ulb code to copypaste
 * @global type $input
 * @global type $repository_path
 * @global type $url 
 */
function popup_ulb_code()
{
    global $input;
    global $repository_path;
    $asset_name = $input['asset'];
    ezmam_repository_path($repository_path);
    template_load_dictionnary('translations.xml');
    //
    // Sanity checks
    //
    if (!isset($input['album']) || !isset($input['asset']) || !isset($input['media'])) {
        echo 'Usage: index.php?action=show_popup&popup=ulb_code&album=ALBUM&asset=ASSET&media=MEDIA';
        die;
    }
    if (!ezmam_album_exists($input['album']) || !ezmam_asset_exists($input['album'], $input['asset'])) {
        error_print_message(ezmam_last_error());
        die;
    }
    $ulb_code = get_code_to_media($input['album'], $input['asset'], $input['media']);
    // Displaying the popup
    require_once template_getpath('popup_ulb_code.php');
}
Beispiel #3
0
/**
 * Parses the file given in input, and places the result in output_folder/lang
 * Caution: this function expects the output folder to already have the correct structure (subfolders)
 * @param type $source_folder Source folder
 * @param type $file Template name
 * @param type $lang Output language
 * @param type $output_folder Output folder
 * @return bool error status
 */
function template_parse($file, $lang, $output_folder, $translation_xml_file)
{
    global $dictionnary_xml;
    //
    // 1) Sanity checks
    //
    if (!is_dir($output_folder)) {
        template_last_error("Output folder {$output_folder} does not exist!");
        return false;
    }
    if (!file_exists($file)) {
        template_last_error("Input file {$file} does not exist");
        return false;
    }
    // TODO: Gérer les sous-dossiers
    //
    // 2) Parsing the file
    //
    $data = file_get_contents($file);
    template_load_dictionnary($translation_xml_file);
    // Version 1 (not optimized at all)
    /*$labels = template_get_labels('fr');
      foreach($labels as $label) {
          $keyword = '®'.$label['id'].'®';
          $label = (string) $label;
          
          $data = preg_replace('!'.$keyword.'!iU', $label, $data);
      }*/
    // version 2, "probably" more efficient
    //look for ®string® where string in any (smallest, ungreedy) suite of nonspace chars.
    //Begin and end of @string@ must be on the same line.
    //calls template_get_label for each match and replace keywork with translated value in the text
    $data = preg_replace_callback('!®(\\S+)®!iU', create_function('$matches', 'return template_get_label($matches[1], \'' . $lang . '\');'), $data);
    //
    // 3) Saving the result
    //
    //$subfolder = strstr($file, '/'); // We want the result to be in the same subfolder as the input, but without the source_folder part.
    $subfolder = substr(strrchr($file, "/"), 1);
    // We want only the file name, not the path
    $output_file = $output_folder . '/' . $lang . '/' . $subfolder;
    if (!file_exists($output_folder . '/' . $lang)) {
        mkdir($output_folder . '/' . $lang);
    }
    //dest dir doesn't exist so create it
    if (file_exists($output_file)) {
        unlink($output_file);
    }
    file_put_contents($output_file, $data);
}
Beispiel #4
0
/**
 * Takes a ls-friendly date and translates it into human-readable
 * @param string $date The date in format YYYY_mm_dd_HHhii
 * @param string $space_char The delimiter to use between digits
 * @param bool $long_months_names(true) If set to "false", the month will be displayed as a number instead of a noun
 * @param string $lang Language the months are displayed in, in cast $long_months_names is set to true
 * @param bool $long_date if set to true, the date will be a "gramatically correct" date, instead of a "easily computable" one
 * @return string The date in format dd_mmmm_YYYY_HH:ii
 */
function get_user_friendly_date($date, $space_char = '_', $long_months_names = true, $lang = 'fr', $long_date = false)
{
    if (!isset($date) || empty($date)) {
        return null;
    }
    $matches = array();
    preg_match('!(\\d{4})\\_(\\d{2})\\_(\\d{2})\\_(\\d{2})h(\\d{2})!', $date, $matches);
    $new_date = $matches[3] . $space_char;
    // Day
    // If we want long month names (in letters, that is), we retrieve these names
    // from the translations file, and remove the non-ASCII characters if needed
    if ($long_months_names) {
        template_load_dictionnary('translations.xml');
        if ($lang == 'fr-ASCII') {
            $new_date .= str_replace(array('é', 'û'), array('e', 'u'), template_get_message('month_' . $matches[2], 'fr'));
        } else {
            $new_date .= template_get_message('month_' . $matches[2], $lang);
        }
    } else {
        $new_date .= $matches[2];
    }
    $new_date .= $space_char . $matches[1];
    // year
    if ($long_date) {
        $new_date .= $space_char . $at;
    }
    // Separator between date and hour
    $new_date .= $space_char . $matches[4] . 'h' . $matches[5];
    // Hours and minutes
    return $new_date;
}