Problema polega na tym ze daje mi blad w tej klasie:
<?php /** *Volta framework *@author marcio <opi14@op.pl>, <polishvodka7@gmail.com> *@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 */ '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')) { { 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(); { 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 <opi14@op.pl>, <polishvodka7@gmail.com> *@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 */ /** *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) { } /** *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 = '') { } } ?>
Potem glowna klasa Vf_Language:
<?php /** *Volta framework *@author marcio <opi14@op.pl>, <polishvodka7@gmail.com> *@copyright Copyright (c) 2012, marcio *@version 1.0 */ class Vf_Language { protected $driver = null; 'php' => 'Array', 'xml' => 'Xml' ); public function __construct($file, $adapter = null) { if($adapter === null) { } 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 <opi14@op.pl>, <polishvodka7@gmail.com> *@copyright Copyright (c) 2012, marcio *@version 1.0 */ abstract class Vf_Language_Abstract { 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; { $_SESSION[$this -> config -> session_lang] = $lang; } else { $_SESSION[$this -> config -> session_lang] = $lang; } } public function getLang() { { 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) { } else { { foreach($vars[0] as $var) { { $replaceVars[] = $var; $replaceVarsValue[] = $this -> data[$this -> getLang()][$key]['pluralize'][$var][$ruleCode]; } } $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 <opi14@op.pl>, <polishvodka7@gmail.com> *@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.
Albo ja jestem tepy albo php jest tepe byl blad logiczny w metodzie i na starym serverze dzialalo a na nowym juz nie:
public function __construct($file, $adapter = null) { if($adapter === null) { $adapter = $this -> extensionsAdapter[$ext]; //tutaj byl blad wczesniej bylo $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); } } }
Moj blad ale skoro dzialalo nawet nie zwrocilem na to uwagi przeciez uzylem end wiec sizeof()-1 jest zbedny, ciekaw jestem jednak dlaczego nie dzialalo na nowym serverze a na starym juz tak....