Witam wykupilem sobie server na linuxpl.com wczesniej moj blog byl na serverze z php 5.2.17 teraz na nowym hostingu chce sie poki co przerzucic na wersje 5.3.28(pozniej na 5.4.x ale poki co mam blad dotyczacy referencji ktorego nie mam pojecia jak poprawic)
Problema polega na tym ze daje mi blad w tej klasie:
<?php
/**
*Volta framework
*@author marcio <[email protected]>, <[email protected]>
*@copyright Copyright (c) 2012, marcio
*@version 1.0
*/
require_once(DIR_ABSTRACT.'Validation.php');
require_once(DIR_INTERFACES.'IValidation.php');
class user extends Vf_Validation implements IValidation
{
/**
*Skladowa klasy ktora przechowywuje tresci bledow
*@access protected
*/
protected $error = array(
'pl' => array(
'banned' => 'To konto zostalo zbanowane',
'account_disabled' => 'To konto nie zostalo aktywowane',
'user_exists' => 'Uzytkownik o takiej nazwie juz istnieje'
)
);
/**
*Konstruktor ustawia konfiguracje walidatora
*@access public
*@param array $cfg
*/
public function __construct($cfg)
{
parent::__construct();
$this -> configure($cfg);
}
/**
*Metoda ktora sprawdza walidacje danych na podstawie wczesniej ustawionej konfiguracji
*@access public
*@param string $object tresc do walidacji
*@return bool|string
*/
public function is_valid($object)
{
if($this -> get_option('check_ban'))
{
if(empty($object))
{
return true;
}
$message = $this -> error[$this -> language -> get() -> getLang()]['banned']; //tutaj jest blad
$ban = Vf_Orm::factory('Ban');
if($ban -> isBanned($object))
{
return $this -> set_error($message);
}
}
if($this -> get_option('check_is_active'))
{
$request = new Vf_Request();
if(empty($object))
{
return true;
}
$message = $this -> error[$this -> language -> get() -> getLang()]['account_disabled'];
$account = Vf_Orm::factory('UserActive') -> find($request -> post('login'));
if($account -> isLoaded() && $account -> active == 0)
{
return $this -> set_error($message);
}
}
if($this -> get_option('check_user'))
{
$message = $this -> error[$this -> language -> get() -> getLang()]['user_exists'];
$user = Vf_Orm::factory('UserExists', $_POST[$this -> get_option('check_user')]);
if($user -> isLoaded())
{
return $this -> set_error($message);
}
}
return true;
}
}
?>
Blad jest dokladnie tutaj(i w innych miejscach gdzie wywoluje ta metode):
$message = $this -> error[$this -> language -> get() -> getLang()]['banned'];
Klasy zwiazane z tym walidatorem to:
<?php
/**
*Volta framework
*@author marcio <[email protected]>, <[email protected]>
*@copyright Copyright (c) 2011, marcio
*@version 1.6.5
*/
require_once(DIR_LIBRARY.'Language.php');
abstract class Vf_Validation
{
/**
*Skladowa klasy ktora przechowywuje ustawienia walidacji
*@access protected
*@var array $config
*/
protected $config = array();
/**
*Skladowa klasy ktora przechowywuje instancje klasy Language
*@access protected
*@var object $language
*/
protected $language = null;
/**
*Tworzymy instancje klasy do obslugi jezykow
*@access public
*/
public function __construct()
{
$this -> language = new Vf_Language('Validation.php');
}
/**
*Metoda ustawia konfiguracje
*@access public
*@param array $config
*/
public function configure($config)
{
$this -> config = $config;
}
/**
*Metoda zwraca nam dana wartosc z konfiguracji walidacji
*@access public
*@param string $key
*@return mixed
*/
public function get_option($key)
{
return (isset($this -> config[$key])) ? $this -> config[$key] : null;
}
/**
*Metoda zwraca pelna konfiguracje walidacji
*@access public
*@return array
*/
public function get_options()
{
return $this -> config;
}
/**
*Ustawiamy tresc bledy ustawiajac tez nazwe pola
*@access protected
*@param string tresc bledu
*@param string nazwa pola
*@return string
*/
protected function set_error($errorMsg, $fieldname = '')
{
return str_replace('%field%', $fieldname, $errorMsg);
}
}
?>
Potem glowna klasa Vf_Language:
<?php
/**
*Volta framework
*@author marcio <[email protected]>, <[email protected]>
*@copyright Copyright (c) 2012, marcio
*@version 1.0
*/
class Vf_Language
{
protected $driver = null;
protected $extensionsAdapter = array(
'php' => 'Array',
'xml' => 'Xml'
);
public function __construct($file, $adapter = null)
{
if($adapter === null)
{
$ext = end(explode('.', $file));
$adapter = $this -> extensionsAdapter[sizeof($ext)-1];
}
if(Vf_Loader::existsFile(DIR_DRIVERS.'Language/'.$adapter.'.php'))
{
require_once(DIR_DRIVERS.'Language/'.$adapter.'.php');
$className = 'Vf_Language_'.$adapter.'_Adapter';
if(class_exists($className))
{
$this -> driver = new $className();
$this -> driver -> load($file);
}
}
}
public function get()
{
return $this -> driver;
}
}
?>
Potem klasa abstrakcyjna language:
<?php
/**
*Volta framework
*@author marcio <[email protected]>, <[email protected]>
*@copyright Copyright (c) 2012, marcio
*@version 1.0
*/
abstract class Vf_Language_Abstract
{
protected $data = array();
protected $lang = null;
protected $config = null;
public function __construct()
{
$this -> config = new Vf_Config('config.Language');
$this -> lang = $this -> config -> default_lang;
}
public function __get($key)
{
return (isset($this -> data[$this -> getLang()][$key])) ? $this -> data[$this -> getLang()][$key] : null;
}
public function setLang($lang)
{
$this -> lang = $lang;
if(!isset($_SESSION[$this -> config -> session_lang]))
{
$_SESSION[$this -> config -> session_lang] = $lang;
}
else
{
unset($_SESSION[$this -> config -> session_lang]);
$_SESSION[$this -> config -> session_lang] = $lang;
}
}
public function getLang()
{
if(isset($_SESSION[$this -> config -> session_lang]))
{
return $_SESSION[$this -> config -> session_lang];
}
else
{
return $this -> lang;
}
}
public function translate($key)
{
return (isset($this -> data[$this -> getLang()][$key])) ? $this -> data[$this -> getLang()][$key] : null;
}
public function phrase($key, $from, $to, $pluralize = false, $count = null)
{
$ruleCode = $this -> getPluralizationRulesCode($count);
if(!$pluralize)
{
$phrase = str_replace($from, $to, $this -> data[$this -> getLang()][$key]);
}
else
{
if(isset($this -> data[$this -> getLang()][$key]['pluralize']))
{
preg_match_all('#\%(.*?)\%#', $this -> data[$this -> getLang()][$key]['text'], $vars);
foreach($vars[0] as $var)
{
if(!in_array($var, $from))
{
$replaceVars[] = $var;
$replaceVarsValue[] = $this -> data[$this -> getLang()][$key]['pluralize'][$var][$ruleCode];
}
}
$fromPluralize = array_merge($from, $replaceVars);
$toPluralize = array_merge($to, $replaceVarsValue);
$phrase = str_replace($fromPluralize, $toPluralize, $this -> data[$this -> getLang()][$key]['text']);
}
}
return $phrase;
}
protected function getPluralizationRulesCode($number)
{
switch($this -> getLang())
{
case 'pl':
return ($number == 1) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 12) || ($number % 100 > 14))) ? 1 : 2);
case 'de':
case 'es':
case 'it':
case 'en':
return ($number == 1) ? 0 : 1;
case 'fr':
return (($number == 0) || ($number == 1)) ? 0 : 1;
case 'ro':
return ($number == 1) ? 0 : ((($number == 0) || (($number % 100 > 0) && ($number % 100 < 20))) ? 1 : 2);
case 'be':
case 'ru':
case 'uk':
return (($number % 10 == 1) && ($number % 100 != 11)) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2);
case 'cs':
case 'sk':
return ($number == 1) ? 0 : ((($number >= 2) && ($number <= 4)) ? 1 : 2);
default:
return 0;
}
}
abstract public function load($file);
}
?>
i najprostszy "sterownik" dla klasy language opierajacy sie o tablice z php:
<?php
/**
*Volta framework
*@author marcio <[email protected]>, <[email protected]>
*@copyright Copyright (c) 2012, marcio
*@version 1.0
*/
require_once(DIR_ABSTRACT.'Language.php');
class Vf_Language_Array_Adapter extends Vf_Language_Abstract
{
public function load($file)
{
if(Vf_Loader::existsFile(DIR_LANG.$file))
{
include(DIR_LANG.$file);
$this -> data = $translate;
}
}
}
?>
Bylbym bardzo wdzieczny za jakakolwiek pomoc poniewaz na starym serverze nie mialem bledu i tak w ogole nie wiem dlaczego on jest skoro z metodzie get() w klasie Vf_Language zwracam skladawa driver ktora zawiera klase sterownika.