Пример #1
0
function ProcessDirectives($matches)
{
    global $replace_categories_order, $replace_galleries_order, $replace_categories_html, $replace_galleries_html;
    $directive = $matches[1];
    $options = $matches[2];
    $sub_inserts = ExtractSubs('INSERT', $options);
    $sub_galleries = ExtractSubs('GALLERIES', $options);
    $options = ExtractOptions($options);
    $output = '';
    switch ($matches[1]) {
        case 'DEFINE':
            if (isset($options['GLOBALDUPES'])) {
                $output .= "{define name=globaldupes value=" . strtolower($options['GLOBALDUPES']) . "}\n";
            }
            if (isset($options['PAGEDUPES'])) {
                $output .= "{define name=pagedupes value=" . strtolower($options['PAGEDUPES']) . "}\n";
            }
            break;
        case 'GALLERIES':
            if ($options['WHERE'] || $options['REWHERE']) {
                $output = "{* SORRY, GALLERIES DIRECTIVES THAT USE THE WHERE OPTION CANNOT BE AUTOMATICALLY CONVERTED\n" . $matches[0] . "\n*}";
            } else {
                $main_opts = ConvertGalleriesOptions($options, null);
                $html = isset($GLOBALS['HTML'][$options['HTML']]) ? $GLOBALS['HTML'][$options['HTML']] : $options['HTML'];
                $html = str_replace(array_keys($replace_galleries_html), array_values($replace_galleries_html), $html);
                $output = "{galleries\nvar=\$galleries\n" . join("\n", $main_opts) . "}\n";
                if (count($sub_galleries)) {
                    foreach (array('HASTHUMB', 'TYPE', 'FORMAT', 'CATEGORY', 'HTML', 'GETNEW', 'DATEFORMAT') as $opt) {
                        if (!isset($sub_galleries[0][$opt])) {
                            $sub_galleries[0][$opt] = $options[$opt];
                        }
                    }
                    $sub_opts = ConvertGalleriesOptions($sub_galleries[0], $options['AMOUNT']);
                    $output .= "{galleries\nvar=\$sub_galleries\n" . join("\n", $sub_opts) . "}\n" . "{intermix var=\$galleries from=\$galleries,\$sub_galleries location=" . $sub_galleries[0]['LOCATION'] . "}\n";
                }
                $output .= "\n{foreach var=\$gallery from=\$galleries counter=\$counter}\n" . $html . "\n";
                foreach ($sub_inserts as $insert) {
                    $output .= "{insert counter=\$counter location=" . $insert['LOCATION'] . "}\n" . $insert['HTML'] . "\n" . "{/insert}\n";
                }
                $output .= "{/foreach}";
            }
            break;
        case 'INCLUDE':
            $output = "{php}\ninclude('" . $options['FILE'] . "');\n{/php}";
            break;
        case 'PERL':
            $output = "{* SORRY, PERL CODE IS NOT SUPPORTED IN TGPX TEMPLATES\n" . $matches[0] . "\n*}";
            break;
        case 'TEMPLATE':
            $GLOBALS['HTML'][$options['NAME']] = $options['HTML'];
            break;
    }
    return $output;
}
Пример #2
0
function ProcessDirectives($matches)
{
    global $replace_categories_order, $replace_galleries_order, $replace_categories_html, $replace_galleries_html;
    $directive = $matches[1];
    $options = $matches[2];
    $sub_inserts = ExtractSubs('INSERT', $options);
    $sub_permanent = ExtractSubs('PERMANENT', $options);
    $options = ExtractOptions($options);
    $output = '';
    switch ($matches[1]) {
        case 'PERMANENT':
        case 'GALLERIES':
            $main_opts = ConvertGalleriesOptions($options, null, $directive);
            $html = isset($GLOBALS['HTML'][$options['HTML']]) ? $GLOBALS['HTML'][$options['HTML']] : $options['HTML'];
            $html = str_replace(array_keys($replace_galleries_html), array_values($replace_galleries_html), $html);
            $output = "{galleries\nvar=\$galleries\n" . join("\n", $main_opts) . "}\n";
            if (count($sub_permanent)) {
                $sub_opts = ConvertGalleriesOptions($sub_permanent[0], $options['AMOUNT'], 'PERMANENT');
                $output .= "{galleries\nvar=\$sub_permanent\n" . join("\n", $sub_opts) . "}\n" . "{intermix var=\$galleries from=\$galleries,\$sub_permanent location=" . $sub_permanent[0]['LOCATION'] . "}\n";
            }
            $output .= "\n{foreach var=\$gallery from=\$galleries counter=\$counter}\n" . $html . "\n";
            foreach ($sub_inserts as $insert) {
                $output .= "{insert counter=\$counter location=" . $insert['LOCATION'] . "}\n" . $insert['HTML'] . "\n" . "{/insert}\n";
            }
            $output .= "{/foreach}";
            break;
        case 'TEMPLATE':
            $GLOBALS['HTML'][$options['NAME']] = $options['HTML'];
            break;
    }
    return $output;
}