Skip to content
This repository
Browse code

check for view files in APPPATH before using the defaults from PKGPATH

  • Loading branch information...
commit b217a91f1c0b8aad5e50524e5aeec20ecffb7d82 1 parent 1a3be65
Harro Verton authored March 05, 2012
26  classes/generate/admin.php
@@ -20,17 +20,17 @@
20 20
  * @category	Core
21 21
  */
22 22
 class Generate_Admin extends Generate_Scaffold
23  
-{	
  23
+{
24 24
 	public static $view_subdir = 'admin/';
25  
-	
  25
+
26 26
 	public static $controller_prefix = 'Admin_';
27 27
 	public static $model_prefix = '';
28  
-	
  28
+
29 29
 	public static $controller_parent = 'Controller_Admin';
30  
-	
  30
+
31 31
 	public static function forge($args, $subfolder)
32 32
 	{
33  
-		
  33
+
34 34
 		$default_files = array(
35 35
 			array(
36 36
 				'source' => $subfolder.'/controllers/base.php',
@@ -58,17 +58,25 @@ public static function forge($args, $subfolder)
58 58
 				'type' => 'views',
59 59
 			),
60 60
 		);
61  
-		
  61
+
62 62
 		foreach ($default_files as $file)
63 63
 		{
64 64
 			if ( ! file_exists($content = APPPATH.$file['location']))
65 65
 			{
66  
-				Generate::create($content, file_get_contents(PKGPATH.'oil/views/'.static::$view_subdir.$file['source']), $file['type']);
  66
+				// check if there's a template in app, and if so, use that
  67
+				if (file_exists(APPPATH.'views/'.static::$view_subdir.$file['source']))
  68
+				{
  69
+					Generate::create($content, file_get_contents(APPPATH.'views/'.static::$view_subdir.$file['source']), $file['type']);
  70
+				}
  71
+				else
  72
+				{
  73
+					Generate::create($content, file_get_contents(PKGPATH.'oil/views/'.static::$view_subdir.$file['source']), $file['type']);
  74
+				}
67 75
 			}
68 76
 		}
69  
-		
  77
+
70 78
 		parent::forge($args, $subfolder);
71 79
 	}
72 80
 }
73 81
 
74  
-/* End of file oil/classes/generate/admin.php */
  82
+/* End of file oil/classes/generate/admin.php */
10  classes/generate/scaffold.php
@@ -168,7 +168,15 @@ public static function forge($args, $subfolder)
168 168
 		// Add the default template if it doesnt exist
169 169
 		if ( ! file_exists($app_template = APPPATH.'views/template.php'))
170 170
 		{
171  
-			Generate::create($app_template, file_get_contents(PKGPATH.'oil/views/'.static::$view_subdir.$subfolder.'/views/template.php'), 'view');
  171
+				// check if there's a template in app, and if so, use that
  172
+				if (file_exists(APPPATH.'views/'.static::$view_subdir.$subfolder.'/views/template.php'))
  173
+				{
  174
+					Generate::create($app_template, file_get_contents(APPPATH.'views/'.static::$view_subdir.$subfolder.'/views/template.php'), 'view');
  175
+				}
  176
+				else
  177
+				{
  178
+					Generate::create($app_template, file_get_contents(PKGPATH.'oil/views/'.static::$view_subdir.$subfolder.'/views/template.php'), 'view');
  179
+				}
172 180
 		}
173 181
 
174 182
 		Generate::build();

0 notes on commit b217a91

Please sign in to comment.
Something went wrong with that request. Please try again.