Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> importowanie plikow
marcio
post 13.09.2009, 17:52:28
Post #1





Grupa: Zarejestrowani
Postów: 2 291
Pomógł: 156
Dołączył: 23.09.2007
Skąd: ITALY-MILAN

Ostrzeżenie: (10%)
X----


WItam robie sobie taki wlasny __autoload tzn juz go mam mialem w tablicy wszystkie sciezki na sztywno i wszystko dziala jednak jak chce ladowac sciezko z konfiguracji nie dziala.

Config.php
  1. <?php
  2.  
  3. /*
  4. *******************************************
  5. |Sciezki do MVC libraries/plugins/components *
  6. *******************************************
  7. */
  8.  
  9. $configs['PathControllers'] = 'controllers/';
  10.  
  11. $configs['PathModels'] = 'models/';
  12.  
  13. $configs['PathViews'] = 'views/';
  14.  
  15. $configs['PathLibs'] = 'libraries/';
  16.  
  17. $configs['PathPlugins'] = 'plugins/';
  18.  
  19. $configs['PathModules'] = 'components/';
  20.  
  21. $configs['PathConfig'] = 'config/';
  22.  
  23.  
  24. /*
  25. ********************
  26. |Ustawienia ogolne *
  27. ********************
  28. */
  29.  
  30.  
  31. $configs['controller'] = 'Home'; //Default controller
  32.  
  33. $configs['action'] = 'Index'; //Defualt action
  34.  
  35. $configs['render'] = true; //Render = true bez echo
  36.  
  37. $configs['debug'] = 2;
  38.  
  39. /*
  40. ********************
  41. |Dane do bazy danych *
  42. ********************
  43. */
  44.  
  45. $configs['host'] = '***';
  46. $configs['login'] = '****';
  47. $configs['pwd'] = '****';
  48. $configs['db'] = '***';
  49.  
  50. return $configs;
  51. ?>

I klase import:
  1. <?php
  2. require_once('libraries/Loader.php');
  3. class Imports {
  4.  
  5.  
  6. /*
  7.   private $PathImports = array(
  8.  
  9.   $cfg -> PathControllers,
  10.   $cfg -> PathLibs,
  11.   $cfg -> PathModels,
  12.   $cfg -> PathModules.$cfg -> PathControllers,
  13.   $cfg -> PathModules.$cfg -> PathModels,
  14.   $cfg -> PathModules.$cfg -> PathViews,
  15.   $cfg -> PathPlugins.$cfg -> PathControllers,
  16.   $cfg -> PathPlugins.$cfg -> PathModels,
  17.   $cfg -> PathPlugins.$cfg -> PathViews,
  18.   $cfg -> PathConfig
  19.  
  20.  
  21.   );
  22.  
  23.   */
  24.  
  25.  
  26.  
  27.  
  28. public function __get($class) {
  29.  
  30.  
  31. foreach($this -> PathImports as $key => $imports) {
  32.  
  33. if(file_exists($imports.$class.'.php')) {
  34.  
  35. require_once($imports.$class.'.php');
  36.  
  37. }
  38.  
  39. else if(file_exists($imports.$class.'_Model.php')) {
  40.  
  41. require_once($imports.$class.'_Model.php');
  42.  
  43. }
  44.  
  45. }
  46.  
  47. if(class_exists($class) || class_exists($class.'_Model'))
  48.  
  49. $obj = new $class();
  50.  
  51.  
  52. return $obj;
  53.  
  54. }
  55.  
  56. }
  57.  
  58. ?>

Gdy w polu PathImports dam sciezki czyli controllers,models etc to dziala jednak nie wiem jak zrobic zeby ladowalo je odrazu do tej tablicy i dzialalo mam nadzieje ze wiecie o co mi chodzi.


--------------------
Zainteresowania: XML | PHP | MY(SQL)| C# for .NET | PYTHON
http://code.google.com/p/form-builider/
Moj blog
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 19.07.2025 - 19:44