Skip to content

Commit

Permalink
Dev: added TemplateManifest::getOtherFiles()
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac authored and TonisOrmisson committed Jul 14, 2017
1 parent 4202ec8 commit 3425d17
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
21 changes: 1 addition & 20 deletions application/controllers/admin/templates.php
Expand Up @@ -1131,26 +1131,7 @@ protected function _initialise($templatename, $screenname, $editfile, $showsumma
$files = array(0=>$files);
}


// Get list of 'otherfiles'
// We can't use $oTemplate->otherFiles, because of retrocompatibility with 2.06 template and the big mess of it mixing files
$filesdir = ($oEditedTemplate->filesPath!='')?$oEditedTemplate->filesPath:$templatedir . '../files';

$otherfiles = array();
if ( file_exists($filesdir) && $handle = opendir($filesdir))
{
while (false !== ($file = readdir($handle)))
{
if (!array_search($file, $normalfiles)) {
if (!is_dir($templatedir . DIRECTORY_SEPARATOR . $file)) {
$otherfiles[] = $file;
}
}
}

closedir($handle);
}

$otherfiles = $oEditedTemplate->getOtherFiles();
$editfile = (empty($editfile))?$sLayoutFile:$editfile;
$sEditfile = $oEditedTemplate->getFilePathForEdition($editfile, array_merge($files, $aCssAndJsfiles));

Expand Down
18 changes: 18 additions & 0 deletions application/models/TemplateManifest.php
Expand Up @@ -228,6 +228,24 @@ public function getTemplateForFile($sFile, $oRTemplate)
return $oRTemplate;
}

public function getOtherFiles()
{
$otherfiles = array();
if ( file_exists($this->filesPath) && $handle = opendir($this->filesPath))
{
while (false !== ($file = readdir($handle)))
{
if (!array_search($file, array("DUMMYENTRY", ".", "..", "preview.png"))) {
if (!is_dir($this->viewPath . DIRECTORY_SEPARATOR . $file)) {
$otherfiles[] = $file;
}
}
}

closedir($handle);
}
return $otherfiles;
}

/**
* Update the config file of a given template so that it extends another one
Expand Down

0 comments on commit 3425d17

Please sign in to comment.