Merge pull request #1879 from Pico88/ticket/12026

[ticket/12026] Correct path for template files
This commit is contained in:
Nathan Guse 2013-12-04 13:59:59 -08:00
commit 97bf88dd32
5 changed files with 95 additions and 9 deletions

View file

@ -528,12 +528,12 @@ class p_master
* the style paths for the extension (the ext author can change them
* if necessary).
*/
$module_dir = explode('_', get_class($this->module));
$module_dir = explode('\\', get_class($this->module));
// 0 phpbb, 1 ext, 2 vendor, 3 extension name, ...
if (isset($module_dir[3]) && $module_dir[1] === 'ext')
// 0 vendor, 1 extension name, ...
if (isset($module_dir[1]))
{
$module_style_dir = 'ext/' . $module_dir[2] . '/' . $module_dir[3] . '/styles';
$module_style_dir = 'ext/' . $module_dir[0] . '/' . $module_dir[1] . '/styles';
if (is_dir($phpbb_root_path . $module_style_dir))
{

View file

@ -80,18 +80,53 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case
);
$modules->update_module_data($module_data, true);
$parent_data = array(
'module_basename' => '',
'module_enabled' => 1,
'module_display' => 1,
'parent_id' => 0,
'module_class' => 'ucp',
'module_langname' => 'UCP_FOOBAR_TITLE',
'module_mode' => '',
'module_auth' => '',
);
$modules->update_module_data($parent_data, true);
$module_data = array(
'module_basename' => 'foo\\bar\\ucp\\main_module',
'module_enabled' => 1,
'module_display' => 1,
'parent_id' => $parent_data['module_id'],
'module_class' => 'ucp',
'module_langname' => 'UCP_FOOBAR_TITLE',
'module_mode' => 'mode',
'module_auth' => '',
);
$modules->update_module_data($module_data, true);
$this->purge_cache();
}
/**
* Check a controller for extension foo/bar.
*/
public function test_foo_bar()
public function test_acp()
{
$this->login();
$this->admin_login();
$crawler = self::request('GET', 'adm/index.php?i=foo%5cbar%5cacp%5cmain_module&mode=mode&sid=' . $this->sid);
$this->assertContains("Bertie rulez!", $crawler->filter('#main')->text());
$this->assertContains('Bertie rulez!', $crawler->filter('#main')->text());
}
public function test_ucp()
{
$this->login();
$crawler = self::request('GET', 'ucp.php?sid=' . $this->sid);
$this->assertContains('UCP_FOOBAR_TITLE', $crawler->filter('#tabs')->text());
$link = $crawler->selectLink('UCP_FOOBAR_TITLE')->link()->getUri();
$crawler = self::request('GET', substr($link, strpos($link, 'ucp.')));
$this->assertContains('UCP Extension Template Test Passed!', $crawler->filter('#content')->text());
$this->phpbb_extension_manager->purge('foo/bar');
}
}

View file

@ -0,0 +1,3 @@
<!-- INCLUDE overall_header.html -->
<div id="content">UCP Extension Template Test Passed!</div>
<!-- INCLUDE overall_footer.html -->

View file

@ -0,0 +1,26 @@
<?php
/**
*
* @package testing
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace foo\bar\ucp;
class main_info
{
function module()
{
return array(
'filename' => '\foo\bar\ucp\main_module',
'title' => 'ACP_FOOBAR_TITLE',
'version' => '1.0.0',
'modes' => array(
'mode' => array('title' => 'ACP_FOOBAR_MODE', 'auth' => '', 'cat' => array('ACP_FOOBAR_TITLE')),
),
);
}
}

View file

@ -0,0 +1,22 @@
<?php
/**
*
* @package testing
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace foo\bar\ucp;
class main_module
{
var $u_action;
function main($id, $mode)
{
$this->tpl_name = 'foobar';
$this->page_title = 'Bertie';
}
}