From 361ba4a5167f66487fd265f77d11c43677125dc9 Mon Sep 17 00:00:00 2001 From: Daniel Camargo Date: Thu, 3 Jul 2014 08:50:41 -0300 Subject: [PATCH] added option to organize views in subfolders it was became messy --- include/library/Crunchbutton/Util.php | 32 ++++++++++++++++--- .../settlement-drivers-payment.phtml | 0 .../settlement-drivers-payments.phtml | 0 .../settlement-drivers-scheduled.phtml | 0 .../{ => settlement}/settlement-drivers.phtml | 0 .../settlement-restaurants-payment.phtml | 0 .../settlement-restaurants-payments.phtml | 0 .../settlement-restaurants-scheduled.phtml | 0 .../settlement-restaurants.phtml | 0 .../{ => settlement}/settlement-summary.phtml | 0 .../{ => settlement}/settlement.phtml | 0 .../cockpit2/layout/zhtml.templates.phtml | 13 +++++--- .../crunchbutton/layout/html.templates.phtml | 13 +++++--- 13 files changed, 44 insertions(+), 14 deletions(-) rename include/views/default/cockpit2/frontend/{ => settlement}/settlement-drivers-payment.phtml (100%) rename include/views/default/cockpit2/frontend/{ => settlement}/settlement-drivers-payments.phtml (100%) rename include/views/default/cockpit2/frontend/{ => settlement}/settlement-drivers-scheduled.phtml (100%) rename include/views/default/cockpit2/frontend/{ => settlement}/settlement-drivers.phtml (100%) rename include/views/default/cockpit2/frontend/{ => settlement}/settlement-restaurants-payment.phtml (100%) rename include/views/default/cockpit2/frontend/{ => settlement}/settlement-restaurants-payments.phtml (100%) rename include/views/default/cockpit2/frontend/{ => settlement}/settlement-restaurants-scheduled.phtml (100%) rename include/views/default/cockpit2/frontend/{ => settlement}/settlement-restaurants.phtml (100%) rename include/views/default/cockpit2/frontend/{ => settlement}/settlement-summary.phtml (100%) rename include/views/default/cockpit2/frontend/{ => settlement}/settlement.phtml (100%) diff --git a/include/library/Crunchbutton/Util.php b/include/library/Crunchbutton/Util.php index b45797194..cb74b1201 100755 --- a/include/library/Crunchbutton/Util.php +++ b/include/library/Crunchbutton/Util.php @@ -1,7 +1,7 @@ theme(); @@ -15,9 +15,14 @@ class Crunchbutton_Util extends Cana_Model { } } - foreach (new DirectoryIterator(c::config()->dirs->view.$frontendDir.'/frontend') as $fileInfo) { - if (!$fileInfo->isDot() && $fileInfo->getBasename() != '.DS_Store' ) { - $files[] = $fileInfo->getBasename('.phtml'); + if( $subFolders ){ + $path = c::config()->dirs->view.$theme.'/frontend'; + $files = array_merge( $files, Crunchbutton_Util::directoryReader( $path ) ); + } else { + foreach (new DirectoryIterator(c::config()->dirs->view.$frontendDir.'/frontend') as $fileInfo) { + if (!$fileInfo->isDot() && $fileInfo->getBasename() != '.DS_Store' ) { + $files[] = $fileInfo->getBasename('.phtml'); + } } } if ($export) { @@ -26,6 +31,25 @@ class Crunchbutton_Util extends Cana_Model { return $files; } + public function directoryReader( $path, $subFolder = '' ){ + $files = []; + foreach ( new DirectoryIterator( $path ) as $fileInfo ) { + if( !$fileInfo->isDot() && $fileInfo->isDir() ){ + // echo '
';var_dump( $fileInfo->getPath() );exit();
+
+					if( $fileInfo->getPathname() != $path ){
+						$subPath = $fileInfo->getPathname();
+						$subFolder = $fileInfo->getBasename();
+						$files = array_merge( $files, Crunchbutton_Util::directoryReader( $subPath, $subFolder ) );
+					}
+				} else
+				if ( !$fileInfo->isDot() && $fileInfo->getBasename() != '.DS_Store' ) {
+					$files[] = [ 'basename' => $fileInfo->getBasename( '.phtml' ), 'subFolder' => $subFolder ];
+				}
+			}
+		return $files;
+	}
+
 	public static function stringToColorCode( $str ) {
 		$code = dechex( crc32( $str ) );
 		$code = substr( $code, 0, 6 );
diff --git a/include/views/default/cockpit2/frontend/settlement-drivers-payment.phtml b/include/views/default/cockpit2/frontend/settlement/settlement-drivers-payment.phtml
similarity index 100%
rename from include/views/default/cockpit2/frontend/settlement-drivers-payment.phtml
rename to include/views/default/cockpit2/frontend/settlement/settlement-drivers-payment.phtml
diff --git a/include/views/default/cockpit2/frontend/settlement-drivers-payments.phtml b/include/views/default/cockpit2/frontend/settlement/settlement-drivers-payments.phtml
similarity index 100%
rename from include/views/default/cockpit2/frontend/settlement-drivers-payments.phtml
rename to include/views/default/cockpit2/frontend/settlement/settlement-drivers-payments.phtml
diff --git a/include/views/default/cockpit2/frontend/settlement-drivers-scheduled.phtml b/include/views/default/cockpit2/frontend/settlement/settlement-drivers-scheduled.phtml
similarity index 100%
rename from include/views/default/cockpit2/frontend/settlement-drivers-scheduled.phtml
rename to include/views/default/cockpit2/frontend/settlement/settlement-drivers-scheduled.phtml
diff --git a/include/views/default/cockpit2/frontend/settlement-drivers.phtml b/include/views/default/cockpit2/frontend/settlement/settlement-drivers.phtml
similarity index 100%
rename from include/views/default/cockpit2/frontend/settlement-drivers.phtml
rename to include/views/default/cockpit2/frontend/settlement/settlement-drivers.phtml
diff --git a/include/views/default/cockpit2/frontend/settlement-restaurants-payment.phtml b/include/views/default/cockpit2/frontend/settlement/settlement-restaurants-payment.phtml
similarity index 100%
rename from include/views/default/cockpit2/frontend/settlement-restaurants-payment.phtml
rename to include/views/default/cockpit2/frontend/settlement/settlement-restaurants-payment.phtml
diff --git a/include/views/default/cockpit2/frontend/settlement-restaurants-payments.phtml b/include/views/default/cockpit2/frontend/settlement/settlement-restaurants-payments.phtml
similarity index 100%
rename from include/views/default/cockpit2/frontend/settlement-restaurants-payments.phtml
rename to include/views/default/cockpit2/frontend/settlement/settlement-restaurants-payments.phtml
diff --git a/include/views/default/cockpit2/frontend/settlement-restaurants-scheduled.phtml b/include/views/default/cockpit2/frontend/settlement/settlement-restaurants-scheduled.phtml
similarity index 100%
rename from include/views/default/cockpit2/frontend/settlement-restaurants-scheduled.phtml
rename to include/views/default/cockpit2/frontend/settlement/settlement-restaurants-scheduled.phtml
diff --git a/include/views/default/cockpit2/frontend/settlement-restaurants.phtml b/include/views/default/cockpit2/frontend/settlement/settlement-restaurants.phtml
similarity index 100%
rename from include/views/default/cockpit2/frontend/settlement-restaurants.phtml
rename to include/views/default/cockpit2/frontend/settlement/settlement-restaurants.phtml
diff --git a/include/views/default/cockpit2/frontend/settlement-summary.phtml b/include/views/default/cockpit2/frontend/settlement/settlement-summary.phtml
similarity index 100%
rename from include/views/default/cockpit2/frontend/settlement-summary.phtml
rename to include/views/default/cockpit2/frontend/settlement/settlement-summary.phtml
diff --git a/include/views/default/cockpit2/frontend/settlement.phtml b/include/views/default/cockpit2/frontend/settlement/settlement.phtml
similarity index 100%
rename from include/views/default/cockpit2/frontend/settlement.phtml
rename to include/views/default/cockpit2/frontend/settlement/settlement.phtml
diff --git a/include/views/default/cockpit2/layout/zhtml.templates.phtml b/include/views/default/cockpit2/layout/zhtml.templates.phtml
index 6af20eb6a..07458965a 100644
--- a/include/views/default/cockpit2/layout/zhtml.templates.phtml
+++ b/include/views/default/cockpit2/layout/zhtml.templates.phtml
@@ -1,5 +1,8 @@
-
-	
-
\ No newline at end of file
+';
+		echo $this->render( $pathname, [ 'filter' => false ] );
+	echo '';
+}
\ No newline at end of file
diff --git a/include/views/default/crunchbutton/layout/html.templates.phtml b/include/views/default/crunchbutton/layout/html.templates.phtml
index 6af20eb6a..07458965a 100644
--- a/include/views/default/crunchbutton/layout/html.templates.phtml
+++ b/include/views/default/crunchbutton/layout/html.templates.phtml
@@ -1,5 +1,8 @@
-
-	
-
\ No newline at end of file
+';
+		echo $this->render( $pathname, [ 'filter' => false ] );
+	echo '';
+}
\ No newline at end of file