コード例 #1
0
function wfAjaxCollectionGetItemList()
{
    $collection = $_SESSION['wsCollection'];
    $template = new CollectionListTemplate();
    $template->set('collection', $collection);
    $template->set('is_ajax', true);
    ob_start();
    $template->execute();
    $html = ob_get_contents();
    ob_end_clean();
    $json = new Services_JSON();
    $result = array();
    $result['html'] = $html;
    $result['collection'] = $collection;
    $r = new AjaxResponse($json->encode($result));
    $r->setContentType('application/json');
    return $r;
}
コード例 #2
0
    function execute()
    {
        $mediapath = $GLOBALS['wgExtensionAssetsPath'] . '/Collection/images/';
        ?>

<div class="collection-column collection-column-left">

<form action="<?php 
        echo htmlspecialchars(SkinTemplate::makeSpecialUrl('Book'));
        ?>
" method="post" id="mw-collection-title-form">
	<table id="mw-collection-title-table" style="width: 80%; background-color: transparent;" align="center">
		<tbody>
			<tr>
				<td class="mw-label"><label for="titleInput"><?php 
        $this->msg('coll-title');
        ?>
</label></td>
				<td class="mw-input"><input id="titleInput" type="text" name="collectionTitle" value="<?php 
        echo htmlspecialchars($this->data['collection']['title']);
        ?>
" /></td>
			</tr>
			<tr>
				<td class="mw-label"><label for="subtitleInput"><?php 
        $this->msg('coll-subtitle');
        ?>
</label></td>
				<td class="mw-input"><input id="subtitleInput" type="text" name="collectionSubtitle" value="<?php 
        echo htmlspecialchars($this->data['collection']['subtitle']);
        ?>
" /></td>
			</tr>
		</tbody>
	</table>
	<input type="hidden" name="bookcmd" value="set_titles" />
	<noscript>
		<input type="submit" value="<?php 
        $this->msg('coll-update');
        ?>
" />
	</noscript>
</form>

<div id="collectionListContainer">
<?php 
        $listTemplate = new CollectionListTemplate();
        $listTemplate->set('collection', $this->data['collection']);
        $listTemplate->execute();
        ?>
</div>
<div style="display:none">
	<span id="newChapterText"><?php 
        $this->msg('coll-new_chapter');
        ?>
</span>
	<span id="renameChapterText"><?php 
        $this->msg('coll-rename_chapter');
        ?>
</span>
	<span id="clearCollectionConfirmText"><?php 
        $this->msg('coll-clear_collection_confirm');
        ?>
</span>
</div>

</div>

<div class="collection-column collection-column-right">

	<div class="collection-column-right-box" id="coll-orderbox">
		<h2><span class="mw-headline"><?php 
        $this->msg('coll-book_title');
        ?>
</span></h2>
		<?php 
        $partnerData = $this->data['podpartners']['pediapress'];
        $this->msgWiki('coll-book_text');
        ?>
		<div>
			<div id="collection-order-button">
				<form action="<?php 
        echo htmlspecialchars(SkinTemplate::makeSpecialUrl('Book'));
        ?>
" method="post">
					<input type="hidden" name="bookcmd" value="post_zip" />
					<input type="hidden" name="partner" value="pediapress" />
					<input type="submit" value="<?php 
        echo wfMsgHtml('coll-order_from_pp', htmlspecialchars($partnerData['name']));
        ?>
" class="order" <?php 
        if (count($this->data['collection']['items']) == 0) {
            ?>
 disabled="disabled"<?php 
        }
        ?>
 />
				</form>
			</div>
		<?php 
        $t = Title::newFromText(wfMsgForContent('coll-order_info_article'));
        if ($t && $t->exists()) {
            ?>
			<div id="coll-more_info" style="display:none">
				<a href="javascript:void(0)" onclick="coll_toggle_order_info(true);"><img src="<?php 
            echo htmlspecialchars($mediapath . "collapse.png");
            ?>
" width="10" height="10" alt="" />&#160;<?php 
            $this->msg('coll-more_info');
            ?>
</a>
			</div>
			<div id="coll-hide_info" style="display:none">
				<a href="javascript:void(0)" onclick="coll_toggle_order_info(false);"><img src="<?php 
            echo htmlspecialchars($mediapath . "expand.png");
            ?>
" width="10" height="10" alt="" />&#160;<?php 
            $this->msg('coll-hide_info');
            ?>
</a>
			</div>
<?php 
        } else {
            ?>
			<a href="<?php 
            echo htmlspecialchars($partnerData['url']);
            ?>
" target="_blank"><?php 
            echo wfMsgHtml('coll-about_pp', htmlspecialchars($partnerData['name']));
            ?>
</a>
<?php 
        }
        ?>
		</div>
<?php 
        if ($t && $t->exists()) {
            ?>
		<div id="coll-order_info" style="display:none; margin-top: 2em;">
<?php 
            echo $GLOBALS['wgOut']->parse('{{:' . $t . '}}');
            ?>
		</div>
<?php 
        }
        ?>
	</div>

	<div class="collection-column-right-box" id="coll-downloadbox">
		<h2><span class="mw-headline"><?php 
        $this->msg('coll-download_title');
        ?>
</span></h2>
		<?php 
        if (count($this->data['formats']) == 1) {
            $writer = array_rand($this->data['formats']);
            echo wfMsgExt('coll-download_as_text', 'parse', $this->data['formats'][$writer]);
            $buttonLabel = wfMsgHtml('coll-download_as', htmlspecialchars($this->data['formats'][$writer]));
        } else {
            $this->msgWiki('coll-download_text');
            $buttonLabel = wfMsgHtml('coll-download');
        }
        ?>
		<form id="downloadForm" action="<?php 
        echo htmlspecialchars(SkinTemplate::makeSpecialUrl('Book'));
        ?>
" method="post">
			<table style="width:100%; background-color: transparent;"><tr><td><tbody><tr><td>
			<?php 
        if (count($this->data['formats']) == 1) {
            ?>
				<input type="hidden" name="writer" value="<?php 
            echo htmlspecialchars($writer);
            ?>
" />
			<?php 
        } else {
            ?>
				<label for="formatSelect"><?php 
            $this->msg('coll-format_label');
            ?>
</label>
				<select id="formatSelect" name="writer">
					<?php 
            foreach ($this->data['formats'] as $writer => $name) {
                ?>
					<option value="<?php 
                echo htmlspecialchars($writer);
                ?>
"><?php 
                echo htmlspecialchars($name);
                ?>
</option>
					<?php 
            }
            ?>
				</select>
			<?php 
        }
        ?>
			</td><td id="collection-download-button">
			<input type="hidden" name="bookcmd" value="render" />
			<input id="downloadButton" type="submit" value="<?php 
        echo $buttonLabel;
        ?>
"<?php 
        if (count($this->data['collection']['items']) == 0) {
            ?>
 disabled="disabled"<?php 
        }
        ?>
 />
			</td></tr></tbody></table>
		</form>
	</div>

	<?php 
        if ($GLOBALS['wgUser']->isLoggedIn()) {
            $canSaveUserPage = $GLOBALS['wgUser']->isAllowed('collectionsaveasuserpage');
            $canSaveCommunityPage = $GLOBALS['wgUser']->isAllowed('collectionsaveascommunitypage');
        } else {
            $canSaveUserPage = false;
            $canSaveCommunityPage = false;
        }
        if ($GLOBALS['wgEnableWriteAPI'] && ($canSaveUserPage || $canSaveCommunityPage)) {
            ?>
	<div class="collection-column-right-box" id="coll-savebox">
		<h2><span class="mw-headline"><?php 
            $this->msg('coll-save_collection_title');
            ?>
</span></h2>
		<?php 
            $this->msgWiki('coll-save_collection_text');
            $communityCollNS = $GLOBALS['wgCommunityCollectionNamespace'];
            ?>
			<form id="saveForm" action="<?php 
            echo htmlspecialchars(SkinTemplate::makeSpecialUrl('Book'));
            ?>
" method="post">
				<table style="width:100%; background-color: transparent;"><tbody>
				<?php 
            if ($canSaveUserPage) {
                ?>
				<tr><td>
				<?php 
                if ($canSaveCommunityPage) {
                    ?>
				<input id="personalCollType" type="radio" name="colltype" value="personal" checked="checked" />
				<?php 
                } else {
                    ?>
				<input type="hidden" name="colltype" value="personal" />
				<?php 
                }
                ?>
				<label for="personalCollTitle"><a href="<?php 
                echo htmlspecialchars(SkinTemplate::makeSpecialUrl('Prefixindex', 'prefix=' . wfUrlencode($this->data['user-book-prefix'])));
                ?>
"><?php 
                echo htmlspecialchars($this->data['user-book-prefix']);
                ?>
</a></label>
				</td>
				<td id="collection-save-input">
				<input id="personalCollTitle" type="text" name="pcollname" />
				</td></tr>
				<?php 
            }
            // if ($canSaveUserPage)
            ?>
				<?php 
            if ($canSaveCommunityPage) {
                ?>
				<tr><td>
				<?php 
                if ($canSaveUserPage) {
                    ?>
				<input id="communityCollType" type="radio" name="colltype" value="community" />
				<?php 
                } else {
                    ?>
				<input type="hidden" name="colltype" value="community" />
				<?php 
                }
                ?>
				<label for="communityCollTitle"><a href="<?php 
                echo htmlspecialchars(SkinTemplate::makeSpecialUrl('Prefixindex', 'prefix=' . wfUrlencode($this->data['community-book-prefix'])));
                ?>
"><?php 
                echo htmlspecialchars($this->data['community-book-prefix']);
                ?>
</a></label>
				</td>
				<td id="collection-save-button">
				<input id="communityCollTitle" type="text" name="ccollname" disabled="disabled" />
				</td></tr>
				<?php 
            }
            // if ($canSaveCommunityPage)
            ?>
				<tr><td>&#160;</td><td id="collection-save-button">
				<input id="saveButton" type="submit" value="<?php 
            $this->msg('coll-save_collection');
            ?>
"<?php 
            if (count($this->data['collection']['items']) == 0) {
                ?>
 disabled="disabled"<?php 
            }
            ?>
 />
				</tr></tbody></table>
				<input name="token" type="hidden" value="<?php 
            echo htmlspecialchars($GLOBALS['wgUser']->editToken());
            ?>
" />
				<input name="bookcmd" type="hidden" value="save_collection" />
			</form>

		<?php 
            $t = wfMsgForContent('coll-bookscategory');
            if (!wfEmptyMsg('coll-bookscategory', $t) && $t != '-') {
                $this->msgWiki('coll-save_category');
            }
            ?>
	</div>
	<?php 
        }
        ?>

</div>



<?php 
    }