function wfLyricWikiVariableSwitch(&$parser, &$cache, &$magicWordId, &$ret)
{
    $lwVars = getLyricWikiVariables();
    foreach ($lwVars as $key => $value) {
        if ($magicWordId == "MAG_LYRICWIKI_" . $key) {
            $ret = $value;
        }
    }
    return true;
}
Example #2
0
/**
 * Fills the textbox of a new page with content.
 */
function lw_templatePreload(&$textbox, Title &$title)
{
    $lwVars = getLyricWikiVariables();
    $titleStr = $title->getText();
    // only use templates in the main namespace
    $ns = $title->getNamespace();
    if ($ns != NS_MAIN && $ns != NS_TALK) {
        return true;
    }
    $tempType = "";
    $pageType = "";
    if (isset($_GET['template'])) {
        $pageType = strtolower($_GET['template']);
    }
    if ($pageType == "") {
        $pageType = $lwVars["pagetype"];
    }
    # pull template from database and replace placeholds
    if ($pageType == "none") {
        $textbox = "";
    } else {
        $extra = trim(wfMsgForContentNoTrans("lwtemp-extra-templates"));
        if ($extra != "") {
            $extras = explode("\n", $extra);
            foreach ($extras as $item) {
                if (strpos($item, "|")) {
                    $parts = explode("|", $item);
                    if (0 < preg_match("/{$parts[0]}/", $titleStr, $m)) {
                        $pageType = $parts[1];
                    }
                }
            }
        }
        $template = wfMsgForContentNoTrans("lwtemp-{$pageType}-template");
        // only display a template if the template actually exists
        if ($template != "<{$pageType}Template>" and $template != "&lt;{$pageType}Template&gt;") {
            $textbox = $template;
            $lwVars = getLyricWikiVariables();
            $replace = array();
            $with = array();
            foreach ($lwVars as $key => $value) {
                $replace[] = "{{" . strtoupper($key) . "}}";
                $with[] = $value;
            }
            $textbox = str_replace($replace, $with, $textbox);
        }
    }
    return true;
}