Esempio n. 1
0
<?php

// $Header$
// Copyright (c) 2005 bitweaver SiteHome
// All Rights Reserved. See below for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details.
require_once SITEHOME_PKG_PATH . 'BitSiteHome.php';
if (isset($_REQUEST["homeTabSubmit"]) && isset($_REQUEST["homeSiteHome"])) {
    $gBitSystem->storeConfig("home_sitehome", $_REQUEST["homeSiteHome"], SITEHOME_PKG_NAME);
    $gBitSmarty->assign('home_sitehome', $_REQUEST["homeSiteHome"]);
}
$formSiteHomeLists = array("sitehome_list_sitehome_id" => array('label' => 'Id', 'note' => 'Display the sitehome id.'), "sitehome_list_title" => array('label' => 'Title', 'note' => 'Display the title.'), "sitehome_list_description" => array('label' => 'Description', 'note' => 'Display the description.'), "sitehome_list_data" => array('label' => 'Text', 'note' => 'Display the text.'));
$gBitSmarty->assign('formSiteHomeLists', $formSiteHomeLists);
$processForm = set_tab();
if ($processForm) {
    $sitehomeToggles = array_merge($formSiteHomeLists);
    foreach ($sitehomeToggles as $item => $data) {
        simple_set_toggle($item, 'sitehomes');
    }
}
$formSiteHomeOpts = array("sitehome_display_title" => array('label' => 'Title', 'note' => 'Display the title.'), "sitehome_display_description" => array('label' => 'Description', 'note' => 'Display the description.'), "sitehome_display_date" => array('label' => 'Date', 'note' => 'Display the creation and modification dates.'));
$gBitSmarty->assign('formSiteHomeOpts', $formSiteHomeOpts);
if (isset($_REQUEST["optsTabSubmit"])) {
    foreach ($formSiteHomeOpts as $item => $data) {
        simple_set_toggle($item, SITEHOME_PKG_NAME);
    }
}
$sitehome = new BitSiteHome();
$sitehomes = $sitehome->getList($_REQUEST);
$gBitSmarty->assign_by_ref('sitehomes', $sitehomes);
Esempio n. 2
0
function checkfile($filename)
{
    global $flag;
    global $target;
    set_time_limit(0);
    //
    // loading source data
    if (!($fd = fopen($filename, 'r'))) {
        die("Cannot open {$filename}");
    }
    while ($data = @fgets($fd)) {
        if (isset($data[1]) and $data[1] != '*' and $data[1] != '?') {
            $source[] = $data;
        }
    }
    fclose($fd);
    // loading target data
    $filename = str_replace(".en.", ".{$flag}.", $filename);
    if (!($fd = fopen($filename, 'r'))) {
        print "Cannot open {$filename}";
    }
    $header = "";
    while ($data = @fgets($fd)) {
        if ($data[1] == '*' or $data[1] == '?') {
            $header .= $data;
        }
        if (substr($data, 0, 1) == "\$") {
            $target[] = $data;
        }
    }
    @fclose($fd);
    $target[] = "";
    // DO NOT DELETE THIS
    // rename file
    for ($n = 1; $n < 999; $n++) {
        $filename2 = str_replace(".php", ".{$n}.php", $filename);
        if (!file_exists($filename2)) {
            rename($filename, $filename2);
            //echo "<br />$filename : $filename2";
            break;
        }
    }
    // output file
    //$filename = str_replace(".php", ".NEW.php", $filename);
    if (!($fd = fopen($filename, 'w'))) {
        die("Cannot open {$filename}");
    }
    if (!fputs($fd, $header, strlen($header))) {
        die("Cannot write to {$filename}");
    }
    // file header
    // process source data
    $ok = 0;
    $nok = 0;
    foreach ($source as $indexval => $english) {
        if (substr($english, 0, 1) == "\$") {
            // print "<br />$english";
            $p = strpos($english, "]");
            $keyword = substr($english, 0, $p + 1);
            // search for existing translation
            foreach ($target as $indexval => $translated) {
                if (stristr($translated, $keyword)) {
                    break;
                }
            }
            if ($translated == "") {
                $nok++;
                $translated = "#" . substr($english, 1);
            } else {
                $ok++;
            }
            // delete comment
            //			$p = @strpos($translated, "//");
            //			if ($p > 5) $translated = trim(substr($translated, 0, $p-1));
            // output record
            $z = $translated;
        } else {
            $z = str_replace(".en.", ".{$flag}.", $english);
        }
        // output string
        //		$z = utf8_encode($z);
        $z = str_replace("\r", "", $z);
        $z = str_replace("\n", "", $z);
        $z = set_tab($z);
        $z = $z . "\r\n";
        if (strlen($z) > 0) {
            if (!fputs($fd, $z, strlen($z))) {
                die("Cannot write to {$filename}");
            }
        }
    }
    fclose($fd);
    echo PGV_JS_START;
    echo 'var OK = ', $ok, ';';
    echo 'var TOT= ', $ok + $nok, ';';
    echo 'var ELT= "', $flag, '.', substr(basename($filename), 0, 1), '";';
    echo 'perc = Math.round(100*(OK / TOT));';
    echo 'progress = document.getElementById(ELT);';
    echo 'progress.innerHTML = perc+"%";';
    echo PGV_JS_END;
    flush();
}