3 class NP_Text extends NucleusPlugin {
5 var $incModePref = array();
6 var $errorLogged = false;
7 var $constantPrefix = "SL_";
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)%>';
17 function supportsFeature($feature) {
19 case 'SqlTablePrefix': return 1;
24 function uninstall() {}
26 $this->incModePref = $this->skin_incmodepref();
29 function event_PreSkinParse() {
31 if( !$member->isLoggedIn() and isset($_GET['lang']) ) {
32 setcookie('NP_Text', getVar('lang'), time()+60*60*24*90); // 3 months
36 function doSkinVar(&$skinType, $constant) {
37 global $member, $CONF;
39 $language = getLanguageName();
40 $getLanguage = isset($_GET['lang']) ? getVar('lang') : false;
41 $cookieLanguage = isset($_COOKIE['NP_Text']) ? cookieVar('NP_Text') : false;
43 // if( !$member->isLoggedIn() ) {
45 $this->use_lang($getLanguage, $constant);
47 elseif( $cookieLanguage ) {
48 $this->use_lang($cookieLanguage, $constant);
51 $this->use_lang($language, $constant);
55 // $this->use_lang($language, $constant);
60 function doTemplateVar($item, $constant) {
61 global $member, $CONF;
63 $language = getLanguageName();
64 $getLanguage = isset($_GET['lang']) ? getVar('lang') : false;
65 $cookieLanguage = isset($_COOKIE['NP_Text']) ? cookieVar('NP_Text') : false;
67 // if( !$member->isLoggedIn() ) {
69 $this->use_lang($getLanguage, $constant);
71 elseif( $cookieLanguage ) {
72 $this->use_lang($cookieLanguage, $constant);
75 $this->use_lang($language, $constant);
79 // $this->use_lang($language, $constant);
84 function use_lang($language, $constant) {
89 if( $this->incModePref[0] == "normal" ) {
90 $filename = $filename.$this->incModePref[1];
91 $filename = $filename."language/";
92 $filename = $filename.$language;
93 $filename = $filename.".php";
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";
103 if( is_file($filename) ) {
107 addToLog(1, "NP_Text cannot find ".$filename);
110 if( defined($this->constantPrefix.$constant) ) {
111 echo constant($this->constantPrefix.$constant);
114 echo $this->constantPrefix.$constant;
115 if( is_file($filename) ) {
116 addToLog(1, "NP_Text cannot find definition for ".$this->constantPrefix.$constant." in ".$filename);
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']);