<?php
/**
 * カテゴリー・ページの一覧画面
 *
 * Copyright (c) 2010-2011 SetucoCMS Project.(http://sourceforge.jp/projects/setucocms)
 * All Rights Reserved.
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * @category   Setuco
 * @package    Admin
 * @subpackage View_Script_Directory
 * @license    http://www.opensource.org/licenses/gpl-2.0.php GNU General Public License, version 2
 * @copyright  Copyright (c) 2010 SetucoCMS Project.(http://sourceforge.jp/projects/setucocms)
 * @link
 * @version
 * @since      File available since Release 0.1.0
 * @param      Zend_Navigation $directory サイト構造の情報
 * @author     charlesvineyard
 */
?>

<!-- topicPath START -->
<div id="topicPath">
    <p>
        <a href="<?php echo $this->baseUrl('/admin') ?>">トップ</a>
        <img src="<?php echo $this->baseUrl('/images/admin/share/topicPath.gif') ?>" width="6" height="11" alt="の中の" />
    </p>
    <p>サイト構造（カテゴリー・ページの一覧）</p>
</div>
<!-- topicpath END -->

<!-- section START -->
<div class="section">
    <div class="hAreaL">
        <div class="hAreaR">
            <div class="hArea">
                <h3>
                    <img src="<?php echo $this->baseUrl('/images/admin/directory/h_directory.jpg') ?>" width="283" height="18" alt="サイト構造（カテゴリー・ページの一覧）" />
                </h3>
            </div>
        </div>
    </div>

    <ul id="directory">
    <?php
    foreach ($this->directory as $category):
        $pageCount = $category->count();
    ?>
        <li class="category<?php echo $this->cycle(array(' check', ''))->next() ?>">
            <?php if ($pageCount === 0): // カテゴリーの中身が空のとき ?>
            <div>
                <p class="folder">
                    <img src="<?php echo $this->baseUrl('/images/admin/directory/icn_category_noChild.gif') ?>" width="36" height="19" alt="カテゴリー" /><?php echo $this->escape($category->getLabel()) ?>
                </p>
                <p>
                    <img src="<?php echo $this->baseUrl('/images/admin/directory/icn_page.gif') ?>" width="11" height="12" alt="このカテゴリーに含まれるページ" /><?php echo $pageCount ?>
                </p>
            </div>
            <?php else: // カテゴリーの中身があるとき ?>
            <div>
                <p class="folder" onclick="openCategory(this, '<?php echo $this->baseUrl('/images/admin/directory/icn_category_open.gif') ?>', '<?php echo $this->baseUrl('/images/admin/directory/icn_category_close.gif') ?>')">
                    <img src="<?php echo $this->baseUrl('/images/admin/directory/icn_category_close.gif') ?>" width="36" height="19" alt="カテゴリーを開く" /><?php echo $this->escape($category->getLabel()) . "\n" ?>
                </p>
                <p>
                    <a href="<?php echo $category->getHref() ?>">
                        <img src="<?php echo $this->baseUrl('/images/admin/directory/icn_page.gif') ?>" width="11" height="12" alt="このカテゴリーに含まれるページ" /><?php echo $pageCount . "\n" ?>
                    </a>
                </p>
            </div>
            <ul>
            <?php
            $i = 0;
            foreach ($category as $page):
                $i++;
            ?>
                <li class="page<?php echo ($i === $pageCount) ? ' lastChild' : '' ?>">
                    <div>
                    <?php if ($page->getVisible()): // ページ公開中の場合?>
                        <p>
                            <a href="<?php echo $page->getViewHref() ?>" target="_blank">
                                <img src="<?php echo $this->baseUrl('/images/admin/directory/icn_check.gif') ?>" width="18" height="15" alt="ページを確認" />
                            </a>
                        </p>
                        <p>
                            <a href="<?php echo $page->getEditHref() ?>">
                                <?php echo $this->escape($page->getLabel()) ?><img src="<?php echo $this->baseUrl('/images/admin/directory/icn_edit.gif') ?>" width="17" height="17" alt="編集" />
                            </a>
                        </p>
                    <?php else: // ページ下書きの場合?>
                        <p>
                            <img src="<?php echo $this->baseUrl('/images/admin/directory/icn_check_no.gif') ?>" width="18" height="15" alt="下書きは表示できません" />
                        </p>
                        <p>
                            <a href="<?php echo $page->getEditHref() ?>">
                                <?php echo $this->escape($page->getLabel()) ?><img src="<?php echo $this->baseUrl('/images/admin/directory/icn_edit.gif') ?>" width="17" height="17" alt="編集" />
                            </a>
                        </p>
                    <?php endif ?>
                    </div>
                </li>
            <?php endforeach ?>
            </ul>
            <?php endif ?>
        </li>
    <?php endforeach ?>
    </ul>
</div>
<!-- section END -->
