Esempio n. 1
0
    if ($type == 'textarea') {
        $items[$element]['rows'] = 4;
        $items[$element]['cols'] = 50;
    }
    if ($type == 'text') {
        $items[$element]['size'] = 30;
    }
    if ($element == 'country') {
        $countries = getoptions_country();
        $items[$element]['options'] = array('' => get_string('nocountryselected')) + $countries;
        $items[$element]['defaultvalue'] = get_config('country');
    }
    if ($element == 'socialprofile') {
        $items[$element] = ArtefactTypeSocialprofile::render_profile_element();
    }
    if (get_helpfile_location('artefact', 'internal', 'profileform', $element)) {
        $items[$element]['help'] = true;
    }
    if (isset($profilefields[$element])) {
        $items[$element]['defaultvalue'] = $profilefields[$element];
    }
    if (isset($element_required[$element])) {
        $items[$element]['rules']['required'] = true;
    }
    if (isset($lockedfields[$element]) && !$USER->get('admin')) {
        $items[$element]['disabled'] = true;
        if ($element == 'email') {
            $items[$element]['help'] = false;
        }
    }
}
Esempio n. 2
0
function get_helpfile_location($plugintype, $pluginname, $form, $element, $page = null, $section = null)
{
    $subdir = 'help/';
    if ($page) {
        $pagebits = explode('-', $page);
        $file = array_pop($pagebits) . '.html';
        if ($plugintype != 'core') {
            $subdir .= 'pages/' . join('/', $pagebits) . '/';
        } else {
            $subdir .= 'pages/' . $pluginname . '/' . join('/', $pagebits) . '/';
        }
    } else {
        if ($section) {
            $subdir .= 'sections/';
            $file = $section . '.html';
        } else {
            if (!empty($form) && !empty($element)) {
                $subdir .= 'forms/';
                $file = $form . '.' . $element . '.html';
            } else {
                if (!empty($form) && empty($element)) {
                    $subdir .= 'forms/';
                    $file = $form . '.html';
                } else {
                    return false;
                }
            }
        }
    }
    // now we have to try and locate the help file
    $lang = current_language();
    if ($lang == 'en.utf8') {
        $trieden = true;
    } else {
        $trieden = false;
    }
    //try the local settings
    $langfile = get_config('docroot') . 'local/lang/' . $lang . '/' . $subdir;
    if ($plugintype != 'core') {
        $langfile .= $plugintype . '.' . $pluginname . '.' . $file;
    } else {
        $langfile .= $file;
    }
    if (is_readable($langfile)) {
        return $langfile;
    }
    if ($plugintype == 'blocktype') {
        // these are a bit of a special case
        $bits = explode('/', $pluginname);
        if (count($bits) == 2) {
            $location = 'artefact/' . $bits[0] . '/blocktype/' . $bits[1] . '/lang/';
        } else {
            try {
                if ($artefactplugin = blocktype_artefactplugin($pluginname)) {
                    $location = 'artefact/' . $artefactplugin . '/blocktype/' . $pluginname . '/lang/';
                } else {
                    $location = 'blocktype/' . $pluginname . '/lang/';
                }
            } catch (SQLException $e) {
                if (get_config('installed')) {
                    throw $e;
                }
            }
        }
    } else {
        if ($plugintype != 'core') {
            $location = $plugintype . '/' . $pluginname . '/lang/';
        } else {
            $location = 'lang/';
        }
    }
    // try the current language
    $langfile = get_language_root() . $location . $lang . '/' . $subdir . $file;
    if (is_readable($langfile)) {
        return $langfile;
    }
    // if it's not found, try the parent language if there is one...
    if (empty($data) && empty($trieden)) {
        $langfile = get_language_root($lang) . 'lang/' . $lang . '/langconfig.php';
        if ($parentlang = get_string_from_file('parentlanguage', $langfile)) {
            if ($parentlang == 'en.utf8') {
                $trieden = true;
            }
            $langfile = get_language_root($parentlang) . $location . $parentlang . '/' . $subdir . $file;
            if (is_readable($langfile)) {
                return $langfile;
            }
        }
    }
    // if it's STILL not found, and we haven't already tried english ...
    if (empty($data) && empty($trieden)) {
        $langfile = get_language_root('en.utf8') . $location . 'en.utf8/' . $subdir . $file;
        if (is_readable($langfile)) {
            return $langfile;
        }
    }
    // if it's a form element, try the wildcard form name
    if (!empty($form) && !empty($element) && $form !== 'ANY') {
        // if it's a block instance config form element, try the wildcard form name
        // and element without it's prefixes
        if (preg_match('/^instconf_/', $element)) {
            $element = end(explode('_', $element));
        }
        return get_helpfile_location('core', '', 'ANY', $element, $page, $section);
    }
    return false;
}
Esempio n. 3
0
function get_helpfile($plugintype, $pluginname, $form, $element, $page = null, $section = null)
{
    if ($langfile = get_helpfile_location($plugintype, $pluginname, $form, $element, $page, $section)) {
        return file_get_contents($langfile);
    }
    return false;
}