<?php
/**
 * Copyright (C) LJCMS All rights reserved.
 * <E-Mail：aspcms@qq.com>
 * Url http://www.liangjing.org
 *     http://www.8CMS.com
 * Update 2016.03.19
 */

class labelIModel extends X {
    
    public function repLabel($content) {
      
        if (!empty($content)) {
            return str_ireplace(
                array("{\$config.sitename}", "{\$config.siteurl}", "{\$config.sitetitle}", "{\$urlpath}", "{\$skinpath}"),
                array(parent::$cfg['sitename'], parent::$cfg['siteurl'], parent::$cfg['sitetitle'], parent::$urlpath, parent::$skinpath),
                $content
            );
        }
        else {
            return '';
        }
    }
    
    public function repWapLabel($content) {
        if (!empty($content)){
            if ($content == '{$config.siteurl}'){
                return parent::$cfg['siteurl'].'wap.php';
            }else{
                return str_ireplace('index', 'wap', str_ireplace(
                    array("{\$config.sitename}", "{\$config.siteurl}", "{\$config.sitetitle}", "{\$urlpath}", "{\$skinpath}"),
                    array(parent::$cfg['sitename'], parent::$cfg['siteurl'], parent::$cfg['sitetitle'], parent::$urlpath, parent::$skinpath),
                    $content
                ));
            } 
        }else{
          return '';
        }
    }
    
    
    public function getOne($labelname) {
         $lang= parent::$lang;
            $sql = "SELECT `content` FROM ".DB_PREFIX."htmllabel".
                    " WHERE `labelname`='{$labelname}' AND lang='$lang'";
            $data = parent::$obj->fetch_first($sql);
            if (!empty($data['content'])) {
                return $this->repLabel($data['content']);
            }
            else {
                return '';
            }
            unset($sql, $data);   
        
        unset($cache);
    } 
}
?>
