Net_UserAgent_Mobile
[ class tree: Net_UserAgent_Mobile ] [ index: Net_UserAgent_Mobile ] [ all elements ]

Source for file Display.php

Documentation is available at Display.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3.  
  4. /**
  5.  * PHP versions 4 and 5
  6.  *
  7.  * Copyright (c) 2003-2009 KUBO Atsuhiro <kubo@iteman.jp>,
  8.  * All rights reserved.
  9.  *
  10.  * Redistribution and use in source and binary forms, with or without
  11.  * modification, are permitted provided that the following conditions are met:
  12.  *
  13.  *     * Redistributions of source code must retain the above copyright
  14.  *       notice, this list of conditions and the following disclaimer.
  15.  *     * Redistributions in binary form must reproduce the above copyright
  16.  *       notice, this list of conditions and the following disclaimer in the
  17.  *       documentation and/or other materials provided with the distribution.
  18.  *
  19.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  20.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  21.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  22.  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  23.  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  24.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  25.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  26.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  27.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  28.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  29.  * POSSIBILITY OF SUCH DAMAGE.
  30.  *
  31.  * @category   Networking
  32.  * @package    Net_UserAgent_Mobile
  33.  * @author     KUBO Atsuhiro <kubo@iteman.jp>
  34.  * @copyright  2003-2009 KUBO Atsuhiro <kubo@iteman.jp>
  35.  * @license    http://www.opensource.org/licenses/bsd-license.php  New BSD License
  36.  * @version    CVS: $Id: Display.php,v 1.1 2009/05/26 08:48:16 kuboa Exp $
  37.  * @since      File available since Release 0.1
  38.  */
  39.  
  40. // {{{ Net_UserAgent_Mobile_Display
  41.  
  42. /**
  43.  * Display information for Net_UserAgent_Mobile
  44.  *
  45.  * Net_UserAgent_Mobile_Display is a class for display information on
  46.  * {@link Net_UserAgent_Mobile}. Handy for image resizing or dispatching.
  47.  *
  48.  * SYNOPSIS:
  49.  * <code>
  50.  * require_once 'Net/UserAgent/Mobile.php';
  51.  *
  52.  * $agent = &Net_UserAgent_Mobile::factory();
  53.  * $display = $agent->getDisplay();
  54.  *
  55.  * $width  = $display->getWidth();
  56.  * $height = $display->getHeight();
  57.  * list($width, $height) = $display->getSize();
  58.  *
  59.  * if ($display->isColor()) {
  60.  *     $depth = $display->getDepth();
  61.  * }
  62.  *
  63.  * // only available in DoCoMo 505i
  64.  * $width_bytes  = $display->getWidthBytes();
  65.  * $height_bytes = $display->getHeightBytes();
  66.  * </code>
  67.  *
  68.  * USING EXTERNAL MAP FILE:
  69.  * If the environment variable DOCOMO_MAP exists, the specified XML data will be used
  70.  * for DoCoMo display information.
  71.  *
  72.  * ex) Please add the following code.
  73.  * $_SERVER['DOCOMO_MAP'] = '/path/to/DoCoMoMap.xml';
  74.  *
  75.  * @category   Networking
  76.  * @package    Net_UserAgent_Mobile
  77.  * @author     KUBO Atsuhiro <kubo@iteman.jp>
  78.  * @copyright  2003-2009 KUBO Atsuhiro <kubo@iteman.jp>
  79.  * @license    http://www.opensource.org/licenses/bsd-license.php  New BSD License
  80.  * @version    Release: 1.0.0
  81.  * @since      Class available since Release 0.1
  82.  */
  83. {
  84.  
  85.     // {{{ properties
  86.  
  87.     /**#@+
  88.      * @access public
  89.      */
  90.  
  91.     /**#@-*/
  92.  
  93.     /**#@+
  94.      * @access private
  95.      */
  96.  
  97.     /**
  98.      * width of the display
  99.      * @var integer 
  100.      */
  101.     var $_width;
  102.  
  103.     /**
  104.      * height of the display
  105.      * @var integer 
  106.      */
  107.     var $_height;
  108.  
  109.     /**
  110.      * depth of the display
  111.      * @var integer 
  112.      */
  113.     var $_depth;
  114.  
  115.     /**
  116.      * color capability of the display
  117.      * @var boolean 
  118.      */
  119.     var $_color;
  120.  
  121.     /**
  122.      * width (bytes) of the display
  123.      * @var integer 
  124.      */
  125.     var $_widthBytes;
  126.  
  127.     /**
  128.      * height (bytes) of the display
  129.      * @var integer 
  130.      */
  131.     var $_heightBytes;
  132.  
  133.     /**#@-*/
  134.  
  135.     /**#@+
  136.      * @access public
  137.      */
  138.  
  139.     // }}}
  140.     // {{{ constructor
  141.  
  142.     /**
  143.      * constructor
  144.      *
  145.      * @param array $data display infomation
  146.      */
  147.     function Net_UserAgent_Mobile_Display($data)
  148.     {
  149.         $this->_width  = (integer)@$data['width'];
  150.         $this->_height = (integer)@$data['height'];
  151.         $this->_depth  = (integer)@$data['depth'];
  152.         $this->_color  = (boolean)@$data['color'];
  153.  
  154.         $this->_widthBytes  = (integer)@$data['width_bytes'];
  155.         $this->_heightBytes = (integer)@$data['height_bytes'];
  156.     }
  157.  
  158.     // }}}
  159.     // {{{ calcSize()
  160.  
  161.     /**
  162.      * returns width * height of the display
  163.      *
  164.      * @return integer 
  165.      */
  166.     function calcSize()
  167.     {
  168.         return $this->_width $this->_height;
  169.     }
  170.  
  171.     // }}}
  172.     // {{{ getSize()
  173.  
  174.     /**
  175.      * returns width with height of the display
  176.      *
  177.      * @return array 
  178.      */
  179.     function getSize()
  180.     {
  181.         return array($this->_width$this->_height);
  182.     }
  183.  
  184.     // }}}
  185.     // {{{ getWidth()
  186.  
  187.     /**
  188.      * returns width of the display
  189.      *
  190.      * @return integer 
  191.      */
  192.     function getWidth()
  193.     {
  194.         return $this->_width;
  195.     }
  196.  
  197.     // }}}
  198.     // {{{ getHeight()
  199.  
  200.     /**
  201.      * returns height of the display
  202.      *
  203.      * @return integer 
  204.      */
  205.     function getHeight()
  206.     {
  207.         return $this->_height;
  208.     }
  209.  
  210.     // }}}
  211.     // {{{ getDepth()
  212.  
  213.     /**
  214.      * returns depth of the display
  215.      *
  216.      * @return integer 
  217.      */
  218.     function getDepth()
  219.     {
  220.         return $this->_depth;
  221.     }
  222.  
  223.     // }}}
  224.     // {{{ isColor()
  225.  
  226.     /**
  227.      * returns true if the display has color capability
  228.      *
  229.      * @return boolean 
  230.      */
  231.     function isColor()
  232.     {
  233.         return $this->_color;
  234.     }
  235.  
  236.     // }}}
  237.     // {{{ getWidthBytes()
  238.  
  239.     /**
  240.      * returns width (bytes) of the display
  241.      *
  242.      * @return integer 
  243.      */
  244.     function getWidthBytes()
  245.     {
  246.         return $this->_widthBytes;
  247.     }
  248.  
  249.     // }}}
  250.     // {{{ getHeightBytes()
  251.  
  252.     /**
  253.      * returns height (bytes) of the display
  254.      *
  255.      * @return integer 
  256.      */
  257.     function getHeightBytes()
  258.     {
  259.         return $this->_heightBytes;
  260.     }
  261.  
  262.     /**#@-*/
  263.  
  264.     /**#@+
  265.      * @access private
  266.      */
  267.  
  268.     /**#@-*/
  269.  
  270.     // }}}
  271. }
  272.  
  273. // }}}
  274.  
  275. /*
  276.  * Local Variables:
  277.  * mode: php
  278.  * coding: iso-8859-1
  279.  * tab-width: 4
  280.  * c-basic-offset: 4
  281.  * c-hanging-comment-ender-p: nil
  282.  * indent-tabs-mode: nil
  283.  * End:
  284.  */

Documentation generated on Tue, 23 Jun 2009 10:00:03 +0000 by phpDocumentor 1.4.2. PEAR Logo Copyright © PHP Group 2004.