Check if a module has admin incude files.

This commit is contained in:
Franck Allimant
2014-04-22 15:53:35 +02:00
parent 62218f7637
commit e183c7c8be
2 changed files with 22 additions and 1 deletions

View File

@@ -12,6 +12,7 @@
namespace Thelia\Controller\Admin; namespace Thelia\Controller\Admin;
use Symfony\Component\Finder\Finder;
use Thelia\Core\Security\Resource\AdminResources; use Thelia\Core\Security\Resource\AdminResources;
use Thelia\Core\Security\AccessManager; use Thelia\Core\Security\AccessManager;
use Thelia\Model\Module; use Thelia\Model\Module;
@@ -128,6 +129,23 @@ class TranslationsController extends BaseAdminController
$templateArguments['front_office_templates'] = $templateArguments['front_office_templates'] =
implode(',', $this->getModuleTemplateNames($module, TemplateDefinition::FRONT_OFFICE)); implode(',', $this->getModuleTemplateNames($module, TemplateDefinition::FRONT_OFFICE));
// Check if we have admin-include files
try {
$finder = Finder::create()
->files()
->depth(0)
->in($module->getAbsoluteAdminIncludesPath())
->name('/\.html$/i')
;
$hasAdminIncludes = $finder->count() > 0;
}
catch (\InvalidArgumentException $ex) {
$hasAdminIncludes = false;
}
$templateArguments['has_admin_includes'] = $hasAdminIncludes;
break; break;
// Thelia Core // Thelia Core

View File

@@ -128,7 +128,10 @@
<select id="module_part" required="required" name="module_part" class="submit-on-change form-control"> <select id="module_part" required="required" name="module_part" class="submit-on-change form-control">
<option value="">{intl l='Please select the module component'}</option> <option value="">{intl l='Please select the module component'}</option>
<option value="core" {if $module_part == 'core'}selected="selected"{/if}>Core files</option> <option value="core" {if $module_part == 'core'}selected="selected"{/if}>Core files</option>
{if $has_admin_includes}
<option value="admin-includes" {if $module_part == 'admin-includes'}selected="selected"{/if}>Administration includes template</option> <option value="admin-includes" {if $module_part == 'admin-includes'}selected="selected"{/if}>Administration includes template</option>
{/if}
{if $back_office_templates != ''} {if $back_office_templates != ''}
{foreach explode(',', $back_office_templates) as $template} {foreach explode(',', $back_office_templates) as $template}