public function doForm($filename)
{
global $DIR_NUCLEUS;
- array_push($this->parser->actions,'formdata','text','callback','errordiv','ticket');
+ array_push($this->parser->actions,'formdata', 'callback','errordiv','ticket');
$oldIncludeMode = Parser::getProperty('IncludeMode');
$oldIncludePrefix = Parser::getProperty('IncludePrefix');
array_pop($this->parser->actions); // errordiv
array_pop($this->parser->actions); // callback
- array_pop($this->parser->actions); // text
array_pop($this->parser->actions); // formdata
array_pop($this->parser->actions); // ticket
return;
}
/**
- * Actions::parse_text()
- * Parse text
- *
- * @param void
- * @return void
- */
- public function parse_text($which)
- {
- // constant($which) only available from 4.0.4 :(
- if ( defined($which) )
- {
- eval("echo $which;");
- }
- return;
- }
-
- /**
* Actions::parse_ticket()
* Parse ticket
*
$manager->notify("Init{$this->event_identifier}Parse", array('skin' => &$this, 'type' => $type));
+ // include skin locale file for <%text%> tag if useable
+ $this->includeLocaleFile(i18n::get_current_locale());
+
// set output type
sendContentType($this->getContentType(), 'skin');
}
/**
+ * Skin::includeLocaleFile()
+ *
+ * @param string $locale locale name
+ * @return void
+ */
+ private function includeLocaleFile($locale)
+ {
+ global $DIR_SKINS;
+
+ if( $this->includeMode == "normal" )
+ {
+ $filename = "./locale/{$locale}.php";
+ }
+ elseif( $this->includeMode == "skindir" )
+ {
+ if ( $this->includePrefix == '' )
+ {
+ $filename = "{$DIR_SKINS}locale/{$locale}.php";
+ }
+ else
+ {
+ $filename = "{$DIR_SKINS}{$this->includePrefix}locale/{$locale}.php";
+ }
+ }
+ else
+ {
+ return;
+ }
+
+ if ( !file_exists($filename) )
+ {
+ return;
+ }
+
+ include_once($filename);
+
+ return;
+ }
+
+ /**
* Skin::getDefaultTypes()
*
* @param string void
+++ /dev/null
-<?php
-/*
-License:
-This software is published under the same license as NucleusCMS, namely
-the GNU General Public License. See http://www.gnu.org/licenses/gpl.html for
-details about the conditions of this license.
-
-In general, this program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your option) any
-later version.
-
-This program is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-* @version $Id: NP_Text.php 1678 2012-02-26 07:31:36Z sakamocchi $
-*/
-class NP_Text extends NucleusPlugin
-{
- public $incModePref = array();
- public $errorLogged = false;
- public $constantPrefix = "SL_";
-
- public function getName()
- {
- return 'Text';
- }
- public function getAuthor()
- {
- return 'Armon Toubman';
- }
-
- public function getURL()
- {
- return 'http://forum.nucleuscms.org/viewtopic.php?t=14904';
- }
-
- public function getVersion()
- {
- return '0.53';
- }
-
- public function getDescription()
- {
- return 'Display constants from translation files: <%Text(CONSTANT)%>';
- }
-
- public function getEventList()
- {
- return array('PreSkinParse');
- }
-
- public function supportsFeature($feature)
- {
- return ( $feature == 'SqlTablePrefix' );
- }
-
- public function install()
- {
- return;
- }
-
- public function uninstall()
- {
- return;
- }
-
- public function init()
- {
- $this->incModePref = $this->skin_incmodepref();
- return;
- }
-
- public function event_PreSkinParse()
- {
- global $member;
- if( !$member->isLoggedIn() and isset($_GET['lang']) )
- {
- /* 3 months */
- setcookie('NP_Text', getVar('lang'), time()+60*60*24*90);
- }
- return;
- }
-
- public function doSkinVar($skinType, $constant)
- {
- global $member, $CONF;
-
- $language = getLanguageName();
- $getLanguage = isset($_GET['lang']) ? getVar('lang') : false;
- $cookieLanguage = isset($_COOKIE['NP_Text']) ? cookieVar('NP_Text') : false;
-
- if( $getLanguage )
- {
- $this->use_lang($getLanguage, $constant);
- }
- elseif( $cookieLanguage )
- {
- $this->use_lang($cookieLanguage, $constant);
- }
- else
- {
- $this->use_lang($language, $constant);
- }
- return;
- }
-
- public function doTemplateVar(&$item, $constant)
- {
- global $member, $CONF;
-
- $language = getLanguageName();
- $getLanguage = isset($_GET['lang']) ? getVar('lang') : false;
- $cookieLanguage = isset($_COOKIE['NP_Text']) ? cookieVar('NP_Text') : false;
-
- if( $getLanguage )
- {
- $this->use_lang($getLanguage, $constant);
- }
- elseif( $cookieLanguage )
- {
- $this->use_lang($cookieLanguage, $constant);
- }
- else
- {
- $this->use_lang($language, $constant);
- }
- return;
- }
-
- private function use_lang($language, $constant)
- {
- global $DIR_SKINS;
-
- $filename = '';
-
- if( $this->incModePref[0] == "normal" )
- {
- $filename = $filename.$this->incModePref[1];
- $filename = $filename."language/";
- $filename = $filename.$language;
- $filename = $filename.".php";
- }
- elseif( $this->incModePref[0] == "skindir" )
- {
- $filename = $filename.$DIR_SKINS;
- $filename = $filename.$this->incModePref[1];
- $filename = $filename."language/";
- $filename = $filename.$language;
- $filename = $filename.".php";
- }
-
- if ( is_file($filename) )
- {
- include($filename);
- }
- else
- {
- addToLog(1, "NP_Text cannot find ".$filename);
- }
-
- if ( defined($this->constantPrefix.$constant) )
- {
- echo constant($this->constantPrefix.$constant);
- }
- else
- {
- echo $this->constantPrefix.$constant;
- if( is_file($filename) )
- {
- addToLog(1, "NP_Text cannot find definition for ".$this->constantPrefix.$constant." in ".$filename);
- }
- }
- return;
- }
-
- private function skin_incmodepref()
- {
- global $currentSkinName;
- $sql = "SELECT * FROM " . sql_table("skin_desc") . " WHERE sdname = '" . $currentSkinName . "'";
- $row = DB::getRow($sql);
- return array($row['sdincmode'], $row['sdincpref']);
- }
-}