<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

require_once 'Pager.php';

/**
 * メーカーリスト
 *
 * @package     Adult.Customer.Itemview.Makerlist
 * @author      netnee <mail@example.com>
 * @access      public
 */
class General_Itemview_Sellerlist
{
    var $seller;
    
    var $title;
    var $pagename;

    var $session;
    var $makerview;
    var $sidemenu;

    var $recmaker;
    var $kanamaker;

    var $kanamakercount;

    var $name;
    var $selectkana;

    var $bodyid;
    
    var $sellers; // 出品者一覧
    
    /**
     * Pager設定
     */
    var $Pager_perPage;
    var $Pager_delta;
    var $Pager_append;
    var $Pager_clearIfVoid;
    var $Pager_linkClass;
    var $Pager_urlVar;
    var $Pager_useSessions;
    var $Pager_closeSession;
    var $Pager_mode;
    var $Pager_prevImg;
    var $Pager_nextImg;
    var $Pager_altPage;
    var $Pager_altPrev;
    var $Pager_altNext;
    var $Pager_altFirst;
    var $Pager_altLast;
    var $Pager_firstPagePre;
    var $Pager_firstPageText;
    var $Pager_firstPagePost;
    var $Pager_lastPagePre;
    var $Pager_lastPageText;
    var $Pager_lastPagePost;
    var $Pager_curPageSpanPre;
    var $Pager_curPageSpanPost;
    var $Pager_separator;
    var $Pager_spacesBeforeSeparator;
    var $Pager_spacesAfterSeparator;

    var $from;
    var $links;


    /**
     * execute
     *
     * @access  public
     */
    function execute()
    {
        $log =& LogFactory::getLog();
        $log->debug("General_Itemview_Sellerlistが実行されました", "General_Itemview_Sellerlist#execute");

        $this->bodyid = 'layout3';

        $perPage = $this->Pager_perPage;
        if (!is_numeric($this->from)) {
            $this->from = 1;
        }
        $from = ($this->from-1)*$perPage;

        $this->sellers = $this->seller->selectSellers($perPage, $from);
        foreach($this->sellers as &$seller) {
            // HTMLタグ削除
            $seller["infomation"] = strip_tags($seller["infomation"]);
            //文字制限20文字
            $len = 20;
            if (mb_strlen($seller["infomation"], "UTF-8") > $len) {
                $seller["infomation"] = mb_substr($seller["infomation"], 0, $len, "UTF-8") . "...";
            }
        }
        
        
        return 'success';
    }

    function setPagerData() {
        // Pager設定
        $pager_ini = array(
            'totalItems'            => $this->kanamakercount,
            'perPage'               => $this->Pager_perPage,                 // 1ページ表示件数
            'delta'                 => $this->Pager_delta,       // 表示ページから、前後に表示するページ数
            'append'                => $this->Pager_append,
            'clearIfVoid'           => $this->Pager_clearIfVoid,
            'linkClass'             => $this->Pager_linkClass,
            'urlVar'                => $this->Pager_urlVar,
            'useSessions'           => $this->Pager_useSessions,
            'closeSession'          => $this->Pager_closeSession,
            'mode'                  => $this->Pager_mode,
            'prevImg'               => $this->Pager_prevImg,
            'nextImg'               => $this->Pager_nextImg,
            'altPage'               => $this->Pager_altPage,
            'altPrev'               => $this->Pager_altPrev,
            'altNext'               => $this->Pager_altNext,
            'altFirst'              => $this->Pager_altFirst,
            'altLast'               => $this->Pager_altLast,
            'firstPagePre'          => $this->Pager_firstPagePre,
            'firstPageText'         => $this->Pager_firstPageText,
            'firstPagePost'         => $this->Pager_firstPagePost,
            'lastPagePre'           => $this->Pager_lastPagePre,
            'lastPageText'          => $this->Pager_lastPageText,
            'lastPagePost'          => $this->Pager_lastPagePost,
            'curPageSpanPre'        => $this->Pager_curPageSpanPre,
            'curPageSpanPost'       => $this->Pager_curPageSpanPost,
            'separator'             => $this->Pager_separator,
            'spacesBeforeSeparator' => $this->Pager_spacesBeforeSeparator,
            'spacesAfterSeparator'  => $this->Pager_spacesAfterSeparator
        );

        // Pager出力
        $pager = & Pager::factory($pager_ini);
        /*
        $this->pagedata = $pager->getPageData();
        $this->nowpages = $pager->getCurrentPageID();
        $this->totalpages = $pager->numPages();
        */
        $this->links = $pager->getLinks();
    }
    function getLink() {
        return $this->links;
    }


    // サイドメニュー用データ取得
    function getSideMenuData(){
        return $this->sidemenu->getSideMenuData(1);
    }

}
?>
