[ Index ]

PHP Cross Reference of Nucleus CMS 3.64

title

Body

[close]

/nucleus3.64/nucleus/plugins/ -> NP_Text.php (source)

   1  <?php
   2   
   3  class NP_Text extends NucleusPlugin {
   4      
   5      var $incModePref = array();
   6      var $errorLogged = false;
   7      var $constantPrefix = "SL_";
   8   
   9  	function getEventList() { return array('PreSkinParse'); }
  10  	function getName() { return 'Text'; }
  11  	function getAuthor() { return 'Armon Toubman'; }
  12  	function getURL() { return 'http://forum.nucleuscms.org/viewtopic.php?t=14904'; }
  13  	function getVersion() { return '0.53'; }
  14  	function getDescription() {
  15          return 'Display constants from language files: <%Text(CONSTANT)%>';
  16      }
  17  	function supportsFeature($feature) {
  18          switch($feature) {
  19              case 'SqlTablePrefix': return 1;
  20              default: return 0;
  21          }
  22      } 
  23  	function install() {}
  24  	function uninstall() {}
  25  	function init() {
  26          $this->incModePref = $this->skin_incmodepref();
  27      }
  28      
  29  	function event_PreSkinParse() {
  30          global $member;
  31          if( !$member->isLoggedIn() and isset($_GET['lang']) ) {
  32              setcookie('NP_Text', getVar('lang'), time()+60*60*24*90); // 3 months
  33          }
  34      }
  35       
  36  	function doSkinVar($skinType, $constant) {
  37          global $member, $CONF;
  38          
  39          $language = getLanguageName();
  40          $getLanguage = isset($_GET['lang']) ? getVar('lang') : false;
  41          $cookieLanguage = isset($_COOKIE['NP_Text']) ? cookieVar('NP_Text') : false;
  42          
  43  //        if( !$member->isLoggedIn() ) {
  44              if( $getLanguage ) {
  45                  $this->use_lang($getLanguage, $constant);
  46              }
  47              elseif( $cookieLanguage ) {
  48                  $this->use_lang($cookieLanguage, $constant);
  49              }
  50              else {
  51                  $this->use_lang($language, $constant);
  52              }
  53  //        }
  54  //        else {
  55  //            $this->use_lang($language, $constant);
  56  //        }
  57          
  58      }
  59      
  60  	function doTemplateVar(&$item, $constant) {
  61          global $member, $CONF;
  62          
  63          $language = getLanguageName();
  64          $getLanguage = isset($_GET['lang']) ? getVar('lang') : false;
  65          $cookieLanguage = isset($_COOKIE['NP_Text']) ? cookieVar('NP_Text') : false;
  66          
  67  //        if( !$member->isLoggedIn() ) {
  68              if( $getLanguage ) {
  69                  $this->use_lang($getLanguage, $constant);
  70              }
  71              elseif( $cookieLanguage ) {
  72                  $this->use_lang($cookieLanguage, $constant);
  73              }
  74              else {
  75                  $this->use_lang($language, $constant);
  76              }
  77  //        }
  78  //        else {
  79  //            $this->use_lang($language, $constant);
  80  //        }
  81          
  82      }
  83      
  84  	function use_lang($language, $constant) {
  85          global $DIR_SKINS;
  86          
  87          $filename = '';
  88          
  89          if( $this->incModePref[0] == "normal" ) {
  90              $filename = $filename.$this->incModePref[1];
  91              $filename = $filename."language/";
  92              $filename = $filename.$language;
  93              $filename = $filename.".php";
  94          }
  95          elseif( $this->incModePref[0] == "skindir" ) {
  96              $filename = $filename.$DIR_SKINS;
  97              $filename = $filename.$this->incModePref[1];
  98              $filename = $filename."language/";
  99              $filename = $filename.$language;
 100              $filename = $filename.".php";
 101          }
 102          
 103          if( is_file($filename) ) {
 104              include($filename);
 105          }
 106          else {
 107              addToLog(1, "NP_Text cannot find ".$filename);
 108          }
 109          
 110          if( defined($this->constantPrefix.$constant) ) {
 111              echo constant($this->constantPrefix.$constant);
 112          }
 113          else {
 114              echo $this->constantPrefix.$constant;
 115              if( is_file($filename) ) {
 116                  addToLog(1, "NP_Text cannot find definition for ".$this->constantPrefix.$constant." in ".$filename);
 117              }
 118          }            
 119          
 120      }
 121      
 122  	function skin_incmodepref() {
 123          global $currentSkinName;
 124          $sql = "SELECT * FROM ".sql_table("skin_desc")." WHERE sdname = '".$currentSkinName."'";
 125          $result = sql_query($sql);
 126          $row = sql_fetch_array($result, MYSQL_ASSOC);
 127          return array($row['sdincmode'], $row['sdincpref']);
 128      }
 129      
 130  }
 131   
 132  ?>


Generated: Mon May 2 16:14:08 2011 Cross-referenced by PHPXref 0.7.1