Exemplo n.º 1
0
        foreach ($keywords as $keyword) {
            $wk = Model::factory('WikiKeyword')->create();
            $wk->wikiArticleId = $curPage->id;
            $wk->keyword = $keyword;
            $wk->save();
        }
        log_scriptLog("Saved page #{$pageId} \"{$title}\"");
    }
}
// Now delete all the pages on our side that aren't category members because
//   (a) they have been deleted or
//   (b) they have been removed from the category
$ourIds = db_getArray('select pageId from WikiArticle');
foreach ($ourIds as $ourId) {
    if (!array_key_exists($ourId, $pageIdHash)) {
        $curPage = WikiArticle::get_by_pageId($ourId);
        log_scriptLog("Deleting page #{$curPage->pageId} \"{$curPage->title}\"");
        $curPage->delete();
    }
}
log_scriptLog('syncWikiArticles.php finished');
/*************************************************************************/
function parse($text)
{
    // Preprocessing
    $text = "__NOEDITSECTION__\n" . $text;
    // Otherwise the returned HTML will contain section edit links
    $text = str_replace(array('ş', 'Ş', 'ţ', 'Ţ'), array('ș', 'Ș', 'ț', 'Ț'), $text);
    // Actual parsing
    $xmlString = util_makePostRequest(PARSER_URL, array('action' => 'parse', 'text' => $text, 'format' => 'xml', 'editsection' => false));
    $xml = simplexml_load_string($xmlString);