Skip to content

Commit

Permalink
Merge pull request #7 from experius/skin-files
Browse files Browse the repository at this point in the history
Skin Files - issue6
  • Loading branch information
Derrick Heesbeen authored Jun 7, 2017
2 parents be2d495 + 5302b4b commit 0e92b92
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions shell/patchHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,25 @@ public function run(){
$this->checkTemplateFiles($patchedFiles);
echo "\n\n";

echo "\e[41m Check Skin Files \e[0m\n";
$this->checkSkinFiles($patchedFiles);
echo "\n\n";

echo "\e[43m Check similar name phtml files in other folders \e[0m\n";
foreach($patchedFiles as $patchedFile){
if(preg_match('/.phtml/',$patchedFile) && preg_match('/app\/design\/frontend\/base\/default/',$patchedFile)){
$this->searchTemplateNames($patchedFile);
}
}

echo "\n\n";
echo "\e[43m Check similar name skin js files in other folders \e[0m\n";
foreach($patchedFiles as $patchedFile){
if(preg_match('/.js/',$patchedFile) && preg_match('/skin\/frontend\/base\/default/',$patchedFile)){
$this->searchSkinNames($patchedFile);
}
}

} else {
echo "Add Patch Filename. php patchHelper.php --patch PATCH_SUPEE-8788_CE_1.9.0.1_v1-2016-10-11-06-57-03.sh \n";
}
Expand Down Expand Up @@ -247,6 +259,35 @@ protected function checkTemplateFiles($filenames){

}

protected function checkSkinFiles($filenames){
$designFolder = Mage::getBaseDir('skin') . '/frontend';

$templates = scandir($designFolder);

foreach ($templates as $key => $subfolder ) {
if ( !in_array( $subfolder, array( '.', '..', 'base' ) ) ) {
$designs = scandir($designFolder . '/' . $subfolder);
foreach($designs as $design){
if ( !in_array($design, array( '.', '..' ) ) ) {
$templatePath = $designFolder . '/' . $subfolder . '/' . $design;

foreach($filenames as $patchedFile){

$fileToCheck = $templatePath . '/' . str_replace('skin/frontend/base/default/','',$patchedFile);

if(file_exists($fileToCheck)){
echo $fileToCheck . "\n";
}

}

}
}
}
}

}

protected function searchTemplateNames($fileName){
$fileNameParts = explode('/',$fileName);
$fileName = end($fileNameParts);
Expand All @@ -256,6 +297,15 @@ protected function searchTemplateNames($fileName){
echo shell_exec('find app/design/frontend -type f -name ' . $fileName . ' -not -path "app/design/frontend/base/*" -not -path "app/design/frontend/rwd/default/*" -not -path "'.$path.'/*" -not -path "*/'.$relativePathToTemplate.'/*"');
}

protected function searchSkinNames($fileName){
$fileNameParts = explode('/',$fileName);
$fileName = end($fileNameParts);
array_pop($fileNameParts);
$path = implode('/',$fileNameParts);
$relativePathToTemplate = str_replace('skin/frontend/base/default/','',$path);
echo shell_exec('find skin/frontend -type f -name ' . $fileName . ' -not -path "skin/frontend/base/*" -not -path "skin/frontend/rwd/default/*" -not -path "'.$path.'/*" -not -path "*/'.$relativePathToTemplate.'/*"');
}

public function usageHelp()
{
return <<<USAGE
Expand Down

0 comments on commit 0e92b92

Please sign in to comment.