Last active
January 22, 2016 10:18
-
-
Save Crease29/5eef088d40e41991da3d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// =================================================== | |
// = place this file in the root of your OXID eShop! = | |
// =================================================== | |
require_once 'bootstrap.php'; | |
// CONFIG | |
$sTheme = 'my_custom_theme'; | |
// CONFIG END | |
/** | |
* Returns files of given $dir recursively. | |
* | |
* @param $dir | |
* @param array $results | |
* | |
* @see http://stackoverflow.com/a/24784144 | |
* | |
* @return array | |
*/ | |
function getDirContents( $dir, &$results = array() ) | |
{ | |
$files = scandir( $dir ); | |
foreach ( $files as $key => $value ) | |
{ | |
$path = realpath( $dir . DIRECTORY_SEPARATOR . $value ); | |
if ( !is_dir( $path ) ) | |
{ | |
$results[] = $path; | |
} | |
else | |
{ | |
if ( $value != "." && $value != ".." ) | |
{ | |
getDirContents( $path, $results ); | |
$results[] = $path; | |
} | |
} | |
} | |
return $results; | |
} | |
$aAzureFiles = getDirContents( getShopBasePath() . "/application/views/azure/tpl" ); | |
$aThemeFiles = getDirContents( getShopBasePath() . "/application/views/$sTheme/tpl" ); | |
if( count( $aAzureFiles ) && count( $aThemeFiles ) ) | |
{ | |
$aAzureBlocks = array(); | |
$aThemeBlocks = array(); | |
// search for blocks in Azure | |
foreach ( $aAzureFiles as $sFile ) | |
{ | |
$sExtension = pathinfo( $sFile, PATHINFO_EXTENSION ); | |
if( $sExtension == 'tpl' ) | |
{ | |
preg_match_all( "/\[\{block name=\"([a-zA-Z_-]*)\"\}\]/", file_get_contents( $sFile ), $aMatches ); | |
if( count( $aMatches[ 1 ] ) ) | |
{ | |
foreach ( $aMatches[ 1 ] as $sBlock ) | |
{ | |
if( !empty( $sBlock ) ) | |
{ | |
$aAzureBlocks[] = $sBlock; | |
} | |
} | |
} | |
} | |
} | |
// search for blocks in given theme | |
foreach ( $aThemeFiles as $sFile ) | |
{ | |
$sExtension = pathinfo( $sFile, PATHINFO_EXTENSION ); | |
if( $sExtension == 'tpl' ) | |
{ | |
preg_match_all( "/\[\{block name=\"([a-zA-Z_-]*)\"\}\]/", file_get_contents( $sFile ), $aMatches ); | |
if( count( $aMatches[ 1 ] ) ) | |
{ | |
foreach ( $aMatches[ 1 ] as $sBlock ) | |
{ | |
if( !empty( $sBlock ) ) | |
{ | |
$aThemeBlocks[] = $sBlock; | |
} | |
} | |
} | |
} | |
} | |
echo '<pre>'; | |
if( count( $aAzureBlocks ) && count( $aThemeBlocks ) ) | |
{ | |
$aMissingBlocks = array_diff( $aAzureBlocks, $aThemeBlocks ); | |
if( count( $aMissingBlocks ) ) | |
{ | |
echo "Missing blocks in you theme '{$sTheme}':\r\r"; | |
echo implode( "\r", $aMissingBlocks ); | |
} | |
else | |
{ | |
echo 'Congratulations! Your theme supports all OXID azure theme blocks.'; | |
} | |
} | |
else | |
{ | |
echo 'Congratulations! Your theme supports all OXID azure theme blocks.'; | |
} | |
echo '</pre>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment