Exemple #1
0
 function print_replacements($parentid = -1, $indent = "\t")
 {
     global $vbulletin, $vbphrase;
     static $stylecache, $donecache;
     if ($parentid == -1 and $vbulletin->debug) {
         echo "<ul class=\"lsq\">\n";
         echo "\t<li><b>" . MASTERSTYLE . "</b>" . construct_link_code($vbphrase['add_new_replacement_variable'], "replacement.php?" . $vbulletin->session->vars['sessionurl'] . "do=add&amp;dostyleid=-1") . "\n";
         echo "\t\t<ul class=\"ldi\">\n";
         $templates = $vbulletin->db->query_read("\n\t\t\t\tSELECT templateid, title\n\t\t\t\tFROM " . TABLE_PREFIX . "template\n\t\t\t\tWHERE templatetype = 'replacement'\n\t\t\t\t\tAND styleid = -1\n\t\t\t");
         if ($vbulletin->db->num_rows($templates)) {
             while ($template = $vbulletin->db->fetch_array($templates)) {
                 echo "\t\t<li>" . htmlspecialchars_uni($template['title']) . construct_link_code($vbphrase['edit'], "replacement.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit&amp;dostyleid=-1&amp;templateid={$template['templateid']}") . construct_link_code($vbphrase['delete'], "replacement.php?" . $vbulletin->session->vars['sessionurl'] . "do=remove&amp;dostyleid=-1&amp;templateid={$template['templateid']}") . "\n";
             }
         } else {
             echo "\t\t\t<li>" . $vbphrase['no_replacements_defined'] . "</li>\n";
         }
         echo "\t\t</ul><br />\n\t</li>\n</ul>\n<hr size=\"1\" />\n";
     }
     // initialise the style cache if not already created
     if (empty($stylecache)) {
         $styles = $vbulletin->db->query_read("\n\t\t\t\tSELECT *\n\t\t\t\tFROM " . TABLE_PREFIX . "style\n\t\t\t\tORDER BY parentid, displayorder\n\t\t\t");
         while ($style = $vbulletin->db->fetch_array($styles)) {
             $stylecache["{$style['parentid']}"]["{$style['displayorder']}"]["{$style['styleid']}"] = $style;
         }
     }
     // initialise the 'donecache' if not already created
     if (empty($donecache)) {
         $donecache = array();
     }
     // check to see if this style actually exists / has children
     if (!isset($stylecache["{$parentid}"])) {
         return;
     }
     foreach ($stylecache["{$parentid}"] as $holder) {
         echo "{$indent}<ul class=\"lsq\">\n";
         foreach ($holder as $styleid => $style) {
             echo "{$indent}<li><b>{$style['title']}</b>" . construct_link_code($vbphrase['add_new_replacement_variable'], "replacement.php?" . $vbulletin->session->vars['sessionurl'] . "do=add&amp;dostyleid={$styleid}") . "\n";
             echo "\t{$indent}<ul class=\"ldi\">\n";
             $templateids = implode(',', unserialize($style['templatelist']));
             $templates = $vbulletin->db->query_read("SELECT templateid, title, styleid, template FROM " . TABLE_PREFIX . "template WHERE templatetype = 'replacement' AND templateid IN({$templateids}) ORDER BY title");
             if ($vbulletin->db->num_rows($templates)) {
                 while ($template = $vbulletin->db->fetch_array($templates)) {
                     if (in_array($template['templateid'], $donecache)) {
                         echo "\t\t{$indent}<li class=\"col-i\">" . htmlspecialchars_uni($template['title']) . construct_link_code($vbphrase['customize'], "replacement.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit&amp;dostyleid={$styleid}&amp;templateid={$template['templateid']}") . "</li>\n";
                     } else {
                         if ($template['styleid'] != -1) {
                             echo "\t\t{$indent}<li class=\"col-c\">" . htmlspecialchars_uni($template['title']) . construct_link_code($vbphrase['edit'], "replacement.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit&amp;dostyleid={$styleid}&amp;templateid={$template['templateid']}") . construct_link_code($vbphrase['delete'], "replacement.php?" . $vbulletin->session->vars['sessionurl'] . "do=remove&amp;dostyleid={$styleid}&amp;templateid={$template['templateid']}") . "</li>\n";
                             $donecache[] = $template['templateid'];
                         } else {
                             echo "\t\t{$indent}<li class=\"col-g\">" . htmlspecialchars_uni($template['title']) . construct_link_code($vbphrase['customize'], "replacement.php?" . $vbulletin->session->vars['sessionurl'] . "do=edit&amp;dostyleid={$styleid}&amp;templateid={$template['templateid']}") . "</li>\n";
                         }
                     }
                 }
             } else {
                 echo "\t\t{$indent}<li>" . $vbphrase['no_replacements_defined'] . "</li>\n";
             }
             echo "{$indent}\t</ul><br />\n";
             print_replacements($styleid, "{$indent}\t");
             echo "{$indent}</li>\n";
         }
         echo "{$indent}</ul>\n";
         if ($style['parentid'] == -1) {
             echo "<hr size=\"1\" />\n";
         }
     }
 }
function print_replacements($parentid = -1, $indent = "\t")
{
    global $vbulletin, $vbphrase;
    static $stylecache, $donecache = array();
    $vb5_config =& vB::getConfig();
    $assertor = vB::getDbAssertor();
    if ($parentid == -1 and $vb5_config['Misc']['debug']) {
        echo "<ul class=\"lsq\">\n";
        echo "\t<li><b>" . MASTERSTYLE . "</b>" . construct_link_code($vbphrase['add_new_replacement_variable'], "replacement.php?" . vB::getCurrentSession()->get('sessionurl') . "do=add&amp;dostyleid=-1") . "\n";
        echo "\t\t<ul class=\"ldi\">\n";
        $templates = $assertor->getRows('template', array('templatetype' => 'replacement', 'styleid' => $parentid));
        if ($templates) {
            foreach ($templates as $template) {
                echo "\t\t<li>" . htmlspecialchars_uni($template['title']) . construct_link_code($vbphrase['edit'], "replacement.php?" . vB::getCurrentSession()->get('sessionurl') . "do=edit&amp;dostyleid=-1&amp;templateid={$template['templateid']}") . construct_link_code($vbphrase['delete'], "replacement.php?" . vB::getCurrentSession()->get('sessionurl') . "do=remove&amp;dostyleid=-1&amp;templateid={$template['templateid']}") . "\n";
            }
        } else {
            echo "\t\t\t<li>" . $vbphrase['no_replacements_defined'] . "</li>\n";
        }
        echo "\t\t</ul><br />\n\t</li>\n</ul>\n<hr size=\"1\" />\n";
    }
    if (empty($stylecache)) {
        $styles = vB_Library::instance('Style')->fetchStyles(false, true);
        foreach ($styles as $style) {
            $stylecache[$style[parentid]][$style[displayorder]][$style[styleid]] = $style;
        }
    }
    // Check style actually exists / has children
    if (!isset($stylecache[$parentid])) {
        return;
    }
    foreach ($stylecache[$parentid] as $holder) {
        echo "{$indent}<ul class=\"lsq\">\n";
        foreach ($holder as $styleid => $style) {
            $style = vB_Library::instance('Style')->fetchStyleByID($styleid);
            echo "{$indent}<li><b>{$style['title']}</b>" . construct_link_code($vbphrase['add_new_replacement_variable'], "replacement.php?" . vB::getCurrentSession()->get('sessionurl') . "do=add&amp;dostyleid={$styleid}") . "\n";
            echo "\t{$indent}<ul class=\"ldi\">\n";
            $templates = $assertor->getRows('getReplacementTemplates', array('templateids' => $style['templatelist']));
            if ($templates) {
                foreach ($templates as $template) {
                    if (in_array($template['templateid'], $donecache)) {
                        echo "\t\t{$indent}<li class=\"col-i\">" . htmlspecialchars_uni($template['title']) . construct_link_code($vbphrase['customize_gstyle'], "replacement.php?" . vB::getCurrentSession()->get('sessionurl') . "do=edit&amp;dostyleid={$styleid}&amp;templateid={$template['templateid']}") . "</li>\n";
                    } else {
                        if ($template['styleid'] != -1) {
                            echo "\t\t{$indent}<li class=\"col-c\">" . htmlspecialchars_uni($template['title']) . construct_link_code($vbphrase['edit'], "replacement.php?" . vB::getCurrentSession()->get('sessionurl') . "do=edit&amp;dostyleid={$styleid}&amp;templateid={$template['templateid']}") . construct_link_code($vbphrase['delete'], "replacement.php?" . vB::getCurrentSession()->get('sessionurl') . "do=remove&amp;dostyleid={$styleid}&amp;templateid={$template['templateid']}") . "</li>\n";
                            $donecache[] = $template['templateid'];
                        } else {
                            echo "\t\t{$indent}<li class=\"col-g\">" . htmlspecialchars_uni($template['title']) . construct_link_code($vbphrase['customize_gstyle'], "replacement.php?" . vB::getCurrentSession()->get('sessionurl') . "do=edit&amp;dostyleid={$styleid}&amp;templateid={$template['templateid']}") . "</li>\n";
                        }
                    }
                }
            } else {
                echo "\t\t{$indent}<li>" . $vbphrase['no_replacements_defined'] . "</li>\n";
            }
            echo "{$indent}\t</ul><br />\n";
            print_replacements($styleid, "{$indent}\t");
            echo "{$indent}</li>\n";
        }
        echo "{$indent}</ul>\n";
        if ($style['parentid'] == -1) {
            echo "<hr size=\"1\" />\n";
        }
    }
}