Exemplo n.º 1
0
if (isCli()) {
    function startsWith($haystack, $needle, $case = true)
    {
        if ($case) {
            return strcmp(substr($haystack, 0, strlen($needle)), $needle) === 0;
        }
        return strcasecmp(substr($haystack, 0, strlen($needle)), $needle) === 0;
    }
    function endsWith($haystack, $needle, $case = true)
    {
        if ($case) {
            return strcmp(substr($haystack, strlen($haystack) - strlen($needle)), $needle) === 0;
        }
        return strcasecmp(substr($haystack, strlen($haystack) - strlen($needle)), $needle) === 0;
    }
    $i18nstrings = array_merge(foorm_i18n_util($blti_instructor_form), foorm_i18n_util($blti_admin_form), foorm_i18n_util($blti_content_edit_form));
    $i18nstrings = array_unique($i18nstrings);
    sort($i18nstrings);
    foreach ($i18nstrings as $i18n) {
        $value = $i18n;
        if (startsWith($value, "bl_")) {
            $value = substr($value, 3);
        }
        if (endsWith($value, "_on")) {
            $value = 'Always enabled';
        }
        if (endsWith($value, "_off")) {
            $value = 'Never allowed';
        }
        if (endsWith($value, "_instructor")) {
            $value = 'Delegate to Instructor';
Exemplo n.º 2
0
if (!function_exists('isCli')) {
    function isCli()
    {
        $sapi_type = php_sapi_name();
        if (substr($sapi_type, 0, 3) == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
            return true;
        } else {
            return false;
        }
    }
}
// If we are running from the command line - do a unit test
if (isCli()) {
    print_r(parseFormString('title:text:required=true:size=25'));
    print_r(parseFormString('description:textarea:required=true:rows=2:cols=25'));
    print_r(parseFormString('sendemail:radio:requred=true:label=bl_sendemail:choices=on,off,part'));
    $row = array();
    $row['title'] = 'Fred';
    $row['description'] = 'Desc';
    $row['sendemail'] = 1;
    function _AT($str)
    {
        return $str;
    }
    at_form_input($row, 'title:text:required=true:size=25');
    at_form_input($row, 'description:textarea:required=true:rows=2:cols=25');
    at_form_input($row, 'sendemail:radio:requred=true:label=bl_sendemail:choices=on,off,part');
    $test_frm = array('title:text:size=80', 'preferheight:integer:label=bl_preferheight:size=80', 'sendname:radio:label=bl_sendname:choices=off,on,content', 'acceptgrades:radio:label=bl_acceptgrades:choices=off,on', 'customparameters:textarea:label=bl_customparameters:rows=5:cols=25');
    $i18strings = foorm_i18n_util($test_frm);
    print_r($i18strings);
}