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

Source for file skin.inc.php

Documentation is available at skin.inc.php

  1. <?php
  2.     /**
  3.      * @author            Matthias Reuter ($LastChangedBy: matthias $)
  4.      * @version            $LastChangedDate: 2008-10-31 23:53:28 +0000 (Fr, 31 Okt 2008) $
  5.      * @package            skin
  6.      * @copyright        2007-2010 IPBWI development team
  7.      * @link            http://ipbwi.com/examples/skin.php
  8.      * @since            2.0
  9.      * @license            http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License
  10.      */
  11.     class ipbwi_skin extends ipbwi {
  12.         public $emoURL            = false;
  13.         private $ipbwi            null;
  14.         /**
  15.          * @desc            Loads and checks different vars when class is initiating
  16.          * @author            Matthias Reuter
  17.          * @since            2.0
  18.          * @ignore
  19.          */
  20.         public function __construct($ipbwi){
  21.             // loads common classes
  22.             $this->ipbwi $ipbwi;
  23.             
  24.             $this->emoURL    = str_replace('<#EMO_DIR#>',$this->emoDir(),$this->ipbwi->ips_wrapper->settings['emoticons_url']);
  25.         }
  26.         /**
  27.          * @desc            Returns the Skin ID of the skin used by a member.
  28.          * @param    int        $memberID Member ID. If Member ID is ommitted, the current User will be used.
  29.          * @return    int        Skin ID or false on failure
  30.          * @author            Matthias Reuter
  31.          * @sample
  32.          *  <code>
  33.          *  $ipbwi->skin->id($memberID);
  34.          *  </code>
  35.          * @since            2.0
  36.          */
  37.         public function id($memberID false){
  38.             $member $this->ipbwi->member->info()// get user info...
  39.             if(isset($member['skin']&& $member['skin'!= ''){
  40.                 return $member['skin'];
  41.             }else{
  42.                 $sql $this->ipbwi->ips_wrapper->DB->query('SELECT set_id FROM '.$this->ipbwi->board['sql_tbl_prefix'].'skin_collections WHERE set_key = "default"');
  43.                 if($row $this->ipbwi->ips_wrapper->DB->fetch($sql)){
  44.                     return $row['set_id'];
  45.                 }else{
  46.                     return false;
  47.                 }
  48.             }
  49.         }
  50.         /**
  51.          * @desc            Gets information on a skin.
  52.          * @param    int        $skinID ID of the Skin
  53.          * @return    array    Information on Skin or false on failure
  54.          * @author            Matthias Reuter
  55.          * @sample
  56.          *  <code>
  57.          *  $ipbwi->skin->info($skinID);
  58.          *  </code>
  59.          * @since            2.0
  60.          */
  61.         public function info($skinID){
  62.             if($skinID >= 0)// If they've specified a skin
  63.                 $sql $this->ipbwi->ips_wrapper->DB->query('SELECT * FROM '.$this->ipbwi->board['sql_tbl_prefix'].'skin_collections WHERE set_id="'.$skinID.'"');
  64.                 if($row $this->ipbwi->ips_wrapper->DB->fetch($sql)){
  65.                     return $row;
  66.                 }else{
  67.                     return false;
  68.                 }
  69.             }else{
  70.                 return false;
  71.             }
  72.         }
  73.         /**
  74.          * @desc            Gets emoticon directory of currently logged in user.
  75.          * @return    array    emoticon dir
  76.          * @author            Matthias Reuter
  77.          * @sample
  78.          *  <code>
  79.          *  $ipbwi->skin->info($skinID);
  80.          *  </code>
  81.          * @since            2.0
  82.          */
  83.         public function emoDir(){
  84.             $member $this->ipbwi->member->info()// get user info...
  85.             
  86.             if(isset($member['skin']&& $member['skin'!= '')// for guests or if no skin is set...
  87.                 $skinID        $member['skin']// ...for skin id
  88.                 $default    false// ...make it the default skin
  89.             }else{
  90.                 $skinID        false;
  91.                 $default    true;
  92.             }
  93.             
  94.             $sql $this->ipbwi->ips_wrapper->DB->query('SELECT set_emo_dir FROM '.$this->ipbwi->board['sql_tbl_prefix'].'skin_collections WHERE '.(($default === true'set_key = "default"' 'set_id = '.$skinID));
  95.             $emodir $this->ipbwi->ips_wrapper->DB->fetch($sql);
  96.             return $emodir['set_emo_dir'].'/';
  97.         }
  98.         /**
  99.          * @desc            Pulls and displays CSS from forums depending on user's skin.
  100.          * @return    array    stylesheet fields
  101.          * @author            Matthias Reuter
  102.          * @sample
  103.          *  <code>
  104.          *  $ipbwi->skin->css();
  105.          *  $ipbwi->skin->css(true,false);
  106.          *  </code>
  107.          * @since            2.0
  108.          */
  109.         public function css(){
  110.             $member $this->ipbwi->member->info()// get user info...
  111.             
  112.             if(isset($member['skin']&& $member['skin'!= '')// for guests or if no skin is set...
  113.                 $skinID        $member['skin']// ...for skin id
  114.                 $default    false// ...make it the default skin
  115.             }else{
  116.                 $skinID        false;
  117.                 $default    true;
  118.             }
  119.             
  120.             // get css groups
  121.             $sql $this->ipbwi->ips_wrapper->DB->query('SELECT set_css_groups,set_image_dir FROM '.$this->ipbwi->board['sql_tbl_prefix'].'skin_collections WHERE '.(($default === true'set_key = "default"' ' set_id = '.$skinID));
  122.             $skin $this->ipbwi->ips_wrapper->DB->fetch($sql);
  123.             $CSSgroups unserialize($skin['set_css_groups']);
  124.             $c count($CSSgroups);
  125.             $i 1;
  126.             $CSSids['list''WHERE (css_id = ';
  127.             foreach($CSSgroups as $IDs => $g){
  128.                 if($i $c){
  129.                     $delimiter ') OR (css_id = ';
  130.                 }else{
  131.                     $delimiter ')';
  132.                 }
  133.                 $i++;
  134.                 $IDs explode('.',$IDs);
  135.                 $CSSids[$IDs[1];
  136.                 $CSSids['list'.= $IDs[1].$delimiter;
  137.             }
  138.             
  139.             // get CSS fields from DB
  140.             $query 'SELECT * FROM '.$this->ipbwi->board['sql_tbl_prefix'].'skin_css '.$CSSids['list'].' ORDER BY css_position ASC';
  141.             $sql $this->ipbwi->ips_wrapper->DB->query($query);
  142.             while($entry $this->ipbwi->ips_wrapper->DB->fetch($sql)){
  143.                 $style[$entry['css_group']]    str_replace('{style_images_url}'$skin['set_image_dir']$entry['css_content']);
  144.             }
  145.             return $style;
  146.         }
  147.         /**
  148.          * @desc            Grabs the IDs of all the avaliable skins.
  149.          * @return    array    Skin IDs
  150.          * @author            Matthias Reuter
  151.          * @sample
  152.          *  <code>
  153.          *  $ipbwi->skin->getList();
  154.          *  </code>
  155.          * @since            2.0
  156.          */
  157.         public function getList(){
  158.             // Grab all skins which aren't hidden
  159.             $sql $this->ipbwi->ips_wrapper->DB->query('SELECT set_id FROM '.$this->ipbwi->board['sql_tbl_prefix'].'skin_collections WHERE set_hide_from_list="0"');
  160.             $skins array();
  161.             while($row $this->ipbwi->ips_wrapper->DB->fetch($sql)){
  162.                 $skins[$row['set_id'];
  163.             }
  164.             return $skins;
  165.         }
  166.         /**
  167.          * @desc            Changes the current user's skin.
  168.          * @param    int        $skinID Skin ID
  169.          * @param    int        $memberID Member ID. If Member ID is ommitted, the current User will be used.
  170.          * @return    bool    true on success, otherwise false
  171.          * @author            Matthias Reuter
  172.          * @sample
  173.          *  <code>
  174.          *  $ipbwi->skin->set();
  175.          *  </code>
  176.          * @since            2.0
  177.          */
  178.         public function set($skinID,$memberID=false){
  179.             // Check it exists
  180.             if($this->info($skinID)){
  181.                 // Grab current member id unless specified
  182.                 $member $this->ipbwi->member->info()// get user info...
  183.                 if($this->ipbwi->member->updateMember(array('skin' => $skinID)$member['member_id'])){
  184.                     return true;
  185.                 }else{
  186.                     return false;
  187.                 }
  188.             }else{
  189.                 $this->ipbwi->addSystemMessage('Error',$this->ipbwi->getLibLang('skinNotExist'),'Located in file <strong>'.__FILE__.'</strong> at class <strong>'.__CLASS__.'</strong> in function <strong>'.__FUNCTION__.'</strong> on line #<strong>'.__LINE__.'</strong>');
  190.                 return false;
  191.             }
  192.         }
  193.     }
  194. ?>

Documentation generated on Sat, 23 Oct 2010 23:36:11 +0200 by phpDocumentor 1.4.3