private function deleteUnusedArticles()
 {
     $newList = array();
     foreach ($this->mLinkList as $item) {
         if (CollectionSession::findArticle($item['name']) != -1) {
             $newList[] = $item;
         }
     }
     $this->mLinkList = $newList;
 }
/**
 * Backend of several following SAJAX function handlers...
 * @param String $action provided by the specific handlers internally
 * @param String $article title passed in from client
 * @return AjaxResponse with JSON-encoded array including HTML fragment.
 */
function wfCollectionSuggestAction($action, $article)
{
    $json = new Services_JSON();
    $result = CollectionSuggest::refresh($action, $article);
    $undoLink = Xml::element('a', array('href' => SkinTemplate::makeSpecialUrl('Book', array('bookcmd' => 'suggest', 'undo' => $action, 'arttitle' => $article)), 'onclick' => "collectionSuggestCall('UndoArticle'," . Xml::encodeJsVar(array($action, $article)) . "); return false;", 'title' => wfMsg('coll-suggest_undo_tooltip')), wfMsg('coll-suggest_undo'));
    $result['last_action'] = wfMsg("coll-suggest_article_{$action}", htmlspecialchars($article), $undoLink);
    $result['collection'] = CollectionSession::getCollection();
    $r = new AjaxResponse($json->encode($result));
    $r->setContentType('application/json');
    return $r;
}
 /**
  * @param $title Title
  * @param $forceOverwrite bool
  * @return bool
  */
 function saveCollection($title, $forceOverwrite = false)
 {
     global $wgRequest, $wgUser;
     $article = new Article($title);
     if ($article->exists() && !$forceOverwrite) {
         return false;
     }
     $articleText = "{{" . wfMsgForContent('coll-savedbook_template') . "}}\n\n";
     $collection = CollectionSession::getCollection();
     if ($collection['title']) {
         $articleText .= '== ' . $collection['title'] . " ==\n";
     }
     if ($collection['subtitle']) {
         $articleText .= '=== ' . $collection['subtitle'] . " ===\n";
     }
     if (!empty($collection['items'])) {
         foreach ($collection['items'] as $item) {
             if ($item['type'] == 'chapter') {
                 $articleText .= ';' . $item['title'] . "\n";
             } elseif ($item['type'] == 'article') {
                 if ($item['currentVersion'] == 1) {
                     $articleText .= ":[[" . $item['title'];
                     if (isset($item['displaytitle']) && $item['displaytitle']) {
                         $articleText .= "|" . $item['displaytitle'];
                     }
                     $articleText .= "]]\n";
                 } else {
                     $articleText .= ":[{{fullurl:" . $item['title'];
                     $articleText .= "|oldid=" . $item['revision'] . "}} ";
                     if (isset($item['displaytitle']) && $item['displaytitle']) {
                         $articleText .= $item['displaytitle'];
                     } else {
                         $articleText .= $item['title'];
                     }
                     $articleText .= "]\n";
                 }
             }
             // $articleText .= $item['revision'] . "/" . $item['latest']."\n";
         }
     }
     $t = wfMsgForContent('coll-bookscategory');
     if (!wfEmptyMsg('coll-bookscategory', $t) && $t != '-') {
         $catTitle = Title::makeTitle(NS_CATEGORY, $t);
         if (!is_null($catTitle)) {
             $articleText .= "\n[[" . $catTitle->getPrefixedText() . "|" . wfEscapeWikiText($title->getSubpageText()) . "]]\n";
         }
     }
     $req = new DerivativeRequest($wgRequest, array('action' => 'edit', 'title' => $title->getPrefixedText(), 'text' => $articleText, 'token' => $wgUser->editToken()), true);
     $api = new ApiMain($req, true);
     $api->execute();
     return true;
 }
    function execute()
    {
        echo wfMsgExt('coll-rendering_finished_text', 'parse', $this->data['download_url']);
        if ($this->data['is_cached']) {
            $forceRenderURL = SkinTemplate::makeSpecialUrl('Book', 'bookcmd=forcerender&' . $this->data['query']);
            echo wfMsg('coll-is_cached', htmlspecialchars($forceRenderURL));
        }
        echo wfMsgExt('coll-excluded-templates', 'parse', wfMsgForContent('coll-exclusion_category_title'));
        $title_string = wfMsgForContent('coll-template_blacklist_title');
        $t = Title::newFromText($title_string);
        if ($t && $t->exists()) {
            echo wfMsgExt('coll-blacklisted-templates', 'parse', $title_string);
        }
        if ($this->data['return_to']) {
            // We are doing this the hard way (i.e. via the HTML detour), to prevent
            // the parser from replacing [[:Special:Book]] with a selflink.
            $t = Title::newFromText($this->data['return_to']);
            echo wfMsg('coll-return_to_collection', htmlspecialchars($t->getFullURL()), htmlspecialchars($this->data['return_to']));
        }
        if (CollectionSession::isEnabled()) {
            $title_string = wfMsgForContent('coll-finished_collection_info_text_article');
        } else {
            $title_string = wfMsgForContent('coll-finished_page_info_text_article');
        }
        $t = Title::newFromText($title_string);
        if ($t && $t->exists()) {
            echo $GLOBALS['wgOut']->parse('{{:' . $t . '}}');
        }
        ?>

<?php 
    }