<?php
/**
 * @copyright ONE/DEPO Project
 * @license   PHP License 3.01 <http://www.php.net/license/3_01.txt>
 */


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

require_once 'Pager.php';

/**
 * レーベル一覧
 *
 * @package     Admin.Datamanage.Label.List
 * @author      Netnee <mail@example.com>
 * @access      public
 */
class Admin_Datamanage_Label_List
{
    var $c_label;
    var $row;
    var $cont;
    
    var $title;
    var $pagename;
    var $div;
    
    var $srcword;           //検索値
    var $srcrecommenddiv;   //おすすめ区分
    
    var $srcdispnum;        // 表示件数
    var $srcdispnumlist;    // 表示件数リスト
    
    // ソート順指定
    var $sortorder = "makernmkana, labelnmkana";
    
    var $pagedata;  // Pagerデータ
    var $links;     // Pagerリンク
    var $from;      // 現在のページID
    
    var $Pager_perPage;
    var $Pager_delta;
    var $Pager_append;
    var $Pager_clearIfVoid;
    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_separator;
    var $Pager_spacesBeforeSeparator;
    var $Pager_spacesAfterSeparator;
    
    var $frommakerlistnm;     // メーカー一覧からの遷移の際にメーカ名が入る
    var $frommakerlistpg;
    
    function execute()
    {
        // メーカ一覧からの遷移はメーカー名による検索取得
        if ( !empty($this->frommakerlistnm) ){
            $this->srcword = $this->frommakerlistnm;
        }
        
        if (!empty($this->srcword) || !empty($this->srcrecommenddiv)){
            // 検索取得
            $this->row = $this->c_label->viewselectSearch($this->srcword, $this->srcrecommenddiv, $this->sortorder);
        } else {
            // 全件取得
            $this->row = $this->c_label->viewselectAll($this->sortorder);
        }
        
        //取得したレコード数
        $this->cont = count($this->row);
        
        // 一覧表示件数
        if (!empty($this->srcdispnum)){
            $this->Pager_perPage = $this->srcdispnum;
        }
        
        // Pager設定
        $params = array(
            'itemData'      => $this->row,
            'perPage'       => $this->Pager_perPage,    // １ページの行数
            'delta'         => $this->Pager_delta,      // 表示ページから、前後に表示するページ数
            'append'        => $this->Pager_append,
            'clearIfVoid'   => $this->Pager_clearIfVoid,
            '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,
	        'separator'     => $this->Pager_separator, 
	        'spacesBeforeSeparator' => $this->Pager_spacesBeforeSeparator,
	        'spacesAfterSeparator'  => $this->Pager_spacesAfterSeparator
        );
        
        // Pager出力
        $pager = & Pager::factory($params);
        $this->pagedata = $pager->getPageData();
        $this->links = $pager->getLinks();
        
        return 'success';
    }
    
    
    /**
     * ページリンク取得
     * 
     * @return object ページリンク
     */
    function getLink()
    {
        return $this->links;
    }
}
?>
