Example #1
0
function __template($tFile)
{
    $tFileN = preg_replace('/\\.html$/', '', $tFile);
    $tFile = DIR_TEMPLATE . '/' . $tFileN . '.html';
    $cFile = DIR_COMPILED . '/' . str_replace('/', '_', $tFileN) . '.php';
    if (false === file_exists($tFile)) {
        die("Templace File [{$tFile}] Not Found!");
    }
    if (false === file_exists($cFile) || @filemtime($tFile) > @filemtime($cFile)) {
        __parse($tFile, $cFile);
    }
    return $cFile;
}
Example #2
0
function parse_sass($file)
{
    return __parse($file, 'sass');
}
Example #3
0
<?php

header('Content-type: text/css');
echo "/* Compiled SCSS */" . "\n";
require_once 'scss/SassParser.php';
//echo $_SERVER['SCRIPT_FILENAME'];
function __parse($src, $syntax, $style = 'nested')
{
    $options = array('style' => $style, 'cache' => FALSE, 'syntax' => $syntax, 'debug' => FALSE, 'callbacks' => array('warn' => 'cb_warn', 'debug' => 'cb_debug'));
    // Execute the compiler.
    $parser = new SassParser($options);
    return $parser->toCss($src, false);
}
// Buffer the source content
ob_start();
include $_SERVER['SCRIPT_FILENAME'];
$content = ob_get_clean();
echo __parse($content, 'scss');
exit;
Example #4
0
function fixAllBlogComments($dry, $debug = 0)
{
    global $method, $wgExternalDatawareDB, $wgCityId, $wgDBname, $wgDBcluster;
    $cluster = is_null($wgDBcluster) ? 'c1' : $wgDBcluster;
    $dbw = wfGetDB(DB_SLAVE);
    $res = $dbw->select(array('recentchanges'), array('rc_id, rc_title as page_title, rc_namespace as page_namespace'), array('rc_namespace' => NS_BLOG_ARTICLE_TALK, "( rc_title not rlike '.+[0-9]+\$' or rc_title not like '%@comment%' )", 'rc_timestamp between \'20100915000000\' and \'20100917000000\''), $method);
    $pages = array();
    while ($row = $dbw->fetchRow($res)) {
        $pages[] = $row;
    }
    $dbw->freeResult($res);
    if ($debug) {
        print sprintf("Found %s (%d): %0d pages \n", $wgDBname, $wgCityId, count($pages));
    }
    if (!empty($pages)) {
        foreach ($pages as $row) {
            if ($debug) {
                print "parse " . $row['page_title'] . "\n";
            }
            $parts = __parse($row['page_title']);
            # check blog exists
            $blog_page_id = __get_page_id($parts['title'], NS_BLOG_ARTICLE);
            # get page id of blog comment
            $row['page_id'] = __get_page_id($row['page_title'], NS_BLOG_ARTICLE_TALK);
            if ($parts['blog'] == 1 && count($parts['partsOriginal']) > 0 && $blog_page_id > 0) {
                $parts['parsed'] = array();
                foreach ($parts['partsOriginal'] as $id => $title) {
                    $parts['parsed'][$id] = sprintf('%s-%s', '@comment', $title);
                }
                $newTitle = sprintf('%s/%s', $parts['title'], implode("/", $parts['parsed']));
                if ($dry) {
                    error_log("update `{$wgDBname}`.`page` set page_title = '{$newTitle}' where page_title = '{$row['page_title']}' and page_namespace = '" . NS_BLOG_ARTICLE_TALK . "'; \n", 3, "/tmp/blog_" . $cluster . ".log");
                } else {
                    $dbw->update('page', array('page_title' => $newTitle), array('25812page_title' => $row['page_title'], 'page_namespace' => NS_BLOG_ARTICLE_TALK), $method);
                }
                # update job
                if ($dry) {
                    error_log("update `{$wgDBname}`.`job` set job_title = '{$newTitle}' where job_title = '{$row['page_title']}' and job_namespace = '" . NS_BLOG_ARTICLE_TALK . "'; \n", 3, "/tmp/blog_" . $cluster . ".log");
                } else {
                    $dbw->update('job', array('job_title' => $newTitle), array('job_title' => $row['page_title'], 'job_namespace' => NS_BLOG_ARTICLE_TALK), $method);
                }
                if ($dry) {
                    error_log(sprintf("update `{$wgDBname}`.`recentchanges` set rc_title = '%s' where rc_id = %d and rc_namespace = %d; \n", $newTitle, $row['rc_id'], NS_BLOG_ARTICLE_TALK), 3, "/tmp/blog_" . $cluster . ".log");
                } else {
                    $dbw->update('recentchanges', array('rc_title' => $newTitle), array('rc_id' => $row['rc_id'], 'rc_namespace' => NS_BLOG_ARTICLE_TALK), $method);
                }
                # update watchlist
                if ($dry) {
                    error_log("update `{$wgDBname}`.`watchlist` set wl_title = '{$newTitle}' where wl_title = '{$row['page_title']}' and wl_namespace = '" . NS_BLOG_ARTICLE_TALK . "'; \n", 3, "/tmp/blog_" . $cluster . ".log");
                } else {
                    $dbw->update('watchlist', array('wl_title' => $newTitle), array('wl_title' => $row['page_title'], 'wl_namespace' => NS_BLOG_ARTICLE_TALK), $method);
                }
                # update dataware
                if ($row['page_id'] > 0) {
                    if ($dry) {
                        error_log(sprintf("update pages set page_title = '%s' where page_id = %d and page_wikia_id = %d;\n", $newTitle, $row['page_id'], $wgCityId), 3, "/tmp/blog_dataware.log");
                    } else {
                        $dbext = wfGetDB(DB_MASTER, array(), $wgExternalDatawareDB);
                        $dbext->update('pages', array('page_title' => $newTitle), array('page_id' => $row['page_id'], "page_wikia_id" => $wgCityId), $method);
                    }
                }
            }
        }
    }
}