From 53436e790c892c485c99718409fe4fcc75eceff0 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 17 Oct 2013 21:42:43 +0200 Subject: [PATCH] [fix/namespaces] Fix portal after adding namespaces B3P-FIX-NAMESPACES --- root/composer.json | 4 +- root/config/services.yml | 3 +- root/controller/main.php | 62 +++++++++++-------- root/ext.php | 4 +- .../{210_beta1.php => v210_beta1.php} | 6 +- root/portal/modules/portal_calendar.php | 9 +-- root/portal/modules/portal_poll.php | 2 +- .../event/overall_header_head_append.html | 2 +- .../template/portal/_block_config.html | 2 +- .../portal/modules/news_compact_center.html | 56 ++++++++++------- .../portal/modules/recent_center.html | 2 +- .../portal/modules/whois_online_center.html | 2 +- 12 files changed, 86 insertions(+), 68 deletions(-) rename root/migrations/{210_beta1.php => v210_beta1.php} (99%) diff --git a/root/composer.json b/root/composer.json index 20328ff0..772e0316 100644 --- a/root/composer.json +++ b/root/composer.json @@ -1,6 +1,6 @@ { "name": "board3/portal", - "type": "phpbb3-extension", + "type": "phpbb-extension", "description": "Adds a portal with several blocks to your forum. You can change the settings, move the blocks, add new blocks and more in the ACP.", "homepage": "http://www.board3.de", "version": "2.1.0-dev", @@ -47,7 +47,7 @@ }], "require": { "php": ">=5.2", - "phpbb": "3.1.0-dev" + "phpbb/phpbb": "3.1.0-dev" }, "extra": { "display-name": "Board3 Portal" diff --git a/root/config/services.yml b/root/config/services.yml index e1cd809a..c686da1e 100644 --- a/root/config/services.yml +++ b/root/config/services.yml @@ -1,11 +1,12 @@ services: board3.portal.main: - class: phpbb_ext_board3_portal_controller_main + class: \board3\portal\controller\main arguments: - @auth - @config - @template - @user + - @path_helper - %core.root_path% - .%core.php_ext% diff --git a/root/controller/main.php b/root/controller/main.php index 2a2c3213..f5685b38 100644 --- a/root/controller/main.php +++ b/root/controller/main.php @@ -7,7 +7,9 @@ * */ -class phpbb_ext_board3_portal_controller_main +namespace board3\portal\controller; + +class main { /** * Auth object @@ -57,6 +59,12 @@ class phpbb_ext_board3_portal_controller_main */ private $includes_path; + /** + * phpBB path helper + * @var \phpbb\path_helper + */ + protected $path_helper; + /** * Constructor * NOTE: The parameters of this method must match in order and type with @@ -65,10 +73,11 @@ class phpbb_ext_board3_portal_controller_main * @param phpbb_config_db $config phpBB Config object * @param phpbb_template $template Template object * @param phpbb_user $user User object + * @param \phpbb\path_helper $path_helper phpBB path helper * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP file extension */ - public function __construct($auth, $config, $template, $user, $phpbb_root_path, $php_ext) + public function __construct($auth, $config, $template, $user, $path_helper, $phpbb_root_path, $php_ext) { global $portal_root_path; @@ -76,6 +85,7 @@ class phpbb_ext_board3_portal_controller_main $this->config = $config; $this->template = $template; $this->user = $user; + $this->path_helper = $path_helper; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; $this->includes_path = $phpbb_root_path . 'ext/board3/portal/portal/'; @@ -90,21 +100,21 @@ class phpbb_ext_board3_portal_controller_main } } - /** - * Extension front handler method. This is called automatically when your extension is accessed - * through index.php?ext=example/foobar - * @return null - */ - public function handle() - { + /** + * Extension front handler method. This is called automatically when your extension is accessed + * through index.php?ext=example/foobar + * @return null + */ + public function handle() + { $this->check_permission(); - // We defined the phpBB objects in __construct() and can use them in the rest of our class like this - //echo 'Welcome, ' . $this->user->data['username']; + // We defined the phpBB objects in __construct() and can use them in the rest of our class like this + //echo 'Welcome, ' . $this->user->data['username']; - // The following takes two arguments: - // 1) which extension language folder we're using (it's not smart enough to use its own automatically) - // 2) what language file to use - $this->user->add_lang_ext('board3/portal', 'mods/portal'); + // The following takes two arguments: + // 1) which extension language folder we're using (it's not smart enough to use its own automatically) + // 2) what language file to use + $this->user->add_lang_ext('board3/portal', 'mods/portal'); /** * get initial data @@ -199,7 +209,7 @@ class phpbb_ext_board3_portal_controller_main { $this->template->assign_block_vars('modules_' . column_num_string($row['module_column']), array( 'TEMPLATE_FILE' => 'portal/modules/' . $template_module['template'], - 'IMAGE_SRC' => $this->root_path . 'styles/' . $this->user->style['style_path'] . '/theme/images/portal/' . $template_module['image_src'], + 'IMAGE_SRC' => $this->path_helper->get_web_root_path() . $this->root_path . 'styles/' . $this->user->style['style_path'] . '/theme/images/portal/' . $template_module['image_src'], 'TITLE' => $template_module['title'], 'CODE' => $template_module['code'], 'MODULE_ID' => $row['module_id'], @@ -211,7 +221,7 @@ class phpbb_ext_board3_portal_controller_main { $this->template->assign_block_vars('modules_' . column_num_string($row['module_column']), array( 'TEMPLATE_FILE' => 'portal/modules/' . $template_module, - 'IMAGE_SRC' => $this->root_path . 'styles/' . $this->user->style['style_path'] . '/theme/images/portal/' . $row['module_image_src'], + 'IMAGE_SRC' => $this->path_helper->get_web_root_path() . $this->root_path . 'styles/' . $this->user->style['style_path'] . '/theme/images/portal/' . $row['module_image_src'], 'IMAGE_WIDTH' => $row['module_image_width'], 'IMAGE_HEIGHT' => $row['module_image_height'], 'MODULE_ID' => $row['module_id'], @@ -240,19 +250,19 @@ class phpbb_ext_board3_portal_controller_main 'S_BOTTOM_COLUMN' => ($module_count['bottom'] > 0) ? true : false, 'S_DISPLAY_PHPBB_MENU' => $this->config['board3_phpbb_menu'], 'B3P_DISPLAY_JUMPBOX' => $this->config['board3_display_jumpbox'], - 'T_EXT_THEME_PATH' => $this->phpbb_root_path . 'ext/board3/portal/styles/' . $this->user->style['style_path'] . '/theme/', + 'T_EXT_THEME_PATH' => $this->path_helper->get_web_root_path() . $this->root_path . 'styles/' . $this->user->style['style_path'] . '/theme/', )); - // And now to output the page. - page_header($this->user->lang('PORTAL')); + // And now to output the page. + page_header($this->user->lang('PORTAL')); - // foobar_body.html is in ./ext/foobar/example/styles/prosilver/template/foobar_body.html - $this->template->set_filenames(array( - 'body' => 'portal/portal_body.html' - )); + // foobar_body.html is in ./ext/foobar/example/styles/prosilver/template/foobar_body.html + $this->template->set_filenames(array( + 'body' => 'portal/portal_body.html' + )); - page_footer(); - } + page_footer(); + } // check if user should be able to access this page private function check_permission() diff --git a/root/ext.php b/root/ext.php index 4b5fd6f1..3cc7397e 100644 --- a/root/ext.php +++ b/root/ext.php @@ -4,6 +4,8 @@ // however you can override the default methods and add custom // installation logic -class phpbb_ext_board3_portal_ext extends phpbb_extension_base +namespace board3\portal; + +class ext extends \phpbb\extension\base { } diff --git a/root/migrations/210_beta1.php b/root/migrations/v210_beta1.php similarity index 99% rename from root/migrations/210_beta1.php rename to root/migrations/v210_beta1.php index 34b72e42..f8a50357 100644 --- a/root/migrations/210_beta1.php +++ b/root/migrations/v210_beta1.php @@ -7,7 +7,9 @@ * */ -class phpbb_ext_board3_portal_migrations_210_beta1 extends phpbb_db_migration +namespace board3\portal\migrations; + +class v210_beta1 extends \phpbb\db\migration\migration { /** * Portal config table @@ -22,7 +24,7 @@ class phpbb_ext_board3_portal_migrations_210_beta1 extends phpbb_db_migration static public function depends_on() { - return array('phpbb_db_migration_data_310_extensions'); + return array('\phpbb\db\migration\data\v310\extensions'); } public function update_schema() diff --git a/root/portal/modules/portal_calendar.php b/root/portal/modules/portal_calendar.php index f45fd61b..f885e3a3 100644 --- a/root/portal/modules/portal_calendar.php +++ b/root/portal/modules/portal_calendar.php @@ -110,8 +110,8 @@ class portal_calendar_module // output our general calendar bits $down = $this->mini_cal_month - 1; $up = $this->mini_cal_month + 1; - $prev_month = '<<'; - $next_month = '>>'; + $prev_month = '<<'; + $next_month = '>>'; $template->assign_block_vars('minical', array( 'S_SUNDAY_FIRST' => ($config['board3_sunday_first_' . $module_id]) ? true : false, @@ -591,11 +591,6 @@ class portal_calendar_module **/ private function makeTimestamp($date) { -<<<<<<< HEAD -======= - global $user; - ->>>>>>> 36903cb... Display correct day of the week with negative UTC offset $this->stamp = strtotime($date); return ($this->stamp); } diff --git a/root/portal/modules/portal_poll.php b/root/portal/modules/portal_poll.php index db70d5ed..2fe95581 100644 --- a/root/portal/modules/portal_poll.php +++ b/root/portal/modules/portal_poll.php @@ -348,7 +348,7 @@ class portal_poll_module $sql = 'SELECT t.poll_title, t.poll_start, t.topic_id, t.topic_first_post_id, t.forum_id, t.poll_length, t.poll_vote_change, t.poll_max_options, t.topic_status, f.forum_status, p.bbcode_bitfield, p.bbcode_uid FROM ' . TOPICS_TABLE . ' t, ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . " f - WHERE t.forum_id = f.forum_id AND t.topic_approved = 1 AND t.poll_start > 0 + WHERE t.forum_id = f.forum_id AND t.topic_visibility = 1 AND t.poll_start > 0 {$where} AND t.topic_moved_id = 0 AND p.post_id = t.topic_first_post_id diff --git a/root/styles/prosilver/template/event/overall_header_head_append.html b/root/styles/prosilver/template/event/overall_header_head_append.html index 2ca0ca1f..dfb983a1 100755 --- a/root/styles/prosilver/template/event/overall_header_head_append.html +++ b/root/styles/prosilver/template/event/overall_header_head_append.html @@ -1 +1 @@ - + diff --git a/root/styles/prosilver/template/portal/_block_config.html b/root/styles/prosilver/template/portal/_block_config.html index c14b14ba..c87b8ea9 100644 --- a/root/styles/prosilver/template/portal/_block_config.html +++ b/root/styles/prosilver/template/portal/_block_config.html @@ -1,6 +1,6 @@ - + diff --git a/root/styles/prosilver/template/portal/modules/news_compact_center.html b/root/styles/prosilver/template/portal/modules/news_compact_center.html index ed3125be..448af991 100644 --- a/root/styles/prosilver/template/portal/modules/news_compact_center.html +++ b/root/styles/prosilver/template/portal/modules/news_compact_center.html @@ -10,10 +10,10 @@ {$CC_BLOCK_H_L} -
style="width: 44%"style="width: 60%">{$TITLE}
+
{$TITLE}
-
{L_REPLIES}
-
{L_VIEWS}
+
{L_REPLIES}
+
{L_VIEWS}
{L_LAST_POST}
{$CC_BLOCK_H_R} @@ -21,31 +21,39 @@
  • -
    {NEWEST_POST_IMG} {news_row.ATTACH_ICON_IMG} {L_VIEW_TOPIC_POLL}{news_row.TITLE}{L_VIEW_UNREAD_POST} - - +
    style="background-image: url({T_ICONS_PATH}{news_row.TOPIC_ICON_IMG}); background-repeat: no-repeat;" title="{news_row.TOPIC_FOLDER_IMG_ALT}"> + + {NEWEST_POST_IMG} -
    {L_POSTED} {L_POST_BY_AUTHOR} {news_row.POSTER_FULL} » {news_row.TIME} - -
    {L_FORUM}: {news_row.FORUM_NAME} - - {L_REPLIES}: {news_row.REPLIES} • {L_VIEWS}: {news_row.TOPIC_VIEWS} + {news_row.ATTACH_ICON_IMG} + {L_VIEW_TOPIC_POLL} +
    + {news_row.TITLE}{L_VIEW_UNREAD_POST} + + + +
    {L_POSTED} {L_POST_BY_AUTHOR} {news_row.POSTER_FULL} » {news_row.TIME} + +
    {L_FORUM}: {news_row.FORUM_NAME} + + {L_REPLIES}: {news_row.REPLIES} • {L_VIEWS}: {news_row.TOPIC_VIEWS} +
    -
    {news_row.REPLIES} {L_REPLIES}
    -
    {news_row.TOPIC_VIEWS} {L_VIEWS}
    +
    {news_row.REPLIES} {L_REPLIES}
    +
    {news_row.TOPIC_VIEWS} {L_VIEWS}
    -
    {L_LAST_POST}{L_POST_BY_AUTHOR} {news_row.USERNAME_FULL_LAST} {NEWEST_POST_IMG}{READ_POST_IMG}
    +
    {L_LAST_POST}{L_POST_BY_AUTHOR} {news_row.USERNAME_FULL_LAST} {NEWEST_POST_IMG}{READ_POST_IMG}
    {news_row.LAST_POST_TIME}
    diff --git a/root/styles/prosilver/template/portal/modules/recent_center.html b/root/styles/prosilver/template/portal/modules/recent_center.html index 88d9b9c2..36f8a9d7 100644 --- a/root/styles/prosilver/template/portal/modules/recent_center.html +++ b/root/styles/prosilver/template/portal/modules/recent_center.html @@ -1,7 +1,7 @@ {$C_BLOCK_H_L}{$TITLE}{$C_BLOCK_H_R}