/** * Show bbcodes and smilies in the quickreply * Template data for Ajax submit * * @param object $event The event object * @return null * @access public */ public function viewtopic_modify_data($event) { $forum_id = $event['forum_id']; $topic_data = $event['topic_data']; $post_list = $event['post_list']; $topic_id = $topic_data['topic_id']; $s_quick_reply = false; if (($this->user->data['is_registered'] || $this->config['qr_allow_for_guests']) && $this->config['allow_quick_reply'] && $topic_data['forum_flags'] & FORUM_FLAG_QUICK_REPLY && $this->auth->acl_get('f_reply', $forum_id)) { // Quick reply enabled forum $s_quick_reply = $topic_data['forum_status'] == ITEM_UNLOCKED && $topic_data['topic_status'] == ITEM_UNLOCKED || $this->auth->acl_get('m_edit', $forum_id) ? true : false; } if (!$this->user->data['is_registered'] && $s_quick_reply) { add_form_key('posting'); $s_attach_sig = $this->config['allow_sig'] && $this->user->optionget('attachsig') && $this->auth->acl_get('f_sigs', $forum_id) && $this->auth->acl_get('u_sig'); $s_smilies = $this->config['allow_smilies'] && $this->user->optionget('smilies') && $this->auth->acl_get('f_smilies', $forum_id); $s_bbcode = $this->config['allow_bbcode'] && $this->user->optionget('bbcode') && $this->auth->acl_get('f_bbcode', $forum_id); $s_notify = false; $qr_hidden_fields = array('topic_cur_post_id' => (int) $topic_data['topic_last_post_id'], 'lastclick' => (int) time(), 'topic_id' => (int) $topic_data['topic_id'], 'forum_id' => (int) $forum_id); // Originally we use checkboxes and check with isset(), so we only provide them if they would be checked !$s_bbcode ? $qr_hidden_fields['disable_bbcode'] = 1 : true; !$s_smilies ? $qr_hidden_fields['disable_smilies'] = 1 : true; !$this->config['allow_post_links'] ? $qr_hidden_fields['disable_magic_url'] = 1 : true; $s_attach_sig ? $qr_hidden_fields['attach_sig'] = 1 : true; $s_notify ? $qr_hidden_fields['notify'] = 1 : true; $topic_data['topic_status'] == ITEM_LOCKED ? $qr_hidden_fields['lock_topic'] = 1 : true; $this->template->assign_vars(array('S_QUICK_REPLY' => true, 'U_QR_ACTION' => append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", "mode=reply&f={$forum_id}&t={$topic_id}"), 'QR_HIDDEN_FIELDS' => build_hidden_fields($qr_hidden_fields), 'USERNAME' => $this->request->variable('username', '', true))); if ($this->config['enable_post_confirm']) { $captcha = $this->captcha->get_instance($this->config['captcha_plugin']); $captcha->init(CONFIRM_POST); } if ($this->config['enable_post_confirm'] && (isset($captcha) && $captcha->is_solved() === false)) { $this->template->assign_vars(array('S_CONFIRM_CODE' => true, 'CAPTCHA_TEMPLATE' => $captcha->get_template())); } // Add the confirm id/code pair to the hidden fields, else an error is displayed on next submit/preview if (isset($captcha) && $captcha->is_solved() !== false) { $this->template->append_var('QR_HIDDEN_FIELDS', build_hidden_fields($captcha->get_hidden_fields())); } } // Ajaxify viewtopic data if ($this->request->is_ajax() && $this->request->is_set('qr_request')) { if (!$this->user->data['is_registered'] && $this->config['enable_post_confirm']) { $captcha = $this->captcha->get_instance($this->config['captcha_plugin']); $captcha->init(CONFIRM_POST); // Add the confirm id/code pair to the hidden fields, else an error is displayed on next submit/preview if (isset($captcha) && $captcha->is_solved() !== false) { $this->template->append_var('QR_HIDDEN_FIELDS', build_hidden_fields($captcha->get_hidden_fields())); } } // Fix issues if the inserted post is not the first. if ($this->qr_insert && !$this->qr_first) { $this->template->alter_block_array('postrow', array('S_FIRST_ROW' => false), false, 'change'); } $page_title = $event['page_title']; $this->template->assign_vars(array('S_QUICKREPLY_REQUEST' => true, 'S_QR_NO_FIRST_POST' => $this->qr_insert, 'S_QR_FULL_QUOTE' => $this->config['qr_full_quote'])); $this->template->append_var('QR_HIDDEN_FIELDS', build_hidden_fields(array('qr' => 1, 'qr_cur_post_id' => (int) max($post_list)))); // Output the page page_header($page_title, false, $forum_id); page_footer(false, false, false); $json_response = new \phpbb\json_response(); $json_response->send(array('success' => true, 'result' => $this->template->assign_display('@tatiana5_quickreply/quickreply_template.html', '', true), 'insert' => $this->qr_insert)); } if ($s_quick_reply) { include_once $this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext; // HTML, BBCode, Smilies, Images and Flash status $bbcode_status = $this->config['allow_bbcode'] && $this->config['qr_bbcode'] && $this->auth->acl_get('f_bbcode', $forum_id) ? true : false; $smilies_status = $this->config['allow_smilies'] && $this->config['qr_smilies'] && $this->auth->acl_get('f_smilies', $forum_id) ? true : false; $img_status = $bbcode_status && $this->auth->acl_get('f_img', $forum_id) ? true : false; $url_status = $this->config['allow_post_links'] ? true : false; $flash_status = $bbcode_status && $this->auth->acl_get('f_flash', $forum_id) && $this->config['allow_post_flash'] ? true : false; $quote_status = true; // Build custom bbcodes array if ($bbcode_status) { display_custom_bbcodes(); } // Generate smiley listing if ($smilies_status) { generate_smilies('inline', $forum_id); } // Show attachment box for adding attachments if true $form_enctype = @ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !$this->config['allow_attachments'] || !$this->auth->acl_get('u_attach') || !$this->auth->acl_get('f_attach', $forum_id) ? '' : '" enctype="multipart/form-data'; $allowed = $this->auth->acl_get('f_attach', $forum_id) && $this->auth->acl_get('u_attach') && $this->config['allow_attachments'] && $form_enctype; $attachment_data = false; if ($bbcode_status || $smilies_status || $this->config['qr_attach'] && $allowed) { $this->user->add_lang('posting'); } if ($this->config['qr_attach'] && $allowed) { $this->template->assign_vars(array('U_QR_ACTION' => append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", "mode=reply&f={$forum_id}&t={$topic_id}") . $form_enctype)); include_once $this->phpbb_root_path . 'includes/message_parser.' . $this->php_ext; $message_parser = new \parse_message(); $message_parser->set_plupload($this->plupload); $message_parser->set_mimetype_guesser($this->mimetype_guesser); $message_parser->get_submitted_attachment_data($this->user->data['user_id']); $attachment_data = $message_parser->attachment_data; $filename_data = $message_parser->filename_data; posting_gen_inline_attachments($attachment_data); $max_files = $this->auth->acl_get('a_') || $this->auth->acl_get('m_', $forum_id) ? 0 : (int) $this->config['max_attachments']; $topic_id = $topic_data['topic_id']; $s_action = append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", "mode=reply&f={$forum_id}&t={$topic_id}"); $this->plupload->configure($this->cache, $this->template, $s_action, $forum_id, $max_files); posting_gen_attachment_entry($attachment_data, $filename_data, $allowed); } $this->template->append_var('QR_HIDDEN_FIELDS', build_hidden_fields(array('qr' => 1, 'qr_cur_post_id' => (int) max($post_list)))); if ($this->phpbb_extension_manager->is_enabled('rxu/PostsMerging') && $this->user->data['is_registered'] && $this->config['merge_interval']) { // Always show the checkbox if PostsMerging extension is installed. $this->user->add_lang_ext('rxu/PostsMerging', 'posts_merging'); $this->template->assign_var('POSTS_MERGING_OPTION', true); } $this->template->assign_vars(array('S_QR_COLOUR_NICKNAME' => $this->config['qr_color_nickname'], 'S_QR_NOT_CHANGE_SUBJECT' => $this->auth->acl_get('f_qr_change_subject', $forum_id) ? false : true, 'S_QR_COMMA_ENABLE' => $this->config['qr_comma'], 'S_QR_QUICKNICK_ENABLE' => $this->config['qr_quicknick'], 'S_QR_QUICKNICK_REF' => $this->config['qr_quicknick_ref'], 'S_QR_QUICKNICK_PM' => $this->config['qr_quicknick_pm'], 'S_QR_QUICKQUOTE_ENABLE' => $this->config['qr_quickquote'], 'S_QR_QUICKQUOTE_LINK' => $this->config['qr_quickquote_link'], 'S_QR_FULL_QUOTE' => $this->config['qr_full_quote'], 'S_QR_CE_ENABLE' => $this->config['qr_ctrlenter'], 'QR_SOURCE_POST' => $this->config['qr_source_post'], 'S_DISPLAY_USERNAME' => !$this->user->data['is_registered'], 'S_BBCODE_ALLOWED' => $bbcode_status ? 1 : 0, 'S_SMILIES_ALLOWED' => $smilies_status, 'S_BBCODE_IMG' => $img_status, 'S_LINKS_ALLOWED' => $url_status, 'S_BBCODE_FLASH' => $flash_status, 'S_BBCODE_QUOTE' => $quote_status, 'MESSAGE' => $this->request->variable('message', '', true), 'READ_POST_IMG' => $this->user->img('icon_post_target', 'POST'), 'S_QR_CAPS_ENABLE' => $this->config['qr_capslock_transfer'], 'S_QR_SHOW_BUTTON_TRANSLIT' => $this->config['qr_show_button_translit'], 'L_FULL_EDITOR' => $this->config['qr_ajax_submit'] ? $this->user->lang['PREVIEW'] : $this->user->lang['FULL_EDITOR'], 'S_QR_AJAX_SUBMIT' => $this->config['qr_ajax_submit'], 'S_QR_AJAX_PAGINATION' => $this->config['qr_ajax_pagination'] && $this->user->data['ajax_pagination'], 'S_QR_ENABLE_SCROLL' => $this->user->data['qr_enable_scroll'], 'S_QR_SCROLL_INTERVAL' => $this->config['qr_scroll_time'], 'S_QR_SOFT_SCROLL' => $this->config['qr_scroll_time'] && $this->user->data['qr_soft_scroll'], 'S_QR_ALLOWED_GUEST' => $this->config['qr_allow_for_guests'] && $this->user->data['user_id'] == ANONYMOUS, 'S_ABBC3_INSTALLED' => $this->phpbb_extension_manager->is_enabled('vse/abbc3'), 'S_QR_SHOW_ATTACH_BOX' => $this->config['qr_attach'] && $allowed, 'S_ATTACH_DATA' => $attachment_data ? json_encode($attachment_data) : '[]')); $add_re = $this->config['qr_enable_re'] ? 'Re: ' : ''; $this->template->assign_var('SUBJECT', $this->request->variable('subject', $add_re . censor_text($topic_data['topic_title']), true)); } $this->template->assign_vars(array('QR_HIDE_POSTS_SUBJECT' => $this->config['qr_show_subjects'] ? false : true)); }
/** * Create a non-cached UrlMatcher * * @param \phpbb\extension\manager $manager Extension manager * @param RequestContext $context Symfony RequestContext object * @return UrlMatcher */ function phpbb_create_url_matcher(\phpbb\extension\manager $manager, RequestContext $context, $root_path) { $provider = new \phpbb\controller\provider(); $provider->find_routing_files($manager->get_finder()); $routes = $provider->find($root_path)->get_routes(); return new UrlMatcher($routes, $context); }
/** * {@inheritdoc} */ public function run() { if (!$this->config->get('populate_migration_refresh_before', false)) { if ($this->config->get_time_remaining() < 1) { $this->config->set('populate_migration_refresh_before', true); throw new resource_limit_reached_exception(); } } $finder = $this->extension_manager->get_finder(); $migrations = $finder->core_path('phpbb/db/migration/data/')->get_classes(); $this->migrator->populate_migrations($migrations); }
/** * Constructor * * @param \phpbb\template\template $template Template object * @param \phpbb\user $user User object * @param \phpbb\config\config $config Config object * @param \phpbb\controller\provider $provider Path provider * @param \phpbb\extension\manager $manager Extension manager object * @param \phpbb\symfony_request $symfony_request Symfony Request object * @param \phpbb\request\request_interface $request phpBB request object * @param \phpbb\filesystem $filesystem The filesystem object * @param string $phpbb_root_path phpBB root path * @param string $php_ext PHP file extension */ public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, \phpbb\symfony_request $symfony_request, \phpbb\request\request_interface $request, \phpbb\filesystem $filesystem, $phpbb_root_path, $php_ext) { $this->template = $template; $this->user = $user; $this->config = $config; $this->symfony_request = $symfony_request; $this->request = $request; $this->filesystem = $filesystem; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; $provider->find_routing_files($manager->get_finder()); $this->route_collection = $provider->find($phpbb_root_path)->get_routes(); }
public function __construct(ContainerInterface $container, \phpbb\finder $extension_finder, \phpbb\db\migrator $migrator, $extension_name, $extension_path) { parent::__construct($container, $extension_finder, $migrator, $extension_name, $extension_path); $this->manager = $this->container->get('ext.manager'); $this->metadata_manager = $this->manager->create_extension_metadata_manager($this->extension_name, $this->container->get('template')); // We are maybe not enabled, so we need to create the object ourself if ($this->container->has('wolfsblvt.core.requirements_helper')) { $this->requirements_helper = $this->container->get('wolfsblvt.core.requirements_helper'); } else { $core = new \wolfsblvt\core\core\core($this->manager, $this->container->get('config'), $this->container->get('dbal.conn'), $this->container->get('request'), $this->container->get('template'), $this->container->get('user'), $this->container->getParameter('core.root_path'), $this->container->getParameter('core.php_ext')); $this->requirements_helper = new \wolfsblvt\core\core\requirements_helper($core, $this->manager, $this->container->get('config'), $this->container->get('dbal.conn'), $this->container->get('template'), $this->container->get('user')); $this->container->set('wolfsblvt.core.requirements_helper', $this->requirements_helper); $this->container->set('wolfsblvt.core.core', $core); } }
/** * Get the list of routes * * @return RouteCollection Get the route collection */ public function get_routes() { if ($this->route_collection == null || empty($this->routing_files)) { $this->find_routing_files($this->extension_manager !== null ? $this->extension_manager->all_enabled(false) : array())->find($this->phpbb_root_path); } return $this->route_collection; }
/** * Event: core.acp_manage_forums_display_form * * @param Event $event */ public function acp_manage_forums_display_form($event) { $this->user->add_lang_ext('kasimi/movetopicswhenlocked', 'acp_forum_settings'); $is_edit = $event['action'] == 'edit'; $forum_data = $event['forum_data']; $template_vars = array('MOVE_TOPICS_WHEN_LOCKED_VERSION' => $this->config['kasimi.movetopicswhenlocked.version'], 'S_MOVE_TOPICS' => $is_edit ? $forum_data['move_topics_when_locked'] : false, 'S_MOVE_TOPICS_TO_OPTIONS' => make_forum_select($is_edit ? $forum_data['move_topics_when_locked_to'] : false, false, false, true)); $topic_solved_extension = $this->user->lang('MOVE_TOPICS_SOLVED_EXTENSION'); if ($this->extension_manager->is_enabled(self::EXT_TOPIC_SOLVED_NAME)) { $metadata = $this->extension_manager->create_extension_metadata_manager(self::EXT_TOPIC_SOLVED_NAME, $this->template)->get_metadata(); $is_valid_version = phpbb_version_compare($metadata['version'], self::EXT_TOPIC_SOLVED_MIN_VERSION, '>='); $template_vars = array_merge($template_vars, array('S_MOVE_TOPICS_SOLVED' => $is_edit ? $forum_data['move_topics_when_locked_solved'] : false, 'MOVE_TOPICS_SOLVED_ENABLED' => $is_valid_version ? $this->user->lang('MOVE_TOPICS_SOLVED_ENABLED', $topic_solved_extension) : false, 'MOVE_TOPICS_SOLVED_VERSION' => $is_valid_version ? false : $this->user->lang('MOVE_TOPICS_SOLVED_VERSION', self::EXT_TOPIC_SOLVED_MIN_VERSION, $topic_solved_extension))); } else { $template_vars['MOVE_TOPICS_SOLVED_DISABLED'] = $this->user->lang('EXTENSION_DISABLED', $topic_solved_extension); } $this->template->assign_vars($template_vars); }
/** * {@inheritdoc} */ public function run() { $this->language->add_lang('migrator'); if (!isset($this->config['version_update_from'])) { $this->config->set('version_update_from', $this->config['version']); } $original_version = $this->config['version_update_from']; $this->migrator->set_output_handler(new log_wrapper_migrator_output_handler($this->language, new installer_migrator_output_handler($this->iohandler), $this->phpbb_root_path . 'store/migrations_' . time() . '.log', $this->filesystem)); $this->migrator->create_migrations_table(); $migrations = $this->extension_manager->get_finder()->core_path('phpbb/db/migration/data/')->extension_directory('/migrations')->get_classes(); $this->migrator->set_migrations($migrations); $migration_step_count = $this->installer_config->get('database_update_migration_steps', -1); if ($migration_step_count < 0) { $migration_step_count = count($this->migrator->get_installable_migrations()) * 2; $this->installer_config->set('database_update_migration_steps', $migration_step_count); } $progress_count = $this->installer_config->get('database_update_count', 0); $restart_progress_bar = $progress_count === 0; // Only "restart" when the update runs for the first time $this->iohandler->set_task_count($migration_step_count, $restart_progress_bar); $this->installer_config->set_task_progress_count($migration_step_count); while (!$this->migrator->finished()) { try { $this->migrator->update(); $progress_count++; $last_run_migration = $this->migrator->get_last_run_migration(); if (isset($last_run_migration['effectively_installed']) && $last_run_migration['effectively_installed']) { // We skipped two step, so increment $progress_count by another one $progress_count++; } else { if ($last_run_migration['task'] === 'process_schema_step' && !$last_run_migration['state']['migration_schema_done'] || $last_run_migration['task'] === 'process_data_step' && !$last_run_migration['state']['migration_data_done']) { // We just run a step that wasn't counted yet so make it count $migration_step_count++; } } $this->iohandler->set_task_count($migration_step_count); $this->installer_config->set_task_progress_count($migration_step_count); $this->iohandler->set_progress('STAGE_UPDATE_DATABASE', $progress_count); } catch (exception $e) { $msg = $e->getParameters(); array_unshift($msg, $e->getMessage()); $this->iohandler->add_error_message($msg); throw new user_interaction_required_exception(); } if ($this->installer_config->get_time_remaining() <= 0 || $this->installer_config->get_memory_remaining() <= 0) { $this->installer_config->set('database_update_count', $progress_count); $this->installer_config->set('database_update_migration_steps', $migration_step_count); throw new resource_limit_reached_exception(); } } if ($original_version !== $this->config['version']) { $this->log->add('admin', isset($this->user->data['user_id']) ? $this->user->data['user_id'] : ANONYMOUS, $this->user->ip, 'LOG_UPDATE_DATABASE', false, array($original_version, $this->config['version'])); } $this->iohandler->add_success_message('INLINE_UPDATE_SUCCESSFUL'); $this->config->delete('version_update_from'); $this->cache->purge(); $this->config->increment('assets_version', 1); }
/** * Check versions for all extensions and return the ones that need an update * * @param bool $check_disabled * @param bool $check_purged * @param bool $force_update * @return array extension names => version info(new, current) */ public function check_ext_versions($check_disabled = true, $check_purged = true, $force_update = false) { if ($check_disabled && $check_purged) { $extensions = $this->manager->all_available(); } else { if ($check_disabled) { $extensions = $this->manager->all_configured(); } else { if ($check_purged) { $extensions = array_diff($this->manager->all_available(), $this->manager->all_disabled()); } else { $extensions = $this->manager->all_enabled(); } } } $version_info = array(); foreach (array_keys($extensions) as $extname) { try { $md_manager = $this->manager->create_extension_metadata_manager($extname, $this->template); // We only need an update if the version check returns potential updates if ($new_versions = $this->version_check($md_manager, $force_update)) { $curr_version = $md_manager->get_metadata('version'); $version_info[$extname] = array('new' => $new_versions, 'current' => $curr_version); } } catch (\Exception $e) { // TODO: Should we store this information, if there is version check info available? continue; } } return $version_info; }
/** * Assign template variables if quick reply is enabled * * @param int $forum_id Forum ID */ public function assign_template_variables_for_qr($forum_id) { if ($this->phpbb_extension_manager->is_enabled('rxu/PostsMerging') && $this->user->data['is_registered'] && $this->config['merge_interval']) { // Always show the checkbox if PostsMerging extension is installed. $this->user->add_lang_ext('rxu/PostsMerging', 'posts_merging'); $this->template->assign_var('POSTS_MERGING_OPTION', true); } $this->template->assign_vars(array('S_QR_COLOUR_NICKNAME' => $this->config['qr_color_nickname'], 'S_QR_NOT_CHANGE_SUBJECT' => $this->auth->acl_get('f_qr_change_subject', $forum_id) ? false : true, 'QR_HIDE_SUBJECT_BOX' => $this->config['qr_hide_subject_box'], 'S_QR_COMMA_ENABLE' => $this->config['qr_comma'], 'S_QR_QUICKNICK_ENABLE' => $this->config['qr_quicknick'], 'S_QR_QUICKNICK_REF' => $this->config['qr_quicknick_ref'], 'S_QR_QUICKNICK_PM' => $this->config['qr_quicknick_pm'], 'S_QR_QUICKQUOTE_ENABLE' => $this->config['qr_quickquote'], 'S_QR_QUICKQUOTE_LINK' => $this->config['qr_quickquote_link'], 'S_QR_FULL_QUOTE' => $this->config['qr_full_quote'], 'S_QR_CE_ENABLE' => $this->config['qr_ctrlenter'], 'QR_SOURCE_POST' => $this->config['qr_source_post'], 'S_DISPLAY_USERNAME' => !$this->user->data['is_registered'], 'MESSAGE' => $this->request->variable('message', '', true), 'READ_POST_IMG' => $this->user->img('icon_post_target', 'POST'), 'S_QR_CAPS_ENABLE' => $this->config['qr_capslock_transfer'], 'S_QR_SHOW_BUTTON_TRANSLIT' => $this->config['qr_show_button_translit'], 'L_FULL_EDITOR' => $this->config['qr_ajax_submit'] ? $this->user->lang['PREVIEW'] : $this->user->lang['FULL_EDITOR'], 'S_QR_AJAX_SUBMIT' => $this->config['qr_ajax_submit'], 'S_QR_AJAX_PAGINATION' => $this->config['qr_ajax_pagination'] && $this->user->data['ajax_pagination'], 'S_QR_ENABLE_SCROLL' => $this->user->data['qr_enable_scroll'], 'S_QR_SCROLL_INTERVAL' => $this->config['qr_scroll_time'], 'S_QR_SOFT_SCROLL' => $this->config['qr_scroll_time'] && $this->user->data['qr_soft_scroll'], 'S_QR_ALLOWED_GUEST' => $this->config['qr_allow_for_guests'] && $this->user->data['user_id'] == ANONYMOUS, 'S_ABBC3_INSTALLED' => $this->phpbb_extension_manager->is_enabled('vse/abbc3'))); }
protected function execute(InputInterface $input, OutputInterface $output) { $migrations = $this->extension_manager->get_finder()->set_extensions(array())->core_path('phpbb/db/migration/data/')->get_classes(); $tips = $migrations; foreach ($migrations as $migration_class) { foreach ($migration_class::depends_on() as $dependency) { $tips_key = array_search($dependency, $tips); if ($tips_key !== false) { unset($tips[$tips_key]); } } } $output->writeln("\t\tarray("); foreach ($tips as $migration) { $output->writeln("\t\t\t'{$migration}',"); } $output->writeln("\t\t);"); }
/** * Sets the filepath of the metadata file * * @throws \phpbb\extension\exception */ private function set_metadata_file() { $ext_filepath = $this->extension_manager->get_extension_path($this->ext_name); $metadata_filepath = $this->phpbb_root_path . $ext_filepath . 'composer.json'; $this->metadata_file = $metadata_filepath; if (!file_exists($this->metadata_file)) { throw new \phpbb\extension\exception($this->user->lang('FILE_NOT_FOUND', $this->metadata_file)); } }
/** * Get file names from Topic Preview's CSS files * * @return Array of file names * @access protected */ protected function get_themes() { $finder = $this->ext_manager->get_finder(); // Find css files in ext/vse/topicpreview/styles/all/theme/ $files = $finder->extension_suffix('.css')->extension_directory('/styles/all/theme')->find_from_extension('topicpreview', $this->phpbb_root_path . 'ext/vse/topicpreview/'); // Get just basenames of array keys $files = array_map(function ($value) { return basename($value, '.css'); }, array_keys($files)); return $files; }
public function get_topic_data($event) { if ($this->user->data['is_registered'] && $this->config['allow_bookmarks']) { $topic_data = $event['topic_data']; $posts_bookmark = array(); $sql = 'SELECT post_id FROM ' . $this->postbookmark_table . ' WHERE user_id = ' . $this->user->data['user_id'] . ' AND topic_id = ' . $topic_data['topic_id']; $result = $this->db->sql_query($sql); while ($row = $this->db->sql_fetchrow($result)) { $posts_bookmark[] = $row['post_id']; } $this->db->sql_freeresult($result); if (!empty($posts_bookmark)) { $topic_data = array_merge($event['topic_data'], array('posts_bookmarks' => $posts_bookmark)); $event['topic_data'] = $topic_data; } $this->template->assign_vars(array('S_QUICK_REPLY_EXT' => $this->phpbb_extension_manager->is_enabled('boardtools/quickreply') || $this->phpbb_extension_manager->is_enabled('tatiana5/quickreply'))); } }
/** * Auto add the specified language file from across all extensions * * This is a modified copy of the add_mod_info in functions_module.php */ public function add($lang_file) { $finder = $this->ext_manager->get_finder(); // We grab the language files from the default, English and user's language. // So we can fall back to the other files like we do when using add_lang() $default_lang_files = $english_lang_files = array(); // Search for board default language if it's not the user language if ($this->config['default_lang'] != $this->user->lang_name) { $default_lang_files = $finder->prefix($lang_file)->suffix(".{$this->php_ext}")->extension_directory('/language/' . basename($this->config['default_lang']))->core_path('language/' . basename($this->config['default_lang']) . '/')->find(); } // Search for english, if its not the default or user language if ($this->config['default_lang'] != 'en' && $this->user->lang_name != 'en') { $english_lang_files = $finder->prefix($lang_file)->suffix(".{$this->php_ext}")->extension_directory('/language/en')->core_path('language/en/')->find(); } // Find files in the user's language $user_lang_files = $finder->prefix($lang_file)->suffix(".{$this->php_ext}")->extension_directory('/language/' . $this->user->lang_name)->core_path('language/' . $this->user->lang_name . '/')->find(); $lang_files = array_unique(array_merge($user_lang_files, $english_lang_files, $default_lang_files)); foreach ($lang_files as $lang_file => $ext_name) { $this->user->add_lang_ext($ext_name, $lang_file); } }
/** * Append extension resources to an array of resouces * * @see resources_locator_interface::locate_resources() * * @param mixed[] $resources List of resources * * @return mixed[] List of resources */ protected function append_ext_resources(array $resources) { if ($this->extension_manager !== null) { foreach ($this->extension_manager->all_enabled(false) as $path) { if (file_exists($this->phpbb_root_path . $path . 'config/' . $this->environment . '/routing/environment.yml')) { $resources[] = [$path . 'config/' . $this->environment . '/routing/environment.yml', 'yaml']; } else { if (!is_dir($this->phpbb_root_path . $path . 'config/' . $this->environment)) { if (file_exists($this->phpbb_root_path . $path . 'config/default/routing/environment.yml')) { $resources[] = [$path . 'config/default/routing/environment.yml', 'yaml']; } else { if (!is_dir($this->phpbb_root_path . $path . 'config/default/routing') && file_exists($this->phpbb_root_path . $path . 'config/routing.yml')) { $resources[] = [$path . 'config/routing.yml', 'yaml']; } } } } } } return $resources; }
public function __construct(\phpbb\config\config $config, \phpbb\cache\service $cache, \phpbb\db\driver\driver_interface $db, \phpbb\db\tools $db_tools, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\extension\manager $extension_manager, \phpbb\profilefields\manager $profilefields_manager, \phpbb\template\template $template, \phpbb\user $user, \phpbb\path_helper $path_helper, $root_path, $phpEx, $pbwow_config_table, $pbwow_chars_table) { $this->config = $config; $this->cache = $cache; $this->db = $db; $this->db_tools = $db_tools; $this->dispatcher = $dispatcher; $this->extension_manager = $extension_manager; $this->profilefields_manager = $profilefields_manager; $this->template = $template; $this->user = $user; $this->path_helper = $path_helper; $this->root_path = $root_path; $this->phpEx = $phpEx; $this->pbwow_config_table = $pbwow_config_table; $this->pbwow_chars_table = $pbwow_chars_table; $this->get_pbwow_config(); $this->avatars_enabled = $config['allow_avatar'] && $user->optionget('viewavatars') ? true : false; $this->avatars_enabled_full = $this->avatars_enabled && $this->pbwow_config['avatars_enable'] ? true : false; $this->tp_ext_enabled = $extension_manager->is_enabled('vse/topicpreview'); }
/** * Get file names from Topic Preview's CSS files * * @return array File name data */ protected function get_themes() { $finder = $this->ext_manager->get_finder(); // Find css files in ext/vse/topicpreview/styles/all/theme/ $themes = $finder->extension_suffix('.css')->extension_directory('/styles/all/theme')->find_from_extension('topicpreview', $this->phpbb_root_path . 'ext/vse/topicpreview/'); // Get just basenames of array keys $themes = array_map(function ($value) { return basename($value, '.css'); }, array_keys($themes)); // Add option for native browser tooltip (aka no theme) $themes[] = self::NO_THEME; return $themes; }
/** * {@inheritdoc} */ public function run() { $this->user->session_begin(); $this->user->setup(array('common', 'acp/common', 'cli')); $install_extensions = $this->iohandler->get_input('install-extensions', array()); $all_available_extensions = $this->extension_manager->all_available(); $i = $this->install_config->get('install_extensions_index', 0); $available_extensions = array_slice($all_available_extensions, $i); // Install extensions foreach ($available_extensions as $ext_name => $ext_path) { if (!empty($install_extensions) && $install_extensions !== ['all'] && !in_array($ext_name, $install_extensions)) { continue; } try { $this->extension_manager->enable($ext_name); $extensions = $this->get_extensions(); if (isset($extensions[$ext_name]) && $extensions[$ext_name]['ext_active']) { // Create log $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($ext_name)); $this->iohandler->add_success_message(array('CLI_EXTENSION_ENABLE_SUCCESS', $ext_name)); } else { $this->iohandler->add_log_message(array('CLI_EXTENSION_ENABLE_FAILURE', $ext_name)); } } catch (\Exception $e) { // Add fail log and continue $this->iohandler->add_log_message(array('CLI_EXTENSION_ENABLE_FAILURE', $ext_name)); } $i++; // Stop execution if resource limit is reached if ($this->install_config->get_time_remaining() <= 0 || $this->install_config->get_memory_remaining() <= 0) { break; } } $this->install_config->set('install_extensions_index', $i); if ($i < sizeof($all_available_extensions)) { throw new resource_limit_reached_exception(); } }
/** * Enable all extensions wich were disabled by the given extension. * * @param mixed $extension_name The name of the extension. * @return void */ public function enable_disabled_requiring_extensions($extension_name) { $extensions = isset($this->temporary_disabled_extensions[$extension_name]) ? $this->temporary_disabled_extensions[$extension_name] : array(); $this->currently_enabling_extension = $extension_name; foreach ($extensions as $ext_name) { if ($this->manager->is_available($ext_name) && $this->manager->is_disabled($ext_name)) { $this->manager->enable($ext_name); } } unset($this->currently_enabling_extension); unset($this->temporary_disabled_extensions[$extension_name]); $this->config->set('wolfsblvt.core.temporary_disabled_extensions', json_encode($this->temporary_disabled_extensions)); // Overwrite success message $this->user->add_lang_ext('wolfsblvt/core', 'extensions_override'); }
/** * Set custom style location (able to use directory outside of phpBB). * * Note: Templates are still compiled to phpBB's cache directory. * * @param string|array $names Array of names (or detailed names) or string of name of template(s) in inheritance tree order, used by extensions. * E.g. array( * 'name' => 'adm', * 'ext_path' => 'adm/style/', * ) * @param string|array of string $paths Array of style paths, relative to current root directory * @return \phpbb\template\template $this */ public function set_custom_style($names, $paths) { $paths = is_string($paths) ? array($paths) : $paths; $names = is_string($names) ? array($names) : $names; // Set as __main__ namespace $this->twig->getLoader()->setPaths($paths); // Add all namespaces for all extensions if ($this->extension_manager instanceof \phpbb\extension\manager) { $names[] = 'all'; foreach ($this->extension_manager->all_enabled() as $ext_namespace => $ext_path) { // namespaces cannot contain / $namespace = str_replace('/', '_', $ext_namespace); $paths = array(); foreach ($names as $template_dir) { if (is_array($template_dir)) { if (isset($template_dir['ext_path'])) { $ext_style_template_path = $ext_path . $template_dir['ext_path']; $ext_style_path = dirname($ext_style_template_path); $ext_style_theme_path = $ext_style_path . 'theme/'; } else { $ext_style_path = $ext_path . 'styles/' . $template_dir['name'] . '/'; $ext_style_template_path = $ext_style_path . 'template/'; $ext_style_theme_path = $ext_style_path . 'theme/'; } } else { $ext_style_path = $ext_path . 'styles/' . $template_dir . '/'; $ext_style_template_path = $ext_style_path . 'template/'; $ext_style_theme_path = $ext_style_path . 'theme/'; } $is_valid_dir = false; if (is_dir($ext_style_template_path)) { $is_valid_dir = true; $paths[] = $ext_style_template_path; } if (is_dir($ext_style_theme_path)) { $is_valid_dir = true; $paths[] = $ext_style_theme_path; } if ($is_valid_dir) { // Add the base style directory as a safe directory $this->twig->getLoader()->addSafeDirectory($ext_style_path); } } $this->twig->getLoader()->setPaths($paths, $namespace); } } return $this; }
/** * {@inheritdoc} */ public function run() { $this->language->add_lang('migrator'); if (!isset($this->config['version_update_from'])) { $this->config->set('version_update_from', $this->config['version']); } $original_version = $this->config['version_update_from']; $this->migrator->set_output_handler(new log_wrapper_migrator_output_handler($this->language, new installer_migrator_output_handler($this->iohandler), $this->phpbb_root_path . 'store/migrations_' . time() . '.log', $this->filesystem)); $this->migrator->create_migrations_table(); $migrations = $this->extension_manager->get_finder()->core_path('phpbb/db/migration/data/')->extension_directory('/migrations')->get_classes(); $this->migrator->set_migrations($migrations); $migration_count = count($this->migrator->get_migrations()); $this->iohandler->set_task_count($migration_count, true); $progress_count = $this->installer_config->get('database_update_count', 0); while (!$this->migrator->finished()) { try { $this->migrator->update(); $progress_count++; $this->iohandler->set_progress('STAGE_UPDATE_DATABASE', $progress_count); } catch (exception $e) { $msg = $e->getParameters(); array_unshift($msg, $e->getMessage()); $this->iohandler->add_error_message($msg); $this->iohandler->send_response(); throw new user_interaction_required_exception(); } if ($this->installer_config->get_time_remaining() <= 0 || $this->installer_config->get_memory_remaining() <= 0) { $this->installer_config->set('database_update_count', $progress_count); throw new resource_limit_reached_exception(); } } if ($original_version !== $this->config['version']) { $this->log->add('admin', isset($this->user->data['user_id']) ? $this->user->data['user_id'] : ANONYMOUS, $this->user->ip, 'LOG_UPDATE_DATABASE', false, array($original_version, $this->config['version'])); } $this->iohandler->finish_progress('INLINE_UPDATE_SUCCESSFUL'); $this->iohandler->add_success_message('INLINE_UPDATE_SUCCESSFUL'); $this->config->delete('version_update_from'); $this->cache->purge(); $this->config->increment('assets_version', 1); }
/** * Get available module information from module files * * @param string $module_class Class of the module (acp, ucp, mcp etc...) * @param string $module ID of module * @param bool $use_all_available Use all available instead of just all * enabled extensions * * @return array Array with module information gathered from module info files. */ public function get_module_infos($module_class, $module = '', $use_all_available = false) { $directory = $this->phpbb_root_path . 'includes/' . $module_class . '/info/'; $fileinfo = array(); $finder = $this->extension_manager->get_finder($use_all_available); $modules = $finder->extension_suffix('_module')->extension_directory("/{$module_class}")->core_path("includes/{$module_class}/info/")->core_prefix($module_class . '_')->get_classes(true); foreach ($modules as $cur_module) { // Skip entries we do not need if we know the module we are // looking for if ($module && strpos(str_replace('\\', '_', $cur_module), $module) === false && $module !== $cur_module) { continue; } $info_class = preg_replace('/_module$/', '_info', $cur_module); // If the class does not exist it might be following the old // format. phpbb_acp_info_acp_foo needs to be turned into // acp_foo_info and the respective file has to be included // manually because it does not support auto loading $old_info_class_file = str_replace("phpbb_{$module_class}_info_", '', $cur_module); $old_info_class = $old_info_class_file . '_info'; if (class_exists($old_info_class)) { $info_class = $old_info_class; } else { if (!class_exists($info_class)) { $info_class = $old_info_class; // need to check class exists again because previous checks triggered autoloading if (!class_exists($info_class) && file_exists($directory . $old_info_class_file . '.' . $this->php_ext)) { include $directory . $old_info_class_file . '.' . $this->php_ext; } } } if (class_exists($info_class)) { $info = new $info_class(); $module_info = $info->module(); $main_class = isset($module_info['filename']) ? $module_info['filename'] : $cur_module; $fileinfo[$main_class] = $module_info; } } ksort($fileinfo); return $fileinfo; }
/** * Lists all the available extensions and dumps to the template * * @param $phpbb_extension_manager An instance of the extension manager * @return null */ public function list_available_exts(\phpbb\extension\manager $phpbb_extension_manager) { $uninstalled = array_diff_key($phpbb_extension_manager->all_available(), $phpbb_extension_manager->all_configured()); $available_extension_meta_data = array(); foreach ($uninstalled as $name => $location) { $md_manager = $phpbb_extension_manager->create_extension_metadata_manager($name, $this->template); try { $meta = $md_manager->get_metadata('all'); $available_extension_meta_data[$name] = array('META_DISPLAY_NAME' => $md_manager->get_metadata('display-name'), 'META_VERSION' => $meta['version']); $force_update = $this->request->variable('versioncheck_force', false); $updates = $this->version_check($md_manager, $force_update, !$force_update); $available_extension_meta_data[$name]['S_UP_TO_DATE'] = empty($updates); $available_extension_meta_data[$name]['S_VERSIONCHECK'] = true; $available_extension_meta_data[$name]['U_VERSIONCHECK_FORCE'] = $this->u_action . '&action=details&versioncheck_force=1&ext_name=' . urlencode($md_manager->get_metadata('name')); } catch (\phpbb\extension\exception $e) { $this->template->assign_block_vars('disabled', array('META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e), 'S_VERSIONCHECK' => false)); } catch (\RuntimeException $e) { $available_extension_meta_data[$name]['S_VERSIONCHECK'] = false; } } uasort($available_extension_meta_data, array($this, 'sort_extension_meta_data_table')); foreach ($available_extension_meta_data as $name => $block_vars) { $block_vars['U_DETAILS'] = $this->u_action . '&action=details&ext_name=' . urlencode($name); $this->template->assign_block_vars('disabled', $block_vars); $this->output_actions('disabled', array('ENABLE' => $this->u_action . '&action=enable_pre&ext_name=' . urlencode($name))); } }
protected function load_migrations() { $migrations = $this->extension_manager->get_finder()->core_path('phpbb/db/migration/data/')->extension_directory('/migrations')->get_classes(); $this->migrator->set_migrations($migrations); return $this->migrator->get_migrations(); }
/** * Lists all the available extensions and dumps to the template * * @param $phpbb_extension_manager An instance of the extension manager * @return null */ public static function list_available_exts(\phpbb\extension\manager $phpbb_extension_manager) { $uninstalled = array_diff_key($phpbb_extension_manager->all_available(), $phpbb_extension_manager->all_configured()); $available_extension_meta_data = array(); foreach ($uninstalled as $name => $location) { $md_manager = $phpbb_extension_manager->create_extension_metadata_manager($name, objects::$template); try { $display_ext_name = $md_manager->get_metadata('display-name'); $meta = $md_manager->get_metadata('all'); $available_extension_meta_data[$name] = array('IS_BROKEN' => false, 'META_DISPLAY_NAME' => $display_ext_name, 'META_NAME' => $name, 'META_VERSION' => $meta['version'], 'U_DELETE' => objects::$u_action . '&action=delete_ext&ext_name=' . urlencode($name), 'U_EXT_NAME' => $name); } catch (\phpbb\extension\exception $e) { $available_extension_meta_data[$name] = array('IS_BROKEN' => true, 'META_DISPLAY_NAME' => isset($display_ext_name) ? $display_ext_name : objects::$user->lang['EXTENSION_BROKEN'] . ' (' . $name . ')', 'META_NAME' => $name, 'META_VERSION' => isset($meta['version']) ? $meta['version'] : '0.0.0', 'U_DELETE' => objects::$u_action . '&action=delete_ext&ext_name=' . urlencode($name), 'U_EXT_NAME' => $name); } } uasort($available_extension_meta_data, array('self', 'sort_extension_meta_data_table')); foreach ($available_extension_meta_data as $name => $block_vars) { if (!$block_vars['IS_BROKEN']) { $block_vars['U_DETAILS'] = objects::$u_action . '&action=details&ext_name=' . urlencode($name); } objects::$template->assign_block_vars('disabled', $block_vars); self::output_actions('disabled', array('ENABLE' => objects::$u_action . '&action=enable_pre&ext_name=' . urlencode($name))); } }
/** * Get the list of enabled phpBB extensions * * Used in EVENT node * * @return array */ public function get_phpbb_extensions() { return $this->extension_manager ? $this->extension_manager->all_enabled() : array(); }
/** * Get image paths/names from ABBC3's icons folder * * @return Array of file data from ./ext/vse/abbc3/images/icons * @access protected */ protected function get_images() { $finder = $this->extension_manager->get_finder(); return $finder->extension_suffix('.gif')->extension_directory('/images/icons')->find_from_extension('abbc3', $this->root_path . $this->ext_root_path); }
/** * {@inheritdoc} */ public function run() { $finder = $this->extension_manager->get_finder(); $migrations = $finder->core_path('phpbb/db/migration/data/')->get_classes(); $this->migrator->populate_migrations($migrations); }
/** * Populate migrations for the installation * * This "installs" all migrations from (root path)/phpbb/db/migrations/data. * "installs" means it adds all migrations to the migrations table, but does not * perform any of the actions in the migrations. * * @param \phpbb\extension\manager $extension_manager * @param \phpbb\db\migrator $migrator */ function populate_migrations($extension_manager, $migrator) { $finder = $extension_manager->get_finder(); $migrations = $finder->core_path('phpbb/db/migration/data/')->get_classes(); $migrator->populate_migrations($migrations); }