From 80840a5f08c530d91f147c1bded1c316c2a73d0f Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 7 Jan 2012 20:51:03 +0100 Subject: [PATCH 001/335] [feature/event-dispatcher] Introduce a port of Symfony2 EventDispatcher PHPBB3-9550 --- phpBB/includes/event/dispatcher.php | 185 ++++++++++++++++++ phpBB/includes/event/dispatcher_interface.php | 96 +++++++++ phpBB/includes/event/event.php | 123 ++++++++++++ phpBB/includes/event/subscriber_interface.php | 50 +++++ 4 files changed, 454 insertions(+) create mode 100644 phpBB/includes/event/dispatcher.php create mode 100644 phpBB/includes/event/dispatcher_interface.php create mode 100644 phpBB/includes/event/event.php create mode 100644 phpBB/includes/event/subscriber_interface.php diff --git a/phpBB/includes/event/dispatcher.php b/phpBB/includes/event/dispatcher.php new file mode 100644 index 0000000000..c3b8dc5790 --- /dev/null +++ b/phpBB/includes/event/dispatcher.php @@ -0,0 +1,185 @@ + + * @author Jonathan Wage + * @author Roman Borschel + * @author Bernhard Schussek + * @author Fabien Potencier + * @author Jordi Boggiano + * @author Jordan Alliot + */ +class phpbb_event_dispatcher +{ + private $listeners = array(); + private $sorted = array(); + + /** + * @see EventDispatcherInterface::dispatch + * + * @api + */ + public function dispatch($event_name, phpbb_event $event = null) + { + if (!isset($this->listeners[$event_name])) { + return; + } + + if (null === $event) { + $event = new phpbb_event(); + } + + $event->set_dispatcher($this); + $event->set_name($event_name); + + $this->do_dispatch($this->get_listeners($event_name), $event_name, $event); + } + + /** + * @see EventDispatcherInterface::get_listeners + */ + public function get_listeners($event_name = null) + { + if (null !== $event_name) { + if (!isset($this->sorted[$event_name])) { + $this->sort_listeners($event_name); + } + + return $this->sorted[$event_name]; + } + + foreach (array_keys($this->listeners) as $event_name) { + if (!isset($this->sorted[$event_name])) { + $this->sort_listeners($event_name); + } + } + + return $this->sorted; + } + + /** + * @see EventDispatcherInterface::has_listeners + */ + public function has_listeners($event_name = null) + { + return (Boolean) count($this->get_listeners($event_name)); + } + + /** + * @see EventDispatcherInterface::add_listener + * + * @api + */ + public function add_listener($event_name, $listener, $priority = 0) + { + $this->listeners[$event_name][$priority][] = $listener; + unset($this->sorted[$event_name]); + } + + /** + * @see EventDispatcherInterface::remove_listener + */ + public function remove_listener($event_name, $listener) + { + if (!isset($this->listeners[$event_name])) { + return; + } + + foreach ($this->listeners[$event_name] as $priority => $listeners) { + if (false !== ($key = array_search($listener, $listeners))) { + unset($this->listeners[$event_name][$priority][$key], $this->sorted[$event_name]); + } + } + } + + /** + * @see EventDispatcherInterface::add_subscriber + * + * @api + */ + public function add_subscriber(phpbb_event_subscriber_interface $subscriber) + { + foreach ($subscriber->get_subscribed_events() as $event_name => $params) { + if (is_string($params)) { + $this->add_listener($event_name, array($subscriber, $params)); + } elseif (is_string($params[0])) { + $this->add_listener($event_name, array($subscriber, $params[0]), $params[1]); + } else { + foreach ($params as $listener) { + $this->add_listener($event_name, array($subscriber, $listener[0]), isset($listener[1]) ? $listener[1] : 0); + } + } + } + } + + /** + * @see EventDispatcherInterface::remove_subscriber + */ + public function remove_subscriber(phpbb_event_subscriber_interface $subscriber) + { + foreach ($subscriber->get_subscribed_events() as $event_name => $params) { + if (is_array($params) && is_array($params[0])) { + foreach ($params as $listener) { + $this->remove_listener($event_name, array($subscriber, $listener[0])); + } + } else { + $this->remove_listener($event_name, array($subscriber, is_string($params) ? $params : $params[0])); + } + } + } + + /** + * Triggers the listeners of an event. + * + * This method can be overridden to add functionality that is executed + * for each listener. + * + * @param array[callback] $listeners The event listeners. + * @param string $event_name The name of the event to dispatch. + * @param Event $event The event object to pass to the event handlers/listeners. + */ + protected function do_dispatch($listeners, $event_name, phpbb_event $event) + { + foreach ($listeners as $listener) { + call_user_func($listener, $event); + if ($event->is_propagation_stopped()) { + break; + } + } + } + + /** + * Sorts the internal list of listeners for the given event by priority. + * + * @param string $event_name The name of the event. + */ + private function sort_listeners($event_name) + { + $this->sorted[$event_name] = array(); + + if (isset($this->listeners[$event_name])) { + krsort($this->listeners[$event_name]); + $this->sorted[$event_name] = call_user_func_array('array_merge', $this->listeners[$event_name]); + } + } +} diff --git a/phpBB/includes/event/dispatcher_interface.php b/phpBB/includes/event/dispatcher_interface.php new file mode 100644 index 0000000000..2564591ed7 --- /dev/null +++ b/phpBB/includes/event/dispatcher_interface.php @@ -0,0 +1,96 @@ + + */ +interface phpbb_event_dispatcher_interface +{ + /** + * Dispatches an event to all registered listeners. + * + * @param string $event_name The name of the event to dispatch. The name of + * the event is the name of the method that is + * invoked on listeners. + * @param Event $event The event to pass to the event handlers/listeners. + * If not supplied, an empty Event instance is created. + * + * @api + */ + function dispatch($event_name, Event $event = null); + + /** + * Adds an event listener that listens on the specified events. + * + * @param string $event_name The event to listen on + * @param callable $listener The listener + * @param integer $priority The higher this value, the earlier an event + * listener will be triggered in the chain (defaults to 0) + * + * @api + */ + function add_listener($event_name, $listener, $priority = 0); + + /** + * Adds an event subscriber. The subscriber is asked for all the events he is + * interested in and added as a listener for these events. + * + * @param EventSubscriberInterface $subscriber The subscriber. + * + * @api + */ + function add_subscriber(phpbb_event_subscriber_interface $subscriber); + + /** + * Removes an event listener from the specified events. + * + * @param string|array $event_name The event(s) to remove a listener from. + * @param object $listener The listener object to remove. + */ + function remove_listener($event_name, $listener); + + /** + * Removes an event subscriber. + * + * @param EventSubscriberInterface $subscriber The subscriber. + */ + function remove_subscriber(phpbb_event_subscriber_interface $subscriber); + + /** + * Gets the listeners of a specific event or all listeners. + * + * @param string $event_name The name of the event. + * + * @return array The event listeners for the specified event, or all event + * listeners by event name. + */ + function get_listeners($event_name = null); + + /** + * Checks whether an event has any registered listeners. + * + * @param string $event_name The name of the event. + * + * @return Boolean TRUE if the specified event has any listeners, FALSE + * otherwise. + */ + function has_listeners($event_name = null); +} diff --git a/phpBB/includes/event/event.php b/phpBB/includes/event/event.php new file mode 100644 index 0000000000..f74370618b --- /dev/null +++ b/phpBB/includes/event/event.php @@ -0,0 +1,123 @@ + + * @author Jonathan Wage + * @author Roman Borschel + * @author Bernhard Schussek + */ +class phpbb_event +{ + /** + * @var Boolean Whether no further event listeners should be triggered + */ + private $propagation_stopped = false; + + /** + * @var EventDispatcher Dispatcher that dispatched this event + */ + private $dispatcher; + + /** + * @var string This event's name + */ + private $name; + + /** + * Returns whether further event listeners should be triggered. + * + * @see Event::stop_propagation + * @return Boolean Whether propagation was already stopped for this event. + * + * @api + */ + public function is_propagation_stopped() + { + return $this->propagation_stopped; + } + + /** + * Stops the propagation of the event to further event listeners. + * + * If multiple event listeners are connected to the same event, no + * further event listener will be triggered once any trigger calls + * stop_propagation(). + * + * @api + */ + public function stop_propagation() + { + $this->propagation_stopped = true; + } + + /** + * Stores the EventDispatcher that dispatches this Event + * + * @param EventDispatcher $dispatcher + * + * @api + */ + public function set_dispatcher(phpbb_event_dispatcher $dispatcher) + { + $this->dispatcher = $dispatcher; + } + + /** + * Returns the EventDispatcher that dispatches this Event + * + * @return EventDispatcher + * + * @api + */ + public function get_dispatcher() + { + return $this->dispatcher; + } + + /** + * Gets the event's name. + * + * @return string + * + * @api + */ + public function get_name() + { + return $this->name; + } + + /** + * Sets the event's name property. + * + * @param string $name The event name. + * + * @api + */ + public function set_name($name) + { + $this->name = $name; + } +} diff --git a/phpBB/includes/event/subscriber_interface.php b/phpBB/includes/event/subscriber_interface.php new file mode 100644 index 0000000000..4e7b23f596 --- /dev/null +++ b/phpBB/includes/event/subscriber_interface.php @@ -0,0 +1,50 @@ + + * @author Jonathan Wage + * @author Roman Borschel + * @author Bernhard Schussek + */ +interface phpbb_event_subscriber_interface +{ + /** + * Returns an array of event names this subscriber wants to listen to. + * + * The array keys are event names and the value can be: + * + * * The method name to call (priority defaults to 0) + * * An array composed of the method name to call and the priority + * * An array of arrays composed of the method names to call and respective + * priorities, or 0 if unset + * + * For instance: + * + * * array('event_name' => 'method_name') + * * array('event_name' => array('method_name', $priority)) + * * array('event_name' => array(array('method_name1', $priority), array('method_name2')) + * + * @return array The event names to listen to + */ + static function get_subscribed_events(); +} From 581b5624f7be3675a35fc61ca6b67b409ae6e8c6 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 7 Jan 2012 20:53:04 +0100 Subject: [PATCH 002/335] [feature/event-dispatcher] Allow subscribers to be loaded from extensions PHPBB3-9550 --- phpBB/common.php | 4 ++ .../event/extension_subscriber_loader.php | 43 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 phpBB/includes/event/extension_subscriber_loader.php diff --git a/phpBB/common.php b/phpBB/common.php index b308037a0e..44a0e7cec3 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -98,6 +98,7 @@ $phpbb_class_loader_ext->set_cache($cache->get_driver()); $phpbb_class_loader->set_cache($cache->get_driver()); // Instantiate some basic classes +$phpbb_dispatcher = new phpbb_event_dispatcher(); $request = new phpbb_request(); $user = new user(); $auth = new auth(); @@ -124,6 +125,9 @@ $phpbb_template_locator = new phpbb_template_locator(); $phpbb_template_path_provider = new phpbb_template_extension_path_provider($phpbb_extension_manager, new phpbb_template_path_provider()); $template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_template_locator, $phpbb_template_path_provider); +$phpbb_subscriber_loader = new phpbb_event_extension_subscriber_loader($phpbb_dispatcher, $phpbb_extension_manager); +$phpbb_subscriber_loader->load(); + // Add own hook handler require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display'))); diff --git a/phpBB/includes/event/extension_subscriber_loader.php b/phpBB/includes/event/extension_subscriber_loader.php new file mode 100644 index 0000000000..2a53af1249 --- /dev/null +++ b/phpBB/includes/event/extension_subscriber_loader.php @@ -0,0 +1,43 @@ +dispatcher = $dispatcher; + $this->extension_manager = $extension_manager; + } + + public function load() + { + $finder = $this->extension_manager->get_finder(); + $subscriber_classes = $finder + ->extension_directory('/event') + ->suffix('subscriber') + ->core_path('event/') + ->get_classes(); + + foreach ($subscriber_classes as $class) { + $subscriber = new $class(); + $this->dispatcher->add_subscriber($subscriber); + } + } +} From 58a99c97cadd6a16b138e4de4f8fd1aa172e4eed Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 7 Jan 2012 20:54:01 +0100 Subject: [PATCH 003/335] [feature/event-dispatcher] Add a sample hook in page_header PHPBB3-9550 --- phpBB/includes/functions.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 753795b7cf..03376bf906 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4461,6 +4461,7 @@ function phpbb_http_login($param) function page_header($page_title = '', $display_online_list = true, $item_id = 0, $item = 'forum') { global $db, $config, $template, $SID, $_SID, $_EXTRA_URL, $user, $auth, $phpEx, $phpbb_root_path; + global $phpbb_dispatcher; if (defined('HEADER_INC')) { @@ -4744,6 +4745,9 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'A_COOKIE_SETTINGS' => addslashes('; path=' . $config['cookie_path'] . ((!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1') ? '' : '; domain=' . $config['cookie_domain']) . ((!$config['cookie_secure']) ? '' : '; secure')), )); + $event = new phpbb_event(); + $phpbb_dispatcher->dispatch('page_header', $event); + // application/xhtml+xml not used because of IE header('Content-type: text/html; charset=UTF-8'); From 03be9761375a082c2a43aceaa1b34661f87d702b Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 7 Jan 2012 21:42:19 +0100 Subject: [PATCH 004/335] [feature/event-dispatcher] Support setting data on an event PHPBB3-9550 --- phpBB/includes/event/data.php | 56 +++++++++++++++++++++++++++++++++++ phpBB/includes/functions.php | 3 +- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 phpBB/includes/event/data.php diff --git a/phpBB/includes/event/data.php b/phpBB/includes/event/data.php new file mode 100644 index 0000000000..754876c119 --- /dev/null +++ b/phpBB/includes/event/data.php @@ -0,0 +1,56 @@ +set_data($data); + } + + public function set_data(array $data = array()) + { + $this->data = $data; + } + + public function get_data() + { + return $this->data; + } + + public function offsetExists($offset) + { + return isset($this->data[$offset]); + } + + public function offsetGet($offset) + { + return isset($this->data[$offset]) ? $this->data[$offset] : null; + } + + public function offsetSet($offset, $value) + { + $this->data[$offset] = $value; + } + + public function offsetUnset($offset) + { + unset($this->data[$offset]); + } +} diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 03376bf906..109f5b0366 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4745,7 +4745,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'A_COOKIE_SETTINGS' => addslashes('; path=' . $config['cookie_path'] . ((!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1') ? '' : '; domain=' . $config['cookie_domain']) . ((!$config['cookie_secure']) ? '' : '; secure')), )); - $event = new phpbb_event(); + $event = new phpbb_event_data(); + $event->set_data(compact('page_title', 'display_online_list', 'item_id', 'item')); $phpbb_dispatcher->dispatch('page_header', $event); // application/xhtml+xml not used because of IE From 80f6f2b96f1ef0c3a3bf5637cac85a3c1fa229db Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 7 Jan 2012 21:50:16 +0100 Subject: [PATCH 005/335] [feature/event-dispatcher] Prefix event name with 'core.' PHPBB3-9550 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 109f5b0366..45958d1a0d 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4747,7 +4747,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 $event = new phpbb_event_data(); $event->set_data(compact('page_title', 'display_online_list', 'item_id', 'item')); - $phpbb_dispatcher->dispatch('page_header', $event); + $phpbb_dispatcher->dispatch('core.page_header', $event); // application/xhtml+xml not used because of IE header('Content-type: text/html; charset=UTF-8'); From 82422968796188d4284d7cba0f837ee8f333bf11 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 8 Jan 2012 00:48:21 +0100 Subject: [PATCH 006/335] [feature/event-dispatcher] Fix event class name in dispatcher interface PHPBB3-9550 --- phpBB/includes/event/dispatcher_interface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/event/dispatcher_interface.php b/phpBB/includes/event/dispatcher_interface.php index 2564591ed7..0a4881b3ba 100644 --- a/phpBB/includes/event/dispatcher_interface.php +++ b/phpBB/includes/event/dispatcher_interface.php @@ -35,7 +35,7 @@ interface phpbb_event_dispatcher_interface * * @api */ - function dispatch($event_name, Event $event = null); + function dispatch($event_name, phpbb_event $event = null); /** * Adds an event listener that listens on the specified events. From 71c5eddb7194f25711bc0733a54f09bf2f0c7c06 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 8 Jan 2012 01:01:11 +0100 Subject: [PATCH 007/335] [feature/event-dispatcher] Add Symfony2 to AUTHORS PHPBB3-9550 --- phpBB/docs/AUTHORS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/phpBB/docs/AUTHORS b/phpBB/docs/AUTHORS index 4fe0af6e28..8be261706e 100644 --- a/phpBB/docs/AUTHORS +++ b/phpBB/docs/AUTHORS @@ -79,3 +79,6 @@ Pear (c) 2001-2004 PHP Group, http://pear.php.net Text_Diff-0.2.1 http://pear.php.net/package/Text_Diff +MIT licenced: +Symfony2 (c) 2004-2011 Fabien Potencier, http://symfony.com/ + From 4c62dcd0ffc36a1c4bea203d7dcabbdd1f6143a3 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 8 Jan 2012 13:20:44 +0100 Subject: [PATCH 008/335] [feature/event-dispatcher] Correct copyright statement for Symfony2 files Also add a notice to the files that were taken from Symfony2. PHPBB3-9550 --- phpBB/includes/event/dispatcher.php | 7 ++++++- phpBB/includes/event/dispatcher_interface.php | 7 ++++++- phpBB/includes/event/event.php | 7 ++++++- phpBB/includes/event/subscriber_interface.php | 7 ++++++- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/event/dispatcher.php b/phpBB/includes/event/dispatcher.php index c3b8dc5790..6f7d61c83b 100644 --- a/phpBB/includes/event/dispatcher.php +++ b/phpBB/includes/event/dispatcher.php @@ -2,7 +2,7 @@ /** * * @package phpBB3 -* @copyright (c) 2011 phpBB Group +* @copyright (c) Fabien Potencier * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -15,6 +15,11 @@ if (!defined('IN_PHPBB')) exit; } +/** + * This file has been taken from Symfony2 and adjusted for + * phpBB's coding standards. + */ + /** * The EventDispatcherInterface is the central point of Symfony's event listener system. * diff --git a/phpBB/includes/event/dispatcher_interface.php b/phpBB/includes/event/dispatcher_interface.php index 0a4881b3ba..37e6bd4cf1 100644 --- a/phpBB/includes/event/dispatcher_interface.php +++ b/phpBB/includes/event/dispatcher_interface.php @@ -2,7 +2,7 @@ /** * * @package phpBB3 -* @copyright (c) 2011 phpBB Group +* @copyright (c) Fabien Potencier * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -15,6 +15,11 @@ if (!defined('IN_PHPBB')) exit; } +/** + * This file has been taken from Symfony2 and adjusted for + * phpBB's coding standards. + */ + /** * The EventDispatcherInterface is the central point of Symfony's event listener system. * Listeners are registered on the manager and events are dispatched through the diff --git a/phpBB/includes/event/event.php b/phpBB/includes/event/event.php index f74370618b..6ee144bc68 100644 --- a/phpBB/includes/event/event.php +++ b/phpBB/includes/event/event.php @@ -2,7 +2,7 @@ /** * * @package phpBB3 -* @copyright (c) 2011 phpBB Group +* @copyright (c) Fabien Potencier * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -15,6 +15,11 @@ if (!defined('IN_PHPBB')) exit; } +/** + * This file has been taken from Symfony2 and adjusted for + * phpBB's coding standards. + */ + /** * Event is the base class for classes containing event data. * diff --git a/phpBB/includes/event/subscriber_interface.php b/phpBB/includes/event/subscriber_interface.php index 4e7b23f596..081d4f0210 100644 --- a/phpBB/includes/event/subscriber_interface.php +++ b/phpBB/includes/event/subscriber_interface.php @@ -2,7 +2,7 @@ /** * * @package phpBB3 -* @copyright (c) 2011 phpBB Group +* @copyright (c) Fabien Potencier * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ @@ -15,6 +15,11 @@ if (!defined('IN_PHPBB')) exit; } +/** + * This file has been taken from Symfony2 and adjusted for + * phpBB's coding standards. + */ + /** * An EventSubscriber knows himself what events he is interested in. * If an EventSubscriber is added to an EventDispatcherInterface, the manager invokes From 246be1cb08dff57899fdafaf0ccfb3cd1913d1f5 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 5 Feb 2012 14:09:28 +0200 Subject: [PATCH 009/335] [feature/prosilver-cleanup/css-reset-v2] CSS reset Adding proper CSS reset to prosilver PHPBB3-10617 --- phpBB/styles/prosilver/theme/common.css | 81 +++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 4 deletions(-) diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index 8b5e09297e..9dce127d66 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -1,12 +1,51 @@ -/* General Markup Styles +/* CSS Reset http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 ---------------------------------------- */ - -* { - /* Reset browsers default margin, padding and font sizes */ +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, embed, +figure, figcaption, footer, header, hgroup, +menu, nav, output, ruby, section, summary, +time, mark, audio, video { margin: 0; padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} +/* HTML5 display-role reset for older browsers */ +article, aside, details, figcaption, figure, +footer, header, hgroup, menu, nav, section { + display: block; +} +body { + line-height: 1; +} +ol, ul { + list-style: none; +} +blockquote, q { + quotes: none; +} +blockquote:before, blockquote:after, +q:before, q:after { + content: ''; + content: none; +} +table { + border-collapse: collapse; + border-spacing: 0; } +/* General Markup Styles +---------------------------------------- */ html { font-size: 100%; /* Always show a scrollbar for short pages - stops the jump when the scrollbar appears. non-IE browsers */ @@ -20,6 +59,7 @@ body { background-color: #FFFFFF; /*font-size: 62.5%; This sets the default font size to be equivalent to 10px */ font-size: 10px; + line-height: normal; margin: 0; padding: 12px 0; } @@ -99,6 +139,39 @@ p.right { text-align: right; } +b, strong { + font-weight: bold; +} + +i, em { + font-style: italic; +} + +u { + text-decoration: underline; +} + +ul { + list-style-type: disc; +} + +ol { + list-style-type: decimal; +} + +li { + display: list-item; +} + +ul ul, ol ul { + list-style-type: circle; +} + +ol ol ul, ol ul ul, ul ol ul, ul ul ul { + list-style-type: square; +} + + /* Main blocks ---------------------------------------- */ #wrap { From f17449e5ffb87c4a63e6c27c52036c5812f970d7 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 4 Feb 2012 11:11:48 +0200 Subject: [PATCH 010/335] [feature/prosilver-cleanup/duplicate-colors] Removing duplicate colors Removing color values from files other than colours.css PHPBB3-10619 --- phpBB/styles/prosilver/theme/colours.css | 14 ++- phpBB/styles/prosilver/theme/common.css | 100 +++--------------- phpBB/styles/prosilver/theme/content.css | 128 ++++------------------- phpBB/styles/prosilver/theme/cp.css | 100 +++--------------- phpBB/styles/prosilver/theme/forms.css | 48 ++------- phpBB/styles/prosilver/theme/links.css | 55 +++------- 6 files changed, 80 insertions(+), 365 deletions(-) diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css index 7bc66f4e7d..f6826f8056 100644 --- a/phpBB/styles/prosilver/theme/colours.css +++ b/phpBB/styles/prosilver/theme/colours.css @@ -26,10 +26,6 @@ hr { border-top-color: #CCCCCC; } -hr.dashed { - border-top-color: #CCCCCC; -} - /* Search box --------------------------------------------- */ @@ -452,6 +448,10 @@ dl.faq dt { color: #BC2A4D; } +.announce, .unreadpost { + /* Highlight the announcements & unread posts box */ +} + /* Post signature */ .signature { border-top-color: #CCCCCC; @@ -963,7 +963,7 @@ dl.mini dt { /* Avatar gallery */ #gallery label { - background-color: #FFFFFF; + background: #FFFFFF; border-color: #CCC; } @@ -998,6 +998,10 @@ dd label { color: #333; } +fieldset.fields1 { + background-color: transparent; +} + /* Hover effects */ fieldset dl:hover dt label { color: #000000; diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index 8b5e09297e..f59728447f 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -16,8 +16,6 @@ html { body { /* Text-Sizing with ems: http://www.clagnut.com/blog/348/ */ font-family: Verdana, Helvetica, Arial, sans-serif; - color: #828282; - background-color: #FFFFFF; /*font-size: 62.5%; This sets the default font size to be equivalent to 10px */ font-size: 10px; margin: 0; @@ -28,7 +26,6 @@ h1 { /* Forum name */ font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; margin-right: 200px; - color: #FFFFFF; margin-top: 15px; font-weight: bold; font-size: 2em; @@ -38,7 +35,6 @@ h2 { /* Forum header titles */ font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-weight: normal; - color: #3f3f3f; font-size: 2em; margin: 0.8em 0 0.2em 0; } @@ -52,11 +48,10 @@ h3 { font-family: Arial, Helvetica, sans-serif; font-weight: bold; text-transform: uppercase; - border-bottom: 1px solid #CCCCCC; + border-bottom: 1px solid transparent; margin-bottom: 3px; padding-bottom: 2px; font-size: 1.05em; - color: #989898; margin-top: 20px; } @@ -78,8 +73,8 @@ img { hr { /* Also see tweaks.css */ - border: 0 none #FFFFFF; - border-top: 1px solid #CCCCCC; + border: 0 solid transparent; + border-top-width: 1px; height: 1px; margin: 5px 0; display: block; @@ -87,7 +82,7 @@ hr { } hr.dashed { - border-top: 1px dashed #CCCCCC; + border-top-style: dashed; margin: 10px 0; } @@ -136,7 +131,6 @@ a#logo:hover { /* Search box --------------------------------------------- */ #search-box { - color: #FFFFFF; position: relative; margin-top: 30px; margin-right: 5px; @@ -148,11 +142,10 @@ a#logo:hover { #search-box #keywords { width: 95px; - background-color: #FFF; } #search-box input { - border: 1px solid #b0b0b0; + border: 1px solid transparent; } /* .button1 style defined later, just a few tweaks for the search button version */ @@ -183,26 +176,24 @@ a#logo:hover { /* Round cornered boxes and backgrounds ---------------------------------------- */ .headerbar { - background: #ebebeb none repeat-x 0 0; - color: #FFFFFF; + background: transparent none repeat-x 0 0; margin-bottom: 4px; padding: 0 5px; } .navbar { - background-color: #ebebeb; padding: 0 10px; } .forabg { - background: #b1b1b1 none repeat-x 0 0; + background: transparent none repeat-x 0 0; margin-bottom: 4px; padding: 0 5px; clear: both; } .forumbg { - background: #ebebeb none repeat-x 0 0; + background: transparent none repeat-x 0 0; margin-bottom: 4px; padding: 0 5px; clear: both; @@ -211,8 +202,6 @@ a#logo:hover { .panel { margin-bottom: 4px; padding: 0 10px; - background-color: #f3f3f3; - color: #3f3f3f; } .post { @@ -222,31 +211,10 @@ a#logo:hover { background-position: 100% 0; } -.post:target .content { - color: #000000; -} - -.post:target h3 a { - color: #000000; -} - -.bg1 { background-color: #f7f7f7;} -.bg2 { background-color: #f2f2f2; } -.bg3 { background-color: #ebebeb; } - .rowbg { margin: 5px 5px 2px 5px; } -.ucprowbg { - background-color: #e2e2e2; -} - -.fieldsbg { - /*border: 1px #DBDEE2 solid;*/ - background-color: #eaeaea; -} - span.corners-top, span.corners-bottom, span.corners-top span, span.corners-bottom span { font-size: 1px; line-height: 1px; @@ -321,7 +289,7 @@ ul.linklist li.rightside, p.rightside { ul.navlinks { padding-bottom: 1px; margin-bottom: 1px; - border-bottom: 1px solid #FFFFFF; + border-bottom: 1px solid transparent; font-weight: bold; } @@ -352,7 +320,6 @@ table.table1 { table.table1 thead th { font-weight: normal; text-transform: uppercase; - color: #FFFFFF; line-height: 1.3em; font-size: 1em; padding: 0 0 4px 3px; @@ -363,30 +330,22 @@ table.table1 thead th span { } table.table1 tbody tr { - border: 1px solid #cfcfcf; -} - -table.table1 tbody tr:hover, table.table1 tbody tr.hover { - background-color: #f6f6f6; - color: #000; + border: 1px solid transparent; } table.table1 td { - color: #6a6a6a; font-size: 1.1em; } table.table1 tbody td { padding: 5px; - border-top: 1px solid #FAFAFA; + border-top: 1px solid transparent; } table.table1 tbody th { padding: 5px; - border-bottom: 1px solid #000000; + border-bottom: 1px solid transparent; text-align: left; - color: #333333; - background-color: #FFFFFF; } /* Specific column styles */ @@ -413,7 +372,6 @@ table.info tbody th { padding: 3px; text-align: right; vertical-align: top; - color: #000000; font-weight: normal; } @@ -460,7 +418,6 @@ dl.details dt { clear: left; width: 30%; text-align: right; - color: #000000; display: block; } @@ -468,7 +425,6 @@ dl.details dd { margin-left: 0; padding-left: 5px; margin-bottom: 5px; - color: #828282; float: left; width: 65%; } @@ -499,28 +455,21 @@ li.pagination { padding: 0 2px; margin: 0 2px; font-weight: normal; - color: #FFFFFF; - background-color: #bfbfbf; - border: 1px solid #bfbfbf; + border: 1px solid transparent; font-size: 0.9em; } .pagination span a, .pagination span a:link, .pagination span a:visited, .pagination span a:active { font-weight: normal; text-decoration: none; - color: #747474; margin: 0 2px; padding: 0 2px; - background-color: #eeeeee; - border: 1px solid #bababa; + border: 1px solid transparent; font-size: 0.9em; line-height: 1.5em; } .pagination span a:hover { - border-color: #d2d2d2; - background-color: #d2d2d2; - color: #FFF; text-decoration: none; } @@ -539,14 +488,6 @@ li.pagination { background: none 0 50% no-repeat; } -.row .pagination span a, li.pagination span a { - background-color: #FFFFFF; -} - -.row .pagination span a:hover, li.pagination span a:hover { - background-color: #d2d2d2; -} - /* Miscellaneous styles ---------------------------------------- */ #forum-permissions { @@ -561,7 +502,6 @@ li.pagination { .copyright { padding: 5px; text-align: center; - color: #555555; } .small { @@ -577,22 +517,11 @@ li.pagination { } .error { - color: #bcbcbc; font-weight: bold; font-size: 1em; } -.reported { - background-color: #f7f7f7; -} - -li.reported:hover { - background-color: #ececec; -} - div.rules { - background-color: #ececec; - color: #bcbcbc; padding: 0 10px; margin: 10px 0; font-size: 1.1em; @@ -603,7 +532,6 @@ div.rules ul, div.rules ol { } p.rules { - background-color: #ececec; background-image: none; padding: 5px; } diff --git a/phpBB/styles/prosilver/theme/content.css b/phpBB/styles/prosilver/theme/content.css index adf5f2ca2a..b0872f78aa 100644 --- a/phpBB/styles/prosilver/theme/content.css +++ b/phpBB/styles/prosilver/theme/content.css @@ -8,13 +8,12 @@ ul.topiclist { } ul.forums { - background: #f9f9f9 none repeat-x 0 0; + background: transparent none repeat-x 0 0; } ul.topiclist li { display: block; list-style-type: none; - color: #777777; margin: 0; } @@ -38,7 +37,7 @@ ul.topiclist dt { ul.topiclist dd { display: block; float: left; - border-left: 1px solid #FFFFFF; + border-left: 1px solid transparent; padding: 4px 0; } @@ -65,28 +64,18 @@ ul.topiclist li.row dt a.subforum { } li.row { - border-top: 1px solid #FFFFFF; - border-bottom: 1px solid #8f8f8f; + border-top: 1px solid transparent; + border-bottom: 1px solid transparent; } li.row strong { font-weight: normal; - color: #000000; -} - -li.row:hover { - background-color: #f6f6f6; -} - -li.row:hover dd { - border-left-color: #CCCCCC; } li.header dt, li.header dd { line-height: 1em; border-left-width: 0; margin: 2px 0 4px 0; - color: #FFFFFF; padding-top: 2px; padding-bottom: 2px; font-size: 1em; @@ -205,7 +194,6 @@ ul.topiclist dd.searchextra { margin-left: 5px; padding: 0.2em 0; font-size: 1.1em; - color: #333333; border-left: none; clear: both; width: 98%; @@ -228,7 +216,6 @@ div[class].topic-actions { .postbody { padding: 0; line-height: 1.48em; - color: #333333; width: 76%; float: left; clear: both; @@ -320,14 +307,12 @@ div[class].topic-actions { line-height: 1.4em; font-family: "Lucida Grande", "Trebuchet MS", Verdana, Helvetica, Arial, sans-serif; font-size: 1em; - color: #333333; padding-bottom: 1px; } .content h2, .panel h2 { font-weight: normal; - color: #989898; - border-bottom: 1px solid #CCCCCC; + border-bottom: 1px solid transparent; font-size: 1.6em; margin-top: 0.5em; margin-bottom: 0.5em; @@ -361,7 +346,6 @@ dl.faq { dl.faq dt { font-weight: bold; - color: #333333; } .content dl.faq { @@ -379,17 +363,9 @@ dl.faq dt { } .posthilit { - background-color: #f3f3f3; - color: #BCBCBC; padding: 0 2px 1px 2px; } -.announce, .unreadpost { - /* Highlight the announcements & unread posts box */ - border-left-color: #BCBCBC; - border-right-color: #BCBCBC; -} - /* Post author */ p.author { margin: 0 15em 0.6em 0; @@ -404,7 +380,7 @@ p.author { margin-top: 1.5em; padding-top: 0.2em; font-size: 1.1em; - border-top: 1px solid #CCCCCC; + border-top: 1px solid transparent; clear: left; line-height: 140%; overflow: hidden; @@ -434,7 +410,7 @@ dd .signature { margin-top: 1.5em; padding-top: 0.2em; font-size: 1em; - border-top: 1px dashed #CCCCCC; + border-top: 1px dashed transparent; clear: left; line-height: 130%; } @@ -450,8 +426,8 @@ ul.searchresults { ----------------------------------------*/ /* Quote block */ blockquote { - background: #ebebeb none 6px 8px no-repeat; - border: 1px solid #dbdbdb; + background: transparent none 6px 8px no-repeat; + border: 1px solid transparent; font-size: 0.95em; margin: 0.5em 1px 0 25px; overflow: hidden; @@ -460,16 +436,10 @@ blockquote { blockquote blockquote { /* Nested quotes */ - background-color: #bababa; font-size: 1em; margin: 0.5em 1px 0 15px; } -blockquote blockquote blockquote { - /* Nested quotes */ - background-color: #e4e4e4; -} - blockquote cite { /* Username/source of quoter */ font-style: normal; @@ -490,14 +460,13 @@ blockquote.uncited { /* Code block */ dl.codebox { padding: 3px; - background-color: #FFFFFF; - border: 1px solid #d8d8d8; + border: 1px solid transparent; font-size: 1em; } dl.codebox dt { text-transform: uppercase; - border-bottom: 1px solid #CCCCCC; + border-bottom: 1px solid transparent; margin-bottom: 3px; font-size: 0.8em; font-weight: bold; @@ -518,17 +487,9 @@ dl.codebox code { padding-top: 5px; font: 0.9em Monaco, "Andale Mono","Courier New", Courier, mono; line-height: 1.3em; - color: #8b8b8b; margin: 2px 0; } -.syntaxbg { color: #FFFFFF; } -.syntaxcomment { color: #000000; } -.syntaxdefault { color: #bcbcbc; } -.syntaxhtml { color: #000000; } -.syntaxkeyword { color: #585858; } -.syntaxstring { color: #a7a7a7; } - /* Attachments ----------------------------------------*/ .attachbox { @@ -536,15 +497,10 @@ dl.codebox code { width: auto; margin: 5px 5px 5px 0; padding: 6px; - background-color: #FFFFFF; - border: 1px dashed #d8d8d8; + border: 1px dashed transparent; clear: left; } -.pm-message .attachbox { - background-color: #f3f3f3; -} - .attachbox dt { font-family: Arial, Helvetica, sans-serif; text-transform: uppercase; @@ -554,7 +510,7 @@ dl.codebox code { margin-top: 4px; padding-top: 4px; clear: left; - border-top: 1px solid #d8d8d8; + border-top: 1px solid transparent; } .attachbox dd dd { @@ -563,7 +519,6 @@ dl.codebox code { .attachbox p { line-height: 110%; - color: #666666; font-weight: normal; clear: left; } @@ -571,7 +526,6 @@ dl.codebox code { .attachbox p.stats { line-height: 110%; - color: #666666; font-weight: normal; clear: left; } @@ -584,7 +538,7 @@ dl.codebox code { } .attach-image img { - border: 1px solid #999999; + border: 1px solid transparent; /* cursor: move; */ cursor: default; } @@ -613,19 +567,16 @@ dl.file dt { } dl.file dd { - color: #666666; margin: 0; padding: 0; } dl.thumbnail img { padding: 3px; - border: 1px solid #666666; - background-color: #FFF; + border: 1px solid transparent; } dl.thumbnail dd { - color: #666666; font-style: italic; font-family: Verdana, Arial, Helvetica, sans-serif; } @@ -634,12 +585,8 @@ dl.thumbnail dd { font-size: 100%; } -dl.thumbnail dt a:hover { - background-color: #EEEEEE; -} - dl.thumbnail dt a:hover img { - border: 1px solid #d2d2d2; + border: 1px solid transparent; } /* Post poll styles @@ -650,15 +597,13 @@ fieldset.polls { fieldset.polls dl { margin-top: 5px; - border-top: 1px solid #e2e2e2; + border-top: 1px solid transparent; padding: 5px 0 0 0; line-height: 120%; - color: #666666; } fieldset.polls dl.voted { font-weight: bold; - color: #000000; } fieldset.polls dt { @@ -692,41 +637,15 @@ fieldset.polls dd input { fieldset.polls dd div { text-align: right; font-family: Arial, Helvetica, sans-serif; - color: #FFFFFF; font-weight: bold; padding: 0 2px; overflow: visible; min-width: 2%; } -.pollbar1 { - background-color: #aaaaaa; - border-bottom: 1px solid #747474; - border-right: 1px solid #747474; -} - -.pollbar2 { - background-color: #bebebe; - border-bottom: 1px solid #8c8c8c; - border-right: 1px solid #8c8c8c; -} - -.pollbar3 { - background-color: #D1D1D1; - border-bottom: 1px solid #aaaaaa; - border-right: 1px solid #aaaaaa; -} - -.pollbar4 { - background-color: #e4e4e4; - border-bottom: 1px solid #bebebe; - border-right: 1px solid #bebebe; -} - -.pollbar5 { - background-color: #f8f8f8; - border-bottom: 1px solid #D1D1D1; - border-right: 1px solid #D1D1D1; +.pollbar1, .pollbar2, .pollbar3, .pollbar4, .pollbar5 { + border-bottom: 1px solid transparent; + border-right: 1px solid transparent; } /* Poster profile block @@ -735,15 +654,11 @@ fieldset.polls dd div { /* Also see tweaks.css */ margin: 5px 0 10px 0; min-height: 80px; - color: #666666; - border-left: 1px solid #FFFFFF; + border-left: 1px solid transparent; width: 22%; float: right; display: inline; } -.pm .postprofile { - border-left: 1px solid #DDDDDD; -} .postprofile dd, .postprofile dt { line-height: 1.2em; @@ -752,7 +667,6 @@ fieldset.polls dd div { .postprofile strong { font-weight: normal; - color: #000000; } .avatar { diff --git a/phpBB/styles/prosilver/theme/cp.css b/phpBB/styles/prosilver/theme/cp.css index 708bfbaf83..62e8513733 100644 --- a/phpBB/styles/prosilver/theme/cp.css +++ b/phpBB/styles/prosilver/theme/cp.css @@ -20,10 +20,6 @@ padding: 0; } -#cp-main h3, #cp-main hr, #cp-menu hr { - border-color: #bfbfbf; -} - #cp-main .panel p { font-size: 1.1em; } @@ -34,17 +30,16 @@ } #cp-main .panel li.row { - border-bottom: 1px solid #cbcbcb; - border-top: 1px solid #F9F9F9; + border-bottom: 1px solid transparent; + border-top: 1px solid transparent; } ul.cplist { margin-bottom: 5px; - border-top: 1px solid #cbcbcb; + border-top: 1px solid transparent; } #cp-main .panel li.header dd, #cp-main .panel li.header dt { - color: #000000; margin-bottom: 2px; } @@ -53,9 +48,8 @@ ul.cplist { } #cp-main table.table1 thead th { - color: #333333; font-weight: bold; - border-bottom: 1px solid #333333; + border-bottom: 1px solid transparent; padding: 5px; } @@ -76,9 +70,8 @@ ul.cplist { } #cp-main .pm-message { - border: 1px solid #e2e2e2; + border: 1px solid transparent; margin: 10px 0; - background-color: #FFFFFF; width: auto; float: none; } @@ -141,23 +134,17 @@ ul.cplist { display: block; background: none no-repeat 100% -35px; padding: 6px 10px 6px 5px; - color: #828282; white-space: nowrap; } -#tabs a:hover span { - color: #bcbcbc; -} - #tabs .activetab a { background-position: 0 0; - border-bottom: 1px solid #ebebeb; + border-bottom: 1px solid transparent; } #tabs .activetab a span { background-position: 100% 0; padding-bottom: 7px; - color: #333333; } #tabs a:hover { @@ -173,7 +160,6 @@ ul.cplist { } #tabs .activetab a:hover span { - color: #000000; background-position: 100% 0; } @@ -196,7 +182,6 @@ ul.cplist { padding: 0 10px 4px 10px; font-size: 1em; font-weight: bold; - background-color: #f2f2f2; margin-left: 2px; } @@ -207,14 +192,6 @@ ul.cplist { text-decoration: none; } -#minitabs li.activetab { - background-color: #F9F9F9; -} - -#minitabs li.activetab a, #minitabs li.activetab a:hover { - color: #333333; -} - /* UCP navigation menu ----------------------------------------*/ /* Container for sub-navigation list */ @@ -242,43 +219,25 @@ ul.cplist { margin: 1px 0; text-decoration: none; font-weight: bold; - color: #333; - background: #cfcfcf none repeat-y 100% 0; + background: transparent none repeat-y 100% 0; } #navigation a:hover { text-decoration: none; - background-color: #c6c6c6; - color: #bcbcbc; background-image: none; } #navigation #active-subsection a { display: block; - color: #d3d3d3; - background-color: #F9F9F9; background-image: none; } -#navigation #active-subsection a:hover { - color: #d3d3d3; -} - /* Preferences pane layout ----------------------------------------*/ #cp-main h2 { border-bottom: none; padding: 0; margin-left: 10px; - color: #333333; -} - -#cp-main .panel { - background-color: #F9F9F9; -} - -#cp-main .pm { - background-color: #FFFFFF; } #cp-main span.corners-top, #cp-menu span.corners-top { @@ -316,7 +275,6 @@ ul.cplist { /* Friends list */ .cp-mini { - background-color: #f9f9f9; padding: 0 5px; margin: 10px 15px 10px 5px; } @@ -327,7 +285,6 @@ ul.cplist { dl.mini dt { font-weight: bold; - color: #676767; } dl.mini dd { @@ -352,7 +309,7 @@ dl.mini dd { .pm-panel-header { margin: 0; padding-bottom: 10px; - border-bottom: 1px dashed #A4B3BF; + border-bottom: 1px dashed transparent; } .reply-all { @@ -373,12 +330,7 @@ dl.mini dd { #cp-main .pm-message-nav { margin: 0; padding: 2px 10px 5px 10px; - border-bottom: 1px dashed #A4B3BF; -} - -/* PM Message history */ -.current { - color: #999999; + border-bottom: 1px dashed transparent; } /* Defined rules list for PM options */ @@ -401,31 +353,16 @@ ol.def-rules li { } .pmlist li.pm_message_reported_colour, .pm_message_reported_colour { - border-left-color: #bcbcbc; - border-right-color: #bcbcbc; -} - -.pmlist li.pm_marked_colour, .pm_marked_colour { - padding: 0; - border: solid 3px #ffffff; - border-width: 0 3px; -} - -.pmlist li.pm_replied_colour, .pm_replied_colour { - padding: 0; - border: solid 3px #c2c2c2; - border-width: 0 3px; -} - -.pmlist li.pm_friend_colour, .pm_friend_colour { - padding: 0; - border: solid 3px #bdbdbd; - border-width: 0 3px; + border-left-color: transparent; + border-right-color: transparent; } +.pmlist li.pm_marked_colour, .pm_marked_colour, +.pmlist li.pm_replied_colour, .pm_replied_colour, +.pmlist li.pm_friend_colour, .pm_friend_colour, .pmlist li.pm_foe_colour, .pm_foe_colour { padding: 0; - border: solid 3px #000000; + border: solid 3px transparent; border-width: 0 3px; } @@ -444,11 +381,6 @@ ol.def-rules li { margin: 10px; padding: 5px; width: auto; - background: #FFFFFF; - border: 1px solid #CCC; + border: 1px solid transparent; text-align: center; } - -#gallery label:hover { - background-color: #EEE; -} diff --git a/phpBB/styles/prosilver/theme/forms.css b/phpBB/styles/prosilver/theme/forms.css index 43888733cc..a381ecc04c 100644 --- a/phpBB/styles/prosilver/theme/forms.css +++ b/phpBB/styles/prosilver/theme/forms.css @@ -23,9 +23,8 @@ select { font-weight: normal; cursor: pointer; vertical-align: middle; - border: 1px solid #666666; + border: 1px solid transparent; padding: 1px; - background-color: #FAFAFA; font-size: 1em; } @@ -33,10 +32,6 @@ option { padding-right: 1em; } -option.disabled-option { - color: graytext; -} - textarea { font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif; width: 60%; @@ -48,7 +43,6 @@ textarea { label { cursor: default; padding-right: 5px; - color: #676767; } label input { @@ -89,10 +83,6 @@ fieldset.fields1 dd { border-left-width: 0; } -fieldset.fields1 { - background-color: transparent; -} - fieldset.fields1 div { margin-bottom: 3px; } @@ -121,7 +111,6 @@ dt label { dd label { white-space: nowrap; - color: #333; } dd input, dd textarea { @@ -137,14 +126,6 @@ dd textarea { } /* Hover effects */ -fieldset dl:hover dt label { - color: #000000; -} - -fieldset.fields2 dl:hover dt label { - color: inherit; -} - #timezone { width: 95%; } @@ -166,7 +147,6 @@ fieldset.quick-login input.inputbox { width: 15%; vertical-align: middle; margin-right: 5px; - background-color: #f3f3f3; } fieldset.quick-login label { @@ -268,7 +248,6 @@ fieldset.submit-buttons input { min-width: 100%; max-width: 100%; font-size: 1.2em; - color: #333333; } /* Emoticons panel */ @@ -284,20 +263,13 @@ fieldset.submit-buttons input { /* Input field styles ---------------------------------------- */ .inputbox { - background-color: #FFFFFF; - border: 1px solid #c0c0c0; - color: #333333; + border: 1px solid transparent; padding: 2px; cursor: text; } -.inputbox:hover { - border: 1px solid #eaeaea; -} - -.inputbox:focus { - border: 1px solid #eaeaea; - color: #4b4b4b; +.inputbox:hover, .inputbox:focus { + border: 1px solid transparent; } input.inputbox { width: 85%; } @@ -324,13 +296,12 @@ a.button1, input.button1, input.button3, a.button2, input.button2 { padding-top: 1px; padding-bottom: 1px; font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif; - color: #000; - background: #FAFAFA none repeat-x top left; + background: transparent none repeat-x top left; } a.button1, input.button1 { font-weight: bold; - border: 1px solid #666666; + border: 1px solid transparent; } input.button3 { @@ -344,13 +315,12 @@ input.button3 { /* Alternative button */ a.button2, input.button2, input.button3 { - border: 1px solid #666666; + border: 1px solid transparent; } /* button in the style of the form buttons */ a.button1, a.button1:link, a.button1:visited, a.button1:active, a.button2, a.button2:link, a.button2:visited, a.button2:active { text-decoration: none; - color: #000000; padding: 2px 8px; line-height: 250%; vertical-align: text-bottom; @@ -359,14 +329,12 @@ a.button1, a.button1:link, a.button1:visited, a.button1:active, a.button2, a.but /* Hover states */ a.button1:hover, input.button1:hover, a.button2:hover, input.button2:hover, input.button3:hover { - border: 1px solid #BCBCBC; + border: 1px solid transparent; background-position: 0 100%; - color: #BCBCBC; } input.disabled { font-weight: normal; - color: #666666; } /* Topic and forum Search */ diff --git a/phpBB/styles/prosilver/theme/links.css b/phpBB/styles/prosilver/theme/links.css index c6a7cb4559..3cb6e928b5 100644 --- a/phpBB/styles/prosilver/theme/links.css +++ b/phpBB/styles/prosilver/theme/links.css @@ -7,10 +7,17 @@ a { unicode-bidi: embed; } -a:link { color: #898989; text-decoration: none; } -a:visited { color: #898989; text-decoration: none; } -a:hover { color: #d3d3d3; text-decoration: underline; } -a:active { color: #d2d2d2; text-decoration: none; } +a:link, a:visited { + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +a:active { + text-decoration: none; +} /* Coloured usernames */ .username-coloured { @@ -21,22 +28,18 @@ a:active { color: #d2d2d2; text-decoration: none; } /* Links on gradient backgrounds */ #search-box a:link, .navbg a:link, .forumbg .header a:link, .forabg .header a:link, th a:link { - color: #FFFFFF; text-decoration: none; } #search-box a:visited, .navbg a:visited, .forumbg .header a:visited, .forabg .header a:visited, th a:visited { - color: #FFFFFF; text-decoration: none; } #search-box a:hover, .navbg a:hover, .forumbg .header a:hover, .forabg .header a:hover, th a:hover { - color: #ffffff; text-decoration: underline; } #search-box a:active, .navbg a:active, .forumbg .header a:active, .forabg .header a:active, th a:active { - color: #ffffff; text-decoration: none; } @@ -45,96 +48,65 @@ a.forumtitle { font-family: "Trebuchet MS", Helvetica, Arial, Sans-serif; font-size: 1.2em; font-weight: bold; - color: #898989; text-decoration: none; } -/* a.forumtitle:visited { color: #898989; } */ - a.forumtitle:hover { - color: #bcbcbc; text-decoration: underline; } -a.forumtitle:active { - color: #898989; -} - a.topictitle { font-family: "Trebuchet MS", Helvetica, Arial, Sans-serif; font-size: 1.2em; font-weight: bold; - color: #898989; text-decoration: none; } -/* a.topictitle:visited { color: #d2d2d2; } */ - a.topictitle:hover { - color: #bcbcbc; text-decoration: underline; } -a.topictitle:active { - color: #898989; -} - /* Post body links */ .postlink { text-decoration: none; - color: #d2d2d2; - border-bottom: 1px solid #d2d2d2; + border-bottom: 1px solid transparent; padding-bottom: 0; } -/* .postlink:visited { color: #bdbdbd; } */ - -.postlink:active { - color: #d2d2d2; -} - .postlink:hover { - background-color: #f6f6f6; text-decoration: none; - color: #404040; } .signature a, .signature a:visited, .signature a:hover, .signature a:active { border: none; text-decoration: underline; - background-color: transparent; } /* Profile links */ .postprofile a:link, .postprofile a:visited, .postprofile dt.author a { font-weight: bold; - color: #898989; text-decoration: none; } .postprofile a:hover, .postprofile dt.author a:hover { text-decoration: underline; - color: #d3d3d3; } /* CSS spec requires a:link, a:visited, a:hover and a:active rules to be specified in this order. */ /* See http://www.phpbb.com/bugs/phpbb3/59685 */ .postprofile a:active { font-weight: bold; - color: #898989; text-decoration: none; } /* Profile searchresults */ .search .postprofile a { - color: #898989; text-decoration: none; font-weight: normal; } .search .postprofile a:hover { - color: #d3d3d3; text-decoration: underline; } @@ -177,7 +149,6 @@ a.up, a.up:link, a.up:active, a.up:visited { a.up:hover { background-position: left top; - background-color: transparent; } a.down, a.down:link, a.down:active, a.down:visited { @@ -194,7 +165,6 @@ a.left, a.left:active, a.left:visited { } a.left:hover { - color: #d2d2d2; text-decoration: none; background-position: 0 60%; } @@ -204,7 +174,6 @@ a.right, a.right:active, a.right:visited { } a.right:hover { - color: #d2d2d2; text-decoration: none; background-position: 100% 60%; } From 162f9b738aaa74684ea42e3ce4d6a911a183a996 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 18 Feb 2012 16:35:43 +0200 Subject: [PATCH 011/335] [feature/purge-cache] Allow all admins to purge cache Allow all administrators to purge cache PHPBB3-10659 --- phpBB/adm/style/acp_main.html | 3 ++- phpBB/includes/acp/acp_main.php | 5 ----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/phpBB/adm/style/acp_main.html b/phpBB/adm/style/acp_main.html index 11f7fedd38..63ca3a1c79 100644 --- a/phpBB/adm/style/acp_main.html +++ b/phpBB/adm/style/acp_main.html @@ -194,13 +194,14 @@
+ +

{L_PURGE_CACHE_EXPLAIN}
- diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index b30c294ce2..7cdf734973 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -330,11 +330,6 @@ class acp_main break; case 'purge_cache': - if ((int) $user->data['user_type'] !== USER_FOUNDER) - { - trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING); - } - global $cache; $cache->purge(); From 11c5a6621389af854170d3190432d3f414c77618 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sat, 18 Feb 2012 23:31:31 +0100 Subject: [PATCH 012/335] [ticket/10658] Use get_user_rank() for group ranks on group view. The old code was buggy because it did not prefix the path with the phpBB root path which causes problems with bridges and other URL rewriting. PHPBB3-10658 --- phpBB/memberlist.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index b3c0bae16a..cfa1631dbe 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1221,21 +1221,16 @@ switch ($mode) // Misusing the avatar function for displaying group avatars... $avatar_img = get_user_avatar($group_row['group_avatar'], $group_row['group_avatar_type'], $group_row['group_avatar_width'], $group_row['group_avatar_height'], 'GROUP_AVATAR'); + // ... same for group rank $rank_title = $rank_img = $rank_img_src = ''; if ($group_row['group_rank']) { - if (isset($ranks['special'][$group_row['group_rank']])) + get_user_rank($group_row['group_rank'], false, $rank_title, $rank_img, $rank_img_src); + + if ($rank_img) { - $rank_title = $ranks['special'][$group_row['group_rank']]['rank_title']; + $rank_img .= '
'; } - $rank_img = (!empty($ranks['special'][$group_row['group_rank']]['rank_image'])) ? '' . $ranks['special'][$group_row['group_rank']]['rank_title'] . '
' : ''; - $rank_img_src = (!empty($ranks['special'][$group_row['group_rank']]['rank_image'])) ? $config['ranks_path'] . '/' . $ranks['special'][$group_row['group_rank']]['rank_image'] : ''; - } - else - { - $rank_title = ''; - $rank_img = ''; - $rank_img_src = ''; } $template->assign_vars(array( From c5de658c7f15a6ab0028353684323c3ef21521c9 Mon Sep 17 00:00:00 2001 From: callumacrae Date: Fri, 2 Dec 2011 17:26:39 +0000 Subject: [PATCH 013/335] [ticket/10510] Moved quick-mod tools markup to template. PHPBB3-10510 --- .../prosilver/template/viewtopic_body.html | 20 +++++++++++-- .../subsilver2/template/viewtopic_body.html | 24 +++++++++++++++- phpBB/viewtopic.php | 28 +++++++++---------- 3 files changed, 54 insertions(+), 18 deletions(-) diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index 952b986d9f..674f8b1ff4 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -254,10 +254,26 @@ - +
- {S_TOPIC_MOD} + + + {S_FORM_TOKEN}
diff --git a/phpBB/styles/subsilver2/template/viewtopic_body.html b/phpBB/styles/subsilver2/template/viewtopic_body.html index b8387482bf..f9526b9b28 100644 --- a/phpBB/styles/subsilver2/template/viewtopic_body.html +++ b/phpBB/styles/subsilver2/template/viewtopic_body.html @@ -347,7 +347,29 @@ - +
{L_QUICK_MOD}: {S_TOPIC_MOD}
+ +
+ {L_QUICK_MOD}: + + +
+ +
{rules.RULE}
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 7cb6df3660..450ebfeda8 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -517,20 +517,6 @@ gen_forum_auth_level('topic', $forum_id, $topic_data['forum_status']); // Quick mod tools $allow_change_type = ($auth->acl_get('m_', $forum_id) || ($user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'])) ? true : false; -$topic_mod = ''; -$topic_mod .= ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED)) ? (($topic_data['topic_status'] == ITEM_UNLOCKED) ? '' : '') : ''; -$topic_mod .= ($auth->acl_get('m_delete', $forum_id)) ? '' : ''; -$topic_mod .= ($auth->acl_get('m_move', $forum_id) && $topic_data['topic_status'] != ITEM_MOVED) ? '' : ''; -$topic_mod .= ($auth->acl_get('m_split', $forum_id)) ? '' : ''; -$topic_mod .= ($auth->acl_get('m_merge', $forum_id)) ? '' : ''; -$topic_mod .= ($auth->acl_get('m_merge', $forum_id)) ? '' : ''; -$topic_mod .= ($auth->acl_get('m_move', $forum_id)) ? '' : ''; -$topic_mod .= ($allow_change_type && $auth->acl_gets('f_sticky', 'f_announce', $forum_id) && $topic_data['topic_type'] != POST_NORMAL) ? '' : ''; -$topic_mod .= ($allow_change_type && $auth->acl_get('f_sticky', $forum_id) && $topic_data['topic_type'] != POST_STICKY) ? '' : ''; -$topic_mod .= ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_ANNOUNCE) ? '' : ''; -$topic_mod .= ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_GLOBAL) ? '' : ''; -$topic_mod .= ($auth->acl_get('m_', $forum_id)) ? '' : ''; - // If we've got a hightlight set pass it on to pagination. $pagination = generate_pagination(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . ((strlen($u_sort_param)) ? "&$u_sort_param" : '') . (($highlight_match) ? "&hilit=$highlight" : '')), $total_posts, $config['posts_per_page'], $start); @@ -617,7 +603,19 @@ $template->assign_vars(array( 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_SINGLE_MODERATOR' => (!empty($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id]) > 1) ? false : true, 'S_TOPIC_ACTION' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start")), - 'S_TOPIC_MOD' => ($topic_mod != '') ? '' : '', + 'S_TOPIC_MOD_LOCK' => ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED)) ? (($topic_data['topic_status'] == ITEM_UNLOCKED) ? 'lock' : 'unlock') : '', + 'S_TOPIC_MOD_DELETE' => ($auth->acl_get('m_delete', $forum_id)) ? true : false, + 'S_TOPIC_MOD_MOVE' => ($auth->acl_get('m_move', $forum_id) && $topic_data['topic_status'] != ITEM_MOVED) ? true : false, + 'S_TOPIC_MOD_SPLIT' => ($auth->acl_get('m_split', $forum_id)) ? true : false, + 'S_TOPIC_MOD_MERGE' => ($auth->acl_get('m_merge', $forum_id)) ? true : false, + 'S_TOPIC_MOD_MERGE_TOPIC' => ($auth->acl_get('m_merge', $forum_id)) ? true : false, + 'S_TOPIC_MOD_FORK' => ($auth->acl_get('m_move', $forum_id)) ? true : false, + 'S_TOPIC_MOD_MAKE_NORMAL' => ($allow_change_type && $auth->acl_gets('f_sticky', 'f_announce', $forum_id) && $topic_data['topic_type'] != POST_NORMAL) ? true : false, + 'S_TOPIC_MOD_MAKE_STICKY' => ($allow_change_type && $auth->acl_get('f_sticky', $forum_id) && $topic_data['topic_type'] != POST_STICKY) ? true : false, + 'S_TOPIC_MOD_MAKE_ANNOUNCE' => ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_ANNOUNCE) ? true : false, + 'S_TOPIC_MOD_MAKE_GLOBAL' => ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_GLOBAL) ? true : false, + 'S_TOPIC_MOD_TOPIC_LOGS' => ($auth->acl_get('m_', $forum_id)), + 'S_MOD_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start") . "&quickmod=1&redirect=" . urlencode(str_replace('&', '&', $viewtopic_url)), true, $user->session_id), 'S_VIEWTOPIC' => true, From 2b0282cba73c8649b1649444a23c3913cc652de2 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Tue, 20 Dec 2011 09:27:56 +0000 Subject: [PATCH 014/335] [ticket/10510] Updated quick-mod conditional in subsilver2. It was still trying to use the old conditional, which was referring to a variable which had been removed. PHPBB3-10510 --- phpBB/styles/subsilver2/template/viewtopic_body.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/styles/subsilver2/template/viewtopic_body.html b/phpBB/styles/subsilver2/template/viewtopic_body.html index f9526b9b28..a431d51c79 100644 --- a/phpBB/styles/subsilver2/template/viewtopic_body.html +++ b/phpBB/styles/subsilver2/template/viewtopic_body.html @@ -348,7 +348,7 @@
- +
{L_QUICK_MOD}:
diff --git a/tests/dbal/order_lower_test.php b/tests/dbal/order_lower_test.php index eaf5211508..e16c0c20ee 100644 --- a/tests/dbal/order_lower_test.php +++ b/tests/dbal/order_lower_test.php @@ -33,24 +33,30 @@ class phpbb_dbal_order_lower_test extends phpbb_database_test_case 'style_name' => 'prosilver', 'style_copyright' => '© phpBB Group', 'style_active' => 1, - 'template_id' => 1, - 'theme_id' => 1, + 'style_path' => 'prosilver', + 'bbcode_bitfield' => 'kNg=', + 'style_parent_id' => 0, + 'style_parent_tree' => '', ), array( 'style_id' => 3, 'style_name' => 'Prosilver1', 'style_copyright' => '© phpBB Group', 'style_active' => 0, - 'template_id' => 3, - 'theme_id' => 3, + 'style_path' => 'prosilver1', + 'bbcode_bitfield' => 'kNg=', + 'style_parent_id' => 1, + 'style_parent_tree' => 'prosilver', ), array( 'style_id' => 2, 'style_name' => 'prosilver2', 'style_copyright' => '© phpBB Group', 'style_active' => 0, - 'template_id' => 2, - 'theme_id' => 2, + 'style_path' => 'prosilver2', + 'bbcode_bitfield' => 'kNg=', + 'style_parent_id' => 0, + 'style_parent_tree' => '', ) ), $db->sql_fetchrowset($result) From 0c6955e73c72d69c91548bb0c3106e39ce166b70 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Wed, 14 Mar 2012 23:45:54 +0200 Subject: [PATCH 042/335] [feature/merging-style-components] Adding new language variables Adding new language variables for acp_styles and removing some unused variables PHPBB3-10632 --- phpBB/language/en/acp/common.php | 2 + phpBB/language/en/acp/styles.php | 64 +++++++++++++------------------- 2 files changed, 28 insertions(+), 38 deletions(-) diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 7f1ecb5c01..254cd473a5 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -168,6 +168,8 @@ $lang = array_merge($lang, array( 'ACP_STYLE_COMPONENTS' => 'Style components', 'ACP_STYLE_MANAGEMENT' => 'Style management', 'ACP_STYLES' => 'Styles', + 'ACP_STYLES_CACHE' => 'Purge Cache', + 'ACP_STYLES_INSTALL' => 'Install Styles', 'ACP_SUBMIT_CHANGES' => 'Submit changes', diff --git a/phpBB/language/en/acp/styles.php b/phpBB/language/en/acp/styles.php index 59df82477e..fe7fae5808 100644 --- a/phpBB/language/en/acp/styles.php +++ b/phpBB/language/en/acp/styles.php @@ -35,15 +35,9 @@ if (empty($lang) || !is_array($lang)) // in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine $lang = array_merge($lang, array( - 'ACP_STYLES_EXPLAIN' => 'Here you can manage the available styles on your board. A style consists of a template and theme. You may alter existing styles, delete, deactivate, reactivate, create or import new ones. You can also see what a style will look like using the preview function. The current default style is noted by the presence of an asterisk (*). Also listed is the total user count for each style, note that overriding user styles will not be reflected here.', - 'ACP_TEMPLATES_EXPLAIN' => 'A template set comprises all the markup used to generate the layout of your board. Here you can edit existing template sets, delete, export, import and preview sets. You can also modify the templating code used to generate BBCode.', - 'ACP_THEMES_EXPLAIN' => 'From here you can create, install, edit, delete and export themes. A theme is the combination of colours and images that are applied to your templates to define the basic look of your board. The range of options open to you depends on the configuration of your server and phpBB installation, see the manual for further details. Please note that when creating new themes the use of an existing theme as a basis is optional.', - 'ADD_STYLE' => 'Create style', - 'ADD_STYLE_EXPLAIN' => 'Here you can create a new style. Depending on your server configuration and file permissions you may have additional options. For example you may be able to base this style on an existing one. You may also be able to upload or import (from the store directory) a style archive. If you upload or import an archive the style name will be determined automatically.', + 'ACP_STYLES_EXPLAIN' => 'Here you can manage the available styles on your board. You may alter existing styles, delete, deactivate, reactivate, install new ones. You can also see what a style will look like using the preview function. Also listed is the total user count for each style, note that overriding user styles will not be reflected here.', 'ADD_TEMPLATE' => 'Create template', 'ADD_TEMPLATE_EXPLAIN' => 'Here you can add a new template. Depending on your server configuration and file permissions you may have additional options here. For example you may be able to base this template set on an existing one. You may also be able to upload or import (from the store directory) a template archive. If you upload or import an archive the template name can be optionally taken from the archive name (to do this leave the template name blank).', - 'ADD_THEME' => 'Create theme', - 'ADD_THEME_EXPLAIN' => 'Here you can add a new theme. Depending on your server configuration and file permissions you may have additional options here. For example you may be able to base this theme on an existing one. You may also be able to upload or import (from the store directory) a theme archive. If you upload or import an archive the theme name can be optionally taken from the archive name (to do this leave the theme name blank).', 'ARCHIVE_FORMAT' => 'Archive file type', 'AUTOMATIC_EXPLAIN' => 'Leave blank to attempt automatic detection.', @@ -58,7 +52,9 @@ $lang = array_merge($lang, array( 'CACHE_FILENAME' => 'Template file', 'CACHE_FILESIZE' => 'File size', 'CACHE_MODIFIED' => 'Modified', + 'CANNOT_BE_INSTALLED' => 'Cannot be installed', 'CONFIRM_TEMPLATE_CLEAR_CACHE' => 'Are you sure you wish to clear all cached versions of your template files?', + 'CONFIRM_DELETE_STYLES' => 'Are you sure you wish to delete selected styles?', 'COPYRIGHT' => 'Copyright', 'CREATE_STYLE' => 'Create new style', 'CREATE_TEMPLATE' => 'Create new template set', @@ -66,13 +62,14 @@ $lang = array_merge($lang, array( 'CURRENT_IMAGE' => 'Current image', 'DEACTIVATE_DEFAULT' => 'You cannot deactivate the default style.', + 'DELETE_DEFAULT' => 'You cannot delete the default style.', 'DELETE_FROM_FS' => 'Delete from filesystem', 'DELETE_STYLE' => 'Delete style', 'DELETE_STYLE_EXPLAIN' => 'Here you can remove the selected style. Take care in deleting styles, there is no undo capability.', + 'DELETE_STYLE_FILES_FAILED' => 'Error deleting files for style "%s".', + 'DELETE_STYLE_FILES_SUCCESS' => 'Files for style "%s" have been deleted.', 'DELETE_TEMPLATE' => 'Delete template', 'DELETE_TEMPLATE_EXPLAIN' => 'Here you can remove the selected template set from the database. Please note that there is no undo capability. It is recommended that you first export your set for possible future use.', - 'DELETE_THEME' => 'Delete theme', - 'DELETE_THEME_EXPLAIN' => 'Here you can remove the selected theme from the database. Please note that there is no undo capability. It is recommended that you first export your theme for possible future use.', 'DETAILS' => 'Details', 'DIMENSIONS_EXPLAIN' => 'Selecting yes here will include width/height parameters.', @@ -239,17 +236,10 @@ $lang = array_merge($lang, array( 'INCLUDE_THEME' => 'Include theme', 'INHERITING_FROM' => 'Inherits from', 'INSTALL_STYLE' => 'Install style', - 'INSTALL_STYLE_EXPLAIN' => 'Here you can install a new style and if appropriate the corresponding style elements. If you already have the relevant style elements installed they will not be overwritten. Some styles require existing style elements to already be installed. If you try installing such a style and do not have the required elements you will be notified.', - 'INSTALL_TEMPLATE' => 'Install Template', - 'INSTALL_TEMPLATE_EXPLAIN' => 'Here you can install a new template set. Depending on your server configuration you may have a number of options here.', - 'INSTALL_THEME' => 'Install theme', - 'INSTALL_THEME_EXPLAIN' => 'Here you can install your selected theme. You can edit certain details if you wish or use the installation defaults.', + 'INSTALL_STYLES' => 'Install styles', + 'INSTALL_STYLES_EXPLAIN' => 'Here you can install new styles.
If you cannot find a specific style in list below, check if that style is already installed. If it is not installed, check if it was uploaded correctly.', 'INSTALLED_STYLE' => 'Installed styles', - 'INSTALLED_TEMPLATE' => 'Installed templates', - 'INSTALLED_THEME' => 'Installed themes', - - 'KEEP_TEMPLATE' => 'Keep “%s” template', - 'KEEP_THEME' => 'Keep “%s” theme', + 'INVALID_STYLE_ID' => 'Invalid style ID.', 'LINE_SPACING' => 'Line spacing', 'LOCALISED_IMAGES' => 'Localised', @@ -257,18 +247,17 @@ $lang = array_merge($lang, array( 'NO_CLASS' => 'Cannot find class in stylesheet.', 'NO_IMAGE' => 'No image', 'NO_IMAGE_ERROR' => 'Cannot find image on filesystem.', + 'NO_MATCHING_STYLES_FOUND' => 'No styles match your query.', 'NO_STYLE' => 'Cannot find style on filesystem.', 'NO_TEMPLATE' => 'Cannot find template on filesystem.', 'NO_THEME' => 'Cannot find theme on filesystem.', 'NO_UNINSTALLED_STYLE' => 'No uninstalled styles detected.', - 'NO_UNINSTALLED_TEMPLATE' => 'No uninstalled templates detected.', - 'NO_UNINSTALLED_THEME' => 'No uninstalled themes detected.', 'NO_UNIT' => 'None', 'ONLY_STYLE' => 'This is the only remaining style, you cannot delete it.', - 'ONLY_TEMPLATE' => 'This is the only remaining template set, you cannot delete it.', - 'ONLY_THEME' => 'This is the only remaining theme, you cannot delete it.', - 'OPTIONAL_BASIS' => 'Optional basis', + + 'PARENT_STYLE_NOT_FOUND' => 'Parent style was not found. This style may not work correctly. Please uninstall it.', + 'PURGED_CACHE' => 'Cache was purged.', 'REFRESH' => 'Refresh', 'REPEAT_NO' => 'None', @@ -282,8 +271,7 @@ $lang = array_merge($lang, array( 'REPLACE_THEME' => 'Replace theme with', 'REPLACE_THEME_EXPLAIN' => 'This theme will replace the one you are deleting in any styles that use it.', 'REPLACE_WITH_OPTION' => 'Replace with “%s”', - 'REQUIRES_TEMPLATE' => 'This style requires the %s template set to be installed.', - 'REQUIRES_THEME' => 'This style requires the %s theme to be installed.', + 'REQUIRES_STYLE' => 'This style requires the style "%s" to be installed.', 'SELECT_IMAGE' => 'Select image', 'SELECT_TEMPLATE' => 'Select template file', @@ -299,21 +287,31 @@ $lang = array_merge($lang, array( 'STYLE_ADDED' => 'Style added successfully.', 'STYLE_DEACTIVATE' => 'Deactivate', 'STYLE_DEFAULT' => 'Make default style', - 'STYLE_DELETED' => 'Style deleted successfully.', + 'STYLE_DEFAULT_CHANGE' => 'Change default style', + 'STYLE_DEFAULT_CHANGE_INACTIVE' => 'You must activate style before making it default style.', + 'STYLE_DELETE_DEPENDENT' => 'Style "%s" cannot be deleted because it has one or more child styles.', + 'STYLE_DELETED' => 'Style "%s" deleted successfully.', 'STYLE_DETAILS_UPDATED' => 'Style edited successfully.', 'STYLE_ERR_ARCHIVE' => 'Please select an archive method.', 'STYLE_ERR_COPY_LONG' => 'The copyright can be no longer than 60 characters.', + 'STYLE_ERR_INVALID_PARENT' => 'Invalid parent style.', 'STYLE_ERR_MORE_ELEMENTS' => 'You must select at least one style element.', 'STYLE_ERR_NAME_CHARS' => 'The style name can only contain alphanumeric characters, -, +, _ and space.', 'STYLE_ERR_NAME_EXIST' => 'A style with that name already exists.', 'STYLE_ERR_NAME_LONG' => 'The style name can be no longer than 30 characters.', - 'STYLE_ERR_NO_IDS' => 'You must select a template and theme for this style.', 'STYLE_ERR_NOT_STYLE' => 'The imported or uploaded file did not contain a valid style archive.', 'STYLE_ERR_STYLE_NAME' => 'You must supply a name for this style.', 'STYLE_EXPORT' => 'Export style', 'STYLE_EXPORT_EXPLAIN' => 'Here you can export a style in the form of an archive. A style does not need to contain all elements but it must contain at least one. For example if you have created a new theme for a commonly used template you could simply export the theme and omit the template. You may select whether to download the file directly or to place it in your store folder for download later or via FTP.', 'STYLE_EXPORTED' => 'Style exported successfully and stored in %s.', + 'STYLE_INSTALLED' => 'Style "%s" has been installed.', + 'STYLE_INSTALLED_EDIT_DETAILS' => '
Click here to edit style details or to change default style.', + 'STYLE_INSTALLED_RETURN_STYLES' => 'Click here to return to installed styles list.', + 'STYLE_INSTALLED_RETURN_UNINSTALLED' => 'Click here to install more styles.', 'STYLE_NAME' => 'Style name', + 'STYLE_NOT_INSTALLED' => 'Style "%s" was not installed.', + 'STYLE_PATH' => 'Style path:', + 'STYLE_PARENT' => 'Parent style:', 'STYLE_TEMPLATE' => 'Template', 'STYLE_THEME' => 'Theme', 'STYLE_USED_BY' => 'Used by (including robots)', @@ -323,8 +321,6 @@ $lang = array_merge($lang, array( 'TEMPLATE_CACHE_EXPLAIN' => 'By default phpBB caches the compiled version of its templates. This decreases the load on the server each time a page is viewed and thus may reduce the page generation time. Here you can view the cache status of each file and delete individual files or the entire cache.', 'TEMPLATE_CACHE_CLEARED' => 'Template cache cleared successfully.', 'TEMPLATE_CACHE_EMPTY' => 'There are no cached templates.', - 'TEMPLATE_DELETED' => 'Template set deleted successfully.', - 'TEMPLATE_DELETE_DEPENDENT' => 'The template set cannot be deleted as there are one or more other template sets inheriting from it:', 'TEMPLATE_DELETED_FS' => 'Template set removed from database but files remain on the filesystem.', 'TEMPLATE_DETAILS_UPDATED' => 'Template details successfully updated.', 'TEMPLATE_EDITOR' => 'Raw HTML template editor', @@ -333,17 +329,12 @@ $lang = array_merge($lang, array( 'TEMPLATE_ERR_CACHE_READ' => 'The cache directory used to store cached versions of template files could not be opened.', 'TEMPLATE_ERR_COPY_LONG' => 'The copyright can be no longer than 60 characters.', 'TEMPLATE_ERR_NAME_CHARS' => 'The template name can only contain alphanumeric characters, -, +, _ and space.', - 'TEMPLATE_ERR_NAME_EXIST' => 'A template set with that name already exists.', 'TEMPLATE_ERR_NAME_LONG' => 'The template name can be no longer than 30 characters.', - 'TEMPLATE_ERR_NOT_TEMPLATE' => 'The archive you specified does not contain a valid template set.', - 'TEMPLATE_ERR_REQUIRED_OR_INCOMPLETE' => 'The new template set requires the template %s to be installed and not inheriting itself.', 'TEMPLATE_ERR_STYLE_NAME' => 'You must supply a name for this template.', - 'TEMPLATE_EXPORT' => 'Export templates', 'TEMPLATE_EXPORT_EXPLAIN' => 'Here you can export a template set in the form of an archive. This archive will contain all the files necessary to install the templates on another board. You may select whether to download the file directly or to place it in your store folder for download later or via FTP.', 'TEMPLATE_EXPORTED' => 'Templates exported successfully and stored in %s.', 'TEMPLATE_FILE' => 'Template file', 'TEMPLATE_FILE_UPDATED' => 'Template file updated successfully.', - 'TEMPLATE_INHERITS' => 'This template sets inherits from %s and thus cannot have a different storage setting than its super template.', 'TEMPLATE_NAME' => 'Template name', 'TEMPLATE_FILE_NOT_WRITABLE'=> 'Unable to write to template file %s. Please check the permissions for the directory and the files.', @@ -371,9 +362,6 @@ $lang = array_merge($lang, array( 'THEME_UPDATED' => 'Theme updated successfully.', 'UNDERLINE' => 'Underline', - 'UNINSTALLED_STYLE' => 'Uninstalled styles', - 'UNINSTALLED_TEMPLATE' => 'Uninstalled templates', - 'UNINSTALLED_THEME' => 'Uninstalled themes', 'UNSET' => 'Undefined', )); From e35a20f957342a320a7c11b0cee1b94025848813 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Wed, 14 Mar 2012 23:47:57 +0200 Subject: [PATCH 043/335] [feature/merging-style-components] New acp_styles New acp_styles, completely rewritten PHPBB3-10632 --- phpBB/includes/acp/acp_styles.php | 3837 ++++++++---------------- phpBB/includes/acp/info/acp_styles.php | 6 +- 2 files changed, 1273 insertions(+), 2570 deletions(-) diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 7b449d3b35..acd010b77e 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -21,16 +21,1278 @@ if (!defined('IN_PHPBB')) class acp_styles { var $u_action; - - var $style_cfg; - var $template_cfg; - var $theme_cfg; + var $u_base_action; + var $s_hidden_fields; + var $mode; + var $styles_path; + var $styles_path_absolute = 'styles'; function main($id, $mode) { - global $db, $user, $auth, $template, $cache; - global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; + global $user, $phpbb_admin_path, $phpbb_root_path, $phpEx, $template, $request; + $this->styles_path = $phpbb_root_path . $this->styles_path_absolute . '/'; + + $this->u_base_action = append_sid("{$phpbb_admin_path}index.$phpEx", "i={$id}"); + $this->s_hidden_fields = array( + 'mode' => $mode, + ); + + $user->add_lang('acp/styles'); + + $this->tpl_name = 'acp_styles'; + $this->page_title = 'ACP_CAT_STYLES'; + $this->mode = $mode; + + $action = $request->variable('action', ''); + $post_actions = array('install', 'activate', 'deactivate', 'delete'); + foreach ($post_actions as $key) + { + if (isset($_POST[$key])) + { + $action = $key; + } + } + if ($action != '') + { + $this->s_hidden_fields['action'] = $action; + } + + $template->assign_vars(array( + 'U_ACTION' => $this->u_base_action, + 'S_HIDDEN_FIELDS' => build_hidden_fields($this->s_hidden_fields) + ) + ); + + // Execute actions + switch ($action) + { + case 'install': + $this->action_install(); + return; + case 'delete': + $this->action_delete(); + return; + case 'activate': + $this->action_activate(); + return; + case 'deactivate': + $this->action_deactivate(); + return; + case 'details': + $this->action_details(); + return; + default: + $this->frontend(); + } + } + + /** + * Main page + */ + function frontend() + { + // Check mode + switch ($this->mode) + { + case 'style': + $this->welcome_message('ACP_STYLES', 'ACP_STYLES_EXPLAIN'); + $this->show_installed(); + return; + case 'install': + $this->welcome_message('INSTALL_STYLES', 'INSTALL_STYLES_EXPLAIN'); + $this->show_available(); + return; + case 'cache': + $this->action_cache(); + return; + } + global $user; + trigger_error($user->lang['NO_MODE'] . adm_back_link($this->u_action), E_USER_WARNING); + } + + /** + * Purge cache + */ + function action_cache() + { + global $cache, $auth, $user; + + $cache->purge(); + + // Clear permissions + $auth->acl_clear_prefetch(); + cache_moderators(); + + add_log('admin', 'LOG_PURGE_CACHE'); + + trigger_error($user->lang['PURGED_CACHE'] . adm_back_link($this->u_base_action), E_USER_NOTICE); + } + + /** + * Install style(s) + */ + function action_install() + { + global $user; + + // Get list of styles to install + $dirs = $this->request_vars('dir', '', true); + + // Get list of styles that can be installed + $styles = $this->find_available(false); + + // Install each style + $messages = array(); + $installed_names = array(); + $installed_dirs = array(); + $last_installed = false; + foreach ($dirs as $dir) + { + $found = false; + foreach ($styles as &$style) + { + // Check if: + // 1. Directory matches directory we are looking for + // 2. Style is not installed yet + // 3. Style with same name or directory hasn't been installed already within this function + if ($style['style_path'] == $dir && empty($style['_installed']) && !in_array($style['style_path'], $installed_dirs) && !in_array($style['style_name'], $installed_names)) + { + // Install style + $style['style_active'] = 1; + $style['style_id'] = $this->install_style($style); + $style['_installed'] = true; + $found = true; + $last_installed = $style['style_id']; + $installed_names[] = $style['style_name']; + $installed_dirs[] = $style['style_path']; + $messages[] = sprintf($user->lang['STYLE_INSTALLED'], htmlspecialchars($style['style_name'])); + } + } + if (!$found) + { + $messages[] = sprintf($user->lang['STYLE_NOT_INSTALLED'], htmlspecialchars($dir)); + } + } + + // Show message + if (!count($messages)) + { + trigger_error($user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); + } + $message = implode('
', $messages); + if (count($messages) == 1 && $last_installed !== false) + { + $message .= '

' . sprintf($user->lang['STYLE_INSTALLED_EDIT_DETAILS'], $this->u_base_action . '&mode=style&action=details&id=' . $last_installed); + } + $message .= '

' . sprintf($user->lang['STYLE_INSTALLED_RETURN_STYLES'], $this->u_base_action . '&mode=style'); + $message .= '

' . sprintf($user->lang['STYLE_INSTALLED_RETURN_UNINSTALLED'], $this->u_base_action . '&mode=install'); + trigger_error($message, E_USER_NOTICE); + } + + /** + * Confirm styles deletion + */ + function action_delete() + { + global $user, $config, $template, $request; + + // Get list of styles to delete + $ids = $this->request_vars('id', 0, true); + + // Check if confirmation box was submitted + if (confirm_box(true)) + { + // Delete + $this->action_delete_confirmed($ids, $request->variable('confirm_delete_files', false)); + return; + } + + // Confirm box + $s_hidden = build_hidden_fields(array( + 'action' => 'delete', + 'ids' => $ids + )); + $template->assign_var('S_CONFIRM_DELETE', true); + confirm_box(false, $user->lang['CONFIRM_DELETE_STYLES'], $s_hidden, 'acp_styles.html'); + + // Canceled - show styles list + $this->frontend(); + } + + /** + * Delete styles(s) + * + * @param array $ids List of style IDs + * @param bool $delete_files If true, script will attempt to remove files for selected styles + */ + function action_delete_confirmed($ids, $delete_files) + { + global $db, $user, $cache; + + $default = $config['default_style']; + $deleted = array(); + $messages = array(); + + // Check styles list + foreach ($ids as $id) + { + if (!$id) + { + trigger_error($user->lang['INVALID_STYLE_ID'] . adm_back_link($this->u_action), E_USER_WARNING); + } + if ($id == $default) + { + trigger_error($user->lang['DELETE_DEFAULT'] . adm_back_link($this->u_action), E_USER_WARNING); + } + $deleted[$id] = false; + } + + // Order by reversed style_id, so parent styles would be removed after child styles + // This way parent and child styles can be removed in same function call + $sql = 'SELECT * + FROM ' . STYLES_TABLE . ' + WHERE style_id IN (' . implode(', ', $ids) . ') + ORDER BY style_id DESC'; + $result = $db->sql_query($sql); + + $rows = $db->sql_fetchrowset($result); + $db->sql_freeresult($result); + + // Delete each style + $deleted = array(); + foreach ($rows as $style) + { + $result = $this->delete_style($style, $delete_files); + + if (is_string($result)) + { + $messages[] = $result; + continue; + } + $messages[] = sprintf($user->lang['STYLE_DELETED'], $style['style_name']); + $deleted[] = $style['style_name']; + + // Attempt to delete files + if ($delete_files) + { + $messages[] = sprintf($user->lang[$this->delete_style_files($style['style_path']) ? 'DELETE_STYLE_FILES_SUCCESS' : 'DELETE_STYLE_FILES_FAILED'], $style['style_name']); + } + } + + if (empty($messages)) + { + // Nothing to delete? + trigger_error($user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); + } + + // Log action + if (count($deleted)) + { + add_log('admin', 'LOG_STYLE_DELETE', implode(', ', $deleted)); + } + + // Clear cache + $cache->purge(); + + // Show message + trigger_error(implode('
', $messages) . adm_back_link($this->u_action), E_USER_NOTICE); + } + + /** + * Activate styles + */ + function action_activate() + { + global $user, $config, $cache, $db; + + // Get list of styles to activate + $ids = $this->request_vars('id', 0, true); + + // Activate styles + $sql = 'UPDATE ' . STYLES_TABLE . ' + SET style_active = 1 + WHERE style_id IN (' . implode(', ', $ids) . ')'; + $db->sql_query($sql); + + // Purge cache + $cache->destroy('sql', STYLES_TABLE); + + // Show styles list + $this->frontend(); + } + + /** + * Deactivate styles + */ + function action_deactivate() + { + global $user, $config, $cache, $db; + + // Get list of styles to deactivate + $ids = $this->request_vars('id', 0, true); + + // Check for default style + foreach ($ids as $id) + { + if ($id == $config['default_style']) + { + trigger_error($user->lang['DEACTIVATE_DEFAULT'] . adm_back_link($this->u_action), E_USER_WARNING); + } + } + + // Reset default style for users who use selected styles + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_style = 0 + WHERE user_style IN (' . implode(', ', $ids) . ')'; + $db->sql_query($sql); + + // Deactivate styles + $sql = 'UPDATE ' . STYLES_TABLE . ' + SET style_active = 0 + WHERE style_id IN (' . implode(', ', $ids) . ')'; + $db->sql_query($sql); + + // Purge cache + $cache->destroy('sql', STYLES_TABLE); + + // Show styles list + $this->frontend(); + } + + /** + * Show style details + */ + function action_details() + { + global $user, $config, $db, $request, $template, $cache; + + $id = $request->variable('id', 0); + if (!$id) + { + trigger_error($user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); + } + + // Get all styles + $styles = $this->get_styles(); + usort($styles, 'acp_styles::sort_styles'); + + // Find current style + $style = false; + foreach ($styles as $row) + { + if ($row['style_id'] == $id) + { + $style = $row; + break; + } + } + + if ($style === false) + { + trigger_error($user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); + } + + // Find all available parent styles + $list = $this->find_possible_parents($styles, $id); + + // Change data + if ($request->variable('update', false)) + { + $update = array( + 'style_name' => trim($request->variable('style_name', $style['style_name'])), + 'style_parent_id' => $request->variable('style_parent', (int) $style['style_parent_id']), + 'style_active' => $request->variable('style_active', (int) $style['style_active']), + ); + $update_action = $this->u_action . '&action=details&id=' . $id; + + // Check style name + if ($update['style_name'] != $style['style_name']) + { + if (!strlen($update['style_name'])) + { + trigger_error($user->lang['STYLE_ERR_STYLE_NAME'] . adm_back_link($update_action), E_USER_WARNING); + } + foreach ($styles as $row) + { + if ($row['style_name'] == $update['style_name']) + { + trigger_error($user->lang['STYLE_ERR_NAME_EXIST'] . adm_back_link($update_action), E_USER_WARNING); + } + } + } + else + { + unset($update['style_name']); + } + + // Check parent style id + if ($update['style_parent_id'] != $style['style_parent_id']) + { + if ($update['style_parent_id'] != 0) + { + $found = false; + foreach ($list as $row) + { + if ($row['style_id'] == $update['style_parent_id']) + { + $found = true; + $update['style_parent_tree'] = ($row['style_parent_tree'] != '' ? $row['style_parent_tree'] . '/' : '') . $row['style_path']; + break; + } + } + if (!$found) + { + trigger_error($user->lang['STYLE_ERR_INVALID_PARENT'] . adm_back_link($update_action), E_USER_WARNING); + } + } + else + { + $update['style_parent_tree'] = ''; + } + } + else + { + unset($update['style_parent_id']); + } + + // Check style_active + if ($update['style_active'] != $style['style_active']) + { + if (!$update['style_active'] && $config['default_style'] == $style['style_id']) + { + trigger_error($user->lang['DEACTIVATE_DEFAULT'] . adm_back_link($update_action), E_USER_WARNING); + } + } + else + { + unset($update['style_active']); + } + + // Update data + if (count($update)) + { + $sql = 'UPDATE ' . STYLES_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $update) . " + WHERE style_id = $id"; + $db->sql_query($sql); + + $style = array_merge($style, $update); + + if (isset($update['style_parent_id'])) + { + // Update styles tree + $styles = $this->get_styles(); + if ($this->update_styles_tree(&$styles, $style)) + { + // Something was changed in styles tree, purge all cache + $cache->purge(); + } + } + add_log('admin', 'LOG_STYLE_EDIT_DETAILS', $style['style_name']); + } + + // Update default style + $default = $request->variable('style_default', 0); + if ($default) + { + if (!$style['style_active']) + { + trigger_error($user->lang['STYLE_DEFAULT_CHANGE_INACTIVE'] . adm_back_link($update_action), E_USER_WARNING); + } + set_config('default_style', $id); + $cache->purge(); + } + + // Show styles list + $this->frontend(); + return; + } + + // Show parent styles + foreach ($list as $row) + { + $template->assign_block_vars('parent_styles', array( + 'STYLE_ID' => $row['style_id'], + 'STYLE_NAME' => htmlspecialchars($row['style_name']), + 'LEVEL' => $row['level'], + 'SPACER' => str_repeat('  ', $row['level']), + ) + ); + } + + // Show style details + $template->assign_vars(array( + 'S_STYLE_DETAILS' => true, + 'STYLE_ID' => $style['style_id'], + 'STYLE_NAME' => htmlspecialchars($style['style_name']), + 'STYLE_PATH' => htmlspecialchars($style['style_path']), + 'STYLE_COPYRIGHT' => strip_tags($style['style_copyright']), + 'STYLE_PARENT' => $style['style_parent_id'], + 'S_STYLE_ACTIVE' => $style['style_active'], + 'S_STYLE_DEFAULT' => ($style['style_id'] == $config['default_style']) + ) + ); + } + + /** + * List installed styles + */ + function show_installed() + { + global $user, $template; + + // Get all installed styles + $styles = $this->get_styles(); + + if (!count($styles)) + { + trigger_error($user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); + } + + usort($styles, 'acp_styles::sort_styles'); + + // Get users + $users = $this->get_users(); + + // Add users counter to rows + foreach ($styles as &$style) + { + $style['_users'] = isset($users[$style['style_id']]) ? $users[$style['style_id']] : 0; + } + + // Set up styles list variables + // Addons should increase this number and update template variable + $this->styles_list_cols = 4; + $template->assign_var('STYLES_LIST_COLS', $this->styles_list_cols); + + // Show styles list + $this->show_styles_list(&$styles, 0, 0); + + // Show styles with invalid inherits_id + foreach ($styles as $style) + { + if (empty($style['_shown'])) + { + $style['_note'] = sprintf($user->lang['REQUIRES_STYLE'], htmlspecialchars($style['style_parent_tree'])); + $this->list_style($style, 0); + } + } + + // Add buttons + $template->assign_block_vars('extra_actions', array( + 'ACTION_NAME' => 'activate', + 'L_ACTION' => $user->lang['STYLE_ACTIVATE'], + ) + ); + + $template->assign_block_vars('extra_actions', array( + 'ACTION_NAME' => 'deactivate', + 'L_ACTION' => $user->lang['STYLE_DEACTIVATE'], + ) + ); + + if (isset($this->style_counters) && $this->style_counters['total'] > 1) + { + $template->assign_block_vars('extra_actions', array( + 'ACTION_NAME' => 'delete', + 'L_ACTION' => $user->lang['DELETE'], + ) + ); + } + } + + /** + * Show list of styles that can be installed + */ + function show_available() + { + global $user, $template; + + // Get list of styles + $styles = $this->find_available(true); + + // Show styles + if (empty($styles)) + { + trigger_error($user->lang['NO_UNINSTALLED_STYLE'] . adm_back_link($this->u_action), E_USER_NOTICE); + } + + usort($styles, 'acp_styles::sort_styles'); + + $this->styles_list_cols = 3; + $template->assign_vars(array( + 'STYLES_LIST_COLS' => $this->styles_list_cols, + 'STYLES_LIST_HIDE_COUNT' => true + ) + ); + + // Show styles + foreach ($styles as &$style) + { + // Check if style has a parent style in styles list + $has_parent = false; + if ($style['_inherit_name'] != '') + { + foreach ($styles as $parent_style) + { + if ($parent_style['style_name'] == $style['_inherit_name'] && empty($parent_style['_shown'])) + { + // Show parent style first + $has_parent = true; + } + } + } + if (!$has_parent) + { + $this->list_style(&$style, 0); + $this->show_available_child_styles(&$styles, $style['style_name'], 1); + } + } + + // Show styles that do not have parent style in styles list + foreach ($styles as $style) + { + if (empty($style['_shown'])) + { + $this->list_style(&$style, 0); + } + } + + // Add button + if (isset($this->style_counters) && $this->style_counters['caninstall'] > 0) + { + $template->assign_block_vars('extra_actions', array( + 'ACTION_NAME' => 'install', + 'L_ACTION' => $user->lang['INSTALL_STYLES'], + ) + ); + } + } + + /** + * Find styles available for installation + * + * @param bool $all if true, function will return all installable styles. if false, function will return only styles that can be installed + * @returns array list of styles + */ + function find_available($all) + { + global $user; + + // Get list of installed styles + $installed = $this->get_styles(); + + $installed_dirs = array(); + $installed_names = array(); + foreach ($installed as $style) + { + $installed_dirs[] = $style['style_path']; + $installed_names[$style['style_name']] = array( + 'path' => $style['style_path'], + 'id' => $style['style_id'], + 'parent' => $style['style_parent_id'], + 'tree' => (strlen($style['style_parent_tree']) ? $style['style_parent_tree'] . '/' : '') . $style['style_path'], + ); + } + + // Get list of directories + $dirs = $this->find_style_dirs(); + + // Find styles that can be installed + $styles = array(); + foreach ($dirs as $dir) + { + if (in_array($dir, $installed_dirs)) + { + // Style is already installed + continue; + } + $cfg = $this->read_style_cfg($dir); + if ($cfg === false) + { + // Invalid style.cfg + continue; + } + + // Style should be available for installation + $parent = $cfg['parent']; + $style = array( + 'style_id' => 0, + 'style_name' => $cfg['name'], + 'style_copyright' => $cfg['copyright'], + 'style_active' => 0, + 'style_path' => $dir, + 'bbcode_bitfield' => $cfg['template_bitfield'], + 'style_parent_id' => 0, + 'style_parent_tree' => '', + // Extra values for styles list + // All extra variable start with _ so they won't be confused with data that can be added to styles table + '_inherit_name' => $parent, + '_available' => true, + '_note' => '', + ); + + // Check style inheritance + if ($parent != '') + { + if (isset($installed_names[$parent])) + { + // Parent style is installed + $row = $installed_names[$parent]; + $style['style_parent_id'] = $row['id']; + $style['style_parent_tree'] = $row['tree']; + } + else + { + // Parent style is not installed yet + $style['_available'] = false; + $style['_note'] = sprintf($user->lang['REQUIRES_STYLE'], htmlspecialchars($parent)); + } + } + + if ($all || $style['_available']) + { + $styles[] = $style; + } + } + + return $styles; + } + + /** + * Show styles list + * + * @param array $styles styles list + * @param int $parent parent style id + * @param int $level style inheritance level + */ + function show_styles_list($styles, $parent, $level) + { + foreach ($styles as &$style) + { + if (empty($style['_shown']) && $style['style_parent_id'] == $parent) + { + $this->list_style(&$style, $level); + $this->show_styles_list(&$styles, $style['style_id'], $level + 1); + } + } + } + + /** + * Show available styles tree + * + * @param array $styles Styles list, passed as reference + * @param string $name Name of parent style + * @param string $level Styles tree level + */ + function show_available_child_styles($styles, $name, $level) + { + foreach ($styles as &$style) + { + if (empty($style['_shown']) && $style['_inherit_name'] == $name) + { + $this->list_style(&$style, $level); + $this->show_available_child_styles(&$styles, $style['style_name'], $level + 1); + } + } + } + + /** + * Update styles tree + * + * @param array $styles Styles list, passed as reference + * @param array $style Current style, false if root + * @returns true if something was updated, false if not + */ + function update_styles_tree($styles, $style = false) + { + $parent_id = ($style === false) ? 0 : $style['style_id']; + $parent_tree = ($style === false) ? '' : ($style['style_parent_tree'] == '' ? '' : $style['style_parent_tree']) . $style['style_path']; + $update = false; + $updated = false; + foreach ($styles as &$row) + { + if ($row['style_parent_id'] == $parent_id) + { + if ($row['style_parent_tree'] != $parent_tree) + { + $row['style_parent_tree'] = $parent_tree; + $update = true; + } + $updated |= $this->update_styles_tree(&$styles, $row); + } + } + if ($update) + { + global $db; + $sql = 'UPDATE ' . STYLES_TABLE . " + SET style_parent_tree = '" . $db->sql_escape($parent_tree) . "' + WHERE style_parent_id = {$parent_id}"; + $db->sql_query($sql); + $updated = true; + } + return $updated; + } + + /** + * Find all possible parent styles for style + * + * @param array $styles list of styles + * @param int $id id of style + * @param int $parent current parent style id + * @param int $level current tree level + * @returns array of style ids, names and levels + */ + function find_possible_parents($styles, $id = -1, $parent = 0, $level = 0) + { + $results = array(); + foreach ($styles as $style) + { + if ($style['style_id'] != $id && $style['style_parent_id'] == $parent) + { + $results[] = array( + 'style_id' => $style['style_id'], + 'style_name' => $style['style_name'], + 'style_path' => $style['style_path'], + 'style_parent_id' => $style['style_parent_id'], + 'style_parent_tree' => $style['style_parent_tree'], + 'level' => $level + ); + $results = array_merge($results, $this->find_possible_parents($styles, $id, $style['style_id'], $level + 1)); + } + } + return $results; + } + + /** + * Show item in styles list + * + * @param array $style style row + * @param array $level style inheritance level + */ + function list_style($style, $level) + { + global $template, $config, $db, $user, $phpbb_root_path, $phpEx; + + // Mark row as shown + if (!empty($style['_shown'])) return; + $style['_shown'] = true; + + // Generate template variables + $actions = array(); + $row = array( + // Style data + 'STYLE_ID' => $style['style_id'], + 'STYLE_NAME' => htmlspecialchars($style['style_name']), + 'STYLE_PATH' => htmlspecialchars($style['style_path']), + 'STYLE_COPYRIGHT' => strip_tags($style['style_copyright']), + 'STYLE_ACTIVE' => $style['style_active'], + + // Additional data + 'DEFAULT' => ($style['style_id'] && $style['style_id'] == $config['default_style']), + 'USERS' => $style['_users'], + 'LEVEL' => $level, + 'PADDING' => (4 + 16 * $level), + 'SHOW_COPYRIGHT' => ($style['style_id']) ? false : true, + 'STYLE_PATH_FULL' => htmlspecialchars($this->styles_path_absolute . '/' . $style['style_path']) . '/', + + // Comment to show below style + 'COMMENT' => (isset($style['_note'])) ? $style['_note'] : '', + + // The following variables should be used by hooks to add custom HTML code + 'EXTRA' => '', + 'EXTRA_OPTIONS' => '' + ); + + // Status specific data + if ($style['style_id']) + { + // Style is installed + + // Details + $actions[] = array( + 'U_ACTION' => $this->u_action . '&action=details&id=' . $style['style_id'], + 'L_ACTION' => $user->lang['DETAILS'] + ); + + // Activate + $actions[] = array( + 'U_ACTION' => $this->u_action . '&action=' . ($style['style_active'] ? 'de' : '') . 'activate&id=' . $style['style_id'], + 'L_ACTION' => $user->lang['STYLE_' . ($style['style_active'] ? 'DE' : '') . 'ACTIVATE'] + ); + +/* // Export + $actions[] = array( + 'U_ACTION' => $this->u_action . '&action=export&id=' . $style['style_id'], + 'L_ACTION' => $user->lang['EXPORT'] + ); */ + + // Delete + $actions[] = array( + 'U_ACTION' => $this->u_action . '&action=delete&id=' . $style['style_id'], + 'L_ACTION' => $user->lang['DELETE'] + ); + + // Preview + $actions[] = array( + 'U_ACTION' => append_sid("{$phpbb_root_path}index.$phpEx", 'style=' . $style['style_id']), + 'L_ACTION' => $user->lang['PREVIEW'] + ); + } + else + { + // Style is not installed + if (empty($style['_available'])) + { + $actions[] = array( + 'HTML' => $user->lang['CANNOT_BE_INSTALLED'] + ); + } + else + { + $actions[] = array( + 'U_ACTION' => $this->u_action . '&action=install&dir=' . urlencode($style['style_path']), + 'L_ACTION' => $user->lang['INSTALL_STYLE'] + ); + } + } + + // todo: add hook + + // Assign template variables + $template->assign_block_vars('styles_list', $row); + foreach($actions as $action) + { + $template->assign_block_vars('styles_list.actions', $action); + } + + // Increase counters + $counter = ($style['style_id']) ? ($style['style_active'] ? 'active' : 'inactive') : (empty($style['_available']) ? 'cannotinstall' : 'caninstall'); + if (!isset($this->style_counters)) + { + $this->style_counters = array( + 'total' => 0, + 'active' => 0, + 'inactive' => 0, + 'caninstall' => 0, + 'cannotinstall' => 0 + ); + } + $this->style_counters[$counter] ++; + $this->style_counters['total'] ++; + } + + /** + * Show welcome message + * + * @param string $title main title + * @param string $description page description + */ + function welcome_message($title, $description) + { + global $user, $template; + $template->assign_vars(array( + 'L_TITLE' => (isset($user->lang[$title])) ? $user->lang[$title] : $title, + 'L_EXPLAIN' => (isset($user->lang[$description])) ? $user->lang[$description] : $description + ) + ); + } + + /** + * Find all directories that have styles + * + * @returns array of directory names + */ + function find_style_dirs() + { + $styles = array(); + + $dp = @opendir($this->styles_path); + if ($dp) + { + while (($file = readdir($dp)) !== false) + { + $dir = $this->styles_path . $file; + if ($file[0] == '.' || !is_dir($dir)) + { + continue; + } + + if (file_exists("{$dir}/style.cfg")) + { + $styles[] = $file; + } + } + closedir($dp); + } + + return $styles; + } + + /** + * Sort styles + */ + function sort_styles($style1, $style2) + { + if ($style1['style_active'] != $style2['style_active']) + { + return ($style1['style_active']) ? -1 : 1; + } + if (isset($style1['_available']) && $style1['_available'] != $style2['_available']) + { + return ($style1['_available']) ? -1 : 1; + } + return strcasecmp(isset($style1['style_name']) ? $style1['style_name'] : $style1['name'], isset($style2['style_name']) ? $style2['style_name'] : $style2['name']); + } + + /** + * Read style configuration file + * + * @param string $dir style directory + * @returns array of style data + * @returns false on error + */ + function read_style_cfg($dir) + { + static $required = array('name', 'version', 'copyright'); + $cfg = parse_cfg_file($this->styles_path . $dir . '/style.cfg'); + + // Check if it is a valid file + foreach ($required as $key) + { + if (!isset($cfg[$key])) + { + return false; + } + } + + // Check data + if (!isset($cfg['parent']) || !is_string($cfg['parent']) || $cfg['parent'] == $cfg['name']) + { + $cfg['parent'] = ''; + } + if (!isset($cfg['template_bitfield'])) + { + $cfg['template_bitfield'] = $this->default_bitfield(); + } + + return $cfg; + } + + /** + * Install style + * + * @param $style style data + * @returns int style id + */ + function install_style($style) + { + global $db; + + // Generate row + $sql_ary = array(); + foreach ($style as $key => $value) + { + if ($key != 'style_id' && substr($key, 0, 1) != '_') + { + $sql_ary[$key] = $value; + } + } + + // Add to database + $db->sql_transaction('begin'); + + $sql = 'INSERT INTO ' . STYLES_TABLE . ' + ' . $db->sql_build_array('INSERT', $sql_ary); + $db->sql_query($sql); + + $id = $db->sql_nextid(); + + $db->sql_transaction('commit'); + + add_log('admin', 'LOG_STYLE_ADD', $sql_ary['style_name']); + + return $id; + } + + /** + * Lists all styles + * + * @returns array of rows with styles data + */ + function get_styles() + { + global $db; + + $sql = 'SELECT * + FROM ' . STYLES_TABLE; + $result = $db->sql_query($sql); + + $rows = $db->sql_fetchrowset($result); + $db->sql_freeresult($result); + + return $rows; + } + + /** + * Count users for each style + * + * @returns array of styles in following format: [style_id] = number of users + */ + function get_users() + { + global $db; + + $sql = 'SELECT user_style, COUNT(user_style) AS style_count + FROM ' . USERS_TABLE . ' + GROUP BY user_style'; + $result = $db->sql_query($sql); + + $style_count = array(); + while ($row = $db->sql_fetchrow($result)) + { + $style_count[$row['user_style']] = $row['style_count']; + } + $db->sql_freeresult($result); + + return $style_count; + } + + /** + * Delete style + * + * @param array $style Style data + * @returns true on success, error message on error + */ + function delete_style($style) + { + global $db, $user; + + $id = $style['style_id']; + $path = $style['style_path']; + + // Check if style has child styles + $sql = 'SELECT style_id + FROM ' . STYLES_TABLE . ' + WHERE style_parent_id = ' . $id . " OR style_parent_tree = '" . $db->sql_escape($path) . "'"; + $result = $db->sql_query($sql); + + $conflict = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if ($conflict !== false) + { + return sprintf($user->lang['STYLE_DELETE_DEPENDENT'], $style['style_name']); + } + + // Change default style for users + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_style = 0 + WHERE user_style = ' . $id; + $db->sql_query($sql); + + // Delete style + $sql = 'DELETE FROM ' . STYLES_TABLE . ' + WHERE style_id = ' . $id; + $db->sql_query($sql); + return true; + } + + /** + * Delete all files in style directory + * + * @param string $path Style directory + * @param string $dir Directory to remove inside style's directory + * @returns true on success, false on error + */ + function delete_style_files($path, $dir = '') + { + $dirname = $this->styles_path . $path . $dir; + $result = true; + + $dp = @opendir($dirname); + + if ($dp) + { + while (($file = readdir($dp)) !== false) + { + if ($file == '.' || $file == '..') + { + continue; + } + $filename = $dirname . '/' . $file; + if (is_dir($filename)) + { + if (!$this->delete_style_files($path, $dir . '/' . $file)) + { + $result = false; + } + } + else + { + if (!@unlink($filename)) + { + $result = false; + } + } + } + closedir($dp); + } + if (!@rmdir($dirname)) + { + return false; + } + + return $result; + } + + /** + * Get list of items from posted data + * + * @param string $name Variable name + * @param $default Default value for array: string or number + * @param bool $error If true, error will be triggered if list is empty + * @returns array of items + */ + function request_vars($name, $default, $error = false) + { + global $request, $user; + + $item = $request->variable($name, $default); + $items = $request->variable($name . 's', array($default)); + + if (count($items) == 1 && $items[0] == $default) + { + $items = array(); + } + + if ($item != $default && !count($items)) + { + $items[] = $item; + } + + if ($error && !count($items)) + { + trigger_error($user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); + } + + return $items; + } + + /** + * Generates hardcoded bitfield + * + * @returns bitfield string + */ + function default_bitfield() + { + static $value; + if(isset($value)) + { + return $value; + } + // Hardcoded template bitfield to add for new templates $bitfield = new bitfield(); $bitfield->set(0); @@ -42,2567 +1304,8 @@ class acp_styles $bitfield->set(9); $bitfield->set(11); $bitfield->set(12); - $this->template_bitfield = $bitfield->get_base64(); - unset($bitfield); - - $user->add_lang('acp/styles'); - - $this->tpl_name = 'acp_styles'; - $this->page_title = 'ACP_CAT_STYLES'; - - $action = request_var('action', ''); - $action = (isset($_POST['add'])) ? 'add' : $action; - $style_id = request_var('id', 0); - - // Fill the configuration variables - $this->style_cfg = $this->template_cfg = $this->theme_cfg = ' -# -# phpBB {MODE} configuration file -# -# @package phpBB3 -# @copyright (c) 2005 phpBB Group -# @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 -# -# -# At the left is the name, please do not change this -# At the right the value is entered -# For on/off options the valid values are on, off, 1, 0, true and false -# -# Values get trimmed, if you want to add a space in front or at the end of -# the value, then enclose the value with single or double quotes. -# Single and double quotes do not need to be escaped. -# -# - -# General Information about this {MODE} -name = {NAME} -copyright = {COPYRIGHT} -version = {VERSION} -'; - - $this->template_cfg .= ' -# Some configuration options - -# Template inheritance -# See http://blog.phpbb.com/2008/07/31/templating-just-got-easier/ -# Set value to empty or this template name to ignore template inheritance. -inherit_from = {INHERIT_FROM} -'; - - // Execute overall actions - switch ($action) - { - case 'delete': - if ($style_id) - { - $this->remove($mode, $style_id); - return; - } - break; - - case 'export': - if ($style_id) - { - $this->export($mode, $style_id); - return; - } - break; - - case 'install': - $this->install($mode); - return; - break; - - case 'add': - $this->add($mode); - return; - break; - - case 'details': - if ($style_id) - { - $this->details($mode, $style_id); - return; - } - break; - - case 'edit': - if ($style_id) - { - switch ($mode) - { - case 'template': - return $this->edit_template($style_id); - case 'theme': - return $this->edit_theme($style_id); - } - } - break; - - case 'cache': - if ($style_id) - { - switch ($mode) - { - case 'template': - return $this->template_cache($style_id); - } - } - break; - } - - switch ($mode) - { - case 'style': - - switch ($action) - { - case 'activate': - case 'deactivate': - - if ($style_id == $config['default_style']) - { - trigger_error($user->lang['DEACTIVATE_DEFAULT'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - if (($action == 'deactivate' && confirm_box(true)) || $action == 'activate') - { - $sql = 'UPDATE ' . STYLES_TABLE . ' - SET style_active = ' . (($action == 'activate') ? 1 : 0) . ' - WHERE style_id = ' . $style_id; - $db->sql_query($sql); - - // Set style to default for any member using deactivated style - if ($action == 'deactivate') - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_style = ' . $config['default_style'] . " - WHERE user_style = $style_id"; - $db->sql_query($sql); - - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET forum_style = 0 - WHERE forum_style = ' . $style_id; - $db->sql_query($sql); - } - } - else if ($action == 'deactivate') - { - $s_hidden_fields = array( - 'i' => $id, - 'mode' => $mode, - 'action' => $action, - 'style_id' => $style_id, - ); - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields)); - } - break; - } - - $this->frontend('style', array('details'), array('export', 'delete')); - break; - - case 'template': - - switch ($action) - { - // Clear cache - case 'refresh': - - $sql = 'SELECT * - FROM ' . STYLES_TEMPLATE_TABLE . " - WHERE template_id = $style_id"; - $result = $db->sql_query($sql); - $template_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$template_row) - { - trigger_error($user->lang['NO_TEMPLATE'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - if (confirm_box(true)) - { - $this->clear_template_cache($template_row); - - trigger_error($user->lang['TEMPLATE_CACHE_CLEARED'] . adm_back_link($this->u_action)); - } - else - { - confirm_box(false, $user->lang['CONFIRM_TEMPLATE_CLEAR_CACHE'], build_hidden_fields(array( - 'i' => $id, - 'mode' => $mode, - 'action' => $action, - 'id' => $style_id - ))); - } - - break; - } - - $this->frontend('template', array('edit', 'cache', 'details'), array('refresh', 'export', 'delete')); - break; - - case 'theme': - $this->frontend('theme', array('edit', 'details'), array('export', 'delete')); - break; - } + $value = $bitfield->get_base64(); + return $value; } - /** - * Build Frontend with supplied options - */ - function frontend($mode, $options, $actions) - { - global $user, $template, $db, $config, $phpbb_root_path, $phpEx; - - $sql_from = ''; - $sql_sort = 'LOWER(' . $mode . '_name)'; - $style_count = array(); - - switch ($mode) - { - case 'style': - $sql_from = STYLES_TABLE; - $sql_sort = 'style_active DESC, ' . $sql_sort; - - $sql = 'SELECT user_style, COUNT(user_style) AS style_count - FROM ' . USERS_TABLE . ' - GROUP BY user_style'; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $style_count[$row['user_style']] = $row['style_count']; - } - $db->sql_freeresult($result); - - break; - - case 'template': - $sql_from = STYLES_TEMPLATE_TABLE; - break; - - case 'theme': - $sql_from = STYLES_THEME_TABLE; - break; - - default: - trigger_error($user->lang['NO_MODE'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $l_prefix = strtoupper($mode); - - $this->page_title = 'ACP_' . $l_prefix . 'S'; - - $template->assign_vars(array( - 'S_FRONTEND' => true, - 'S_STYLE' => ($mode == 'style') ? true : false, - - 'L_TITLE' => $user->lang[$this->page_title], - 'L_EXPLAIN' => $user->lang[$this->page_title . '_EXPLAIN'], - 'L_NAME' => $user->lang[$l_prefix . '_NAME'], - 'L_INSTALLED' => $user->lang['INSTALLED_' . $l_prefix], - 'L_UNINSTALLED' => $user->lang['UNINSTALLED_' . $l_prefix], - 'L_NO_UNINSTALLED' => $user->lang['NO_UNINSTALLED_' . $l_prefix], - 'L_CREATE' => $user->lang['CREATE_' . $l_prefix], - - 'U_ACTION' => $this->u_action, - ) - ); - - $sql = "SELECT * - FROM $sql_from - ORDER BY $sql_sort ASC"; - $result = $db->sql_query($sql); - - $installed = array(); - - $basis_options = ''; - while ($row = $db->sql_fetchrow($result)) - { - $installed[] = $row[$mode . '_name']; - $basis_options .= ''; - - $stylevis = ($mode == 'style' && !$row['style_active']) ? 'activate' : 'deactivate'; - - $s_options = array(); - foreach ($options as $option) - { - $s_options[] = '' . $user->lang[strtoupper($option)] . ''; - } - - $s_actions = array(); - foreach ($actions as $option) - { - $s_actions[] = '' . $user->lang[strtoupper($option)] . ''; - } - - $template->assign_block_vars('installed', array( - 'S_DEFAULT_STYLE' => ($mode == 'style' && $row['style_id'] == $config['default_style']) ? true : false, - 'U_EDIT' => $this->u_action . '&action=' . (($mode == 'style') ? 'details' : 'edit') . '&id=' . $row[$mode . '_id'], - 'U_STYLE_ACT_DEACT' => $this->u_action . '&action=' . $stylevis . '&id=' . $row[$mode . '_id'], - 'L_STYLE_ACT_DEACT' => $user->lang['STYLE_' . strtoupper($stylevis)], - 'S_OPTIONS' => implode(' | ', $s_options), - 'S_ACTIONS' => implode(' | ', $s_actions), - 'U_PREVIEW' => ($mode == 'style') ? append_sid("{$phpbb_root_path}index.$phpEx", "$mode=" . $row[$mode . '_id']) : '', - - 'NAME' => $row[$mode . '_name'], - 'STYLE_COUNT' => ($mode == 'style' && isset($style_count[$row['style_id']])) ? $style_count[$row['style_id']] : 0, - - 'S_INACTIVE' => ($mode == 'style' && !$row['style_active']) ? true : false, - ) - ); - } - $db->sql_freeresult($result); - - // Grab uninstalled items - $new_ary = $cfg = array(); - - $dp = @opendir("{$phpbb_root_path}styles"); - - if ($dp) - { - while (($file = readdir($dp)) !== false) - { - if ($file[0] == '.' || !is_dir($phpbb_root_path . 'styles/' . $file)) - { - continue; - } - - $subpath = ($mode != 'style') ? "$mode/" : ''; - if (file_exists("{$phpbb_root_path}styles/$file/$subpath$mode.cfg")) - { - if ($cfg = file("{$phpbb_root_path}styles/$file/$subpath$mode.cfg")) - { - $items = parse_cfg_file('', $cfg); - $name = (isset($items['name'])) ? trim($items['name']) : false; - - if ($name && !in_array($name, $installed)) - { - $new_ary[] = array( - 'path' => $file, - 'name' => $name, - 'copyright' => $items['copyright'], - ); - } - } - } - } - closedir($dp); - } - - unset($installed); - - if (sizeof($new_ary)) - { - foreach ($new_ary as $cfg) - { - $template->assign_block_vars('uninstalled', array( - 'NAME' => $cfg['name'], - 'COPYRIGHT' => $cfg['copyright'], - 'U_INSTALL' => $this->u_action . '&action=install&path=' . urlencode($cfg['path'])) - ); - } - } - unset($new_ary); - - $template->assign_vars(array( - 'S_BASIS_OPTIONS' => $basis_options) - ); - - } - - /** - * Provides a template editor which allows saving changes to template files on the filesystem or in the database. - * - * @param int $template_id specifies which template set is being edited - */ - function edit_template($template_id) - { - global $phpbb_root_path, $phpEx, $config, $db, $cache, $user, $template, $safe_mode; - - if (defined('PHPBB_DISABLE_ACP_EDITOR')) - { - trigger_error($user->lang['EDITOR_DISABLED'] . adm_back_link($this->u_action)); - } - - $this->page_title = 'EDIT_TEMPLATE'; - - $filelist = $filelist_cats = array(); - - $template_data = utf8_normalize_nfc(request_var('template_data', '', true)); - $template_data = htmlspecialchars_decode($template_data); - $template_file = utf8_normalize_nfc(request_var('template_file', '', true)); - $text_rows = max(5, min(999, request_var('text_rows', 20))); - $save_changes = (isset($_POST['save'])) ? true : false; - - // make sure template_file path doesn't go upwards - $template_file = preg_replace('#\.{2,}#', '.', $template_file); - - // Retrieve some information about the template - $sql = 'SELECT template_path, template_name - FROM ' . STYLES_TEMPLATE_TABLE . " - WHERE template_id = $template_id"; - $result = $db->sql_query($sql); - $template_info = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$template_info) - { - trigger_error($user->lang['NO_TEMPLATE'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - // Get the filesystem location of the current file - $template_path = "{$phpbb_root_path}styles/{$template_info['template_path']}/template"; - $file = "$template_path/$template_file"; - - if ($template_file) - { - $l_not_writable = sprintf($user->lang['TEMPLATE_FILE_NOT_WRITABLE'], htmlspecialchars($template_file)) . adm_back_link($this->u_action); - - if ($safe_mode) - { - trigger_error($l_not_writable, E_USER_WARNING); - } - - if (file_exists($file) && is_file($file) && is_readable($file)) - { - if (!phpbb_is_writable($file)) - { - trigger_error($l_not_writable, E_USER_WARNING); - } - } - else - { - trigger_error($user->lang['NO_TEMPLATE'] . adm_back_link($this->u_action), E_USER_WARNING); - } - } - - if ($save_changes && !check_form_key('acp_styles')) - { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING); - } - else if (!$save_changes) - { - add_form_key('acp_styles'); - } - - // save changes to the template if the user submitted any - if ($save_changes && $template_file) - { - // Try to write the file - if (!($fp = @fopen($file, 'wb'))) - { - // File exists and is writeable, but still not able to be written to - trigger_error($l_not_writable, E_USER_WARNING); - } - fwrite($fp, $template_data); - fclose($fp); - - // destroy the cached version of the template (filename without extension) - $this->clear_template_cache($template_info, array(substr($template_file, 0, -5))); - - $cache->destroy('sql', STYLES_TABLE); - - add_log('admin', 'LOG_TEMPLATE_EDIT', $template_info['template_name'], $template_file); - trigger_error($user->lang['TEMPLATE_FILE_UPDATED'] . adm_back_link($this->u_action . "&action=edit&id=$template_id&text_rows=$text_rows&template_file=$template_file")); - } - - // Generate a category array containing template filenames - - $filelist = filelist($template_path, '', 'html'); - $filelist[''] = array_diff($filelist[''], array('bbcode.html')); - - if ($template_file) - { - $template_data = file_get_contents($file); - - if (!$template_data) - { - trigger_error($user->lang['NO_TEMPLATE'] . adm_back_link($this->u_action), E_USER_WARNING); - } - } - - if (empty($filelist[''])) - { - trigger_error($user->lang['NO_TEMPLATE'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - // Now create the categories - $filelist_cats[''] = array(); - foreach ($filelist as $pathfile => $file_ary) - { - // Use the directory name as category name - if (!empty($pathfile)) - { - $filelist_cats[$pathfile] = array(); - foreach ($file_ary as $file) - { - $filelist_cats[$pathfile][$pathfile . $file] = $file; - } - } - // or if it's in the main category use the word before the first underscore to group files - else - { - $cats = array(); - foreach ($file_ary as $file) - { - $cats[] = substr($file, 0, strpos($file, '_')); - $filelist_cats[substr($file, 0, strpos($file, '_'))][$file] = $file; - } - - $cats = array_values(array_unique($cats)); - - // we don't need any single element categories so put them into the misc '' category - for ($i = 0, $n = sizeof($cats); $i < $n; $i++) - { - if (sizeof($filelist_cats[$cats[$i]]) == 1 && $cats[$i] !== '') - { - $filelist_cats[''][key($filelist_cats[$cats[$i]])] = current($filelist_cats[$cats[$i]]); - unset($filelist_cats[$cats[$i]]); - } - } - unset($cats); - } - } - unset($filelist); - - // Generate list of categorised template files - $tpl_options = ''; - ksort($filelist_cats); - foreach ($filelist_cats as $category => $tpl_ary) - { - ksort($tpl_ary); - - if (!empty($category)) - { - $tpl_options .= ''; - } - - foreach ($tpl_ary as $filename => $file) - { - $selected = ($template_file == $filename) ? ' selected="selected"' : ''; - $tpl_options .= ''; - } - } - - $template->assign_vars(array( - 'S_EDIT_TEMPLATE' => true, - 'S_HIDDEN_FIELDS' => build_hidden_fields(array('template_file' => $template_file)), - 'S_TEMPLATES' => $tpl_options, - - 'U_ACTION' => $this->u_action . "&action=edit&id=$template_id&text_rows=$text_rows", - 'U_BACK' => $this->u_action, - - 'L_EDIT' => $user->lang['EDIT_TEMPLATE'], - 'L_EDIT_EXPLAIN' => $user->lang['EDIT_TEMPLATE_EXPLAIN'], - 'L_EDITOR' => $user->lang['TEMPLATE_EDITOR'], - 'L_EDITOR_HEIGHT' => $user->lang['TEMPLATE_EDITOR_HEIGHT'], - 'L_FILE' => $user->lang['TEMPLATE_FILE'], - 'L_SELECT' => $user->lang['SELECT_TEMPLATE'], - 'L_SELECTED' => $user->lang['SELECTED_TEMPLATE'], - 'L_SELECTED_FILE' => $user->lang['SELECTED_TEMPLATE_FILE'], - - 'SELECTED_TEMPLATE' => $template_info['template_name'], - 'TEMPLATE_FILE' => $template_file, - 'TEMPLATE_DATA' => utf8_htmlspecialchars($template_data), - 'TEXT_ROWS' => $text_rows) - ); - } - - /** - * Allows the admin to view cached versions of template files and clear single template cache files - * - * @param int $template_id specifies which template's cache is shown - */ - function template_cache($template_id) - { - global $phpbb_root_path, $phpEx, $config, $db, $cache, $user, $template; - - $source = str_replace('/', '.', request_var('source', '')); - $file_ary = array_diff(request_var('delete', array('')), array('')); - $submit = isset($_POST['submit']) ? true : false; - - $sql = 'SELECT * - FROM ' . STYLES_TEMPLATE_TABLE . " - WHERE template_id = $template_id"; - $result = $db->sql_query($sql); - $template_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$template_row) - { - trigger_error($user->lang['NO_TEMPLATE'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - // User wants to delete one or more files ... - if ($submit && $file_ary) - { - $this->clear_template_cache($template_row, $file_ary); - trigger_error($user->lang['TEMPLATE_CACHE_CLEARED'] . adm_back_link($this->u_action . "&action=cache&id=$template_id")); - } - - $cache_prefix = 'tpl_' . str_replace('_', '-', $template_row['template_path']); - - // Someone wants to see the cached source ... so we'll highlight it, - // add line numbers and indent it appropriately. This could be nasty - // on larger source files ... - if ($source && file_exists("{$phpbb_root_path}cache/{$cache_prefix}_$source.html.$phpEx")) - { - adm_page_header($user->lang['TEMPLATE_CACHE']); - - $template->set_filenames(array( - 'body' => 'viewsource.html') - ); - - $template->assign_vars(array( - 'FILENAME' => str_replace('.', '/', $source) . '.html') - ); - - $code = str_replace(array("\r\n", "\r"), array("\n", "\n"), file_get_contents("{$phpbb_root_path}cache/{$cache_prefix}_$source.html.$phpEx")); - - $conf = array('highlight.bg', 'highlight.comment', 'highlight.default', 'highlight.html', 'highlight.keyword', 'highlight.string'); - foreach ($conf as $ini_var) - { - @ini_set($ini_var, str_replace('highlight.', 'syntax', $ini_var)); - } - - $marker = 'MARKER' . time(); - $code = highlight_string(str_replace("\n", $marker, $code), true); - $code = str_replace($marker, "\n", $code); - $str_from = array('', '', '','[', ']', '.', ':'); - $str_to = array('', '', '', '[', ']', '.', ':'); - - $code = str_replace($str_from, $str_to, $code); - $code = preg_replace('#^()\n?(.*?)\n?()$#ism', '$1$2$3', $code); - $code = substr($code, strlen('')); - $code = substr($code, 0, -1 * strlen('')); - $code = explode("\n", $code); - - foreach ($code as $key => $line) - { - $template->assign_block_vars('source', array( - 'LINENUM' => $key + 1, - 'LINE' => preg_replace('#([^ ;]) ([^ &])#', '$1 $2', $line)) - ); - unset($code[$key]); - } - - adm_page_footer(); - } - - // Get a list of cached template files and then retrieve additional information about them - $file_ary = $this->template_cache_filelist($template_row['template_path']); - - foreach ($file_ary as $file) - { - $file = str_replace('/', '.', $file); - - // perform some dirty guessing to get the path right. - // We assume that three dots in a row were '../' - $tpl_file = str_replace('.', '/', $file); - $tpl_file = str_replace('///', '../', $tpl_file); - - $filename = "{$cache_prefix}_$file.html.$phpEx"; - - if (!file_exists("{$phpbb_root_path}cache/$filename")) - { - continue; - } - - $file_tpl = "{$phpbb_root_path}styles/{$template_row['template_path']}/template/$tpl_file.html"; - $inherited = false; - - if (isset($template_row['template_inherits_id']) && $template_row['template_inherits_id'] && !file_exists($file_tpl)) - { - $file_tpl = "{$phpbb_root_path}styles/{$template_row['template_inherit_path']}/template/$tpl_file.html"; - $inherited = true; - } - - $template->assign_block_vars('file', array( - 'U_VIEWSOURCE' => $this->u_action . "&action=cache&id=$template_id&source=$file", - - 'CACHED' => $user->format_date(filemtime("{$phpbb_root_path}cache/$filename")), - 'FILENAME' => $file, - 'FILENAME_PATH' => $file_tpl, - 'FILESIZE' => get_formatted_filesize(filesize("{$phpbb_root_path}cache/$filename")), - 'MODIFIED' => $user->format_date(filemtime($file_tpl)), - )); - } - - $template->assign_vars(array( - 'S_CACHE' => true, - 'S_TEMPLATE' => true, - - 'U_ACTION' => $this->u_action . "&action=cache&id=$template_id", - 'U_BACK' => $this->u_action) - ); - } - - /** - * Provides a css editor and a basic easier to use stylesheet editing tool for less experienced (or lazy) users - * - * @param int $theme_id specifies which theme is being edited - */ - function edit_theme($theme_id) - { - global $phpbb_root_path, $phpEx, $config, $db, $cache, $user, $template, $safe_mode; - - $this->page_title = 'EDIT_THEME'; - - $filelist = $filelist_cats = array(); - - $theme_data = utf8_normalize_nfc(request_var('template_data', '', true)); - $theme_data = htmlspecialchars_decode($theme_data); - $theme_file = utf8_normalize_nfc(request_var('template_file', '', true)); - $text_rows = max(5, min(999, request_var('text_rows', 20))); - $save_changes = (isset($_POST['save'])) ? true : false; - - // make sure theme_file path doesn't go upwards - $theme_file = str_replace('..', '.', $theme_file); - - // Retrieve some information about the theme - $sql = 'SELECT theme_path, theme_name - FROM ' . STYLES_THEME_TABLE . " - WHERE theme_id = $theme_id"; - $result = $db->sql_query($sql); - - if (!($theme_info = $db->sql_fetchrow($result))) - { - trigger_error($user->lang['NO_THEME'] . adm_back_link($this->u_action), E_USER_WARNING); - } - $db->sql_freeresult($result); - - // Get the filesystem location of the current file - $theme_path = "{$phpbb_root_path}styles/{$theme_info['theme_path']}/theme"; - $file = "$theme_path/$theme_file"; - - if ($theme_file) - { - $l_not_writable = sprintf($user->lang['THEME_FILE_NOT_WRITABLE'], htmlspecialchars($theme_file)) . adm_back_link($this->u_action); - - if ($safe_mode) - { - trigger_error($l_not_writable, E_USER_WARNING); - } - - if (file_exists($file) && is_file($file) && is_readable($file)) - { - if (!phpbb_is_writable($file)) - { - trigger_error($l_not_writable, E_USER_WARNING); - } - } - else - { - trigger_error($user->lang['NO_THEME'] . adm_back_link($this->u_action), E_USER_WARNING); - } - } - - // save changes to the theme if the user submitted any - if ($save_changes && $theme_file) - { - $message = $user->lang['THEME_UPDATED']; - - if (!($fp = @fopen($file, 'wb'))) - { - trigger_error($l_not_writable, E_USER_WARNING); - } - fwrite($fp, $theme_data); - fclose($fp); - - $cache->destroy('sql', STYLES_THEME_TABLE); - add_log('admin', 'LOG_THEME_EDIT_FILE', $theme_info['theme_name'], $theme_file); - - trigger_error($message . adm_back_link($this->u_action . "&action=edit&id=$theme_id&template_file=$theme_file&text_rows=$text_rows")); - } - - // Generate a category array containing theme filenames - $filelist = filelist($theme_path, '', 'css'); - - if ($theme_file) - { - $theme_data = file_get_contents($file); - - if (!$theme_data) - { - trigger_error($user->lang['NO_THEME'] . adm_back_link($this->u_action), E_USER_WARNING); - } - } - - // Now create the categories - $filelist_cats[''] = array(); - foreach ($filelist as $pathfile => $file_ary) - { - // Use the directory name as category name - if (!empty($pathfile)) - { - $filelist_cats[$pathfile] = array(); - foreach ($file_ary as $file) - { - $filelist_cats[$pathfile][$pathfile . $file] = $file; - } - } - // or if it's in the main category use the word before the first underscore to group files - else - { - $cats = array(); - foreach ($file_ary as $file) - { - $cats[] = substr($file, 0, strpos($file, '_')); - $filelist_cats[substr($file, 0, strpos($file, '_'))][$file] = $file; - } - - $cats = array_values(array_unique($cats)); - - // we don't need any single element categories so put them into the misc '' category - for ($i = 0, $n = sizeof($cats); $i < $n; $i++) - { - if (sizeof($filelist_cats[$cats[$i]]) == 1 && $cats[$i] !== '') - { - $filelist_cats[''][key($filelist_cats[$cats[$i]])] = current($filelist_cats[$cats[$i]]); - unset($filelist_cats[$cats[$i]]); - } - } - unset($cats); - } - } - unset($filelist); - - // Generate list of categorised theme files - $tpl_options = ''; - ksort($filelist_cats); - foreach ($filelist_cats as $category => $tpl_ary) - { - ksort($tpl_ary); - - if (!empty($category)) - { - $tpl_options .= ''; - } - - foreach ($tpl_ary as $filename => $file) - { - $selected = ($theme_file == $filename) ? ' selected="selected"' : ''; - $tpl_options .= ''; - } - } - - $template->assign_vars(array( - 'S_EDIT_THEME' => true, - 'S_HIDDEN_FIELDS' => build_hidden_fields(array('template_file' => $theme_file)), - 'S_TEMPLATES' => $tpl_options, - - 'U_ACTION' => $this->u_action . "&action=edit&id=$theme_id&text_rows=$text_rows", - 'U_BACK' => $this->u_action, - - 'L_EDIT' => $user->lang['EDIT_THEME'], - 'L_EDIT_EXPLAIN' => $user->lang['EDIT_THEME_EXPLAIN'], - 'L_EDITOR' => $user->lang['THEME_EDITOR'], - 'L_EDITOR_HEIGHT' => $user->lang['THEME_EDITOR_HEIGHT'], - 'L_FILE' => $user->lang['THEME_FILE'], - 'L_SELECT' => $user->lang['SELECT_THEME'], - 'L_SELECTED' => $user->lang['SELECTED_THEME'], - 'L_SELECTED_FILE' => $user->lang['SELECTED_THEME_FILE'], - - 'SELECTED_TEMPLATE' => $theme_info['theme_name'], - 'TEMPLATE_FILE' => $theme_file, - 'TEMPLATE_DATA' => utf8_htmlspecialchars($theme_data), - 'TEXT_ROWS' => $text_rows, - )); - } - - /** - * Remove style/template/theme - */ - function remove($mode, $style_id) - { - global $db, $template, $user, $phpbb_root_path, $cache, $config; - - $new_id = request_var('new_id', 0); - $update = (isset($_POST['update'])) ? true : false; - $sql_where = ''; - - switch ($mode) - { - case 'style': - $sql_from = STYLES_TABLE; - $sql_select = 'style_id, style_name, template_id, theme_id'; - $sql_where = 'AND style_active = 1'; - break; - - case 'template': - $sql_from = STYLES_TEMPLATE_TABLE; - $sql_select = 'template_id, template_name, template_path'; - break; - - case 'theme': - $sql_from = STYLES_THEME_TABLE; - $sql_select = 'theme_id, theme_name, theme_path'; - break; - } - - if ($mode === 'template' && ($conflicts = $this->check_inheritance($mode, $style_id))) - { - $l_type = strtoupper($mode); - $msg = $user->lang[$l_type . '_DELETE_DEPENDENT']; - foreach ($conflicts as $id => $values) - { - $msg .= '
' . $values['template_name']; - } - - trigger_error($msg . adm_back_link($this->u_action), E_USER_WARNING); - } - - $l_prefix = strtoupper($mode); - - $sql = "SELECT $sql_select - FROM $sql_from - WHERE {$mode}_id = $style_id"; - $result = $db->sql_query($sql); - $style_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$style_row) - { - trigger_error($user->lang['NO_' . $l_prefix] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $s_only_component = $this->display_component_options($mode, $style_row[$mode . '_id'], $style_row); - - if ($s_only_component) - { - trigger_error($user->lang['ONLY_' . $l_prefix] . adm_back_link($this->u_action), E_USER_WARNING); - } - - if ($update) - { - if ($mode == 'style') - { - $sql = "DELETE FROM $sql_from - WHERE {$mode}_id = $style_id"; - $db->sql_query($sql); - - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_style = $new_id - WHERE user_style = $style_id"; - $db->sql_query($sql); - - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET forum_style = $new_id - WHERE forum_style = $style_id"; - $db->sql_query($sql); - - if ($style_id == $config['default_style']) - { - set_config('default_style', $new_id); - } - - // Remove the components - $components = array('template', 'theme'); - foreach ($components as $component) - { - $new_id = request_var('new_' . $component . '_id', 0); - $component_id = $style_row[$component . '_id']; - $this->remove_component($component, $component_id, $new_id, $style_id); - } - } - else - { - $this->remove_component($mode, $style_id, $new_id); - } - - $cache->destroy('sql', STYLES_TABLE); - - add_log('admin', 'LOG_' . $l_prefix . '_DELETE', $style_row[$mode . '_name']); - $message = ($mode != 'style') ? $l_prefix . '_DELETED_FS' : $l_prefix . '_DELETED'; - trigger_error($user->lang[$message] . adm_back_link($this->u_action)); - } - - $this->page_title = 'DELETE_' . $l_prefix; - - $template->assign_vars(array( - 'S_DELETE' => true, - - 'L_TITLE' => $user->lang[$this->page_title], - 'L_EXPLAIN' => $user->lang[$this->page_title . '_EXPLAIN'], - 'L_NAME' => $user->lang[$l_prefix . '_NAME'], - 'L_REPLACE' => $user->lang['REPLACE_' . $l_prefix], - 'L_REPLACE_EXPLAIN' => $user->lang['REPLACE_' . $l_prefix . '_EXPLAIN'], - - 'U_ACTION' => $this->u_action . "&action=delete&id=$style_id", - 'U_BACK' => $this->u_action, - - 'NAME' => $style_row[$mode . '_name'], - ) - ); - - if ($mode == 'style') - { - $template->assign_vars(array( - 'S_DELETE_STYLE' => true, - )); - } - } - - /** - * Remove template/theme entry from the database - */ - function remove_component($component, $component_id, $new_id, $style_id = false) - { - global $db; - - if (($new_id == 0) || ($component === 'template' && ($conflicts = $this->check_inheritance($component, $component_id)))) - { - // We can not delete the template, as the user wants to keep the component or an other template is inheriting from this one. - return; - } - - $component_in_use = array(); - if ($component != 'style') - { - $component_in_use = $this->component_in_use($component, $component_id, $style_id); - } - - if (($new_id == -1) && !empty($component_in_use)) - { - // We can not delete the component, as it is still in use - return; - } - - switch ($component) - { - case 'template': - $sql_from = STYLES_TEMPLATE_TABLE; - break; - - case 'theme': - $sql_from = STYLES_THEME_TABLE; - break; - } - - $sql = "DELETE FROM $sql_from - WHERE {$component}_id = $component_id"; - $db->sql_query($sql); - - $sql = 'UPDATE ' . STYLES_TABLE . " - SET {$component}_id = $new_id - WHERE {$component}_id = $component_id"; - $db->sql_query($sql); - } - - /** - * Display the options which can be used to replace a style/template/theme - * - * @return boolean Returns true if the component is the only component and can not be deleted. - */ - function display_component_options($component, $component_id, $style_row = false, $style_id = false) - { - global $db, $template, $user; - - $is_only_component = true; - $component_in_use = array(); - if ($component != 'style') - { - $component_in_use = $this->component_in_use($component, $component_id, $style_id); - } - - $sql_where = ''; - switch ($component) - { - case 'style': - $sql_from = STYLES_TABLE; - $sql_where = 'WHERE style_active = 1'; - break; - - case 'template': - $sql_from = STYLES_TEMPLATE_TABLE; - $sql_where = 'WHERE template_inherits_id <> ' . $component_id; - break; - - case 'theme': - $sql_from = STYLES_THEME_TABLE; - break; - } - - $s_options = ''; - if (($component != 'style') && empty($component_in_use)) - { - // If it is not in use, there must be another component - $is_only_component = false; - - $sql = "SELECT {$component}_id, {$component}_name - FROM $sql_from - WHERE {$component}_id = {$component_id}"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $s_options .= ''; - $s_options .= ''; - } - else - { - $sql = "SELECT {$component}_id, {$component}_name - FROM $sql_from - $sql_where - ORDER BY {$component}_name ASC"; - $result = $db->sql_query($sql); - - $s_keep_option = $s_options = ''; - while ($row = $db->sql_fetchrow($result)) - { - if ($row[$component . '_id'] != $component_id) - { - $is_only_component = false; - $s_options .= ''; - } - else if ($component != 'style') - { - $s_keep_option = ''; - } - } - $db->sql_freeresult($result); - $s_options = $s_keep_option . $s_options; - } - - if (!$style_row) - { - $template->assign_var('S_REPLACE_' . strtoupper($component) . '_OPTIONS', $s_options); - } - else - { - $template->assign_var('S_REPLACE_OPTIONS', $s_options); - if ($component == 'style') - { - $components = array('template', 'theme'); - foreach ($components as $component) - { - $this->display_component_options($component, $style_row[$component . '_id'], false, $component_id, true); - } - } - } - - return $is_only_component; - } - - /** - * Check whether the component is still used by another style or component - */ - function component_in_use($component, $component_id, $style_id = false) - { - global $db; - - $component_in_use = array(); - - if ($style_id) - { - $sql = 'SELECT style_id, style_name - FROM ' . STYLES_TABLE . " - WHERE {$component}_id = {$component_id} - AND style_id <> {$style_id} - ORDER BY style_name ASC"; - } - else - { - $sql = 'SELECT style_id, style_name - FROM ' . STYLES_TABLE . " - WHERE {$component}_id = {$component_id} - ORDER BY style_name ASC"; - } - $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) - { - $component_in_use[] = $row['style_name']; - } - $db->sql_freeresult($result); - - if ($component === 'template' && ($conflicts = $this->check_inheritance($component, $component_id))) - { - foreach ($conflicts as $temp_id => $conflict_data) - { - $component_in_use[] = $conflict_data['template_name']; - } - } - - return $component_in_use; - } - - /** - * Export style or style elements - */ - function export($mode, $style_id) - { - global $db, $template, $user, $phpbb_root_path, $cache, $phpEx, $config; - - $update = (isset($_POST['update'])) ? true : false; - - $inc_template = request_var('inc_template', 0); - $inc_theme = request_var('inc_theme', 0); - $store = request_var('store', 0); - $format = request_var('format', ''); - - $error = array(); - $methods = array('tar'); - - $available_methods = array('tar.gz' => 'zlib', 'tar.bz2' => 'bz2', 'zip' => 'zlib'); - foreach ($available_methods as $type => $module) - { - if (!@extension_loaded($module)) - { - continue; - } - - $methods[] = $type; - } - - if (!in_array($format, $methods)) - { - $format = 'tar'; - } - - switch ($mode) - { - case 'style': - if ($update && ($inc_template + $inc_theme) < 1) - { - $error[] = $user->lang['STYLE_ERR_MORE_ELEMENTS']; - } - - $name = 'style_name'; - - $sql_select = 's.style_id, s.style_name, s.style_copyright'; - $sql_select .= ($inc_template) ? ', t.*' : ', t.template_name'; - $sql_select .= ($inc_theme) ? ', c.*' : ', c.theme_name'; - $sql_from = STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c'; - $sql_where = "s.style_id = $style_id AND t.template_id = s.template_id AND c.theme_id = s.theme_id"; - - $l_prefix = 'STYLE'; - break; - - case 'template': - $name = 'template_name'; - - $sql_select = '*'; - $sql_from = STYLES_TEMPLATE_TABLE; - $sql_where = "template_id = $style_id"; - - $l_prefix = 'TEMPLATE'; - break; - - case 'theme': - $name = 'theme_name'; - - $sql_select = '*'; - $sql_from = STYLES_THEME_TABLE; - $sql_where = "theme_id = $style_id"; - - $l_prefix = 'THEME'; - break; - } - - if ($update && !sizeof($error)) - { - $sql = "SELECT $sql_select - FROM $sql_from - WHERE $sql_where"; - $result = $db->sql_query($sql); - $style_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$style_row) - { - trigger_error($user->lang['NO_' . $l_prefix] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $var_ary = array('style_id', 'style_name', 'style_copyright', 'template_id', 'template_name', 'template_path', 'template_copyright', 'template_inherits_id', 'bbcode_bitfield', 'theme_id', 'theme_name', 'theme_path', 'theme_copyright'); - - foreach ($var_ary as $var) - { - if (!isset($style_row[$var])) - { - $style_row[$var] = ''; - } - } - - $files = $data = array(); - - if ($mode == 'style') - { - $style_cfg = str_replace(array('{MODE}', '{NAME}', '{COPYRIGHT}', '{VERSION}'), array($mode, $style_row['style_name'], $style_row['style_copyright'], $config['version']), $this->style_cfg); - - $style_cfg .= (!$inc_template) ? "\nrequired_template = {$style_row['template_name']}" : ''; - $style_cfg .= (!$inc_theme) ? "\nrequired_theme = {$style_row['theme_name']}" : ''; - - $data[] = array( - 'src' => $style_cfg, - 'prefix' => 'style.cfg' - ); - - unset($style_cfg); - } - - // Export template core code - if ($mode == 'template' || $inc_template) - { - $use_template_name = $style_row['template_name']; - - // Add the inherit from variable, depending on it's use... - if ($style_row['template_inherits_id']) - { - // Get the template name - $sql = 'SELECT template_name - FROM ' . STYLES_TEMPLATE_TABLE . ' - WHERE template_id = ' . (int) $style_row['template_inherits_id']; - $result = $db->sql_query($sql); - $use_template_name = (string) $db->sql_fetchfield('template_name'); - $db->sql_freeresult($result); - } - - $template_cfg = str_replace(array('{MODE}', '{NAME}', '{COPYRIGHT}', '{VERSION}', '{INHERIT_FROM}'), array($mode, $style_row['template_name'], $style_row['template_copyright'], $config['version'], $use_template_name), $this->template_cfg); - - $template_cfg .= "\n\nbbcode_bitfield = {$style_row['bbcode_bitfield']}"; - - $data[] = array( - 'src' => $template_cfg, - 'prefix' => 'template/template.cfg' - ); - - // This is potentially nasty memory-wise ... - $files[] = array( - 'src' => "styles/{$style_row['template_path']}/template/", - 'prefix-' => "styles/{$style_row['template_path']}/", - 'prefix+' => false, - 'exclude' => 'template.cfg' - ); - unset($template_cfg); - } - - // Export theme core code - if ($mode == 'theme' || $inc_theme) - { - $theme_cfg = str_replace(array('{MODE}', '{NAME}', '{COPYRIGHT}', '{VERSION}'), array($mode, $style_row['theme_name'], $style_row['theme_copyright'], $config['version']), $this->theme_cfg); - - // Read old cfg file - $items = $cache->obtain_cfg_items($style_row); - $items = $items['theme']; - - $files[] = array( - 'src' => "styles/{$style_row['theme_path']}/theme/", - 'prefix-' => "styles/{$style_row['theme_path']}/", - 'prefix+' => false, - 'exclude' => 'theme.cfg', - ); - - $data[] = array( - 'src' => $theme_cfg, - 'prefix' => 'theme/theme.cfg', - ); - - unset($items, $theme_cfg); - } - - switch ($format) - { - case 'tar': - $ext = '.tar'; - break; - - case 'zip': - $ext = '.zip'; - break; - - case 'tar.gz': - $ext = '.tar.gz'; - break; - - case 'tar.bz2': - $ext = '.tar.bz2'; - break; - - default: - $error[] = $user->lang[$l_prefix . '_ERR_ARCHIVE']; - } - - if (!sizeof($error)) - { - include($phpbb_root_path . 'includes/functions_compress.' . $phpEx); - - if ($mode == 'style') - { - $path = preg_replace('#[^\w-]+#', '_', $style_row['style_name']); - } - else - { - $path = $style_row[$mode . '_path']; - } - - if ($format == 'zip') - { - $compress = new compress_zip('w', $phpbb_root_path . "store/$path$ext"); - } - else - { - $compress = new compress_tar('w', $phpbb_root_path . "store/$path$ext", $ext); - } - - if (sizeof($files)) - { - foreach ($files as $file_ary) - { - $compress->add_file($file_ary['src'], $file_ary['prefix-'], $file_ary['prefix+'], $file_ary['exclude']); - } - } - - if (sizeof($data)) - { - foreach ($data as $data_ary) - { - $compress->add_data($data_ary['src'], $data_ary['prefix']); - } - } - - $compress->close(); - - add_log('admin', 'LOG_' . $l_prefix . '_EXPORT', $style_row[$mode . '_name']); - - if (!$store) - { - $compress->download($path); - @unlink("{$phpbb_root_path}store/$path$ext"); - exit; - } - - trigger_error(sprintf($user->lang[$l_prefix . '_EXPORTED'], "store/$path$ext") . adm_back_link($this->u_action)); - } - } - - $sql = "SELECT {$mode}_id, {$mode}_name - FROM " . (($mode == 'style') ? STYLES_TABLE : $sql_from) . " - WHERE {$mode}_id = $style_id"; - $result = $db->sql_query($sql); - $style_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$style_row) - { - trigger_error($user->lang['NO_' . $l_prefix] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $this->page_title = $l_prefix . '_EXPORT'; - - $format_buttons = ''; - foreach ($methods as $method) - { - $format_buttons .= ''; - } - - $template->assign_vars(array( - 'S_EXPORT' => true, - 'S_ERROR_MSG' => (sizeof($error)) ? true : false, - 'S_STYLE' => ($mode == 'style') ? true : false, - - 'L_TITLE' => $user->lang[$this->page_title], - 'L_EXPLAIN' => $user->lang[$this->page_title . '_EXPLAIN'], - 'L_NAME' => $user->lang[$l_prefix . '_NAME'], - - 'U_ACTION' => $this->u_action . '&action=export&id=' . $style_id, - 'U_BACK' => $this->u_action, - - 'ERROR_MSG' => (sizeof($error)) ? implode('
', $error) : '', - 'NAME' => $style_row[$mode . '_name'], - 'FORMAT_BUTTONS' => $format_buttons) - ); - } - - /** - * Display details - */ - function details($mode, $style_id) - { - global $template, $db, $config, $user, $safe_mode, $cache, $phpbb_root_path; - - $update = (isset($_POST['update'])) ? true : false; - $l_type = strtoupper($mode); - - $error = array(); - $element_ary = array('template' => STYLES_TEMPLATE_TABLE, 'theme' => STYLES_THEME_TABLE); - - switch ($mode) - { - case 'style': - $sql_from = STYLES_TABLE; - break; - - case 'template': - $sql_from = STYLES_TEMPLATE_TABLE; - break; - - case 'theme': - $sql_from = STYLES_THEME_TABLE; - break; - } - - $sql = "SELECT * - FROM $sql_from - WHERE {$mode}_id = $style_id"; - $result = $db->sql_query($sql); - $style_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$style_row) - { - trigger_error($user->lang['NO_' . $l_type] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $style_row['style_default'] = ($mode == 'style' && $config['default_style'] == $style_id) ? 1 : 0; - - if ($update) - { - $name = utf8_normalize_nfc(request_var('name', '', true)); - $copyright = utf8_normalize_nfc(request_var('copyright', '', true)); - - $template_id = request_var('template_id', 0); - $theme_id = request_var('theme_id', 0); - - $style_active = request_var('style_active', 0); - $style_default = request_var('style_default', 0); - - // If the admin selected the style to be the default style, but forgot to activate it... we will do it for him - if ($style_default) - { - $style_active = 1; - } - - $sql = "SELECT {$mode}_id, {$mode}_name - FROM $sql_from - WHERE {$mode}_id <> $style_id - AND LOWER({$mode}_name) = '" . $db->sql_escape(strtolower($name)) . "'"; - $result = $db->sql_query($sql); - $conflict = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($mode == 'style' && (!$template_id || !$theme_id)) - { - $error[] = $user->lang['STYLE_ERR_NO_IDS']; - } - - if ($mode == 'style' && $style_row['style_active'] && !$style_active && $config['default_style'] == $style_id) - { - $error[] = $user->lang['DEACTIVATE_DEFAULT']; - } - - if (!$name || $conflict) - { - $error[] = $user->lang[$l_type . '_ERR_STYLE_NAME']; - } - - if (!sizeof($error)) - { - // Check length settings - if (utf8_strlen($name) > 30) - { - $error[] = $user->lang[$l_type . '_ERR_NAME_LONG']; - } - - if (utf8_strlen($copyright) > 60) - { - $error[] = $user->lang[$l_type . '_ERR_COPY_LONG']; - } - } - } - - if ($update && sizeof($error)) - { - $style_row = array_merge($style_row, array( - 'template_id' => $template_id, - 'theme_id' => $theme_id, - 'style_active' => $style_active, - $mode . '_name' => $name, - $mode . '_copyright' => $copyright) - ); - } - - // User has submitted form and no errors have occurred - if ($update && !sizeof($error)) - { - $sql_ary = array( - $mode . '_name' => $name, - $mode . '_copyright' => $copyright - ); - - switch ($mode) - { - case 'style': - - $sql_ary += array( - 'template_id' => (int) $template_id, - 'theme_id' => (int) $theme_id, - 'style_active' => (int) $style_active, - ); - break; - - case 'theme': - break; - - case 'template': - break; - } - - if (sizeof($sql_ary)) - { - $sql = "UPDATE $sql_from - SET " . $db->sql_build_array('UPDATE', $sql_ary) . " - WHERE {$mode}_id = $style_id"; - $db->sql_query($sql); - - // Making this the default style? - if ($mode == 'style' && $style_default) - { - set_config('default_style', $style_id); - } - } - - $cache->destroy('sql', STYLES_TABLE); - - add_log('admin', 'LOG_' . $l_type . '_EDIT_DETAILS', $name); - if (sizeof($error)) - { - trigger_error(implode('
', $error) . adm_back_link($this->u_action), E_USER_WARNING); - } - else - { - trigger_error($user->lang[$l_type . '_DETAILS_UPDATED'] . adm_back_link($this->u_action)); - } - } - - if ($mode == 'style') - { - foreach ($element_ary as $element => $table) - { - $sql = "SELECT {$element}_id, {$element}_name - FROM $table - ORDER BY {$element}_id ASC"; - $result = $db->sql_query($sql); - - ${$element . '_options'} = ''; - while ($row = $db->sql_fetchrow($result)) - { - $selected = ($row[$element . '_id'] == $style_row[$element . '_id']) ? ' selected="selected"' : ''; - ${$element . '_options'} .= ''; - } - $db->sql_freeresult($result); - } - } - - if ($mode == 'template') - { - $super = array(); - if (isset($style_row[$mode . '_inherits_id']) && $style_row['template_inherits_id']) - { - $super = $this->get_super($mode, $style_row['template_id']); - } - } - - $this->page_title = 'EDIT_DETAILS_' . $l_type; - - $template->assign_vars(array( - 'S_DETAILS' => true, - 'S_ERROR_MSG' => (sizeof($error)) ? true : false, - 'S_STYLE' => ($mode == 'style') ? true : false, - 'S_TEMPLATE' => ($mode == 'template') ? true : false, - 'S_THEME' => ($mode == 'theme') ? true : false, - 'S_STYLE_ACTIVE' => (isset($style_row['style_active'])) ? $style_row['style_active'] : 0, - 'S_STYLE_DEFAULT' => (isset($style_row['style_default'])) ? $style_row['style_default'] : 0, - 'S_SUPERTEMPLATE' => (isset($style_row[$mode . '_inherits_id']) && $style_row[$mode . '_inherits_id']) ? $super['template_name'] : 0, - - 'S_TEMPLATE_OPTIONS' => ($mode == 'style') ? $template_options : '', - 'S_THEME_OPTIONS' => ($mode == 'style') ? $theme_options : '', - - 'U_ACTION' => $this->u_action . '&action=details&id=' . $style_id, - 'U_BACK' => $this->u_action, - - 'L_TITLE' => $user->lang[$this->page_title], - 'L_EXPLAIN' => $user->lang[$this->page_title . '_EXPLAIN'], - 'L_NAME' => $user->lang[$l_type . '_NAME'], - - 'ERROR_MSG' => (sizeof($error)) ? implode('
', $error) : '', - 'NAME' => $style_row[$mode . '_name'], - 'COPYRIGHT' => $style_row[$mode . '_copyright'], - ) - ); - } - - /** - * Load css file contents - */ - function load_css_file($path, $filename) - { - global $phpbb_root_path; - - $file = "{$phpbb_root_path}styles/$path/theme/$filename"; - - if (file_exists($file) && ($content = file_get_contents($file))) - { - $content = trim($content); - } - else - { - $content = ''; - } - if (defined('DEBUG')) - { - $content = "/* BEGIN @include $filename */ \n $content \n /* END @include $filename */ \n"; - } - - return $content; - } - - /** - * Returns a string containing the value that should be used for the theme_data column in the theme database table. - * Includes contents of files loaded via @import - * - * @param array $theme_row is an associative array containing the theme's current database entry - * @param mixed $stylesheet can either be the new content for the stylesheet or false to load from the standard file - * @param string $root_path should only be used in case you want to use a different root path than "{$phpbb_root_path}styles/{$theme_row['theme_path']}" - * - * @return string Stylesheet data for theme_data column in the theme table - */ - function db_theme_data($theme_row, $stylesheet = false, $root_path = '') - { - global $phpbb_root_path; - - if (!$root_path) - { - $root_path = $phpbb_root_path . 'styles/' . $theme_row['theme_path']; - } - - if (!$stylesheet) - { - $stylesheet = ''; - if (file_exists($root_path . '/theme/stylesheet.css')) - { - $stylesheet = file_get_contents($root_path . '/theme/stylesheet.css'); - } - } - - // Match CSS imports - $matches = array(); - preg_match_all('/@import url\((["\'])(.*)\1\);/i', $stylesheet, $matches); - - // remove commented stylesheets (very simple parser, allows only whitespace - // around an @import statement) - preg_match_all('#/\*\s*@import url\((["\'])(.*)\1\);\s\*/#i', $stylesheet, $commented); - $matches[2] = array_diff($matches[2], $commented[2]); - - if (sizeof($matches)) - { - foreach ($matches[0] as $idx => $match) - { - if (isset($matches[2][$idx])) - { - $stylesheet = str_replace($match, acp_styles::load_css_file($theme_row['theme_path'], $matches[2][$idx]), $stylesheet); - } - } - } - - // adjust paths - return str_replace('./', 'styles/' . $theme_row['theme_path'] . '/theme/', $stylesheet); - } - - /** - * Returns an array containing all template filenames for one template that are currently cached. - * - * @param string $template_path contains the name of the template's folder in /styles/ - * - * @return array of filenames that exist in /styles/$template_path/template/ (without extension!) - */ - function template_cache_filelist($template_path) - { - global $phpbb_root_path, $phpEx, $user; - - $cache_prefix = 'tpl_' . str_replace('_', '-', $template_path); - - if (!($dp = @opendir("{$phpbb_root_path}cache"))) - { - trigger_error($user->lang['TEMPLATE_ERR_CACHE_READ'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $file_ary = array(); - while ($file = readdir($dp)) - { - if ($file[0] == '.') - { - continue; - } - - if (is_file($phpbb_root_path . 'cache/' . $file) && (strpos($file, $cache_prefix) === 0)) - { - $file_ary[] = str_replace('.', '/', preg_replace('#^' . preg_quote($cache_prefix, '#') . '_(.*?)\.html\.' . $phpEx . '$#i', '\1', $file)); - } - } - closedir($dp); - - return $file_ary; - } - - /** - * Destroys cached versions of template files - * - * @param array $template_row contains the template's row in the STYLES_TEMPLATE_TABLE database table - * @param mixed $file_ary is optional and may contain an array of template file names which should be refreshed in the cache. - * The file names should be the original template file names and not the cache file names. - */ - function clear_template_cache($template_row, $file_ary = false) - { - global $phpbb_root_path, $phpEx, $user; - - $cache_prefix = 'tpl_' . str_replace('_', '-', $template_row['template_path']); - - if (!$file_ary || !is_array($file_ary)) - { - $file_ary = $this->template_cache_filelist($template_row['template_path']); - $log_file_list = $user->lang['ALL_FILES']; - } - else - { - $log_file_list = implode(', ', $file_ary); - } - - foreach ($file_ary as $file) - { - $file = str_replace('/', '.', $file); - - $file = "{$phpbb_root_path}cache/{$cache_prefix}_$file.html.$phpEx"; - if (file_exists($file) && is_file($file)) - { - @unlink($file); - } - } - unset($file_ary); - - add_log('admin', 'LOG_TEMPLATE_CACHE_CLEARED', $template_row['template_name'], $log_file_list); - } - - /** - * Install Style/Template/Theme - */ - function install($mode) - { - global $phpbb_root_path, $phpEx, $config, $db, $cache, $user, $template; - - $l_type = strtoupper($mode); - - $error = $installcfg = $style_row = array(); - $root_path = $cfg_file = ''; - $element_ary = array('template' => STYLES_TEMPLATE_TABLE, 'theme' => STYLES_THEME_TABLE); - - $install_path = request_var('path', ''); - $update = (isset($_POST['update'])) ? true : false; - - // Installing, obtain cfg file contents - if ($install_path) - { - $root_path = $phpbb_root_path . 'styles/' . $install_path . '/'; - $cfg_file = ($mode == 'style') ? "$root_path$mode.cfg" : "$root_path$mode/$mode.cfg"; - - if (!file_exists($cfg_file)) - { - $error[] = $user->lang[$l_type . '_ERR_NOT_' . $l_type]; - } - else - { - $installcfg = parse_cfg_file($cfg_file); - } - } - - // Installing - if (sizeof($installcfg)) - { - $name = $installcfg['name']; - $copyright = $installcfg['copyright']; - $version = $installcfg['version']; - - $style_row = array( - $mode . '_id' => 0, - $mode . '_name' => '', - $mode . '_copyright' => '' - ); - - switch ($mode) - { - case 'style': - - $style_row = array( - 'style_id' => 0, - 'style_name' => $installcfg['name'], - 'style_copyright' => $installcfg['copyright'] - ); - - $reqd_template = (isset($installcfg['required_template'])) ? $installcfg['required_template'] : false; - $reqd_theme = (isset($installcfg['required_theme'])) ? $installcfg['required_theme'] : false; - - // Check to see if each element is already installed, if it is grab the id - foreach ($element_ary as $element => $table) - { - $style_row = array_merge($style_row, array( - $element . '_id' => 0, - $element . '_name' => '', - $element . '_copyright' => '') - ); - - $this->test_installed($element, $error, (${'reqd_' . $element}) ? $phpbb_root_path . 'styles/' . $reqd_template . '/' : $root_path, ${'reqd_' . $element}, $style_row[$element . '_id'], $style_row[$element . '_name'], $style_row[$element . '_copyright']); - - if (!$style_row[$element . '_name']) - { - $style_row[$element . '_name'] = $reqd_template; - } - - // Merge other information to installcfg... if present - $cfg_file = $phpbb_root_path . 'styles/' . $install_path . '/' . $element . '/' . $element . '.cfg'; - - if (file_exists($cfg_file)) - { - $cfg_contents = parse_cfg_file($cfg_file); - - // Merge only specific things. We may need them later. - foreach (array('inherit_from') as $key) - { - if (!empty($cfg_contents[$key]) && !isset($installcfg[$key])) - { - $installcfg[$key] = $cfg_contents[$key]; - } - } - } - } - - break; - - case 'template': - $this->test_installed('template', $error, $root_path, false, $style_row['template_id'], $style_row['template_name'], $style_row['template_copyright']); - break; - - case 'theme': - $this->test_installed('theme', $error, $root_path, false, $style_row['theme_id'], $style_row['theme_name'], $style_row['theme_copyright']); - break; - } - } - else - { - trigger_error($user->lang['NO_' . $l_type] . adm_back_link($this->u_action), E_USER_WARNING); - } - - $style_row['style_active'] = request_var('style_active', 1); - $style_row['style_default'] = request_var('style_default', 0); - - // User has submitted form and no errors have occurred - if ($update && !sizeof($error)) - { - if ($mode == 'style') - { - foreach ($element_ary as $element => $table) - { - ${$element . '_root_path'} = (${'reqd_' . $element}) ? $phpbb_root_path . 'styles/' . ${'reqd_' . $element} . '/' : false; - ${$element . '_path'} = (${'reqd_' . $element}) ? ${'reqd_' . $element} : false; - } - $this->install_style($error, 'install', $root_path, $style_row['style_id'], $style_row['style_name'], $install_path, $style_row['style_copyright'], $style_row['style_active'], $style_row['style_default'], $style_row, $template_root_path, $template_path, $theme_root_path, $theme_path); - } - else - { - $this->install_element($mode, $error, 'install', $root_path, $style_row[$mode . '_id'], $style_row[$mode . '_name'], $install_path, $style_row[$mode . '_copyright']); - } - - if (!sizeof($error)) - { - $cache->destroy('sql', STYLES_TABLE); - - trigger_error($user->lang[$l_type . '_ADDED'] . adm_back_link($this->u_action)); - } - } - - $this->page_title = 'INSTALL_' . $l_type; - - $template->assign_vars(array( - 'S_DETAILS' => true, - 'S_INSTALL' => true, - 'S_ERROR_MSG' => (sizeof($error)) ? true : false, - 'S_LOCATION' => (isset($installcfg['inherit_from']) && $installcfg['inherit_from']) ? false : true, - 'S_STYLE' => ($mode == 'style') ? true : false, - 'S_TEMPLATE' => ($mode == 'template') ? true : false, - 'S_SUPERTEMPLATE' => (isset($installcfg['inherit_from'])) ? $installcfg['inherit_from'] : '', - 'S_THEME' => ($mode == 'theme') ? true : false, - - 'S_STYLE_ACTIVE' => (isset($style_row['style_active'])) ? $style_row['style_active'] : 0, - 'S_STYLE_DEFAULT' => (isset($style_row['style_default'])) ? $style_row['style_default'] : 0, - - 'U_ACTION' => $this->u_action . "&action=install&path=" . urlencode($install_path), - 'U_BACK' => $this->u_action, - - 'L_TITLE' => $user->lang[$this->page_title], - 'L_EXPLAIN' => $user->lang[$this->page_title . '_EXPLAIN'], - 'L_NAME' => $user->lang[$l_type . '_NAME'], - - 'ERROR_MSG' => (sizeof($error)) ? implode('
', $error) : '', - 'NAME' => $style_row[$mode . '_name'], - 'COPYRIGHT' => $style_row[$mode . '_copyright'], - 'TEMPLATE_NAME' => ($mode == 'style') ? $style_row['template_name'] : '', - 'THEME_NAME' => ($mode == 'style') ? $style_row['theme_name'] : '') - ); - } - - /** - * Add new style - */ - function add($mode) - { - global $phpbb_root_path, $phpEx, $config, $db, $cache, $user, $template; - - $l_type = strtoupper($mode); - $element_ary = array('template' => STYLES_TEMPLATE_TABLE, 'theme' => STYLES_THEME_TABLE); - $error = array(); - - $style_row = array( - $mode . '_name' => utf8_normalize_nfc(request_var('name', '', true)), - $mode . '_copyright' => utf8_normalize_nfc(request_var('copyright', '', true)), - 'template_id' => 0, - 'theme_id' => 0, - 'style_active' => request_var('style_active', 1), - 'style_default' => request_var('style_default', 0), - ); - - $basis = request_var('basis', 0); - $update = (isset($_POST['update'])) ? true : false; - - if ($basis) - { - switch ($mode) - { - case 'style': - $sql_select = 'template_id, theme_id'; - $sql_from = STYLES_TABLE; - break; - - case 'template': - $sql_select = 'template_id'; - $sql_from = STYLES_TEMPLATE_TABLE; - break; - - case 'theme': - $sql_select = 'theme_id'; - $sql_from = STYLES_THEME_TABLE; - break; - } - - $sql = "SELECT $sql_select - FROM $sql_from - WHERE {$mode}_id = $basis"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $error[] = $user->lang['NO_' . $l_type]; - } - - if (!sizeof($error)) - { - $style_row['template_id'] = (isset($row['template_id'])) ? $row['template_id'] : $style_row['template_id']; - $style_row['theme_id'] = (isset($row['theme_id'])) ? $row['theme_id'] : $style_row['theme_id']; - } - } - - if ($update) - { - $style_row['template_id'] = request_var('template_id', $style_row['template_id']); - $style_row['theme_id'] = request_var('theme_id', $style_row['theme_id']); - - if ($mode == 'style' && (!$style_row['template_id'] || !$style_row['theme_id'])) - { - $error[] = $user->lang['STYLE_ERR_NO_IDS']; - } - } - - // User has submitted form and no errors have occurred - if ($update && !sizeof($error)) - { - if ($mode == 'style') - { - $style_row['style_id'] = 0; - - $this->install_style($error, 'add', '', $style_row['style_id'], $style_row['style_name'], '', $style_row['style_copyright'], $style_row['style_active'], $style_row['style_default'], $style_row); - } - - if (!sizeof($error)) - { - $cache->destroy('sql', STYLES_TABLE); - - trigger_error($user->lang[$l_type . '_ADDED'] . adm_back_link($this->u_action)); - } - } - - if ($mode == 'style') - { - foreach ($element_ary as $element => $table) - { - $sql = "SELECT {$element}_id, {$element}_name - FROM $table - ORDER BY {$element}_id ASC"; - $result = $db->sql_query($sql); - - ${$element . '_options'} = ''; - while ($row = $db->sql_fetchrow($result)) - { - $selected = ($row[$element . '_id'] == $style_row[$element . '_id']) ? ' selected="selected"' : ''; - ${$element . '_options'} .= ''; - } - $db->sql_freeresult($result); - } - } - - $this->page_title = 'ADD_' . $l_type; - - $template->assign_vars(array( - 'S_DETAILS' => true, - 'S_ADD' => true, - 'S_ERROR_MSG' => (sizeof($error)) ? true : false, - 'S_STYLE' => ($mode == 'style') ? true : false, - 'S_TEMPLATE' => ($mode == 'template') ? true : false, - 'S_THEME' => ($mode == 'theme') ? true : false, - 'S_BASIS' => ($basis) ? true : false, - - 'S_STYLE_ACTIVE' => (isset($style_row['style_active'])) ? $style_row['style_active'] : 0, - 'S_STYLE_DEFAULT' => (isset($style_row['style_default'])) ? $style_row['style_default'] : 0, - 'S_TEMPLATE_OPTIONS' => ($mode == 'style') ? $template_options : '', - 'S_THEME_OPTIONS' => ($mode == 'style') ? $theme_options : '', - - 'U_ACTION' => $this->u_action . '&action=add&basis=' . $basis, - 'U_BACK' => $this->u_action, - - 'L_TITLE' => $user->lang[$this->page_title], - 'L_EXPLAIN' => $user->lang[$this->page_title . '_EXPLAIN'], - 'L_NAME' => $user->lang[$l_type . '_NAME'], - - 'ERROR_MSG' => (sizeof($error)) ? implode('
', $error) : '', - 'NAME' => $style_row[$mode . '_name'], - 'COPYRIGHT' => $style_row[$mode . '_copyright']) - ); - - } - - /** - - $reqd_template = (isset($installcfg['required_template'])) ? $installcfg['required_template'] : false; - $reqd_theme = (isset($installcfg['required_theme'])) ? $installcfg['required_theme'] : false; - - // Check to see if each element is already installed, if it is grab the id - foreach ($element_ary as $element => $table) - { - $style_row = array_merge($style_row, array( - $element . '_id' => 0, - $element . '_name' => '', - $element . '_copyright' => '') - ); - - $this->test_installed($element, $error, $root_path, ${'reqd_' . $element}, $style_row[$element . '_id'], $style_row[$element . '_name'], $style_row[$element . '_copyright']); - * Is this element installed? If not, grab its cfg details - */ - function test_installed($element, &$error, $root_path, $reqd_name, &$id, &$name, &$copyright) - { - global $db, $user; - - switch ($element) - { - case 'template': - $sql_from = STYLES_TEMPLATE_TABLE; - break; - - case 'theme': - $sql_from = STYLES_THEME_TABLE; - break; - } - - $l_element = strtoupper($element); - - $chk_name = ($reqd_name !== false) ? $reqd_name : $name; - - $sql = "SELECT {$element}_id, {$element}_name - FROM $sql_from - WHERE {$element}_name = '" . $db->sql_escape($chk_name) . "'"; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - $name = $row[$element . '_name']; - $id = $row[$element . '_id']; - } - else - { - if (!($cfg = @file("$root_path$element/$element.cfg"))) - { - $error[] = sprintf($user->lang['REQUIRES_' . $l_element], $reqd_name); - return false; - } - - $cfg = parse_cfg_file("$root_path$element/$element.cfg", $cfg); - - $name = $cfg['name']; - $copyright = $cfg['copyright']; - $id = 0; - - unset($cfg); - } - $db->sql_freeresult($result); - } - - /** - * Install/Add style - */ - function install_style(&$error, $action, $root_path, &$id, $name, $path, $copyright, $active, $default, &$style_row, $template_root_path = false, $template_path = false, $theme_root_path = false, $theme_path = false) - { - global $config, $db, $user; - - $element_ary = array('template', 'theme'); - - if (!$name) - { - $error[] = $user->lang['STYLE_ERR_STYLE_NAME']; - } - - // Check length settings - if (utf8_strlen($name) > 30) - { - $error[] = $user->lang['STYLE_ERR_NAME_LONG']; - } - - if (utf8_strlen($copyright) > 60) - { - $error[] = $user->lang['STYLE_ERR_COPY_LONG']; - } - - // Check if the name already exist - $sql = 'SELECT style_id - FROM ' . STYLES_TABLE . " - WHERE style_name = '" . $db->sql_escape($name) . "'"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - $error[] = $user->lang['STYLE_ERR_NAME_EXIST']; - } - - if (sizeof($error)) - { - return false; - } - - foreach ($element_ary as $element) - { - // Zero id value ... need to install element ... run usual checks - // and do the install if necessary - if (!$style_row[$element . '_id']) - { - $this->install_element($element, $error, $action, (${$element . '_root_path'}) ? ${$element . '_root_path'} : $root_path, $style_row[$element . '_id'], $style_row[$element . '_name'], (${$element . '_path'}) ? ${$element . '_path'} : $path, $style_row[$element . '_copyright']); - } - } - - if (!$style_row['template_id'] || !$style_row['theme_id']) - { - $error[] = $user->lang['STYLE_ERR_NO_IDS']; - } - - if (sizeof($error)) - { - return false; - } - - $db->sql_transaction('begin'); - - $sql_ary = array( - 'style_name' => $name, - 'style_copyright' => $copyright, - 'style_active' => (int) $active, - 'template_id' => (int) $style_row['template_id'], - 'theme_id' => (int) $style_row['theme_id'], - ); - - $sql = 'INSERT INTO ' . STYLES_TABLE . ' - ' . $db->sql_build_array('INSERT', $sql_ary); - $db->sql_query($sql); - - $id = $db->sql_nextid(); - - if ($default) - { - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_style = $id - WHERE user_style = " . $config['default_style']; - $db->sql_query($sql); - - set_config('default_style', $id); - } - - $db->sql_transaction('commit'); - - add_log('admin', 'LOG_STYLE_ADD', $name); - } - - /** - * Install/add an element, doing various checks as we go - */ - function install_element($mode, &$error, $action, $root_path, &$id, $name, $path, $copyright) - { - global $phpbb_root_path, $db, $user; - - // we parse the cfg here (again) - $cfg_data = parse_cfg_file("$root_path$mode/$mode.cfg"); - - switch ($mode) - { - case 'template': - $sql_from = STYLES_TEMPLATE_TABLE; - break; - - case 'theme': - $sql_from = STYLES_THEME_TABLE; - break; - } - - $l_type = strtoupper($mode); - - if (!$name) - { - $error[] = $user->lang[$l_type . '_ERR_STYLE_NAME']; - } - - // Check length settings - if (utf8_strlen($name) > 30) - { - $error[] = $user->lang[$l_type . '_ERR_NAME_LONG']; - } - - if (utf8_strlen($copyright) > 60) - { - $error[] = $user->lang[$l_type . '_ERR_COPY_LONG']; - } - - // Check if the name already exist - $sql = "SELECT {$mode}_id - FROM $sql_from - WHERE {$mode}_name = '" . $db->sql_escape($name) . "'"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if ($row) - { - // If it exist, we just use the style on installation - if ($action == 'install') - { - $id = $row[$mode . '_id']; - return false; - } - - $error[] = $user->lang[$l_type . '_ERR_NAME_EXIST']; - } - - if (isset($cfg_data['inherit_from']) && $cfg_data['inherit_from']) - { - if ($mode === 'template') - { - $select_bf = ', bbcode_bitfield'; - } - else - { - $select_bf = ''; - } - - $sql = "SELECT {$mode}_id, {$mode}_name, {$mode}_path $select_bf - FROM $sql_from - WHERE {$mode}_name = '" . $db->sql_escape($cfg_data['inherit_from']) . "' - AND {$mode}_inherits_id = 0"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - if (!$row) - { - $error[] = sprintf($user->lang[$l_type . '_ERR_REQUIRED_OR_INCOMPLETE'], $cfg_data['inherit_from']); - } - else - { - $inherit_id = $row["{$mode}_id"]; - $inherit_path = $row["{$mode}_path"]; - $inherit_bf = ($mode === 'template') ? $row["bbcode_bitfield"] : false; - } - } - else - { - $inherit_id = 0; - $inherit_path = ''; - $inherit_bf = false; - } - - if (sizeof($error)) - { - return false; - } - - $sql_ary = array( - $mode . '_name' => $name, - $mode . '_copyright' => $copyright, - $mode . '_path' => $path, - ); - - switch ($mode) - { - case 'template': - // We check if the template author defined a different bitfield - if (!empty($cfg_data['template_bitfield'])) - { - $sql_ary['bbcode_bitfield'] = $cfg_data['template_bitfield']; - } - else if ($inherit_bf) - { - $sql_ary['bbcode_bitfield'] = $inherit_bf; - } - else - { - $sql_ary['bbcode_bitfield'] = $this->template_bitfield; - } - - if (isset($cfg_data['inherit_from']) && $cfg_data['inherit_from']) - { - $sql_ary += array( - 'template_inherits_id' => $inherit_id, - 'template_inherit_path' => $inherit_path, - ); - } - break; - - case 'theme': - break; - } - - $db->sql_transaction('begin'); - - $sql = "INSERT INTO $sql_from - " . $db->sql_build_array('INSERT', $sql_ary); - $db->sql_query($sql); - - $id = $db->sql_nextid(); - - $db->sql_transaction('commit'); - - add_log('admin', 'LOG_' . $l_type . '_ADD_FS', $name); - } - - /** - * Checks downwards dependencies - * - * @access public - * @param string $mode The element type to check - only template is supported - * @param int $id The template id - * @returns false if no component inherits, array with name, path and id for each subtemplate otherwise - */ - function check_inheritance($mode, $id) - { - global $db; - - $l_type = strtoupper($mode); - - switch ($mode) - { - case 'template': - $sql_from = STYLES_TEMPLATE_TABLE; - break; - - case 'theme': - $sql_from = STYLES_THEME_TABLE; - break; - } - - $sql = "SELECT {$mode}_id, {$mode}_name, {$mode}_path - FROM $sql_from - WHERE {$mode}_inherits_id = " . (int) $id; - $result = $db->sql_query($sql); - - $names = array(); - while ($row = $db->sql_fetchrow($result)) - { - - $names[$row["{$mode}_id"]] = array( - "{$mode}_id" => $row["{$mode}_id"], - "{$mode}_name" => $row["{$mode}_name"], - "{$mode}_path" => $row["{$mode}_path"], - ); - } - $db->sql_freeresult($result); - - if (sizeof($names)) - { - return $names; - } - else - { - return false; - } - } - - /** - * Checks upwards dependencies - * - * @access public - * @param string $mode The element type to check - only template is supported - * @param int $id The template id - * @returns false if the component does not inherit, array with name, path and id otherwise - */ - function get_super($mode, $id) - { - global $db; - - $l_type = strtoupper($mode); - - switch ($mode) - { - case 'template': - $sql_from = STYLES_TEMPLATE_TABLE; - break; - - case 'theme': - $sql_from = STYLES_THEME_TABLE; - break; - } - - $sql = "SELECT {$mode}_inherits_id - FROM $sql_from - WHERE {$mode}_id = " . (int) $id; - $result = $db->sql_query_limit($sql, 1); - - if ($row = $db->sql_fetchrow($result)) - { - $db->sql_freeresult($result); - } - else - { - return false; - } - - $super_id = $row["{$mode}_inherits_id"]; - - $sql = "SELECT {$mode}_id, {$mode}_name, {$mode}_path - FROM $sql_from - WHERE {$mode}_id = " . (int) $super_id; - - $result = $db->sql_query_limit($sql, 1); - if ($row = $db->sql_fetchrow($result)) - { - $db->sql_freeresult($result); - return $row; - } - - return false; - } } diff --git a/phpBB/includes/acp/info/acp_styles.php b/phpBB/includes/acp/info/acp_styles.php index 221371c4cb..3137c4781b 100644 --- a/phpBB/includes/acp/info/acp_styles.php +++ b/phpBB/includes/acp/info/acp_styles.php @@ -17,11 +17,11 @@ class acp_styles_info return array( 'filename' => 'acp_styles', 'title' => 'ACP_CAT_STYLES', - 'version' => '1.0.0', + 'version' => '2.0.0', 'modes' => array( 'style' => array('title' => 'ACP_STYLES', 'auth' => 'acl_a_styles', 'cat' => array('ACP_STYLE_MANAGEMENT')), - 'template' => array('title' => 'ACP_TEMPLATES', 'auth' => 'acl_a_styles', 'cat' => array('ACP_STYLE_COMPONENTS')), - 'theme' => array('title' => 'ACP_THEMES', 'auth' => 'acl_a_styles', 'cat' => array('ACP_STYLE_COMPONENTS')), + 'install' => array('title' => 'ACP_STYLES_INSTALL', 'auth' => 'acl_a_styles', 'cat' => array('ACP_STYLE_MANAGEMENT')), + 'cache' => array('title' => 'ACP_STYLES_CACHE', 'auth' => 'acl_a_styles', 'cat' => array('ACP_STYLE_MANAGEMENT')), ), ); } From 39944a08b9ea031dfc156f61ad0d8f4c594882e5 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 15 Mar 2012 00:20:11 +0200 Subject: [PATCH 044/335] [feature/merging-style-components] New acp_styles template New acp_styles.html, completely rewritten PHPBB3-10632 --- phpBB/adm/style/acp_styles.html | 500 +++++++++----------------------- 1 file changed, 134 insertions(+), 366 deletions(-) diff --git a/phpBB/adm/style/acp_styles.html b/phpBB/adm/style/acp_styles.html index dc89aa247a..b09cbafc95 100644 --- a/phpBB/adm/style/acp_styles.html +++ b/phpBB/adm/style/acp_styles.html @@ -2,399 +2,167 @@ - + + - « {L_BACK} +
+

{MESSAGE_TITLE}

+

{MESSAGE_TEXT}

+ + + -

{L_TITLE}

+ {S_HIDDEN_FIELDS} -

{L_EXPLAIN}

+
+   + +
- +
+ + + +

{L_TITLE}

+ +

{L_EXPLAIN}

+ +
+{S_HIDDEN_FIELDS} +{S_FORM_TOKEN} + + +
- {L_TITLE}
-
-
{NAME}
+
+
-

{L_REPLACE_EXPLAIN}
-
-
- -
-
-

{L_REPLACE_TEMPLATE_EXPLAIN}
-
-
-
-

{L_REPLACE_THEME_EXPLAIN}
-
-
- - -

- - {S_FORM_TOKEN} -

-
-
- - - - « {L_BACK} - -

{L_EDIT}

- -

{L_EDIT_EXPLAIN}

- -

{L_SELECTED}: {SELECTED_TEMPLATE}

- -
- - -
- {L_SELECT} -
-
-
-
- {S_FORM_TOKEN} -
- -
- - - - -
- -
- {L_EDITOR} - -
-
-
{TEMPLATE_FILE}
-
- -
-
-
-
- -
- -
- {L_SUBMIT} - {S_HIDDEN_FIELDS} - {S_FORM_TOKEN} - -
-
- - - - - « {L_BACK} - -

{L_TEMPLATE_CACHE}

- -

{L_TEMPLATE_CACHE_EXPLAIN}

- -
-
- {L_TEMPLATE_CACHE} - - - - - - - - - - - - - - - - - - - - - - - - - - -
{L_CACHE_FILENAME}{L_CACHE_FILESIZE}{L_CACHE_CACHED}{L_CACHE_MODIFIED}{L_MARK}
{file.FILENAME_PATH}{file.FILESIZE}{file.CACHED}{file.MODIFIED}
{L_TEMPLATE_CACHE_EMPTY}
- -

- {L_MARK_ALL} :: {L_UNMARK_ALL}
- {S_FORM_TOKEN} - -

-
-
- - - - « {L_BACK} - -

{L_TITLE}

- -

{L_EXPLAIN}

- - -
-

{L_WARNING}

-

{ERROR_MSG}

-
- - -
- -
- {L_TITLE} -
-
-
{NAME}
-
- -
-
-
-
-
-
-
-
-
-
- -
-

{L_DOWNLOAD_STORE_EXPLAIN}
-
-
+
+
{STYLE_PATH}
-
-
{FORMAT_BUTTONS}
-
- -

- {S_FORM_TOKEN} - -

-
- - -
- - - -

{L_TITLE}

- -

{L_EXPLAIN}

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - colspan="2">{uninstalled.NAME}
{L_COPYRIGHT}: {uninstalled.COPYRIGHT} -
- - - -
{L_NAME}{L_STYLE_USED_BY}{L_OPTIONS}{L_ACTIONS}
{L_INSTALLED}
{L_INACTIVE_STYLES}
{installed.NAME} *{installed.STYLE_COUNT} - {installed.S_OPTIONS} - - - {installed.L_STYLE_ACT_DEACT} | - - {installed.S_ACTIONS} - - | {L_PREVIEW} - -
{L_UNINSTALLED}
{L_NO_UNINSTALLED}
{L_INSTALL}
- - -
- -
- {L_CREATE} - {L_CREATE}: {L_FROM} -
- -
- - - - - « {L_BACK} - -

{L_TITLE}

- -

{L_EXPLAIN}

- - -
-

{L_WARNING}

-

{ERROR_MSG}

-
- - -
- -
- {L_TITLE} -
-
-
{NAME}
+
+
{STYLE_COPYRIGHT}
-
-
{COPYRIGHT}
+
+
-
-
-
{S_SUPERTEMPLATE}
+
+
+
- - +
-
-
{TEMPLATE_NAME}
+
+
+
-
-
-
{THEME_NAME}
-
- - -
- -
- {L_OPTIONS} -
-
-
-
-
- -
-
-
-
-
-
{L_SUBMIT} + {L_BACK} {S_FORM_TOKEN}
+ -
+ + + + + + + + {STYLES_LIST_EXTRA} + + + + + + class="row-inactive"> + + + + + + + + + + + {styles_list.EXTRA} + + + + +
{L_STYLE_NAME}{L_STYLE_USED_BY}{L_ACTIONS} 
+ + + + + {styles_list.STYLE_NAME} +
{styles_list.STYLE_COPYRIGHT}
+ + {styles_list.STYLE_NAME} + + +
{styles_list.COMMENT}
+ + +
{L_STYLE_PATH} {styles_list.STYLE_PATH_FULL}
+ +
{styles_list.USERS} + + | + + {styles_list.actions.L_ACTION} + + {styles_list.actions.HTML} + + + + + + +   + + + + +
+ + + +
+ + + +
+ + + +
+ + {extra_links.L_ACTION} + +
+ + + From 3997ffac2a2e6f422dcd5cd5bd076edee6fa91dd Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 15 Mar 2012 13:13:21 +0200 Subject: [PATCH 045/335] [feature/merging-style-components] Creating style class Creating phpbb_style class, changing template initialization to style initialization PHPBB3-10632 --- phpBB/common.php | 6 +- phpBB/includes/bbcode.php | 9 +- phpBB/includes/functions_messenger.php | 6 +- phpBB/includes/style/style.php | 89 ++++++++++++++++++++ phpBB/install/index.php | 5 +- tests/template/template_inheritance_test.php | 5 +- tests/template/template_test_case.php | 8 +- 7 files changed, 106 insertions(+), 22 deletions(-) create mode 100644 phpBB/includes/style/style.php diff --git a/phpBB/common.php b/phpBB/common.php index a38a986280..dd49b29528 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -120,9 +120,9 @@ set_config_count(null, null, null, $config); // load extensions $phpbb_extension_manager = new phpbb_extension_manager($db, EXT_TABLE, $phpbb_root_path, ".$phpEx", $cache->get_driver()); -$phpbb_style_locator = new phpbb_style_locator(); -$phpbb_style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider()); -$template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_locator, $phpbb_style_path_provider); +// Initialize style +$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_extension_manager); +$template = $style->template; // Add own hook handler require($phpbb_root_path . 'includes/hooks/index.' . $phpEx); diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index 61271545bd..3831cb03ad 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -132,12 +132,11 @@ class bbcode { $this->template_bitfield = new bitfield($user->theme['bbcode_bitfield']); - $template_locator = new phpbb_style_locator(); - $template_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider()); - $template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $template_locator, $template_path_provider); + $style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_extension_manager); + $template = $style->template; $template->set_template(); - $template_locator->set_filenames(array('bbcode.html' => 'bbcode.html')); - $this->template_filename = $template_locator->get_source_file_for_handle('bbcode.html'); + $template->set_filenames(array('bbcode.html' => 'bbcode.html')); + $this->template_filename = $style->locator->get_source_file_for_handle('bbcode.html'); } $bbcode_ids = $rowset = $sql = array(); diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 1fb5f15879..4e1ec160af 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -208,10 +208,9 @@ class messenger // tpl_msg now holds a template object we can use to parse the template file if (!isset($this->tpl_msg[$template_lang . $template_file])) { - $template_locator = new phpbb_style_locator(); - $template_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider()); - $this->tpl_msg[$template_lang . $template_file] = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $template_locator, $template_path_provider); + $this->tpl_msg[$template_lang . $template_file] = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_extension_manager); $tpl = &$this->tpl_msg[$template_lang . $template_file]; + $tpl = $tpl->template; $fallback_template_path = false; @@ -237,6 +236,7 @@ class messenger } $this->tpl_obj = &$this->tpl_msg[$template_lang . $template_file]; + $this->tpl_obj = $this->tpl_obj->template; $this->vars = &$this->tpl_obj->_rootref; $this->tpl_msg = ''; diff --git a/phpBB/includes/style/style.php b/phpBB/includes/style/style.php new file mode 100644 index 0000000000..217a70e237 --- /dev/null +++ b/phpBB/includes/style/style.php @@ -0,0 +1,89 @@ +phpbb_root_path = $phpbb_root_path; + $this->phpEx = $phpEx; + $this->config = $config; + $this->user = $user; + $this->locator = new phpbb_style_locator(); + $this->provider = new phpbb_style_path_provider(); + if ($phpbb_extension_manager !== false) + { + $this->provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, $this->provider); + } + $this->template = new phpbb_style_template($this->phpbb_root_path, $this->phpEx, $this->config, $this->user, $this->locator, $this->provider); + } +} diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 9b0dde1009..7c6dd10d03 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -201,9 +201,8 @@ $config = new phpbb_config(array( 'load_tplcompile' => '1' )); -$phpbb_style_locator = new phpbb_style_locator(); -$phpbb_style_path_provider = new phpbb_style_path_provider(); -$template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_locator, $phpbb_style_path_provider); +$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, false); +$template = $style->template; $template->set_ext_dir_prefix('adm/'); $template->set_custom_template('../adm/style', 'admin'); $template->assign_var('T_ASSETS_PATH', '../assets'); diff --git a/tests/template/template_inheritance_test.php b/tests/template/template_inheritance_test.php index e2a2ac2261..2c67b38641 100644 --- a/tests/template/template_inheritance_test.php +++ b/tests/template/template_inheritance_test.php @@ -71,9 +71,8 @@ class phpbb_template_template_inheritance_test extends phpbb_template_template_t $this->template_path = dirname(__FILE__) . '/templates'; $this->parent_template_path = dirname(__FILE__) . '/parent_templates'; - $this->template_locator = new phpbb_style_locator(); - $this->template_provider = new phpbb_style_path_provider(); - $this->template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $this->template_locator, $this->template_provider); + $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, false); + $this->template = $this->style->template; $this->template->set_custom_template($this->template_path, 'tests', $this->parent_template_path, 'parent'); } } diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index 8eea11e84f..a0e980621d 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -12,10 +12,9 @@ require_once dirname(__FILE__) . '/../mock/extension_manager.php'; class phpbb_template_template_test_case extends phpbb_test_case { + protected $style; protected $template; protected $template_path; - protected $template_locator; - protected $template_provider; // Keep the contents of the cache for debugging? const PRESERVE_CACHE = true; @@ -63,9 +62,8 @@ class phpbb_template_template_test_case extends phpbb_test_case $config = new phpbb_config(array_merge($defaults, $new_config)); $this->template_path = dirname(__FILE__) . '/templates'; - $this->template_locator = new phpbb_style_locator(); - $this->template_provider = new phpbb_style_path_provider(); - $this->template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $this->template_locator, $this->template_provider); + $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, false); + $this->template = $this->style->template; $this->template->set_custom_template($this->template_path, 'tests'); } From c83f386c923fdb0e2823e7f742561a44a6f0f6ed Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 15 Mar 2012 13:41:23 +0200 Subject: [PATCH 046/335] [feature/merging-style-components] Changing $style to $style_id Changing $style to $style_id in user::setup to avoid conflict with new global style variable PHPBB3-10632 --- phpBB/includes/session.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index cd6f17154a..f2956243e2 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -1568,7 +1568,7 @@ class user extends session /** * Setup basic user-specific items (style, language, ...) */ - function setup($lang_set = false, $style = false) + function setup($lang_set = false, $style_id = false) { global $db, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache; @@ -1643,36 +1643,36 @@ class user extends session { global $SID, $_EXTRA_URL; - $style = $style_request; - $SID .= '&style=' . $style; - $_EXTRA_URL = array('style=' . $style); + $style_id = $style_request; + $SID .= '&style=' . $style_id; + $_EXTRA_URL = array('style=' . $style_id); } else { // Set up style - $style = ($style) ? $style : ((!$config['override_user_style']) ? $this->data['user_style'] : $config['default_style']); + $style_id = ($style_id) ? $style_id : ((!$config['override_user_style']) ? $this->data['user_style'] : $config['default_style']); } $sql = 'SELECT * FROM ' . STYLES_TABLE . " s - WHERE s.style_id = $style"; + WHERE s.style_id = $style_id"; $result = $db->sql_query($sql, 3600); $this->theme = $db->sql_fetchrow($result); $db->sql_freeresult($result); // User has wrong style - if (!$this->theme && $style == $this->data['user_style']) + if (!$this->theme && $style_id == $this->data['user_style']) { - $style = $this->data['user_style'] = $config['default_style']; + $style_id = $this->data['user_style'] = $config['default_style']; $sql = 'UPDATE ' . USERS_TABLE . " - SET user_style = $style + SET user_style = $style_id WHERE user_id = {$this->data['user_id']}"; $db->sql_query($sql); $sql = 'SELECT * FROM ' . STYLES_TABLE . " s - WHERE s.style_id = $style"; + WHERE s.style_id = $style_id"; $result = $db->sql_query($sql, 3600); $this->theme = $db->sql_fetchrow($result); $db->sql_freeresult($result); From 8b7c2c3c6516fd4eb606054ca3822d8a7f977282 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 15 Mar 2012 16:33:13 +0200 Subject: [PATCH 047/335] [feature/merging-style-components] Renaming style locator Renaming style locator to style resource locator PHPBB3-10632 --- phpBB/includes/style/{locator.php => resource_locator.php} | 2 +- phpBB/includes/style/style.php | 2 +- phpBB/includes/style/template.php | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) rename phpBB/includes/style/{locator.php => resource_locator.php} (99%) diff --git a/phpBB/includes/style/locator.php b/phpBB/includes/style/resource_locator.php similarity index 99% rename from phpBB/includes/style/locator.php rename to phpBB/includes/style/resource_locator.php index 2d0bcce924..f36768fcd3 100644 --- a/phpBB/includes/style/locator.php +++ b/phpBB/includes/style/resource_locator.php @@ -25,7 +25,7 @@ if (!defined('IN_PHPBB')) * * @package phpBB3 */ -class phpbb_style_locator +class phpbb_style_resource_locator { /** * Paths to directories that templates are stored in. diff --git a/phpBB/includes/style/style.php b/phpBB/includes/style/style.php index 217a70e237..b134b4f76f 100644 --- a/phpBB/includes/style/style.php +++ b/phpBB/includes/style/style.php @@ -78,7 +78,7 @@ class phpbb_style $this->phpEx = $phpEx; $this->config = $config; $this->user = $user; - $this->locator = new phpbb_style_locator(); + $this->locator = new phpbb_style_resource_locator(); $this->provider = new phpbb_style_path_provider(); if ($phpbb_extension_manager !== false) { diff --git a/phpBB/includes/style/template.php b/phpBB/includes/style/template.php index 02fa0bd250..076b9e05ea 100644 --- a/phpBB/includes/style/template.php +++ b/phpBB/includes/style/template.php @@ -64,7 +64,7 @@ class phpbb_style_template /** * Template locator - * @var phpbb_style_locator + * @var phpbb_style_resource_locator */ private $locator; @@ -79,10 +79,10 @@ class phpbb_style_template * * @param string $phpbb_root_path phpBB root path * @param user $user current user - * @param phpbb_style_locator $locator template locator + * @param phpbb_style_resource_locator $locator template locator * @param phpbb_style_path_provider $provider template path provider */ - public function __construct($phpbb_root_path, $phpEx, $config, $user, phpbb_style_locator $locator, phpbb_style_path_provider_interface $provider) + public function __construct($phpbb_root_path, $phpEx, $config, $user, phpbb_style_resource_locator $locator, phpbb_style_path_provider_interface $provider) { $this->phpbb_root_path = $phpbb_root_path; $this->phpEx = $phpEx; From c692e0d92da55944414d5f50accefdd96c2e31ee Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 15 Mar 2012 21:04:27 +0200 Subject: [PATCH 048/335] [feature/merging-style-components] Changing path provider Changing set_templates() to set_style() and removing second parameter, changing get_main_template_path() to get_main_style_path(), removing template_root_for_style(), updating docblocks PHPBB3-10632 --- .../style/extension_path_provider.php | 45 +++++++------- phpBB/includes/style/path_provider.php | 60 +++++-------------- .../style/path_provider_interface.php | 23 +++---- 3 files changed, 45 insertions(+), 83 deletions(-) diff --git a/phpBB/includes/style/extension_path_provider.php b/phpBB/includes/style/extension_path_provider.php index 05dc5661f6..1fb6580ce1 100644 --- a/phpBB/includes/style/extension_path_provider.php +++ b/phpBB/includes/style/extension_path_provider.php @@ -16,26 +16,26 @@ if (!defined('IN_PHPBB')) } /** -* Provides a template locator with core template paths and extension template paths +* Provides a style resource locator with core style paths and extension style paths * -* Finds installed template paths and makes them available to the locator. +* Finds installed style paths and makes them available to the resource locator. * * @package phpBB3 */ class phpbb_style_extension_path_provider extends phpbb_extension_provider implements phpbb_style_path_provider_interface { /** - * Optional prefix for template paths searched within extensions. + * Optional prefix for style paths searched within extensions. * * Empty by default. Relative to the extension directory. As an example, it - * could be adm/ for admin templates. + * could be adm/ for admin style. * * @var string */ protected $ext_dir_prefix = ''; /** - * A provider of paths to be searched for templates + * A provider of paths to be searched for styles * @var phpbb_style_path_provider */ protected $base_path_provider; @@ -54,11 +54,11 @@ class phpbb_style_extension_path_provider extends phpbb_extension_provider imple } /** - * Sets a prefix for template paths searched within extensions. + * Sets a prefix for style paths searched within extensions. * * The prefix is inserted between the extension's path e.g. ext/foo/ and - * the looked up template path, e.g. styles/bar/template/some.html. So it - * should not have a leading slash, but should have a trailing slash. + * the looked up style path, e.g. styles/bar/. So it should not have a + * leading slash, but should have a trailing slash. * * @param string $ext_dir_prefix The prefix including trailing slash * @return null @@ -69,13 +69,13 @@ class phpbb_style_extension_path_provider extends phpbb_extension_provider imple } /** - * Finds template paths using the extension manager + * Finds style paths using the extension manager * - * Locates a path (e.g. styles/prosilver/template/) in all active extensions. - * Then appends the core template paths based in the current working + * Locates a path (e.g. styles/prosilver/) in all active extensions. + * Then appends the core style paths based in the current working * directory. * - * @return array List of template paths + * @return array List of style paths */ public function find() { @@ -102,29 +102,24 @@ class phpbb_style_extension_path_provider extends phpbb_extension_provider imple } /** - * Overwrites the current template names and paths + * Overwrites the current style paths * - * @param array $templates An associative map from template names to paths. - * The first element is the main template. - * If the path is false, it will be generated from - * the supplied name. - * @param string $style_root_path The root directory for styles identified - * by name only. + * @param array $styles An array of style paths. The first element is the main style. * @return null */ - public function set_templates(array $templates, $style_root_path) + public function set_styles(array $styles) { - $this->base_path_provider->set_templates($templates, $style_root_path); + $this->base_path_provider->set_styles($styles); $this->items = null; } /** - * Retrieves the path to the main template passed into set_templates() + * Retrieves the path to the main style passed into set_styles() * - * @return string Main template path + * @return string Main style path */ - public function get_main_template_path() + public function get_main_style_path() { - return $this->base_path_provider->get_main_template_path(); + return $this->base_path_provider->get_main_style_path(); } } diff --git a/phpBB/includes/style/path_provider.php b/phpBB/includes/style/path_provider.php index 649797df41..c229af92ba 100644 --- a/phpBB/includes/style/path_provider.php +++ b/phpBB/includes/style/path_provider.php @@ -16,15 +16,15 @@ if (!defined('IN_PHPBB')) } /** -* Provides a template locator with paths +* Provides a style resource locator with paths * -* Finds installed template paths and makes them available to the locator. +* Finds installed style paths and makes them available to the resource locator. * * @package phpBB3 */ class phpbb_style_path_provider implements IteratorAggregate, phpbb_style_path_provider_interface { - protected $main_template_name = ''; + protected $main_style_name = ''; protected $paths = array(); /** @@ -38,62 +38,34 @@ class phpbb_style_path_provider implements IteratorAggregate, phpbb_style_path_p } /** - * Overwrites the current template names and paths + * Overwrites the current style paths * - * The first element of the passed templates map, is considered the main - * template and can be retrieved through get_main_template_path(). + * The first element of the passed styles map, is considered the main + * style and can be retrieved through get_main_style_path(). * - * @param array $templates An associative map from template names to paths. - * The first element is the main template. - * If the path is false, it will be generated from - * the supplied name. - * @param string $style_root_path The root directory for styles identified - * by name only. + * @param array $styles An array of style paths. The first element is the main style. * @return null */ - public function set_templates(array $templates, $style_root_path) + public function set_styles(array $styles) { - $this->paths = array(); - - foreach ($templates as $name => $path) - { - if (!$path) - { - $path = $style_root_path . $this->template_root_for_style($name); - } - - $this->paths[] = $path; - } - - $this->main_template_path = $this->paths[0]; + $this->paths = $styles; + $this->main_style_path = $this->paths[0]; } /** - * Retrieves the path to the main template passed into set_templates() + * Retrieves the path to the main style passed into set_styles() * - * @return string Main template path + * @return string Main style path */ - public function get_main_template_path() + public function get_main_style_path() { - return $this->main_template_path; + return $this->main_style_path; } /** - * Converts a style name to relative (to board root or extension) path to - * the style's template files. + * Retrieve an iterator over all style paths * - * @param $style_name string Style name - * @return string Path to style template files - */ - private function template_root_for_style($style_name) - { - return 'styles/' . $style_name . '/template'; - } - - /** - * Retrieve an iterator over all template paths - * - * @return ArrayIterator An iterator for the array of template paths + * @return ArrayIterator An iterator for the array of style paths */ public function getIterator() { diff --git a/phpBB/includes/style/path_provider_interface.php b/phpBB/includes/style/path_provider_interface.php index e65c037dcc..7ae94e17f4 100644 --- a/phpBB/includes/style/path_provider_interface.php +++ b/phpBB/includes/style/path_provider_interface.php @@ -16,16 +16,16 @@ if (!defined('IN_PHPBB')) } /** -* Provides a template locator with paths +* Provides a style resource locator with paths * -* Finds installed template paths and makes them available to the locator. +* Finds installed style paths and makes them available to the resource locator. * * @package phpBB3 */ interface phpbb_style_path_provider_interface extends Traversable { /** - * Defines a prefix to use for template paths in extensions + * Defines a prefix to use for style paths in extensions * * @param string $ext_dir_prefix The prefix including trailing slash * @return null @@ -33,22 +33,17 @@ interface phpbb_style_path_provider_interface extends Traversable public function set_ext_dir_prefix($ext_dir_prefix); /** - * Overwrites the current template names and paths + * Overwrites the current style paths * - * @param array $templates An associative map from template names to paths. - * The first element is the main template. - * If the path is false, it will be generated from - * the supplied name. - * @param string $style_root_path The root directory for styles identified - * by name only. + * @param array $styles An array of style paths. The first element is the main style. * @return null */ - public function set_templates(array $templates, $style_root_path); + public function set_styles(array $styles); /** - * Retrieves the path to the main template passed into set_templates() + * Retrieves the path to the main style passed into set_styles() * - * @return string Main template path + * @return string Main style path */ - public function get_main_template_path(); + public function get_main_style_path(); } From 0b2abe5250ebe6c75473a8d9f9be2aeb13855565 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 15 Mar 2012 21:06:24 +0200 Subject: [PATCH 049/335] [feature/merging-style-components] Changing resource locator Changing "template" to "style" in all functions that deal with styles, changing error messages, updating docblocks PHPBB3-10632 --- phpBB/includes/style/resource_locator.php | 67 ++++++++++++++--------- 1 file changed, 40 insertions(+), 27 deletions(-) diff --git a/phpBB/includes/style/resource_locator.php b/phpBB/includes/style/resource_locator.php index f36768fcd3..af261534c3 100644 --- a/phpBB/includes/style/resource_locator.php +++ b/phpBB/includes/style/resource_locator.php @@ -17,28 +17,41 @@ if (!defined('IN_PHPBB')) /** -* Template locator. Maintains mapping from template handles to source paths. +* Style resource locator. +* Maintains mapping from template handles to source template file paths. +* Locates style files: resources (such as .js and .css files) and templates. * -* Template locator is aware of template inheritance, and can return actual -* filesystem paths (i.e., the "primary" template or the "parent" template) +* Style resource locator is aware of styles tree, and can return actual +* filesystem paths (i.e., the "child" style or the "parent" styles) * depending on what files exist. * +* Root paths stored in locator are paths to style directories. Templates are +* stored in subdirectory that $template_path points to. +* * @package phpBB3 */ class phpbb_style_resource_locator { /** - * Paths to directories that templates are stored in. + * Paths to style directories. * @var array */ private $roots = array(); /** - * Index of the main template in the roots array + * Index of the main style in the roots array. * @var int */ private $main_root_id = 0; + /** + * Location of templates directory within style directories. + * Must have trailing slash. Empty if templates are stored in root + * style directory, such as admin control panel templates. + * @var string + */ + public $template_path = 'template/'; + /** * Map from root index to handles to source template file paths. * Normally it only contains paths for handles that are used @@ -57,34 +70,34 @@ class phpbb_style_resource_locator private $filenames = array(); /** - * Set main template location (must have been added through set_paths first). + * Set main style location (must have been added through set_paths first). * - * @param string $template_path Path to template directory + * @param string $style_path Path to style directory * @return null */ - public function set_main_template($template) + public function set_main_style($style_path) { - $this->main_root_id = array_search($template, $this->roots, true); + $this->main_root_id = array_search($style_path, $this->roots, true); } /** - * Sets the list of template paths + * Sets the list of style paths * - * These paths will be searched for template files in the provided order. + * These paths will be searched for style files in the provided order. * Paths may be outside of phpBB, but templates loaded from these paths * will still be cached. * - * @param array $template_paths An array of paths to template directories + * @param array $style_paths An array of paths to style directories * @return null */ - public function set_paths($template_paths) + public function set_paths($style_paths) { $this->roots = array(); $this->files = array(); $this->filenames = array(); $this->main_root_id = 0; - foreach ($template_paths as $path) + foreach ($style_paths as $path) { // Make sure $path has no ending slash if (substr($path, -1) === '/') @@ -107,14 +120,14 @@ class phpbb_style_resource_locator { if (empty($filename)) { - trigger_error("template locator: set_filenames: Empty filename specified for $handle", E_USER_ERROR); + trigger_error("style resource locator: set_filenames: Empty filename specified for $handle", E_USER_ERROR); } $this->filename[$handle] = $filename; foreach ($this->roots as $root_index => $root) { - $this->files[$root_index][$handle] = $root . '/' . $filename; + $this->files[$root_index][$handle] = $root . '/' . $this->template_path . $filename; } } } @@ -133,37 +146,37 @@ class phpbb_style_resource_locator { if (!isset($this->filename[$handle])) { - trigger_error("template locator: get_filename_for_handle: No file specified for handle $handle", E_USER_ERROR); + trigger_error("style resource locator: get_filename_for_handle: No file specified for handle $handle", E_USER_ERROR); } return $this->filename[$handle]; } /** * Determines the source file path for a template handle without - * regard for template inheritance. + * regard for styles tree. * - * This function returns the path in "primary" template directory + * This function returns the path in "primary" style directory * corresponding to the given template handle. That path may or * may not actually exist on the filesystem. Because this function * does not perform stat calls to determine whether the path it * returns actually exists, it is faster than get_source_file_for_handle. * * Use get_source_file_for_handle to obtain the actual path that is - * guaranteed to exist (which might come from the parent/fallback - * template directory if template inheritance is used). + * guaranteed to exist (which might come from the parent style + * directory if primary style has parent styles). * * This function will trigger an error if the handle was never * associated with a template file via set_filenames. * * @param $handle string Template handle - * @return string Path to source file path in primary template directory + * @return string Path to source file path in primary style directory */ public function get_virtual_source_file_for_handle($handle) { // If we don't have a file assigned to this handle, die. if (!isset($this->files[$this->main_root_id][$handle])) { - trigger_error("template locator: No file specified for handle $handle", E_USER_ERROR); + trigger_error("style resource locator: No file specified for handle $handle", E_USER_ERROR); } $source_file = $this->files[$this->main_root_id][$handle]; @@ -172,7 +185,7 @@ class phpbb_style_resource_locator /** * Determines the source file path for a template handle, accounting - * for template inheritance and verifying that the path exists. + * for styles tree and verifying that the path exists. * * This function returns the actual path that may be compiled for * the specified template handle. It will trigger an error if @@ -181,7 +194,7 @@ class phpbb_style_resource_locator * filesystem. * * Use get_virtual_source_file_for_handle to just resolve a template - * handle to a path without any filesystem or inheritance checks. + * handle to a path without any filesystem or styles tree checks. * * @param string $handle Template handle (i.e. "friendly" template name) * @return string Source file path @@ -191,7 +204,7 @@ class phpbb_style_resource_locator // If we don't have a file assigned to this handle, die. if (!isset($this->files[$this->main_root_id][$handle])) { - trigger_error("template locator: No file specified for handle $handle", E_USER_ERROR); + trigger_error("style resource locator: No file specified for handle $handle", E_USER_ERROR); } // locate a source file that exists @@ -206,7 +219,7 @@ class phpbb_style_resource_locator // search failed if (!file_exists($source_file)) { - trigger_error("template locator: File for handle $handle does not exist. Could not find: $tried", E_USER_ERROR); + trigger_error("style resource locator: File for handle $handle does not exist. Could not find: $tried", E_USER_ERROR); } return $source_file; From 5b149e93b91ab1cb09e2e9c8c3c00312973c1c5e Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 15 Mar 2012 21:08:41 +0200 Subject: [PATCH 050/335] [feature/merging-style-components] Changing template class Removing functions that are now handled by phpbb_style class, allowing to write $context, updating docblocks PHPBB3-10632 --- phpBB/includes/style/template.php | 76 +++++-------------------------- 1 file changed, 11 insertions(+), 65 deletions(-) diff --git a/phpBB/includes/style/template.php b/phpBB/includes/style/template.php index 076b9e05ea..21a2e821dd 100644 --- a/phpBB/includes/style/template.php +++ b/phpBB/includes/style/template.php @@ -35,7 +35,7 @@ class phpbb_style_template * @var phpbb_style_template_context Template context. * Stores template data used during template rendering. */ - private $context; + public $context; /** * @var string Path of the cache directory for the template @@ -63,7 +63,7 @@ class phpbb_style_template private $user; /** - * Template locator + * Style resource locator * @var phpbb_style_resource_locator */ private $locator; @@ -74,13 +74,19 @@ class phpbb_style_template */ private $provider; + /** + * Location of templates directory within style directories + * @var string + */ + public $template_path = 'template/'; + /** * Constructor. * * @param string $phpbb_root_path phpBB root path * @param user $user current user - * @param phpbb_style_resource_locator $locator template locator - * @param phpbb_style_path_provider $provider template path provider + * @param phpbb_style_resource_locator $locator style resource locator + * @param phpbb_style_path_provider $provider style path provider */ public function __construct($phpbb_root_path, $phpEx, $config, $user, phpbb_style_resource_locator $locator, phpbb_style_path_provider_interface $provider) { @@ -89,70 +95,10 @@ class phpbb_style_template $this->config = $config; $this->user = $user; $this->locator = $locator; + $this->template_path = $this->locator->template_path; $this->provider = $provider; } - /** - * Set template location based on (current) user's chosen style. - */ - public function set_template() - { - $template_name = $this->user->theme['style_path']; - $fallback_name = ($this->user->theme['style_parent_id']) ? array_reverse(explode('/', $this->user->theme['style_parent_tree'])) : false; - - return $this->set_custom_template(false, $template_name, false, $fallback_name); - } - - /** - * Defines a prefix to use for template paths in extensions - * - * @param string $ext_dir_prefix The prefix including trailing slash - * @return null - */ - public function set_ext_dir_prefix($ext_dir_prefix) - { - $this->provider->set_ext_dir_prefix($ext_dir_prefix); - } - - /** - * Set custom template location (able to use directory outside of phpBB). - * - * Note: Templates are still compiled to phpBB's cache directory. - * - * @param string $template_path Path to template directory - * @param string $template_name Name of template - * @param string or array $fallback_template_path Path to fallback template - * @param string or array $fallback_template_name Name of fallback template - */ - public function set_custom_template($template_path, $template_name, $fallback_template_path = false, $fallback_template_name = false) - { - $templates = array($template_name => $template_path); - - if (is_string($fallback_template_name)) - { - $templates[$fallback_template_name] = $fallback_template_path; - } - if (is_array($fallback_template_name)) - { - $i = 0; - foreach ($fallback_template_name as $fallback_template_name_item) - { - $templates[$fallback_template_name_item] = is_array($fallback_template_path) ? $fallback_template_path[$i] : $fallback_template_path; - $i ++; - } - } - - $this->provider->set_templates($templates, $this->phpbb_root_path); - $this->locator->set_paths($this->provider); - $this->locator->set_main_template($this->provider->get_main_template_path()); - - $this->cachepath = $this->phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $template_name) . '_'; - - $this->context = new phpbb_style_template_context(); - - return true; - } - /** * Sets the template filenames for handles. * From 1ce4d4c4fc482f33fd061c4f718b4f8c3656dbdb Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 15 Mar 2012 21:09:49 +0200 Subject: [PATCH 051/335] [feature/merging-style-components] Changing style class Moving functions that deal with styles from template to style class, updating docblocks PHPBB3-10632 --- phpBB/includes/style/style.php | 75 +++++++++++++++++++++++++++++++--- 1 file changed, 70 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/style/style.php b/phpBB/includes/style/style.php index b134b4f76f..5dee0a138c 100644 --- a/phpBB/includes/style/style.php +++ b/phpBB/includes/style/style.php @@ -27,11 +27,6 @@ class phpbb_style */ public $template; - /** - * @var string Path of the cache directory for the template - */ - public $cachepath = ''; - /** * @var string phpBB root path */ @@ -86,4 +81,74 @@ class phpbb_style } $this->template = new phpbb_style_template($this->phpbb_root_path, $this->phpEx, $this->config, $this->user, $this->locator, $this->provider); } + + /** + * Set style location based on (current) user's chosen style. + */ + public function set_style() + { + $style_name = $this->user->theme['style_path']; + $style_dirs = ($this->user->theme['style_parent_id']) ? array_reverse(explode('/', $this->user->theme['style_parent_tree'])) : array(); + $paths = array($this->get_style_path($style_name)); + foreach ($style_dirs as $dir) + { + $paths[] = $this->get_style_path($dir); + } + + return $this->set_custom_style($style_name, $paths); + } + + /** + * Set custom style location (able to use directory outside of phpBB). + * + * Note: Templates are still compiled to phpBB's cache directory. + * + * @param string $name Name of style, used for cache prefix. Examples: "admin", "prosilver" + * @param array or string $paths Array of style paths, relative to current root directory + * @param string $template_path Path to templates, relative to style directory. False if path should not be changed. + */ + public function set_custom_style($name, $paths, $template_path = false) + { + if (is_string($paths)) + { + $paths = array($paths); + } + + $this->provider->set_styles($paths); + $this->locator->set_paths($this->provider); + $this->locator->set_main_style($this->provider->get_main_style_path()); + + $this->template->cachepath = $this->phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $name) . '_'; + + $this->template->context = new phpbb_style_template_context(); + + if ($template_path !== false) + { + $this->template->template_path = $this->locator->template_path = $template_path; + } + + return true; + } + + /** + * Get location of style directory for specific style_path + * + * @param string $path Style path, such as "prosilver" + * @return string Path to style directory, relative to current path + */ + public function get_style_path($path) + { + return $this->phpbb_root_path . 'styles/' . $path; + } + + /** + * Defines a prefix to use for style paths in extensions + * + * @param string $ext_dir_prefix The prefix including trailing slash + * @return null + */ + public function set_ext_dir_prefix($ext_dir_prefix) + { + $this->provider->set_ext_dir_prefix($ext_dir_prefix); + } } From fd96f97dc3c659e1d2e9b58420d652ad79387fbf Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 15 Mar 2012 21:11:34 +0200 Subject: [PATCH 052/335] [feature/merging-style-components] Updating style initialization Changing template initialization to style initialization. PHPBB3-10632 --- phpBB/adm/index.php | 6 +++--- phpBB/includes/bbcode.php | 2 +- phpBB/includes/functions_messenger.php | 8 ++++---- phpBB/includes/session.php | 4 ++-- phpBB/install/index.php | 4 ++-- phpBB/install/install_update.php | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/phpBB/adm/index.php b/phpBB/adm/index.php index e7168b210b..91894e5aec 100644 --- a/phpBB/adm/index.php +++ b/phpBB/adm/index.php @@ -50,9 +50,9 @@ $file_uploads = (@ini_get('file_uploads') == '1' || strtolower(@ini_get('file_up $module_id = request_var('i', ''); $mode = request_var('mode', ''); -// Set custom template for admin area -$template->set_ext_dir_prefix('adm/'); -$template->set_custom_template($phpbb_admin_path . 'style', 'admin'); +// Set custom style for admin area +$style->set_ext_dir_prefix('adm/'); +$style->set_custom_style('admin', $phpbb_admin_path . 'style', ''); $template->assign_var('T_ASSETS_PATH', $phpbb_root_path . 'assets'); $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style'); diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index 3831cb03ad..5e3bfed5ec 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -133,8 +133,8 @@ class bbcode $this->template_bitfield = new bitfield($user->theme['bbcode_bitfield']); $style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_extension_manager); + $style->set_style(); $template = $style->template; - $template->set_template(); $template->set_filenames(array('bbcode.html' => 'bbcode.html')); $this->template_filename = $style->locator->get_source_file_for_handle('bbcode.html'); } diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 4e1ec160af..a5e7ad75ca 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -201,7 +201,7 @@ class messenger { // fall back to board default language if the user's language is // missing $template_file. If this does not exist either, - // $tpl->set_custom_template will do a trigger_error + // $tpl->set_filenames will do a trigger_error $template_lang = basename($config['default_lang']); } @@ -209,8 +209,8 @@ class messenger if (!isset($this->tpl_msg[$template_lang . $template_file])) { $this->tpl_msg[$template_lang . $template_file] = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_extension_manager); - $tpl = &$this->tpl_msg[$template_lang . $template_file]; - $tpl = $tpl->template; + $stl = &$this->tpl_msg[$template_lang . $template_file]; + $tpl = $stl->template; $fallback_template_path = false; @@ -228,7 +228,7 @@ class messenger } } - $tpl->set_custom_template($template_path, $template_lang . '_email', $fallback_template_path); + $stl->set_custom_style($template_lang . '_email', array($template_path, $fallback_template_path), ''); $tpl->set_filenames(array( 'body' => $template_file . '.txt', diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index f2956243e2..2fd2efe9b2 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -1570,7 +1570,7 @@ class user extends session */ function setup($lang_set = false, $style_id = false) { - global $db, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache; + global $db, $style, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache; if ($this->data['user_id'] != ANONYMOUS) { @@ -1704,7 +1704,7 @@ class user extends session } } - $template->set_template(); + $style->set_style(); $this->img_lang = $this->lang_name; diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 7c6dd10d03..1f013df72b 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -202,9 +202,9 @@ $config = new phpbb_config(array( )); $style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, false); +$style->set_ext_dir_prefix('adm/'); +$style->set_custom_style('admin', '../adm/style', ''); $template = $style->template; -$template->set_ext_dir_prefix('adm/'); -$template->set_custom_template('../adm/style', 'admin'); $template->assign_var('T_ASSETS_PATH', '../assets'); $template->assign_var('T_TEMPLATE_PATH', '../adm/style'); diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index aba692aa62..dcf01e5cc8 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -71,7 +71,7 @@ class install_update extends module function main($mode, $sub) { - global $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language; + global $style, $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language; global $request; $this->tpl_name = 'install_update'; @@ -131,7 +131,7 @@ class install_update extends module } // Set custom template again. ;) - $template->set_custom_template('../adm/style', 'admin'); + $style->set_custom_style('admin', '../adm/style', ''); $template->assign_vars(array( 'S_USER_LANG' => $user->lang['USER_LANG'], From d25b607ca16bfd240f3b9cb9da7e4567b426ec26 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 15 Mar 2012 21:12:13 +0200 Subject: [PATCH 053/335] [feature/merging-style-components] Updating test cases Updating code in test cases for new template classes. PHPBB3-10632 --- tests/template/includephp_test.php | 2 +- tests/template/template_inheritance_test.php | 2 +- tests/template/template_test.php | 4 ++-- tests/template/template_test_case.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/template/includephp_test.php b/tests/template/includephp_test.php index 28ea118a13..626735f15f 100644 --- a/tests/template/includephp_test.php +++ b/tests/template/includephp_test.php @@ -36,7 +36,7 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case $this->setup_engine(array('tpl_allow_php' => true)); - $this->template->set_custom_template($cache_dir, 'tests'); + $this->style->set_custom_style('tests', $cache_dir); $cache_file = $this->template->cachepath . 'includephp_absolute.html.php'; $this->run_template('includephp_absolute.html', array(), array(), array(), "Path is absolute.\ntesting included php", $cache_file); diff --git a/tests/template/template_inheritance_test.php b/tests/template/template_inheritance_test.php index 2c67b38641..f7bd38cc08 100644 --- a/tests/template/template_inheritance_test.php +++ b/tests/template/template_inheritance_test.php @@ -72,7 +72,7 @@ class phpbb_template_template_inheritance_test extends phpbb_template_template_t $this->template_path = dirname(__FILE__) . '/templates'; $this->parent_template_path = dirname(__FILE__) . '/parent_templates'; $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, false); + $this->style->set_custom_style('tests', array($this->template_path, $this->parent_template_path), ''); $this->template = $this->style->template; - $this->template->set_custom_template($this->template_path, 'tests', $this->parent_template_path, 'parent'); } } diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 76b1af68d8..edf621e16c 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -277,7 +277,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case $this->template->set_filenames(array('test' => $filename)); $this->assertFileNotExists($this->template_path . '/' . $filename, 'Testing missing file, file cannot exist'); - $expecting = sprintf('template locator: File for handle test does not exist. Could not find: %s', realpath($this->template_path . '/../') . '/templates/' . $filename); + $expecting = sprintf('style resource locator: File for handle test does not exist. Could not find: %s', realpath($this->template_path . '/../') . '/templates/' . $filename); $this->setExpectedTriggerError(E_USER_ERROR, $expecting); $this->display('test'); @@ -285,7 +285,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case public function test_empty_file() { - $expecting = 'template locator: set_filenames: Empty filename specified for test'; + $expecting = 'style resource locator: set_filenames: Empty filename specified for test'; $this->setExpectedTriggerError(E_USER_ERROR, $expecting); $this->template->set_filenames(array('test' => '')); diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index a0e980621d..5884225a54 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -63,8 +63,8 @@ class phpbb_template_template_test_case extends phpbb_test_case $this->template_path = dirname(__FILE__) . '/templates'; $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, false); + $this->style->set_custom_style('tests', $this->template_path, ''); $this->template = $this->style->template; - $this->template->set_custom_template($this->template_path, 'tests'); } protected function setUp() From 71afba0dedd2fcc4e478e191acc23277df8209c9 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 15 Mar 2012 22:46:06 -0400 Subject: [PATCH 054/335] [task/php54] Refactor error_reporting call slightly. Separate error level assignment into a variable in this commit so that the only difference between Olympus and Ascraeus is the addition of logic altering $level. PHPBB3-10615 --- phpBB/includes/startup.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/startup.php b/phpBB/includes/startup.php index bbe2f127f1..178fb30435 100644 --- a/phpBB/includes/startup.php +++ b/phpBB/includes/startup.php @@ -19,7 +19,8 @@ if (!defined('E_DEPRECATED')) { define('E_DEPRECATED', 8192); } -error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED); +$level = E_ALL & ~E_NOTICE & ~E_DEPRECATED; +error_reporting($level); /* * Remove variables created by register_globals from the global scope From 5efdbfa5e4e3c00c08167cdfff912ee4937f4fd2 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Thu, 15 Mar 2012 22:47:42 -0400 Subject: [PATCH 055/335] [task/php54] Disable E_STRICT in Olympus when running on PHP 5.4. We cannot use static in Olympus because it must be PHP 4 compatible. Therefore disable E_STRICT for Olympus. This commit should be reverted for Ascraeus. PHPBB3-10615 --- phpBB/includes/startup.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/phpBB/includes/startup.php b/phpBB/includes/startup.php index 178fb30435..cf216a65db 100644 --- a/phpBB/includes/startup.php +++ b/phpBB/includes/startup.php @@ -20,6 +20,21 @@ if (!defined('E_DEPRECATED')) define('E_DEPRECATED', 8192); } $level = E_ALL & ~E_NOTICE & ~E_DEPRECATED; +if (version_compare(PHP_VERSION, '5.4.0-dev', '>=')) +{ + // PHP 5.4 adds E_STRICT to E_ALL. + // Our utf8 normalizer triggers E_STRICT output on PHP 5.4. + // Unfortunately it cannot be made E_STRICT-clean while + // continuing to work on PHP 4. + // Therefore, in phpBB 3.0.x we disable E_STRICT on PHP 5.4+, + // while phpBB 3.1 will fix utf8 normalizer. + // E_STRICT is defined starting with PHP 5 + if (!defined('E_STRICT')) + { + define('E_STRICT', 2048); + } + $level &= ~E_STRICT; +} error_reporting($level); /* From ccdd176b72250be2e8f72bd13147679a5f2a263b Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Fri, 16 Mar 2012 04:56:41 -0400 Subject: [PATCH 056/335] [task/php54-ascraeus] Bring p_master#module_auth into PHP 5 era. Split module_auth into a static and a non-static version. Call the static version statically and the non-static version non-statically. PHPBB3-10615 --- phpBB/includes/acp/acp_users.php | 2 +- phpBB/includes/functions_module.php | 22 +++++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 97f4b1b5fd..cf6716c322 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -128,7 +128,7 @@ class acp_users $dropdown_modes = array(); while ($row = $db->sql_fetchrow($result)) { - if (!$this->p_master->module_auth($row['module_auth'])) + if (!$this->p_master->module_auth_self($row['module_auth'])) { continue; } diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index db7defdc48..1c1bc42a11 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -128,7 +128,7 @@ class p_master foreach ($this->module_cache['modules'] as $key => $row) { // Not allowed to view module? - if (!$this->module_auth($row['module_auth'])) + if (!$this->module_auth_self($row['module_auth'])) { unset($this->module_cache['modules'][$key]); continue; @@ -315,9 +315,23 @@ class p_master } /** - * Check module authorisation + * Check module authorisation. + * + * This is a non-static version that uses $this->acl_forum_id + * for the forum id. */ - function module_auth($module_auth, $forum_id = false) + function module_auth_self($module_auth) + { + return self::module_auth($module_auth, $this->acl_forum_id); + } + + /** + * Check module authorisation. + * + * This is a static version, it must be given $forum_id. + * See also module_auth_self. + */ + static function module_auth($module_auth, $forum_id) { global $auth, $config; global $request; @@ -365,8 +379,6 @@ class p_master // Make sure $id seperation is working fine $module_auth = str_replace(' , ', ',', $module_auth); - $forum_id = ($forum_id === false) ? $this->acl_forum_id : $forum_id; - $is_auth = false; eval('$is_auth = (int) (' . preg_replace(array('#acl_([a-z0-9_]+)(,\$id)?#', '#\$id#', '#aclf_([a-z0-9_]+)#', '#cfg_([a-z0-9_]+)#', '#request_([a-zA-Z0-9_]+)#'), array('(int) $auth->acl_get(\'\\1\'\\2)', '(int) $forum_id', '(int) $auth->acl_getf_global(\'\\1\')', '(int) $config[\'\\1\']', '$request->variable(\'\\1\', false)'), $module_auth) . ');'); From 9a07f5287c91549dc989615f0cf6dc1fd8f82e5f Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sun, 4 Mar 2012 10:32:06 +0000 Subject: [PATCH 057/335] [ticket/10510] Moved quick-mod tools into a loop. PHPBB3-10510 --- .../prosilver/template/viewtopic_body.html | 16 +-- .../subsilver2/template/viewtopic_body.html | 16 +-- phpBB/viewtopic.php | 106 +++++++++++++++--- 3 files changed, 99 insertions(+), 39 deletions(-) diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index 674f8b1ff4..320d6cb97d 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -259,19 +259,9 @@
{S_FORM_TOKEN} diff --git a/phpBB/styles/subsilver2/template/viewtopic_body.html b/phpBB/styles/subsilver2/template/viewtopic_body.html index a431d51c79..f696254249 100644 --- a/phpBB/styles/subsilver2/template/viewtopic_body.html +++ b/phpBB/styles/subsilver2/template/viewtopic_body.html @@ -352,19 +352,9 @@
{L_QUICK_MOD}:
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 450ebfeda8..12a611ce6f 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -517,6 +517,99 @@ gen_forum_auth_level('topic', $forum_id, $topic_data['forum_status']); // Quick mod tools $allow_change_type = ($auth->acl_get('m_', $forum_id) || ($user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'])) ? true : false; +if ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED)) +{ + $template->assign_block_vars('quickmod', array( + 'VALUE' => (($topic_data['topic_status'] == ITEM_UNLOCKED) ? 'lock' : 'unlock'), + 'TITLE' => $user->lang[(($topic_data['topic_status'] == ITEM_UNLOCKED) ? 'LOCK' : 'UNLOCK') . '_TOPIC'] + )); +} + +if ($auth->acl_get('m_delete', $forum_id)) +{ + $template->assign_block_vars('quickmod', array( + 'VALUE' => 'delete_topic', + 'TITLE' => $user->lang['DELETE_TOPIC'] + )); +} + +if ($auth->acl_get('m_move', $forum_id) && $topic_data['topic_status'] != ITEM_MOVED) +{ + $template->assign_block_vars('quickmod', array( + 'VALUE' => 'move', + 'TITLE' => $user->lang['MOVE_TOPIC'] + )); +} + +if ($auth->acl_get('m_split', $forum_id)) +{ + $template->assign_block_vars('quickmod', array( + 'VALUE' => 'split', + 'TITLE' => $user->lang['SPLIT_TOPIC'] + )); +} + +if ($auth->acl_get('m_merge', $forum_id)) +{ + $template->assign_block_vars('quickmod', array( + 'VALUE' => 'merge', + 'TITLE' => $user->lang['MERGE_POSTS'] + )); + + $template->assign_block_vars('quickmod', array( + 'VALUE' => 'merge_topic', + 'TITLE' => $user->lang['MERGE_TOPIC'] + )); +} + +if ($auth->acl_get('m_move', $forum_id)) +{ + $template->assign_block_vars('quickmod', array( + 'VALUE' => 'fork', + 'TITLE' => $user->lang['FORK_TOPIC'] + )); +} + +if ($allow_change_type && $auth->acl_gets('f_sticky', 'f_announce', $forum_id) && $topic_data['topic_type'] != POST_NORMAL) +{ + $template->assign_block_vars('quickmod', array( + 'VALUE' => 'make_normal', + 'TITLE' => $user->lang['MAKE_NORMAL'] + )); +} + +if ($allow_change_type && $auth->acl_get('f_sticky', $forum_id) && $topic_data['topic_type'] != POST_STICKY) +{ + $template->assign_block_vars('quickmod', array( + 'VALUE' => 'make_sticky', + 'TITLE' => $user->lang['MAKE_STICKY'] + )); +} + +if ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_ANNOUNCE) +{ + $template->assign_block_vars('quickmod', array( + 'VALUE' => 'make_announce', + 'TITLE' => $user->lang['MAKE_ANNOUNCE'] + )); +} + +if ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_GLOBAL) +{ + $template->assign_block_vars('quickmod', array( + 'VALUE' => 'make_global', + 'TITLE' => $user->lang['MAKE_GLOBAL'] + )); +} + +if ($auth->acl_get('m_', $forum_id)) +{ + $template->assign_block_vars('quickmod', array( + 'VALUE' => 'topic_logs', + 'TITLE' => $user->lang['VIEW_TOPIC_LOGS'] + )); +} + // If we've got a hightlight set pass it on to pagination. $pagination = generate_pagination(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . ((strlen($u_sort_param)) ? "&$u_sort_param" : '') . (($highlight_match) ? "&hilit=$highlight" : '')), $total_posts, $config['posts_per_page'], $start); @@ -603,19 +696,6 @@ $template->assign_vars(array( 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_SINGLE_MODERATOR' => (!empty($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id]) > 1) ? false : true, 'S_TOPIC_ACTION' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start")), - 'S_TOPIC_MOD_LOCK' => ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED)) ? (($topic_data['topic_status'] == ITEM_UNLOCKED) ? 'lock' : 'unlock') : '', - 'S_TOPIC_MOD_DELETE' => ($auth->acl_get('m_delete', $forum_id)) ? true : false, - 'S_TOPIC_MOD_MOVE' => ($auth->acl_get('m_move', $forum_id) && $topic_data['topic_status'] != ITEM_MOVED) ? true : false, - 'S_TOPIC_MOD_SPLIT' => ($auth->acl_get('m_split', $forum_id)) ? true : false, - 'S_TOPIC_MOD_MERGE' => ($auth->acl_get('m_merge', $forum_id)) ? true : false, - 'S_TOPIC_MOD_MERGE_TOPIC' => ($auth->acl_get('m_merge', $forum_id)) ? true : false, - 'S_TOPIC_MOD_FORK' => ($auth->acl_get('m_move', $forum_id)) ? true : false, - 'S_TOPIC_MOD_MAKE_NORMAL' => ($allow_change_type && $auth->acl_gets('f_sticky', 'f_announce', $forum_id) && $topic_data['topic_type'] != POST_NORMAL) ? true : false, - 'S_TOPIC_MOD_MAKE_STICKY' => ($allow_change_type && $auth->acl_get('f_sticky', $forum_id) && $topic_data['topic_type'] != POST_STICKY) ? true : false, - 'S_TOPIC_MOD_MAKE_ANNOUNCE' => ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_ANNOUNCE) ? true : false, - 'S_TOPIC_MOD_MAKE_GLOBAL' => ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_GLOBAL) ? true : false, - 'S_TOPIC_MOD_TOPIC_LOGS' => ($auth->acl_get('m_', $forum_id)), - 'S_MOD_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start") . "&quickmod=1&redirect=" . urlencode(str_replace('&', '&', $viewtopic_url)), true, $user->session_id), 'S_VIEWTOPIC' => true, From c52e99fdbb4854f57ab8e4c6ad1fe06c4944a492 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Thu, 8 Mar 2012 18:41:22 +0000 Subject: [PATCH 058/335] [ticket/10510] Fixed a bug where quickmod tools weren't being displayed. It was referring to some template variables that were removed in a previous commit. Changed! PHPBB3-10510 --- phpBB/styles/prosilver/template/viewtopic_body.html | 2 +- phpBB/styles/subsilver2/template/viewtopic_body.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index 320d6cb97d..59e464d22e 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -254,7 +254,7 @@ - +
diff --git a/phpBB/styles/subsilver2/template/viewtopic_body.html b/phpBB/styles/subsilver2/template/viewtopic_body.html index f696254249..2c5351b926 100644 --- a/phpBB/styles/subsilver2/template/viewtopic_body.html +++ b/phpBB/styles/subsilver2/template/viewtopic_body.html @@ -348,7 +348,7 @@ - +
- + {L_QUICK_MOD}:
+ {REPORTED_IMG}
{topic_review_row.MESSAGE}
From 6f5c0dddfcd2a1b56fe1e8cf783f48ecfc8561e9 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Tue, 14 Feb 2012 07:58:30 +0000 Subject: [PATCH 071/335] [feature/save-post-on-report] Bug fix table name There was a bug in the previous commit. I changed the name of the colon of the table and forgot to update the database_update.php now it's fixed. PHPBB3-10600 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 0a2c3998c4..7240e899a6 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1089,7 +1089,7 @@ function database_update_info() 'field_show_on_pm' => array('BOOL', 0), ), REPORTS_TABLE => array( - 'reported_post' => array('TEXT', ''), + 'reported_text' => array('TEXT', ''), ), ), 'change_columns' => array( From 18373035c3299e80b2c075cfc3d475c89af3cc73 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Wed, 15 Feb 2012 22:03:32 +0000 Subject: [PATCH 072/335] [feature/save-post-on-report] Changed the name of the column The name of the column was changed from reported_post AND reported_text to reported_post_text. This change was made by request PHPBB3-10600 --- phpBB/develop/create_schema_files.php | 2 +- phpBB/includes/mcp/mcp_reports.php | 4 ++-- phpBB/install/database_update.php | 2 +- phpBB/install/schemas/firebird_schema.sql | 2 +- phpBB/install/schemas/mssql_schema.sql | 2 +- phpBB/install/schemas/mysql_40_schema.sql | 2 +- phpBB/install/schemas/mysql_41_schema.sql | 2 +- phpBB/install/schemas/oracle_schema.sql | 2 +- phpBB/install/schemas/postgres_schema.sql | 2 +- phpBB/install/schemas/sqlite_schema.sql | 2 +- phpBB/report.php | 10 +++++----- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index a4738df5bf..987c9152d4 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1528,7 +1528,7 @@ function get_schema_struct() 'report_closed' => array('BOOL', 0), 'report_time' => array('TIMESTAMP', 0), 'report_text' => array('MTEXT_UNI', ''), - 'reported_post' => array('MTEXT_UNI', ''), + 'reported_post_text' => array('MTEXT_UNI', ''), ), 'PRIMARY_KEY' => 'report_id', 'KEYS' => array( diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index c848175c79..b4756b2600 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -71,7 +71,7 @@ class mcp_reports // closed reports are accessed by report id $report_id = request_var('r', 0); - $sql = 'SELECT r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, r.reported_text, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour + $sql = 'SELECT r.post_id, r.user_id, r.report_id, r.report_closed, report_time, r.report_text, r.reported_post_text, rr.reason_title, rr.reason_description, u.username, u.username_clean, u.user_colour FROM ' . REPORTS_TABLE . ' r, ' . REPORTS_REASONS_TABLE . ' rr, ' . USERS_TABLE . ' u WHERE ' . (($report_id) ? 'r.report_id = ' . $report_id : "r.post_id = $post_id") . ' AND rr.reason_id = r.reason_id @@ -226,7 +226,7 @@ class mcp_reports 'REPORTER_NAME' => get_username_string('username', $report['user_id'], $report['username'], $report['user_colour']), 'U_VIEW_REPORTER_PROFILE' => get_username_string('profile', $report['user_id'], $report['username'], $report['user_colour']), - 'POST_PREVIEW' => $report['reported_text'], + 'POST_PREVIEW' => $report['reported_post_text'], 'POST_SUBJECT' => ($post_info['post_subject']) ? $post_info['post_subject'] : $user->lang['NO_SUBJECT'], 'POST_DATE' => $user->format_date($post_info['post_time']), 'POST_IP' => $post_info['poster_ip'], diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 7240e899a6..2fdbd16e4a 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1089,7 +1089,7 @@ function database_update_info() 'field_show_on_pm' => array('BOOL', 0), ), REPORTS_TABLE => array( - 'reported_text' => array('TEXT', ''), + 'reported_post_text' => array('TEXT', ''), ), ), 'change_columns' => array( diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql index 518f1bcd4f..b88ed0a64a 100644 --- a/phpBB/install/schemas/firebird_schema.sql +++ b/phpBB/install/schemas/firebird_schema.sql @@ -910,7 +910,7 @@ CREATE TABLE phpbb_reports ( report_closed INTEGER DEFAULT 0 NOT NULL, report_time INTEGER DEFAULT 0 NOT NULL, report_text BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL, - reported_post BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL + reported_post_text BLOB SUB_TYPE TEXT CHARACTER SET UTF8 DEFAULT '' NOT NULL );; ALTER TABLE phpbb_reports ADD PRIMARY KEY (report_id);; diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 526ce0f65b..a0399756e9 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -1109,7 +1109,7 @@ CREATE TABLE [phpbb_reports] ( [report_closed] [int] DEFAULT (0) NOT NULL , [report_time] [int] DEFAULT (0) NOT NULL , [report_text] [text] DEFAULT ('') NOT NULL , - [reported_post] [text] DEFAULT ('') NOT NULL + [reported_post_text] [text] DEFAULT ('') NOT NULL ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 22276b0d1f..69648c6b14 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -647,7 +647,7 @@ CREATE TABLE phpbb_reports ( report_closed tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, report_time int(11) UNSIGNED DEFAULT '0' NOT NULL, report_text mediumblob NOT NULL, - reported_post mediumblob NOT NULL, + reported_post_text mediumblob NOT NULL, PRIMARY KEY (report_id), KEY post_id (post_id), KEY pm_id (pm_id) diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index 7513b4518d..9b32ee19c6 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -647,7 +647,7 @@ CREATE TABLE phpbb_reports ( report_closed tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, report_time int(11) UNSIGNED DEFAULT '0' NOT NULL, report_text mediumtext NOT NULL, - reported_post mediumtext NOT NULL, + reported_post_text mediumtext NOT NULL, PRIMARY KEY (report_id), KEY post_id (post_id), KEY pm_id (pm_id) diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index 3982686c0d..032c8633dd 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -1214,7 +1214,7 @@ CREATE TABLE phpbb_reports ( report_closed number(1) DEFAULT '0' NOT NULL, report_time number(11) DEFAULT '0' NOT NULL, report_text clob DEFAULT '' , - reported_post clob DEFAULT '' , + reported_post_text clob DEFAULT '' , CONSTRAINT pk_phpbb_reports PRIMARY KEY (report_id) ) / diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index 69685e45aa..f482920776 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -853,7 +853,7 @@ CREATE TABLE phpbb_reports ( report_closed INT2 DEFAULT '0' NOT NULL CHECK (report_closed >= 0), report_time INT4 DEFAULT '0' NOT NULL CHECK (report_time >= 0), report_text TEXT DEFAULT '' NOT NULL, - reported_post TEXT DEFAULT '' NOT NULL, + reported_post_text TEXT DEFAULT '' NOT NULL, PRIMARY KEY (report_id) ); diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index 3916493bea..56468bcdd9 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -628,7 +628,7 @@ CREATE TABLE phpbb_reports ( report_closed INTEGER UNSIGNED NOT NULL DEFAULT '0', report_time INTEGER UNSIGNED NOT NULL DEFAULT '0', report_text mediumtext(16777215) NOT NULL DEFAULT '', - reported_post mediumtext(16777215) NOT NULL DEFAULT '' + reported_post_text mediumtext(16777215) NOT NULL DEFAULT '' ); CREATE INDEX phpbb_reports_post_id ON phpbb_reports (post_id); diff --git a/phpBB/report.php b/phpBB/report.php index ab4de68cea..29b46a6211 100644 --- a/phpBB/report.php +++ b/phpBB/report.php @@ -71,9 +71,9 @@ if ($post_id) trigger_error('POST_NOT_EXIST'); } - $forum_id = (int) $report_data['forum_id']; - $topic_id = (int) $report_data['topic_id']; - $reported_text = $report_data['post_text']; + $forum_id = (int) $report_data['forum_id']; + $topic_id = (int) $report_data['topic_id']; + $reported_post_text = $report_data['post_text']; $sql = 'SELECT * FROM ' . FORUMS_TABLE . ' @@ -132,7 +132,7 @@ else trigger_error($message); } - $reported_text = $report_data['message_text']; + $reported_post_text = $report_data['message_text']; } // Submit report? @@ -159,7 +159,7 @@ if ($submit && $reason_id) 'report_closed' => 0, 'report_time' => (int) time(), 'report_text' => (string) $report_text, - 'reported_text' => $reported_text, + 'reported_post_text' => $reported_post_text, ); $sql = 'INSERT INTO ' . REPORTS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary); From 165a2d1aa879f1fc65448721da5f6d143aff91fe Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Thu, 8 Mar 2012 09:16:36 +0000 Subject: [PATCH 073/335] [feature/save-post-on-report] Change the column type of reported text What ever it said. I changed the type of data in the column reported_post_text to match what was requested by p PHPBB3-10600 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 2fdbd16e4a..8a7ec1004e 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1089,7 +1089,7 @@ function database_update_info() 'field_show_on_pm' => array('BOOL', 0), ), REPORTS_TABLE => array( - 'reported_post_text' => array('TEXT', ''), + 'reported_post_text' => array('MTEXT_UNI', ''), ), ), 'change_columns' => array( From 28c6b95100014bc9237c50c16e6b69a96102e7c6 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Thu, 8 Mar 2012 22:04:56 +0000 Subject: [PATCH 074/335] [feature/save-post-on-report] bbcode_nl2br missing. New lines were missing in the reported_post_text. By adding the bbcode_nl2br() became as it is supposed to. PHPBB3-10600 --- phpBB/includes/mcp/mcp_reports.php | 7 ++++--- phpBB/styles/prosilver/template/posting_topic_review.html | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index b4756b2600..69c6a4cfff 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -116,8 +116,9 @@ class mcp_reports $template->assign_vars(array( 'S_TOPIC_REVIEW' => true, 'S_BBCODE_ALLOWED' => $post_info['enable_bbcode'], - 'TOPIC_TITLE' => $post_info['topic_title']) - ); + 'TOPIC_TITLE' => $post_info['topic_title'], + 'REPORTED_POST_ID' => $post_id, + )); } $topic_tracking_info = $extensions = $attachments = array(); @@ -226,7 +227,7 @@ class mcp_reports 'REPORTER_NAME' => get_username_string('username', $report['user_id'], $report['username'], $report['user_colour']), 'U_VIEW_REPORTER_PROFILE' => get_username_string('profile', $report['user_id'], $report['username'], $report['user_colour']), - 'POST_PREVIEW' => $report['reported_post_text'], + 'POST_PREVIEW' => bbcode_nl2br($report['reported_post_text']), 'POST_SUBJECT' => ($post_info['post_subject']) ? $post_info['post_subject'] : $user->lang['NO_SUBJECT'], 'POST_DATE' => $user->format_date($post_info['post_time']), 'POST_IP' => $post_info['poster_ip'], diff --git a/phpBB/styles/prosilver/template/posting_topic_review.html b/phpBB/styles/prosilver/template/posting_topic_review.html index a022048c34..1c4b67044d 100644 --- a/phpBB/styles/prosilver/template/posting_topic_review.html +++ b/phpBB/styles/prosilver/template/posting_topic_review.html @@ -17,7 +17,7 @@
{topic_review_row.L_IGNORE_POST} -
+
From 3a044b4b3ef6b5a7c27ea357bc3b7d7dd101a262 Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Fri, 9 Mar 2012 15:56:43 +0000 Subject: [PATCH 075/335] [feature/save-post-on-report] Changed mark in subsilver2 to look like viewtopic As cyberalien requested. This was changed to match better the idea behind what was made in prosilver to subsilver2. PHPBB3-10600 --- .../styles/subsilver2/template/posting_topic_review.html | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/phpBB/styles/subsilver2/template/posting_topic_review.html b/phpBB/styles/subsilver2/template/posting_topic_review.html index 92f71c2307..cbd6746a8a 100644 --- a/phpBB/styles/subsilver2/template/posting_topic_review.html +++ b/phpBB/styles/subsilver2/template/posting_topic_review.html @@ -51,7 +51,13 @@
- {REPORTED_IMG} + + + + {REPORTED_IMG} + +
+
{topic_review_row.MESSAGE}
From a0131b45f56847f7e5c44a6db66cd7359967585f Mon Sep 17 00:00:00 2001 From: David King Date: Wed, 8 Feb 2012 00:08:17 -0500 Subject: [PATCH 076/335] [ticket/10586] Extension front controller Handle extension front pages PHPBB3-10586 --- .../extension/controller_interface.php | 31 +++++++++++++++ phpBB/includes/extension/manager.php | 22 +++++++++++ phpBB/index.php | 39 +++++++++++++++++++ phpBB/language/en/common.php | 4 ++ 4 files changed, 96 insertions(+) create mode 100644 phpBB/includes/extension/controller_interface.php diff --git a/phpBB/includes/extension/controller_interface.php b/phpBB/includes/extension/controller_interface.php new file mode 100644 index 0000000000..bcc8972db4 --- /dev/null +++ b/phpBB/includes/extension/controller_interface.php @@ -0,0 +1,31 @@ +phpbb_root_path . "ext/$name/"); + } + + /** + * Check to see if a given extension is enabled + * + * @param string $name Extension name to check + * @return bool Depending on whether or not the extension is enabled + */ + public function enabled($name) + { + return isset($this->extensions[$name]) && $this->extensions[$name]['ext_active']; + } /** * Instantiates a phpbb_extension_finder. diff --git a/phpBB/index.php b/phpBB/index.php index f1243bb336..a206ed4d37 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -24,6 +24,45 @@ $user->session_begin(); $auth->acl($user->data); $user->setup('viewforum'); +// If given an extension, look for a front controller +if ($ext = $request->variable('ext', '')) +{ + // The class to load + $class = "phpbb_ext_{$ext}_controller"; + + // Make sure the specified extension is enabled + // and that it has a controller class + if (!$phpbb_extension_manager->available($ext)) + { + send_status_line(404, 'Not Found'); + trigger_error($user->lang('EXTENSION_DOES_NOT_EXIST', $ext)); + } + else if (!$phpbb_extension_manager->enabled($ext)) + { + send_status_line(404, 'Not Found'); + trigger_error($user->lang('EXTENSION_DISABLED', $ext)); + } + else if (!file_exists("{$phpbb_root_path}ext/$ext/controller.$phpEx") || !class_exists($class)) + { + send_status_line(404, 'Not Found'); + trigger_error($user->lang('EXTENSION_CONTROLLER_MISSING', $ext)); + } + + // Instantiate the extension controller + $controller = new $class; + + // But let's make sure it's actually a proper controller + if (!($controller instanceof phpbb_extension_controller_interface)) + { + send_status_line(500, 'Internal Server Error'); + trigger_error($user->lang('EXTENSION_CLASS_WRONG_TYPE', $class)); + } + + // Let's get it started... + $controller->handle(); + exit_handler(); +} + display_forums('', $config['load_moderators']); $order_legend = ($config['legend_sort_groupname']) ? 'group_name' : 'group_legend'; diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 7741ff8d1f..94edddc6f5 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -185,7 +185,11 @@ $lang = array_merge($lang, array( 'ERR_WRONG_PATH_TO_PHPBB' => 'The phpBB path specified appears to be invalid.', 'EXPAND_VIEW' => 'Expand view', 'EXTENSION' => 'Extension', + 'EXTENSION_CONTROLLER_MISSING' => 'The extension %s is missing a controller class and cannot be accessed through the front-end.', + 'EXTENSION_CLASS_WRONG_TYPE' => 'The extension controller class %s is not an instance of the phpbb_extension_controller_interface.', + 'EXTENSION_DISABLED' => 'The extension %s is not enabled.', 'EXTENSION_DISABLED_AFTER_POSTING' => 'The extension %s has been deactivated and can no longer be displayed.', + 'EXTENSION_DOES_NOT_EXIST' => 'The extension %s does not exist.', 'FAQ' => 'FAQ', 'FAQ_EXPLAIN' => 'Frequently Asked Questions', From 969c6d42e390fe05960d9dd3b97b230d4e7830a0 Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 17 Feb 2012 14:21:28 -0500 Subject: [PATCH 077/335] [ticket/10586] Removed file_exists() check because class_exists() covers that. PHPBB3-10586 --- phpBB/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/index.php b/phpBB/index.php index a206ed4d37..575134f6b1 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -42,7 +42,7 @@ if ($ext = $request->variable('ext', '')) send_status_line(404, 'Not Found'); trigger_error($user->lang('EXTENSION_DISABLED', $ext)); } - else if (!file_exists("{$phpbb_root_path}ext/$ext/controller.$phpEx") || !class_exists($class)) + else if (!class_exists($class)) { send_status_line(404, 'Not Found'); trigger_error($user->lang('EXTENSION_CONTROLLER_MISSING', $ext)); From e45452d1b3d39220ebd9b20390b9cc23ef64d3dd Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 18 Feb 2012 11:24:27 -0500 Subject: [PATCH 078/335] [ticket/10586] Sanitize periods from class names, use manager to get path. PHPBB3-10586 --- phpBB/includes/extension/manager.php | 2 +- phpBB/index.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index b94379141c..6f1c885ea9 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -437,7 +437,7 @@ class phpbb_extension_manager */ public function available($name) { - return file_exists($this->phpbb_root_path . "ext/$name/"); + return file_exists($this->get_extension_path($name, true)); } /** diff --git a/phpBB/index.php b/phpBB/index.php index 575134f6b1..e6a472ce31 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -28,7 +28,7 @@ $user->setup('viewforum'); if ($ext = $request->variable('ext', '')) { // The class to load - $class = "phpbb_ext_{$ext}_controller"; + $class = 'phpbb_ext_' . str_replace('/', '_', $name) . '_controller'; // Make sure the specified extension is enabled // and that it has a controller class From e5ce9646567e6b3441c21ab960f8a77f1281c72b Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 18 Feb 2012 11:34:07 -0500 Subject: [PATCH 079/335] [ticket/10586] Copy/paste fail fixed PHPBB3-10586 --- phpBB/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/index.php b/phpBB/index.php index e6a472ce31..2500774f67 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -28,7 +28,7 @@ $user->setup('viewforum'); if ($ext = $request->variable('ext', '')) { // The class to load - $class = 'phpbb_ext_' . str_replace('/', '_', $name) . '_controller'; + $class = 'phpbb_ext_' . str_replace('/', '_', $ext) . '_controller'; // Make sure the specified extension is enabled // and that it has a controller class From 401de113f9a0cec57c9648a079303d30fdb23666 Mon Sep 17 00:00:00 2001 From: David King Date: Sun, 19 Feb 2012 15:26:20 -0500 Subject: [PATCH 080/335] [ticket/10586] test stuff. does not work yet, still need to put phpBB objects in bootstrap.php --- .../functional/extension_controller_test.php | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 tests/functional/extension_controller_test.php diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php new file mode 100644 index 0000000000..7f0bccc485 --- /dev/null +++ b/tests/functional/extension_controller_test.php @@ -0,0 +1,96 @@ +enable('foobar'); + $phpbb_extension_manager->enable('foo_bar'); + $phpbb_extension_manager->enable('error_class'); + $phpbb_extension_manager->enable('error_classtype'); + } + + public function tearDown() + { + global $db, $cache; + $phpbb_extension_manager = new phpbb_extension_manager($db, 'phpbb_ext', '.php', $cache, '_cache'); + + $phpbb_extension_manager->purge('foobar'); + $phpbb_extension_manager->purge('foo_bar'); + $phpbb_extension_manager->purge('error_class'); + $phpbb_extension_manager->purge('error_classtype'); + } + + /** + * Check an extension at ./ext/foobar/ which should have the class + * phpbb_ext_foobar_controller + */ + public function test_foobar() + { + $crawler = $this->request('GET', 'index.php?ext=foobar'); + $this->assertGreaterThan(0, $crawler->filter('#welcome')->count()); + } + + /** + * Check an extension at ./ext/foo/bar/ which should have the class + * phpbb_ext_foo_bar_controller + */ + public function test_foo_bar() + { + $crawler = $this->request('GET', 'index.php?ext=foo/bar'); + $this->assertGreaterThan(0, $crawler->filter('#welcome')->count()); + } + + /** + * Check the error produced by extension at ./ext/error/class which has class + * phpbb_ext_foobar_controller + */ + public function test_error_class_name() + { + $crawler = $this->request('GET', 'index.php?ext=error/class'); + $this->assertGreaterThan(0, $crawler->filter('html:contains("The extension error_class is missing a controller class and cannot be accessed through the front-end.")')->count()); + } + + /** + * Check the error produced by extension at ./ext/error/classtype which has class + * phpbb_ext_error_classtype_controller but does not implement phpbb_extension_controller_interface + */ + public function test_error_class_type() + { + $crawler = $this->request('GET', 'index.php?ext=error/classtype'); + $this->assertGreaterThan(0, $crawler->filter('html:contains("The extension controller class phpbb_ext_error_classtype_controller is not an instance of the phpbb_extension_controller_interface.")')->count()); + } + + /** + * Check the error produced by extension at ./ext/error/disabled that is (obviously) + * a disabled extension + */ + public function test_error_ext_disabled() + { + $crawler = $this->request('GET', 'index.php?ext=error/disabled'); + $this->assertGreaterThan(0, $crawler->filter('html:contains("The extension error_classtype is not enabled.")')->count()); + } + + /** + * Check the error produced by extension at ./ext/error/404 that is (obviously) + * not existant + */ + public function test_error_ext_missing() + { + $crawler = $this->request('GET', 'index.php?ext=error/404'); + $this->assertGreaterThan(0, $crawler->filter('html:contains("The extension error_404 does not exist.")')->count()); + } +} From 9212466626a3d80a90cab1f23cf423a1c4e20655 Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 21 Feb 2012 09:38:53 -0500 Subject: [PATCH 081/335] [ticket/10586] some bootstrap additions and test changes to try and make it work PHPBB3-10586 --- tests/bootstrap.php | 36 +++++++++++++++++++ .../functional/extension_controller_test.php | 6 ++-- 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 302701e3b3..e98ec384e6 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -26,6 +26,42 @@ require_once 'test_framework/phpbb_test_case.php'; require_once 'test_framework/phpbb_database_test_case.php'; require_once 'test_framework/phpbb_database_test_connection_manager.php'; +// For functional tests, we need to make available the phpBB objects +require_once $phpbb_root_path . 'config.php'; +// Setup class loader first +$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".$phpEx"); +$phpbb_class_loader_ext->register(); +$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx"); +$phpbb_class_loader->register(); + +// set up caching +$cache_factory = new phpbb_cache_factory($acm_type); +$cache = $cache_factory->get_service(); +$phpbb_class_loader_ext->set_cache($cache->get_driver()); +$phpbb_class_loader->set_cache($cache->get_driver()); + +// We have to include this because the class loader doesn't +// recognize classes without the phpbb_ prefix +// So user and auth and the DBAL aren't found unless we require these files +require($phpbb_root_path . 'includes/session.' . $phpEx); +require($phpbb_root_path . 'includes/auth.' . $phpEx); +require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); +// Instantiate some basic classes +$user = new user(); +$auth = new auth(); +$db = new $sql_db(); + +$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false); + +// We do not need this any longer, unset for safety purposes +unset($dbpasswd); + +// Grab global variables, re-cache if necessary +$config = new phpbb_config_db($db, $cache->get_driver(), CONFIG_TABLE); + +// load extensions +$phpbb_extension_manager = new phpbb_extension_manager($db, EXT_TABLE, $phpbb_root_path, ".$phpEx", $cache->get_driver()); + if (version_compare(PHP_VERSION, '5.3.0-dev', '>=')) { require_once 'test_framework/phpbb_functional_test_case.php'; diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index 7f0bccc485..430d93f9bf 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -14,8 +14,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c { public function setUp() { - global $db, $cache; - $phpbb_extension_manager = new phpbb_extension_manager($db, 'phpbb_ext', '.php', $cache, '_cache'); + global $phpbb_extension_manager; $phpbb_extension_manager->enable('foobar'); $phpbb_extension_manager->enable('foo_bar'); @@ -25,8 +24,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c public function tearDown() { - global $db, $cache; - $phpbb_extension_manager = new phpbb_extension_manager($db, 'phpbb_ext', '.php', $cache, '_cache'); + global $phpbb_extension_manager; $phpbb_extension_manager->purge('foobar'); $phpbb_extension_manager->purge('foo_bar'); From a37a28b48546afc880446db7e4b2fd87c70a6cda Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 21 Feb 2012 10:53:22 -0500 Subject: [PATCH 082/335] [ticket/10586] Now tests run, but fail. But here is what I have. PHPBB3-10586 --- tests/bootstrap.php | 36 ------------------- .../functional/extension_controller_test.php | 6 ++-- .../phpbb_functional_test_case.php | 20 +++++++++++ 3 files changed, 24 insertions(+), 38 deletions(-) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index e98ec384e6..302701e3b3 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -26,42 +26,6 @@ require_once 'test_framework/phpbb_test_case.php'; require_once 'test_framework/phpbb_database_test_case.php'; require_once 'test_framework/phpbb_database_test_connection_manager.php'; -// For functional tests, we need to make available the phpBB objects -require_once $phpbb_root_path . 'config.php'; -// Setup class loader first -$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".$phpEx"); -$phpbb_class_loader_ext->register(); -$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx"); -$phpbb_class_loader->register(); - -// set up caching -$cache_factory = new phpbb_cache_factory($acm_type); -$cache = $cache_factory->get_service(); -$phpbb_class_loader_ext->set_cache($cache->get_driver()); -$phpbb_class_loader->set_cache($cache->get_driver()); - -// We have to include this because the class loader doesn't -// recognize classes without the phpbb_ prefix -// So user and auth and the DBAL aren't found unless we require these files -require($phpbb_root_path . 'includes/session.' . $phpEx); -require($phpbb_root_path . 'includes/auth.' . $phpEx); -require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); -// Instantiate some basic classes -$user = new user(); -$auth = new auth(); -$db = new $sql_db(); - -$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false); - -// We do not need this any longer, unset for safety purposes -unset($dbpasswd); - -// Grab global variables, re-cache if necessary -$config = new phpbb_config_db($db, $cache->get_driver(), CONFIG_TABLE); - -// load extensions -$phpbb_extension_manager = new phpbb_extension_manager($db, EXT_TABLE, $phpbb_root_path, ".$phpEx", $cache->get_driver()); - if (version_compare(PHP_VERSION, '5.3.0-dev', '>=')) { require_once 'test_framework/phpbb_functional_test_case.php'; diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index 430d93f9bf..7e50eb7d91 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -14,7 +14,8 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c { public function setUp() { - global $phpbb_extension_manager; + parent::setUp(); + $phpbb_extension_manager = $this->get_ext_manager(); $phpbb_extension_manager->enable('foobar'); $phpbb_extension_manager->enable('foo_bar'); @@ -24,7 +25,8 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c public function tearDown() { - global $phpbb_extension_manager; + parent::tearDown(); + $phpbb_extension_manager = $this->get_ext_manager(); $phpbb_extension_manager->purge('foobar'); $phpbb_extension_manager->purge('foo_bar'); diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index b5e6f7e377..b2ae215d91 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -66,6 +66,26 @@ class phpbb_functional_test_case extends phpbb_test_case } } + protected function get_db() + { + global $phpbb_root_path, $phpEx; + if (!class_exists('dbal_' . self::$config['dbms'])) + { + include($phpbb_root_path . 'includes/db/' . self::$config['dbms'] . ".$phpEx"); + } + $sql_db = 'dbal_' . self::$config['dbms']; + $db = new $sql_db(); + $db->sql_connect(self::$config['dbhost'], self::$config['dbuser'], self::$config['dbpasswd'], self::$config['dbname'], self::$config['dbport']); + return $db; + } + + protected function get_ext_manager() + { + global $phpbb_root_path, $phpEx; + + return new phpbb_extension_manager($this->get_db(), self::$config['table_prefix'] . 'ext', $phpbb_root_path, ".$phpEx", new phpbb_cache_driver_null); + } + protected function install_board() { global $phpbb_root_path, $phpEx; From d235262bc21657f0693501ac1154e1443578d507 Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 21 Feb 2012 11:17:21 -0500 Subject: [PATCH 083/335] [ticket/10586] Adding the extensions used by the tests PHPBB3-10586 --- .../fixtures/ext/error/class/controller.php | 17 +++++++++++++++++ .../fixtures/ext/error/class/ext.php | 6 ++++++ .../ext/error/classtype/controller.php | 17 +++++++++++++++++ .../fixtures/ext/error/classtype/ext.php | 6 ++++++ .../fixtures/ext/error/disabled/controller.php | 17 +++++++++++++++++ .../fixtures/ext/error/disabled/ext.php | 6 ++++++ .../fixtures/ext/foo/bar/controller.php | 17 +++++++++++++++++ tests/functional/fixtures/ext/foo/bar/ext.php | 6 ++++++ .../styles/prosilver/template/index_body.html | 5 +++++ .../fixtures/ext/foobar/controller.php | 17 +++++++++++++++++ tests/functional/fixtures/ext/foobar/ext.php | 6 ++++++ .../styles/prosilver/template/index_body.html | 5 +++++ .../phpbb_functional_test_case.php | 18 ++++++++++++------ 13 files changed, 137 insertions(+), 6 deletions(-) create mode 100644 tests/functional/fixtures/ext/error/class/controller.php create mode 100644 tests/functional/fixtures/ext/error/class/ext.php create mode 100644 tests/functional/fixtures/ext/error/classtype/controller.php create mode 100644 tests/functional/fixtures/ext/error/classtype/ext.php create mode 100644 tests/functional/fixtures/ext/error/disabled/controller.php create mode 100644 tests/functional/fixtures/ext/error/disabled/ext.php create mode 100644 tests/functional/fixtures/ext/foo/bar/controller.php create mode 100644 tests/functional/fixtures/ext/foo/bar/ext.php create mode 100644 tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/index_body.html create mode 100644 tests/functional/fixtures/ext/foobar/controller.php create mode 100644 tests/functional/fixtures/ext/foobar/ext.php create mode 100644 tests/functional/fixtures/ext/foobar/styles/prosilver/template/index_body.html diff --git a/tests/functional/fixtures/ext/error/class/controller.php b/tests/functional/fixtures/ext/error/class/controller.php new file mode 100644 index 0000000000..eb2ae362a6 --- /dev/null +++ b/tests/functional/fixtures/ext/error/class/controller.php @@ -0,0 +1,17 @@ +set_ext_dir_prefix($phpbb_root_path . 'ext/error/class/'); + + $template->set_filenames(array( + 'body' => 'index_body.html' + )); + + page_header('Test extension'); + page_footer(); + } +} diff --git a/tests/functional/fixtures/ext/error/class/ext.php b/tests/functional/fixtures/ext/error/class/ext.php new file mode 100644 index 0000000000..f97ad2b838 --- /dev/null +++ b/tests/functional/fixtures/ext/error/class/ext.php @@ -0,0 +1,6 @@ +set_ext_dir_prefix($phpbb_root_path . 'ext/error/classtype/'); + + $template->set_filenames(array( + 'body' => 'index_body.html' + )); + + page_header('Test extension'); + page_footer(); + } +} diff --git a/tests/functional/fixtures/ext/error/classtype/ext.php b/tests/functional/fixtures/ext/error/classtype/ext.php new file mode 100644 index 0000000000..35b1cd15a2 --- /dev/null +++ b/tests/functional/fixtures/ext/error/classtype/ext.php @@ -0,0 +1,6 @@ +set_ext_dir_prefix($phpbb_root_path . 'ext/error/disabled/'); + + $template->set_filenames(array( + 'body' => 'index_body.html' + )); + + page_header('Test extension'); + page_footer(); + } +} diff --git a/tests/functional/fixtures/ext/error/disabled/ext.php b/tests/functional/fixtures/ext/error/disabled/ext.php new file mode 100644 index 0000000000..aec8051848 --- /dev/null +++ b/tests/functional/fixtures/ext/error/disabled/ext.php @@ -0,0 +1,6 @@ +set_ext_dir_prefix($phpbb_root_path . 'ext/foo/bar/'); + + $template->set_filenames(array( + 'body' => 'index_body.html' + )); + + page_header('Test extension'); + page_footer(); + } +} diff --git a/tests/functional/fixtures/ext/foo/bar/ext.php b/tests/functional/fixtures/ext/foo/bar/ext.php new file mode 100644 index 0000000000..3a2068631e --- /dev/null +++ b/tests/functional/fixtures/ext/foo/bar/ext.php @@ -0,0 +1,6 @@ + + +
This is for testing purposes.
+ + diff --git a/tests/functional/fixtures/ext/foobar/controller.php b/tests/functional/fixtures/ext/foobar/controller.php new file mode 100644 index 0000000000..c3ef29ffef --- /dev/null +++ b/tests/functional/fixtures/ext/foobar/controller.php @@ -0,0 +1,17 @@ +set_ext_dir_prefix($phpbb_root_path . 'ext/foobar/'); + + $template->set_filenames(array( + 'body' => 'index_body.html' + )); + + page_header('Test extension'); + page_footer(); + } +} diff --git a/tests/functional/fixtures/ext/foobar/ext.php b/tests/functional/fixtures/ext/foobar/ext.php new file mode 100644 index 0000000000..7b3f37cbfb --- /dev/null +++ b/tests/functional/fixtures/ext/foobar/ext.php @@ -0,0 +1,6 @@ + + +
This is for testing purposes.
+ + diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index b2ae215d91..9797ecfef8 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -14,6 +14,8 @@ class phpbb_functional_test_case extends phpbb_test_case protected $client; protected $root_url; + protected $db = null; + static protected $config = array(); static protected $already_installed = false; @@ -69,14 +71,18 @@ class phpbb_functional_test_case extends phpbb_test_case protected function get_db() { global $phpbb_root_path, $phpEx; - if (!class_exists('dbal_' . self::$config['dbms'])) + // so we don't reopen an open connection + if (!($this->db instanceof dbal)) { - include($phpbb_root_path . 'includes/db/' . self::$config['dbms'] . ".$phpEx"); + if (!class_exists('dbal_' . self::$config['dbms'])) + { + include($phpbb_root_path . 'includes/db/' . self::$config['dbms'] . ".$phpEx"); + } + $sql_db = 'dbal_' . self::$config['dbms']; + $this->db = new $sql_db(); + $this->db->sql_connect(self::$config['dbhost'], self::$config['dbuser'], self::$config['dbpasswd'], self::$config['dbname'], self::$config['dbport']); } - $sql_db = 'dbal_' . self::$config['dbms']; - $db = new $sql_db(); - $db->sql_connect(self::$config['dbhost'], self::$config['dbuser'], self::$config['dbpasswd'], self::$config['dbname'], self::$config['dbport']); - return $db; + return $this->db; } protected function get_ext_manager() From 7b44d6f21a5a8be289bf6810f2c38d580647581e Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 16 Mar 2012 15:35:01 -0400 Subject: [PATCH 084/335] [ticket/10586] initial work on copying fixtures. Note that this depends on 10706 PHPBB3-10586 --- .../functional/extension_controller_test.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index 7e50eb7d91..b52174bbd5 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -12,6 +12,39 @@ */ class phpbb_functional_extension_controller_test extends phpbb_functional_test_case { + /** + * This should only be called once before the tests are run. + * This is used to copy the fixtures to the phpBB install + */ + static public function setUpBeforeClass() + { + parent::setUpBeforeClass(); + // When you add new tests that require new fixtures, add them to the array. + $fixtures = array( + 'error/class/controller.php', + 'error/class/ext.php', + 'error/classtype/controller.php', + 'error/classtype/ext.php', + 'error/disabled/controller.php', + 'error/disabled/ext.php', + 'foo/bar/controller.php', + 'foo/bar/ext.php', + 'foo/bar/styles/prosilver/template/index_body.html', + 'foobar/controller.php', + 'foobar/ext.php', + 'foobar/styles/prosilver/template/index_body.html', + ); + + foreach ($fixtures as $fixture) + { + // we have to use self::$config['phpbb_functional_url'] because $this->root_url is not available in static classes + if(!copy("tests/functional/fixtures/ext/$fixture", self::$config['phpbb_functional_url'] . "/ext/$fixture")) + { + echo 'Could not copy file ' . $fixture; + } + } + } + public function setUp() { parent::setUp(); From 66b45318efea886ac6afc1f332cc94ee2af1c494 Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 16 Mar 2012 16:42:29 -0400 Subject: [PATCH 085/335] [ticket/10586] browse tests now work, but mine dont. at least we are making progress PHPBB3-10586 --- tests/functional/browse_test.php | 11 ++++++++++ .../functional/extension_controller_test.php | 22 ++++++++++++++++++- .../phpbb_test_case_helpers.php | 12 ++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/tests/functional/browse_test.php b/tests/functional/browse_test.php index 723cf93232..d119787d13 100644 --- a/tests/functional/browse_test.php +++ b/tests/functional/browse_test.php @@ -12,6 +12,17 @@ */ class phpbb_functional_browse_test extends phpbb_functional_test_case { + public static function setUpBeforeClass() + { + parent::setUpBeforeClass(); + $f_path = self::$config['phpbb_functional_path']; + // we cannot run these tests correctly if the install directory is present + if (is_dir($f_path . 'install/')) + { + rename($f_path . 'install/', $f_path . 'install_/'); + } + // NOTE: this will need to be renamed back again later if you wish to test again + } public function test_index() { $crawler = $this->request('GET', 'index.php'); diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index b52174bbd5..50710d0347 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -19,7 +19,27 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c static public function setUpBeforeClass() { parent::setUpBeforeClass(); + $f_path = self::$config['phpbb_functional_path']; + + // these directories need to be created before the files can be copied + $directories = array( + $f_path . 'ext/error/class/', + $f_path . 'ext/error/classtype/', + $f_path . 'ext/error/disabled/', + $f_path . 'ext/foo/bar/', + $f_path . 'ext/foo/bar/styles/prosilver/template/', + $f_path . 'ext/foobar/', + $f_path . 'ext/foobar/styles/prosilver/template/', + ); // When you add new tests that require new fixtures, add them to the array. + foreach ($directories as $dir) + { + if (!is_dir($dir)) + { + mkdir($dir, 0777, true); + } + } + $fixtures = array( 'error/class/controller.php', 'error/class/ext.php', @@ -38,7 +58,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c foreach ($fixtures as $fixture) { // we have to use self::$config['phpbb_functional_url'] because $this->root_url is not available in static classes - if(!copy("tests/functional/fixtures/ext/$fixture", self::$config['phpbb_functional_url'] . "/ext/$fixture")) + if(!copy("tests/functional/fixtures/ext/$fixture", "{$f_path}ext/$fixture")) { echo 'Could not copy file ' . $fixture; } diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 9c91778cb0..51b04db263 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -80,6 +80,11 @@ class phpbb_test_case_helpers { $config['phpbb_functional_url'] = $phpbb_functional_url; } + + if (isset($phpbb_functional_path)) + { + $config['phpbb_functional_path'] = $phpbb_functional_path; + } } if (isset($_SERVER['PHPBB_TEST_DBMS'])) @@ -101,6 +106,13 @@ class phpbb_test_case_helpers )); } + if (isset($_SERVER['PHPBB_FUNCTIONAL_PATH'])) + { + $config = array_merge($config, array( + 'phpbb_functional_path' => isset($_SERVER['PHPBB_FUNCTIONAL_PATH']) ? $_SERVER['PHPBB_FUNCTIONAL_PATH'] : '', + )); + } + return $config; } } From e78585c973d260651dd8487d586facd2ab9e1e51 Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 16 Mar 2012 17:18:08 -0400 Subject: [PATCH 086/335] [ticket/10586] Rename install directory back to install/ after tests PHPBB3-10586 --- tests/functional/extension_controller_test.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index 50710d0347..f137a49bf4 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -65,6 +65,17 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c } } + public static function tearDownAfterClass() + { + $f_path = self::$config['phpbb_functional_path']; + // first we rename the install_ directory back to install + rename($f_path . 'install_/', $f_path . 'install/'); + + // @todo delete the fixtures from the $f_path board + // Note that it might be best to find a public domain function + // and port it into here instead of writing it from scratch + } + public function setUp() { parent::setUp(); From 4100b312bb0eb7246e9057461b6f8f3c66fdad60 Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 17 Mar 2012 22:12:50 -0400 Subject: [PATCH 087/335] [ticket/10586] Tests are coming along, just a little more to go PHPBB3-10586 --- .../functional/extension_controller_test.php | 56 +++++++++---------- .../fixtures/ext/foo/bar/controller.php | 2 +- .../{index_body.html => foobar_body.html} | 0 .../fixtures/ext/foobar/controller.php | 2 +- .../{index_body.html => foobar_body.html} | 0 5 files changed, 28 insertions(+), 32 deletions(-) rename tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/{index_body.html => foobar_body.html} (100%) rename tests/functional/fixtures/ext/foobar/styles/prosilver/template/{index_body.html => foobar_body.html} (100%) diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index f137a49bf4..cb27511be1 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -49,10 +49,10 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c 'error/disabled/ext.php', 'foo/bar/controller.php', 'foo/bar/ext.php', - 'foo/bar/styles/prosilver/template/index_body.html', + 'foo/bar/styles/prosilver/template/foobar_body.html', 'foobar/controller.php', 'foobar/ext.php', - 'foobar/styles/prosilver/template/index_body.html', + 'foobar/styles/prosilver/template/foobar_body.html', ); foreach ($fixtures as $fixture) @@ -76,36 +76,20 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c // and port it into here instead of writing it from scratch } - public function setUp() - { - parent::setUp(); - $phpbb_extension_manager = $this->get_ext_manager(); - - $phpbb_extension_manager->enable('foobar'); - $phpbb_extension_manager->enable('foo_bar'); - $phpbb_extension_manager->enable('error_class'); - $phpbb_extension_manager->enable('error_classtype'); - } - - public function tearDown() - { - parent::tearDown(); - $phpbb_extension_manager = $this->get_ext_manager(); - - $phpbb_extension_manager->purge('foobar'); - $phpbb_extension_manager->purge('foo_bar'); - $phpbb_extension_manager->purge('error_class'); - $phpbb_extension_manager->purge('error_classtype'); - } - /** * Check an extension at ./ext/foobar/ which should have the class * phpbb_ext_foobar_controller */ public function test_foobar() { + $phpbb_extension_manager = $this->get_ext_manager(); + $phpbb_extension_manager->enable('foobar'); $crawler = $this->request('GET', 'index.php?ext=foobar'); - $this->assertGreaterThan(0, $crawler->filter('#welcome')->count()); + if($this->assertGreaterThan(0, $crawler->filter('#welcome')->count())) + { + $this->assertContains("This is for testing purposes.", $crawler->filter('#welcome')->text()); + } + $phpbb_extension_manager->purge('foobar'); } /** @@ -114,8 +98,14 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c */ public function test_foo_bar() { + $phpbb_extension_manager = $this->get_ext_manager(); + $phpbb_extension_manager->enable('foo/bar'); $crawler = $this->request('GET', 'index.php?ext=foo/bar'); - $this->assertGreaterThan(0, $crawler->filter('#welcome')->count()); + if($this->assertGreaterThan(0, $crawler->filter('#welcome')->count())) + { + $this->assertContains("This is for testing purposes.", $crawler->filter('#welcome')->text()); + } + $phpbb_extension_manager->purge('foo_bar'); } /** @@ -124,8 +114,11 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c */ public function test_error_class_name() { + $phpbb_extension_manager = $this->get_ext_manager(); + $phpbb_extension_manager->enable('error/class'); $crawler = $this->request('GET', 'index.php?ext=error/class'); - $this->assertGreaterThan(0, $crawler->filter('html:contains("The extension error_class is missing a controller class and cannot be accessed through the front-end.")')->count()); + $this->assertContains("The extension error/class is missing a controller class and cannot be accessed through the front-end.", $crawler->filter('#message')->text()); + $phpbb_extension_manager->purge('error_class'); } /** @@ -134,8 +127,11 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c */ public function test_error_class_type() { + $phpbb_extension_manager = $this->get_ext_manager(); + $phpbb_extension_manager->enable('error/classtype'); $crawler = $this->request('GET', 'index.php?ext=error/classtype'); - $this->assertGreaterThan(0, $crawler->filter('html:contains("The extension controller class phpbb_ext_error_classtype_controller is not an instance of the phpbb_extension_controller_interface.")')->count()); + $this->assertContains("The extension controller class phpbb_ext_error_classtype_controller is not an instance of the phpbb_extension_controller_interface.", $crawler->filter('#message')->text()); + $phpbb_extension_manager->purge('error_classtype'); } /** @@ -145,7 +141,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c public function test_error_ext_disabled() { $crawler = $this->request('GET', 'index.php?ext=error/disabled'); - $this->assertGreaterThan(0, $crawler->filter('html:contains("The extension error_classtype is not enabled.")')->count()); + $this->assertContains("The extension error/disabled is not enabled", $crawler->filter('#message')->text()); } /** @@ -155,6 +151,6 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c public function test_error_ext_missing() { $crawler = $this->request('GET', 'index.php?ext=error/404'); - $this->assertGreaterThan(0, $crawler->filter('html:contains("The extension error_404 does not exist.")')->count()); + $this->assertContains("The extension error/404 does not exist.", $crawler->filter('#message')->text()); } } diff --git a/tests/functional/fixtures/ext/foo/bar/controller.php b/tests/functional/fixtures/ext/foo/bar/controller.php index 93d1f099c9..24d218c412 100644 --- a/tests/functional/fixtures/ext/foo/bar/controller.php +++ b/tests/functional/fixtures/ext/foo/bar/controller.php @@ -8,7 +8,7 @@ class phpbb_ext_foo_bar_controller implements phpbb_extension_controller_interfa $template->set_ext_dir_prefix($phpbb_root_path . 'ext/foo/bar/'); $template->set_filenames(array( - 'body' => 'index_body.html' + 'body' => 'foobar_body.html' )); page_header('Test extension'); diff --git a/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/index_body.html b/tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foobar_body.html similarity index 100% rename from tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/index_body.html rename to tests/functional/fixtures/ext/foo/bar/styles/prosilver/template/foobar_body.html diff --git a/tests/functional/fixtures/ext/foobar/controller.php b/tests/functional/fixtures/ext/foobar/controller.php index c3ef29ffef..bf8d8139ae 100644 --- a/tests/functional/fixtures/ext/foobar/controller.php +++ b/tests/functional/fixtures/ext/foobar/controller.php @@ -8,7 +8,7 @@ class phpbb_ext_foobar_controller implements phpbb_extension_controller_interfac $template->set_ext_dir_prefix($phpbb_root_path . 'ext/foobar/'); $template->set_filenames(array( - 'body' => 'index_body.html' + 'body' => 'foobar_body.html' )); page_header('Test extension'); diff --git a/tests/functional/fixtures/ext/foobar/styles/prosilver/template/index_body.html b/tests/functional/fixtures/ext/foobar/styles/prosilver/template/foobar_body.html similarity index 100% rename from tests/functional/fixtures/ext/foobar/styles/prosilver/template/index_body.html rename to tests/functional/fixtures/ext/foobar/styles/prosilver/template/foobar_body.html From 7d1e4bca334dc9fcef3eb6e62cb412226ebc7ca4 Mon Sep 17 00:00:00 2001 From: David King Date: Sun, 18 Mar 2012 14:44:37 -0400 Subject: [PATCH 088/335] [ticket/10586] more work on getting tests to pass PHPBB3-10586 --- tests/functional/extension_controller_test.php | 16 +++++----------- .../phpbb_functional_test_case.php | 2 +- tests/test_framework/phpbb_test_case_helpers.php | 8 +++----- 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index cb27511be1..46f3dc6f96 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -85,10 +85,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c $phpbb_extension_manager = $this->get_ext_manager(); $phpbb_extension_manager->enable('foobar'); $crawler = $this->request('GET', 'index.php?ext=foobar'); - if($this->assertGreaterThan(0, $crawler->filter('#welcome')->count())) - { - $this->assertContains("This is for testing purposes.", $crawler->filter('#welcome')->text()); - } + $this->assertContains("This is for testing purposes.", $crawler->filter('#page-body')->text()); $phpbb_extension_manager->purge('foobar'); } @@ -101,11 +98,8 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c $phpbb_extension_manager = $this->get_ext_manager(); $phpbb_extension_manager->enable('foo/bar'); $crawler = $this->request('GET', 'index.php?ext=foo/bar'); - if($this->assertGreaterThan(0, $crawler->filter('#welcome')->count())) - { - $this->assertContains("This is for testing purposes.", $crawler->filter('#welcome')->text()); - } - $phpbb_extension_manager->purge('foo_bar'); + $this->assertContains("This is for testing purposes.", $crawler->filter('#page-body')->text()); + $phpbb_extension_manager->purge('foo/bar'); } /** @@ -118,7 +112,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c $phpbb_extension_manager->enable('error/class'); $crawler = $this->request('GET', 'index.php?ext=error/class'); $this->assertContains("The extension error/class is missing a controller class and cannot be accessed through the front-end.", $crawler->filter('#message')->text()); - $phpbb_extension_manager->purge('error_class'); + $phpbb_extension_manager->purge('error/class'); } /** @@ -131,7 +125,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c $phpbb_extension_manager->enable('error/classtype'); $crawler = $this->request('GET', 'index.php?ext=error/classtype'); $this->assertContains("The extension controller class phpbb_ext_error_classtype_controller is not an instance of the phpbb_extension_controller_interface.", $crawler->filter('#message')->text()); - $phpbb_extension_manager->purge('error_classtype'); + $phpbb_extension_manager->purge('error/classtype'); } /** diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 9797ecfef8..b3376891bc 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -89,7 +89,7 @@ class phpbb_functional_test_case extends phpbb_test_case { global $phpbb_root_path, $phpEx; - return new phpbb_extension_manager($this->get_db(), self::$config['table_prefix'] . 'ext', $phpbb_root_path, ".$phpEx", new phpbb_cache_driver_null); + return new phpbb_extension_manager($this->get_db(), self::$config['table_prefix'] . 'ext', $phpbb_root_path, ".$phpEx", new phpbb_cache_driver_file); } protected function install_board() diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 51b04db263..4aec07a8fb 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -81,7 +81,7 @@ class phpbb_test_case_helpers $config['phpbb_functional_url'] = $phpbb_functional_url; } - if (isset($phpbb_functional_path)) + if (!empty($phpbb_functional_path)) { $config['phpbb_functional_path'] = $phpbb_functional_path; } @@ -106,11 +106,9 @@ class phpbb_test_case_helpers )); } - if (isset($_SERVER['PHPBB_FUNCTIONAL_PATH'])) + if (!empty($_SERVER['PHPBB_FUNCTIONAL_PATH'])) { - $config = array_merge($config, array( - 'phpbb_functional_path' => isset($_SERVER['PHPBB_FUNCTIONAL_PATH']) ? $_SERVER['PHPBB_FUNCTIONAL_PATH'] : '', - )); + $config['phpbb_functional_path'] = $_SERVER['PHPBB_FUNCTIONAL_PATH']; } return $config; From 76e61951942048e3e98dbe60a3683d5269a4fa0e Mon Sep 17 00:00:00 2001 From: David King Date: Sun, 18 Mar 2012 16:50:41 -0400 Subject: [PATCH 089/335] [ticket/10586] trying to get tests to work PHPBB3-10586 --- .../functional/extension_controller_test.php | 28 +++++++++++-------- .../phpbb_functional_test_case.php | 5 ++-- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index 46f3dc6f96..4123853151 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -12,6 +12,7 @@ */ class phpbb_functional_extension_controller_test extends phpbb_functional_test_case { + protected $phpbb_extension_manager; /** * This should only be called once before the tests are run. * This is used to copy the fixtures to the phpBB install @@ -76,17 +77,23 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c // and port it into here instead of writing it from scratch } + public function setUp() + { + parent::setUp(); + $this->phpbb_extension_manager = !($this->phpbb_extension_manager instanceof phpbb_extension_manager) ? $this->get_ext_manager() : $this->phpbb_extension_manager; + $this->cache->purge('_ext'); + } + /** * Check an extension at ./ext/foobar/ which should have the class * phpbb_ext_foobar_controller */ public function test_foobar() { - $phpbb_extension_manager = $this->get_ext_manager(); - $phpbb_extension_manager->enable('foobar'); + $this->phpbb_extension_manager->enable('foobar'); $crawler = $this->request('GET', 'index.php?ext=foobar'); $this->assertContains("This is for testing purposes.", $crawler->filter('#page-body')->text()); - $phpbb_extension_manager->purge('foobar'); + $this->phpbb_extension_manager->purge('foobar'); } /** @@ -95,11 +102,10 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c */ public function test_foo_bar() { - $phpbb_extension_manager = $this->get_ext_manager(); - $phpbb_extension_manager->enable('foo/bar'); + $this->phpbb_extension_manager->enable('foo/bar'); $crawler = $this->request('GET', 'index.php?ext=foo/bar'); $this->assertContains("This is for testing purposes.", $crawler->filter('#page-body')->text()); - $phpbb_extension_manager->purge('foo/bar'); + $this->phpbb_extension_manager->purge('foo/bar'); } /** @@ -108,11 +114,10 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c */ public function test_error_class_name() { - $phpbb_extension_manager = $this->get_ext_manager(); - $phpbb_extension_manager->enable('error/class'); + $this->phpbb_extension_manager->enable('error/class'); $crawler = $this->request('GET', 'index.php?ext=error/class'); $this->assertContains("The extension error/class is missing a controller class and cannot be accessed through the front-end.", $crawler->filter('#message')->text()); - $phpbb_extension_manager->purge('error/class'); + $this->phpbb_extension_manager->purge('error/class'); } /** @@ -121,11 +126,10 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c */ public function test_error_class_type() { - $phpbb_extension_manager = $this->get_ext_manager(); - $phpbb_extension_manager->enable('error/classtype'); + $this->phpbb_extension_manager->enable('error/classtype'); $crawler = $this->request('GET', 'index.php?ext=error/classtype'); $this->assertContains("The extension controller class phpbb_ext_error_classtype_controller is not an instance of the phpbb_extension_controller_interface.", $crawler->filter('#message')->text()); - $phpbb_extension_manager->purge('error/classtype'); + $this->phpbb_extension_manager->purge('error/classtype'); } /** diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index b3376891bc..d569556d02 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -14,6 +14,7 @@ class phpbb_functional_test_case extends phpbb_test_case protected $client; protected $root_url; + protected $cache = null; protected $db = null; static protected $config = array(); @@ -88,8 +89,8 @@ class phpbb_functional_test_case extends phpbb_test_case protected function get_ext_manager() { global $phpbb_root_path, $phpEx; - - return new phpbb_extension_manager($this->get_db(), self::$config['table_prefix'] . 'ext', $phpbb_root_path, ".$phpEx", new phpbb_cache_driver_file); + $this->cache = ($this->cache instanceof phpbb_cache_driver_null) ? $this->cache : new phpbb_cache_driver_null; + return new phpbb_extension_manager($this->get_db(), self::$config['table_prefix'] . 'ext', $phpbb_root_path, ".$phpEx", $this->cache); } protected function install_board() From 1bbb32a5cffeff4875c4ed0566999cbee8919c86 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 18 Mar 2012 22:57:37 +0100 Subject: [PATCH 090/335] [ticket/10586] Correctly purge board cache and don't rename install directory PHPBB3-10586 --- tests/functional/browse_test.php | 11 ------ .../functional/extension_controller_test.php | 8 ++-- tests/functional/fixtures/ext/foobar/ext.php | 4 +- .../phpbb_functional_test_case.php | 37 +++++++++++++++++-- 4 files changed, 40 insertions(+), 20 deletions(-) diff --git a/tests/functional/browse_test.php b/tests/functional/browse_test.php index d119787d13..723cf93232 100644 --- a/tests/functional/browse_test.php +++ b/tests/functional/browse_test.php @@ -12,17 +12,6 @@ */ class phpbb_functional_browse_test extends phpbb_functional_test_case { - public static function setUpBeforeClass() - { - parent::setUpBeforeClass(); - $f_path = self::$config['phpbb_functional_path']; - // we cannot run these tests correctly if the install directory is present - if (is_dir($f_path . 'install/')) - { - rename($f_path . 'install/', $f_path . 'install_/'); - } - // NOTE: this will need to be renamed back again later if you wish to test again - } public function test_index() { $crawler = $this->request('GET', 'index.php'); diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index 4123853151..dd8aa1181b 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -69,8 +69,6 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c public static function tearDownAfterClass() { $f_path = self::$config['phpbb_functional_path']; - // first we rename the install_ directory back to install - rename($f_path . 'install_/', $f_path . 'install/'); // @todo delete the fixtures from the $f_path board // Note that it might be best to find a public domain function @@ -80,8 +78,10 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c public function setUp() { parent::setUp(); - $this->phpbb_extension_manager = !($this->phpbb_extension_manager instanceof phpbb_extension_manager) ? $this->get_ext_manager() : $this->phpbb_extension_manager; - $this->cache->purge('_ext'); + + $this->phpbb_extension_manager = $this->get_extension_manager(); + + $this->purge_cache(); } /** diff --git a/tests/functional/fixtures/ext/foobar/ext.php b/tests/functional/fixtures/ext/foobar/ext.php index 7b3f37cbfb..7cf443d369 100644 --- a/tests/functional/fixtures/ext/foobar/ext.php +++ b/tests/functional/fixtures/ext/foobar/ext.php @@ -1,6 +1,6 @@ db; } - protected function get_ext_manager() + protected function get_cache_driver() + { + if (!$this->cache) + { + $this->cache = new phpbb_cache_driver_file; + } + + return $this->cache; + } + + protected function purge_cache() + { + $cache = $this->get_cache_driver(); + + $cache->purge(); + $cache->unload(); + $cache->load(); + } + + protected function get_extension_manager() { global $phpbb_root_path, $phpEx; - $this->cache = ($this->cache instanceof phpbb_cache_driver_null) ? $this->cache : new phpbb_cache_driver_null; - return new phpbb_extension_manager($this->get_db(), self::$config['table_prefix'] . 'ext', $phpbb_root_path, ".$phpEx", $this->cache); + + if (!$this->extension_manager) + { + $this->extension_manager = new phpbb_extension_manager( + $this->get_db(), + self::$config['table_prefix'] . 'ext', + $phpbb_root_path, + ".$phpEx", + $this->get_cache_driver() + ); + } + + return $this->extension_manager; } protected function install_board() From 6a0bad8c0b7bdb261c0ee72b850bc727de6d019b Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 19 Mar 2012 09:56:48 -0400 Subject: [PATCH 091/335] [ticket/10586] Tests finally work (thanks naderman) PHPBB3-10586 --- .../functional/extension_controller_test.php | 25 +++++++++---------- .../phpbb_test_case_helpers.php | 10 -------- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index dd8aa1181b..263d48c034 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -19,20 +19,20 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c */ static public function setUpBeforeClass() { + global $phpbb_root_path; parent::setUpBeforeClass(); - $f_path = self::$config['phpbb_functional_path']; // these directories need to be created before the files can be copied $directories = array( - $f_path . 'ext/error/class/', - $f_path . 'ext/error/classtype/', - $f_path . 'ext/error/disabled/', - $f_path . 'ext/foo/bar/', - $f_path . 'ext/foo/bar/styles/prosilver/template/', - $f_path . 'ext/foobar/', - $f_path . 'ext/foobar/styles/prosilver/template/', + $phpbb_root_path . 'ext/error/class/', + $phpbb_root_path . 'ext/error/classtype/', + $phpbb_root_path . 'ext/error/disabled/', + $phpbb_root_path . 'ext/foo/bar/', + $phpbb_root_path . 'ext/foo/bar/styles/prosilver/template/', + $phpbb_root_path . 'ext/foobar/', + $phpbb_root_path . 'ext/foobar/styles/prosilver/template/', ); - // When you add new tests that require new fixtures, add them to the array. + foreach ($directories as $dir) { if (!is_dir($dir)) @@ -58,8 +58,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c foreach ($fixtures as $fixture) { - // we have to use self::$config['phpbb_functional_url'] because $this->root_url is not available in static classes - if(!copy("tests/functional/fixtures/ext/$fixture", "{$f_path}ext/$fixture")) + if(!copy("tests/functional/fixtures/ext/$fixture", "{$phpbb_root_path}ext/$fixture")) { echo 'Could not copy file ' . $fixture; } @@ -68,9 +67,9 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c public static function tearDownAfterClass() { - $f_path = self::$config['phpbb_functional_path']; + $phpbb_root_path = self::$config['phpbb_functional_path']; - // @todo delete the fixtures from the $f_path board + // @todo delete the fixtures from the $phpbb_root_path board // Note that it might be best to find a public domain function // and port it into here instead of writing it from scratch } diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 4aec07a8fb..9c91778cb0 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -80,11 +80,6 @@ class phpbb_test_case_helpers { $config['phpbb_functional_url'] = $phpbb_functional_url; } - - if (!empty($phpbb_functional_path)) - { - $config['phpbb_functional_path'] = $phpbb_functional_path; - } } if (isset($_SERVER['PHPBB_TEST_DBMS'])) @@ -106,11 +101,6 @@ class phpbb_test_case_helpers )); } - if (!empty($_SERVER['PHPBB_FUNCTIONAL_PATH'])) - { - $config['phpbb_functional_path'] = $_SERVER['PHPBB_FUNCTIONAL_PATH']; - } - return $config; } } From 97d4f168f588288df071e4a8b107b9ffb8b0355f Mon Sep 17 00:00:00 2001 From: Richard Foote Date: Mon, 19 Mar 2012 15:08:28 -0400 Subject: [PATCH 092/335] [ticket/10675] Add disk full language string when posting attachments Add language string visible by admins only for when the disk does not have enough free space to upload attachments. PHPBB3-10675 --- phpBB/includes/functions_posting.php | 9 ++++++++- phpBB/language/en/posting.php | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index f920be9c4b..b40fd67927 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -497,7 +497,14 @@ function upload_attachment($form_name, $forum_id, $local = false, $local_storage { if ($free_space <= $file->get('filesize')) { - $filedata['error'][] = $user->lang['ATTACH_QUOTA_REACHED']; + if ($auth->acl_get('a_')) + { + $filedata['error'][] = $user->lang['ATTACH_DISK_FULL']; + } + else + { + $filedata['error'][] = $user->lang['ATTACH_QUOTA_REACHED']; + } $filedata['post_attach'] = false; $file->remove(); diff --git a/phpBB/language/en/posting.php b/phpBB/language/en/posting.php index f8d265dddd..dd0ba7fc6d 100644 --- a/phpBB/language/en/posting.php +++ b/phpBB/language/en/posting.php @@ -42,6 +42,7 @@ $lang = array_merge($lang, array( 'ADD_POLL' => 'Poll creation', 'ADD_POLL_EXPLAIN' => 'If you do not want to add a poll to your topic leave the fields blank.', 'ALREADY_DELETED' => 'Sorry but this message is already deleted.', + 'ATTACH_DISK_FULL' => 'There is not enough free disk space to post this attachment', 'ATTACH_QUOTA_REACHED' => 'Sorry, the board attachment quota has been reached.', 'ATTACH_SIG' => 'Attach a signature (signatures can be altered via the UCP)', From 70d88965c795a5e392605fe556df580773a505c3 Mon Sep 17 00:00:00 2001 From: Richard Foote Date: Mon, 19 Mar 2012 23:19:21 -0400 Subject: [PATCH 093/335] [ticket/10708] Check converted passwords for multi-byte characters Check for multi-byte characters in converted passwords. PHPBB3-10708 --- phpBB/includes/auth/auth_db.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/auth/auth_db.php b/phpBB/includes/auth/auth_db.php index c20196d019..1c6cdf7832 100644 --- a/phpBB/includes/auth/auth_db.php +++ b/phpBB/includes/auth/auth_db.php @@ -163,7 +163,7 @@ function login_db($username, $password, $ip = '', $browser = '', $forwarded_for $password_old_format = (!STRIP) ? addslashes($password_old_format) : $password_old_format; $password_new_format = ''; - set_var($password_new_format, stripslashes($password_old_format), 'string'); + set_var($password_new_format, stripslashes($password_old_format), 'string', true); if ($password == $password_new_format) { From 2005c339ff26bf189fb818f0e25d6c0954b9702a Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 20 Mar 2012 17:45:08 +0100 Subject: [PATCH 094/335] =?UTF-8?q?[ticket/10717]=20Fix=20profile=20field?= =?UTF-8?q?=20sample=20in=20prosilver=C2=B4s=20memberlist=5Fview.html?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PHPBB3-10717 --- phpBB/styles/prosilver/template/memberlist_view.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/template/memberlist_view.html b/phpBB/styles/prosilver/template/memberlist_view.html index cfec07cff0..2758a7e6cc 100644 --- a/phpBB/styles/prosilver/template/memberlist_view.html +++ b/phpBB/styles/prosilver/template/memberlist_view.html @@ -69,7 +69,7 @@
{L_JABBER}:
{L_SEND_JABBER_MESSAGE}
{L_JABBER}:
{USER_JABBER}
-
{postrow.PROFILE_FIELD1_NAME}:
{postrow.PROFILE_FIELD1_VALUE}
+
{PROFILE_FIELD1_NAME}:
{PROFILE_FIELD1_VALUE}
From c2169f689955dfb3d6fe48bd0186e06583d7f7a4 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Wed, 21 Mar 2012 09:17:16 +0000 Subject: [PATCH 095/335] [feature/events-dispatcher] Adding phpBB/vendor to .gitignore PHPBB3-9550 --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7d789c59a1..59f7f49e65 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ /phpBB/images/avatars/gallery/* /phpBB/images/avatars/upload/* /phpBB/store/* +/phpBB/vendor /tests/phpbb_unit_tests.sqlite2 /tests/test_config.php /tests/tmp/* From b4b586ae10ce34d1c7d00d784fac7a51804eff3e Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 21 Mar 2012 13:09:39 +0100 Subject: [PATCH 096/335] [feature/event-dispatcher] Switch subscriber loader to EventDispatcherInterface Do not hardcode the implementation of EventDispatcher. PHPBB3-9550 --- phpBB/includes/event/extension_subscriber_loader.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/event/extension_subscriber_loader.php b/phpBB/includes/event/extension_subscriber_loader.php index 60e7fe2382..155846d53d 100644 --- a/phpBB/includes/event/extension_subscriber_loader.php +++ b/phpBB/includes/event/extension_subscriber_loader.php @@ -15,14 +15,14 @@ if (!defined('IN_PHPBB')) exit; } -use Symfony\Component\EventDispatcher\EventDispatcher; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; class phpbb_event_extension_subscriber_loader { private $dispatcher; private $extension_manager; - public function __construct(EventDispatcher $dispatcher, phpbb_extension_manager $extension_manager) + public function __construct(EventDispatcherInterface $dispatcher, phpbb_extension_manager $extension_manager) { $this->dispatcher = $dispatcher; $this->extension_manager = $extension_manager; From baefbdb8825a37051a200203a0191d34caa12229 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 21 Mar 2012 13:15:45 +0100 Subject: [PATCH 097/335] [feature/event-dispatcher] Add phpbb_event_dispatcher_wrapper PHPBB3-9550 --- phpBB/common.php | 2 +- phpBB/includes/event/dispatcher_wrapper.php | 88 +++++++++++++++++++++ 2 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 phpBB/includes/event/dispatcher_wrapper.php diff --git a/phpBB/common.php b/phpBB/common.php index 132b95c1fe..c7e66ef0d6 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -100,7 +100,7 @@ $phpbb_class_loader_ext->set_cache($cache->get_driver()); $phpbb_class_loader->set_cache($cache->get_driver()); // Instantiate some basic classes -$phpbb_dispatcher = new EventDispatcher(); +$phpbb_dispatcher = new phpbb_event_dispatcher_wrapper(new EventDispatcher()); $request = new phpbb_request(); $user = new user(); $auth = new auth(); diff --git a/phpBB/includes/event/dispatcher_wrapper.php b/phpBB/includes/event/dispatcher_wrapper.php new file mode 100644 index 0000000000..5f5d653c3c --- /dev/null +++ b/phpBB/includes/event/dispatcher_wrapper.php @@ -0,0 +1,88 @@ +trigger_event('core.index', compact($vars))); +* +* Apart from that it implements the EventDispatcherInterface +* and proxies all method calls to the member dispatcher. +*/ +class phpbb_event_dispatcher_wrapper implements EventDispatcherInterface +{ + private $dispatcher; + + public function __construct(EventDispatcherInterface $dispatcher) + { + $this->dispatcher = $dispatcher; + } + + public function dispatch($eventName, Event $event = null) + { + $this->dispatcher->dispatch($eventName, $event); + } + + public function addListener($eventName, $listener, $priority = 0) + { + $this->dispatcher->addListener($eventName, $listener, $priority); + } + + public function addSubscriber(EventSubscriberInterface $subscriber) + { + $this->dispatcher->addSubscriber($subscriber); + } + + public function removeListener($eventName, $listener) + { + $this->dispatcher->removeListener($eventName, $listener); + } + + public function removeSubscriber(EventSubscriberInterface $subscriber) + { + $this->dispatcher->removeSubscriber($subscriber); + } + + public function getListeners($eventName = null) + { + return $this->dispatcher->getListeners($eventName); + } + + public function hasListeners($eventName = null) + { + return $this->dispatcher->hasListeners($eventName); + } + + public function trigger_event($eventName, $data = array()) + { + $event = new phpbb_event_data($data); + $this->dispatch($eventName, $event); + return $event->get_data_filtered(array_keys($data)); + } +} From 92f771eb82b64bb35e0cd42534ddd0306a6aef68 Mon Sep 17 00:00:00 2001 From: Dhruv Goel Date: Thu, 22 Mar 2012 03:10:14 +0530 Subject: [PATCH 098/335] [ticket/10704] minor typo in a comment Make sure $id separation is working fine PHPBB3-10704 --- phpBB/includes/functions_module.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index db7defdc48..ae4f0f238e 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -362,7 +362,7 @@ class p_master $module_auth = implode(' ', $tokens); - // Make sure $id seperation is working fine + // Make sure $id separation is working fine $module_auth = str_replace(' , ', ',', $module_auth); $forum_id = ($forum_id === false) ? $this->acl_forum_id : $forum_id; From 4dafcc2525fa72f2bd91760fae49e51ff9d1a0ef Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Wed, 21 Mar 2012 22:57:29 +0000 Subject: [PATCH 099/335] [task/travis] Adding Travis Continuous Intergration Support PHPBB3-10718 --- .travis.yml | 33 +++++++++++++++++++++++++++++++++ travis/mysql.travis.xml | 28 ++++++++++++++++++++++++++++ travis/postgres.travis.xml | 30 ++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 .travis.yml create mode 100644 travis/mysql.travis.xml create mode 100644 travis/postgres.travis.xml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..e091954e0e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,33 @@ +language: php +php: + - 5.2 + - 5.3 + - 5.4 + +env: + - DB=mysql + - DB=postgres + +before_script: + - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS phpbb_tests;' -U postgres; fi" + - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'create database phpbb_tests;' -U postgres; fi" + - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS phpbb_tests;'; fi" + - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.2' ]; then pear install --force phpunit/DbUnit; fi" + - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.3' ]; then pyrus install --force phpunit/DbUnit; fi" + - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.4' ]; then pyrus install --force phpunit/DbUnit; fi" + - phpenv rehash + +script: + - phpunit --configuration travis/$DB.travis.xml + +notifications: + email: + recipients: + - m@michaelcullum.com + on_success: never + on_failure: always + +branches: + only: + develop + task/travis diff --git a/travis/mysql.travis.xml b/travis/mysql.travis.xml new file mode 100644 index 0000000000..a849f50136 --- /dev/null +++ b/travis/mysql.travis.xml @@ -0,0 +1,28 @@ + + + + + ../tests/ + + + + + + + + + + + + + diff --git a/travis/postgres.travis.xml b/travis/postgres.travis.xml new file mode 100644 index 0000000000..e44696a335 --- /dev/null +++ b/travis/postgres.travis.xml @@ -0,0 +1,30 @@ + + + + + ../tests/ + + + + + + + + + + + + + + + From 9120c7691e28ca298eb83ebbe12a82c2723cfeee Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Wed, 21 Mar 2012 23:25:50 +0000 Subject: [PATCH 100/335] [task/travis] Removing development information PHPBB3-10718 --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e091954e0e..8e870ca9c2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,11 +23,12 @@ script: notifications: email: recipients: - - m@michaelcullum.com + - dev-team@phpbb.com on_success: never - on_failure: always + on_failure: change branches: only: develop + develop-olympus task/travis From 4325bbf4c601332614f456df969983d85829e931 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Wed, 21 Mar 2012 23:30:56 +0000 Subject: [PATCH 101/335] [task/travis] Add automated testing to readme PHPBB3-10718 --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 6b94f898a3..f7dfc4926e 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,12 @@ Find support and lots more on [phpBB.com](http://www.phpbb.com)! Discuss the dev 3. [Read our Git Contribution Guidelines](http://wiki.phpbb.com/Git); if you're new to git, also read [the introduction guide](http://wiki.phpbb.com/display/DEV/Working+with+Git) 4. Send us a pull request +## AUTOMATED TESTING + +We have unit and functional tests in order to prevent regressions. You can view the bamboo continuous integration [here](http://bamboo.phpbb.com) or check our travis build below. +Develop - [![Build Status](https://secure.travis-ci.org/phpbb/phpbb3.png?branch=develop)](http://travis-ci.org/phpbb/phpbb3) +Develop-Olympus - [![Build Status](https://secure.travis-ci.org/phpbb/phpbb3.png?branch=develop-olympus)](http://travis-ci.org/phpbb/phpbb3) + ## LICENSE [GNU General Public License v2](http://opensource.org/licenses/gpl-2.0.php) From 5a9dd1994fc20aaebe3145540b630826d7333998 Mon Sep 17 00:00:00 2001 From: rxu Date: Thu, 22 Mar 2012 21:19:01 +0800 Subject: [PATCH 102/335] [ticket/10684] Adjust function and parameter name, minor changes. PHPBB3-10684 --- phpBB/includes/functions_posting.php | 4 ++-- phpBB/includes/functions_privmsgs.php | 4 ++-- phpBB/includes/functions_user.php | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 073ce1ff4e..7f45b2da8c 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -1181,11 +1181,11 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id $topic_title = censor_text($topic_title); // Exclude guests, current user and banned users from notifications - if (!function_exists('phpbb_get_banned_users_ids')) + if (!function_exists('phpbb_get_banned_user_ids')) { include($phpbb_root_path . 'includes/functions_user.' . $phpEx); } - $sql_ignore_users = phpbb_get_banned_users_ids(); + $sql_ignore_users = phpbb_get_banned_user_ids(); $sql_ignore_users[ANONYMOUS] = ANONYMOUS; $sql_ignore_users[$user->data['user_id']] = $user->data['user_id']; diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 4ea8f74153..447920cfd5 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -1630,11 +1630,11 @@ function pm_notification($mode, $author, $recipients, $subject, $message, $msg_i return; } - if (!function_exists('phpbb_get_banned_users_ids')) + if (!function_exists('phpbb_get_banned_user_ids')) { include($phpbb_root_path . 'includes/functions_user.' . $phpEx); } - $banned_users = phpbb_get_banned_users_ids(array_keys($recipients)); + $banned_users = phpbb_get_banned_user_ids(array_keys($recipients)); $recipients = array_diff(array_keys($recipients), $banned_users); if (!sizeof($recipients)) diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 8c42a5bb42..10fb57ea97 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -3588,24 +3588,24 @@ function remove_newly_registered($user_id, $user_data = false) } /** -* Get a list of banned users' ids, ignoring stale bans which were not cleaned yet. +* Gets user ids of currently banned registered users. * -* @param array $users_ids Array of users' ids to check for banning, +* @param array $user_ids Array of users' ids to check for banning, * leave empty to get complete list of banned ids * @return array Array of banned users' ids if any, empty array otherwise */ -function phpbb_get_banned_users_ids($users_ids = array()) +function phpbb_get_banned_user_ids($user_ids = array()) { global $db; - $sql_users_ids = (!empty($users_ids)) ? $db->sql_in_set('ban_userid', $users_ids) : 'ban_userid <> 0'; + $sql_user_ids = (!empty($user_ids)) ? $db->sql_in_set('ban_userid', $user_ids) : 'ban_userid <> 0'; // Get banned User ID's // Ignore stale bans which were not wiped yet $banned_ids_list = array(); $sql = 'SELECT ban_userid FROM ' . BANLIST_TABLE . " - WHERE $sql_users_ids + WHERE $sql_user_ids AND ban_exclude <> 1 AND (ban_end > " . time() . ' OR ban_end = 0)'; From d1980f6ad616e800ff82299ceafc5c8c763c6570 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Thu, 22 Mar 2012 13:32:58 +0000 Subject: [PATCH 103/335] [task/travis] Fixing some travis issues PHPBB3-10718 --- .travis.yml | 2 +- README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8e870ca9c2..bf97a20850 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ notifications: email: recipients: - dev-team@phpbb.com - on_success: never + on_success: change on_failure: change branches: diff --git a/README.md b/README.md index f7dfc4926e..51e65176c6 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,8 @@ Find support and lots more on [phpBB.com](http://www.phpbb.com)! Discuss the dev ## AUTOMATED TESTING We have unit and functional tests in order to prevent regressions. You can view the bamboo continuous integration [here](http://bamboo.phpbb.com) or check our travis build below. -Develop - [![Build Status](https://secure.travis-ci.org/phpbb/phpbb3.png?branch=develop)](http://travis-ci.org/phpbb/phpbb3) -Develop-Olympus - [![Build Status](https://secure.travis-ci.org/phpbb/phpbb3.png?branch=develop-olympus)](http://travis-ci.org/phpbb/phpbb3) +develop - [![Build Status](https://secure.travis-ci.org/phpbb/phpbb3.png?branch=develop)](http://travis-ci.org/phpbb/phpbb3) +develop-olympus - [![Build Status](https://secure.travis-ci.org/phpbb/phpbb3.png?branch=develop-olympus)](http://travis-ci.org/phpbb/phpbb3) ## LICENSE From c7f65fba627680e7de81ae6c7ea9c1e0fc4359ea Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Thu, 22 Mar 2012 14:13:25 +0000 Subject: [PATCH 104/335] [task/travis] Rename travis phpunit config files PHPBB3-10718 --- .travis.yml | 2 +- travis/{mysql.travis.xml => phpunit-mysql-travis.xml} | 0 travis/{postgres.travis.xml => phpunit-postgres-travis.xml} | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename travis/{mysql.travis.xml => phpunit-mysql-travis.xml} (100%) rename travis/{postgres.travis.xml => phpunit-postgres-travis.xml} (100%) diff --git a/.travis.yml b/.travis.yml index bf97a20850..d638e1cccd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ before_script: - phpenv rehash script: - - phpunit --configuration travis/$DB.travis.xml + - phpunit --configuration travis/phpunit-$DB-travis.xml notifications: email: diff --git a/travis/mysql.travis.xml b/travis/phpunit-mysql-travis.xml similarity index 100% rename from travis/mysql.travis.xml rename to travis/phpunit-mysql-travis.xml diff --git a/travis/postgres.travis.xml b/travis/phpunit-postgres-travis.xml similarity index 100% rename from travis/postgres.travis.xml rename to travis/phpunit-postgres-travis.xml From 115ee7f3b815567cf598178225022b2d7d7f5310 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Thu, 22 Mar 2012 14:44:36 +0000 Subject: [PATCH 105/335] [task/travis] Some more small travis fixes PHPBB3-10718 --- .travis.yml | 6 ------ travis/phpunit-mysql-travis.xml | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index d638e1cccd..78221d588c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,9 +26,3 @@ notifications: - dev-team@phpbb.com on_success: change on_failure: change - -branches: - only: - develop - develop-olympus - task/travis diff --git a/travis/phpunit-mysql-travis.xml b/travis/phpunit-mysql-travis.xml index a849f50136..807dfbcdaa 100644 --- a/travis/phpunit-mysql-travis.xml +++ b/travis/phpunit-mysql-travis.xml @@ -8,7 +8,7 @@ processIsolation="false" stopOnFailure="false" syntaxCheck="true" - strict="true" + strict="true" bootstrap="../tests/bootstrap.php"> From 4000d8051d4e7c07338d48023c4f4c82610a2ddb Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Wed, 21 Mar 2012 23:33:13 +0000 Subject: [PATCH 106/335] [task/travis] Dropping support for 5.2 in develop branch PHPBB3-10718 --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 78221d588c..e2cb463911 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: php php: - - 5.2 - 5.3 - 5.4 From e034eb96b777978c4b32dad89b46a7fc6e85f52e Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Thu, 22 Mar 2012 14:56:55 +0000 Subject: [PATCH 107/335] [task/travis-develop2] Update version from 5.3 to 5.3.2 PHPBB3-10718 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e2cb463911..8c07f48372 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: php php: - - 5.3 + - 5.3.2 - 5.4 env: From 0172ced4e202e5d8dfb0086a0370007113f39c5b Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Thu, 22 Mar 2012 00:06:46 +0000 Subject: [PATCH 108/335] [ticket/10719] Revert "Skip functional tests on PHP 5.2" This reverts commit 9c861a0350ae67f06a38ee6efc890412a32751f4. PHPBB3-10719 --- phpunit.xml.all | 4 ---- phpunit.xml.dist | 4 ---- phpunit.xml.functional | 4 ---- tests/bootstrap.php | 6 +----- 4 files changed, 1 insertion(+), 17 deletions(-) diff --git a/phpunit.xml.all b/phpunit.xml.all index b835a38c20..fde3bbb1a7 100644 --- a/phpunit.xml.all +++ b/phpunit.xml.all @@ -14,10 +14,6 @@ ./tests/ - ./tests/functional - - - ./tests/functional diff --git a/phpunit.xml.dist b/phpunit.xml.dist index da31dce5e3..27dee48aac 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -14,10 +14,6 @@ ./tests/ - ./tests/functional - - - ./tests/functional diff --git a/phpunit.xml.functional b/phpunit.xml.functional index 91d569e65b..9facbcff8b 100644 --- a/phpunit.xml.functional +++ b/phpunit.xml.functional @@ -14,10 +14,6 @@ ./tests/ - ./tests/functional - - - ./tests/functional diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 302701e3b3..f103d8f15a 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -25,8 +25,4 @@ require_once 'test_framework/phpbb_test_case_helpers.php'; require_once 'test_framework/phpbb_test_case.php'; require_once 'test_framework/phpbb_database_test_case.php'; require_once 'test_framework/phpbb_database_test_connection_manager.php'; - -if (version_compare(PHP_VERSION, '5.3.0-dev', '>=')) -{ - require_once 'test_framework/phpbb_functional_test_case.php'; -} +require_once 'test_framework/phpbb_functional_test_case.php'; From 0ed66ad0e8d11c802520046b446aa5622a637df9 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Thu, 22 Mar 2012 16:00:10 +0000 Subject: [PATCH 109/335] [task/travis] Exclude functional and slow tests PHPBB3-10718 --- travis/phpunit-mysql-travis.xml | 6 ++++++ travis/phpunit-postgres-travis.xml | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/travis/phpunit-mysql-travis.xml b/travis/phpunit-mysql-travis.xml index 807dfbcdaa..79215c8de1 100644 --- a/travis/phpunit-mysql-travis.xml +++ b/travis/phpunit-mysql-travis.xml @@ -16,6 +16,12 @@ + + + slow + + + diff --git a/travis/phpunit-postgres-travis.xml b/travis/phpunit-postgres-travis.xml index e44696a335..02db76ae78 100644 --- a/travis/phpunit-postgres-travis.xml +++ b/travis/phpunit-postgres-travis.xml @@ -16,6 +16,12 @@ + + + slow + + + From 841d11c6cd90d331c2923ba7851dd5f813203ddf Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Thu, 22 Mar 2012 16:09:58 +0000 Subject: [PATCH 110/335] [task/travis] Refactor php version check for dbunit install PHPBB3-10718 --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 78221d588c..d73bbd2a48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,9 +12,7 @@ before_script: - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS phpbb_tests;' -U postgres; fi" - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'create database phpbb_tests;' -U postgres; fi" - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS phpbb_tests;'; fi" - - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.2' ]; then pear install --force phpunit/DbUnit; fi" - - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.3' ]; then pyrus install --force phpunit/DbUnit; fi" - - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.4' ]; then pyrus install --force phpunit/DbUnit; fi" + - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.2' ]; then pear install --force phpunit/DbUnit; else pyrus install --force phpunit/DbUnit; fi" - phpenv rehash script: From 18c541dfee6ec7db0e04c939bc103cefe9dab9d7 Mon Sep 17 00:00:00 2001 From: Dhruv Goel Date: Fri, 23 Mar 2012 00:27:29 +0530 Subject: [PATCH 111/335] [ticket/10703] Added a condition to check if ext directory exists The existence of ext directory is checked, if not present a proper error message that file doesn't exist is printed out. No Fatal Error messages. PHPBB3-10703 --- phpBB/develop/extensions.php | 8 +++++++- phpBB/includes/extension/manager.php | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/phpBB/develop/extensions.php b/phpBB/develop/extensions.php index 2f7c3d1167..43621f3080 100644 --- a/phpBB/develop/extensions.php +++ b/phpBB/develop/extensions.php @@ -37,6 +37,13 @@ function list_extensions() global $phpbb_extension_manager; $phpbb_extension_manager->load_extensions(); + $all = array_keys($phpbb_extension_manager->all_available()); + + if (empty($all)) + { + echo "There were no extensions found.\n"; + exit(3); + } echo "Enabled:\n"; $enabled = array_keys($phpbb_extension_manager->all_enabled()); @@ -49,7 +56,6 @@ function list_extensions() echo "\n"; echo "Available:\n"; - $all = array_keys($phpbb_extension_manager->all_available()); $purged = array_diff($all, $enabled, $disabled); print_extensions($purged); } diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php index c38f0df32e..dac0e5f947 100644 --- a/phpBB/includes/extension/manager.php +++ b/phpBB/includes/extension/manager.php @@ -352,6 +352,10 @@ class phpbb_extension_manager public function all_available() { $available = array(); + if (!is_dir($this->phpbb_root_path . 'ext/')) + { + return $available; + } $iterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($this->phpbb_root_path . 'ext/'), From 5bcdfe94dd487441565c00450b3a8efcaeecd840 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Fri, 23 Mar 2012 06:40:15 +0000 Subject: [PATCH 112/335] [ticket/10723] Stop Travis running all tests on sqlite Correct information so all tests don't run on sqlite PHPBB3-10723 --- travis/phpunit-mysql-travis.xml | 14 +++++++------- travis/phpunit-postgres-travis.xml | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/travis/phpunit-mysql-travis.xml b/travis/phpunit-mysql-travis.xml index 79215c8de1..36845a7f71 100644 --- a/travis/phpunit-mysql-travis.xml +++ b/travis/phpunit-mysql-travis.xml @@ -23,12 +23,12 @@ - - - - - - - + + + + + + + diff --git a/travis/phpunit-postgres-travis.xml b/travis/phpunit-postgres-travis.xml index 02db76ae78..461a53bcb1 100644 --- a/travis/phpunit-postgres-travis.xml +++ b/travis/phpunit-postgres-travis.xml @@ -25,12 +25,12 @@ - - - - - - - + + + + + + + From afc2c5a2e3c56e4e6f96f9ce122a2695a0008f15 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Sat, 24 Mar 2012 11:03:54 +0000 Subject: [PATCH 113/335] [feature/event-dispatcher] Add composer install to travis PHPBB3-9550 --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index d5e1231584..f21928dd37 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,8 @@ before_script: - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS phpbb_tests;'; fi" - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.2' ]; then pear install --force phpunit/DbUnit; else pyrus install --force phpunit/DbUnit; fi" - phpenv rehash + - curl -s http://getcomposer.org/installer | php + - php composer.phar install script: - phpunit --configuration travis/phpunit-$DB-travis.xml From 400277c03624788e6a31f9aa4a15b883478f58cc Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 24 Mar 2012 15:45:18 +0100 Subject: [PATCH 114/335] [feature/event-dispatcher] Change phpbb_event_dispatcher to inheritance, tests PHPBB3-9550 --- phpBB/common.php | 2 +- phpBB/includes/event/dispatcher.php | 42 ++++++++++ phpBB/includes/event/dispatcher_wrapper.php | 88 --------------------- tests/event/dispatcher_test.php | 29 +++++++ 4 files changed, 72 insertions(+), 89 deletions(-) create mode 100644 phpBB/includes/event/dispatcher.php delete mode 100644 phpBB/includes/event/dispatcher_wrapper.php create mode 100644 tests/event/dispatcher_test.php diff --git a/phpBB/common.php b/phpBB/common.php index c7e66ef0d6..fafcb81feb 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -100,7 +100,7 @@ $phpbb_class_loader_ext->set_cache($cache->get_driver()); $phpbb_class_loader->set_cache($cache->get_driver()); // Instantiate some basic classes -$phpbb_dispatcher = new phpbb_event_dispatcher_wrapper(new EventDispatcher()); +$phpbb_dispatcher = new phpbb_event_dispatcher(); $request = new phpbb_request(); $user = new user(); $auth = new auth(); diff --git a/phpBB/includes/event/dispatcher.php b/phpBB/includes/event/dispatcher.php new file mode 100644 index 0000000000..2bf46b9b06 --- /dev/null +++ b/phpBB/includes/event/dispatcher.php @@ -0,0 +1,42 @@ +trigger_event('core.index', compact($vars))); +* +*/ +class phpbb_event_dispatcher extends EventDispatcher +{ + public function trigger_event($eventName, $data = array()) + { + $event = new phpbb_event_data($data); + $this->dispatch($eventName, $event); + return $event->get_data_filtered(array_keys($data)); + } +} diff --git a/phpBB/includes/event/dispatcher_wrapper.php b/phpBB/includes/event/dispatcher_wrapper.php deleted file mode 100644 index 5f5d653c3c..0000000000 --- a/phpBB/includes/event/dispatcher_wrapper.php +++ /dev/null @@ -1,88 +0,0 @@ -trigger_event('core.index', compact($vars))); -* -* Apart from that it implements the EventDispatcherInterface -* and proxies all method calls to the member dispatcher. -*/ -class phpbb_event_dispatcher_wrapper implements EventDispatcherInterface -{ - private $dispatcher; - - public function __construct(EventDispatcherInterface $dispatcher) - { - $this->dispatcher = $dispatcher; - } - - public function dispatch($eventName, Event $event = null) - { - $this->dispatcher->dispatch($eventName, $event); - } - - public function addListener($eventName, $listener, $priority = 0) - { - $this->dispatcher->addListener($eventName, $listener, $priority); - } - - public function addSubscriber(EventSubscriberInterface $subscriber) - { - $this->dispatcher->addSubscriber($subscriber); - } - - public function removeListener($eventName, $listener) - { - $this->dispatcher->removeListener($eventName, $listener); - } - - public function removeSubscriber(EventSubscriberInterface $subscriber) - { - $this->dispatcher->removeSubscriber($subscriber); - } - - public function getListeners($eventName = null) - { - return $this->dispatcher->getListeners($eventName); - } - - public function hasListeners($eventName = null) - { - return $this->dispatcher->hasListeners($eventName); - } - - public function trigger_event($eventName, $data = array()) - { - $event = new phpbb_event_data($data); - $this->dispatch($eventName, $event); - return $event->get_data_filtered(array_keys($data)); - } -} diff --git a/tests/event/dispatcher_test.php b/tests/event/dispatcher_test.php new file mode 100644 index 0000000000..59e51b1cdc --- /dev/null +++ b/tests/event/dispatcher_test.php @@ -0,0 +1,29 @@ +addListener('core.test_event', function (phpbb_event_data $event) { + $event['foo'] = $event['foo'] . '2'; + $event['bar'] = $event['bar'] . '2'; + }); + + $foo = 'foo'; + $bar = 'bar'; + + $vars = array('foo', 'bar'); + $result = $dispatcher->trigger_event('core.test_event', compact($vars)); + + $this->assertSame(array('foo' => 'foo2', 'bar' => 'bar2'), $result); + } +} From 2768db44f557cd5db4b54a287ecb1d2fcbe94140 Mon Sep 17 00:00:00 2001 From: HTF Date: Sat, 24 Mar 2012 15:13:04 +0000 Subject: [PATCH 115/335] [ticket/10129] Remove apostrophes and plurals in ACP user management -> permissions language file as per ticket. PHPBB3-10129 --- phpBB/language/en/acp/common.php | 8 ++++---- phpBB/language/en/acp/permissions.php | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 958b9c7598..e64ba3c371 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -96,10 +96,10 @@ $lang = array_merge($lang, array( 'ACP_GLOBAL_MODERATORS' => 'Global moderators', 'ACP_GLOBAL_PERMISSIONS' => 'Global permissions', 'ACP_GROUPS' => 'Groups', - 'ACP_GROUPS_FORUM_PERMISSIONS' => 'Groups’ forum permissions', + 'ACP_GROUPS_FORUM_PERMISSIONS' => 'Group forum permissions', 'ACP_GROUPS_MANAGE' => 'Manage groups', 'ACP_GROUPS_MANAGEMENT' => 'Group management', - 'ACP_GROUPS_PERMISSIONS' => 'Groups’ permissions', + 'ACP_GROUPS_PERMISSIONS' => 'Group permissions', 'ACP_ICONS' => 'Topic icons', 'ACP_ICONS_SMILIES' => 'Topic icons/smilies', @@ -172,9 +172,9 @@ $lang = array_merge($lang, array( 'ACP_THEMES' => 'Themes', 'ACP_UPDATE' => 'Updating', - 'ACP_USERS_FORUM_PERMISSIONS' => 'Users’ forum permissions', + 'ACP_USERS_FORUM_PERMISSIONS' => 'User forum permissions', 'ACP_USERS_LOGS' => 'User logs', - 'ACP_USERS_PERMISSIONS' => 'Users’ permissions', + 'ACP_USERS_PERMISSIONS' => 'User permissions', 'ACP_USER_ATTACH' => 'Attachments', 'ACP_USER_AVATAR' => 'Avatar', 'ACP_USER_FEEDBACK' => 'Feedback', diff --git a/phpBB/language/en/acp/permissions.php b/phpBB/language/en/acp/permissions.php index 016be51282..c0396cc247 100644 --- a/phpBB/language/en/acp/permissions.php +++ b/phpBB/language/en/acp/permissions.php @@ -40,10 +40,10 @@ $lang = array_merge($lang, array(

Permissions are highly granular and grouped into four major sections, which are:

Global Permissions

-

These are used to control access on a global level and apply to the entire bulletin board. They are further divided into Users’ Permissions, Groups’ Permissions, Administrators and Global Moderators.

+

These are used to control access on a global level and apply to the entire bulletin board. They are further divided into User Permissions, Group Permissions, Administrators and Global Moderators.

Forum Based Permissions

-

These are used to control access on a per forum basis. They are further divided into Forum Permissions, Forum Moderators, Users’ Forum Permissions and Groups’ Forum Permissions.

+

These are used to control access on a per forum basis. They are further divided into Forum Permissions, Forum Moderators, User Forum Permissions and Group Forum Permissions.

Permission Roles

These are used to create different sets of permissions for the different permission types later being able to be assigned on a role-based basis. The default roles should cover the administration of bulletin boards large and small, though within each of the four divisions, you can add/edit/delete roles as you see fit.

@@ -83,13 +83,13 @@ $lang = array_merge($lang, array( 'ACP_FORUM_PERMISSIONS_COPY_EXPLAIN' => 'Here you can copy forum permissions from one forum to one or more other forums.', 'ACP_GLOBAL_MODERATORS_EXPLAIN' => 'Here you can assign global moderator permissions to users or groups. These moderators are like ordinary moderators except they have access to every forum on your board.', 'ACP_GROUPS_FORUM_PERMISSIONS_EXPLAIN' => 'Here you can assign forum permissions to groups.', - 'ACP_GROUPS_PERMISSIONS_EXPLAIN' => 'Here you can assign global permissions to groups - user permissions, global moderator permissions and administrator permissions. User permissions include capabilities such as the use of avatars, sending private messages, et cetera; global moderator permissions such as approving posts, manage topics, manage bans, et cetera and lastly administrator permissions such as altering permissions, define custom BBCodes, manage forums, et cetera. Individual users permissions should only be changed in rare occasions, the preferred method is putting users in groups and assigning the group’s permissions.', + 'ACP_GROUPS_PERMISSIONS_EXPLAIN' => 'Here you can assign global permissions to groups - user permissions, global moderator permissions and administrator permissions. User permissions include capabilities such as the use of avatars, sending private messages, et cetera; global moderator permissions such as approving posts, manage topics, manage bans, et cetera and lastly administrator permissions such as altering permissions, define custom BBCodes, manage forums, et cetera. Individual user permissions should only be changed in rare occasions, the preferred method is putting users in groups and assigning the group permissions.', 'ACP_ADMIN_ROLES_EXPLAIN' => 'Here you are able to manage the roles for administrative permissions. Roles are effective permissions, if you change a role the items having this role assigned will change its permissions too.', 'ACP_FORUM_ROLES_EXPLAIN' => 'Here you are able to manage the roles for forum permissions. Roles are effective permissions, if you change a role the items having this role assigned will change its permissions too.', 'ACP_MOD_ROLES_EXPLAIN' => 'Here you are able to manage the roles for moderative permissions. Roles are effective permissions, if you change a role the items having this role assigned will change its permissions too.', 'ACP_USER_ROLES_EXPLAIN' => 'Here you are able to manage the roles for user permissions. Roles are effective permissions, if you change a role the items having this role assigned will change its permissions too.', 'ACP_USERS_FORUM_PERMISSIONS_EXPLAIN' => 'Here you can assign forum permissions to users.', - 'ACP_USERS_PERMISSIONS_EXPLAIN' => 'Here you can assign global permissions to users - user permissions, global moderator permissions and administrator permissions. User permissions include capabilities such as the use of avatars, sending private messages, et cetera; global moderator permissions such as approving posts, manage topics, manage bans, et cetera and lastly administrator permissions such as altering permissions, define custom BBCodes, manage forums, et cetera. To alter these settings for large numbers of users the Group permissions system is the preferred method. User’s permissions should only be changed in rare occasions, the preferred method is putting users in groups and assigning the group’s permissions.', + 'ACP_USERS_PERMISSIONS_EXPLAIN' => 'Here you can assign global permissions to users - user permissions, global moderator permissions and administrator permissions. User permissions include capabilities such as the use of avatars, sending private messages, et cetera; global moderator permissions such as approving posts, manage topics, manage bans, et cetera and lastly administrator permissions such as altering permissions, define custom BBCodes, manage forums, et cetera. To alter these settings for large numbers of users the Group permissions system is the preferred method. User permissions should only be changed in rare occasions, the preferred method is putting users in groups and assigning the group permissions.', 'ACP_VIEW_ADMIN_PERMISSIONS_EXPLAIN' => 'Here you can view the effective administrative permissions assigned to the selected users/groups.', 'ACP_VIEW_GLOBAL_MOD_PERMISSIONS_EXPLAIN' => 'Here you can view the global moderative permissions assigned to the selected users/groups.', 'ACP_VIEW_FORUM_PERMISSIONS_EXPLAIN' => 'Here you can view the forum permissions assigned to the selected users/groups and forums.', @@ -225,8 +225,8 @@ $lang = array_merge($lang, array( 'SELECT_TYPE' => 'Select type', 'SET_PERMISSIONS' => 'Set permissions', 'SET_ROLE_PERMISSIONS' => 'Set role permissions', - 'SET_USERS_PERMISSIONS' => 'Set users permissions', - 'SET_USERS_FORUM_PERMISSIONS' => 'Set users forum permissions', + 'SET_USERS_PERMISSIONS' => 'Set user permissions', + 'SET_USERS_FORUM_PERMISSIONS' => 'Set user forum permissions', 'TRACE_DEFAULT' => 'By default every permission is NO (unset). So the permission can be overwritten by other settings.', 'TRACE_FOR' => 'Trace for', From a44423baee5d0d5e0fd8899204a71e4a292dc6bf Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 24 Mar 2012 21:37:45 +0100 Subject: [PATCH 116/335] [feature/event-dispatcher] Change composer autoloading options Check if composer's generated autoloader is present, and if not give an error. PHPBB3-9550 --- phpBB/includes/startup.php | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/phpBB/includes/startup.php b/phpBB/includes/startup.php index 9c4e1374ba..45eaff6fc7 100644 --- a/phpBB/includes/startup.php +++ b/phpBB/includes/startup.php @@ -149,22 +149,32 @@ if (function_exists('date_default_timezone_set') && function_exists('date_defaul // Autoloading of dependencies. // Three options are supported: -// 1. Specify PHPBB_AUTOLOAD=/path/to/autoload.php in the environment. -// This is useful for running CLI scripts and tests. +// 1. If dependencies are installed with Composer, Composer will create a +// vendor/.composer/autoload.php. If this file exists it will be +// automatically used by phpBB. This is the default mode that phpBB +// will use when shipped. +// 2. To disable composer autoloading, PHPBB_NO_AUTOLOAD can be specified. +// Additionally specify PHPBB_AUTOLOAD=/path/to/autoload.php in the +// environment. This is useful for running CLI scripts and tests. // /path/to/autoload.php should define and register class loaders // for all of phpBB's dependencies. -// 2. If dependencies are installed with Composer, Composer will create a -// vendor/.composer/autoload.php. If this file exists it will be -// automatically used by phpBB. -// 3. Failing that phpBB assumes that autoloading has been set up in -// some other way. This might be useful in cases when phpBB is integrated -// into a larger program. -if (getenv('PHPBB_AUTOLOAD')) +// 3. You can also set PHPBB_NO_AUTOLOAD without setting PHPBB_AUTOLOAD. +// In this case autoloading needs to be defined before running any phpBB +// script. This might be useful in cases when phpBB is integrated into a +// larger program. +if (getenv('PHPBB_NO_AUTOLOAD')) { - require(getenv('PHPBB_AUTOLOAD')); + if (getenv('PHPBB_AUTOLOAD')) + { + require(getenv('PHPBB_AUTOLOAD')); + } } -else if (file_exists($phpbb_root_path . 'vendor/.composer/autoload.php')) +else { + if (!file_exists($phpbb_root_path . 'vendor/.composer/autoload.php')) + { + trigger_error('You have not set up composer dependencies. See http://getcomposer.org/.', E_USER_ERROR); + } require($phpbb_root_path . 'vendor/.composer/autoload.php'); } From cfb8f01040ca9fded20d8f3dd4620cd7477d60fc Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 24 Mar 2012 22:03:03 -0400 Subject: [PATCH 117/335] [ticket/10727] Do not hide Quick Reply with javascript on prosilver PHPBB3-10727 --- phpBB/language/en/viewtopic.php | 2 - .../prosilver/template/quickreply_editor.html | 59 +------------------ 2 files changed, 1 insertion(+), 60 deletions(-) diff --git a/phpBB/language/en/viewtopic.php b/phpBB/language/en/viewtopic.php index 2b20938afe..f47f8a076b 100644 --- a/phpBB/language/en/viewtopic.php +++ b/phpBB/language/en/viewtopic.php @@ -47,7 +47,6 @@ $lang = array_merge($lang, array( 'BUMP_TOPIC' => 'Bump topic', 'CODE' => 'Code', - 'COLLAPSE_QR' => 'Hide Quick Reply', 'DELETE_TOPIC' => 'Delete topic', 'DOWNLOAD_NOTICE' => 'You do not have the required permissions to view the files attached to this post.', @@ -97,7 +96,6 @@ $lang = array_merge($lang, array( 'REPLY_TO_TOPIC' => 'Reply to topic', 'RETURN_POST' => '%sReturn to the post%s', - 'SHOW_QR' => 'Quick Reply', 'SUBMIT_VOTE' => 'Submit vote', 'TOTAL_VOTES' => 'Total votes', diff --git a/phpBB/styles/prosilver/template/quickreply_editor.html b/phpBB/styles/prosilver/template/quickreply_editor.html index ea07c2e6d8..f61cc49c0b 100644 --- a/phpBB/styles/prosilver/template/quickreply_editor.html +++ b/phpBB/styles/prosilver/template/quickreply_editor.html @@ -1,51 +1,5 @@ - -
-
-

{L_WARNINGS_ZERO_TOTAL}

+

{L_NO_WARNINGS}

@@ -88,7 +88,7 @@
-

{L_WARNINGS_ZERO_TOTAL}

+

{L_NO_WARNINGS}

diff --git a/phpBB/styles/prosilver/template/mcp_warn_list.html b/phpBB/styles/prosilver/template/mcp_warn_list.html index d9c0bce088..5e43903f11 100644 --- a/phpBB/styles/prosilver/template/mcp_warn_list.html +++ b/phpBB/styles/prosilver/template/mcp_warn_list.html @@ -53,7 +53,7 @@ -

{L_WARNINGS_ZERO_TOTAL}

+

{L_NO_WARNINGS}

From 56629d8e3c80cd490b8ec39d4fa102d0303f9a4b Mon Sep 17 00:00:00 2001 From: Bruno Ais Date: Thu, 29 Mar 2012 15:52:28 +0100 Subject: [PATCH 139/335] [ticket/10705] Change WARNINGS_ZERO_TOTAL in subsilver2 Located the L_WARNINGS_ZERO_TOTAL in subsilver2 and replaced it with L_NO_WARNINGS PHPBB3-10705 --- phpBB/styles/subsilver2/template/mcp_warn_front.html | 4 ++-- phpBB/styles/subsilver2/template/mcp_warn_list.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/styles/subsilver2/template/mcp_warn_front.html b/phpBB/styles/subsilver2/template/mcp_warn_front.html index 417355d537..020a79f419 100644 --- a/phpBB/styles/subsilver2/template/mcp_warn_front.html +++ b/phpBB/styles/subsilver2/template/mcp_warn_front.html @@ -38,7 +38,7 @@
{L_WARNINGS_ZERO_TOTAL}{L_NO_WARNINGS}
@@ -64,7 +64,7 @@ - {L_WARNINGS_ZERO_TOTAL} + {L_NO_WARNINGS} diff --git a/phpBB/styles/subsilver2/template/mcp_warn_list.html b/phpBB/styles/subsilver2/template/mcp_warn_list.html index 6ed0b68bd5..0b0cfa8a45 100644 --- a/phpBB/styles/subsilver2/template/mcp_warn_list.html +++ b/phpBB/styles/subsilver2/template/mcp_warn_list.html @@ -21,7 +21,7 @@ - {L_WARNINGS_ZERO_TOTAL} + {L_NO_WARNINGS} From 7aef3eb7b3dae478fe90c5dfdb276b693c726272 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Thu, 29 Mar 2012 21:29:56 +0200 Subject: [PATCH 140/335] [feature/event-dispatcher] Braces CS fix PHPBB3-9550 --- phpBB/includes/event/extension_subscriber_loader.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/event/extension_subscriber_loader.php b/phpBB/includes/event/extension_subscriber_loader.php index 155846d53d..71b16b8371 100644 --- a/phpBB/includes/event/extension_subscriber_loader.php +++ b/phpBB/includes/event/extension_subscriber_loader.php @@ -37,7 +37,8 @@ class phpbb_event_extension_subscriber_loader ->core_path('event/') ->get_classes(); - foreach ($subscriber_classes as $class) { + foreach ($subscriber_classes as $class) + { $subscriber = new $class(); $this->dispatcher->addSubscriber($subscriber); } From ddf1a05ad018404f57472068cd533e121343e907 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Thu, 29 Mar 2012 21:09:02 +0100 Subject: [PATCH 141/335] [ticket/10510] Added docs to viewtopic quick mod tools array. PHPBB3-10510 --- phpBB/viewtopic.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index cf97196e31..8a95851b7e 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -518,6 +518,8 @@ gen_forum_auth_level('topic', $forum_id, $topic_data['forum_status']); $allow_change_type = ($auth->acl_get('m_', $forum_id) || ($user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'])) ? true : false; $quickmod_array = array( +// 'key' => array('LANG_KEY', $userHasPermissions), + 'lock' => array('LOCK_TOPIC', ($topic_data['topic_status'] == ITEM_UNLOCKED) && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED))), 'unlock' => array('UNLOCK_TOPIC', ($topic_data['topic_status'] != ITEM_UNLOCKED) && ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED))), 'delete_topic' => array('DELETE_TOPIC', $auth->acl_get('m_delete', $forum_id)), From b250ffc561a631d6639c80017e7d0178e7c68e05 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Thu, 29 Mar 2012 23:19:35 +0100 Subject: [PATCH 142/335] [feature/event-dispatcher] Add .gitignore to ignore the composer.phar file PHPBB3-9550 --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index eb7b546445..c6db64b115 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ /phpBB/cache/*.html /phpBB/cache/*.php /phpBB/cache/queue.php.lock +/phpBB/composer.phar /phpBB/config.php /phpBB/ext/* /phpBB/files/* From 0d6a5cb6ae29348a247c8f42e2046c8b84741aa5 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Fri, 30 Mar 2012 11:02:48 +0100 Subject: [PATCH 143/335] [feature/event-dispatcher] Update core.page_header event Update it to the new correct format. PHPBB3-9550 --- phpBB/includes/functions.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index bd7ed71dcb..7a96dd3609 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4763,9 +4763,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 )); $vars = array('page_title', 'display_online_list', 'item_id', 'item'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.page_header', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.page_header', compact($vars))); // application/xhtml+xml not used because of IE header('Content-type: text/html; charset=UTF-8'); From cab437ae83297a8fc092fe77fdae8eb66d3b93a1 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Fri, 30 Mar 2012 12:59:37 +0100 Subject: [PATCH 144/335] [feature/event-dispatcher] Add dependencies install information PHPBB3-9550 --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 51e65176c6..a7feb8db40 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,15 @@ phpBB is a free bulletin board written in PHP. Find support and lots more on [phpBB.com](http://www.phpbb.com)! Discuss the development on [area51](http://area51.phpbb.com/phpBB/index.php). +## INSTALLING DEPENDENCIES + +To be able to run an installation from the repo (and not from a pre-built package) you need to run the following commands to install phpBB's dependencies. + + cd phpBB + curl -s http://getcomposer.org/installer | php + php composer.phar install + + ## CONTRIBUTE 1. [Create an account on phpBB.com](http://www.phpbb.com/community/ucp.php?mode=register) From 951e2c8d0c32e6c2bcae02e2f2ff8be35af35b36 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Fri, 30 Mar 2012 14:22:20 +0200 Subject: [PATCH 145/335] [feature/event-dispatcher] Fix copyright years PHPBB3-9550 --- phpBB/includes/event/data.php | 2 +- phpBB/includes/event/extension_subscriber_loader.php | 2 +- tests/event/dispatcher_test.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/event/data.php b/phpBB/includes/event/data.php index 47cb2d5a30..70718ff0ae 100644 --- a/phpBB/includes/event/data.php +++ b/phpBB/includes/event/data.php @@ -2,7 +2,7 @@ /** * * @package phpBB3 -* @copyright (c) 2011 phpBB Group +* @copyright (c) 2012 phpBB Group * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ diff --git a/phpBB/includes/event/extension_subscriber_loader.php b/phpBB/includes/event/extension_subscriber_loader.php index 71b16b8371..d933b943d7 100644 --- a/phpBB/includes/event/extension_subscriber_loader.php +++ b/phpBB/includes/event/extension_subscriber_loader.php @@ -2,7 +2,7 @@ /** * * @package phpBB3 -* @copyright (c) 2011 phpBB Group +* @copyright (c) 2012 phpBB Group * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ diff --git a/tests/event/dispatcher_test.php b/tests/event/dispatcher_test.php index 59e51b1cdc..f8fe060d99 100644 --- a/tests/event/dispatcher_test.php +++ b/tests/event/dispatcher_test.php @@ -2,7 +2,7 @@ /** * * @package testing -* @copyright (c) 2010 phpBB Group +* @copyright (c) 2012 phpBB Group * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ From 506951e8aff98582ebc56fcda9ed0626497ade77 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Fri, 30 Mar 2012 16:13:16 +0300 Subject: [PATCH 146/335] [feature/merging-style-components] Changing acp_styles text Changing acp styles welcome message a little bit. PHPBB3-10632 --- phpBB/language/en/acp/styles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/language/en/acp/styles.php b/phpBB/language/en/acp/styles.php index fe7fae5808..8a4a8e7308 100644 --- a/phpBB/language/en/acp/styles.php +++ b/phpBB/language/en/acp/styles.php @@ -237,7 +237,7 @@ $lang = array_merge($lang, array( 'INHERITING_FROM' => 'Inherits from', 'INSTALL_STYLE' => 'Install style', 'INSTALL_STYLES' => 'Install styles', - 'INSTALL_STYLES_EXPLAIN' => 'Here you can install new styles.
If you cannot find a specific style in list below, check if that style is already installed. If it is not installed, check if it was uploaded correctly.', + 'INSTALL_STYLES_EXPLAIN' => 'Here you can install new styles.
If you cannot find a specific style in list below, check to make sure style is already installed. If it is not installed, check if it was uploaded correctly.', 'INSTALLED_STYLE' => 'Installed styles', 'INVALID_STYLE_ID' => 'Invalid style ID.', From 9391d423c05818e5f18ddbe051e1713c835f4404 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Fri, 30 Mar 2012 19:04:20 +0100 Subject: [PATCH 147/335] [feature/event-dispatcher] Adding composer.phar to .gitignore for olympus To keep the .gitignore's the same. PHPBB3-9550 --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e6e017f85e..de26e1dd1e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ /phpBB/cache/*.html /phpBB/cache/*.php /phpBB/cache/queue.php.lock +/phpBB/composer.phar /phpBB/config.php /phpBB/config_dev.php /phpBB/config_test.php From d420ceb9c717b83ba29dde3734b563881051e51a Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Thu, 14 Jul 2011 13:33:42 +0100 Subject: [PATCH 148/335] [ticket/10270] Added JavaScript popups and basic AJAX functionality to PHP. This commit adds the phpbb object (JavaScript), and alert and confirm box methods. It also adds the first basic AJAX functionality, to deleting posts in viewtopic. PHPBB3-10270 --- phpBB/includes/functions.php | 53 ++++++++++-- .../prosilver/template/overall_footer.html | 3 + phpBB/styles/prosilver/theme/common.css | 30 ++++++- phpBB/styles/script.js | 80 +++++++++++++++++++ 4 files changed, 158 insertions(+), 8 deletions(-) create mode 100644 phpBB/styles/script.js diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 7a96dd3609..572986bb4b 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2448,15 +2448,25 @@ function build_url($strip_vars = false) */ function meta_refresh($time, $url, $disable_cd_check = false) { - global $template; + global $template, $refresh_data; - $url = redirect($url, true, $disable_cd_check); - $url = str_replace('&', '&', $url); + if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') + { + $refresh_data = array( + 'time' => $time, + 'url' => str_replace('&', '&', $url) + ); + } + else + { + $url = redirect($url, true, $disable_cd_check); + $url = str_replace('&', '&', $url); - // For XHTML compatibility we change back & to & - $template->assign_vars(array( - 'META' => '') - ); + // For XHTML compatibility we change back & to & + $template->assign_vars(array( + 'META' => '') + ); + } return $url; } @@ -2699,6 +2709,21 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo WHERE user_id = " . $user->data['user_id']; $db->sql_query($sql); + + if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') + { + $u_action .= '&confirm_uid=' . $user->data['user_id'] . '&sess=' . $user->session_id . '&sid=' . $user->session_id; + echo json_encode(array( + 'MESSAGE_TITLE' => (!isset($user->lang[$title])) ? $user->lang['CONFIRM'] : $user->lang[$title], + 'MESSAGE_TEXT' => (!isset($user->lang[$title . '_CONFIRM'])) ? $title : $user->lang[$title . '_CONFIRM'], + + 'YES_VALUE' => $user->lang['YES'], + 'S_CONFIRM_ACTION' => str_replace('&', '&', $u_action), //inefficient, rewrite whole function + 'S_HIDDEN_FIELDS' => $hidden . $s_hidden_fields + )); + exit; + } + if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) { adm_page_footer(); @@ -3922,6 +3947,20 @@ function msg_handler($errno, $msg_text, $errfile, $errline) 'S_USER_NOTICE' => ($errno == E_USER_NOTICE) ? true : false) ); + if ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') + { + global $refresh_data; + + echo json_encode(array( + 'MESSAGE_TITLE' => $msg_title, + 'MESSAGE_TEXT' => $msg_text, + 'S_USER_WARNING' => ($errno == E_USER_WARNING) ? true : false, + 'S_USER_NOTICE' => ($errno == E_USER_NOTICE) ? true : false, + 'REFRESH_DATA' => (!empty($refresh_data)) ? $refresh_data : null + )); + exit; + } + // We do not want the cron script to be called on error messages define('IN_CRON', true); diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html index 4456d6b37d..0d2fd4d27a 100644 --- a/phpBB/styles/prosilver/template/overall_footer.html +++ b/phpBB/styles/prosilver/template/overall_footer.html @@ -24,6 +24,9 @@
{DEBUG_OUTPUT}
{L_ACP} + + + diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index 27a55caf7a..5cf12be1ce 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -468,7 +468,7 @@ table.info tbody th { /* Misc layout styles ---------------------------------------- */ -/* column[1-2] styles are containers for two column layouts +/* column[1-2] styles are containers for two column layouts Also see tweaks.css */ .column1 { float: left; @@ -580,6 +580,34 @@ li.pagination { background: none 0 50% no-repeat; } +.row .pagination span a, li.pagination span a { + background-color: #FFFFFF; +} + +.row .pagination span a:hover, li.pagination span a:hover { + background-color: #d2d2d2; +} + +/* jQuery popups +---------------------------------------- */ +.jalert { + background-color: #FFFFFF; + border: 1px solid #999999; + display: none; + position: fixed; + top: 100px; + left: 35%; + width: 30%; + z-index: 50; + padding: 25px; + padding: 0 25px 20px 25px; +} + +.jalert p { + margin: 8px 0; + padding-bottom: 8px; +} + /* Miscellaneous styles ---------------------------------------- */ #forum-permissions { diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js new file mode 100644 index 0000000000..9be3efd4ce --- /dev/null +++ b/phpBB/styles/script.js @@ -0,0 +1,80 @@ +var phpbb = {}; + +/** + * Display a simple alert. + * + * @param string title Title of the message, eg "Information" + * @param string msg Message to display. Can be HTML. + */ +phpbb.alert = function(title, msg) { + var div = $('

' + title + '

' + msg + '

'); + + $(document).bind('click', function(e) { + if ($(e.target).parents('.jalert').length) + { + return true; + } + div.hide(300, function() { + div.remove(); + }); + return false; + }); + + $('body').append(div); + div.show(300); +} + +/** + * Display a simple yes / no box to the user. + * + * @param string msg Message to display. Can be HTML. + * @param function callback Callback. + */ +phpbb.confirm = function(msg, callback) { + var div = $('

' + msg + '

\ +  \ +
'); + + $('body').append(div); + + $('.jalertbut').bind('click', function(event) { + div.hide(300, function() { + div.remove(); + }); + callback(this.value === 'Yes'); + return false; + }); + div.show(300); +} + + + +$('.delete-icon a').click(function() +{ + var pid = this.href.split('&p=')[1]; + var __self = this; + $.get(this.href, function(res) { + res = JSON.parse(res); + phpbb.confirm(res.MESSAGE_TEXT, function(del) { + if (del) + { + var p = res.S_CONFIRM_ACTION.split('?'); + p[1] += '&confirm=Yes' + $.post(p[0], p[1], function(res) { + res = JSON.parse(res); + phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT) + $(__self).parents('div #p' + pid).remove(); + + //if there is a refresh, check that it isn't to the same place + if (res.REFRESH_DATA && res.REFRESH_DATA.url.indexOf('t=') === -1) + { + setTimeout(function() { + window.location = res.REFRESH_DATA.url; + }, res.REFRESH_DATA.time * 1000); + } + }); + } + }); + }); + return false; +}); From e6401c081e2e7543db020d16271792d715571249 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Thu, 14 Jul 2011 14:41:24 +0100 Subject: [PATCH 149/335] [ticket/10271] Added phpbb.confirm_box (JavaScript). As well as adding the method, this commit also changes the previous commit so that deleting a post from viewtopic uses this method, too. This commit has also made some improvements to phpbb.alert and phpbb.confirm. PHPBB3-10271 --- phpBB/styles/script.js | 97 ++++++++++++++++++++++++++++++------------ 1 file changed, 70 insertions(+), 27 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 9be3efd4ce..ed10375cf1 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -5,11 +5,13 @@ var phpbb = {}; * * @param string title Title of the message, eg "Information" * @param string msg Message to display. Can be HTML. + * + * @return Returns the div created. */ phpbb.alert = function(title, msg) { var div = $('

' + title + '

' + msg + '

'); - $(document).bind('click', function(e) { + $(document).one('click', function(e) { if ($(e.target).parents('.jalert').length) { return true; @@ -22,6 +24,7 @@ phpbb.alert = function(title, msg) { $('body').append(div); div.show(300); + return div; } /** @@ -29,6 +32,8 @@ phpbb.alert = function(title, msg) { * * @param string msg Message to display. Can be HTML. * @param function callback Callback. + * + * @return Returns the div created. */ phpbb.confirm = function(msg, callback) { var div = $('

' + msg + '

\ @@ -45,36 +50,74 @@ phpbb.confirm = function(msg, callback) { return false; }); div.show(300); + return div; } - -$('.delete-icon a').click(function() +/** + * This function interacts via AJAX with phpBBs confirm_box function. + * + * @param string condition The element to capture. + * @param bool/function refresh If we are sent back a refresh, should it be + * acted upon? This can either be true / false / a function. + * @param function callback Callback. + */ +phpbb.confirm_box = function(condition, refresh, callback) { - var pid = this.href.split('&p=')[1]; - var __self = this; - $.get(this.href, function(res) { - res = JSON.parse(res); - phpbb.confirm(res.MESSAGE_TEXT, function(del) { - if (del) - { - var p = res.S_CONFIRM_ACTION.split('?'); - p[1] += '&confirm=Yes' - $.post(p[0], p[1], function(res) { - res = JSON.parse(res); - phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT) - $(__self).parents('div #p' + pid).remove(); + __self = this; + $(condition).click(function() { + var __self = this; + $.get(this.href, function(res) { + res = JSON.parse(res); + phpbb.confirm(res.MESSAGE_TEXT, function(del) { + if (del) + { + var p = res.S_CONFIRM_ACTION.split('?'); + p[1] += '&confirm=Yes'; + $.post(p[0], p[1], function(res) { + res = JSON.parse(res); + var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); + callback(__self); - //if there is a refresh, check that it isn't to the same place - if (res.REFRESH_DATA && res.REFRESH_DATA.url.indexOf('t=') === -1) - { - setTimeout(function() { - window.location = res.REFRESH_DATA.url; - }, res.REFRESH_DATA.time * 1000); - } - }); - } + if (res.REFRESH_DATA) + { + if (typeof refresh === 'function') + { + refresh = refresh(res.REFRESH_DATA.url) + } + else if (typeof refresh !== 'boolean') + { + refresh = false; + } + + if (refresh) + { + setTimeout(function() { + window.location = res.REFRESH_DATA.url; + }, res.REFRESH_DATA.time * 1000); + } + else + { + setTimeout(function() { + div.hide(300, function() { + div.remove(); + }); + }, res.REFRESH_DATA.time * 1000); + } + } + }); + } + }); }); + return false; }); - return false; -}); +} + +var refresh = function(url) { + return (url.indexOf('t=') === -1); +} +var callback = function(el) { + var pid = el.href.split('&p=')[1]; + $(el).parents('div #p' + pid).remove(); +} +phpbb.confirm_box('.delete-icon a', refresh, callback); From 2556f5fcc2df1dc51ddd5a97859a7325809b7837 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Thu, 14 Jul 2011 14:57:45 +0100 Subject: [PATCH 150/335] [ticket/10272] AJAXified most links. This commit makes some significant changes to the phpbb.confirm_box function (namely, removing some duplicate code), and also manually adds most link to the phpBB AJAX functions. PHPBB3-10272 --- phpBB/styles/script.js | 101 +++++++++++++++++++++++++++++++---------- 1 file changed, 76 insertions(+), 25 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index ed10375cf1..ee67768469 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -53,6 +53,39 @@ phpbb.confirm = function(msg, callback) { return div; } +/** + * Clearing up some duplicate code - don't use this. + */ +function handle_refresh(data, refresh, div) +{ + if (data) + { + if (typeof refresh === 'function') + { + refresh = refresh(data.url) + } + else if (typeof refresh !== 'boolean') + { + refresh = false; + } + + if (refresh) + { + setTimeout(function() { + window.location = data.url; + }, data.time * 1000); + } + else + { + setTimeout(function() { + div.hide(300, function() { + div.remove(); + }); + }, data.time * 1000); + } + } +} + /** * This function interacts via AJAX with phpBBs confirm_box function. @@ -77,34 +110,13 @@ phpbb.confirm_box = function(condition, refresh, callback) $.post(p[0], p[1], function(res) { res = JSON.parse(res); var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - callback(__self); - if (res.REFRESH_DATA) + if (typeof callback !== 'undefined') { - if (typeof refresh === 'function') - { - refresh = refresh(res.REFRESH_DATA.url) - } - else if (typeof refresh !== 'boolean') - { - refresh = false; - } - - if (refresh) - { - setTimeout(function() { - window.location = res.REFRESH_DATA.url; - }, res.REFRESH_DATA.time * 1000); - } - else - { - setTimeout(function() { - div.hide(300, function() { - div.remove(); - }); - }, res.REFRESH_DATA.time * 1000); - } + callback(__self); } + + handle_refresh(res.REFRESH_DATA, refresh, alert); }); } }); @@ -113,6 +125,26 @@ phpbb.confirm_box = function(condition, refresh, callback) }); } +/** + * Makes a link use AJAX instead of loading an entire page. + */ +phpbb.ajaxify = function(selector, refresh, callback) { + $(selector).click(function() { + var __self = this; + $.get(this.href, function(res) { + res = JSON.parse(res); + var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); + if (typeof callback !== 'undefined') + { + callback(__self, res); + } + + handle_refresh(res.REFRESH_DATA, refresh, alert); + }); + return false; + }); +} + var refresh = function(url) { return (url.indexOf('t=') === -1); } @@ -121,3 +153,22 @@ var callback = function(el) { $(el).parents('div #p' + pid).remove(); } phpbb.confirm_box('.delete-icon a', refresh, callback); +phpbb.confirm_box('a[href$="ucp.php?mode=delete_cookies"]', true); + +phpbb.ajaxify('a[href*="&bookmark=1"]', false, function(el, res) { + var text = (res.MESSAGE_TEXT.indexOf('Removed') === -1); + text = (text) ? 'Remove from bookmarks' : 'Bookmark topic'; + $(el).text(el.title = text); +}); +phpbb.ajaxify('a[href*="&watch=topic"]', false, function(el, res) { + var text = (res.MESSAGE_TEXT.indexOf('no longer subscribed') === -1); + text = (text) ? 'Unsubscribe topic' : 'Subscribe topic'; + $(el).text(el.title = text); +}); +phpbb.ajaxify('a[href*="watch=forum"]', false, function(el, res) { + var text = (res.MESSAGE_TEXT.indexOf('no longer subscribed') === -1); + text = (text) ? 'Unsubscribe forum' : 'Subscribe forum'; + $(el).text(el.title = text); +}); +phpbb.ajaxify('a[href*="mode=bump"]'); +phpbb.ajaxify('a[href*="mark="]'); //captures topics and forums From c4aaf3ae5a2b0a720227a0eadcb62bea5671056a Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Thu, 14 Jul 2011 17:49:17 +0100 Subject: [PATCH 151/335] [feature/ajax] Cleaned up AJAX-related JavaScript. Mostly just added comments, but has cleaned up some actual code too. PHPBB3-10270 --- phpBB/styles/script.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index ee67768469..4e0566a9a5 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -1,7 +1,7 @@ var phpbb = {}; /** - * Display a simple alert. + * Display a simple alert similar to JSs native alert(). * * @param string title Title of the message, eg "Information" * @param string msg Message to display. Can be HTML. @@ -54,7 +54,7 @@ phpbb.confirm = function(msg, callback) { } /** - * Clearing up some duplicate code - don't use this. + * Works out what to do with the refresh. Don't use this. */ function handle_refresh(data, refresh, div) { @@ -97,7 +97,6 @@ function handle_refresh(data, refresh, div) */ phpbb.confirm_box = function(condition, refresh, callback) { - __self = this; $(condition).click(function() { var __self = this; $.get(this.href, function(res) { @@ -106,16 +105,13 @@ phpbb.confirm_box = function(condition, refresh, callback) if (del) { var p = res.S_CONFIRM_ACTION.split('?'); - p[1] += '&confirm=Yes'; - $.post(p[0], p[1], function(res) { + $.post(p[0], p[1] + '&confirm=Yes', function(res) { res = JSON.parse(res); var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - if (typeof callback !== 'undefined') { callback(__self); } - handle_refresh(res.REFRESH_DATA, refresh, alert); }); } @@ -127,6 +123,11 @@ phpbb.confirm_box = function(condition, refresh, callback) /** * Makes a link use AJAX instead of loading an entire page. + * + * @param string condition The element to capture. + * @param bool/function refresh If we are sent back a refresh, should it be + * acted upon? This can either be true / false / a function. + * @param function callback Callback. */ phpbb.ajaxify = function(selector, refresh, callback) { $(selector).click(function() { @@ -138,23 +139,25 @@ phpbb.ajaxify = function(selector, refresh, callback) { { callback(__self, res); } - handle_refresh(res.REFRESH_DATA, refresh, alert); }); return false; }); } + +//bind the confirm_boxes var refresh = function(url) { return (url.indexOf('t=') === -1); } -var callback = function(el) { +phpbb.confirm_box('.delete-icon a', refresh, function(el) { var pid = el.href.split('&p=')[1]; $(el).parents('div #p' + pid).remove(); -} -phpbb.confirm_box('.delete-icon a', refresh, callback); +}); phpbb.confirm_box('a[href$="ucp.php?mode=delete_cookies"]', true); + +//AJAXify some links phpbb.ajaxify('a[href*="&bookmark=1"]', false, function(el, res) { var text = (res.MESSAGE_TEXT.indexOf('Removed') === -1); text = (text) ? 'Remove from bookmarks' : 'Bookmark topic'; From 8a28456f759747fc34aaf9a6589102fcace3acb6 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sat, 16 Jul 2011 17:53:22 +0100 Subject: [PATCH 152/335] [ticket/10273] AJAXified approve / disapprove posts (in viewtopic). This commit AJAXifies the moderator approval functionality, and adds it to viewtopic instead of the MCP. This commit has involved some language changes, which may affect fallbacks. PHPBB3-10273 --- phpBB/language/en/common.php | 2 +- phpBB/language/en/viewtopic.php | 2 + .../prosilver/template/viewtopic_body.html | 10 +++- phpBB/styles/prosilver/theme/common.css | 4 ++ phpBB/styles/script.js | 51 +++++++++++++++++++ phpBB/viewtopic.php | 1 + 6 files changed, 68 insertions(+), 2 deletions(-) diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 94edddc6f5..19b801e585 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -476,7 +476,7 @@ $lang = array_merge($lang, array( 'POST_SUBJECT' => 'Post subject', 'POST_TIME' => 'Post time', 'POST_TOPIC' => 'Post a new topic', - 'POST_UNAPPROVED' => 'This post is waiting for approval', + 'POST_UNAPPROVED' => 'Post awaiting approval:', 'PREVIEW' => 'Preview', 'PREVIOUS' => 'Previous', // Used in pagination 'PREVIOUS_STEP' => 'Previous', diff --git a/phpBB/language/en/viewtopic.php b/phpBB/language/en/viewtopic.php index f47f8a076b..1460490672 100644 --- a/phpBB/language/en/viewtopic.php +++ b/phpBB/language/en/viewtopic.php @@ -35,6 +35,7 @@ if (empty($lang) || !is_array($lang)) // in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine $lang = array_merge($lang, array( + 'APPROVE' => 'Approve', 'ATTACHMENT' => 'Attachment', 'ATTACHMENT_FUNCTIONALITY_DISABLED' => 'The attachments feature has been disabled.', @@ -49,6 +50,7 @@ $lang = array_merge($lang, array( 'CODE' => 'Code', 'DELETE_TOPIC' => 'Delete topic', + 'DISAPPROVE' => 'Disapprove', 'DOWNLOAD_NOTICE' => 'You do not have the required permissions to view the files attached to this post.', 'EDITED_TIMES_TOTAL' => array( diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index 59e464d22e..5571ce07c4 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -135,10 +135,18 @@

{postrow.MINI_POST_IMG}{postrow.MINI_POST_IMG}{L_POST_BY_AUTHOR} {postrow.POST_AUTHOR_FULL} » {postrow.POST_DATE}

+

- {UNAPPROVED_IMG} {L_POST_UNAPPROVED}
+ + {UNAPPROVED_IMG} {L_POST_UNAPPROVED}   +   + + + {S_FORM_TOKEN} +
{REPORTED_IMG} {L_POST_REPORTED}

+
{postrow.MESSAGE}
diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index 5cf12be1ce..6b34bb1c3d 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -658,6 +658,10 @@ p.rules { p.rules img { vertical-align: middle; +} + +p.rules strong { + vertical-align: middle; padding-top: 5px; } diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 4e0566a9a5..b5dec2ca0a 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -86,6 +86,18 @@ function handle_refresh(data, refresh, div) } } +function parse_hidden(inputs) +{ + var end = []; + $(inputs).each(function() { + if (this.type === 'hidden') + { + end.push(this.name + '=' + this.value); + } + }); + return end.join('&'); +} + /** * This function interacts via AJAX with phpBBs confirm_box function. @@ -175,3 +187,42 @@ phpbb.ajaxify('a[href*="watch=forum"]', false, function(el, res) { }); phpbb.ajaxify('a[href*="mode=bump"]'); phpbb.ajaxify('a[href*="mark="]'); //captures topics and forums + + + +/** + * Forms have to be captured manually, as they're all different. + */ +$('input[name^="action"]').click(function(e) { + var __self = this; + var path = $(this).parents('form')[0].action.replace('&', '&'); + var action = (this.name === 'action[approve]') ? 'approve' : 'disapprove'; + var data = { + action: action, + post_id_list: [$(this).siblings('input[name="post_id_list[]"]')[0].value] + }; + $.post(path, data, function(res) { + res = JSON.parse(res); + phpbb.confirm(res.MESSAGE_TEXT, function(del) { + if (del) + { + path = res.S_CONFIRM_ACTION; + data = parse_hidden(res.S_HIDDEN_FIELDS); + $.post(path, data + '&confirm=Yes', function(res) { + console.log(res); + res = JSON.parse(res); + var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); + + $(__self).parents((action === 'approve') ? '.rules' : '.post').remove(); + + setTimeout(function() { + alert.hide(300, function() { + alert.remove(); + }); + }, 5000); + }); + } + }); + }); + return false; +}); diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 8a95851b7e..1ce80568b6 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -1534,6 +1534,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'U_YIM' => $user_cache[$poster_id]['yim'], 'U_JABBER' => $user_cache[$poster_id]['jabber'], + 'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&p={$row['post_id']}&f=$forum_id"), 'U_REPORT' => ($auth->acl_get('f_report', $forum_id)) ? append_sid("{$phpbb_root_path}report.$phpEx", 'f=' . $forum_id . '&p=' . $row['post_id']) : '', 'U_MCP_REPORT' => ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=report_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', 'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=approve_details&f=' . $forum_id . '&p=' . $row['post_id'], true, $user->session_id) : '', From 456e56144256f3d14d78b02b397d5f3838f0cfea Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sat, 16 Jul 2011 18:20:04 +0100 Subject: [PATCH 153/335] [ticket/10270] Cleaned up code and made popups fade. This commit cleans up some code - mostly, replacing all instances of __self with "that", and also replacing the parse_hidden function with jQuerys built in .serialize. It also adds animations to the popups. PHPBB3-10270 --- phpBB/styles/script.js | 42 +++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index b5dec2ca0a..17934ed6ae 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -16,14 +16,14 @@ phpbb.alert = function(title, msg) { { return true; } - div.hide(300, function() { + div.animate({opacity: 0}, 300, function() { div.remove(); }); return false; }); $('body').append(div); - div.show(300); + div.css('opacity', 0).show().animate({opacity: 1}, 300); return div; } @@ -43,13 +43,13 @@ phpbb.confirm = function(msg, callback) { $('body').append(div); $('.jalertbut').bind('click', function(event) { - div.hide(300, function() { + div.animate({opacity: 0}, 300, function() { div.remove(); }); callback(this.value === 'Yes'); return false; }); - div.show(300); + div.css('opacity', 0).show().animate({opacity: 1}, 300); return div; } @@ -78,7 +78,7 @@ function handle_refresh(data, refresh, div) else { setTimeout(function() { - div.hide(300, function() { + div.animate({opacity: 0}, 300, function() { div.remove(); }); }, data.time * 1000); @@ -86,18 +86,6 @@ function handle_refresh(data, refresh, div) } } -function parse_hidden(inputs) -{ - var end = []; - $(inputs).each(function() { - if (this.type === 'hidden') - { - end.push(this.name + '=' + this.value); - } - }); - return end.join('&'); -} - /** * This function interacts via AJAX with phpBBs confirm_box function. @@ -110,19 +98,20 @@ function parse_hidden(inputs) phpbb.confirm_box = function(condition, refresh, callback) { $(condition).click(function() { - var __self = this; + var that = this; $.get(this.href, function(res) { res = JSON.parse(res); phpbb.confirm(res.MESSAGE_TEXT, function(del) { if (del) { - var p = res.S_CONFIRM_ACTION.split('?'); - $.post(p[0], p[1] + '&confirm=Yes', function(res) { + var path = res.S_CONFIRM_ACTION; + var data = $('
' + res.S_HIDDEN_FIELDS + '
').serialize(); + $.post(path, data + '&confirm=Yes', function(res) { res = JSON.parse(res); var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); if (typeof callback !== 'undefined') { - callback(__self); + callback(that); } handle_refresh(res.REFRESH_DATA, refresh, alert); }); @@ -143,13 +132,13 @@ phpbb.confirm_box = function(condition, refresh, callback) */ phpbb.ajaxify = function(selector, refresh, callback) { $(selector).click(function() { - var __self = this; + var that = this; $.get(this.href, function(res) { res = JSON.parse(res); var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); if (typeof callback !== 'undefined') { - callback(__self, res); + callback(that, res); } handle_refresh(res.REFRESH_DATA, refresh, alert); }); @@ -194,7 +183,7 @@ phpbb.ajaxify('a[href*="mark="]'); //captures topics and forums * Forms have to be captured manually, as they're all different. */ $('input[name^="action"]').click(function(e) { - var __self = this; + var that = this; var path = $(this).parents('form')[0].action.replace('&', '&'); var action = (this.name === 'action[approve]') ? 'approve' : 'disapprove'; var data = { @@ -207,13 +196,12 @@ $('input[name^="action"]').click(function(e) { if (del) { path = res.S_CONFIRM_ACTION; - data = parse_hidden(res.S_HIDDEN_FIELDS); + data = $('
' + res.S_HIDDEN_FIELDS + '
').serialize(); $.post(path, data + '&confirm=Yes', function(res) { - console.log(res); res = JSON.parse(res); var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - $(__self).parents((action === 'approve') ? '.rules' : '.post').remove(); + $(that).parents((action === 'approve') ? '.rules' : '.post').remove(); setTimeout(function() { alert.hide(300, function() { From f42f6f19028fab5b047baae0df5004a43e946a30 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sun, 17 Jul 2011 14:57:13 +0100 Subject: [PATCH 154/335] [ticket/10273] Added phpbb.ajaxify_form and converted accept / deny to it. Also made a few minor improvements to other JavaScript. PHPBB3-10273 --- .../prosilver/template/viewtopic_body.html | 4 +- phpBB/styles/script.js | 125 +++++++++++------- 2 files changed, 80 insertions(+), 49 deletions(-) diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index 5571ce07c4..856ee6962c 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -139,8 +139,8 @@

{UNAPPROVED_IMG} {L_POST_UNAPPROVED}   -   - +   + {S_FORM_TOKEN}
diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 17934ed6ae..5d9b89e386 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -1,3 +1,26 @@ +/** + * Make some changes to the jQuery core. + */ +$.fn.hide = function() { + this.animate({opacity: 0}, 300, function() { + $(this).css('display', 'none') + .css('opacity', 1); + }); +} +$.fn.show = function() { + this.css('opacity', 0) + .css('display', 'block') + .animate({opacity: 1}, 300); +} + +$.fn.remove_old = $.fn.remove; +$.fn.remove = function() { + this.animate({opacity: 0}, 300, function() { + $(this).remove_old(); + }); +} + + var phpbb = {}; /** @@ -16,14 +39,12 @@ phpbb.alert = function(title, msg) { { return true; } - div.animate({opacity: 0}, 300, function() { - div.remove(); - }); + div.remove(); return false; }); $('body').append(div); - div.css('opacity', 0).show().animate({opacity: 1}, 300); + div.show(); return div; } @@ -37,19 +58,17 @@ phpbb.alert = function(title, msg) { */ phpbb.confirm = function(msg, callback) { var div = $('

' + msg + '

\ -  \ -
'); +  \ +
'); $('body').append(div); $('.jalertbut').bind('click', function(event) { - div.animate({opacity: 0}, 300, function() { - div.remove(); - }); + div.remove(); callback(this.value === 'Yes'); return false; }); - div.css('opacity', 0).show().animate({opacity: 1}, 300); + div.show(); return div; } @@ -101,12 +120,13 @@ phpbb.confirm_box = function(condition, refresh, callback) var that = this; $.get(this.href, function(res) { res = JSON.parse(res); + console.log(res); phpbb.confirm(res.MESSAGE_TEXT, function(del) { if (del) { var path = res.S_CONFIRM_ACTION; var data = $('
' + res.S_HIDDEN_FIELDS + '
').serialize(); - $.post(path, data + '&confirm=Yes', function(res) { + $.post(path, data + '&confirm=' + res.YES_VALUE, function(res) { res = JSON.parse(res); var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); if (typeof callback !== 'undefined') @@ -135,6 +155,7 @@ phpbb.ajaxify = function(selector, refresh, callback) { var that = this; $.get(this.href, function(res) { res = JSON.parse(res); + console.log(res); var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); if (typeof callback !== 'undefined') { @@ -146,6 +167,50 @@ phpbb.ajaxify = function(selector, refresh, callback) { }); } +/** + * AJAXifies a form. This will automatically get the action from the submit. + * + * @param string condition The element to capture. + * @param bool/function refresh If we are sent back a refresh, should it be + * acted upon? This can either be true / false / a function. + * @param function callback Callback. + */ +phpbb.ajaxify_form = function(selector, refresh, callback) +{ + $(selector + ' input:submit').click(function(e) { + var act = /action\[([a-z]+)\]/.exec(this.name), + data = decodeURI($(this).closest('form').serialize()), + path = $(this).closest('form').attr('action').replace('&', '&'), + that = this; + + if (act) + { + data += '&action=' + act[1]; + } + + $.post(path, data, function(res) { + res = JSON.parse(res); + phpbb.confirm(res.MESSAGE_TEXT, function(del) { + if (del) + { + path = res.S_CONFIRM_ACTION; + data = $('
' + res.S_HIDDEN_FIELDS + '
').serialize(); + $.post(path, data + '&confirm=' + res.YES_VALUE, function(res) { + res = JSON.parse(res); + var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); + if (typeof callback !== 'undefined') + { + callback(that, act[1]); + } + handle_refresh(res.REFRESH_DATA, refresh, alert); + }); + } + }); + }); + return false; + }); +} + //bind the confirm_boxes var refresh = function(url) { @@ -177,40 +242,6 @@ phpbb.ajaxify('a[href*="watch=forum"]', false, function(el, res) { phpbb.ajaxify('a[href*="mode=bump"]'); phpbb.ajaxify('a[href*="mark="]'); //captures topics and forums - - -/** - * Forms have to be captured manually, as they're all different. - */ -$('input[name^="action"]').click(function(e) { - var that = this; - var path = $(this).parents('form')[0].action.replace('&', '&'); - var action = (this.name === 'action[approve]') ? 'approve' : 'disapprove'; - var data = { - action: action, - post_id_list: [$(this).siblings('input[name="post_id_list[]"]')[0].value] - }; - $.post(path, data, function(res) { - res = JSON.parse(res); - phpbb.confirm(res.MESSAGE_TEXT, function(del) { - if (del) - { - path = res.S_CONFIRM_ACTION; - data = $('
' + res.S_HIDDEN_FIELDS + '
').serialize(); - $.post(path, data + '&confirm=Yes', function(res) { - res = JSON.parse(res); - var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - - $(that).parents((action === 'approve') ? '.rules' : '.post').remove(); - - setTimeout(function() { - alert.hide(300, function() { - alert.remove(); - }); - }, 5000); - }); - } - }); - }); - return false; +phpbb.ajaxify_form('.mcp_approve', false, function(el, act) { + $(el).parents((act === 'approve') ? '.rules' : '.post').remove(); }); From fbad17f91202236d3b4ed5c1dacb844aaf2ddbff Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sun, 17 Jul 2011 15:27:58 +0100 Subject: [PATCH 155/335] [feature/ajax] Reduced duplicate code by merging all AJAX function into one. This commit merges phpbb.confirm_box, phpbb.ajaxify and phpbb.ajaxify_form into one function which automatically detects what is happening and calls the correct code accordingly. This has removed a lot of duplicate code and generally made the code cleaner. PHPBB3-10270 --- phpBB/styles/script.js | 202 +++++++++++++++++------------------------ 1 file changed, 84 insertions(+), 118 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 5d9b89e386..e893b84bf8 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -75,72 +75,7 @@ phpbb.confirm = function(msg, callback) { /** * Works out what to do with the refresh. Don't use this. */ -function handle_refresh(data, refresh, div) -{ - if (data) - { - if (typeof refresh === 'function') - { - refresh = refresh(data.url) - } - else if (typeof refresh !== 'boolean') - { - refresh = false; - } - if (refresh) - { - setTimeout(function() { - window.location = data.url; - }, data.time * 1000); - } - else - { - setTimeout(function() { - div.animate({opacity: 0}, 300, function() { - div.remove(); - }); - }, data.time * 1000); - } - } -} - - -/** - * This function interacts via AJAX with phpBBs confirm_box function. - * - * @param string condition The element to capture. - * @param bool/function refresh If we are sent back a refresh, should it be - * acted upon? This can either be true / false / a function. - * @param function callback Callback. - */ -phpbb.confirm_box = function(condition, refresh, callback) -{ - $(condition).click(function() { - var that = this; - $.get(this.href, function(res) { - res = JSON.parse(res); - console.log(res); - phpbb.confirm(res.MESSAGE_TEXT, function(del) { - if (del) - { - var path = res.S_CONFIRM_ACTION; - var data = $('
' + res.S_HIDDEN_FIELDS + '
').serialize(); - $.post(path, data + '&confirm=' + res.YES_VALUE, function(res) { - res = JSON.parse(res); - var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - if (typeof callback !== 'undefined') - { - callback(that); - } - handle_refresh(res.REFRESH_DATA, refresh, alert); - }); - } - }); - }); - return false; - }); -} /** * Makes a link use AJAX instead of loading an entire page. @@ -151,62 +86,92 @@ phpbb.confirm_box = function(condition, refresh, callback) * @param function callback Callback. */ phpbb.ajaxify = function(selector, refresh, callback) { - $(selector).click(function() { - var that = this; - $.get(this.href, function(res) { - res = JSON.parse(res); - console.log(res); - var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - if (typeof callback !== 'undefined') - { - callback(that, res); - } - handle_refresh(res.REFRESH_DATA, refresh, alert); - }); - return false; - }); -} -/** - * AJAXifies a form. This will automatically get the action from the submit. - * - * @param string condition The element to capture. - * @param bool/function refresh If we are sent back a refresh, should it be - * acted upon? This can either be true / false / a function. - * @param function callback Callback. - */ -phpbb.ajaxify_form = function(selector, refresh, callback) -{ - $(selector + ' input:submit').click(function(e) { - var act = /action\[([a-z]+)\]/.exec(this.name), - data = decodeURI($(this).closest('form').serialize()), - path = $(this).closest('form').attr('action').replace('&', '&'), - that = this; - - if (act) + //private function to handle refreshes + function handle_refresh(data, refresh, div) + { + if (!data) { - data += '&action=' + act[1]; + return; } - $.post(path, data, function(res) { + refresh = ((typeof refresh === 'function') ? refresh(data.url) : + (typeof refresh === 'boolean') && refresh); + + setTimeout(function() { + if (refresh) + { + window.location = data.url; + } + else + { + div.remove(); + } + }, data.time * 1000); + } + + var is_form = $(selector).is('form'); + $(selector + ((is_form) ? ' input:submit' : '')).click(function() { + var act, data, path, that = this; + function return_handler(res) + { res = JSON.parse(res); - phpbb.confirm(res.MESSAGE_TEXT, function(del) { - if (del) + + if (typeof res.S_CONFIRM_ACTION === 'undefined') + { + /** + * It is a standard link, no confirm_box required. + */ + var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); + if (typeof callback !== 'undefined') { - path = res.S_CONFIRM_ACTION; - data = $('
' + res.S_HIDDEN_FIELDS + '
').serialize(); - $.post(path, data + '&confirm=' + res.YES_VALUE, function(res) { - res = JSON.parse(res); - var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - if (typeof callback !== 'undefined') - { - callback(that, act[1]); - } - handle_refresh(res.REFRESH_DATA, refresh, alert); - }); + callback(that, res); } - }); - }); + handle_refresh(res.REFRESH_DATA, refresh, alert); + } + else + { + /** + * confirm_box - confirm with the user and send back + */ + phpbb.confirm(res.MESSAGE_TEXT, function(del) { + if (del) + { + data = $('
' + res.S_HIDDEN_FIELDS + '
').serialize(); + path = res.S_CONFIRM_ACTION; + $.post(path, data + '&confirm=' + res.YES_VALUE, function(res) { + res = JSON.parse(res); + var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); + if (typeof callback !== 'undefined') + { + callback(that, (is_form) ? act : null); + } + handle_refresh(res.REFRESH_DATA, refresh, alert); + }); + } + }); + } + } + + if (is_form) + { + act = /action\[([a-z]+)\]/.exec(this.name); + data = decodeURI($(this).closest('form').serialize()); + path = $(this).closest('form').attr('action').replace('&', '&'); + + if (act) + { + act = act[1] + data += '&action=' + act; + } + + $.post(path, data, return_handler); + } + else + { + $.get(this.href, return_handler); + } + return false; }); } @@ -216,20 +181,21 @@ phpbb.ajaxify_form = function(selector, refresh, callback) var refresh = function(url) { return (url.indexOf('t=') === -1); } -phpbb.confirm_box('.delete-icon a', refresh, function(el) { +phpbb.ajaxify('.delete-icon a', refresh, function(el) { var pid = el.href.split('&p=')[1]; $(el).parents('div #p' + pid).remove(); }); -phpbb.confirm_box('a[href$="ucp.php?mode=delete_cookies"]', true); +phpbb.ajaxify('a[href$="ucp.php?mode=delete_cookies"]', true); //AJAXify some links phpbb.ajaxify('a[href*="&bookmark=1"]', false, function(el, res) { + console.log(res); var text = (res.MESSAGE_TEXT.indexOf('Removed') === -1); text = (text) ? 'Remove from bookmarks' : 'Bookmark topic'; $(el).text(el.title = text); }); -phpbb.ajaxify('a[href*="&watch=topic"]', false, function(el, res) { +phpbb.ajaxify('a[href*="watch=topic"]', false, function(el, res) { var text = (res.MESSAGE_TEXT.indexOf('no longer subscribed') === -1); text = (text) ? 'Unsubscribe topic' : 'Subscribe topic'; $(el).text(el.title = text); @@ -242,6 +208,6 @@ phpbb.ajaxify('a[href*="watch=forum"]', false, function(el, res) { phpbb.ajaxify('a[href*="mode=bump"]'); phpbb.ajaxify('a[href*="mark="]'); //captures topics and forums -phpbb.ajaxify_form('.mcp_approve', false, function(el, act) { +phpbb.ajaxify('.mcp_approve', false, function(el, act) { $(el).parents((act === 'approve') ? '.rules' : '.post').remove(); }); From ac1b32c30772cd722c77694af83cb14b4581675f Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sun, 17 Jul 2011 15:36:54 +0100 Subject: [PATCH 156/335] [ticket/10270] Changed function names of jQuery modifications. The code was modifying the jQuery code before, now the functions have been renamed to unused function names. PHPBB3-10270 --- phpBB/styles/script.js | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index e893b84bf8..959a41a643 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -1,22 +1,21 @@ /** * Make some changes to the jQuery core. */ -$.fn.hide = function() { +$.fn.hide_anim = function() { this.animate({opacity: 0}, 300, function() { $(this).css('display', 'none') .css('opacity', 1); }); } -$.fn.show = function() { +$.fn.show_anim = function() { this.css('opacity', 0) .css('display', 'block') .animate({opacity: 1}, 300); } -$.fn.remove_old = $.fn.remove; -$.fn.remove = function() { +$.fn.remove_anim = function() { this.animate({opacity: 0}, 300, function() { - $(this).remove_old(); + $(this).remove(); }); } @@ -39,12 +38,12 @@ phpbb.alert = function(title, msg) { { return true; } - div.remove(); + div.remove_anim(); return false; }); $('body').append(div); - div.show(); + div.show_anim(); return div; } @@ -64,11 +63,11 @@ phpbb.confirm = function(msg, callback) { $('body').append(div); $('.jalertbut').bind('click', function(event) { - div.remove(); + div.remove_anim(); callback(this.value === 'Yes'); return false; }); - div.show(); + div.show_anim(); return div; } @@ -105,7 +104,7 @@ phpbb.ajaxify = function(selector, refresh, callback) { } else { - div.remove(); + div.remove_anim(); } }, data.time * 1000); } @@ -183,14 +182,13 @@ var refresh = function(url) { } phpbb.ajaxify('.delete-icon a', refresh, function(el) { var pid = el.href.split('&p=')[1]; - $(el).parents('div #p' + pid).remove(); + $(el).parents('div #p' + pid).remove_anim(); }); phpbb.ajaxify('a[href$="ucp.php?mode=delete_cookies"]', true); //AJAXify some links phpbb.ajaxify('a[href*="&bookmark=1"]', false, function(el, res) { - console.log(res); var text = (res.MESSAGE_TEXT.indexOf('Removed') === -1); text = (text) ? 'Remove from bookmarks' : 'Bookmark topic'; $(el).text(el.title = text); @@ -209,5 +207,5 @@ phpbb.ajaxify('a[href*="mode=bump"]'); phpbb.ajaxify('a[href*="mark="]'); //captures topics and forums phpbb.ajaxify('.mcp_approve', false, function(el, act) { - $(el).parents((act === 'approve') ? '.rules' : '.post').remove(); + $(el).parents((act === 'approve') ? '.rules' : '.post').remove_anim(); }); From 2f2ec1096b6288c032e276c75c849bb1cc820674 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sun, 17 Jul 2011 15:56:27 +0100 Subject: [PATCH 157/335] [ticket/10272] Made some jQuery selectors more specific to avoid conflicts. Before, a link to any URL with, say, "mode=bump" in the title would have been prevented from acting normally. PHPBB3-10272 --- phpBB/styles/script.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 959a41a643..32b12bdd34 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -184,27 +184,27 @@ phpbb.ajaxify('.delete-icon a', refresh, function(el) { var pid = el.href.split('&p=')[1]; $(el).parents('div #p' + pid).remove_anim(); }); -phpbb.ajaxify('a[href$="ucp.php?mode=delete_cookies"]', true); +phpbb.ajaxify('#page-footer a[href$="ucp.php?mode=delete_cookies"]', true); //AJAXify some links -phpbb.ajaxify('a[href*="&bookmark=1"]', false, function(el, res) { +phpbb.ajaxify('#page-footer a[href*="&bookmark=1"]', false, function(el, res) { var text = (res.MESSAGE_TEXT.indexOf('Removed') === -1); text = (text) ? 'Remove from bookmarks' : 'Bookmark topic'; $(el).text(el.title = text); }); -phpbb.ajaxify('a[href*="watch=topic"]', false, function(el, res) { +phpbb.ajaxify('#page-footer a[href*="watch=topic"]', false, function(el, res) { var text = (res.MESSAGE_TEXT.indexOf('no longer subscribed') === -1); text = (text) ? 'Unsubscribe topic' : 'Subscribe topic'; $(el).text(el.title = text); }); -phpbb.ajaxify('a[href*="watch=forum"]', false, function(el, res) { +phpbb.ajaxify('#page-footer a[href*="watch=forum"]', false, function(el, res) { var text = (res.MESSAGE_TEXT.indexOf('no longer subscribed') === -1); text = (text) ? 'Unsubscribe forum' : 'Subscribe forum'; $(el).text(el.title = text); }); -phpbb.ajaxify('a[href*="mode=bump"]'); -phpbb.ajaxify('a[href*="mark="]'); //captures topics and forums +phpbb.ajaxify('#page-footer a[href*="mode=bump"]'); +phpbb.ajaxify('.rightside a[href*="mark="]'); //captures topics and forums phpbb.ajaxify('.mcp_approve', false, function(el, act) { $(el).parents((act === 'approve') ? '.rules' : '.post').remove_anim(); From 8fd86717e1320cb3160515fe786869c80e6771f9 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 20 Jul 2011 18:28:14 +0100 Subject: [PATCH 158/335] [ticket/10271] Added ability for exceptions to phpbb.ajaxify. Also made it easy for additional options to be added in the future. PHPBB3-10271 --- .../prosilver/template/viewtopic_body.html | 2 +- phpBB/styles/script.js | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index 856ee6962c..9e333cf5ec 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -263,7 +263,7 @@ -
+
  -   +  
diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index b73c392312..889db70f98 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -103,6 +103,11 @@ phpbb.ajaxify = function(options, refresh, callback) { $(selector).click(function() { var act, data, path, that = this; + if ($(this).data('ajax') == false) + { + return true; + } + function return_handler(res) { res = JSON.parse(res); @@ -157,7 +162,11 @@ phpbb.ajaxify = function(options, refresh, callback) { act = act[1] data += '&action=' + act; } - + else + { + data += '&' + this.name + '=' + this.value; + } + if (run_exception && options.exception($(this).parents('form'), act, data)) { return true; @@ -213,6 +222,10 @@ phpbb.add_ajax_callback('post_delete', function(el) { $(el).parents((act === 'approve') ? '.rules' : '.post').fadeOut(function() { $(this).remove(); }); +}).add_ajax_callback('qr-submit', function(el) { + $(el).parents('form').fadeOut(function() { + $(this).remove(); + }); }); From 7ccc18297af17dbc66fc5a28710af6970a17fb6e Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Mon, 25 Jul 2011 20:42:29 +0100 Subject: [PATCH 163/335] [ticket/10270] Makes page fade to dark on popup, and added $.querystring. PHPBB3-10270 --- phpBB/styles/prosilver/theme/common.css | 16 ++- phpBB/styles/script.js | 139 ++++++++++++++++++++---- 2 files changed, 133 insertions(+), 22 deletions(-) diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index 6b34bb1c3d..a3d2c5660e 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -593,8 +593,8 @@ li.pagination { .jalert { background-color: #FFFFFF; border: 1px solid #999999; - display: none; position: fixed; + display: none; top: 100px; left: 35%; width: 30%; @@ -608,6 +608,20 @@ li.pagination { padding-bottom: 8px; } +#darkenwrapper { + display: none; +} + +#darken { + position: fixed; + left: 0; + top: 0; + width: 100%; + height: 100%; + background-color: #000000; + opacity: 0.5; +} + /* Miscellaneous styles ---------------------------------------- */ #forum-permissions { diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 889db70f98..0b2d372db7 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -1,5 +1,47 @@ +$.querystring = function(string) { + var end = {}, i; + + string = string.split('&'); + for (i = 0; i < string.length; i++) + { + end[string[i].split('=')[0]] = decodeURIComponent(string[i].split('=')[1]); + } + return end; +} + + var phpbb = {}; +var dark = $('
 
'); +$('body').append(dark); + +var loading_alert = $('

Loading

Please wait.

'); +$(dark).append(loading_alert); + + +/** + * Display a loading screen. + */ +phpbb.loading_alert = function() { + if (dark.is(':visible')) + { + loading_alert.fadeIn(); + } + else + { + loading_alert.show(); + dark.fadeIn(); + } + + setTimeout(function() { + if (loading_alert.is(':visible')) + { + phpbb.alert('Error', 'Error processing your request. Please try again.'); + } + }, 3000); + return loading_alert; +} + /** * Display a simple alert similar to JSs native alert(). * @@ -8,22 +50,48 @@ var phpbb = {}; * * @return Returns the div created. */ -phpbb.alert = function(title, msg) { +phpbb.alert = function(title, msg, fadedark) { var div = $('

' + title + '

' + msg + '

'); - $(document).one('click', function(e) { - if ($(e.target).parents('.jalert').length) + $(div).bind('click', function(e) { + e.stopPropagation(); + return true; + }); + $(dark).one('click', function(e) { + if (typeof fadedark === 'undefined' || fadedark) { - return true; + dark.fadeOut(function() { + div.remove(); + }); + } + else + { + div.fadeOut(function() { + div.remove(); + }); } - div.fadeOut(function() { - div.remove(); - }); return false; }); - $('body').append(div); - div.fadeIn(); + if (loading_alert.is(':visible')) + { + loading_alert.fadeOut(function() { + $(dark).append(div); + div.fadeIn(); + }); + } + else if (dark.is(':visible')) + { + $(dark).append(div); + div.fadeIn(); + } + else + { + $(dark).append(div); + div.show(); + dark.fadeIn(); + } + return div; } @@ -35,21 +103,47 @@ phpbb.alert = function(title, msg) { * * @return Returns the div created. */ -phpbb.confirm = function(msg, callback) { +phpbb.confirm = function(msg, callback, fadedark) { var div = $('

' + msg + '

\  \
'); - - $('body').append(div); - - $('.jalertbut').bind('click', function(event) { - div.fadeOut(function() { - div.remove(); - }); + + div.find('.jalertbut').bind('click', function() { + if (typeof fadedark === 'undefined' || fadedark) + { + dark.fadeOut(function() { + div.remove(); + }); + } + else + { + div.fadeOut(function() { + div.remove(); + }); + } callback(this.value === 'Yes'); return false; }); - div.fadeIn(); + + if (loading_alert.is(':visible')) + { + loading_alert.fadeOut(function() { + $(dark).append(div); + div.fadeIn(); + }); + } + else if (dark.is(':visible')) + { + $(dark).append(div); + div.fadeIn(); + } + else + { + $(dark).append(div); + div.show(); + dark.fadeIn(); + } + return div; } @@ -82,7 +176,7 @@ phpbb.ajaxify = function(options, refresh, callback) { } else { - div.fadeOut(function() { + dark.fadeOut(function() { div.remove(); }); } @@ -135,6 +229,7 @@ phpbb.ajaxify = function(options, refresh, callback) { { data = $('' + res.S_HIDDEN_FIELDS + '').serialize(); path = res.S_CONFIRM_ACTION; + phpbb.loading_alert(); $.post(path, data + '&confirm=' + res.YES_VALUE, function(res) { res = JSON.parse(res); var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); @@ -146,7 +241,7 @@ phpbb.ajaxify = function(options, refresh, callback) { handle_refresh(res.REFRESH_DATA, refresh, alert); }); } - }); + }, false); } } @@ -171,6 +266,7 @@ phpbb.ajaxify = function(options, refresh, callback) { { return true; } + phpbb.loading_alert(); $.post(path, data, return_handler); } else @@ -179,6 +275,7 @@ phpbb.ajaxify = function(options, refresh, callback) { { return true; } + phpbb.loading_alert(); $.get(this.href, return_handler); } @@ -240,7 +337,7 @@ $('[data-ajax]').each(function() { phpbb.ajaxify({ selector: '#quickmodform', exception: function(el, act, data) { - var d = data.split('=')[1]; + var d = $.querystring(data).action; if (d == 'make_normal') { return !(el.find('select option[value="make_global"]').length); From 149daa0e4fbe5bf59a613caf850ecda083cc772a Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Tue, 26 Jul 2011 11:46:49 +0100 Subject: [PATCH 164/335] [feature/ajax] Added code to avoid conflicts with other libraries using $ PHPBB3-10270 --- phpBB/styles/script.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 0b2d372db7..66e99a6a63 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -1,3 +1,6 @@ +;(function($) { //avoid conflicts with other libraries + + $.querystring = function(string) { var end = {}, i; @@ -345,3 +348,6 @@ phpbb.ajaxify({ return !(d == 'lock' || d == 'unlock' || d == 'delete_topic' || d.slice(0, 5) == 'make_'); } }, true); + + +})(jQuery); //avoid conflicts with other libraries From e4ea4d1c579477389349a06190643391ea8740fc Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Tue, 26 Jul 2011 12:13:09 +0100 Subject: [PATCH 165/335] [ticket/10270] Fixed a bug where fadedark wouldn't go. If the confirm box was submitted as yes, then the fadedark would stay until it was clicked. This commit fixes that. PHPBB3-10270 --- phpBB/styles/script.js | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 66e99a6a63..8c7324e39a 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -50,6 +50,8 @@ phpbb.loading_alert = function() { * * @param string title Title of the message, eg "Information" * @param string msg Message to display. Can be HTML. + * @param bool fadedark Remove the dark background when done? Defaults + * to yes. * * @return Returns the div created. */ @@ -61,18 +63,10 @@ phpbb.alert = function(title, msg, fadedark) { return true; }); $(dark).one('click', function(e) { - if (typeof fadedark === 'undefined' || fadedark) - { - dark.fadeOut(function() { - div.remove(); - }); - } - else - { - div.fadeOut(function() { - div.remove(); - }); - } + var fade = (typeof fadedark !== 'undefined' && !fadedark) ? div : dark; + fade.fadeOut(function() { + div.remove(); + }); return false; }); @@ -102,7 +96,10 @@ phpbb.alert = function(title, msg, fadedark) { * Display a simple yes / no box to the user. * * @param string msg Message to display. Can be HTML. - * @param function callback Callback. + * @param function callback Callback. Bool param, whether the user pressed + * yes or no (or whatever their language is). + * @param bool fadedark Remove the dark background when done? Defaults + * to yes. * * @return Returns the div created. */ @@ -112,19 +109,12 @@ phpbb.confirm = function(msg, callback, fadedark) { '); div.find('.jalertbut').bind('click', function() { - if (typeof fadedark === 'undefined' || fadedark) - { - dark.fadeOut(function() { - div.remove(); - }); - } - else - { - div.fadeOut(function() { - div.remove(); - }); - } - callback(this.value === 'Yes'); + var res = this.value === 'Yes'; + var fade = (typeof fadedark !== 'undefined' && !fadedark && res) ? div : dark; + fade.fadeOut(function() { + div.remove(); + }); + callback(res); return false; }); From 22c6953c116e24cbe278f0fe63aabaf950c843e3 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Tue, 26 Jul 2011 16:25:04 +0100 Subject: [PATCH 166/335] [feature/ajax] Fixed a small bug in the JavaScript. The bug meant that code outside of the function that ran on document ready would not be able to access the phpbb object. PHPBB3-10270 --- phpBB/styles/script.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 8c7324e39a..72e3c59e75 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -1,4 +1,6 @@ -;(function($) { //avoid conflicts with other libraries +var phpbb = {}; + +(function($) { //avoid conflicts with other libraries $.querystring = function(string) { @@ -13,8 +15,6 @@ $.querystring = function(string) { } -var phpbb = {}; - var dark = $('
 
'); $('body').append(dark); From bb7a03f738c97dc225873691c459f2bf9e612ef6 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 27 Jul 2011 12:57:58 +0100 Subject: [PATCH 167/335] [ticket/10281] AJAXified reordering forums in the ACP. PHPBB3-10281 --- phpBB/adm/style/acp_forums.html | 18 ++++++++--------- phpBB/adm/style/overall_footer.html | 4 ++++ phpBB/includes/acp/acp_forums.php | 6 ++++++ phpBB/styles/script.js | 30 +++++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 9 deletions(-) diff --git a/phpBB/adm/style/acp_forums.html b/phpBB/adm/style/acp_forums.html index 447c0ce466..b2b3ad6d40 100644 --- a/phpBB/adm/style/acp_forums.html +++ b/phpBB/adm/style/acp_forums.html @@ -443,7 +443,7 @@ - + {forums.FOLDER_IMAGE}
{forums.FORUM_IMAGE}
@@ -453,17 +453,17 @@ - {ICON_MOVE_UP_DISABLED} - {ICON_MOVE_DOWN} + {ICON_MOVE_UP_DISABLED} + {ICON_MOVE_DOWN} - {ICON_MOVE_UP} - {ICON_MOVE_DOWN} + {ICON_MOVE_UP} + {ICON_MOVE_DOWN} - {ICON_MOVE_UP} - {ICON_MOVE_DOWN_DISABLED} + {ICON_MOVE_UP} + {ICON_MOVE_DOWN_DISABLED} - {ICON_MOVE_UP_DISABLED} - {ICON_MOVE_DOWN_DISABLED} + {ICON_MOVE_UP_DISABLED} + {ICON_MOVE_DOWN_DISABLED} {ICON_EDIT} diff --git a/phpBB/adm/style/overall_footer.html b/phpBB/adm/style/overall_footer.html index f05e9c56c5..3740122d9b 100644 --- a/phpBB/adm/style/overall_footer.html +++ b/phpBB/adm/style/overall_footer.html @@ -17,6 +17,10 @@
{DEBUG_OUTPUT} + + + + diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index fad22fc285..d3e2dbd904 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -255,6 +255,12 @@ class acp_forums add_log('admin', 'LOG_FORUM_' . strtoupper($action), $row['forum_name'], $move_forum_name); $cache->destroy('sql', FORUMS_TABLE); } + + if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') + { + echo json_encode(array('success' => ($move_forum_name !== false))); + exit; + } break; diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 72e3c59e75..35c99464bd 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -316,6 +316,36 @@ phpbb.add_ajax_callback('post_delete', function(el) { $(el).parents('form').fadeOut(function() { $(this).remove(); }); +}).add_ajax_callback('forum_down', function(el) { + var tr = $(el).parents('tr'); + if (tr.is(':first-child')) + { + $(el).parents('span').siblings('.up').html('Move up'); + tr.next().find('.up').html('Move up'); + phpbb.ajaxify({selector: $(el).parents('span').siblings('.up').children('a')}, false, 'forum_up'); + } + tr.insertAfter(tr.next()); + if (tr.is(':last-child')) + { + $(el).html('Move down'); + tr.prev().find('.down').html('Move down'); + phpbb.ajaxify({selector: tr.prev().find('.down').children('a')}, false, 'forum_down'); + } +}).add_ajax_callback('forum_up', function(el) { + var tr = $(el).parents('tr'); + if (tr.is(':last-child')) + { + $(el).parents('span').siblings('.down').html('Move down'); + tr.prev().find('.down').html('Move down'); + phpbb.ajaxify({selector: $(el).parents('span').siblings('.down').children('a')}, false, 'forum_down'); + } + tr.insertBefore(tr.prev()); + if (tr.is(':first-child')) + { + $(el).html('Move up'); + tr.next().find('.up').html('Move up'); + phpbb.ajaxify({selector: tr.next().find('.up').children('a')}, false, 'forum_up'); + } }); From 59031fdc735a80502ea2cda3683a9276da5649cd Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Thu, 18 Aug 2011 18:34:09 +0100 Subject: [PATCH 168/335] [ticket/10272] AJAXified the add / remove friend / foe links. PHPBB3-10272 --- phpBB/styles/prosilver/template/memberlist_view.html | 8 ++++---- phpBB/styles/script.js | 7 ++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/phpBB/styles/prosilver/template/memberlist_view.html b/phpBB/styles/prosilver/template/memberlist_view.html index f10ec64975..d8bb92a731 100644 --- a/phpBB/styles/prosilver/template/memberlist_view.html +++ b/phpBB/styles/prosilver/template/memberlist_view.html @@ -35,15 +35,15 @@
{custom_fields.PROFILE_FIELD_NAME}:
{custom_fields.PROFILE_FIELD_VALUE}
-
 
{L_REMOVE_FRIEND}
+
 
{L_REMOVE_FRIEND}
-
 
{L_REMOVE_FOE}
+
 
{L_REMOVE_FOE}
-
 
{L_ADD_FRIEND}
+
 
{L_ADD_FRIEND}
-
 
{L_ADD_FOE}
+
 
{L_ADD_FOE}
diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 35c99464bd..d17a2cdc10 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -346,7 +346,12 @@ phpbb.add_ajax_callback('post_delete', function(el) { tr.next().find('.up').html('Move up'); phpbb.ajaxify({selector: tr.next().find('.up').children('a')}, false, 'forum_up'); } -}); +}).add_ajax_callback('zebra', function(el, res) { + if (res.MESSAGE_TEXT.indexOf('successfully') !== -1) { + $('.zebra').html(res.MESSAGE_TEXT.split(' Date: Thu, 18 Aug 2011 19:02:18 +0100 Subject: [PATCH 169/335] [ticket/10270] Added keyboard shortcuts to confirm and alert boxes. PHPBB3-10270 --- phpBB/styles/script.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index d17a2cdc10..54248cc31c 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -69,6 +69,14 @@ phpbb.alert = function(title, msg, fadedark) { }); return false; }); + + $(document).bind('keydown', function(e) { + if (e.keyCode === 13 || e.keyCode === 27) { + $(dark).trigger('click'); + return false; + } + return true; + }); if (loading_alert.is(':visible')) { @@ -118,6 +126,17 @@ phpbb.confirm = function(msg, callback, fadedark) { return false; }); + $(document).bind('keydown', function(e) { + if (e.keyCode === 13) { + $('.jalertbut.button1').trigger('click'); + return false; + } else if (e.keyCode === 27) { + $('.jalertbut.button2').trigger('click'); + return false; + } + return true; + }); + if (loading_alert.is(':visible')) { loading_alert.fadeOut(function() { From 94172b54dd09b28e19b4b12933b3f96e498d264a Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Fri, 19 Aug 2011 09:38:57 +0100 Subject: [PATCH 170/335] [ticket/10271] Changed AJAX functions to $request->is_ajax(). PHPBB3-10271 --- phpBB/includes/acp/acp_forums.php | 4 ++-- phpBB/includes/functions.php | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index d3e2dbd904..cb410e361a 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -25,7 +25,7 @@ class acp_forums function main($id, $mode) { - global $db, $user, $auth, $template, $cache; + global $db, $user, $auth, $template, $cache, $request; global $config, $phpbb_admin_path, $phpbb_root_path, $phpEx; $user->add_lang('acp/forums'); @@ -256,7 +256,7 @@ class acp_forums $cache->destroy('sql', FORUMS_TABLE); } - if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') + if ($request->is_ajax()) { echo json_encode(array('success' => ($move_forum_name !== false))); exit; diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 572986bb4b..b126fcc709 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2448,9 +2448,9 @@ function build_url($strip_vars = false) */ function meta_refresh($time, $url, $disable_cd_check = false) { - global $template, $refresh_data; + global $template, $refresh_data, $request; - if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') + if ($request->is_ajax()) { $refresh_data = array( 'time' => $time, @@ -2629,7 +2629,7 @@ function check_form_key($form_name, $timespan = false, $return_page = '', $trigg */ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_body.html', $u_action = '') { - global $user, $template, $db; + global $user, $template, $db, $request; global $phpEx, $phpbb_root_path, $request; if (isset($_POST['cancel'])) @@ -2710,7 +2710,7 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo $db->sql_query($sql); - if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') + if ($request->is_ajax()) { $u_action .= '&confirm_uid=' . $user->data['user_id'] . '&sess=' . $user->session_id . '&sid=' . $user->session_id; echo json_encode(array( @@ -3748,7 +3748,7 @@ function phpbb_checkdnsrr($host, $type = 'MX') */ function msg_handler($errno, $msg_text, $errfile, $errline) { - global $cache, $db, $auth, $template, $config, $user; + global $cache, $db, $auth, $template, $config, $user, $request; global $phpEx, $phpbb_root_path, $msg_title, $msg_long_text; // Do not display notices if we suppress them via @ @@ -3947,7 +3947,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) 'S_USER_NOTICE' => ($errno == E_USER_NOTICE) ? true : false) ); - if ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') + if ($request->is_ajax()) { global $refresh_data; From dce38f44de04bd7a1f91f8e57f6d266bd5e1af86 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Fri, 19 Aug 2011 10:45:03 +0100 Subject: [PATCH 171/335] [ticket/10328] Added a JSON class. The JSON class adds a consistent way to send JSON to the client, making it perfect for AJAX (jQuery automatically parses it). PHPBB3-10328 --- phpBB/common.php | 1 + phpBB/includes/acp/acp_forums.php | 3 +- phpBB/includes/functions.php | 6 ++-- phpBB/includes/json.php | 59 +++++++++++++++++++++++++++++++ phpBB/styles/script.js | 3 -- 5 files changed, 63 insertions(+), 9 deletions(-) create mode 100644 phpBB/includes/json.php diff --git a/phpBB/common.php b/phpBB/common.php index 129f7e4881..2c90ccf76c 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -74,6 +74,7 @@ if (!empty($load_extensions) && function_exists('dl')) // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); +require($phpbb_root_path . 'includes/json.' . $phpEx); require($phpbb_root_path . 'includes/session.' . $phpEx); require($phpbb_root_path . 'includes/auth.' . $phpEx); diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index cb410e361a..6c05b1e108 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -258,8 +258,7 @@ class acp_forums if ($request->is_ajax()) { - echo json_encode(array('success' => ($move_forum_name !== false))); - exit; + JSON::send(array('success' => ($move_forum_name !== false))); } break; diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index b126fcc709..b9ca30279f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2713,7 +2713,7 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo if ($request->is_ajax()) { $u_action .= '&confirm_uid=' . $user->data['user_id'] . '&sess=' . $user->session_id . '&sid=' . $user->session_id; - echo json_encode(array( + JSON::send(array( 'MESSAGE_TITLE' => (!isset($user->lang[$title])) ? $user->lang['CONFIRM'] : $user->lang[$title], 'MESSAGE_TEXT' => (!isset($user->lang[$title . '_CONFIRM'])) ? $title : $user->lang[$title . '_CONFIRM'], @@ -2721,7 +2721,6 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo 'S_CONFIRM_ACTION' => str_replace('&', '&', $u_action), //inefficient, rewrite whole function 'S_HIDDEN_FIELDS' => $hidden . $s_hidden_fields )); - exit; } if (defined('IN_ADMIN') && isset($user->data['session_admin']) && $user->data['session_admin']) @@ -3951,14 +3950,13 @@ function msg_handler($errno, $msg_text, $errfile, $errline) { global $refresh_data; - echo json_encode(array( + JSON::send(array( 'MESSAGE_TITLE' => $msg_title, 'MESSAGE_TEXT' => $msg_text, 'S_USER_WARNING' => ($errno == E_USER_WARNING) ? true : false, 'S_USER_NOTICE' => ($errno == E_USER_NOTICE) ? true : false, 'REFRESH_DATA' => (!empty($refresh_data)) ? $refresh_data : null )); - exit; } // We do not want the cron script to be called on error messages diff --git a/phpBB/includes/json.php b/phpBB/includes/json.php new file mode 100644 index 0000000000..04472080d9 --- /dev/null +++ b/phpBB/includes/json.php @@ -0,0 +1,59 @@ + Date: Fri, 19 Aug 2011 17:39:35 +0100 Subject: [PATCH 172/335] [ticket/10270] Lengthened the timeout on the AJAX request error. It was at 3 seconds before, now it is at 5 seconds from when the popup has faded in. PHPBB3-10270 --- phpBB/styles/script.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 3ed12bfee8..04e768e21e 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -33,15 +33,16 @@ phpbb.loading_alert = function() { else { loading_alert.show(); - dark.fadeIn(); + dark.fadeIn(function() { + setTimeout(function() { + if (loading_alert.is(':visible')) + { + phpbb.alert('Error', 'Error processing your request. Please try again.'); + } + }, 5000); + }); } - - setTimeout(function() { - if (loading_alert.is(':visible')) - { - phpbb.alert('Error', 'Error processing your request. Please try again.'); - } - }, 3000); + return loading_alert; } From 082c5c5b328e10e3fa99beaff31c4bc28f73bbd0 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Fri, 19 Aug 2011 18:11:58 +0100 Subject: [PATCH 173/335] [ticket/10272] Zebra operations using AJAX are now less hacky. Before, they were splitting stuff by the
, and now JSON::add() is being used. PHPBB3-10272 --- phpBB/includes/ucp/ucp_zebra.php | 4 ++++ phpBB/styles/script.js | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/ucp/ucp_zebra.php b/phpBB/includes/ucp/ucp_zebra.php index 004f3b80aa..3f0e97b48a 100644 --- a/phpBB/includes/ucp/ucp_zebra.php +++ b/phpBB/includes/ucp/ucp_zebra.php @@ -201,6 +201,10 @@ class ucp_zebra if ($updated) { + JSON::add(array( + 'message' => $user->lang[$l_mode . '_UPDATED'], + 'success' => true + )); meta_refresh(3, $this->u_action); $message = $user->lang[$l_mode . '_UPDATED'] . '
' . implode('
', $error) . ((sizeof($error)) ? '
' : '') . '
' . sprintf($user->lang['RETURN_UCP'], '', ''); trigger_error($message); diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 04e768e21e..f1fe2b9a10 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -364,8 +364,8 @@ phpbb.add_ajax_callback('post_delete', function(el) { phpbb.ajaxify({selector: tr.next().find('.up').children('a')}, false, 'forum_up'); } }).add_ajax_callback('zebra', function(el, res) { - if (res.MESSAGE_TEXT.indexOf('successfully') !== -1) { - $('.zebra').html(res.MESSAGE_TEXT.split(' Date: Wed, 24 Aug 2011 11:31:17 +0100 Subject: [PATCH 174/335] [ticket/10271] Moved $.querystring to phpbb.parse_querystring. PHPBB3-10271 --- phpBB/styles/script.js | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index f1fe2b9a10..ceaf92672c 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -3,18 +3,6 @@ var phpbb = {}; (function($) { //avoid conflicts with other libraries -$.querystring = function(string) { - var end = {}, i; - - string = string.split('&'); - for (i = 0; i < string.length; i++) - { - end[string[i].split('=')[0]] = decodeURIComponent(string[i].split('=')[1]); - } - return end; -} - - var dark = $('
 
'); $('body').append(dark); @@ -160,6 +148,23 @@ phpbb.confirm = function(msg, callback, fadedark) { return div; } +/** + * Turn a querystring into an array. + * + * @argument string string The querystring to parse. + * @returns array The array created. + */ +phpbb.parse_querystring = function(string) { + var end = {}, i; + + string = string.split('&'); + for (i = 0; i < string.length; i++) + { + end[string[i].split('=')[0]] = decodeURIComponent(string[i].split('=')[1]); + } + return end; +} + /** * Makes a link use AJAX instead of loading an entire page. @@ -382,7 +387,7 @@ $('[data-ajax]').each(function() { phpbb.ajaxify({ selector: '#quickmodform', exception: function(el, act, data) { - var d = $.querystring(data).action; + var d = phpbb.parse_querystring(data).action; if (d == 'make_normal') { return !(el.find('select option[value="make_global"]').length); From 6efb9dd0b6e0119009d5b10d198722ba2b19f0e2 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 24 Aug 2011 11:34:41 +0100 Subject: [PATCH 175/335] [ticket/10270] Added jQuery popup CSS to the ACP. It was missing previously, meaning that it displayed wrong and in the footer. PHPBB3-10270 --- phpBB/adm/style/admin.css | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/phpBB/adm/style/admin.css b/phpBB/adm/style/admin.css index ceda824e5a..70c06f2d62 100644 --- a/phpBB/adm/style/admin.css +++ b/phpBB/adm/style/admin.css @@ -1070,6 +1070,40 @@ input.disabled { color: #666666; } +/* jQuery popups +---------------------------------------- */ +.jalert { + background-color: #FFFFFF; + border: 1px solid #999999; + position: fixed; + display: none; + top: 100px; + left: 35%; + width: 30%; + z-index: 50; + padding: 25px; + padding: 0 25px 20px 25px; +} + +.jalert p { + margin: 8px 0; + padding-bottom: 8px; +} + +#darkenwrapper { + display: none; +} + +#darken { + position: fixed; + left: 0; + top: 0; + width: 100%; + height: 100%; + background-color: #000000; + opacity: 0.5; +} + /* Pagination ---------------------------------------- */ .pagination { From 420de9c9a0a638135da147a498436dbe7abfd4bd Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 24 Aug 2011 11:42:39 +0100 Subject: [PATCH 176/335] [ticket/10270] Moved some HTML from the JavaScript to overall_footer. PHPBB3-10270 --- phpBB/adm/style/overall_footer.html | 5 +++++ phpBB/language/en/common.php | 2 ++ phpBB/styles/prosilver/template/overall_footer.html | 5 +++++ phpBB/styles/script.js | 7 ++----- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/phpBB/adm/style/overall_footer.html b/phpBB/adm/style/overall_footer.html index 3740122d9b..625121f1bd 100644 --- a/phpBB/adm/style/overall_footer.html +++ b/phpBB/adm/style/overall_footer.html @@ -18,6 +18,11 @@ {DEBUG_OUTPUT} +
+
 
+

{L_LOADING}

{L_PLEASE_WAIT}

+
+ diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 19b801e585..e8fff96e5a 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -314,6 +314,7 @@ $lang = array_merge($lang, array( 'LDAP_NO_SERVER_CONNECTION' => 'Could not connect to LDAP server.', 'LDAP_SEARCH_FAILED' => 'An error occured while searching the LDAP directory.', 'LEGEND' => 'Legend', + 'LOADING' => 'Loading', 'LOCATION' => 'Location', 'LOCK_POST' => 'Lock post', 'LOCK_POST_EXPLAIN' => 'Prevent editing', @@ -451,6 +452,7 @@ $lang = array_merge($lang, array( 2 => '%d pixels', ), 'PLAY_QUICKTIME_FILE' => 'Play Quicktime file', + 'PLEASE_WAIT' => 'Please wait.', 'PM' => 'PM', 'PM_REPORTED' => 'Click to view report', 'POSTING_MESSAGE' => 'Posting message in %s', diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html index ffdb27be98..37caaf7cca 100644 --- a/phpBB/styles/prosilver/template/overall_footer.html +++ b/phpBB/styles/prosilver/template/overall_footer.html @@ -24,6 +24,11 @@
{DEBUG_OUTPUT}
{L_ACP} + +
+
 
+

{L_LOADING}

{L_PLEASE_WAIT}

+
diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index ceaf92672c..bf8c548df0 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -3,11 +3,8 @@ var phpbb = {}; (function($) { //avoid conflicts with other libraries -var dark = $('
 
'); -$('body').append(dark); - -var loading_alert = $('

Loading

Please wait.

'); -$(dark).append(loading_alert); +var dark = $('#darkenwrapper'), + loading_alert = $('#loadingalert'); /** From c92b30d66cbb2839369c04172eb5ae9bacd27a16 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 24 Aug 2011 11:44:28 +0100 Subject: [PATCH 177/335] [feature/ajax] Changed JavaScript comments to follow coding guidelines. Also replaced a couple instances of "@return" with "@returns". PHPBB3-10270 --- phpBB/styles/script.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index bf8c548df0..1b9262f585 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -1,6 +1,6 @@ var phpbb = {}; -(function($) { //avoid conflicts with other libraries +(function($) { // Avoid conflicts with other libraries var dark = $('#darkenwrapper'), @@ -9,6 +9,8 @@ var dark = $('#darkenwrapper'), /** * Display a loading screen. + * + * @returns object Returns loading_alert. */ phpbb.loading_alert = function() { if (dark.is(':visible')) @@ -39,7 +41,7 @@ phpbb.loading_alert = function() { * @param bool fadedark Remove the dark background when done? Defaults * to yes. * - * @return Returns the div created. + * @returns object Returns the div created. */ phpbb.alert = function(title, msg, fadedark) { var div = $('

' + title + '

' + msg + '

'); @@ -95,7 +97,7 @@ phpbb.alert = function(title, msg, fadedark) { * @param bool fadedark Remove the dark background when done? Defaults * to yes. * - * @return Returns the div created. + * @returns object Returns the div created. */ phpbb.confirm = function(msg, callback, fadedark) { var div = $('

' + msg + '

\ @@ -173,7 +175,7 @@ phpbb.parse_querystring = function(string) { */ phpbb.ajaxify = function(options, refresh, callback) { - //private function to handle refreshes + // Private function to handle refreshes function handle_refresh(data, refresh, div) { if (!data) @@ -221,9 +223,7 @@ phpbb.ajaxify = function(options, refresh, callback) { { if (typeof res.S_CONFIRM_ACTION === 'undefined') { - /** - * It is a standard link, no confirm_box required. - */ + // It is a standard link, no confirm_box required. var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); callback = phpbb.ajax_callbacks[callback]; if (typeof callback === 'function') @@ -234,9 +234,7 @@ phpbb.ajaxify = function(options, refresh, callback) { } else { - /** - * confirm_box - confirm with the user and send back - */ + // confirm_box - confirm with the user and send back phpbb.confirm(res.MESSAGE_TEXT, function(del) { if (del) { @@ -394,4 +392,4 @@ phpbb.ajaxify({ }, true); -})(jQuery); //avoid conflicts with other libraries +})(jQuery); // Avoid conflicts with other libraries From 7a933bdb5ad4a9bc4877a7d4d516fa0b21d9e4c0 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 24 Aug 2011 12:25:54 +0100 Subject: [PATCH 178/335] [ticket/10328] Renamed the JSON class, also now using autoloading. It is no longer static, and uses autoloading. It has also been renamed from JSON to phpbb_json_response. PHPBB3-10328 --- phpBB/common.php | 1 - phpBB/includes/acp/acp_forums.php | 3 ++- phpBB/includes/functions.php | 6 +++-- .../includes/{json.php => json_response.php} | 23 +++--------------- phpBB/includes/ucp/ucp_zebra.php | 24 ++++++++++++++----- phpBB/styles/script.js | 2 +- 6 files changed, 28 insertions(+), 31 deletions(-) rename phpBB/includes/{json.php => json_response.php} (58%) diff --git a/phpBB/common.php b/phpBB/common.php index 2c90ccf76c..129f7e4881 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -74,7 +74,6 @@ if (!empty($load_extensions) && function_exists('dl')) // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); -require($phpbb_root_path . 'includes/json.' . $phpEx); require($phpbb_root_path . 'includes/session.' . $phpEx); require($phpbb_root_path . 'includes/auth.' . $phpEx); diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 6c05b1e108..3a3b2021eb 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -258,7 +258,8 @@ class acp_forums if ($request->is_ajax()) { - JSON::send(array('success' => ($move_forum_name !== false))); + $json_response = new phpbb_json_response; + $json_response->send(array('success' => ($move_forum_name !== false))); } break; diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index b9ca30279f..afd901a296 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -2713,7 +2713,8 @@ function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_bo if ($request->is_ajax()) { $u_action .= '&confirm_uid=' . $user->data['user_id'] . '&sess=' . $user->session_id . '&sid=' . $user->session_id; - JSON::send(array( + $json_response = new phpbb_json_response; + $json_response->send(array( 'MESSAGE_TITLE' => (!isset($user->lang[$title])) ? $user->lang['CONFIRM'] : $user->lang[$title], 'MESSAGE_TEXT' => (!isset($user->lang[$title . '_CONFIRM'])) ? $title : $user->lang[$title . '_CONFIRM'], @@ -3950,7 +3951,8 @@ function msg_handler($errno, $msg_text, $errfile, $errline) { global $refresh_data; - JSON::send(array( + $json_response = new phpbb_json_response; + $json_response->send(array( 'MESSAGE_TITLE' => $msg_title, 'MESSAGE_TEXT' => $msg_text, 'S_USER_WARNING' => ($errno == E_USER_WARNING) ? true : false, diff --git a/phpBB/includes/json.php b/phpBB/includes/json_response.php similarity index 58% rename from phpBB/includes/json.php rename to phpBB/includes/json_response.php index 04472080d9..95d02e3c0e 100644 --- a/phpBB/includes/json.php +++ b/phpBB/includes/json_response.php @@ -20,25 +20,18 @@ if (!defined('IN_PHPBB')) * JSON class * @package phpBB3 */ -class JSON +class phpbb_json_response { - private static $data = array(); - /** * Send the data to the client and exit the script. * * @param array $data Any additional data to send. * @param bool $exit Will exit the script if true. */ - public static function send($data = false, $exit = true) + public function send($data, $exit = true) { - if ($data) - { - self::add($data); - } - header('Content-type: application/json'); - echo json_encode(self::$data); + echo json_encode($data); if ($exit) { @@ -46,14 +39,4 @@ class JSON exit_handler(); } } - - /** - * Saves some data to be written when JSON::send() is called. - * - * @param array $data Data to save to be sent. - */ - public static function add($data) - { - self::$data = array_merge(self::$data, $data); - } } diff --git a/phpBB/includes/ucp/ucp_zebra.php b/phpBB/includes/ucp/ucp_zebra.php index 3f0e97b48a..efe928b387 100644 --- a/phpBB/includes/ucp/ucp_zebra.php +++ b/phpBB/includes/ucp/ucp_zebra.php @@ -25,7 +25,7 @@ class ucp_zebra function main($id, $mode) { - global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx; + global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx, $request; $submit = (isset($_POST['submit']) || isset($_GET['add']) || isset($_GET['remove'])) ? true : false; $s_hidden_fields = ''; @@ -198,13 +198,25 @@ class ucp_zebra } } } - - if ($updated) + + if ($request->is_ajax()) { - JSON::add(array( - 'message' => $user->lang[$l_mode . '_UPDATED'], - 'success' => true + $message = ($updated) ? $user->lang[$l_mode . '_UPDATED'] : implode('
', $error); + + $json_response = new phpbb_json_response; + $json_response->send(array( + 'success' => $updated, + + 'MESSAGE_TITLE' => $user->lang['INFORMATION'], + 'MESSAGE_TEXT' => $message, + 'REFRESH_DATA' => array( + 'time' => 3, + 'url' => $this->u_action + ) )); + } + else if ($updated) + { meta_refresh(3, $this->u_action); $message = $user->lang[$l_mode . '_UPDATED'] . '
' . implode('
', $error) . ((sizeof($error)) ? '
' : '') . '
' . sprintf($user->lang['RETURN_UCP'], '', ''); trigger_error($message); diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 1b9262f585..8814d105e1 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -365,7 +365,7 @@ phpbb.add_ajax_callback('post_delete', function(el) { } }).add_ajax_callback('zebra', function(el, res) { if (res.success) { - $('.zebra').html(res.message); + $('.zebra').html(res.MESSAGE_TEXT); $($('.zebra').get(1)).remove(); } });; From 11112314f757f4a6c65852817fba0f1a2f4526d2 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 24 Aug 2011 12:46:33 +0100 Subject: [PATCH 179/335] [ticket/10271] AJAXified various deletions in the ACP. The following places have had deletion AJAXified: * Smilies and icons * Word censors * BBCodes * Attachment groups * Groups * Admin / User / Moderator / Forum roles * Report / denial reasons * Module management * Custom profile fields PHPBB3-10271 --- phpBB/adm/style/acp_attachments.html | 2 +- phpBB/adm/style/acp_bbcodes.html | 2 +- phpBB/adm/style/acp_groups.html | 2 +- phpBB/adm/style/acp_icons.html | 2 +- phpBB/adm/style/acp_modules.html | 2 +- phpBB/adm/style/acp_permission_roles.html | 2 +- phpBB/adm/style/acp_profile.html | 4 ++-- phpBB/adm/style/acp_ranks.html | 2 +- phpBB/adm/style/acp_reasons.html | 2 +- phpBB/adm/style/acp_words.html | 2 +- phpBB/includes/acp/acp_bbcodes.php | 14 +++++++++++++- phpBB/includes/acp/acp_icons.php | 12 ++++++++++++ phpBB/includes/acp/acp_ranks.php | 14 +++++++++++++- phpBB/language/en/acp/posting.php | 1 + phpBB/styles/script.js | 3 +++ 15 files changed, 53 insertions(+), 13 deletions(-) diff --git a/phpBB/adm/style/acp_attachments.html b/phpBB/adm/style/acp_attachments.html index 33ef8062a6..c2f8b34792 100644 --- a/phpBB/adm/style/acp_attachments.html +++ b/phpBB/adm/style/acp_attachments.html @@ -248,7 +248,7 @@
» {L_ALLOWED_IN_PM_POST} {groups.CATEGORY} -  {ICON_EDIT}  {ICON_DELETE}  +  {ICON_EDIT}  {ICON_DELETE}  diff --git a/phpBB/adm/style/acp_bbcodes.html b/phpBB/adm/style/acp_bbcodes.html index b85e8eca81..5939af24ae 100644 --- a/phpBB/adm/style/acp_bbcodes.html +++ b/phpBB/adm/style/acp_bbcodes.html @@ -101,7 +101,7 @@ {bbcodes.BBCODE_TAG} - {ICON_EDIT} {ICON_DELETE} + {ICON_EDIT} {ICON_DELETE} diff --git a/phpBB/adm/style/acp_groups.html b/phpBB/adm/style/acp_groups.html index 158751623a..ed94fa985e 100644 --- a/phpBB/adm/style/acp_groups.html +++ b/phpBB/adm/style/acp_groups.html @@ -350,7 +350,7 @@ {groups.TOTAL_MEMBERS} {L_SETTINGS} {L_MEMBERS} - {L_DELETE}{L_DELETE} + {L_DELETE}{L_DELETE} diff --git a/phpBB/adm/style/acp_icons.html b/phpBB/adm/style/acp_icons.html index 85b5343666..a8864d42f7 100644 --- a/phpBB/adm/style/acp_icons.html +++ b/phpBB/adm/style/acp_icons.html @@ -245,7 +245,7 @@ {ICON_MOVE_UP_DISABLED}{ICON_MOVE_UP}  {ICON_MOVE_DOWN_DISABLED}{ICON_MOVE_DOWN} -  {ICON_EDIT} {ICON_DELETE} +  {ICON_EDIT} {ICON_DELETE} diff --git a/phpBB/adm/style/acp_modules.html b/phpBB/adm/style/acp_modules.html index 3f1c0bf50b..6c4645e80c 100644 --- a/phpBB/adm/style/acp_modules.html +++ b/phpBB/adm/style/acp_modules.html @@ -164,7 +164,7 @@ {ICON_MOVE_DOWN_DISABLED} {ICON_EDIT} - {ICON_DELETE} + {ICON_DELETE} diff --git a/phpBB/adm/style/acp_permission_roles.html b/phpBB/adm/style/acp_permission_roles.html index 658d8dd0c8..2ac77af25d 100644 --- a/phpBB/adm/style/acp_permission_roles.html +++ b/phpBB/adm/style/acp_permission_roles.html @@ -174,7 +174,7 @@ {ICON_MOVE_DOWN_DISABLED} {ICON_EDIT} - {ICON_DELETE} + {ICON_DELETE} diff --git a/phpBB/adm/style/acp_profile.html b/phpBB/adm/style/acp_profile.html index 0ac0d78a64..7804533d1a 100644 --- a/phpBB/adm/style/acp_profile.html +++ b/phpBB/adm/style/acp_profile.html @@ -195,7 +195,7 @@ {fields.FIELD_IDENT} {fields.FIELD_TYPE} - {fields.L_ACTIVATE_DEACTIVATE} | {L_TRANSLATE} + {fields.L_ACTIVATE_DEACTIVATE} | {L_TRANSLATE} @@ -213,7 +213,7 @@ {ICON_EDIT_DISABLED} - {ICON_DELETE} + {ICON_DELETE} diff --git a/phpBB/adm/style/acp_ranks.html b/phpBB/adm/style/acp_ranks.html index 2f77a256b1..7fb7da7095 100644 --- a/phpBB/adm/style/acp_ranks.html +++ b/phpBB/adm/style/acp_ranks.html @@ -80,7 +80,7 @@ {ranks.RANK_TITLE}  -   {ranks.RANK_TITLE}   -  {ranks.MIN_POSTS} - {ICON_EDIT} {ICON_DELETE} + {ICON_EDIT} {ICON_DELETE} diff --git a/phpBB/adm/style/acp_reasons.html b/phpBB/adm/style/acp_reasons.html index 522aec5930..7cf2cce4c9 100644 --- a/phpBB/adm/style/acp_reasons.html +++ b/phpBB/adm/style/acp_reasons.html @@ -99,7 +99,7 @@ {ICON_EDIT} - {ICON_DELETE} + {ICON_DELETE} {ICON_DELETE_DISABLED} diff --git a/phpBB/adm/style/acp_words.html b/phpBB/adm/style/acp_words.html index 113f58ef92..4acd75f933 100644 --- a/phpBB/adm/style/acp_words.html +++ b/phpBB/adm/style/acp_words.html @@ -60,7 +60,7 @@ {words.WORD} {words.REPLACEMENT} -  {ICON_EDIT}  {ICON_DELETE}  +  {ICON_EDIT}  {ICON_DELETE}  diff --git a/phpBB/includes/acp/acp_bbcodes.php b/phpBB/includes/acp/acp_bbcodes.php index a3822a982a..e537d7a8b9 100644 --- a/phpBB/includes/acp/acp_bbcodes.php +++ b/phpBB/includes/acp/acp_bbcodes.php @@ -24,7 +24,7 @@ class acp_bbcodes function main($id, $mode) { - global $db, $user, $auth, $template, $cache; + global $db, $user, $auth, $template, $cache, $request; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; $user->add_lang('acp/posting'); @@ -272,6 +272,18 @@ class acp_bbcodes $db->sql_query('DELETE FROM ' . BBCODES_TABLE . " WHERE bbcode_id = $bbcode_id"); $cache->destroy('sql', BBCODES_TABLE); add_log('admin', 'LOG_BBCODE_DELETE', $row['bbcode_tag']); + + if ($request->is_ajax()) + { + $json_response = new phpbb_json_response; + $json_response->send(array( + 'MESSAGE_TITLE' => $user->lang['INFORMATION'], + 'MESSAGE_TEXT' => $user->lang['BBCODE_DELETED'], + 'REFRESH_DATA' => array( + 'time' => 3 + ) + )); + } } else { diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index 49a092f16b..bfe17c5007 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -782,6 +782,18 @@ class acp_icons $cache->destroy('_icons'); $cache->destroy('sql', $table); + + if ($request->is_ajax()) + { + $json_response = new phpbb_json_response; + $json_response->send(array( + 'MESSAGE_TITLE' => $user->lang['INFORMATION'], + 'MESSAGE_TEXT' => $notice, + 'REFRESH_DATA' => array( + 'time' => 3 + ) + )); + } } else { diff --git a/phpBB/includes/acp/acp_ranks.php b/phpBB/includes/acp/acp_ranks.php index ec5a76df87..d9ed5b17f1 100644 --- a/phpBB/includes/acp/acp_ranks.php +++ b/phpBB/includes/acp/acp_ranks.php @@ -24,7 +24,7 @@ class acp_ranks function main($id, $mode) { - global $db, $user, $auth, $template, $cache; + global $db, $user, $auth, $template, $cache, $request; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; $user->add_lang('acp/posting'); @@ -122,6 +122,18 @@ class acp_ranks $cache->destroy('_ranks'); add_log('admin', 'LOG_RANK_REMOVED', $rank_title); + + if ($request->is_ajax()) + { + $json_response = new phpbb_json_response; + $json_response->send(array( + 'MESSAGE_TITLE' => $user->lang['INFORMATION'], + 'MESSAGE_TEXT' => $user->lang['RANK_REMOVED'], + 'REFRESH_DATA' => array( + 'time' => 3 + ) + )); + } } else { diff --git a/phpBB/language/en/acp/posting.php b/phpBB/language/en/acp/posting.php index 84cf640d1f..76d4869990 100644 --- a/phpBB/language/en/acp/posting.php +++ b/phpBB/language/en/acp/posting.php @@ -45,6 +45,7 @@ $lang = array_merge($lang, array( 'BBCODE_ADDED' => 'BBCode added successfully.', 'BBCODE_EDITED' => 'BBCode edited successfully.', + 'BBCODE_DELETED' => 'The BBCode has been removed successfully.', 'BBCODE_NOT_EXIST' => 'The BBCode you selected does not exist.', 'BBCODE_HELPLINE' => 'Help line', 'BBCODE_HELPLINE_EXPLAIN' => 'This field contains the mouse over text of the BBCode.', diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 8814d105e1..85dcdb25f5 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -363,6 +363,9 @@ phpbb.add_ajax_callback('post_delete', function(el) { tr.next().find('.up').html('Move up'); phpbb.ajaxify({selector: tr.next().find('.up').children('a')}, false, 'forum_up'); } +}).add_ajax_callback('row_delete', function(el) { + var tr = $(el).parents('tr'); + tr.remove(); }).add_ajax_callback('zebra', function(el, res) { if (res.success) { $('.zebra').html(res.MESSAGE_TEXT); From 1cb3b595ec70730429a9c8654b248fc6d50cf1b3 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 24 Aug 2011 15:45:51 +0100 Subject: [PATCH 180/335] [ticket/10271] AJAXified the styles tab in the ACP. PHPBB3-10271 --- phpBB/adm/style/acp_styles.html | 2 +- phpBB/includes/acp/acp_styles.php | 17 +++++++++++++++-- phpBB/language/en/acp/styles.php | 2 ++ phpBB/styles/script.js | 22 ++++++++++++++++------ 4 files changed, 34 insertions(+), 9 deletions(-) diff --git a/phpBB/adm/style/acp_styles.html b/phpBB/adm/style/acp_styles.html index dc89aa247a..dfc8def646 100644 --- a/phpBB/adm/style/acp_styles.html +++ b/phpBB/adm/style/acp_styles.html @@ -288,7 +288,7 @@ - {installed.L_STYLE_ACT_DEACT} | + {installed.L_STYLE_ACT_DEACT} | {installed.S_ACTIONS} diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 7b449d3b35..a241dd3d10 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -28,7 +28,7 @@ class acp_styles function main($id, $mode) { - global $db, $user, $auth, $template, $cache; + global $db, $user, $auth, $template, $cache, $request; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; // Hardcoded template bitfield to add for new templates @@ -185,6 +185,18 @@ inherit_from = {INHERIT_FROM} WHERE forum_style = ' . $style_id; $db->sql_query($sql); } + if ($request->is_ajax()) + { + $json_response = new phpbb_json_response; + $json_response->send(array( + 'text' => $user->lang['STYLE_' . (($action == 'activate') ? 'DE' : '') . 'ACTIVATE'], + 'MESSAGE_TITLE' => $user->lang['INFORMATION'], + 'MESSAGE_TEXT' => $user->lang['STYLE_' . strtoupper($action) . 'D'], + 'REFRESH_DATA' => array( + 'time' => 3 + ) + )); + } } else if ($action == 'deactivate') { @@ -335,7 +347,8 @@ inherit_from = {INHERIT_FROM} $s_actions = array(); foreach ($actions as $option) { - $s_actions[] = '' . $user->lang[strtoupper($option)] . ''; + $data_ajax = ($option == 'refresh') ? ' data-ajax="true"' : ''; + $s_actions[] = '' . $user->lang[strtoupper($option)] . ''; } $template->assign_block_vars('installed', array( diff --git a/phpBB/language/en/acp/styles.php b/phpBB/language/en/acp/styles.php index 59df82477e..3a96100947 100644 --- a/phpBB/language/en/acp/styles.php +++ b/phpBB/language/en/acp/styles.php @@ -295,9 +295,11 @@ $lang = array_merge($lang, array( 'SELECTED_THEME_FILE' => 'Selected theme file', 'STORE_FILESYSTEM' => 'Filesystem', 'STYLE_ACTIVATE' => 'Activate', + 'STYLE_ACTIVATED' => 'Style activated successfully', 'STYLE_ACTIVE' => 'Active', 'STYLE_ADDED' => 'Style added successfully.', 'STYLE_DEACTIVATE' => 'Deactivate', + 'STYLE_DEACTIVATED' => 'Style deactivated successfully', 'STYLE_DEFAULT' => 'Make default style', 'STYLE_DELETED' => 'Style deleted successfully.', 'STYLE_DETAILS_UPDATED' => 'Style edited successfully.', diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 85dcdb25f5..44b21906cc 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -225,10 +225,9 @@ phpbb.ajaxify = function(options, refresh, callback) { { // It is a standard link, no confirm_box required. var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - callback = phpbb.ajax_callbacks[callback]; - if (typeof callback === 'function') + if (typeof phpbb.ajax_callbacks[callback] === 'function') { - callback(that, (is_form) ? act : null); + phpbb.ajax_callbacks[callback](that, res, (is_form) ? act : null); } handle_refresh(res.REFRESH_DATA, refresh, alert); } @@ -243,10 +242,9 @@ phpbb.ajaxify = function(options, refresh, callback) { phpbb.loading_alert(); $.post(path, data + '&confirm=' + res.YES_VALUE, function(res) { var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - callback = phpbb.ajax_callbacks[callback]; - if (typeof callback === 'function') + if (typeof phpbb.ajax_callbacks[callback] === 'function') { - callback(that, res, (is_form) ? act : null); + phpbb.ajax_callbacks[callback](that, res, (is_form) ? act : null); } handle_refresh(res.REFRESH_DATA, refresh, alert); }); @@ -363,6 +361,18 @@ phpbb.add_ajax_callback('post_delete', function(el) { tr.next().find('.up').html('Move up'); phpbb.ajaxify({selector: tr.next().find('.up').children('a')}, false, 'forum_up'); } +}).add_ajax_callback('style_act_deact', function(el, res) { + $(el).text(res.text); + var new_href = $(el).attr('href'); + if (new_href.indexOf('deactivate') !== -1) + { + new_href = new_href.replace('deactivate', 'activate') + } + else + { + new_href = new_href.replace('activate', 'deactivate') + } + $(el).attr('href', new_href); }).add_ajax_callback('row_delete', function(el) { var tr = $(el).parents('tr'); tr.remove(); From 4ae74cd4b450ae4cca956f6f3e2371429f67deec Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 24 Aug 2011 16:06:06 +0100 Subject: [PATCH 181/335] [ticket/10271] AJAXified buttons on acp_main. PHPBB3-10271 --- phpBB/adm/style/acp_main.html | 14 ++++++------ phpBB/includes/acp/acp_main.php | 38 ++++++++++++++++++++++++++++++-- phpBB/language/en/acp/common.php | 7 ++++++ 3 files changed, 50 insertions(+), 9 deletions(-) diff --git a/phpBB/adm/style/acp_main.html b/phpBB/adm/style/acp_main.html index 63ca3a1c79..d9f833d878 100644 --- a/phpBB/adm/style/acp_main.html +++ b/phpBB/adm/style/acp_main.html @@ -152,35 +152,35 @@
{L_STATISTIC_RESYNC_OPTIONS} -
+

 
-
+

 
-
+

{L_RESYNC_STATS_EXPLAIN}
-
+

{L_RESYNC_POSTCOUNTS_EXPLAIN}
-
+

{L_RESYNC_POST_MARKING_EXPLAIN}
@@ -188,7 +188,7 @@ -
+

{L_PURGE_SESSIONS_EXPLAIN}
@@ -196,7 +196,7 @@ -
+

{L_PURGE_CACHE_EXPLAIN}
diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index 4c9ee85982..144b225766 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -24,7 +24,7 @@ class acp_main function main($id, $mode) { - global $config, $db, $user, $auth, $template; + global $config, $db, $user, $auth, $template, $request; global $phpbb_root_path, $phpbb_admin_path, $phpEx; // Show restore permissions notice @@ -129,6 +129,11 @@ class acp_main set_config('record_online_users', 1, true); set_config('record_online_date', time(), true); add_log('admin', 'LOG_RESET_ONLINE'); + + if ($request->is_ajax()) + { + trigger_error('RESET_ONLINE_SUCCESS'); + } break; case 'stats': @@ -179,6 +184,11 @@ class acp_main update_last_username(); add_log('admin', 'LOG_RESYNC_STATS'); + + if ($request->is_ajax()) + { + trigger_error('RESYNC_STATS_SUCCESS'); + } break; case 'user': @@ -241,7 +251,11 @@ class acp_main } add_log('admin', 'LOG_RESYNC_POSTCOUNTS'); - + + if ($request->is_ajax()) + { + trigger_error('RESYNC_POSTCOUNTS_SUCCESS'); + } break; case 'date': @@ -252,6 +266,11 @@ class acp_main set_config('board_startdate', time() - 1); add_log('admin', 'LOG_RESET_DATE'); + + if ($request->is_ajax()) + { + trigger_error('RESET_DATE_SUCCESS'); + } break; case 'db_track': @@ -327,6 +346,11 @@ class acp_main } add_log('admin', 'LOG_RESYNC_POST_MARKING'); + + if ($request->is_ajax()) + { + trigger_error('RESYNC_POST_MARKING_SUCCESS'); + } break; case 'purge_cache': @@ -338,6 +362,11 @@ class acp_main cache_moderators(); add_log('admin', 'LOG_PURGE_CACHE'); + + if ($request->is_ajax()) + { + trigger_error('PURGE_CACHE_SUCCESS'); + } break; case 'purge_sessions': @@ -384,6 +413,11 @@ class acp_main $db->sql_query($sql); add_log('admin', 'LOG_PURGE_SESSIONS'); + + if ($request->is_ajax()) + { + trigger_error('PURGE_SESSIONS_SUCCESS'); + } break; } } diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index 242329a041..f96947b580 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -368,25 +368,32 @@ $lang = array_merge($lang, array( 'PURGE_CACHE' => 'Purge the cache', 'PURGE_CACHE_CONFIRM' => 'Are you sure you wish to purge the cache?', 'PURGE_CACHE_EXPLAIN' => 'Purge all cache related items, this includes any cached template files or queries.', + 'PURGE_CACHE_SUCCESS' => 'Cache successfully purged.', 'PURGE_SESSIONS' => 'Purge all sessions', 'PURGE_SESSIONS_CONFIRM' => 'Are you sure you wish to purge all sessions? This will log out all users.', 'PURGE_SESSIONS_EXPLAIN' => 'Purge all sessions. This will log out all users by truncating the session table.', + 'PURGE_SESSIONS_SUCCESS' => 'Sessions successfully purged.', 'RESET_DATE' => 'Reset board’s start date', 'RESET_DATE_CONFIRM' => 'Are you sure you wish to reset the board’s start date?', + 'RESET_DATE_SUCCESS' => 'Board’s start date reset', 'RESET_ONLINE' => 'Reset most users ever online', 'RESET_ONLINE_CONFIRM' => 'Are you sure you wish to reset the most users ever online counter?', + 'RESET_ONLINE_SUCCESS' => 'Most users ever online reset', 'RESYNC_FILES_STATS_CONFIRM' => 'Are you sure you wish to resynchronise files statistics?', 'RESYNC_POSTCOUNTS' => 'Resynchronise post counts', 'RESYNC_POSTCOUNTS_EXPLAIN' => 'Only existing posts will be taken into consideration. Pruned posts will not be counted.', 'RESYNC_POSTCOUNTS_CONFIRM' => 'Are you sure you wish to resynchronise post counts?', + 'RESYNC_POSTCOUNTS_SUCCESS' => 'Resynchronised post counts', 'RESYNC_POST_MARKING' => 'Resynchronise dotted topics', 'RESYNC_POST_MARKING_CONFIRM' => 'Are you sure you wish to resynchronise dotted topics?', 'RESYNC_POST_MARKING_EXPLAIN' => 'First unmarks all topics and then correctly marks topics that have seen any activity during the past six months.', + 'RESYNC_POST_MARKING_SUCCESS' => 'Resynchronised dotted topics', 'RESYNC_STATS' => 'Resynchronise statistics', 'RESYNC_STATS_CONFIRM' => 'Are you sure you wish to resynchronise statistics?', 'RESYNC_STATS_EXPLAIN' => 'Recalculates the total number of posts, topics, users and files.', + 'RESYNC_STATS_SUCCESS' => 'Resynchronised statistics', 'RUN' => 'Run now', 'STATISTIC' => 'Statistic', From fc7cb6a70b9e0422bf5658bb9f49de831be08718 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 24 Aug 2011 16:25:54 +0100 Subject: [PATCH 182/335] [ticket/10270] Made the alert after an AJAX operation optional. PHPBB3-10270 --- phpBB/styles/script.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 44b21906cc..16d64319d9 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -224,7 +224,11 @@ phpbb.ajaxify = function(options, refresh, callback) { if (typeof res.S_CONFIRM_ACTION === 'undefined') { // It is a standard link, no confirm_box required. - var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); + if (typeof res.MESSAGE_TITLE !== 'undefined') + { + var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); + } + if (typeof phpbb.ajax_callbacks[callback] === 'function') { phpbb.ajax_callbacks[callback](that, res, (is_form) ? act : null); @@ -241,7 +245,11 @@ phpbb.ajaxify = function(options, refresh, callback) { path = res.S_CONFIRM_ACTION; phpbb.loading_alert(); $.post(path, data + '&confirm=' + res.YES_VALUE, function(res) { - var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); + if (typeof res.MESSAGE_TITLE !== 'undefined') + { + var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); + } + if (typeof phpbb.ajax_callbacks[callback] === 'function') { phpbb.ajax_callbacks[callback](that, res, (is_form) ? act : null); From e7e09f8da26abf0d4e625653d14d68774050a244 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 24 Aug 2011 16:39:25 +0100 Subject: [PATCH 183/335] [ticket/10272] AJAXified the bots page in the ACP. PHPBB3-10272 --- phpBB/adm/style/acp_bots.html | 4 ++-- phpBB/includes/acp/acp_bots.php | 10 +++++++++- phpBB/styles/script.js | 8 ++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/phpBB/adm/style/acp_bots.html b/phpBB/adm/style/acp_bots.html index 886005caa3..e0e9588364 100644 --- a/phpBB/adm/style/acp_bots.html +++ b/phpBB/adm/style/acp_bots.html @@ -76,9 +76,9 @@ {bots.BOT_NAME}  {bots.LAST_VISIT}  -  {bots.L_ACTIVATE_DEACTIVATE}  +  {bots.L_ACTIVATE_DEACTIVATE}   {L_EDIT}  -  {L_DELETE}  +  {L_DELETE}  diff --git a/phpBB/includes/acp/acp_bots.php b/phpBB/includes/acp/acp_bots.php index f080b3c9fb..b9dd6664f4 100644 --- a/phpBB/includes/acp/acp_bots.php +++ b/phpBB/includes/acp/acp_bots.php @@ -24,7 +24,7 @@ class acp_bots function main($id, $mode) { - global $config, $db, $user, $auth, $template, $cache; + global $config, $db, $user, $auth, $template, $cache, $request; global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix; $action = request_var('action', ''); @@ -352,6 +352,14 @@ class acp_bots break; } + + if ($request->is_ajax() && ($action == 'activate' || $action == 'deactivate')) + { + $json_response = new phpbb_json_response; + $json_response->send(array( + 'text' => $user->lang['BOT_' . (($action == 'activate') ? 'DE' : '') . 'ACTIVATE'], + )); + } $s_options = ''; $_options = array('activate' => 'BOT_ACTIVATE', 'deactivate' => 'BOT_DEACTIVATE', 'delete' => 'DELETE'); diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 16d64319d9..59fe7cf8e2 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -228,6 +228,10 @@ phpbb.ajaxify = function(options, refresh, callback) { { var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); } + else + { + dark.fadeOut(); + } if (typeof phpbb.ajax_callbacks[callback] === 'function') { @@ -249,6 +253,10 @@ phpbb.ajaxify = function(options, refresh, callback) { { var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); } + else + { + dark.fadeOut(); + } if (typeof phpbb.ajax_callbacks[callback] === 'function') { From bcb824a9f2407523c84501ac1d4260bb27661ff1 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 24 Aug 2011 16:59:05 +0100 Subject: [PATCH 184/335] [ticket/10272] Renamed AJAX callback "style_act_deact" to "act_deact". PHPBB3-10272 --- phpBB/adm/style/acp_bots.html | 2 +- phpBB/adm/style/acp_modules.html | 2 +- phpBB/adm/style/acp_profile.html | 2 +- phpBB/adm/style/acp_styles.html | 2 +- phpBB/styles/script.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/phpBB/adm/style/acp_bots.html b/phpBB/adm/style/acp_bots.html index e0e9588364..3a5ef72acd 100644 --- a/phpBB/adm/style/acp_bots.html +++ b/phpBB/adm/style/acp_bots.html @@ -76,7 +76,7 @@ {bots.BOT_NAME}  {bots.LAST_VISIT}  -  {bots.L_ACTIVATE_DEACTIVATE}  +  {bots.L_ACTIVATE_DEACTIVATE}   {L_EDIT}   {L_DELETE}  diff --git a/phpBB/adm/style/acp_modules.html b/phpBB/adm/style/acp_modules.html index 6c4645e80c..380a037977 100644 --- a/phpBB/adm/style/acp_modules.html +++ b/phpBB/adm/style/acp_modules.html @@ -148,7 +148,7 @@ {modules.MODULE_IMAGE} {modules.MODULE_TITLE} [{L_HIDDEN_MODULE}] -  {L_DISABLE}{L_ENABLE}  +  {L_DISABLE}{L_ENABLE}  {ICON_MOVE_UP_DISABLED} diff --git a/phpBB/adm/style/acp_profile.html b/phpBB/adm/style/acp_profile.html index 7804533d1a..d0920774f1 100644 --- a/phpBB/adm/style/acp_profile.html +++ b/phpBB/adm/style/acp_profile.html @@ -195,7 +195,7 @@ {fields.FIELD_IDENT} {fields.FIELD_TYPE} - {fields.L_ACTIVATE_DEACTIVATE} | {L_TRANSLATE} + {fields.L_ACTIVATE_DEACTIVATE} | {L_TRANSLATE} diff --git a/phpBB/adm/style/acp_styles.html b/phpBB/adm/style/acp_styles.html index dfc8def646..0b98dea603 100644 --- a/phpBB/adm/style/acp_styles.html +++ b/phpBB/adm/style/acp_styles.html @@ -288,7 +288,7 @@ - {installed.L_STYLE_ACT_DEACT} | + {installed.L_STYLE_ACT_DEACT} | {installed.S_ACTIONS} diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 59fe7cf8e2..4630c4fed1 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -377,7 +377,7 @@ phpbb.add_ajax_callback('post_delete', function(el) { tr.next().find('.up').html('Move up'); phpbb.ajaxify({selector: tr.next().find('.up').children('a')}, false, 'forum_up'); } -}).add_ajax_callback('style_act_deact', function(el, res) { +}).add_ajax_callback('act_deact', function(el, res) { $(el).text(res.text); var new_href = $(el).attr('href'); if (new_href.indexOf('deactivate') !== -1) From f85faf435da19f877b7633e208ae103a3d954355 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 24 Aug 2011 22:29:52 +0100 Subject: [PATCH 185/335] [ticket/10271] Cleaned up phpbb.ajaxify. Reduced a lot of duplicate code and made it more efficient. PHPBB3-10271 --- phpBB/styles/script.js | 70 +++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 45 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 4630c4fed1..4d7d6e1425 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -174,32 +174,6 @@ phpbb.parse_querystring = function(string) { * @param function callback Callback. */ phpbb.ajaxify = function(options, refresh, callback) { - - // Private function to handle refreshes - function handle_refresh(data, refresh, div) - { - if (!data) - { - return; - } - - refresh = ((typeof refresh === 'function') ? refresh(data.url) : - (typeof refresh === 'boolean') && refresh); - - setTimeout(function() { - if (refresh) - { - window.location = data.url; - } - else - { - dark.fadeOut(function() { - div.remove(); - }); - } - }, data.time * 1000); - } - var selector = (typeof options === 'string') ? options : options.selector; var is_form = $(selector).is('form'); if (is_form && typeof selector === 'object') @@ -237,7 +211,29 @@ phpbb.ajaxify = function(options, refresh, callback) { { phpbb.ajax_callbacks[callback](that, res, (is_form) ? act : null); } - handle_refresh(res.REFRESH_DATA, refresh, alert); + + if (res.REFRESH_DATA) + { + if (typeof refresh === 'function') + { + refresh = refresh(res.REFRESH_DATA.url); + } + else if (typeof refresh !== 'boolean') + { + refresh = false; + } + + setTimeout(function() { + if (refresh) + { + window.location = res.REFRESH_DATA.url; + } + + dark.fadeOut(function() { + alert.remove(); + }); + }, res.REFRESH_DATA.time * 1000); + } } else { @@ -245,25 +241,9 @@ phpbb.ajaxify = function(options, refresh, callback) { phpbb.confirm(res.MESSAGE_TEXT, function(del) { if (del) { - data = $('' + res.S_HIDDEN_FIELDS + '').serialize(); - path = res.S_CONFIRM_ACTION; phpbb.loading_alert(); - $.post(path, data + '&confirm=' + res.YES_VALUE, function(res) { - if (typeof res.MESSAGE_TITLE !== 'undefined') - { - var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); - } - else - { - dark.fadeOut(); - } - - if (typeof phpbb.ajax_callbacks[callback] === 'function') - { - phpbb.ajax_callbacks[callback](that, res, (is_form) ? act : null); - } - handle_refresh(res.REFRESH_DATA, refresh, alert); - }); + data = $('
' + res.S_HIDDEN_FIELDS + '
').serialize(); + $.post(res.S_CONFIRM_ACTION, data + '&confirm=' + res.YES_VALUE, return_handler); } }, false); } From 53201da98c7b9ca88d1b43f1b59b8d17208c2025 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 24 Aug 2011 22:53:26 +0100 Subject: [PATCH 186/335] [ticket/10270] Increased the speed of the animations. PHPBB3-10270 --- phpBB/styles/script.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 4d7d6e1425..0e885bceed 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -15,12 +15,12 @@ var dark = $('#darkenwrapper'), phpbb.loading_alert = function() { if (dark.is(':visible')) { - loading_alert.fadeIn(); + loading_alert.fadeIn(200); } else { loading_alert.show(); - dark.fadeIn(function() { + dark.fadeIn(200, function() { setTimeout(function() { if (loading_alert.is(':visible')) { @@ -52,7 +52,7 @@ phpbb.alert = function(title, msg, fadedark) { }); $(dark).one('click', function(e) { var fade = (typeof fadedark !== 'undefined' && !fadedark) ? div : dark; - fade.fadeOut(function() { + fade.fadeOut(200, function() { div.remove(); }); return false; @@ -68,21 +68,21 @@ phpbb.alert = function(title, msg, fadedark) { if (loading_alert.is(':visible')) { - loading_alert.fadeOut(function() { + loading_alert.fadeOut(200, function() { $(dark).append(div); - div.fadeIn(); + div.fadeIn(200); }); } else if (dark.is(':visible')) { $(dark).append(div); - div.fadeIn(); + div.fadeIn(200); } else { $(dark).append(div); div.show(); - dark.fadeIn(); + dark.fadeIn(200); } return div; @@ -107,7 +107,7 @@ phpbb.confirm = function(msg, callback, fadedark) { div.find('.jalertbut').bind('click', function() { var res = this.value === 'Yes'; var fade = (typeof fadedark !== 'undefined' && !fadedark && res) ? div : dark; - fade.fadeOut(function() { + fade.fadeOut(200, function() { div.remove(); }); callback(res); @@ -127,21 +127,21 @@ phpbb.confirm = function(msg, callback, fadedark) { if (loading_alert.is(':visible')) { - loading_alert.fadeOut(function() { + loading_alert.fadeOut(200, function() { $(dark).append(div); - div.fadeIn(); + div.fadeIn(200); }); } else if (dark.is(':visible')) { $(dark).append(div); - div.fadeIn(); + div.fadeIn(200); } else { $(dark).append(div); div.show(); - dark.fadeIn(); + dark.fadeIn(200); } return div; @@ -204,7 +204,7 @@ phpbb.ajaxify = function(options, refresh, callback) { } else { - dark.fadeOut(); + dark.fadeOut(200); } if (typeof phpbb.ajax_callbacks[callback] === 'function') @@ -229,7 +229,7 @@ phpbb.ajaxify = function(options, refresh, callback) { window.location = res.REFRESH_DATA.url; } - dark.fadeOut(function() { + dark.fadeOut(200, function() { alert.remove(); }); }, res.REFRESH_DATA.time * 1000); @@ -249,7 +249,7 @@ phpbb.ajaxify = function(options, refresh, callback) { } } - var run_exception = typeof options.exception === 'function'; + var run_exception = (typeof options.exception === 'function'); if (is_form) { act = /action\[([a-z]+)\]/.exec(this.name); From 431a78f34696707973f1c67f4417d6ee85713ee6 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sun, 11 Sep 2011 15:42:00 +0100 Subject: [PATCH 187/335] [ticket/10270] Got rid of the temporary jQuery for the AJAX changes. The jQuery library wasn't included before, so a temporary one was included. Now that igorws jQuery patch has been merged, the temporary library can be removed. PHPBB3-10270 --- phpBB/adm/style/overall_footer.html | 5 +---- phpBB/styles/prosilver/template/overall_footer.html | 4 +--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/phpBB/adm/style/overall_footer.html b/phpBB/adm/style/overall_footer.html index 625121f1bd..ec3e6a30d3 100644 --- a/phpBB/adm/style/overall_footer.html +++ b/phpBB/adm/style/overall_footer.html @@ -22,15 +22,12 @@
 

{L_LOADING}

{L_PLEASE_WAIT}

- - - - + diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html index 37caaf7cca..20f6ee1f91 100644 --- a/phpBB/styles/prosilver/template/overall_footer.html +++ b/phpBB/styles/prosilver/template/overall_footer.html @@ -29,9 +29,6 @@
 

{L_LOADING}

{L_PLEASE_WAIT}

- - - @@ -43,6 +40,7 @@ + From 8c0e72cd9e52c754bd6a851de73862b3c6485840 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sun, 11 Sep 2011 15:54:03 +0100 Subject: [PATCH 188/335] [ticket/10270] Sped up animations of popups. They were too slow and were hampering the user experience on boards with a fast connection such as local boards. PHPBB3-10270 --- phpBB/styles/script.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 0e885bceed..cafb11c9e4 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -15,12 +15,12 @@ var dark = $('#darkenwrapper'), phpbb.loading_alert = function() { if (dark.is(':visible')) { - loading_alert.fadeIn(200); + loading_alert.fadeIn(100); } else { loading_alert.show(); - dark.fadeIn(200, function() { + dark.fadeIn(100, function() { setTimeout(function() { if (loading_alert.is(':visible')) { @@ -52,7 +52,7 @@ phpbb.alert = function(title, msg, fadedark) { }); $(dark).one('click', function(e) { var fade = (typeof fadedark !== 'undefined' && !fadedark) ? div : dark; - fade.fadeOut(200, function() { + fade.fadeOut(100, function() { div.remove(); }); return false; @@ -68,21 +68,21 @@ phpbb.alert = function(title, msg, fadedark) { if (loading_alert.is(':visible')) { - loading_alert.fadeOut(200, function() { + loading_alert.fadeOut(100, function() { $(dark).append(div); - div.fadeIn(200); + div.fadeIn(100); }); } else if (dark.is(':visible')) { $(dark).append(div); - div.fadeIn(200); + div.fadeIn(100); } else { $(dark).append(div); div.show(); - dark.fadeIn(200); + dark.fadeIn(100); } return div; @@ -107,7 +107,7 @@ phpbb.confirm = function(msg, callback, fadedark) { div.find('.jalertbut').bind('click', function() { var res = this.value === 'Yes'; var fade = (typeof fadedark !== 'undefined' && !fadedark && res) ? div : dark; - fade.fadeOut(200, function() { + fade.fadeOut(100, function() { div.remove(); }); callback(res); @@ -127,21 +127,21 @@ phpbb.confirm = function(msg, callback, fadedark) { if (loading_alert.is(':visible')) { - loading_alert.fadeOut(200, function() { + loading_alert.fadeOut(100, function() { $(dark).append(div); - div.fadeIn(200); + div.fadeIn(100); }); } else if (dark.is(':visible')) { $(dark).append(div); - div.fadeIn(200); + div.fadeIn(100); } else { $(dark).append(div); div.show(); - dark.fadeIn(200); + dark.fadeIn(100); } return div; @@ -204,7 +204,7 @@ phpbb.ajaxify = function(options, refresh, callback) { } else { - dark.fadeOut(200); + dark.fadeOut(100); } if (typeof phpbb.ajax_callbacks[callback] === 'function') @@ -229,7 +229,7 @@ phpbb.ajaxify = function(options, refresh, callback) { window.location = res.REFRESH_DATA.url; } - dark.fadeOut(200, function() { + dark.fadeOut(100, function() { alert.remove(); }); }, res.REFRESH_DATA.time * 1000); From dbb81fbd2bfadf52502f2200b0420953d98ffb56 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sat, 24 Sep 2011 16:35:46 +0100 Subject: [PATCH 189/335] [ticket/10328] Added capital to "Content-type" in phpbb_json_response. It was originally Content-type, but has been replaced with Content-Type, which is correct. PHPBB3-10328 --- phpBB/includes/json_response.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/json_response.php b/phpBB/includes/json_response.php index 95d02e3c0e..dfddea98f2 100644 --- a/phpBB/includes/json_response.php +++ b/phpBB/includes/json_response.php @@ -30,7 +30,7 @@ class phpbb_json_response */ public function send($data, $exit = true) { - header('Content-type: application/json'); + header('Content-Type: application/json'); echo json_encode($data); if ($exit) From 233c2d51cfc1ffc33b03f1ab73c016d07828bab4 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sat, 24 Sep 2011 16:42:22 +0100 Subject: [PATCH 190/335] [ticket/10270] Removed some unnecessary calls to $() in script.js. Sometimes, jQuery objects were being sent through the jQuery function again, wasting resources. PHPBB3-10270 --- phpBB/styles/script.js | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index cafb11c9e4..dd9d2532cc 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -46,11 +46,11 @@ phpbb.loading_alert = function() { phpbb.alert = function(title, msg, fadedark) { var div = $('

' + title + '

' + msg + '

'); - $(div).bind('click', function(e) { + div.bind('click', function(e) { e.stopPropagation(); return true; }); - $(dark).one('click', function(e) { + dark.one('click', function(e) { var fade = (typeof fadedark !== 'undefined' && !fadedark) ? div : dark; fade.fadeOut(100, function() { div.remove(); @@ -60,7 +60,7 @@ phpbb.alert = function(title, msg, fadedark) { $(document).bind('keydown', function(e) { if (e.keyCode === 13 || e.keyCode === 27) { - $(dark).trigger('click'); + dark.trigger('click'); return false; } return true; @@ -69,18 +69,18 @@ phpbb.alert = function(title, msg, fadedark) { if (loading_alert.is(':visible')) { loading_alert.fadeOut(100, function() { - $(dark).append(div); + dark.append(div); div.fadeIn(100); }); } else if (dark.is(':visible')) { - $(dark).append(div); + dark.append(div); div.fadeIn(100); } else { - $(dark).append(div); + dark.append(div); div.show(); dark.fadeIn(100); } @@ -128,18 +128,18 @@ phpbb.confirm = function(msg, callback, fadedark) { if (loading_alert.is(':visible')) { loading_alert.fadeOut(100, function() { - $(dark).append(div); + dark.append(div); div.fadeIn(100); }); } else if (dark.is(':visible')) { - $(dark).append(div); + dark.append(div); div.fadeIn(100); } else { - $(dark).append(div); + dark.append(div); div.show(); dark.fadeIn(100); } @@ -174,18 +174,14 @@ phpbb.parse_querystring = function(string) { * @param function callback Callback. */ phpbb.ajaxify = function(options, refresh, callback) { - var selector = (typeof options === 'string') ? options : options.selector; - var is_form = $(selector).is('form'); - if (is_form && typeof selector === 'object') + var selector = $((typeof options === 'string') ? options : options.selector); + var is_form = selector.is('form'); + if (is_form) { - selector = $(selector).find('input:submit'); - } - else if (is_form) - { - selector += ' input:submit'; + selector = selector.find('input:submit'); } - $(selector).click(function() { + selector.click(function() { var act, data, path, that = this; if ($(this).data('ajax') == false) From 818d98916873945d7e0e7bf2855e982496c7fe35 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sat, 24 Sep 2011 17:41:58 +0100 Subject: [PATCH 191/335] [feature/ajax] Moved script.js into a few different files. Seperated it into: assets/javascript/core.js, styles/prosilver/template/ajax.js and adm/style/ajax.js. PHPBB3-10270 --- phpBB/adm/style/ajax.js | 61 ++++++++++ phpBB/adm/style/overall_footer.html | 3 +- .../script.js => assets/javascript/core.js} | 104 +----------------- phpBB/styles/prosilver/template/ajax.js | 66 +++++++++++ .../prosilver/template/overall_footer.html | 3 +- 5 files changed, 133 insertions(+), 104 deletions(-) create mode 100644 phpBB/adm/style/ajax.js rename phpBB/{styles/script.js => assets/javascript/core.js} (61%) create mode 100644 phpBB/styles/prosilver/template/ajax.js diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js new file mode 100644 index 0000000000..407ef92110 --- /dev/null +++ b/phpBB/adm/style/ajax.js @@ -0,0 +1,61 @@ +(function($) { // Avoid conflicts with other libraries + + + +phpbb.add_ajax_callback('forum_down', function(el) { + var tr = $(el).parents('tr'); + if (tr.is(':first-child')) + { + $(el).parents('span').siblings('.up').html('Move up'); + tr.next().find('.up').html('Move up'); + phpbb.ajaxify({selector: $(el).parents('span').siblings('.up').children('a')}, false, 'forum_up'); + } + tr.insertAfter(tr.next()); + if (tr.is(':last-child')) + { + $(el).html('Move down'); + tr.prev().find('.down').html('Move down'); + phpbb.ajaxify({selector: tr.prev().find('.down').children('a')}, false, 'forum_down'); + } +}).add_ajax_callback('forum_up', function(el) { + var tr = $(el).parents('tr'); + if (tr.is(':last-child')) + { + $(el).parents('span').siblings('.down').html('Move down'); + tr.prev().find('.down').html('Move down'); + phpbb.ajaxify({selector: $(el).parents('span').siblings('.down').children('a')}, false, 'forum_down'); + } + tr.insertBefore(tr.prev()); + if (tr.is(':first-child')) + { + $(el).html('Move up'); + tr.next().find('.up').html('Move up'); + phpbb.ajaxify({selector: tr.next().find('.up').children('a')}, false, 'forum_up'); + } +}).add_ajax_callback('act_deact', function(el, res) { + $(el).text(res.text); + var new_href = $(el).attr('href'); + if (new_href.indexOf('deactivate') !== -1) + { + new_href = new_href.replace('deactivate', 'activate') + } + else + { + new_href = new_href.replace('activate', 'deactivate') + } + $(el).attr('href', new_href); +}).add_ajax_callback('row_delete', function(el) { + var tr = $(el).parents('tr'); + tr.remove(); +}); + + + +$('[data-ajax]').each(function() { + var fn = ($(this).data('ajax') !== 'true') ? $(this).data('ajax') : null; + phpbb.ajaxify({selector: this}, $(this).data('refresh') !== undefined, fn); +}); + + + +})(jQuery); // Avoid conflicts with other libraries diff --git a/phpBB/adm/style/overall_footer.html b/phpBB/adm/style/overall_footer.html index ec3e6a30d3..b57f8261a3 100644 --- a/phpBB/adm/style/overall_footer.html +++ b/phpBB/adm/style/overall_footer.html @@ -27,7 +27,8 @@ - + + diff --git a/phpBB/styles/script.js b/phpBB/assets/javascript/core.js similarity index 61% rename from phpBB/styles/script.js rename to phpBB/assets/javascript/core.js index dd9d2532cc..7337a7fbc0 100644 --- a/phpBB/styles/script.js +++ b/phpBB/assets/javascript/core.js @@ -3,6 +3,7 @@ var phpbb = {}; (function($) { // Avoid conflicts with other libraries + var dark = $('#darkenwrapper'), loading_alert = $('#loadingalert'); @@ -295,106 +296,5 @@ phpbb.add_ajax_callback = function(id, callback) } -phpbb.add_ajax_callback('post_delete', function(el) { - if ($(this).data('refresh') === undefined) - { - var pid = el.href.split('&p=')[1]; - $(el).parents('div #p' + pid).fadeOut(function() { - $(this).remove(); - }); - } -}).add_ajax_callback('bookmark', function(el, res) { - var text = (res.MESSAGE_TEXT.indexOf('Removed') === -1); - text = (text) ? 'Remove from bookmarks' : 'Bookmark topic'; - $(el).text(el.title = text); -}).add_ajax_callback('topic_subscribe', function(el) { - $(el).text(el.title = 'Unsubscribe topic'); -}).add_ajax_callback('topic_unsubscribe', function(el) { - $(el).text(el.title = 'Subscribe forum'); -}).add_ajax_callback('forum_subscribe', function(el) { - $(el).text(el.title = 'Unsubscribe topic'); -}).add_ajax_callback('forum_unsubscribe', function(el) { - $(el).text(el.title = 'Subscribe forum'); -}).add_ajax_callback('post_approve', function(el, res, act) { - $(el).parents((act === 'approve') ? '.rules' : '.post').fadeOut(function() { - $(this).remove(); - }); -}).add_ajax_callback('qr-submit', function(el) { - $(el).parents('form').fadeOut(function() { - $(this).remove(); - }); -}).add_ajax_callback('forum_down', function(el) { - var tr = $(el).parents('tr'); - if (tr.is(':first-child')) - { - $(el).parents('span').siblings('.up').html('Move up'); - tr.next().find('.up').html('Move up'); - phpbb.ajaxify({selector: $(el).parents('span').siblings('.up').children('a')}, false, 'forum_up'); - } - tr.insertAfter(tr.next()); - if (tr.is(':last-child')) - { - $(el).html('Move down'); - tr.prev().find('.down').html('Move down'); - phpbb.ajaxify({selector: tr.prev().find('.down').children('a')}, false, 'forum_down'); - } -}).add_ajax_callback('forum_up', function(el) { - var tr = $(el).parents('tr'); - if (tr.is(':last-child')) - { - $(el).parents('span').siblings('.down').html('Move down'); - tr.prev().find('.down').html('Move down'); - phpbb.ajaxify({selector: $(el).parents('span').siblings('.down').children('a')}, false, 'forum_down'); - } - tr.insertBefore(tr.prev()); - if (tr.is(':first-child')) - { - $(el).html('Move up'); - tr.next().find('.up').html('Move up'); - phpbb.ajaxify({selector: tr.next().find('.up').children('a')}, false, 'forum_up'); - } -}).add_ajax_callback('act_deact', function(el, res) { - $(el).text(res.text); - var new_href = $(el).attr('href'); - if (new_href.indexOf('deactivate') !== -1) - { - new_href = new_href.replace('deactivate', 'activate') - } - else - { - new_href = new_href.replace('activate', 'deactivate') - } - $(el).attr('href', new_href); -}).add_ajax_callback('row_delete', function(el) { - var tr = $(el).parents('tr'); - tr.remove(); -}).add_ajax_callback('zebra', function(el, res) { - if (res.success) { - $('.zebra').html(res.MESSAGE_TEXT); - $($('.zebra').get(1)).remove(); - } -});; - - -$('[data-ajax]').each(function() { - var fn = ($(this).data('ajax') !== 'true') ? $(this).data('ajax') : null; - phpbb.ajaxify({selector: this}, $(this).data('refresh') !== undefined, fn); -}); - - - -phpbb.ajaxify({ - selector: '#quickmodform', - exception: function(el, act, data) { - var d = phpbb.parse_querystring(data).action; - if (d == 'make_normal') - { - return !(el.find('select option[value="make_global"]').length); - } - return !(d == 'lock' || d == 'unlock' || d == 'delete_topic' || d.slice(0, 5) == 'make_'); - } -}, true); - - -})(jQuery); // Avoid conflicts with other libraries +})(jQuery); // Avoid conflicts with other libraries \ No newline at end of file diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js new file mode 100644 index 0000000000..38233ad0e0 --- /dev/null +++ b/phpBB/styles/prosilver/template/ajax.js @@ -0,0 +1,66 @@ +(function($) { // Avoid conflicts with other libraries + + + +phpbb.add_ajax_callback('post_delete', function(el) { + if ($(this).data('refresh') === undefined) + { + var pid = el.href.split('&p=')[1]; + $(el).parents('div #p' + pid).fadeOut(function() { + $(this).remove(); + }); + } +}).add_ajax_callback('bookmark', function(el, res) { + var text = (res.MESSAGE_TEXT.indexOf('Removed') === -1); + text = (text) ? 'Remove from bookmarks' : 'Bookmark topic'; + $(el).text(el.title = text); +}).add_ajax_callback('topic_subscribe', function(el) { + $(el).text(el.title = 'Unsubscribe topic'); +}).add_ajax_callback('topic_unsubscribe', function(el) { + $(el).text(el.title = 'Subscribe forum'); +}).add_ajax_callback('forum_subscribe', function(el) { + $(el).text(el.title = 'Unsubscribe topic'); +}).add_ajax_callback('forum_unsubscribe', function(el) { + $(el).text(el.title = 'Subscribe forum'); +}).add_ajax_callback('post_approve', function(el, res, act) { + $(el).parents((act === 'approve') ? '.rules' : '.post').fadeOut(function() { + $(this).remove(); + }); +}).add_ajax_callback('qr-submit', function(el) { + $(el).parents('form').fadeOut(function() { + $(this).remove(); + }); +}).add_ajax_callback('row_delete', function(el) { + var tr = $(el).parents('tr'); + tr.remove(); +}).add_ajax_callback('zebra', function(el, res) { + if (res.success) { + $('.zebra').html(res.MESSAGE_TEXT); + $($('.zebra').get(1)).remove(); + } +});; + + + +$('[data-ajax]').each(function() { + var fn = ($(this).data('ajax') !== 'true') ? $(this).data('ajax') : null; + phpbb.ajaxify({selector: this}, $(this).data('refresh') !== undefined, fn); +}); + + + +phpbb.ajaxify({ + selector: '#quickmodform', + exception: function(el, act, data) { + var d = phpbb.parse_querystring(data).action; + if (d == 'make_normal') + { + return !(el.find('select option[value="make_global"]').length); + } + return !(d == 'lock' || d == 'unlock' || d == 'delete_topic' || d.slice(0, 5) == 'make_'); + } +}, true); + + + +})(jQuery); // Avoid conflicts with other libraries diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html index 20f6ee1f91..a89cd7f04e 100644 --- a/phpBB/styles/prosilver/template/overall_footer.html +++ b/phpBB/styles/prosilver/template/overall_footer.html @@ -40,7 +40,8 @@ - + + From 0e55b2393dffa269a724f3090469dad563217dff Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sun, 25 Sep 2011 16:02:26 +0100 Subject: [PATCH 192/335] [ticket/10270] Removed all the inline language and HTML from the JS. PHPBB3-10270 --- phpBB/assets/javascript/core.js | 23 ++++++++++++------- phpBB/language/en/common.php | 2 ++ phpBB/styles/prosilver/template/ajax.js | 12 ---------- .../prosilver/template/overall_footer.html | 13 ++++++++--- .../prosilver/template/overall_header.html | 2 +- phpBB/viewtopic.php | 2 ++ 6 files changed, 30 insertions(+), 24 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 7337a7fbc0..d685d28c81 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -25,7 +25,7 @@ phpbb.loading_alert = function() { setTimeout(function() { if (loading_alert.is(':visible')) { - phpbb.alert('Error', 'Error processing your request. Please try again.'); + phpbb.alert($('body').data('l-err'), $('body').data('l-err-processing-req')); } }, 5000); }); @@ -45,7 +45,9 @@ phpbb.loading_alert = function() { * @returns object Returns the div created. */ phpbb.alert = function(title, msg, fadedark) { - var div = $('

' + title + '

' + msg + '

'); + var div = $('#jalert_alert'); + div.find('h3').html(title); + div.find('p').html(msg); div.bind('click', function(e) { e.stopPropagation(); @@ -54,7 +56,7 @@ phpbb.alert = function(title, msg, fadedark) { dark.one('click', function(e) { var fade = (typeof fadedark !== 'undefined' && !fadedark) ? div : dark; fade.fadeOut(100, function() { - div.remove(); + div.hide(); }); return false; }); @@ -101,15 +103,14 @@ phpbb.alert = function(title, msg, fadedark) { * @returns object Returns the div created. */ phpbb.confirm = function(msg, callback, fadedark) { - var div = $('

' + msg + '

\ -  \ -
'); + var div = $('#jalert_confirm'); + div.find('p').html(msg); div.find('.jalertbut').bind('click', function() { var res = this.value === 'Yes'; var fade = (typeof fadedark !== 'undefined' && !fadedark && res) ? div : dark; fade.fadeOut(100, function() { - div.remove(); + div.hide(); }); callback(res); return false; @@ -227,7 +228,7 @@ phpbb.ajaxify = function(options, refresh, callback) { } dark.fadeOut(100, function() { - alert.remove(); + alert.hide(); }); }, res.REFRESH_DATA.time * 1000); } @@ -296,5 +297,11 @@ phpbb.add_ajax_callback = function(id, callback) } +phpbb.add_ajax_callback('alt_text', function(el) { + var alt_text = $(el).data('alt-text'); + $(el).data('alt-text', $(el).text()); + $(el).text(el.title = alt_text); +}); + })(jQuery); // Avoid conflicts with other libraries \ No newline at end of file diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index e8fff96e5a..ff3d229915 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -179,10 +179,12 @@ $lang = array_merge($lang, array( 'ERR_CONNECTING_SERVER' => 'Error connecting to the server.', 'ERR_JAB_AUTH' => 'Could not authorise on Jabber server.', 'ERR_JAB_CONNECT' => 'Could not connect to Jabber server.', + 'ERR_PROCESSING_REQ' => 'There was an error processing your request. Please try again.', 'ERR_UNABLE_TO_LOGIN' => 'The specified username or password is incorrect.', 'ERR_UNWATCHING' => 'An error occured while trying to unsubscribe.', 'ERR_WATCHING' => 'An error occured while trying to subscribe.', 'ERR_WRONG_PATH_TO_PHPBB' => 'The phpBB path specified appears to be invalid.', + 'ERROR' => 'Error', 'EXPAND_VIEW' => 'Expand view', 'EXTENSION' => 'Extension', 'EXTENSION_CONTROLLER_MISSING' => 'The extension %s is missing a controller class and cannot be accessed through the front-end.', diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 38233ad0e0..58b765779e 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -10,18 +10,6 @@ phpbb.add_ajax_callback('post_delete', function(el) { $(this).remove(); }); } -}).add_ajax_callback('bookmark', function(el, res) { - var text = (res.MESSAGE_TEXT.indexOf('Removed') === -1); - text = (text) ? 'Remove from bookmarks' : 'Bookmark topic'; - $(el).text(el.title = text); -}).add_ajax_callback('topic_subscribe', function(el) { - $(el).text(el.title = 'Unsubscribe topic'); -}).add_ajax_callback('topic_unsubscribe', function(el) { - $(el).text(el.title = 'Subscribe forum'); -}).add_ajax_callback('forum_subscribe', function(el) { - $(el).text(el.title = 'Unsubscribe topic'); -}).add_ajax_callback('forum_unsubscribe', function(el) { - $(el).text(el.title = 'Subscribe forum'); }).add_ajax_callback('post_approve', function(el, res, act) { $(el).parents((act === 'approve') ? '.rules' : '.post').fadeOut(function() { $(this).remove(); diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html index a89cd7f04e..362f8bc1cc 100644 --- a/phpBB/styles/prosilver/template/overall_footer.html +++ b/phpBB/styles/prosilver/template/overall_footer.html @@ -8,9 +8,9 @@
+ + diff --git a/phpBB/adm/style/admin.css b/phpBB/adm/style/admin.css index 01af071766..a162d44f9d 100644 --- a/phpBB/adm/style/admin.css +++ b/phpBB/adm/style/admin.css @@ -101,6 +101,10 @@ hr { font-size: 0.85em; } +.hidden { + display: none; +} + /* General links */ a:link, a:visited { color: #105289; diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index b4385b2740..0c00efee1b 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -2,6 +2,13 @@ "use strict"; +var img_templates = { + up: $('.template-up-img'), + up_disabled: $('.template-up-img-disabled'), + down: $('.template-down-img'), + down_disabled: $('.template-down-img-disabled') +}; + /** * The following callbacks are for reording forums in acp_forums. forum_down * is triggered when a forum is moved down, and forum_up is triggered when @@ -14,18 +21,26 @@ phpbb.add_ajax_callback('forum_down', function() { if (tr.is(':first-child')) { - el.parents('span').siblings('.up').html('Move up'); - tr.next().find('.up').html('Move up'); + var up_img = img_templates.up.clone().attr('href', tr.attr('data-up')); + el.parents('span').siblings('.up').html(up_img); + + tr.next().find('.up').html(img_templates.up_disabled); + phpbb.ajaxify({ selector: el.parents('span').siblings('.up').children('a'), callback: 'forum_up' }); } + tr.insertAfter(tr.next()); + if (tr.is(':last-child')) { - el.html('Move down'); - tr.prev().find('.down').html('Move down'); + el.replaceWith(img_templates.down_disabled); + + var down_img = img_templates.down.clone().attr('href', tr.attr('data-down')); + tr.prev().find('.down').html(down_img); + phpbb.ajaxify({ selector: tr.prev().find('.down').children('a'), callback: 'forum_down' @@ -39,18 +54,26 @@ phpbb.add_ajax_callback('forum_up', function() { if (tr.is(':last-child')) { - el.parents('span').siblings('.down').html('Move down'); - tr.prev().find('.down').html('Move down'); + var down_img = img_templates.down.clone().attr('href', tr.attr('data-down')); + el.parents('span').siblings('.down').html(down_img); + + tr.prev().find('.down').html(img_templates.down_disabled); + phpbb.ajaxify({ selector: el.parents('span').siblings('.down').children('a'), callback: 'forum_down' }); } + tr.insertBefore(tr.prev()); + if (tr.is(':first-child')) { - el.html('Move up'); - tr.next().find('.up').html('Move up'); + el.replaceWith(img_templates.up_disabled); + + var up_img = img_templates.up.clone().attr('href', tr.attr('data-up')); + tr.next().find('.up').html(up_img); + phpbb.ajaxify({ selector: tr.next().find('.up').children('a'), callback: 'forum_up' diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index d1fc1fa3e3..3b0e7899cb 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -702,3 +702,7 @@ p.rules a { line-height: 1px; background: transparent; } + +.hidden { + display: none; +} From 2ede0b1c811657827c388c4a0559063f4f02f025 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Thu, 9 Feb 2012 17:10:16 +0200 Subject: [PATCH 242/335] [feature/ajax] Better handling for zebra Better handling for zebra: message is displayed instead of first .zebra. Other .zebra entries are emptied, but not completely removed to avoid changing layout. PHPBB3-10272 --- phpBB/styles/prosilver/template/ajax.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 739648200b..35e8d6c0b4 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -41,8 +41,8 @@ phpbb.add_ajax_callback('zebra', function(res) { if (res.success) { zebra = $('.zebra'); - zebra.html(res.MESSAGE_TEXT); - $(zebra.get(1)).remove(); + zebra.first().html(res.MESSAGE_TEXT); + zebra.not(':first').html(' ').prev().html(' '); } }); From fc0d2425dcc7fe63cd9ff027a555fe14671d7393 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Thu, 9 Feb 2012 22:13:34 +0100 Subject: [PATCH 243/335] [feature/ajax] Fix the alt_text ajax callback PHPBB3-10270 --- phpBB/assets/javascript/core.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 22865e744d..973d57c6ac 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -409,9 +409,8 @@ phpbb.add_ajax_callback('alt_text', function(data) { alt_text; alt_text = el.attr('data-alt-text'); - el.text(); - el.attr('data-alt-text', el.text()); - el.text(el[0].title = alt_text); + el.attr('title', alt_text); + el.text(alt_text); }); From 6ad4015a37c6bba8e3b2a8cddc816f1ba7780dfa Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 11 Feb 2012 20:13:28 +0100 Subject: [PATCH 244/335] [feature/ajax] Add a missing semicolon PHPBB3-10270 --- phpBB/assets/javascript/core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 973d57c6ac..0ff7436ca5 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -345,7 +345,7 @@ phpbb.ajaxify = function(options) { if (action) { - action = action[1] + action = action[1]; data += '&action=' + action; } else From b8a6a50f5c6a1f1f2ebcf9650e3f026561e2b060 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 11 Feb 2012 20:32:44 +0100 Subject: [PATCH 245/335] [feature/ajax] Rename exception to filter PHPBB3-10270 --- phpBB/assets/javascript/core.js | 10 +++++----- phpBB/styles/prosilver/template/ajax.js | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 0ff7436ca5..2f1a19c682 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -336,7 +336,7 @@ phpbb.ajaxify = function(options) { // If the element is a form, POST must be used and some extra data must // be taken from the form. - var run_exception = (typeof options.exception === 'function'); + var run_filter = (typeof options.filter === 'function'); if (is_form) { action = /action\[([a-z]+)\]/.exec(this.name); @@ -353,9 +353,9 @@ phpbb.ajaxify = function(options) { data += '&' + this.name + '=' + this.value; } - // If exception function returns true, cancel the AJAX functionality, + // If filter function returns true, cancel the AJAX functionality, // and return true (meaning that the HTTP request will be sent normally). - if (run_exception && options.exception.call($this.parents('form')[0], action, data)) + if (run_filter && options.filter.call($this.parents('form')[0], action, data)) { return true; } @@ -364,9 +364,9 @@ phpbb.ajaxify = function(options) { } else { - // If exception function returns true, cancel the AJAX functionality, + // If filter function returns true, cancel the AJAX functionality, // and return true (meaning that the HTTP request will be sent normally). - if (run_exception && options.exception.call(this)) + if (run_filter && options.filter.call(this)) { return true; } diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 35e8d6c0b4..f49b0af9c6 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -68,12 +68,12 @@ $('[data-ajax]').each(function() { /** * This AJAXifies the quick-mod tools. The reason it cannot be a standard - * callback / data attribute is that it requires exceptions - some of the options + * callback / data attribute is that it requires filtering - some of the options * can be ajaxified, while others cannot. */ phpbb.ajaxify({ selector: '#quickmodform', - exception: function(act, data) { + filter: function(act, data) { var action = $('#quick-mod-select').val(); if (action === 'make_normal') From 4848d6c9e839c287de736cf3badac42e859eaa69 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Tue, 14 Feb 2012 16:51:26 +0100 Subject: [PATCH 246/335] [feature/ajax] Bind to form.submit instead of form input.click PHPBB3-10270 --- phpBB/assets/javascript/core.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 2f1a19c682..4300e7056f 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -245,17 +245,13 @@ phpbb.ajaxify = function(options) { var elements = $(options.selector), refresh = options.refresh, callback = options.callback, - is_form = elements.is('form'); + is_form = elements.is('form'), + event_name = is_form ? 'submit' : 'click'; - if (is_form) - { - elements = elements.find('input:submit'); - } - - elements.click(function() { + elements.bind(event_name, function() { var action, data, path, that = this, $this = $(this); - if ($this.attr('data-ajax') == false) + if (!$this.attr('data-ajax')) { return; } @@ -290,7 +286,7 @@ phpbb.ajaxify = function(options) { if (typeof phpbb.ajax_callbacks[callback] === 'function') { - phpbb.ajax_callbacks[callback].call(that, res, (is_form) ? act : null); + phpbb.ajax_callbacks[callback].call(that, res); } // If the server says to refresh the page, check whether the page should From de82608e6ffa5e2bc12654197b7d7bd580563ddc Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 15 Feb 2012 19:32:53 +0100 Subject: [PATCH 247/335] [feature/ajax] Refactor phpbb.ajaxify event callback PHPBB3-10270 --- phpBB/assets/javascript/core.js | 56 +++++++++++-------------- phpBB/styles/prosilver/template/ajax.js | 2 +- 2 files changed, 26 insertions(+), 32 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 4300e7056f..b42870f466 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -249,7 +249,7 @@ phpbb.ajaxify = function(options) { event_name = is_form ? 'submit' : 'click'; elements.bind(event_name, function() { - var action, data, path, that = this, $this = $(this); + var action, method, data, that = this, $this = $(this); if (!$this.attr('data-ajax')) { @@ -333,45 +333,39 @@ phpbb.ajaxify = function(options) { // If the element is a form, POST must be used and some extra data must // be taken from the form. var run_filter = (typeof options.filter === 'function'); + if (is_form) { - action = /action\[([a-z]+)\]/.exec(this.name); - data = decodeURI($this.closest('form').serialize()); - path = $this.closest('form').attr('action').replace('&', '&'); - - if (action) - { - action = action[1]; - data += '&action=' + action; - } - else - { - data += '&' + this.name + '=' + this.value; - } - - // If filter function returns true, cancel the AJAX functionality, - // and return true (meaning that the HTTP request will be sent normally). - if (run_filter && options.filter.call($this.parents('form')[0], action, data)) - { - return true; - } - phpbb.loading_alert(); - $.post(path, data, return_handler); + action = $this.attr('action').replace('&', '&'); + data = $this.serializeArray(); + method = $this.attr('method'); } else { - // If filter function returns true, cancel the AJAX functionality, - // and return true (meaning that the HTTP request will be sent normally). - if (run_filter && options.filter.call(this)) - { - return true; - } - phpbb.loading_alert(); - $.get(this.href, return_handler); + action = this.href; + data = null; + method = 'GET'; } + // If filter function returns true, cancel the AJAX functionality, + // and return true (meaning that the HTTP request will be sent normally). + if (run_filter && options.filter.call(this, data)) + { + return true; + } + + phpbb.loading_alert(); + + $.ajax({ + url: action, + type: method, + data: data, + success: return_handler + }); + return false; }); + return this; } diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index f49b0af9c6..4360dc645f 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -73,7 +73,7 @@ $('[data-ajax]').each(function() { */ phpbb.ajaxify({ selector: '#quickmodform', - filter: function(act, data) { + filter: function(data) { var action = $('#quick-mod-select').val(); if (action === 'make_normal') From 2f25173d931d00b31087913b1772b51f12623690 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 15 Feb 2012 19:38:55 +0100 Subject: [PATCH 248/335] [feature/ajax] Change filter semantics, some minor adjustments PHPBB3-10270 --- phpBB/assets/javascript/core.js | 4 ++-- phpBB/styles/prosilver/template/ajax.js | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index b42870f466..488b095b47 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -338,7 +338,7 @@ phpbb.ajaxify = function(options) { { action = $this.attr('action').replace('&', '&'); data = $this.serializeArray(); - method = $this.attr('method'); + method = $this.attr('method') || 'GET'; } else { @@ -347,7 +347,7 @@ phpbb.ajaxify = function(options) { method = 'GET'; } - // If filter function returns true, cancel the AJAX functionality, + // If filter function returns false, cancel the AJAX functionality, // and return true (meaning that the HTTP request will be sent normally). if (run_filter && options.filter.call(this, data)) { diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 4360dc645f..f82da9f70e 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -73,25 +73,25 @@ $('[data-ajax]').each(function() { */ phpbb.ajaxify({ selector: '#quickmodform', - filter: function(data) { + refresh: true, + filter: function (data) { var action = $('#quick-mod-select').val(); if (action === 'make_normal') { - return !($(this).find('select option[value="make_global"]').length); + return $(this).find('select option[value="make_global"]').length > 0; } else if (action === 'lock' || action === 'unlock') { - return false; + return true; } if (action === 'delete_topic' || action === 'make_sticky' || action === 'make_announce' || action === 'make_global') { - return false; + return true; } - return true; - }, - refresh: true + return false; + } }); From 27199bb50954e22416e64154032e08801d0fbb6d Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 15 Feb 2012 20:58:00 +0100 Subject: [PATCH 249/335] [feature/ajax] Generic error handling with a phpbb.alert box PHPBB3-10270 --- phpBB/adm/style/overall_footer.html | 2 +- phpBB/assets/javascript/core.js | 18 +++++++++++++++++- phpBB/language/en/common.php | 2 ++ .../prosilver/template/overall_footer.html | 2 +- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/phpBB/adm/style/overall_footer.html b/phpBB/adm/style/overall_footer.html index 549b6995af..dfe161fd76 100644 --- a/phpBB/adm/style/overall_footer.html +++ b/phpBB/adm/style/overall_footer.html @@ -18,7 +18,7 @@ {DEBUG_OUTPUT} -
+
 

{L_LOADING}

{L_PLEASE_WAIT}

diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 488b095b47..1faec27316 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -324,12 +324,28 @@ phpbb.ajaxify = function(options) { { phpbb.loading_alert(); data = $('
' + res.S_HIDDEN_FIELDS + '
').serialize(); - $.post(res.S_CONFIRM_ACTION, data + '&confirm=' + res.YES_VALUE, return_handler); + $.ajax({ + url: res.S_CONFIRM_ACTION, + type: 'POST', + data: data + '&confirm=' + res.YES_VALUE, + success: return_handler + }); } }, false); } } + function error_handler() + { + var alert; + + alert = phpbb.alert(dark.attr('data-ajax-error-title'), dark.attr('data-ajax-error-text')); + + dark.fadeOut(phpbb.alert_time, function() { + alert.hide(); + }); + } + // If the element is a form, POST must be used and some extra data must // be taken from the form. var run_filter = (typeof options.filter === 'function'); diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 4983aaca69..b92b915623 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -67,6 +67,8 @@ $lang = array_merge($lang, array( 'ADMINISTRATORS' => 'Administrators', 'AGE' => 'Age', 'AIM' => 'AIM', + 'AJAX_ERROR_TITLE' => 'AJAX error', + 'AJAX_ERROR_TEXT' => 'Something went wrong when processing your request.', 'ALLOWED' => 'Allowed', 'ALL_FILES' => 'All files', 'ALL_FORUMS' => 'All forums', diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html index 00de9029ec..ccc5b8b5de 100644 --- a/phpBB/styles/prosilver/template/overall_footer.html +++ b/phpBB/styles/prosilver/template/overall_footer.html @@ -25,7 +25,7 @@
{L_ACP}
-
+
 

{L_LOADING}

{L_PLEASE_WAIT}

From ea4362fc4cc89c4371d3eaadb1326676c6d2793e Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 15 Feb 2012 21:04:19 +0100 Subject: [PATCH 250/335] [feature/ajax] Use the error handler PHPBB3-10270 --- phpBB/assets/javascript/core.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 1faec27316..764bc74bce 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -328,7 +328,8 @@ phpbb.ajaxify = function(options) { url: res.S_CONFIRM_ACTION, type: 'POST', data: data + '&confirm=' + res.YES_VALUE, - success: return_handler + success: return_handler, + error: error_handler }); } }, false); @@ -341,9 +342,11 @@ phpbb.ajaxify = function(options) { alert = phpbb.alert(dark.attr('data-ajax-error-title'), dark.attr('data-ajax-error-text')); - dark.fadeOut(phpbb.alert_time, function() { - alert.hide(); - }); + setTimeout(function () { + dark.fadeOut(phpbb.alert_time, function() { + alert.hide(); + }); + }, 5000); } // If the element is a form, POST must be used and some extra data must @@ -376,7 +379,8 @@ phpbb.ajaxify = function(options) { url: action, type: method, data: data, - success: return_handler + success: return_handler, + error: error_handler }); return false; From 2f44850a28fa9121052b9db57370d8e20ec5a0aa Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Wed, 15 Feb 2012 21:16:16 +0100 Subject: [PATCH 251/335] [feature/ajax] Fix filter check, quick mod tools data-attribute PHPBB3-10270 --- phpBB/assets/javascript/core.js | 2 +- phpBB/styles/prosilver/template/viewtopic_body.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 764bc74bce..eb9798331e 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -368,7 +368,7 @@ phpbb.ajaxify = function(options) { // If filter function returns false, cancel the AJAX functionality, // and return true (meaning that the HTTP request will be sent normally). - if (run_filter && options.filter.call(this, data)) + if (run_filter && !options.filter.call(this, data)) { return true; } diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index 8559b6fd9e..1c450b0500 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -263,7 +263,7 @@ -
+
  diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html index ccc5b8b5de..1561bae26a 100644 --- a/phpBB/styles/prosilver/template/overall_footer.html +++ b/phpBB/styles/prosilver/template/overall_footer.html @@ -31,11 +31,11 @@
- +

- +

  diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css index 42f6efc5b1..855febf4aa 100644 --- a/phpBB/styles/prosilver/theme/colours.css +++ b/phpBB/styles/prosilver/theme/colours.css @@ -1074,3 +1074,17 @@ input.search { input.disabled { color: #666666; } + +/* jQuery popups +---------------------------------------- */ +.phpbb_alert { + background-color: #FFFFFF; + border-color: #999999; +} +.phpbb_alert .alert_close { + background-image: url("./images/alert_close.png"); +} +#darken { + background-color: #000000; +} + diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index 3b0e7899cb..31015b28f9 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -591,8 +591,7 @@ li.pagination { /* jQuery popups ---------------------------------------- */ .phpbb_alert { - background-color: #FFFFFF; - border: 1px solid #999999; + border: 1px solid transparent; position: fixed; display: none; top: 100px; @@ -603,10 +602,19 @@ li.pagination { padding: 0 25px 20px 25px; } -.phpbb_alert img.alert_close { +.phpbb_alert .alert_close { + display: block; float: right; + width: 16px; + height: 16px; + overflow: hidden; + text-decoration: none !important; + background: transparent none 0 0 no-repeat; margin-top: -7px; - margin-right: -30px; + margin-right: -31px; +} +.phpbb_alert .alert_close:hover { + background-position: 0 -16px; } .phpbb_alert p { @@ -624,7 +632,6 @@ li.pagination { top: 0; width: 100%; height: 100%; - background-color: #000000; opacity: 0.5; } diff --git a/phpBB/styles/prosilver/theme/images/alert_close.png b/phpBB/styles/prosilver/theme/images/alert_close.png index 123ac4ac901f817080d565efbf952886f2177b5e..79750a013c5db627a14bf3d57edc8f8e3a477046 100644 GIT binary patch literal 2097 zcmaJ?YgAKL7LJ0*E65`_OVRcktP$(m;m=}RWa0BUlnFI$KFgT?|u4kiA3~!|za!^XLV766|9vif#KejaL{7)!6A}_|31pm15rZevXf%TciR7k7xWS211XQ|7 zVaFu}76kJZVmTs~Ndbc*7%e-9FtPed|G0ug{y|m>zi*SiVR$7d#}jb`!`M;+DD?ERrEISR|7J zeqkN}7vzhjhWH(x%cXOqFak>X5QoLY>J@Nev4GC@B#`|*{mC94R5FpsCi<{wRDTMY z!ydg(~-9>ey7ZS}zi<3m!t+ZB3SKgt9WQ7Gdw4$Ft9d~}4j zFW?e{Nv?m9pHdj_97b)G@1|0l9`^7s(F1|DU%OVV^zp?&GlP5Zhxvso<-*BtV`j90+^+Kq+rZ^rVgVBNYDp_VD1tDjYM!MYi*vF#7t(PL0l z)DyZYi6cAnqoAfJ+sj$iJv7vitlLk2akMevXSk}Y?AyJOkta(^u++rfgKD3$rw7cKB`MuM-owP8{DYdB?iOn(y5+F}JX2vgz#XG`}8n#b{t^MpOj~ zg+kWF*_X97H56K5&}Lh+f9sl>d^#RHFta*$?i_(mKY8nxM|XGkwh+v4o5;OgTKnnc z(t&~Y_IBgXf1jGN&Iw?#NDM}n-5HHWV`FJ@v3LC2uj}dxI1;{9<)g_%Ez!i`;!Br| znM`Ij^a@jO_Uv(;ZhyqJ-C%Rg;?5DqCY$?$XqHO_x$=jU7ObcxOv{#IgZ&VT-z={VJW37mK0GC+~Yb-~OSGgC|l zZr!!dj?z>Fuz&h~MEzxs&zgQg<3&zW3AgzLh1+4IKqzYtm@Vp3jR!(7oD}PFIVLjH zzWr@oYYbJz;Z3@9K1=N#x1V{!$2%>0ev*Z*jE<<-YCWq=PgvMqn?3dB6pvt;H{Up{ zd7_DioBR6uGJWm)QpUF(*kVuz0!+ph1Beywao>^UFx1wac`1|_6gs6iqg>D5F;_n_sqUFU+rFJp-wFwhQkVD7JgIw13D@SeKaZ>)ZJd4< z+yAO-gF4Z=JHFzfN8W7Hfby#=Ocj}k59M^l>lQ38kK?L8?&YOrwf8gR`5pnzrJk07 z9h>HqX7}&L$Wx~68AZB`wWs)RGd{E4H?(8tzjDos27za(tedB`w-v2!Ti0L7i8%Kg z{pab)fVr32!GH^D*`%P6vmxhA_uiJxkAp>NlObLf(dO&-mrdKxoIaINP)J#o)3)m4 zP&-o_>eMz2#Z3YgxgTUO}hquind8 z6ZFON6Q7E3^pnjtJ7$l0Z`TYmj0WTG-oDUjK}#HF0P-Ihb32c&Kw&oWB|A*ZcNl)+ N9Ci?^(l_eZe*jUwWY7Qr delta 658 zcmV;D0&V@V5S;~(7k>~41^@s6AM^iV00004b3#c}2nYxWddbVG7wVRUJ4ZXi@?ZDjy5H7_|YF)`g4T#x_&0338hSaefw zW^{L9a%BKPWN%_+AVz6&Wp{6KYjYq&Q#En5<2C>Q0rp8mL4Q;@jeV25Ym-qJ#(&37 zf)M#!98zOSz%;#BX>^rtb*W8B92y%db#bbsi+@171grt4L>-G+B7|77hgqmX^LNaE}%5M5AMc z{ixMyGVS%&6kH!Ddo2*qB-^&dw(SAo+1Z)iTb3o0PN%620;{V(du7|UEs>2439qkf zlYBle*9=2)xtun65{Xy}?xA4f;mV2*G#U+=@%co7gnxoTDHIBF)!`5Yl1L;puUIUK zf>$WGG2Hv{@v%1Pt#~{>G7kkQ6wK}J?v4aa)70V_pHJHD_BexsOTh2blaqlPsZ=UF z4u=6S41-ds#G_D%PN$vg%aupkQL>E@=+ zp2=kL3V;4Ts@wDP2c~K2U@R7sXIonXgMF~PES6>IvnjVbryrC8W7_MjwOXx_KF1-M zOny}GX82Rw_b)E~Xf~S{iqq+INx01E&B07*qoM6N<$f_tGUn*aa+ From 07826d6679d7edb738024c2e759247e82574a8a3 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 00:13:08 +0200 Subject: [PATCH 259/335] [feature/ajax] Remove quick-reply AJAX handling until we have something good The current implementation is not very user friendly, lots of things flashing in the user's face. We can re-consider AJAX when we have a decent solution. PHPBB3-10270 --- phpBB/styles/prosilver/template/ajax.js | 7 ------- phpBB/styles/prosilver/template/quickreply_editor.html | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 9ae7679e3e..3ad03f1539 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -24,13 +24,6 @@ phpbb.add_ajax_callback('post_approve', function(res) { }); }); -// This callback handles the removal of the quick reply form. -phpbb.add_ajax_callback('qr-submit', function() { - $(this).css('pointer-events', 'none').fadeOut(function() { - $(this).remove(); - }); -}); - // This removes the parent row of the link or form that fired the callback. phpbb.add_ajax_callback('row_delete', function() { $(this).parents('tr').remove(); diff --git a/phpBB/styles/prosilver/template/quickreply_editor.html b/phpBB/styles/prosilver/template/quickreply_editor.html index 3eff2a2bd6..4cd5eedd3e 100644 --- a/phpBB/styles/prosilver/template/quickreply_editor.html +++ b/phpBB/styles/prosilver/template/quickreply_editor.html @@ -1,4 +1,4 @@ - +

{L_QUICKREPLY}

From 9b971c9fb17f284cda413eacc6665f5cdf837cbd Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 00:59:27 +0200 Subject: [PATCH 260/335] [feature/ajax] Replace static call to phpbb_request with OO PHPBB3-10270 --- phpBB/includes/acp/acp_modules.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_modules.php b/phpBB/includes/acp/acp_modules.php index 427a3e1e71..e7cd057361 100644 --- a/phpBB/includes/acp/acp_modules.php +++ b/phpBB/includes/acp/acp_modules.php @@ -375,7 +375,8 @@ class acp_modules { if ($request->is_ajax()) { - phpbb_json_response::send(array( + $json_response = new phpbb_json_response(); + $json_response->send(array( 'MESSAGE_TITLE' => $user->lang('ERROR'), 'MESSAGE_TEXT' => implode('
', $errors), )); From d3e7744dd6968b941fb3216ee2a989ed6a0c2ba1 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 00:59:49 +0200 Subject: [PATCH 261/335] [feature/ajax] Remove not working module enable/disable ajax code PHPBB3-10270 --- phpBB/adm/style/acp_modules.html | 2 +- phpBB/adm/style/ajax.js | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/phpBB/adm/style/acp_modules.html b/phpBB/adm/style/acp_modules.html index 380a037977..6c4645e80c 100644 --- a/phpBB/adm/style/acp_modules.html +++ b/phpBB/adm/style/acp_modules.html @@ -148,7 +148,7 @@ {modules.MODULE_IMAGE} {modules.MODULE_TITLE} [{L_HIDDEN_MODULE}] -  {L_DISABLE}{L_ENABLE}  +  {L_DISABLE}{L_ENABLE}  {ICON_MOVE_UP_DISABLED} diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 0c00efee1b..fd2f7a2122 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -89,7 +89,9 @@ phpbb.add_ajax_callback('forum_up', function() { phpbb.add_ajax_callback('activate_deactivate', function(res) { var el = $(this), new_href = el.attr('href'); + el.text(res.text); + if (new_href.indexOf('deactivate') !== -1) { new_href = new_href.replace('deactivate', 'activate') @@ -98,6 +100,7 @@ phpbb.add_ajax_callback('activate_deactivate', function(res) { { new_href = new_href.replace('activate', 'deactivate') } + el.attr('href', new_href); }); From ac320fad0599184f458786455cc441010d6f6d35 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 31 Mar 2012 01:57:10 +0300 Subject: [PATCH 262/335] [ticket/10270] Alter background colors for posts Change background colors for posts after deleted post PHPBB3-10270 --- phpBB/styles/prosilver/template/ajax.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index 3ad03f1539..cc886c42b1 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -10,7 +10,14 @@ phpbb.add_ajax_callback('post_delete', function() { if (el.attr('data-refresh') === undefined) { post_id = el[0].href.split('&p=')[1]; - el.parents('#p' + post_id).css('pointer-events', 'none').fadeOut(function() { + var post = el.parents('#p' + post_id).css('pointer-events', 'none'); + if (post.hasClass('bg1') || post.hasClass('bg2')) + { + var posts1 = post.nextAll('.bg1'); + post.nextAll('.bg2').removeClass('bg2').addClass('bg1'); + posts1.removeClass('bg1').addClass('bg2'); + } + post.fadeOut(function() { $(this).remove(); }); } From 8138103c6b5695b07c2f98d7ff9942e22903591a Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 01:09:41 +0200 Subject: [PATCH 263/335] [feature/ajax] Send correct activate/deactivate JSON response in acp_profile PHPBB3-10270 --- phpBB/includes/acp/acp_profile.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index 511148baf9..3ffffd3047 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -242,6 +242,15 @@ class acp_profile $db->sql_freeresult($result); add_log('admin', 'LOG_PROFILE_FIELD_ACTIVATE', $field_ident); + + if ($request->is_ajax()) + { + $json_response = new phpbb_json_response(); + $json_response->send(array( + 'text' => $user->lang('DEACTIVATE'), + )); + } + trigger_error($user->lang['PROFILE_FIELD_ACTIVATED'] . adm_back_link($this->u_action)); break; @@ -266,7 +275,16 @@ class acp_profile $field_ident = (string) $db->sql_fetchfield('field_ident'); $db->sql_freeresult($result); + if ($request->is_ajax()) + { + $json_response = new phpbb_json_response(); + $json_response->send(array( + 'text' => $user->lang('ACTIVATE'), + )); + } + add_log('admin', 'LOG_PROFILE_FIELD_DEACTIVATE', $field_ident); + trigger_error($user->lang['PROFILE_FIELD_DEACTIVATED'] . adm_back_link($this->u_action)); break; From ef03f8d0536033d1ef4739c5884d1a1f919618bd Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 01:15:13 +0200 Subject: [PATCH 264/335] [feature/ajax] Fix acp_styles activate_deactivate ajax callback name PHPBB3-10270 --- phpBB/adm/style/acp_styles.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/adm/style/acp_styles.html b/phpBB/adm/style/acp_styles.html index a166623f89..3532e8c7d9 100644 --- a/phpBB/adm/style/acp_styles.html +++ b/phpBB/adm/style/acp_styles.html @@ -288,7 +288,7 @@ - {installed.L_STYLE_ACT_DEACT} | + {installed.L_STYLE_ACT_DEACT} | {installed.S_ACTIONS} From 4a5172c9f74047c5917a0356f8537da2fe1550f4 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 01:17:35 +0200 Subject: [PATCH 265/335] [feature/ajax] Unify phpbb_json_response instantiation PHPBB3-10270 --- phpBB/includes/acp/acp_modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_modules.php b/phpBB/includes/acp/acp_modules.php index e7cd057361..8528dc91c4 100644 --- a/phpBB/includes/acp/acp_modules.php +++ b/phpBB/includes/acp/acp_modules.php @@ -375,7 +375,7 @@ class acp_modules { if ($request->is_ajax()) { - $json_response = new phpbb_json_response(); + $json_response = new phpbb_json_response; $json_response->send(array( 'MESSAGE_TITLE' => $user->lang('ERROR'), 'MESSAGE_TEXT' => implode('
', $errors), From 41d8a777dc73350a2f3bba6aaae2686921110d08 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 01:26:04 +0200 Subject: [PATCH 266/335] [feature/ajax] Add entirely unrelated but nice newlines PHPBB3-10270 --- phpBB/includes/acp/acp_styles.php | 1 + phpBB/includes/functions_display.php | 1 + 2 files changed, 2 insertions(+) diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index a241dd3d10..26939080bc 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -185,6 +185,7 @@ inherit_from = {INHERIT_FROM} WHERE forum_style = ' . $style_id; $db->sql_query($sql); } + if ($request->is_ajax()) { $json_response = new phpbb_json_response; diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 9335cabc15..18db64cc68 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -273,6 +273,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod markread('topics', $forum_ids); $message = sprintf($user->lang['RETURN_FORUM'], '', ''); meta_refresh(3, $redirect); + trigger_error($user->lang['FORUMS_MARKED'] . '

' . $message); } else From b42e10df28742ba5a68d15e740e33aa7f8260f40 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 01:35:28 +0200 Subject: [PATCH 267/335] [feature/ajax] Remove strange non-breaking spaces from approve button The viewtopic inline approve/disapprove buttons for posts had spaces. PHPBB3-10270 --- phpBB/styles/prosilver/template/viewtopic_body.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html index 1c450b0500..3c551b3d52 100644 --- a/phpBB/styles/prosilver/template/viewtopic_body.html +++ b/phpBB/styles/prosilver/template/viewtopic_body.html @@ -138,8 +138,8 @@

- {UNAPPROVED_IMG} {L_POST_UNAPPROVED}   -   + {UNAPPROVED_IMG} {L_POST_UNAPPROVED} + {S_FORM_TOKEN} From a7045e65724481002e232a7d143b7cc2ed6acb3a Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 30 Mar 2012 21:43:00 -0400 Subject: [PATCH 268/335] [feature/qrpreview] Preview from Quick Reply PHPBB3-10726 --- phpBB/language/en/viewtopic.php | 2 +- phpBB/posting.php | 2 +- phpBB/styles/prosilver/template/ajax.js | 11 +++++++++++ .../styles/prosilver/template/quickreply_editor.html | 4 ++-- .../styles/subsilver2/template/quickreply_editor.html | 4 ++-- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/phpBB/language/en/viewtopic.php b/phpBB/language/en/viewtopic.php index 1460490672..184f88ed3c 100644 --- a/phpBB/language/en/viewtopic.php +++ b/phpBB/language/en/viewtopic.php @@ -62,7 +62,7 @@ $lang = array_merge($lang, array( 'FILE_NOT_FOUND_404' => 'The file %s does not exist.', 'FORK_TOPIC' => 'Copy topic', - 'FULL_EDITOR' => 'Full Editor', + 'FULL_EDITOR' => 'Full Editor & Preview', 'LINKAGE_FORBIDDEN' => 'You are not authorised to view, download or link from/to this site.', 'LOGIN_NOTIFY_TOPIC' => 'You have been notified about this topic, please login to view it.', diff --git a/phpBB/posting.php b/phpBB/posting.php index 56fb7832f2..71ba353e89 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -38,7 +38,7 @@ $load = (isset($_POST['load'])) ? true : false; $delete = (isset($_POST['delete'])) ? true : false; $cancel = (isset($_POST['cancel']) && !isset($_POST['save'])) ? true : false; -$refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['full_editor']) || isset($_POST['cancel_unglobalise']) || $save || $load) ? true : false; +$refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['cancel_unglobalise']) || $save || $load) ? true : false; $mode = ($delete && !$preview && !$refresh && $submit) ? 'delete' : request_var('mode', ''); $error = $post_data = array(); diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index cc886c42b1..54f34e4204 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -66,6 +66,17 @@ $('[data-ajax]').each(function() { }); +/** + * This simply appends #preview to the action of the + * QR action when you click the Full Editor & Preview button + */ +$('#qr_full_editor').click(function() { + $('#qr_postform').attr('action', function(i, val) { + return val + '#preview'; + }); +}); + + /** * This AJAXifies the quick-mod tools. The reason it cannot be a standard diff --git a/phpBB/styles/prosilver/template/quickreply_editor.html b/phpBB/styles/prosilver/template/quickreply_editor.html index 4cd5eedd3e..c7d998eca5 100644 --- a/phpBB/styles/prosilver/template/quickreply_editor.html +++ b/phpBB/styles/prosilver/template/quickreply_editor.html @@ -14,8 +14,8 @@

{S_FORM_TOKEN} {QR_HIDDEN_FIELDS} -   -   +   +  
diff --git a/phpBB/styles/subsilver2/template/quickreply_editor.html b/phpBB/styles/subsilver2/template/quickreply_editor.html index de5017280c..4c3f7a3d0b 100644 --- a/phpBB/styles/subsilver2/template/quickreply_editor.html +++ b/phpBB/styles/subsilver2/template/quickreply_editor.html @@ -14,8 +14,8 @@ -   - +   + {S_FORM_TOKEN} {QR_HIDDEN_FIELDS} From 0c8d0a82de69277d090907618eee71f815f12436 Mon Sep 17 00:00:00 2001 From: David King Date: Fri, 30 Mar 2012 21:46:20 -0400 Subject: [PATCH 269/335] [feature/qrpreview] Add id qr_postform to prosilver QR PHPBB3-10726 --- phpBB/styles/prosilver/template/quickreply_editor.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/template/quickreply_editor.html b/phpBB/styles/prosilver/template/quickreply_editor.html index c7d998eca5..a08b5dc3cc 100644 --- a/phpBB/styles/prosilver/template/quickreply_editor.html +++ b/phpBB/styles/prosilver/template/quickreply_editor.html @@ -1,4 +1,4 @@ - +

{L_QUICKREPLY}

From 3c21a8e21efaa46bdd2a3eacfd748047cf322137 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Sat, 31 Mar 2012 09:27:15 +0100 Subject: [PATCH 270/335] [ticket/10736] Changing travis so it installs composer.phar to phpBB/ PHPBB3-10736 --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index f21928dd37..82f7d27e35 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,8 +13,10 @@ before_script: - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS phpbb_tests;'; fi" - sh -c "if [ '$TRAVIS_PHP_VERSION' = '5.2' ]; then pear install --force phpunit/DbUnit; else pyrus install --force phpunit/DbUnit; fi" - phpenv rehash + - cd phpBB - curl -s http://getcomposer.org/installer | php - php composer.phar install + - cd ../ script: - phpunit --configuration travis/phpunit-$DB-travis.xml From fadeefe7709bd4dcec4cd1166efec130de06eb8f Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sat, 31 Mar 2012 15:18:49 +0200 Subject: [PATCH 271/335] [ticket/10736] Run composer in phing builds PHPBB3-10736 --- build/build.xml | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/build/build.xml b/build/build.xml index 3d8d3de640..1646c10a08 100644 --- a/build/build.xml +++ b/build/build.xml @@ -11,9 +11,9 @@ - - - + + + @@ -43,7 +43,19 @@ - + + + + + + + - + + + + + + From e13e4d92061df3a49cc5dbf7724f232ab927018a Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 31 Mar 2012 16:33:30 +0300 Subject: [PATCH 272/335] [feature/merging-style-components] Updating styles in coding guidelines Updating styles section in coding guidelines PHPBB3-10632 --- phpBB/docs/coding-guidelines.html | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/phpBB/docs/coding-guidelines.html b/phpBB/docs/coding-guidelines.html index f8aaf77441..e6dfe579e9 100644 --- a/phpBB/docs/coding-guidelines.html +++ b/phpBB/docs/coding-guidelines.html @@ -1144,15 +1144,19 @@ append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;

3.i. Style Config Files

-

Style cfg files are simple name-value lists with the information necessary for installing a style. Similar cfg files exist for templates, themes and imagesets. These follow the same principle and will not be introduced individually. Styles can use installed components by using the required_theme/required_template/required_imageset entries. The important part of the style configuration file is assigning an unique name.

+

Style cfg files are simple name-value lists with the information necessary for installing a style. The important part of the style configuration file is assigning an unique name.

-        # General Information about this style
-        name = prosilver_duplicate
-        copyright = © phpBB Group, 2007
-        version = 3.0.3
-        required_template = prosilver
-        required_theme = prosilver
-        required_imageset = prosilver
+# General Information about this style
+name = prosilver_duplicate
+copyright = © phpBB Group, 2007
+version = 3.1.0
+
+# Defining a different template bitfield
+# template_bitfield = lNg=
+
+# Parent style
+# Set value to empty or to this style's name if this style does not have a parent style
+parent = prosilver
 	

3.2. General Styling Rules

Templates should be produced in a consistent manner. Where appropriate they should be based off an existing copy, e.g. index, viewforum or viewtopic (the combination of which implement a range of conditional and variable forms). Please also note that the indentation and coding guidelines also apply to templates where possible.

@@ -1175,7 +1179,7 @@ append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;

Row colours/classes are now defined by the template, use an IF S_ROW_COUNT switch, see viewtopic or viewforum for an example.

-

Remember block level ordering is important ... while not all pages validate as XHTML 1.0 Strict compliant it is something we're trying to work on.

+

Remember block level ordering is important.

Use a standard cellpadding of 2 and cellspacing of 0 on outer tables. Inner tables can vary from 0 to 3 or even 4 depending on the need.

@@ -1243,13 +1247,13 @@ append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;

A bit later loops will be explained further. To not irritate you we will explain conditionals as well as other statements first.

Including files

-

Something that existed in 2.0.x which no longer exists in 3.0.x is the ability to assign a template to a variable. This was used (for example) to output the jumpbox. Instead (perhaps better, perhaps not but certainly more flexible) we now have INCLUDE. This takes the simple form:

+

Something that existed in 2.0.x which no longer exists in 3.x is the ability to assign a template to a variable. This was used (for example) to output the jumpbox. Instead (perhaps better, perhaps not but certainly more flexible) we now have INCLUDE. This takes the simple form:

 <!-- INCLUDE filename -->
 
-

You will note in the 3.0 templates the major sources start with <!-- INCLUDE overall_header.html --> or <!-- INCLUDE simple_header.html -->, etc. In 2.0.x control of "which" header to use was defined entirely within the code. In 3.0.x the template designer can output what they like. Note that you can introduce new templates (i.e. other than those in the default set) using this system and include them as you wish ... perhaps useful for a common "menu" bar or some such. No need to modify loads of files as with 2.0.x.

+

You will note in the 3.x templates the major sources start with <!-- INCLUDE overall_header.html --> or <!-- INCLUDE simple_header.html -->, etc. In 2.0.x control of "which" header to use was defined entirely within the code. In 3.x the template designer can output what they like. Note that you can introduce new templates (i.e. other than those in the default set) using this system and include them as you wish ... perhaps useful for a common "menu" bar or some such. No need to modify loads of files as with 2.0.x.

Added in 3.0.6 is the ability to include a file using a template variable to specify the file, this functionality only works for root variables (i.e. not block variables).

@@ -1281,7 +1285,7 @@ append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;
 

it will be included and executed inline.

A note, it is very much encouraged that template designers do not include PHP. The ability to include raw PHP was introduced primarily to allow end users to include banner code, etc. without modifying multiple files (as with 2.0.x). It was not intended for general use ... hence www.phpbb.com will not make available template sets which include PHP. And by default templates will have PHP disabled (the admin will need to specifically activate PHP for a template).

Conditionals/Control structures

-

The most significant addition to 3.0.x are conditions or control structures, "if something then do this else do that". The system deployed is very similar to Smarty. This may confuse some people at first but it offers great potential and great flexibility with a little imagination. In their most simple form these constructs take the form:

+

The most significant addition to 3.x are conditions or control structures, "if something then do this else do that". The system deployed is very similar to Smarty. This may confuse some people at first but it offers great potential and great flexibility with a little imagination. In their most simple form these constructs take the form:

 <!-- IF expr -->
@@ -1352,7 +1356,7 @@ div
 <!-- ENDIF -->
 
-

Each statement will be tested in turn and the relevant output generated when a match (if a match) is found. It is not necessary to always use ELSEIF, ELSE can be used alone to match "everything else".

So what can you do with all this? Well take for example the colouration of rows in viewforum. In 2.0.x row colours were predefined within the source as either row color1, row color2 or row class1, row class2. In 3.0.x this is moved to the template, it may look a little daunting at first but remember control flows from top to bottom and it's not too difficult:

+

Each statement will be tested in turn and the relevant output generated when a match (if a match) is found. It is not necessary to always use ELSEIF, ELSE can be used alone to match "everything else".

So what can you do with all this? Well take for example the colouration of rows in viewforum. In 2.0.x row colours were predefined within the source as either row color1, row color2 or row class1, row class2. In 3.x this is moved to the template, it may look a little daunting at first but remember control flows from top to bottom and it's not too difficult:

 <table>

From bc46cfd6e5a6dd0a759c610e4654a7fad47db130 Mon Sep 17 00:00:00 2001
From: Igor Wiedler 
Date: Sat, 31 Mar 2012 15:48:12 +0200
Subject: [PATCH 273/335] [feature/merging-style-components] Fix notices in
 acp_styles

PHPBB3-10632
---
 phpBB/includes/acp/acp_styles.php | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php
index acd010b77e..123725ef1d 100644
--- a/phpBB/includes/acp/acp_styles.php
+++ b/phpBB/includes/acp/acp_styles.php
@@ -228,7 +228,7 @@ class acp_styles
 	*/
 	function action_delete_confirmed($ids, $delete_files)
 	{
-		global $db, $user, $cache;
+		global $db, $user, $cache, $config;
 
 		$default = $config['default_style'];
 		$deleted = array();
@@ -556,6 +556,7 @@ class acp_styles
 		$users = $this->get_users();
 		
 		// Add users counter to rows
+		$style['_users'] = array();
 		foreach ($styles as &$style)
 		{
 			$style['_users'] = isset($users[$style['style_id']]) ? $users[$style['style_id']] : 0;
@@ -1288,7 +1289,7 @@ class acp_styles
 	function default_bitfield()
 	{
 		static $value;
-		if(isset($value))
+		if (isset($value))
 		{
 			return $value;
 		}

From 961199755200668790b243447eac6bf3374b0bb6 Mon Sep 17 00:00:00 2001
From: Vjacheslav Trushkin 
Date: Sat, 31 Mar 2012 17:04:17 +0300
Subject: [PATCH 274/335] [feature/merging-style-components] Fixing few errors
 in acp_styles

Fixing notices and usability issues

PHPBB3-10632
---
 phpBB/includes/acp/acp_styles.php | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php
index 123725ef1d..5ff79b0c19 100644
--- a/phpBB/includes/acp/acp_styles.php
+++ b/phpBB/includes/acp/acp_styles.php
@@ -181,10 +181,6 @@ class acp_styles
 			trigger_error($user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING);
 		}
 		$message = implode('
', $messages); - if (count($messages) == 1 && $last_installed !== false) - { - $message .= '

' . sprintf($user->lang['STYLE_INSTALLED_EDIT_DETAILS'], $this->u_base_action . '&mode=style&action=details&id=' . $last_installed); - } $message .= '

' . sprintf($user->lang['STYLE_INSTALLED_RETURN_STYLES'], $this->u_base_action . '&mode=style'); $message .= '

' . sprintf($user->lang['STYLE_INSTALLED_RETURN_UNINSTALLED'], $this->u_base_action . '&mode=install'); trigger_error($message, E_USER_NOTICE); @@ -556,7 +552,6 @@ class acp_styles $users = $this->get_users(); // Add users counter to rows - $style['_users'] = array(); foreach ($styles as &$style) { $style['_users'] = isset($users[$style['style_id']]) ? $users[$style['style_id']] : 0; @@ -892,7 +887,7 @@ class acp_styles // Additional data 'DEFAULT' => ($style['style_id'] && $style['style_id'] == $config['default_style']), - 'USERS' => $style['_users'], + 'USERS' => (isset($style['_users'])) ? $style['_users'] : '', 'LEVEL' => $level, 'PADDING' => (4 + 16 * $level), 'SHOW_COPYRIGHT' => ($style['style_id']) ? false : true, From 360312f599edd852e14fcd162552e19dd2d278a6 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 31 Mar 2012 17:38:30 +0300 Subject: [PATCH 275/335] [feature/merging-style-components] Initializing locator and provider separately Moving locator and path provider initialization out of style class PHPBB3-10632 --- phpBB/common.php | 4 +++- phpBB/includes/bbcode.php | 6 ++++-- phpBB/includes/functions_messenger.php | 4 +++- phpBB/includes/style/style.php | 16 ++++++---------- phpBB/install/index.php | 4 +++- tests/template/template_inheritance_test.php | 4 +++- tests/template/template_test_case.php | 6 +++++- 7 files changed, 27 insertions(+), 17 deletions(-) diff --git a/phpBB/common.php b/phpBB/common.php index 3f039e49c0..1e3f787611 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -124,7 +124,9 @@ set_config_count(null, null, null, $config); $phpbb_extension_manager = new phpbb_extension_manager($db, EXT_TABLE, $phpbb_root_path, ".$phpEx", $cache->get_driver()); // Initialize style -$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_extension_manager); +$phpbb_style_resource_locator = new phpbb_style_resource_locator(); +$phpbb_style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider()); +$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider); $template = $style->template; $phpbb_subscriber_loader = new phpbb_event_extension_subscriber_loader($phpbb_dispatcher, $phpbb_extension_manager); diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index 5e3bfed5ec..2cae38022e 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -132,11 +132,13 @@ class bbcode { $this->template_bitfield = new bitfield($user->theme['bbcode_bitfield']); - $style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_extension_manager); + $style_resource_locator = new phpbb_style_resource_locator(); + $style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider()); + $style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, $style_path_provider); $style->set_style(); $template = $style->template; $template->set_filenames(array('bbcode.html' => 'bbcode.html')); - $this->template_filename = $style->locator->get_source_file_for_handle('bbcode.html'); + $this->template_filename = $style_resource_locator->get_source_file_for_handle('bbcode.html'); } $bbcode_ids = $rowset = $sql = array(); diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index a5e7ad75ca..4d076a7957 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -208,7 +208,9 @@ class messenger // tpl_msg now holds a template object we can use to parse the template file if (!isset($this->tpl_msg[$template_lang . $template_file])) { - $this->tpl_msg[$template_lang . $template_file] = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_extension_manager); + $style_resource_locator = new phpbb_style_resource_locator(); + $style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider()); + $this->tpl_msg[$template_lang . $template_file] = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, $style_path_provider); $stl = &$this->tpl_msg[$template_lang . $template_file]; $tpl = $stl->template; diff --git a/phpBB/includes/style/style.php b/phpBB/includes/style/style.php index 5dee0a138c..265a45eca7 100644 --- a/phpBB/includes/style/style.php +++ b/phpBB/includes/style/style.php @@ -50,9 +50,8 @@ class phpbb_style /** * Style resource locator * @var phpbb_style_resource_locator - * This item is temporary public, until locate() function is implemented */ - public $locator; + private $locator; /** * Style path provider @@ -65,20 +64,17 @@ class phpbb_style * * @param string $phpbb_root_path phpBB root path * @param user $user current user - * @param phpbb_extension_manager $phpbb_extension_manager extension manager. Set it to false if extension manager should not be used. + * @param phpbb_style_resource_locator $locator style resource locator + * @param phpbb_style_path_provider $provider style path provider */ - public function __construct($phpbb_root_path, $phpEx, $config, $user, $phpbb_extension_manager = false) + public function __construct($phpbb_root_path, $phpEx, $config, $user, phpbb_style_resource_locator $locator, phpbb_style_path_provider_interface $provider) { $this->phpbb_root_path = $phpbb_root_path; $this->phpEx = $phpEx; $this->config = $config; $this->user = $user; - $this->locator = new phpbb_style_resource_locator(); - $this->provider = new phpbb_style_path_provider(); - if ($phpbb_extension_manager !== false) - { - $this->provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, $this->provider); - } + $this->locator = $locator; + $this->provider = $provider; $this->template = new phpbb_style_template($this->phpbb_root_path, $this->phpEx, $this->config, $this->user, $this->locator, $this->provider); } diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 49f7847489..fdce7234e5 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -202,7 +202,9 @@ $config = new phpbb_config(array( 'load_tplcompile' => '1' )); -$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, false); +$phpbb_style_resource_locator = new phpbb_style_resource_locator(); +$phpbb_style_path_provider = new phpbb_style_path_provider(); +$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider); $style->set_ext_dir_prefix('adm/'); $style->set_custom_style('admin', '../adm/style', ''); $template = $style->template; diff --git a/tests/template/template_inheritance_test.php b/tests/template/template_inheritance_test.php index f7bd38cc08..aa527a3eb5 100644 --- a/tests/template/template_inheritance_test.php +++ b/tests/template/template_inheritance_test.php @@ -71,7 +71,9 @@ class phpbb_template_template_inheritance_test extends phpbb_template_template_t $this->template_path = dirname(__FILE__) . '/templates'; $this->parent_template_path = dirname(__FILE__) . '/parent_templates'; - $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, false); + $this->style_resource_locator = new phpbb_style_path_provider(); + $this->style_provider = new phpbb_style_path_provider(); + $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider); $this->style->set_custom_style('tests', array($this->template_path, $this->parent_template_path), ''); $this->template = $this->style->template; } diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index 5884225a54..f324736ba4 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -15,6 +15,8 @@ class phpbb_template_template_test_case extends phpbb_test_case protected $style; protected $template; protected $template_path; + protected $style_resource_locator; + protected $style_provider; // Keep the contents of the cache for debugging? const PRESERVE_CACHE = true; @@ -62,7 +64,9 @@ class phpbb_template_template_test_case extends phpbb_test_case $config = new phpbb_config(array_merge($defaults, $new_config)); $this->template_path = dirname(__FILE__) . '/templates'; - $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, false); + $this->style_resource_locator = new phpbb_style_path_provider(); + $this->style_provider = new phpbb_style_path_provider(); + $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider); $this->style->set_custom_style('tests', $this->template_path, ''); $this->template = $this->style->template; } From 0540509f145d7eb9ba1fd4468399b48edcf46d23 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 31 Mar 2012 17:58:17 +0300 Subject: [PATCH 276/335] [feature/merging-style-components] Renaming "delete" to "uninstall" for styles Changing from "delete" to "uninstall" in acp_styles to avoid confusing users PHPBB3-10632 --- phpBB/includes/acp/acp_styles.php | 64 +++++++++++++++---------------- phpBB/language/en/acp/styles.php | 7 +++- 2 files changed, 37 insertions(+), 34 deletions(-) diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 5ff79b0c19..9345ad470a 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -45,7 +45,7 @@ class acp_styles $this->mode = $mode; $action = $request->variable('action', ''); - $post_actions = array('install', 'activate', 'deactivate', 'delete'); + $post_actions = array('install', 'activate', 'deactivate', 'uninstall'); foreach ($post_actions as $key) { if (isset($_POST[$key])) @@ -70,8 +70,8 @@ class acp_styles case 'install': $this->action_install(); return; - case 'delete': - $this->action_delete(); + case 'uninstall': + $this->action_uninstall(); return; case 'activate': $this->action_activate(); @@ -187,47 +187,47 @@ class acp_styles } /** - * Confirm styles deletion + * Confirm styles removal */ - function action_delete() + function action_uninstall() { global $user, $config, $template, $request; - // Get list of styles to delete + // Get list of styles to uninstall $ids = $this->request_vars('id', 0, true); // Check if confirmation box was submitted if (confirm_box(true)) { - // Delete - $this->action_delete_confirmed($ids, $request->variable('confirm_delete_files', false)); + // Uninstall + $this->action_uninstall_confirmed($ids, $request->variable('confirm_delete_files', false)); return; } // Confirm box $s_hidden = build_hidden_fields(array( - 'action' => 'delete', + 'action' => 'uninstall', 'ids' => $ids )); $template->assign_var('S_CONFIRM_DELETE', true); - confirm_box(false, $user->lang['CONFIRM_DELETE_STYLES'], $s_hidden, 'acp_styles.html'); + confirm_box(false, $user->lang['CONFIRM_UNINSTALL_STYLES'], $s_hidden, 'acp_styles.html'); // Canceled - show styles list $this->frontend(); } /** - * Delete styles(s) + * Uninstall styles(s) * * @param array $ids List of style IDs * @param bool $delete_files If true, script will attempt to remove files for selected styles */ - function action_delete_confirmed($ids, $delete_files) + function action_uninstall_confirmed($ids, $delete_files) { global $db, $user, $cache, $config; $default = $config['default_style']; - $deleted = array(); + $uninstalled = array(); $messages = array(); // Check styles list @@ -239,9 +239,9 @@ class acp_styles } if ($id == $default) { - trigger_error($user->lang['DELETE_DEFAULT'] . adm_back_link($this->u_action), E_USER_WARNING); + trigger_error($user->lang['UNINSTALL_DEFAULT'] . adm_back_link($this->u_action), E_USER_WARNING); } - $deleted[$id] = false; + $uninstalled[$id] = false; } // Order by reversed style_id, so parent styles would be removed after child styles @@ -255,19 +255,19 @@ class acp_styles $rows = $db->sql_fetchrowset($result); $db->sql_freeresult($result); - // Delete each style - $deleted = array(); + // Uinstall each style + $uninstalled = array(); foreach ($rows as $style) { - $result = $this->delete_style($style, $delete_files); + $result = $this->uninstall_style($style, $delete_files); if (is_string($result)) { $messages[] = $result; continue; } - $messages[] = sprintf($user->lang['STYLE_DELETED'], $style['style_name']); - $deleted[] = $style['style_name']; + $messages[] = sprintf($user->lang['STYLE_UNINSTALLED'], $style['style_name']); + $uninstalled[] = $style['style_name']; // Attempt to delete files if ($delete_files) @@ -278,14 +278,14 @@ class acp_styles if (empty($messages)) { - // Nothing to delete? + // Nothing to uninstall? trigger_error($user->lang['NO_MATCHING_STYLES_FOUND'] . adm_back_link($this->u_action), E_USER_WARNING); } // Log action - if (count($deleted)) + if (count($uninstalled)) { - add_log('admin', 'LOG_STYLE_DELETE', implode(', ', $deleted)); + add_log('admin', 'LOG_STYLE_DELETE', implode(', ', $uninstalled)); } // Clear cache @@ -591,8 +591,8 @@ class acp_styles if (isset($this->style_counters) && $this->style_counters['total'] > 1) { $template->assign_block_vars('extra_actions', array( - 'ACTION_NAME' => 'delete', - 'L_ACTION' => $user->lang['DELETE'], + 'ACTION_NAME' => 'uninstall', + 'L_ACTION' => $user->lang['STYLE_UNINSTALL'], ) ); } @@ -924,10 +924,10 @@ class acp_styles 'L_ACTION' => $user->lang['EXPORT'] ); */ - // Delete + // Uninstall $actions[] = array( - 'U_ACTION' => $this->u_action . '&action=delete&id=' . $style['style_id'], - 'L_ACTION' => $user->lang['DELETE'] + 'U_ACTION' => $this->u_action . '&action=uninstall&id=' . $style['style_id'], + 'L_ACTION' => $user->lang['STYLE_UNINSTALL'] ); // Preview @@ -1156,12 +1156,12 @@ class acp_styles } /** - * Delete style + * Uninstall style * * @param array $style Style data * @returns true on success, error message on error */ - function delete_style($style) + function uninstall_style($style) { global $db, $user; @@ -1179,7 +1179,7 @@ class acp_styles if ($conflict !== false) { - return sprintf($user->lang['STYLE_DELETE_DEPENDENT'], $style['style_name']); + return sprintf($user->lang['STYLE_UNINSTALL_DEPENDENT'], $style['style_name']); } // Change default style for users @@ -1188,7 +1188,7 @@ class acp_styles WHERE user_style = ' . $id; $db->sql_query($sql); - // Delete style + // Uninstall style $sql = 'DELETE FROM ' . STYLES_TABLE . ' WHERE style_id = ' . $id; $db->sql_query($sql); diff --git a/phpBB/language/en/acp/styles.php b/phpBB/language/en/acp/styles.php index 1a6335cdbf..f5bab1d76f 100644 --- a/phpBB/language/en/acp/styles.php +++ b/phpBB/language/en/acp/styles.php @@ -55,6 +55,7 @@ $lang = array_merge($lang, array( 'CANNOT_BE_INSTALLED' => 'Cannot be installed', 'CONFIRM_TEMPLATE_CLEAR_CACHE' => 'Are you sure you wish to clear all cached versions of your template files?', 'CONFIRM_DELETE_STYLES' => 'Are you sure you wish to delete selected styles?', + 'CONFIRM_UNINSTALL_STYLES' => 'Are you sure you wish to uninstall selected styles?', 'COPYRIGHT' => 'Copyright', 'CREATE_STYLE' => 'Create new style', 'CREATE_TEMPLATE' => 'Create new template set', @@ -62,7 +63,6 @@ $lang = array_merge($lang, array( 'CURRENT_IMAGE' => 'Current image', 'DEACTIVATE_DEFAULT' => 'You cannot deactivate the default style.', - 'DELETE_DEFAULT' => 'You cannot delete the default style.', 'DELETE_FROM_FS' => 'Delete from filesystem', 'DELETE_STYLE' => 'Delete style', 'DELETE_STYLE_EXPLAIN' => 'Here you can remove the selected style. Take care in deleting styles, there is no undo capability.', @@ -291,7 +291,6 @@ $lang = array_merge($lang, array( 'STYLE_DEFAULT' => 'Make default style', 'STYLE_DEFAULT_CHANGE' => 'Change default style', 'STYLE_DEFAULT_CHANGE_INACTIVE' => 'You must activate style before making it default style.', - 'STYLE_DELETE_DEPENDENT' => 'Style "%s" cannot be deleted because it has one or more child styles.', 'STYLE_DELETED' => 'Style "%s" deleted successfully.', 'STYLE_DETAILS_UPDATED' => 'Style edited successfully.', 'STYLE_ERR_ARCHIVE' => 'Please select an archive method.', @@ -316,6 +315,9 @@ $lang = array_merge($lang, array( 'STYLE_PARENT' => 'Parent style:', 'STYLE_TEMPLATE' => 'Template', 'STYLE_THEME' => 'Theme', + 'STYLE_UNINSTALL' => 'Uninstall', + 'STYLE_UNINSTALL_DEPENDENT' => 'Style "%s" cannot be uninstalled because it has one or more child styles.', + 'STYLE_UNINSTALLED' => 'Style "%s" uninstalled successfully.', 'STYLE_USED_BY' => 'Used by (including robots)', 'TEMPLATE_ADDED' => 'Template set added.', @@ -364,6 +366,7 @@ $lang = array_merge($lang, array( 'THEME_UPDATED' => 'Theme updated successfully.', 'UNDERLINE' => 'Underline', + 'UNINSTALL_DEFAULT' => 'You cannot uninstall the default style.', 'UNSET' => 'Undefined', )); From 17989c17a040a28aeeefcf55f6cca054b28c06ed Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 31 Mar 2012 18:10:00 +0300 Subject: [PATCH 277/335] [feature/merging-style-components] Moving template initialization out of style Moving template initialization out of style constructor PHPBB3-10632 --- phpBB/common.php | 4 ++-- phpBB/includes/bbcode.php | 4 ++-- phpBB/includes/functions_messenger.php | 7 +++---- phpBB/includes/style/style.php | 7 ++++--- phpBB/install/index.php | 4 ++-- tests/template/template_inheritance_test.php | 4 ++-- tests/template/template_test_case.php | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/phpBB/common.php b/phpBB/common.php index 1e3f787611..c11d39d9a1 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -126,8 +126,8 @@ $phpbb_extension_manager = new phpbb_extension_manager($db, EXT_TABLE, $phpbb_ro // Initialize style $phpbb_style_resource_locator = new phpbb_style_resource_locator(); $phpbb_style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider()); -$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider); -$template = $style->template; +$template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider); +$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider, $template); $phpbb_subscriber_loader = new phpbb_event_extension_subscriber_loader($phpbb_dispatcher, $phpbb_extension_manager); $phpbb_subscriber_loader->load(); diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index 2cae38022e..612ced8ad6 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -134,9 +134,9 @@ class bbcode $style_resource_locator = new phpbb_style_resource_locator(); $style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider()); - $style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, $style_path_provider); + $template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, $style_path_provider); + $style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, $style_path_provider, $template); $style->set_style(); - $template = $style->template; $template->set_filenames(array('bbcode.html' => 'bbcode.html')); $this->template_filename = $style_resource_locator->get_source_file_for_handle('bbcode.html'); } diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 4d076a7957..aae200df55 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -210,9 +210,9 @@ class messenger { $style_resource_locator = new phpbb_style_resource_locator(); $style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider()); - $this->tpl_msg[$template_lang . $template_file] = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, $style_path_provider); - $stl = &$this->tpl_msg[$template_lang . $template_file]; - $tpl = $stl->template; + $tpl = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, $style_path_provider); + $stl = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $style_resource_locator, $style_path_provider, $tpl); + $this->tpl_msg[$template_lang . $template_file] = $tpl; $fallback_template_path = false; @@ -238,7 +238,6 @@ class messenger } $this->tpl_obj = &$this->tpl_msg[$template_lang . $template_file]; - $this->tpl_obj = $this->tpl_obj->template; $this->vars = &$this->tpl_obj->_rootref; $this->tpl_msg = ''; diff --git a/phpBB/includes/style/style.php b/phpBB/includes/style/style.php index 265a45eca7..539a2642ee 100644 --- a/phpBB/includes/style/style.php +++ b/phpBB/includes/style/style.php @@ -25,7 +25,7 @@ class phpbb_style * @var phpbb_style_template Template class. * Handles everything related to templates. */ - public $template; + private $template; /** * @var string phpBB root path @@ -66,8 +66,9 @@ class phpbb_style * @param user $user current user * @param phpbb_style_resource_locator $locator style resource locator * @param phpbb_style_path_provider $provider style path provider + * @param phpbb_style_template $template template */ - public function __construct($phpbb_root_path, $phpEx, $config, $user, phpbb_style_resource_locator $locator, phpbb_style_path_provider_interface $provider) + public function __construct($phpbb_root_path, $phpEx, $config, $user, phpbb_style_resource_locator $locator, phpbb_style_path_provider_interface $provider, phpbb_style_template $template) { $this->phpbb_root_path = $phpbb_root_path; $this->phpEx = $phpEx; @@ -75,7 +76,7 @@ class phpbb_style $this->user = $user; $this->locator = $locator; $this->provider = $provider; - $this->template = new phpbb_style_template($this->phpbb_root_path, $this->phpEx, $this->config, $this->user, $this->locator, $this->provider); + $this->template = $template; } /** diff --git a/phpBB/install/index.php b/phpBB/install/index.php index fdce7234e5..6c32a322f8 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -204,10 +204,10 @@ $config = new phpbb_config(array( $phpbb_style_resource_locator = new phpbb_style_resource_locator(); $phpbb_style_path_provider = new phpbb_style_path_provider(); -$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider); +$template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider); +$style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider, $template); $style->set_ext_dir_prefix('adm/'); $style->set_custom_style('admin', '../adm/style', ''); -$template = $style->template; $template->assign_var('T_ASSETS_PATH', '../assets'); $template->assign_var('T_TEMPLATE_PATH', '../adm/style'); diff --git a/tests/template/template_inheritance_test.php b/tests/template/template_inheritance_test.php index aa527a3eb5..3f5ec53953 100644 --- a/tests/template/template_inheritance_test.php +++ b/tests/template/template_inheritance_test.php @@ -73,8 +73,8 @@ class phpbb_template_template_inheritance_test extends phpbb_template_template_t $this->parent_template_path = dirname(__FILE__) . '/parent_templates'; $this->style_resource_locator = new phpbb_style_path_provider(); $this->style_provider = new phpbb_style_path_provider(); - $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider); + $this->template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider); + $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template); $this->style->set_custom_style('tests', array($this->template_path, $this->parent_template_path), ''); - $this->template = $this->style->template; } } diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index f324736ba4..a2aedec41d 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -66,9 +66,9 @@ class phpbb_template_template_test_case extends phpbb_test_case $this->template_path = dirname(__FILE__) . '/templates'; $this->style_resource_locator = new phpbb_style_path_provider(); $this->style_provider = new phpbb_style_path_provider(); - $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider); + $this->template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider); + $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template); $this->style->set_custom_style('tests', $this->template_path, ''); - $this->template = $this->style->template; } protected function setUp() From 377db78dcafb99ea65dca79777426db3117ec02c Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 31 Mar 2012 18:16:53 +0300 Subject: [PATCH 278/335] [feature/merging-style-components] Fix for unit tests Fixing typo in template unit tests PHPBB3-10632 --- tests/template/template_inheritance_test.php | 2 +- tests/template/template_test_case.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/template/template_inheritance_test.php b/tests/template/template_inheritance_test.php index 3f5ec53953..7348da9a4a 100644 --- a/tests/template/template_inheritance_test.php +++ b/tests/template/template_inheritance_test.php @@ -71,7 +71,7 @@ class phpbb_template_template_inheritance_test extends phpbb_template_template_t $this->template_path = dirname(__FILE__) . '/templates'; $this->parent_template_path = dirname(__FILE__) . '/parent_templates'; - $this->style_resource_locator = new phpbb_style_path_provider(); + $this->style_resource_locator = new phpbb_style_resource_locator(); $this->style_provider = new phpbb_style_path_provider(); $this->template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider); $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template); diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index a2aedec41d..a87e531a07 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -64,7 +64,7 @@ class phpbb_template_template_test_case extends phpbb_test_case $config = new phpbb_config(array_merge($defaults, $new_config)); $this->template_path = dirname(__FILE__) . '/templates'; - $this->style_resource_locator = new phpbb_style_path_provider(); + $this->style_resource_locator = new phpbb_style_resource_locator(); $this->style_provider = new phpbb_style_path_provider(); $this->template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider); $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template); From 5d07b16ec647f51d51504cf9d6a0861a975ceb8e Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 17:15:32 +0200 Subject: [PATCH 279/335] [feature/merging-style-components] Fix back link on install page When on install page and all styles are installed, fix back link to go to main styles page. PHPBB3-10632 --- phpBB/includes/acp/acp_styles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index 9345ad470a..2772fb2217 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -611,7 +611,7 @@ class acp_styles // Show styles if (empty($styles)) { - trigger_error($user->lang['NO_UNINSTALLED_STYLE'] . adm_back_link($this->u_action), E_USER_NOTICE); + trigger_error($user->lang['NO_UNINSTALLED_STYLE'] . adm_back_link($this->u_base_action), E_USER_NOTICE); } usort($styles, 'acp_styles::sort_styles'); From 1be5bd8e1311a9dd859e6e685cdfa5979adf69a4 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 31 Mar 2012 18:38:37 +0300 Subject: [PATCH 280/335] [feature/merging-style-components] Fixing typo in database updater Fixing typo in database_update.php PHPBB3-10632 --- phpBB/install/database_update.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 18ca4870fb..3235731d28 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2274,7 +2274,7 @@ function change_database_data(&$no_updates, $version) 'cat' => 'ACP_ATTACHMENTS', ), 'install' => array( - 'base' => 'acp_styles' + 'base' => 'acp_styles', 'class' => 'acp', 'title' => 'ACP_STYLES_INSTALL', 'auth' => 'acl_a_styles', From 550ee7309a1d83711e4b9cf4abe3468807d84996 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 31 Mar 2012 18:53:49 +0300 Subject: [PATCH 281/335] [feature/merging-style-components] Fixing typos in database updater Yes, I failed... again. Fixing 2 more typos in database_update.php PHPBB3-10632 --- phpBB/install/database_update.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 3235731d28..583574a245 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -2281,14 +2281,14 @@ function change_database_data(&$no_updates, $version) 'cat' => 'ACP_STYLE_MANAGEMENT', ), 'edit' => array( - 'base' => 'acp_styles' + 'base' => 'acp_styles', 'class' => 'acp', 'title' => 'ACP_STYLES_EDIT', 'auth' => 'acl_a_styles', 'cat' => 'ACP_STYLE_MANAGEMENT', ), 'cache' => array( - 'base' => 'acp_styles' + 'base' => 'acp_styles', 'class' => 'acp', 'title' => 'ACP_STYLES_CACHE', 'auth' => 'acl_a_styles', From 6deb7b3671c29ab7ce1db6e11b5c6be0950d265f Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 02:50:19 +0200 Subject: [PATCH 282/335] [feature/class-prefix] Rename user and session to phpbb_* PHPBB-10609 --- phpBB/common.php | 3 +- phpBB/docs/coding-guidelines.html | 2 +- phpBB/docs/hook_system.html | 4 +- phpBB/includes/functions.php | 2 +- phpBB/includes/functions_profile_fields.php | 2 +- phpBB/includes/session.php | 838 +----------------- phpBB/includes/user.php | 851 +++++++++++++++++++ phpBB/install/database_update.php | 3 +- phpBB/install/index.php | 3 +- tests/mock/session_testable.php | 3 +- tests/security/base.php | 4 +- tests/security/extract_current_page_test.php | 5 +- tests/security/redirect_test.php | 1 - tests/user/lang_test.php | 6 +- 14 files changed, 867 insertions(+), 860 deletions(-) create mode 100644 phpBB/includes/user.php diff --git a/phpBB/common.php b/phpBB/common.php index c11d39d9a1..c4430208dc 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -74,7 +74,6 @@ if (!empty($load_extensions) && function_exists('dl')) // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); -require($phpbb_root_path . 'includes/session.' . $phpEx); require($phpbb_root_path . 'includes/auth.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); @@ -102,7 +101,7 @@ $phpbb_class_loader->set_cache($cache->get_driver()); // Instantiate some basic classes $phpbb_dispatcher = new phpbb_event_dispatcher(); $request = new phpbb_request(); -$user = new user(); +$user = new phpbb_user(); $auth = new auth(); $db = new $sql_db(); diff --git a/phpBB/docs/coding-guidelines.html b/phpBB/docs/coding-guidelines.html index e6dfe579e9..6d428916c7 100644 --- a/phpBB/docs/coding-guidelines.html +++ b/phpBB/docs/coding-guidelines.html @@ -248,7 +248,7 @@ PHPBB_QA (Set board to QA-Mode, which means the updater also c

If the PHPBB_USE_BOARD_URL_PATH constant is set to true, phpBB uses generate_board_url() (this will return the boards url with the script path included) on all instances where web-accessible images are loaded. The exact locations are:

    -
  • /includes/session.php - user::img()
  • +
  • /includes/user.php - phpbb_user::img()
  • /includes/functions_content.php - smiley_text()
diff --git a/phpBB/docs/hook_system.html b/phpBB/docs/hook_system.html index 1ac45e0cb5..6dd84bfc23 100644 --- a/phpBB/docs/hook_system.html +++ b/phpBB/docs/hook_system.html @@ -368,7 +368,7 @@ a:active { color: #368AD2; }

In phpBB3 there are four functions you are able to hook into with your custom functions:

-

phpbb_user_session_handler(); which is called within user::setup after the session and the user object is correctly initialized.
+

phpbb_user_session_handler(); which is called within phpbb_user::setup after the session and the user object is correctly initialized.
append_sid($url, $params = false, $is_amp = true, $session_id = false); which is called for building urls (appending the session id)
$template->display($handle, $template); which is called directly before outputting the (not-yet-compiled) template.
exit_handler(); which is called at the very end of phpBB3's execution.

@@ -388,7 +388,7 @@ PHPBB_USE_BOARD_URL_PATH (use generate_board_url() for image paths instead of $p

If the PHPBB_USE_BOARD_URL_PATH constant is set to true, phpBB uses generate_board_url() (this will return the boards url with the script path included) on all instances where web-accessible images are loaded. The exact locations are:

    -
  • /includes/session.php - user::img()
  • +
  • /includes/user.php - phpbb_user::img()
  • /includes/functions_content.php - smiley_text()
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 99740b753b..74db8cb8fd 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4949,7 +4949,7 @@ function exit_handler() } /** -* Handler for init calls in phpBB. This function is called in user::setup(); +* Handler for init calls in phpBB. This function is called in phpbb_user::setup(); * This function supports hooks. */ function phpbb_user_session_handler() diff --git a/phpBB/includes/functions_profile_fields.php b/phpBB/includes/functions_profile_fields.php index 34d973b3a6..3399334f94 100644 --- a/phpBB/includes/functions_profile_fields.php +++ b/phpBB/includes/functions_profile_fields.php @@ -555,7 +555,7 @@ class custom_profile { global $user; // Date should display as the same date for every user regardless of timezone, so remove offset - // to compensate for the offset added by user::format_date() + // to compensate for the offset added by phpbb_user::format_date() return $user->format_date(gmmktime(0, 0, 0, $month, $day, $year) - ($user->timezone + $user->dst), $user->lang['DATE_FORMAT'], true); } diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 2fd2efe9b2..bcdff54457 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -19,7 +19,7 @@ if (!defined('IN_PHPBB')) * Session class * @package phpBB3 */ -class session +class phpbb_session { var $cookie_data = array(); var $page = array(); @@ -1511,839 +1511,3 @@ class session $db->sql_query($sql); } } - - -/** -* Base user class -* -* This is the overarching class which contains (through session extend) -* all methods utilised for user functionality during a session. -* -* @package phpBB3 -*/ -class user extends session -{ - var $lang = array(); - var $help = array(); - var $theme = array(); - var $date_format; - var $timezone; - var $dst; - - var $lang_name = false; - var $lang_id = false; - var $lang_path; - var $img_lang; - var $img_array = array(); - - // Able to add new options (up to id 31) - var $keyoptions = array('viewimg' => 0, 'viewflash' => 1, 'viewsmilies' => 2, 'viewsigs' => 3, 'viewavatars' => 4, 'viewcensors' => 5, 'attachsig' => 6, 'bbcode' => 8, 'smilies' => 9, 'popuppm' => 10, 'sig_bbcode' => 15, 'sig_smilies' => 16, 'sig_links' => 17); - - /** - * Constructor to set the lang path - */ - function user() - { - global $phpbb_root_path; - - $this->lang_path = $phpbb_root_path . 'language/'; - } - - /** - * Function to set custom language path (able to use directory outside of phpBB) - * - * @param string $lang_path New language path used. - * @access public - */ - function set_custom_lang_path($lang_path) - { - $this->lang_path = $lang_path; - - if (substr($this->lang_path, -1) != '/') - { - $this->lang_path .= '/'; - } - } - - /** - * Setup basic user-specific items (style, language, ...) - */ - function setup($lang_set = false, $style_id = false) - { - global $db, $style, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache; - - if ($this->data['user_id'] != ANONYMOUS) - { - $this->lang_name = (file_exists($this->lang_path . $this->data['user_lang'] . "/common.$phpEx")) ? $this->data['user_lang'] : basename($config['default_lang']); - - $this->date_format = $this->data['user_dateformat']; - $this->timezone = $this->data['user_timezone'] * 3600; - $this->dst = $this->data['user_dst'] * 3600; - } - else - { - $this->lang_name = basename($config['default_lang']); - $this->date_format = $config['default_dateformat']; - $this->timezone = $config['board_timezone'] * 3600; - $this->dst = $config['board_dst'] * 3600; - - /** - * If a guest user is surfing, we try to guess his/her language first by obtaining the browser language - * If re-enabled we need to make sure only those languages installed are checked - * Commented out so we do not loose the code. - - if ($request->header('Accept-Language')) - { - $accept_lang_ary = explode(',', $request->header('Accept-Language')); - - foreach ($accept_lang_ary as $accept_lang) - { - // Set correct format ... guess full xx_YY form - $accept_lang = substr($accept_lang, 0, 2) . '_' . strtoupper(substr($accept_lang, 3, 2)); - $accept_lang = basename($accept_lang); - - if (file_exists($this->lang_path . $accept_lang . "/common.$phpEx")) - { - $this->lang_name = $config['default_lang'] = $accept_lang; - break; - } - else - { - // No match on xx_YY so try xx - $accept_lang = substr($accept_lang, 0, 2); - $accept_lang = basename($accept_lang); - - if (file_exists($this->lang_path . $accept_lang . "/common.$phpEx")) - { - $this->lang_name = $config['default_lang'] = $accept_lang; - break; - } - } - } - } - */ - } - - // We include common language file here to not load it every time a custom language file is included - $lang = &$this->lang; - - // Do not suppress error if in DEBUG_EXTRA mode - $include_result = (defined('DEBUG_EXTRA')) ? (include $this->lang_path . $this->lang_name . "/common.$phpEx") : (@include $this->lang_path . $this->lang_name . "/common.$phpEx"); - - if ($include_result === false) - { - die('Language file ' . $this->lang_path . $this->lang_name . "/common.$phpEx" . " couldn't be opened."); - } - - $this->add_lang($lang_set); - unset($lang_set); - - $style_request = request_var('style', 0); - if ($style_request && $auth->acl_get('a_styles') && !defined('ADMIN_START')) - { - global $SID, $_EXTRA_URL; - - $style_id = $style_request; - $SID .= '&style=' . $style_id; - $_EXTRA_URL = array('style=' . $style_id); - } - else - { - // Set up style - $style_id = ($style_id) ? $style_id : ((!$config['override_user_style']) ? $this->data['user_style'] : $config['default_style']); - } - - $sql = 'SELECT * - FROM ' . STYLES_TABLE . " s - WHERE s.style_id = $style_id"; - $result = $db->sql_query($sql, 3600); - $this->theme = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // User has wrong style - if (!$this->theme && $style_id == $this->data['user_style']) - { - $style_id = $this->data['user_style'] = $config['default_style']; - - $sql = 'UPDATE ' . USERS_TABLE . " - SET user_style = $style_id - WHERE user_id = {$this->data['user_id']}"; - $db->sql_query($sql); - - $sql = 'SELECT * - FROM ' . STYLES_TABLE . " s - WHERE s.style_id = $style_id"; - $result = $db->sql_query($sql, 3600); - $this->theme = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - } - - if (!$this->theme) - { - trigger_error('Could not get style data', E_USER_ERROR); - } - - // Now parse the cfg file and cache it - $parsed_items = $cache->obtain_cfg_items($this->theme); - - // We are only interested in the theme configuration for now - $parsed_items = $parsed_items['theme']; - - $check_for = array( - 'pagination_sep' => (string) ', ' - ); - - foreach ($check_for as $key => $default_value) - { - $this->theme[$key] = (isset($parsed_items[$key])) ? $parsed_items[$key] : $default_value; - settype($this->theme[$key], gettype($default_value)); - - if (is_string($default_value)) - { - $this->theme[$key] = htmlspecialchars($this->theme[$key]); - } - } - - $style->set_style(); - - $this->img_lang = $this->lang_name; - - // Call phpbb_user_session_handler() in case external application want to "bend" some variables or replace classes... - // After calling it we continue script execution... - phpbb_user_session_handler(); - - // If this function got called from the error handler we are finished here. - if (defined('IN_ERROR_HANDLER')) - { - return; - } - - // Disable board if the install/ directory is still present - // For the brave development army we do not care about this, else we need to comment out this everytime we develop locally - if (!defined('DEBUG_EXTRA') && !defined('ADMIN_START') && !defined('IN_INSTALL') && !defined('IN_LOGIN') && file_exists($phpbb_root_path . 'install') && !is_file($phpbb_root_path . 'install')) - { - // Adjust the message slightly according to the permissions - if ($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) - { - $message = 'REMOVE_INSTALL'; - } - else - { - $message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE'; - } - trigger_error($message); - } - - // Is board disabled and user not an admin or moderator? - if ($config['board_disable'] && !defined('IN_LOGIN') && !$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) - { - if ($this->data['is_bot']) - { - send_status_line(503, 'Service Unavailable'); - } - - $message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE'; - trigger_error($message); - } - - // Is load exceeded? - if ($config['limit_load'] && $this->load !== false) - { - if ($this->load > floatval($config['limit_load']) && !defined('IN_LOGIN') && !defined('IN_ADMIN')) - { - // Set board disabled to true to let the admins/mods get the proper notification - $config['board_disable'] = '1'; - - if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) - { - if ($this->data['is_bot']) - { - send_status_line(503, 'Service Unavailable'); - } - trigger_error('BOARD_UNAVAILABLE'); - } - } - } - - if (isset($this->data['session_viewonline'])) - { - // Make sure the user is able to hide his session - if (!$this->data['session_viewonline']) - { - // Reset online status if not allowed to hide the session... - if (!$auth->acl_get('u_hideonline')) - { - $sql = 'UPDATE ' . SESSIONS_TABLE . ' - SET session_viewonline = 1 - WHERE session_user_id = ' . $this->data['user_id']; - $db->sql_query($sql); - $this->data['session_viewonline'] = 1; - } - } - else if (!$this->data['user_allow_viewonline']) - { - // the user wants to hide and is allowed to -> cloaking device on. - if ($auth->acl_get('u_hideonline')) - { - $sql = 'UPDATE ' . SESSIONS_TABLE . ' - SET session_viewonline = 0 - WHERE session_user_id = ' . $this->data['user_id']; - $db->sql_query($sql); - $this->data['session_viewonline'] = 0; - } - } - } - - - // Does the user need to change their password? If so, redirect to the - // ucp profile reg_details page ... of course do not redirect if we're already in the ucp - if (!defined('IN_ADMIN') && !defined('ADMIN_START') && $config['chg_passforce'] && !empty($this->data['is_registered']) && $auth->acl_get('u_chgpasswd') && $this->data['user_passchg'] < time() - ($config['chg_passforce'] * 86400)) - { - if (strpos($this->page['query_string'], 'mode=reg_details') === false && $this->page['page_name'] != "ucp.$phpEx") - { - redirect(append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=profile&mode=reg_details')); - } - } - - return; - } - - /** - * More advanced language substitution - * Function to mimic sprintf() with the possibility of using phpBB's language system to substitute nullar/singular/plural forms. - * Params are the language key and the parameters to be substituted. - * This function/functionality is inspired by SHS` and Ashe. - * - * Example call: $user->lang('NUM_POSTS_IN_QUEUE', 1); - * - * If the first parameter is an array, the elements are used as keys and subkeys to get the language entry: - * Example: $user->lang(array('datetime', 'AGO'), 1) uses $user->lang['datetime']['AGO'] as language entry. - */ - function lang() - { - $args = func_get_args(); - $key = $args[0]; - - if (is_array($key)) - { - $lang = &$this->lang[array_shift($key)]; - - foreach ($key as $_key) - { - $lang = &$lang[$_key]; - } - } - else - { - $lang = &$this->lang[$key]; - } - - // Return if language string does not exist - if (!isset($lang) || (!is_string($lang) && !is_array($lang))) - { - return $key; - } - - // If the language entry is a string, we simply mimic sprintf() behaviour - if (is_string($lang)) - { - if (sizeof($args) == 1) - { - return $lang; - } - - // Replace key with language entry and simply pass along... - $args[0] = $lang; - return call_user_func_array('sprintf', $args); - } - else if (sizeof($lang) == 0) - { - // If the language entry is an empty array, we just return the language key - return $args[0]; - } - - // It is an array... now handle different nullar/singular/plural forms - $key_found = false; - - // We now get the first number passed and will select the key based upon this number - for ($i = 1, $num_args = sizeof($args); $i < $num_args; $i++) - { - if (is_int($args[$i]) || is_float($args[$i])) - { - if ($args[$i] == 0 && isset($lang[0])) - { - // We allow each translation using plural forms to specify a version for the case of 0 things, - // so that "0 users" may be displayed as "No users". - $key_found = 0; - break; - } - else - { - $use_plural_form = $this->get_plural_form($args[$i]); - if (isset($lang[$use_plural_form])) - { - // The key we should use exists, so we use it. - $key_found = $use_plural_form; - } - else - { - // If the key we need to use does not exist, we fall back to the previous one. - $numbers = array_keys($lang); - - foreach ($numbers as $num) - { - if ($num > $use_plural_form) - { - break; - } - - $key_found = $num; - } - } - break; - } - } - } - - // Ok, let's check if the key was found, else use the last entry (because it is mostly the plural form) - if ($key_found === false) - { - $numbers = array_keys($lang); - $key_found = end($numbers); - } - - // Use the language string we determined and pass it to sprintf() - $args[0] = $lang[$key_found]; - return call_user_func_array('sprintf', $args); - } - - /** - * Determine which plural form we should use. - * For some languages this is not as simple as for English. - * - * @param $number int|float The number we want to get the plural case for. Float numbers are floored. - * @param $force_rule mixed False to use the plural rule of the language package - * or an integer to force a certain plural rule - * @return int The plural-case we need to use for the number plural-rule combination - */ - function get_plural_form($number, $force_rule = false) - { - $number = (int) $number; - - // Default to English system - $plural_rule = ($force_rule !== false) ? $force_rule : ((isset($this->lang['PLURAL_RULE'])) ? $this->lang['PLURAL_RULE'] : 1); - - return phpbb_get_plural_form($plural_rule, $number); - } - - /** - * Add Language Items - use_db and use_help are assigned where needed (only use them to force inclusion) - * - * @param mixed $lang_set specifies the language entries to include - * @param bool $use_db internal variable for recursion, do not use - * @param bool $use_help internal variable for recursion, do not use - * @param string $ext_name The extension to load language from, or empty for core files - * - * Examples: - * - * $lang_set = array('posting', 'help' => 'faq'); - * $lang_set = array('posting', 'viewtopic', 'help' => array('bbcode', 'faq')) - * $lang_set = array(array('posting', 'viewtopic'), 'help' => array('bbcode', 'faq')) - * $lang_set = 'posting' - * $lang_set = array('help' => 'faq', 'db' => array('help:faq', 'posting')) - * - */ - function add_lang($lang_set, $use_db = false, $use_help = false, $ext_name = '') - { - global $phpEx; - - if (is_array($lang_set)) - { - foreach ($lang_set as $key => $lang_file) - { - // Please do not delete this line. - // We have to force the type here, else [array] language inclusion will not work - $key = (string) $key; - - if ($key == 'db') - { - $this->add_lang($lang_file, true, $use_help, $ext_name); - } - else if ($key == 'help') - { - $this->add_lang($lang_file, $use_db, true, $ext_name); - } - else if (!is_array($lang_file)) - { - $this->set_lang($this->lang, $this->help, $lang_file, $use_db, $use_help, $ext_name); - } - else - { - $this->add_lang($lang_file, $use_db, $use_help, $ext_name); - } - } - unset($lang_set); - } - else if ($lang_set) - { - $this->set_lang($this->lang, $this->help, $lang_set, $use_db, $use_help, $ext_name); - } - } - - /** - * Add Language Items from an extension - use_db and use_help are assigned where needed (only use them to force inclusion) - * - * @param string $ext_name The extension to load language from, or empty for core files - * @param mixed $lang_set specifies the language entries to include - * @param bool $use_db internal variable for recursion, do not use - * @param bool $use_help internal variable for recursion, do not use - */ - function add_lang_ext($ext_name, $lang_set, $use_db = false, $use_help = false) - { - if ($ext_name === '/') - { - $ext_name = ''; - } - - $this->add_lang($lang_set, $use_db, $use_help, $ext_name); - } - - /** - * Set language entry (called by add_lang) - * @access private - */ - function set_lang(&$lang, &$help, $lang_file, $use_db = false, $use_help = false, $ext_name = '') - { - global $phpbb_root_path, $phpEx; - - // Make sure the language name is set (if the user setup did not happen it is not set) - if (!$this->lang_name) - { - global $config; - $this->lang_name = basename($config['default_lang']); - } - - // $lang == $this->lang - // $help == $this->help - // - add appropriate variables here, name them as they are used within the language file... - if (!$use_db) - { - if ($use_help && strpos($lang_file, '/') !== false) - { - $filename = dirname($lang_file) . '/help_' . basename($lang_file); - } - else - { - $filename = (($use_help) ? 'help_' : '') . $lang_file; - } - - if ($ext_name) - { - global $phpbb_extension_manager; - $ext_path = $phpbb_extension_manager->get_extension_path($ext_name, true); - - $lang_path = $ext_path . 'language/'; - } - else - { - $lang_path = $this->lang_path; - } - - if (strpos($phpbb_root_path . $filename, $lang_path . $this->lang_name . '/') === 0) - { - $language_filename = $phpbb_root_path . $filename; - } - else - { - $language_filename = $lang_path . $this->lang_name . '/' . $filename . '.' . $phpEx; - } - - if (!file_exists($language_filename)) - { - global $config; - - if ($this->lang_name == 'en') - { - // The user's selected language is missing the file, the board default's language is missing the file, and the file doesn't exist in /en. - $language_filename = str_replace($lang_path . 'en', $lang_path . $this->data['user_lang'], $language_filename); - trigger_error('Language file ' . $language_filename . ' couldn\'t be opened.', E_USER_ERROR); - } - else if ($this->lang_name == basename($config['default_lang'])) - { - // Fall back to the English Language - $this->lang_name = 'en'; - $this->set_lang($lang, $help, $lang_file, $use_db, $use_help, $ext_name); - } - else if ($this->lang_name == $this->data['user_lang']) - { - // Fall back to the board default language - $this->lang_name = basename($config['default_lang']); - $this->set_lang($lang, $help, $lang_file, $use_db, $use_help, $ext_name); - } - - // Reset the lang name - $this->lang_name = (file_exists($lang_path . $this->data['user_lang'] . "/common.$phpEx")) ? $this->data['user_lang'] : basename($config['default_lang']); - return; - } - - // Do not suppress error if in DEBUG_EXTRA mode - $include_result = (defined('DEBUG_EXTRA')) ? (include $language_filename) : (@include $language_filename); - - if ($include_result === false) - { - trigger_error('Language file ' . $language_filename . ' couldn\'t be opened.', E_USER_ERROR); - } - } - else if ($use_db) - { - // Get Database Language Strings - // Put them into $lang if nothing is prefixed, put them into $help if help: is prefixed - // For example: help:faq, posting - } - } - - /** - * Format user date - * - * @param int $gmepoch unix timestamp - * @param string $format date format in date() notation. | used to indicate relative dates, for example |d m Y|, h:i is translated to Today, h:i. - * @param bool $forcedate force non-relative date format. - * - * @return mixed translated date - */ - function format_date($gmepoch, $format = false, $forcedate = false) - { - static $midnight; - static $date_cache; - - $format = (!$format) ? $this->date_format : $format; - $now = time(); - $delta = $now - $gmepoch; - - if (!isset($date_cache[$format])) - { - // Is the user requesting a friendly date format (i.e. 'Today 12:42')? - $date_cache[$format] = array( - 'is_short' => strpos($format, '|'), - 'format_short' => substr($format, 0, strpos($format, '|')) . '||' . substr(strrchr($format, '|'), 1), - 'format_long' => str_replace('|', '', $format), - 'lang' => $this->lang['datetime'], - ); - - // Short representation of month in format? Some languages use different terms for the long and short format of May - if ((strpos($format, '\M') === false && strpos($format, 'M') !== false) || (strpos($format, '\r') === false && strpos($format, 'r') !== false)) - { - $date_cache[$format]['lang']['May'] = $this->lang['datetime']['May_short']; - } - } - - // Zone offset - $zone_offset = $this->timezone + $this->dst; - - // Show date < 1 hour ago as 'xx min ago' but not greater than 60 seconds in the future - // A small tolerence is given for times in the future but in the same minute are displayed as '< than a minute ago' - if ($delta < 3600 && $delta > -60 && ($delta >= -5 || (($now / 60) % 60) == (($gmepoch / 60) % 60)) && $date_cache[$format]['is_short'] !== false && !$forcedate && isset($this->lang['datetime']['AGO'])) - { - return $this->lang(array('datetime', 'AGO'), max(0, (int) floor($delta / 60))); - } - - if (!$midnight) - { - list($d, $m, $y) = explode(' ', gmdate('j n Y', time() + $zone_offset)); - $midnight = gmmktime(0, 0, 0, $m, $d, $y) - $zone_offset; - } - - if ($date_cache[$format]['is_short'] !== false && !$forcedate && !($gmepoch < $midnight - 86400 || $gmepoch > $midnight + 172800)) - { - $day = false; - - if ($gmepoch > $midnight + 86400) - { - $day = 'TOMORROW'; - } - else if ($gmepoch > $midnight) - { - $day = 'TODAY'; - } - else if ($gmepoch > $midnight - 86400) - { - $day = 'YESTERDAY'; - } - - if ($day !== false) - { - return str_replace('||', $this->lang['datetime'][$day], strtr(@gmdate($date_cache[$format]['format_short'], $gmepoch + $zone_offset), $date_cache[$format]['lang'])); - } - } - - return strtr(@gmdate($date_cache[$format]['format_long'], $gmepoch + $zone_offset), $date_cache[$format]['lang']); - } - - /** - * Get language id currently used by the user - */ - function get_iso_lang_id() - { - global $config, $db; - - if (!empty($this->lang_id)) - { - return $this->lang_id; - } - - if (!$this->lang_name) - { - $this->lang_name = $config['default_lang']; - } - - $sql = 'SELECT lang_id - FROM ' . LANG_TABLE . " - WHERE lang_iso = '" . $db->sql_escape($this->lang_name) . "'"; - $result = $db->sql_query($sql); - $this->lang_id = (int) $db->sql_fetchfield('lang_id'); - $db->sql_freeresult($result); - - return $this->lang_id; - } - - /** - * Get users profile fields - */ - function get_profile_fields($user_id) - { - global $db; - - if (isset($this->profile_fields)) - { - return; - } - - $sql = 'SELECT * - FROM ' . PROFILE_FIELDS_DATA_TABLE . " - WHERE user_id = $user_id"; - $result = $db->sql_query_limit($sql, 1); - $this->profile_fields = (!($row = $db->sql_fetchrow($result))) ? array() : $row; - $db->sql_freeresult($result); - } - - /** - * Specify/Get image - */ - function img($img, $alt = '') - { - $alt = (!empty($this->lang[$alt])) ? $this->lang[$alt] : $alt; - return '' . $alt . ''; - } - - /** - * Get option bit field from user options. - * - * @param int $key option key, as defined in $keyoptions property. - * @param int $data bit field value to use, or false to use $this->data['user_options'] - * @return bool true if the option is set in the bit field, false otherwise - */ - function optionget($key, $data = false) - { - $var = ($data !== false) ? $data : $this->data['user_options']; - return phpbb_optionget($this->keyoptions[$key], $var); - } - - /** - * Set option bit field for user options. - * - * @param int $key Option key, as defined in $keyoptions property. - * @param bool $value True to set the option, false to clear the option. - * @param int $data Current bit field value, or false to use $this->data['user_options'] - * @return int|bool If $data is false, the bit field is modified and - * written back to $this->data['user_options'], and - * return value is true if the bit field changed and - * false otherwise. If $data is not false, the new - * bitfield value is returned. - */ - function optionset($key, $value, $data = false) - { - $var = ($data !== false) ? $data : $this->data['user_options']; - - $new_var = phpbb_optionset($this->keyoptions[$key], $value, $var); - - if ($data === false) - { - if ($new_var != $var) - { - $this->data['user_options'] = $new_var; - return true; - } - else - { - return false; - } - } - else - { - return $new_var; - } - } - - /** - * Funtion to make the user leave the NEWLY_REGISTERED system group. - * @access public - */ - function leave_newly_registered() - { - global $db; - - if (empty($this->data['user_new'])) - { - return false; - } - - if (!function_exists('remove_newly_registered')) - { - global $phpbb_root_path, $phpEx; - - include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - } - if ($group = remove_newly_registered($this->data['user_id'], $this->data)) - { - $this->data['group_id'] = $group; - - } - $this->data['user_permissions'] = ''; - $this->data['user_new'] = 0; - - return true; - } - - /** - * Returns all password protected forum ids the user is currently NOT authenticated for. - * - * @return array Array of forum ids - * @access public - */ - function get_passworded_forums() - { - global $db; - - $sql = 'SELECT f.forum_id, fa.user_id - FROM ' . FORUMS_TABLE . ' f - LEFT JOIN ' . FORUMS_ACCESS_TABLE . " fa - ON (fa.forum_id = f.forum_id - AND fa.session_id = '" . $db->sql_escape($this->session_id) . "') - WHERE f.forum_password <> ''"; - $result = $db->sql_query($sql); - - $forum_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $forum_id = (int) $row['forum_id']; - - if ($row['user_id'] != $this->data['user_id']) - { - $forum_ids[$forum_id] = $forum_id; - } - } - $db->sql_freeresult($result); - - return $forum_ids; - } -} diff --git a/phpBB/includes/user.php b/phpBB/includes/user.php new file mode 100644 index 0000000000..1676f82ccb --- /dev/null +++ b/phpBB/includes/user.php @@ -0,0 +1,851 @@ + 0, 'viewflash' => 1, 'viewsmilies' => 2, 'viewsigs' => 3, 'viewavatars' => 4, 'viewcensors' => 5, 'attachsig' => 6, 'bbcode' => 8, 'smilies' => 9, 'popuppm' => 10, 'sig_bbcode' => 15, 'sig_smilies' => 16, 'sig_links' => 17); + + /** + * Constructor to set the lang path + */ + function __construct() + { + global $phpbb_root_path; + + $this->lang_path = $phpbb_root_path . 'language/'; + } + + /** + * Function to set custom language path (able to use directory outside of phpBB) + * + * @param string $lang_path New language path used. + * @access public + */ + function set_custom_lang_path($lang_path) + { + $this->lang_path = $lang_path; + + if (substr($this->lang_path, -1) != '/') + { + $this->lang_path .= '/'; + } + } + + /** + * Setup basic user-specific items (style, language, ...) + */ + function setup($lang_set = false, $style_id = false) + { + global $db, $style, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache; + + if ($this->data['user_id'] != ANONYMOUS) + { + $this->lang_name = (file_exists($this->lang_path . $this->data['user_lang'] . "/common.$phpEx")) ? $this->data['user_lang'] : basename($config['default_lang']); + + $this->date_format = $this->data['user_dateformat']; + $this->timezone = $this->data['user_timezone'] * 3600; + $this->dst = $this->data['user_dst'] * 3600; + } + else + { + $this->lang_name = basename($config['default_lang']); + $this->date_format = $config['default_dateformat']; + $this->timezone = $config['board_timezone'] * 3600; + $this->dst = $config['board_dst'] * 3600; + + /** + * If a guest user is surfing, we try to guess his/her language first by obtaining the browser language + * If re-enabled we need to make sure only those languages installed are checked + * Commented out so we do not loose the code. + + if ($request->header('Accept-Language')) + { + $accept_lang_ary = explode(',', $request->header('Accept-Language')); + + foreach ($accept_lang_ary as $accept_lang) + { + // Set correct format ... guess full xx_YY form + $accept_lang = substr($accept_lang, 0, 2) . '_' . strtoupper(substr($accept_lang, 3, 2)); + $accept_lang = basename($accept_lang); + + if (file_exists($this->lang_path . $accept_lang . "/common.$phpEx")) + { + $this->lang_name = $config['default_lang'] = $accept_lang; + break; + } + else + { + // No match on xx_YY so try xx + $accept_lang = substr($accept_lang, 0, 2); + $accept_lang = basename($accept_lang); + + if (file_exists($this->lang_path . $accept_lang . "/common.$phpEx")) + { + $this->lang_name = $config['default_lang'] = $accept_lang; + break; + } + } + } + } + */ + } + + // We include common language file here to not load it every time a custom language file is included + $lang = &$this->lang; + + // Do not suppress error if in DEBUG_EXTRA mode + $include_result = (defined('DEBUG_EXTRA')) ? (include $this->lang_path . $this->lang_name . "/common.$phpEx") : (@include $this->lang_path . $this->lang_name . "/common.$phpEx"); + + if ($include_result === false) + { + die('Language file ' . $this->lang_path . $this->lang_name . "/common.$phpEx" . " couldn't be opened."); + } + + $this->add_lang($lang_set); + unset($lang_set); + + $style_request = request_var('style', 0); + if ($style_request && $auth->acl_get('a_styles') && !defined('ADMIN_START')) + { + global $SID, $_EXTRA_URL; + + $style_id = $style_request; + $SID .= '&style=' . $style_id; + $_EXTRA_URL = array('style=' . $style_id); + } + else + { + // Set up style + $style_id = ($style_id) ? $style_id : ((!$config['override_user_style']) ? $this->data['user_style'] : $config['default_style']); + } + + $sql = 'SELECT * + FROM ' . STYLES_TABLE . " s + WHERE s.style_id = $style_id"; + $result = $db->sql_query($sql, 3600); + $this->theme = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + // User has wrong style + if (!$this->theme && $style_id == $this->data['user_style']) + { + $style_id = $this->data['user_style'] = $config['default_style']; + + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_style = $style_id + WHERE user_id = {$this->data['user_id']}"; + $db->sql_query($sql); + + $sql = 'SELECT * + FROM ' . STYLES_TABLE . " s + WHERE s.style_id = $style_id"; + $result = $db->sql_query($sql, 3600); + $this->theme = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + } + + if (!$this->theme) + { + trigger_error('Could not get style data', E_USER_ERROR); + } + + // Now parse the cfg file and cache it + $parsed_items = $cache->obtain_cfg_items($this->theme); + + // We are only interested in the theme configuration for now + $parsed_items = $parsed_items['theme']; + + $check_for = array( + 'pagination_sep' => (string) ', ' + ); + + foreach ($check_for as $key => $default_value) + { + $this->theme[$key] = (isset($parsed_items[$key])) ? $parsed_items[$key] : $default_value; + settype($this->theme[$key], gettype($default_value)); + + if (is_string($default_value)) + { + $this->theme[$key] = htmlspecialchars($this->theme[$key]); + } + } + + $style->set_style(); + + $this->img_lang = $this->lang_name; + + // Call phpbb_user_session_handler() in case external application want to "bend" some variables or replace classes... + // After calling it we continue script execution... + phpbb_user_session_handler(); + + // If this function got called from the error handler we are finished here. + if (defined('IN_ERROR_HANDLER')) + { + return; + } + + // Disable board if the install/ directory is still present + // For the brave development army we do not care about this, else we need to comment out this everytime we develop locally + if (!defined('DEBUG_EXTRA') && !defined('ADMIN_START') && !defined('IN_INSTALL') && !defined('IN_LOGIN') && file_exists($phpbb_root_path . 'install') && !is_file($phpbb_root_path . 'install')) + { + // Adjust the message slightly according to the permissions + if ($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_')) + { + $message = 'REMOVE_INSTALL'; + } + else + { + $message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE'; + } + trigger_error($message); + } + + // Is board disabled and user not an admin or moderator? + if ($config['board_disable'] && !defined('IN_LOGIN') && !$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) + { + if ($this->data['is_bot']) + { + send_status_line(503, 'Service Unavailable'); + } + + $message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE'; + trigger_error($message); + } + + // Is load exceeded? + if ($config['limit_load'] && $this->load !== false) + { + if ($this->load > floatval($config['limit_load']) && !defined('IN_LOGIN') && !defined('IN_ADMIN')) + { + // Set board disabled to true to let the admins/mods get the proper notification + $config['board_disable'] = '1'; + + if (!$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_')) + { + if ($this->data['is_bot']) + { + send_status_line(503, 'Service Unavailable'); + } + trigger_error('BOARD_UNAVAILABLE'); + } + } + } + + if (isset($this->data['session_viewonline'])) + { + // Make sure the user is able to hide his session + if (!$this->data['session_viewonline']) + { + // Reset online status if not allowed to hide the session... + if (!$auth->acl_get('u_hideonline')) + { + $sql = 'UPDATE ' . SESSIONS_TABLE . ' + SET session_viewonline = 1 + WHERE session_user_id = ' . $this->data['user_id']; + $db->sql_query($sql); + $this->data['session_viewonline'] = 1; + } + } + else if (!$this->data['user_allow_viewonline']) + { + // the user wants to hide and is allowed to -> cloaking device on. + if ($auth->acl_get('u_hideonline')) + { + $sql = 'UPDATE ' . SESSIONS_TABLE . ' + SET session_viewonline = 0 + WHERE session_user_id = ' . $this->data['user_id']; + $db->sql_query($sql); + $this->data['session_viewonline'] = 0; + } + } + } + + + // Does the user need to change their password? If so, redirect to the + // ucp profile reg_details page ... of course do not redirect if we're already in the ucp + if (!defined('IN_ADMIN') && !defined('ADMIN_START') && $config['chg_passforce'] && !empty($this->data['is_registered']) && $auth->acl_get('u_chgpasswd') && $this->data['user_passchg'] < time() - ($config['chg_passforce'] * 86400)) + { + if (strpos($this->page['query_string'], 'mode=reg_details') === false && $this->page['page_name'] != "ucp.$phpEx") + { + redirect(append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=profile&mode=reg_details')); + } + } + + return; + } + + /** + * More advanced language substitution + * Function to mimic sprintf() with the possibility of using phpBB's language system to substitute nullar/singular/plural forms. + * Params are the language key and the parameters to be substituted. + * This function/functionality is inspired by SHS` and Ashe. + * + * Example call: $user->lang('NUM_POSTS_IN_QUEUE', 1); + * + * If the first parameter is an array, the elements are used as keys and subkeys to get the language entry: + * Example: $user->lang(array('datetime', 'AGO'), 1) uses $user->lang['datetime']['AGO'] as language entry. + */ + function lang() + { + $args = func_get_args(); + $key = $args[0]; + + if (is_array($key)) + { + $lang = &$this->lang[array_shift($key)]; + + foreach ($key as $_key) + { + $lang = &$lang[$_key]; + } + } + else + { + $lang = &$this->lang[$key]; + } + + // Return if language string does not exist + if (!isset($lang) || (!is_string($lang) && !is_array($lang))) + { + return $key; + } + + // If the language entry is a string, we simply mimic sprintf() behaviour + if (is_string($lang)) + { + if (sizeof($args) == 1) + { + return $lang; + } + + // Replace key with language entry and simply pass along... + $args[0] = $lang; + return call_user_func_array('sprintf', $args); + } + else if (sizeof($lang) == 0) + { + // If the language entry is an empty array, we just return the language key + return $args[0]; + } + + // It is an array... now handle different nullar/singular/plural forms + $key_found = false; + + // We now get the first number passed and will select the key based upon this number + for ($i = 1, $num_args = sizeof($args); $i < $num_args; $i++) + { + if (is_int($args[$i]) || is_float($args[$i])) + { + if ($args[$i] == 0 && isset($lang[0])) + { + // We allow each translation using plural forms to specify a version for the case of 0 things, + // so that "0 users" may be displayed as "No users". + $key_found = 0; + break; + } + else + { + $use_plural_form = $this->get_plural_form($args[$i]); + if (isset($lang[$use_plural_form])) + { + // The key we should use exists, so we use it. + $key_found = $use_plural_form; + } + else + { + // If the key we need to use does not exist, we fall back to the previous one. + $numbers = array_keys($lang); + + foreach ($numbers as $num) + { + if ($num > $use_plural_form) + { + break; + } + + $key_found = $num; + } + } + break; + } + } + } + + // Ok, let's check if the key was found, else use the last entry (because it is mostly the plural form) + if ($key_found === false) + { + $numbers = array_keys($lang); + $key_found = end($numbers); + } + + // Use the language string we determined and pass it to sprintf() + $args[0] = $lang[$key_found]; + return call_user_func_array('sprintf', $args); + } + + /** + * Determine which plural form we should use. + * For some languages this is not as simple as for English. + * + * @param $number int|float The number we want to get the plural case for. Float numbers are floored. + * @param $force_rule mixed False to use the plural rule of the language package + * or an integer to force a certain plural rule + * @return int The plural-case we need to use for the number plural-rule combination + */ + function get_plural_form($number, $force_rule = false) + { + $number = (int) $number; + + // Default to English system + $plural_rule = ($force_rule !== false) ? $force_rule : ((isset($this->lang['PLURAL_RULE'])) ? $this->lang['PLURAL_RULE'] : 1); + + return phpbb_get_plural_form($plural_rule, $number); + } + + /** + * Add Language Items - use_db and use_help are assigned where needed (only use them to force inclusion) + * + * @param mixed $lang_set specifies the language entries to include + * @param bool $use_db internal variable for recursion, do not use + * @param bool $use_help internal variable for recursion, do not use + * @param string $ext_name The extension to load language from, or empty for core files + * + * Examples: + * + * $lang_set = array('posting', 'help' => 'faq'); + * $lang_set = array('posting', 'viewtopic', 'help' => array('bbcode', 'faq')) + * $lang_set = array(array('posting', 'viewtopic'), 'help' => array('bbcode', 'faq')) + * $lang_set = 'posting' + * $lang_set = array('help' => 'faq', 'db' => array('help:faq', 'posting')) + * + */ + function add_lang($lang_set, $use_db = false, $use_help = false, $ext_name = '') + { + global $phpEx; + + if (is_array($lang_set)) + { + foreach ($lang_set as $key => $lang_file) + { + // Please do not delete this line. + // We have to force the type here, else [array] language inclusion will not work + $key = (string) $key; + + if ($key == 'db') + { + $this->add_lang($lang_file, true, $use_help, $ext_name); + } + else if ($key == 'help') + { + $this->add_lang($lang_file, $use_db, true, $ext_name); + } + else if (!is_array($lang_file)) + { + $this->set_lang($this->lang, $this->help, $lang_file, $use_db, $use_help, $ext_name); + } + else + { + $this->add_lang($lang_file, $use_db, $use_help, $ext_name); + } + } + unset($lang_set); + } + else if ($lang_set) + { + $this->set_lang($this->lang, $this->help, $lang_set, $use_db, $use_help, $ext_name); + } + } + + /** + * Add Language Items from an extension - use_db and use_help are assigned where needed (only use them to force inclusion) + * + * @param string $ext_name The extension to load language from, or empty for core files + * @param mixed $lang_set specifies the language entries to include + * @param bool $use_db internal variable for recursion, do not use + * @param bool $use_help internal variable for recursion, do not use + */ + function add_lang_ext($ext_name, $lang_set, $use_db = false, $use_help = false) + { + if ($ext_name === '/') + { + $ext_name = ''; + } + + $this->add_lang($lang_set, $use_db, $use_help, $ext_name); + } + + /** + * Set language entry (called by add_lang) + * @access private + */ + function set_lang(&$lang, &$help, $lang_file, $use_db = false, $use_help = false, $ext_name = '') + { + global $phpbb_root_path, $phpEx; + + // Make sure the language name is set (if the user setup did not happen it is not set) + if (!$this->lang_name) + { + global $config; + $this->lang_name = basename($config['default_lang']); + } + + // $lang == $this->lang + // $help == $this->help + // - add appropriate variables here, name them as they are used within the language file... + if (!$use_db) + { + if ($use_help && strpos($lang_file, '/') !== false) + { + $filename = dirname($lang_file) . '/help_' . basename($lang_file); + } + else + { + $filename = (($use_help) ? 'help_' : '') . $lang_file; + } + + if ($ext_name) + { + global $phpbb_extension_manager; + $ext_path = $phpbb_extension_manager->get_extension_path($ext_name, true); + + $lang_path = $ext_path . 'language/'; + } + else + { + $lang_path = $this->lang_path; + } + + if (strpos($phpbb_root_path . $filename, $lang_path . $this->lang_name . '/') === 0) + { + $language_filename = $phpbb_root_path . $filename; + } + else + { + $language_filename = $lang_path . $this->lang_name . '/' . $filename . '.' . $phpEx; + } + + if (!file_exists($language_filename)) + { + global $config; + + if ($this->lang_name == 'en') + { + // The user's selected language is missing the file, the board default's language is missing the file, and the file doesn't exist in /en. + $language_filename = str_replace($lang_path . 'en', $lang_path . $this->data['user_lang'], $language_filename); + trigger_error('Language file ' . $language_filename . ' couldn\'t be opened.', E_USER_ERROR); + } + else if ($this->lang_name == basename($config['default_lang'])) + { + // Fall back to the English Language + $this->lang_name = 'en'; + $this->set_lang($lang, $help, $lang_file, $use_db, $use_help, $ext_name); + } + else if ($this->lang_name == $this->data['user_lang']) + { + // Fall back to the board default language + $this->lang_name = basename($config['default_lang']); + $this->set_lang($lang, $help, $lang_file, $use_db, $use_help, $ext_name); + } + + // Reset the lang name + $this->lang_name = (file_exists($lang_path . $this->data['user_lang'] . "/common.$phpEx")) ? $this->data['user_lang'] : basename($config['default_lang']); + return; + } + + // Do not suppress error if in DEBUG_EXTRA mode + $include_result = (defined('DEBUG_EXTRA')) ? (include $language_filename) : (@include $language_filename); + + if ($include_result === false) + { + trigger_error('Language file ' . $language_filename . ' couldn\'t be opened.', E_USER_ERROR); + } + } + else if ($use_db) + { + // Get Database Language Strings + // Put them into $lang if nothing is prefixed, put them into $help if help: is prefixed + // For example: help:faq, posting + } + } + + /** + * Format user date + * + * @param int $gmepoch unix timestamp + * @param string $format date format in date() notation. | used to indicate relative dates, for example |d m Y|, h:i is translated to Today, h:i. + * @param bool $forcedate force non-relative date format. + * + * @return mixed translated date + */ + function format_date($gmepoch, $format = false, $forcedate = false) + { + static $midnight; + static $date_cache; + + $format = (!$format) ? $this->date_format : $format; + $now = time(); + $delta = $now - $gmepoch; + + if (!isset($date_cache[$format])) + { + // Is the user requesting a friendly date format (i.e. 'Today 12:42')? + $date_cache[$format] = array( + 'is_short' => strpos($format, '|'), + 'format_short' => substr($format, 0, strpos($format, '|')) . '||' . substr(strrchr($format, '|'), 1), + 'format_long' => str_replace('|', '', $format), + 'lang' => $this->lang['datetime'], + ); + + // Short representation of month in format? Some languages use different terms for the long and short format of May + if ((strpos($format, '\M') === false && strpos($format, 'M') !== false) || (strpos($format, '\r') === false && strpos($format, 'r') !== false)) + { + $date_cache[$format]['lang']['May'] = $this->lang['datetime']['May_short']; + } + } + + // Zone offset + $zone_offset = $this->timezone + $this->dst; + + // Show date < 1 hour ago as 'xx min ago' but not greater than 60 seconds in the future + // A small tolerence is given for times in the future but in the same minute are displayed as '< than a minute ago' + if ($delta < 3600 && $delta > -60 && ($delta >= -5 || (($now / 60) % 60) == (($gmepoch / 60) % 60)) && $date_cache[$format]['is_short'] !== false && !$forcedate && isset($this->lang['datetime']['AGO'])) + { + return $this->lang(array('datetime', 'AGO'), max(0, (int) floor($delta / 60))); + } + + if (!$midnight) + { + list($d, $m, $y) = explode(' ', gmdate('j n Y', time() + $zone_offset)); + $midnight = gmmktime(0, 0, 0, $m, $d, $y) - $zone_offset; + } + + if ($date_cache[$format]['is_short'] !== false && !$forcedate && !($gmepoch < $midnight - 86400 || $gmepoch > $midnight + 172800)) + { + $day = false; + + if ($gmepoch > $midnight + 86400) + { + $day = 'TOMORROW'; + } + else if ($gmepoch > $midnight) + { + $day = 'TODAY'; + } + else if ($gmepoch > $midnight - 86400) + { + $day = 'YESTERDAY'; + } + + if ($day !== false) + { + return str_replace('||', $this->lang['datetime'][$day], strtr(@gmdate($date_cache[$format]['format_short'], $gmepoch + $zone_offset), $date_cache[$format]['lang'])); + } + } + + return strtr(@gmdate($date_cache[$format]['format_long'], $gmepoch + $zone_offset), $date_cache[$format]['lang']); + } + + /** + * Get language id currently used by the user + */ + function get_iso_lang_id() + { + global $config, $db; + + if (!empty($this->lang_id)) + { + return $this->lang_id; + } + + if (!$this->lang_name) + { + $this->lang_name = $config['default_lang']; + } + + $sql = 'SELECT lang_id + FROM ' . LANG_TABLE . " + WHERE lang_iso = '" . $db->sql_escape($this->lang_name) . "'"; + $result = $db->sql_query($sql); + $this->lang_id = (int) $db->sql_fetchfield('lang_id'); + $db->sql_freeresult($result); + + return $this->lang_id; + } + + /** + * Get users profile fields + */ + function get_profile_fields($user_id) + { + global $db; + + if (isset($this->profile_fields)) + { + return; + } + + $sql = 'SELECT * + FROM ' . PROFILE_FIELDS_DATA_TABLE . " + WHERE user_id = $user_id"; + $result = $db->sql_query_limit($sql, 1); + $this->profile_fields = (!($row = $db->sql_fetchrow($result))) ? array() : $row; + $db->sql_freeresult($result); + } + + /** + * Specify/Get image + */ + function img($img, $alt = '') + { + $alt = (!empty($this->lang[$alt])) ? $this->lang[$alt] : $alt; + return '' . $alt . ''; + } + + /** + * Get option bit field from user options. + * + * @param int $key option key, as defined in $keyoptions property. + * @param int $data bit field value to use, or false to use $this->data['user_options'] + * @return bool true if the option is set in the bit field, false otherwise + */ + function optionget($key, $data = false) + { + $var = ($data !== false) ? $data : $this->data['user_options']; + return phpbb_optionget($this->keyoptions[$key], $var); + } + + /** + * Set option bit field for user options. + * + * @param int $key Option key, as defined in $keyoptions property. + * @param bool $value True to set the option, false to clear the option. + * @param int $data Current bit field value, or false to use $this->data['user_options'] + * @return int|bool If $data is false, the bit field is modified and + * written back to $this->data['user_options'], and + * return value is true if the bit field changed and + * false otherwise. If $data is not false, the new + * bitfield value is returned. + */ + function optionset($key, $value, $data = false) + { + $var = ($data !== false) ? $data : $this->data['user_options']; + + $new_var = phpbb_optionset($this->keyoptions[$key], $value, $var); + + if ($data === false) + { + if ($new_var != $var) + { + $this->data['user_options'] = $new_var; + return true; + } + else + { + return false; + } + } + else + { + return $new_var; + } + } + + /** + * Funtion to make the user leave the NEWLY_REGISTERED system group. + * @access public + */ + function leave_newly_registered() + { + global $db; + + if (empty($this->data['user_new'])) + { + return false; + } + + if (!function_exists('remove_newly_registered')) + { + global $phpbb_root_path, $phpEx; + + include($phpbb_root_path . 'includes/functions_user.' . $phpEx); + } + if ($group = remove_newly_registered($this->data['user_id'], $this->data)) + { + $this->data['group_id'] = $group; + + } + $this->data['user_permissions'] = ''; + $this->data['user_new'] = 0; + + return true; + } + + /** + * Returns all password protected forum ids the user is currently NOT authenticated for. + * + * @return array Array of forum ids + * @access public + */ + function get_passworded_forums() + { + global $db; + + $sql = 'SELECT f.forum_id, fa.user_id + FROM ' . FORUMS_TABLE . ' f + LEFT JOIN ' . FORUMS_ACCESS_TABLE . " fa + ON (fa.forum_id = f.forum_id + AND fa.session_id = '" . $db->sql_escape($this->session_id) . "') + WHERE f.forum_password <> ''"; + $result = $db->sql_query($sql); + + $forum_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $forum_id = (int) $row['forum_id']; + + if ($row['user_id'] != $this->data['user_id']) + { + $forum_ids[$forum_id] = $forum_id; + } + } + $db->sql_freeresult($result); + + return $forum_ids; + } +} diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 18ca4870fb..fb5e79358d 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -84,7 +84,6 @@ if (!empty($load_extensions) && function_exists('dl')) // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); -require($phpbb_root_path . 'includes/session.' . $phpEx); require($phpbb_root_path . 'includes/auth.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); @@ -122,7 +121,7 @@ $phpbb_class_loader->set_cache($cache->get_driver()); $phpbb_dispatcher = new phpbb_event_dispatcher(); $request = new phpbb_request(); -$user = new user(); +$user = new phpbb_user(); $db = new $sql_db(); // make sure request_var uses this request instance diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 6c32a322f8..d3cb68e82e 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -76,7 +76,6 @@ require($phpbb_root_path . 'includes/functions.' . $phpEx); phpbb_require_updated('includes/functions_content.' . $phpEx, true); include($phpbb_root_path . 'includes/auth.' . $phpEx); -include($phpbb_root_path . 'includes/session.' . $phpEx); include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); require($phpbb_root_path . 'includes/functions_install.' . $phpEx); @@ -178,7 +177,7 @@ $sub = request_var('sub', ''); // Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); -$user = new user(); +$user = new phpbb_user(); $auth = new auth(); // Add own hook handler, if present. :o diff --git a/tests/mock/session_testable.php b/tests/mock/session_testable.php index 70a58fb6cc..56ff8c8b32 100644 --- a/tests/mock/session_testable.php +++ b/tests/mock/session_testable.php @@ -8,7 +8,6 @@ */ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/session.php'; /** * Extends the session class to overwrite the setting of cookies. @@ -17,7 +16,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/session.php'; * test it without warnings about sent headers. This class only stores cookie * data for later verification. */ -class phpbb_mock_session_testable extends session +class phpbb_mock_session_testable extends phpbb_session { private $_cookies = array(); diff --git a/tests/security/base.php b/tests/security/base.php index f7f3f9f661..82e4dda9d0 100644 --- a/tests/security/base.php +++ b/tests/security/base.php @@ -41,13 +41,13 @@ abstract class phpbb_security_test_base extends phpbb_test_case $request = new phpbb_mock_request(array(), array(), array(), $server); // Set no user and trick a bit to circumvent errors - $user = new user(); + $user = new phpbb_user(); $user->lang = true; $user->browser = $server['HTTP_USER_AGENT']; $user->referer = ''; $user->forwarded_for = ''; $user->host = $server['HTTP_HOST']; - $user->page = session::extract_current_page($phpbb_root_path); + $user->page = phpbb_session::extract_current_page($phpbb_root_path); } protected function tearDown() diff --git a/tests/security/extract_current_page_test.php b/tests/security/extract_current_page_test.php index 00fc3b5841..b4a475ffb3 100644 --- a/tests/security/extract_current_page_test.php +++ b/tests/security/extract_current_page_test.php @@ -10,7 +10,6 @@ require_once dirname(__FILE__) . '/base.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/session.php'; class phpbb_security_extract_current_page_test extends phpbb_security_test_base { @@ -34,7 +33,7 @@ class phpbb_security_extract_current_page_test extends phpbb_security_test_base 'QUERY_STRING' => $query_string, )); - $result = session::extract_current_page('./'); + $result = phpbb_session::extract_current_page('./'); $label = 'Running extract_current_page on ' . $query_string . ' with PHP_SELF filled.'; $this->assertEquals($expected, $result['query_string'], $label); @@ -52,7 +51,7 @@ class phpbb_security_extract_current_page_test extends phpbb_security_test_base 'QUERY_STRING' => $query_string, )); - $result = session::extract_current_page('./'); + $result = phpbb_session::extract_current_page('./'); $label = 'Running extract_current_page on ' . $query_string . ' with REQUEST_URI filled.'; $this->assertEquals($expected, $result['query_string'], $label); diff --git a/tests/security/redirect_test.php b/tests/security/redirect_test.php index 634a506ab9..da318209e2 100644 --- a/tests/security/redirect_test.php +++ b/tests/security/redirect_test.php @@ -10,7 +10,6 @@ require_once dirname(__FILE__) . '/base.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; -require_once dirname(__FILE__) . '/../../phpBB/includes/session.php'; class phpbb_security_redirect_test extends phpbb_security_test_base { diff --git a/tests/user/lang_test.php b/tests/user/lang_test.php index f0ea76f342..d7ff451a70 100644 --- a/tests/user/lang_test.php +++ b/tests/user/lang_test.php @@ -7,13 +7,11 @@ * */ -require_once dirname(__FILE__) . '/../../phpBB/includes/session.php'; - class phpbb_user_lang_test extends phpbb_test_case { public function test_user_lang_sprintf() { - $user = new user; + $user = new phpbb_user; $user->lang = array( 'FOO' => 'BAR', 'BARZ' => 'PENG', @@ -95,7 +93,7 @@ class phpbb_user_lang_test extends phpbb_test_case $this->assertEquals($user->lang('ARRY', 1, 's', 2), '1 post'); // ticket PHPBB3-10345 - different plural rules, not just 0/1/2+ - $user = new user; + $user = new phpbb_user; $user->lang = array( 'PLURAL_RULE' => 13, 'ARRY' => array( From 9236dd4c471a6f7655bd00ae422a13013a400ac4 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 31 Mar 2012 02:54:39 +0200 Subject: [PATCH 283/335] [feature/class-prefix] Rename auth => phpbb_auth PHPBB3-10609 --- phpBB/common.php | 3 +-- phpBB/docs/auth_api.html | 2 +- phpBB/includes/acp/acp_permissions.php | 2 +- phpBB/includes/acp/acp_users.php | 2 +- phpBB/includes/acp/auth.php | 4 ++-- phpBB/includes/{ => auth}/auth.php | 2 +- phpBB/includes/functions_privmsgs.php | 2 +- phpBB/includes/mcp/mcp_warn.php | 4 ++-- phpBB/includes/ucp/ucp_remind.php | 2 +- phpBB/install/database_update.php | 1 - phpBB/install/index.php | 3 +-- 11 files changed, 12 insertions(+), 15 deletions(-) rename phpBB/includes/{ => auth}/auth.php (99%) diff --git a/phpBB/common.php b/phpBB/common.php index c4430208dc..b3b8d7e4f7 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -74,7 +74,6 @@ if (!empty($load_extensions) && function_exists('dl')) // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); -require($phpbb_root_path . 'includes/auth.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); require($phpbb_root_path . 'includes/functions_content.' . $phpEx); @@ -102,7 +101,7 @@ $phpbb_class_loader->set_cache($cache->get_driver()); $phpbb_dispatcher = new phpbb_event_dispatcher(); $request = new phpbb_request(); $user = new phpbb_user(); -$auth = new auth(); +$auth = new phpbb_auth(); $db = new $sql_db(); // make sure request_var uses this request instance diff --git a/phpBB/docs/auth_api.html b/phpBB/docs/auth_api.html index 40a63eaa9d..2302140030 100644 --- a/phpBB/docs/auth_api.html +++ b/phpBB/docs/auth_api.html @@ -86,7 +86,7 @@

To use any methods contained with the auth class it first needs to be instantiated. This is best achieved early in the execution of the script in the following manner:

-$auth = new auth();
+$auth = new phpbb_auth();
 	

Once an instance of the class has been created you are free to call the various methods it contains. Please note that should you wish to use the auth_admin methods you will need to instantiate this separately but in the same way.

diff --git a/phpBB/includes/acp/acp_permissions.php b/phpBB/includes/acp/acp_permissions.php index 150b67b8f7..d728744c04 100644 --- a/phpBB/includes/acp/acp_permissions.php +++ b/phpBB/includes/acp/acp_permissions.php @@ -1105,7 +1105,7 @@ class acp_permissions { if ($user_id != $user->data['user_id']) { - $auth2 = new auth(); + $auth2 = new phpbb_auth(); $auth2->acl($userdata); $auth_setting = $auth2->acl_get($permission); } diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index cf6716c322..44717452e8 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1554,7 +1554,7 @@ class acp_users || $user_row['user_allow_viewonline'] && !$sql_ary['user_allow_viewonline']) { // We also need to check if the user has the permission to cloak. - $user_auth = new auth(); + $user_auth = new phpbb_auth(); $user_auth->acl($user_row); $session_sql_ary = array( diff --git a/phpBB/includes/acp/auth.php b/phpBB/includes/acp/auth.php index 8f99450776..7d9fd267ff 100644 --- a/phpBB/includes/acp/auth.php +++ b/phpBB/includes/acp/auth.php @@ -19,7 +19,7 @@ if (!defined('IN_PHPBB')) * ACP Permission/Auth class * @package phpBB3 */ -class auth_admin extends auth +class auth_admin extends phpbb_auth { /** * Init auth settings @@ -130,7 +130,7 @@ class auth_admin extends auth { if ($user->data['user_id'] != $userdata['user_id']) { - $auth2 = new auth(); + $auth2 = new phpbb_auth(); $auth2->acl($userdata); } else diff --git a/phpBB/includes/auth.php b/phpBB/includes/auth/auth.php similarity index 99% rename from phpBB/includes/auth.php rename to phpBB/includes/auth/auth.php index 11e86a50fe..e3bccaf47b 100644 --- a/phpBB/includes/auth.php +++ b/phpBB/includes/auth/auth.php @@ -19,7 +19,7 @@ if (!defined('IN_PHPBB')) * Permission/Auth class * @package phpBB3 */ -class auth +class phpbb_auth { var $acl = array(); var $cache = array(); diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index a6fb87536a..434349714b 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -343,7 +343,7 @@ function check_rule(&$rules, &$rule_row, &$message_row, $user_id) $userdata = $db->sql_fetchrow($result); $db->sql_freeresult($result); - $auth2 = new auth(); + $auth2 = new phpbb_auth(); $auth2->acl($userdata); if (!$auth2->acl_get('a_') && !$auth2->acl_get('m_') && !$auth2->acl_getf_global('m_')) diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index d8e655000f..9d838790a0 100644 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -251,7 +251,7 @@ class mcp_warn // Check if can send a notification if ($config['allow_privmsg']) { - $auth2 = new auth(); + $auth2 = new phpbb_auth(); $auth2->acl($user_row); $s_can_notify = ($auth2->acl_get('u_readpm')) ? true : false; unset($auth2); @@ -374,7 +374,7 @@ class mcp_warn // Check if can send a notification if ($config['allow_privmsg']) { - $auth2 = new auth(); + $auth2 = new phpbb_auth(); $auth2->acl($user_row); $s_can_notify = ($auth2->acl_get('u_readpm')) ? true : false; unset($auth2); diff --git a/phpBB/includes/ucp/ucp_remind.php b/phpBB/includes/ucp/ucp_remind.php index bcd4e261fe..4f65ed1866 100644 --- a/phpBB/includes/ucp/ucp_remind.php +++ b/phpBB/includes/ucp/ucp_remind.php @@ -66,7 +66,7 @@ class ucp_remind } // Check users permissions - $auth2 = new auth(); + $auth2 = new phpbb_auth(); $auth2->acl($user_row); if (!$auth2->acl_get('u_chgpasswd')) diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index fb5e79358d..96d984c04c 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -84,7 +84,6 @@ if (!empty($load_extensions) && function_exists('dl')) // Include files require($phpbb_root_path . 'includes/class_loader.' . $phpEx); -require($phpbb_root_path . 'includes/auth.' . $phpEx); require($phpbb_root_path . 'includes/functions.' . $phpEx); diff --git a/phpBB/install/index.php b/phpBB/install/index.php index d3cb68e82e..13ab30a9fa 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -75,7 +75,6 @@ require($phpbb_root_path . 'includes/functions.' . $phpEx); phpbb_require_updated('includes/functions_content.' . $phpEx, true); -include($phpbb_root_path . 'includes/auth.' . $phpEx); include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx); require($phpbb_root_path . 'includes/functions_install.' . $phpEx); @@ -178,7 +177,7 @@ $sub = request_var('sub', ''); set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); $user = new phpbb_user(); -$auth = new auth(); +$auth = new phpbb_auth(); // Add own hook handler, if present. :o if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx)) From b8b342be2d238616b96ace9acbe8af2e18ba1e7a Mon Sep 17 00:00:00 2001 From: Richard Foote Date: Sat, 31 Mar 2012 12:46:44 -0400 Subject: [PATCH 284/335] [Ticket/10675] Correct language string ATTACH_DISK_FULL Add period to ATTACH_DISK_FULL language string PHPBB3-10675 --- phpBB/language/en/posting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/language/en/posting.php b/phpBB/language/en/posting.php index dd0ba7fc6d..24f3204c57 100644 --- a/phpBB/language/en/posting.php +++ b/phpBB/language/en/posting.php @@ -42,7 +42,7 @@ $lang = array_merge($lang, array( 'ADD_POLL' => 'Poll creation', 'ADD_POLL_EXPLAIN' => 'If you do not want to add a poll to your topic leave the fields blank.', 'ALREADY_DELETED' => 'Sorry but this message is already deleted.', - 'ATTACH_DISK_FULL' => 'There is not enough free disk space to post this attachment', + 'ATTACH_DISK_FULL' => 'There is not enough free disk space to post this attachment.', 'ATTACH_QUOTA_REACHED' => 'Sorry, the board attachment quota has been reached.', 'ATTACH_SIG' => 'Attach a signature (signatures can be altered via the UCP)', From b3f46b9565117940b79c7530a1c21336cd072073 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 31 Mar 2012 21:20:18 +0300 Subject: [PATCH 285/335] [ticket/10735] Changing locator paths structure Changing locator paths to 2 dimensional array PHPBB3-10735 --- phpBB/includes/extension/finder.php | 18 +++-- .../style/extension_path_provider.php | 36 +++++----- phpBB/includes/style/path_provider.php | 16 +---- .../style/path_provider_interface.php | 7 -- phpBB/includes/style/resource_locator.php | 66 ++++++++----------- phpBB/includes/style/style.php | 4 +- 6 files changed, 62 insertions(+), 85 deletions(-) diff --git a/phpBB/includes/extension/finder.php b/phpBB/includes/extension/finder.php index 23b9f1c658..87ca40917d 100644 --- a/phpBB/includes/extension/finder.php +++ b/phpBB/includes/extension/finder.php @@ -270,11 +270,12 @@ class phpbb_extension_finder * Finds all directories matching the configured options * * @param bool $cache Whether the result should be cached + * @param bool $extension_keys Whether the result should have extension name as array key * @return array An array of paths to found directories */ - public function get_directories($cache = true) + public function get_directories($cache = true, $extension_keys = false) { - return $this->find_with_root_path($cache, true); + return $this->find_with_root_path($cache, true, $extension_keys); } /** @@ -294,16 +295,25 @@ class phpbb_extension_finder * @param bool $cache Whether the result should be cached * @param bool $is_dir Directories will be returned when true, only files * otherwise + * @param bool $extension_keys If true, result will be associative array + * with extension name as key * @return array An array of paths to found items */ - protected function find_with_root_path($cache = true, $is_dir = false) + protected function find_with_root_path($cache = true, $is_dir = false, $extension_keys = false) { $items = $this->find($cache, $is_dir); $result = array(); foreach ($items as $item => $ext_name) { - $result[] = $this->phpbb_root_path . $item; + if ($extension_keys) + { + $result[$ext_name] = $this->phpbb_root_path . $item; + } + else + { + $result[] = $this->phpbb_root_path . $item; + } } return $result; diff --git a/phpBB/includes/style/extension_path_provider.php b/phpBB/includes/style/extension_path_provider.php index 1fb6580ce1..4eac300424 100644 --- a/phpBB/includes/style/extension_path_provider.php +++ b/phpBB/includes/style/extension_path_provider.php @@ -82,22 +82,26 @@ class phpbb_style_extension_path_provider extends phpbb_extension_provider imple $directories = array(); $finder = $this->extension_manager->get_finder(); - foreach ($this->base_path_provider as $path) + foreach ($this->base_path_provider as $key => $paths) { - if ($path && !phpbb_is_absolute($path)) + if ($key == 'style') { - $directories = array_merge($directories, $finder - ->directory('/' . $this->ext_dir_prefix . $path) - ->get_directories() - ); + foreach ($paths as $path) + { + $directories['style'][] = $path; + if ($path && !phpbb_is_absolute($path)) + { + $result = $finder->directory('/' . $this->ext_dir_prefix . $path) + ->get_directories(true, true); + foreach ($result as $ext => $ext_path) + { + $directories[$ext][] = $ext_path; + } + } + } } } - foreach ($this->base_path_provider as $path) - { - $directories[] = $path; - } - return $directories; } @@ -112,14 +116,4 @@ class phpbb_style_extension_path_provider extends phpbb_extension_provider imple $this->base_path_provider->set_styles($styles); $this->items = null; } - - /** - * Retrieves the path to the main style passed into set_styles() - * - * @return string Main style path - */ - public function get_main_style_path() - { - return $this->base_path_provider->get_main_style_path(); - } } diff --git a/phpBB/includes/style/path_provider.php b/phpBB/includes/style/path_provider.php index c229af92ba..731d682e88 100644 --- a/phpBB/includes/style/path_provider.php +++ b/phpBB/includes/style/path_provider.php @@ -24,7 +24,6 @@ if (!defined('IN_PHPBB')) */ class phpbb_style_path_provider implements IteratorAggregate, phpbb_style_path_provider_interface { - protected $main_style_name = ''; protected $paths = array(); /** @@ -41,25 +40,14 @@ class phpbb_style_path_provider implements IteratorAggregate, phpbb_style_path_p * Overwrites the current style paths * * The first element of the passed styles map, is considered the main - * style and can be retrieved through get_main_style_path(). + * style. * * @param array $styles An array of style paths. The first element is the main style. * @return null */ public function set_styles(array $styles) { - $this->paths = $styles; - $this->main_style_path = $this->paths[0]; - } - - /** - * Retrieves the path to the main style passed into set_styles() - * - * @return string Main style path - */ - public function get_main_style_path() - { - return $this->main_style_path; + $this->paths = array('style' => $styles); } /** diff --git a/phpBB/includes/style/path_provider_interface.php b/phpBB/includes/style/path_provider_interface.php index 7ae94e17f4..1a6153a4d3 100644 --- a/phpBB/includes/style/path_provider_interface.php +++ b/phpBB/includes/style/path_provider_interface.php @@ -39,11 +39,4 @@ interface phpbb_style_path_provider_interface extends Traversable * @return null */ public function set_styles(array $styles); - - /** - * Retrieves the path to the main style passed into set_styles() - * - * @return string Main style path - */ - public function get_main_style_path(); } diff --git a/phpBB/includes/style/resource_locator.php b/phpBB/includes/style/resource_locator.php index af261534c3..39505cedb5 100644 --- a/phpBB/includes/style/resource_locator.php +++ b/phpBB/includes/style/resource_locator.php @@ -38,12 +38,6 @@ class phpbb_style_resource_locator */ private $roots = array(); - /** - * Index of the main style in the roots array. - * @var int - */ - private $main_root_id = 0; - /** * Location of templates directory within style directories. * Must have trailing slash. Empty if templates are stored in root @@ -69,17 +63,6 @@ class phpbb_style_resource_locator */ private $filenames = array(); - /** - * Set main style location (must have been added through set_paths first). - * - * @param string $style_path Path to style directory - * @return null - */ - public function set_main_style($style_path) - { - $this->main_root_id = array_search($style_path, $this->roots, true); - } - /** * Sets the list of style paths * @@ -95,16 +78,18 @@ class phpbb_style_resource_locator $this->roots = array(); $this->files = array(); $this->filenames = array(); - $this->main_root_id = 0; - foreach ($style_paths as $path) + foreach ($style_paths as $key => $paths) { - // Make sure $path has no ending slash - if (substr($path, -1) === '/') + foreach ($paths as $path) { - $path = substr($path, 0, -1); + // Make sure $path has no ending slash + if (substr($path, -1) === '/') + { + $path = substr($path, 0, -1); + } + $this->roots[$key][] = $path; } - $this->roots[] = $path; } } @@ -125,9 +110,12 @@ class phpbb_style_resource_locator $this->filename[$handle] = $filename; - foreach ($this->roots as $root_index => $root) + foreach ($this->roots as $root_key => $root_paths) { - $this->files[$root_index][$handle] = $root . '/' . $this->template_path . $filename; + foreach ($root_paths as $root_index => $root) + { + $this->files[$root_key][$root_index][$handle] = $root . '/' . $this->template_path . $filename; + } } } } @@ -174,12 +162,12 @@ class phpbb_style_resource_locator public function get_virtual_source_file_for_handle($handle) { // If we don't have a file assigned to this handle, die. - if (!isset($this->files[$this->main_root_id][$handle])) + if (!isset($this->files['style'][0][$handle])) { trigger_error("style resource locator: No file specified for handle $handle", E_USER_ERROR); } - $source_file = $this->files[$this->main_root_id][$handle]; + $source_file = $this->files['style'][0][$handle]; return $source_file; } @@ -202,26 +190,28 @@ class phpbb_style_resource_locator public function get_source_file_for_handle($handle) { // If we don't have a file assigned to this handle, die. - if (!isset($this->files[$this->main_root_id][$handle])) + if (!isset($this->files['style'][0][$handle])) { trigger_error("style resource locator: No file specified for handle $handle", E_USER_ERROR); } // locate a source file that exists - $source_file = $this->files[0][$handle]; + $source_file = $this->files['style'][0][$handle]; $tried = $source_file; - for ($i = 1, $n = count($this->roots); $i < $n && !file_exists($source_file); $i++) + foreach ($this->roots as $root_key => $root_paths) { - $source_file = $this->files[$i][$handle]; - $tried .= ', ' . $source_file; + foreach ($root_paths as $root_index => $root) + { + $source_file = $this->files[$root_key][$root_index][$handle]; + if (file_exists($source_file)) + { + return $source_file; + } + $tried .= ', ' . $source_file; + } } // search failed - if (!file_exists($source_file)) - { - trigger_error("style resource locator: File for handle $handle does not exist. Could not find: $tried", E_USER_ERROR); - } - - return $source_file; + trigger_error("style resource locator: File for handle $handle does not exist. Could not find: $tried", E_USER_ERROR); } } diff --git a/phpBB/includes/style/style.php b/phpBB/includes/style/style.php index 539a2642ee..dc1e71dff6 100644 --- a/phpBB/includes/style/style.php +++ b/phpBB/includes/style/style.php @@ -92,6 +92,9 @@ class phpbb_style $paths[] = $this->get_style_path($dir); } + // Add 'all' path, used as last fallback path by hooks and extensions + $paths[] = $this->get_style_path('all'); + return $this->set_custom_style($style_name, $paths); } @@ -113,7 +116,6 @@ class phpbb_style $this->provider->set_styles($paths); $this->locator->set_paths($this->provider); - $this->locator->set_main_style($this->provider->get_main_style_path()); $this->template->cachepath = $this->phpbb_root_path . 'cache/tpl_' . str_replace('_', '-', $name) . '_'; From 2ce73baeab35adc3515a04c1db38af62c98d5c93 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 31 Mar 2012 22:07:04 +0300 Subject: [PATCH 286/335] [ticket/10733] Extending get_source_file_for_handle Extending resource locator's function get_source_file_for_handle to find all files. This modified function should be used by template events to locate all templates before compiling them. PHPBB3-10733 --- phpBB/includes/style/resource_locator.php | 31 ++++++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/phpBB/includes/style/resource_locator.php b/phpBB/includes/style/resource_locator.php index 39505cedb5..1b35752111 100644 --- a/phpBB/includes/style/resource_locator.php +++ b/phpBB/includes/style/resource_locator.php @@ -185,9 +185,12 @@ class phpbb_style_resource_locator * handle to a path without any filesystem or styles tree checks. * * @param string $handle Template handle (i.e. "friendly" template name) + * @param bool $find_all If true, each root path will be checked and function + * will return array of files instead of string and will not + * trigger a error if template does not exist * @return string Source file path */ - public function get_source_file_for_handle($handle) + public function get_source_file_for_handle($handle, $find_all = false) { // If we don't have a file assigned to this handle, die. if (!isset($this->files['style'][0][$handle])) @@ -198,20 +201,40 @@ class phpbb_style_resource_locator // locate a source file that exists $source_file = $this->files['style'][0][$handle]; $tried = $source_file; + $found = false; + $found_all = array(); foreach ($this->roots as $root_key => $root_paths) { foreach ($root_paths as $root_index => $root) { $source_file = $this->files[$root_key][$root_index][$handle]; + $tried .= ', ' . $source_file; if (file_exists($source_file)) { - return $source_file; + $found = true; + break; + } + } + if ($found) + { + if ($find_all) + { + $found_all[] = $source_file; + $found = false; + } + else + { + break; } - $tried .= ', ' . $source_file; } } // search failed - trigger_error("style resource locator: File for handle $handle does not exist. Could not find: $tried", E_USER_ERROR); + if (!$found && !$find_all) + { + trigger_error("style resource locator: File for handle $handle does not exist. Could not find: $tried", E_USER_ERROR); + } + + return ($find_all) ? $found_all : $source_file; } } From 5ccd6915e3e8af30856319d84a48dde074fdbaee Mon Sep 17 00:00:00 2001 From: David King Date: Sat, 31 Mar 2012 15:52:16 -0400 Subject: [PATCH 287/335] [feature/qrpreview] Do not error or show preview if no text is entered PHPBB3-10726 --- phpBB/posting.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/posting.php b/phpBB/posting.php index 71ba353e89..7f57f693af 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -38,7 +38,7 @@ $load = (isset($_POST['load'])) ? true : false; $delete = (isset($_POST['delete'])) ? true : false; $cancel = (isset($_POST['cancel']) && !isset($_POST['save'])) ? true : false; -$refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['cancel_unglobalise']) || $save || $load) ? true : false; +$refresh = (isset($_POST['add_file']) || isset($_POST['delete_file']) || isset($_POST['cancel_unglobalise']) || $save || $load || $preview) ? true : false; $mode = ($delete && !$preview && !$refresh && $submit) ? 'delete' : request_var('mode', ''); $error = $post_data = array(); @@ -1198,8 +1198,8 @@ if (!sizeof($error) && $preview) 'PREVIEW_MESSAGE' => $preview_message, 'PREVIEW_SIGNATURE' => $preview_signature, - 'S_DISPLAY_PREVIEW' => true) - ); + 'S_DISPLAY_PREVIEW' => !empty($preview_message), + )); } } From f80512f1066ebfc09d2a4ffac412c56a3fb247de Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 1 Apr 2012 09:52:55 +0300 Subject: [PATCH 288/335] [ticket/10733] Adding functions to locate resources Adding $style->locate() and $template->locate() functions PHPBB3-10733 --- phpBB/includes/style/resource_locator.php | 51 +++++++++++++++++++++++ phpBB/includes/style/style.php | 28 +++++++++++++ phpBB/includes/style/template.php | 36 ++++++++++++++++ 3 files changed, 115 insertions(+) diff --git a/phpBB/includes/style/resource_locator.php b/phpBB/includes/style/resource_locator.php index 1b35752111..3e6dd5d6aa 100644 --- a/phpBB/includes/style/resource_locator.php +++ b/phpBB/includes/style/resource_locator.php @@ -237,4 +237,55 @@ class phpbb_style_resource_locator return ($find_all) ? $found_all : $source_file; } + + /** + * Locates source file path, accounting for styles tree and verifying that + * the path exists. + * + * Unlike previous functions, this function works without template handle + * and it can search for more than one file. If more than one file name is + * specified, it will return location of file that it finds first. + * + * @param array $files List of files to locate. + * @param bool $return_default Determines what to return if file does not + * exist. If true, function will return location where file is + * supposed to be. If false, function will return false. + * @param bool $return_full_path If true, function will return full path + * to file. If false, function will return file name. This + * parameter can be used to check which one of set of files + * is available. + * @return string or boolean Source file path if file exists or $return_default is + * true. False if file does not exist and $return_default is false + */ + public function get_first_file_location($files, $return_default = false, $return_full_path = true) + { + // set default value + $default_result = false; + + // check all available paths + foreach ($this->roots as $root_paths) + { + foreach ($root_paths as $path) + { + // check all files + foreach ($files as $filename) + { + $source_file = $path . '/' . $filename; + if (file_exists($source_file)) + { + return ($return_full_path) ? $source_file : $filename; + } + + // assign first file as result if $return_default is true + if ($return_default && $default_result === false) + { + $default_result = $source_file; + } + } + } + } + + // search failed + return $default_result; + } } diff --git a/phpBB/includes/style/style.php b/phpBB/includes/style/style.php index dc1e71dff6..5ac61c9f10 100644 --- a/phpBB/includes/style/style.php +++ b/phpBB/includes/style/style.php @@ -150,4 +150,32 @@ class phpbb_style { $this->provider->set_ext_dir_prefix($ext_dir_prefix); } + + /** + * Locates source file path, accounting for styles tree and verifying that + * the path exists. + * + * @param string or array $files List of files to locate. If there is only + * one file, $files can be a string to make code easier to read. + * @param bool $return_default Determines what to return if file does not + * exist. If true, function will return location where file is + * supposed to be. If false, function will return false. + * @param bool $return_full_path If true, function will return full path + * to file. If false, function will return file name. This + * parameter can be used to check which one of set of files + * is available. + * @return string or boolean Source file path if file exists or $return_default is + * true. False if file does not exist and $return_default is false + */ + public function locate($files, $return_default = false, $return_full_path = true) + { + // convert string to array + if (is_string($files)) + { + $files = array($files); + } + + // use resource locator to find files + return $this->locator->get_first_file_location($files, $return_default, $return_full_path); + } } diff --git a/phpBB/includes/style/template.php b/phpBB/includes/style/template.php index 21a2e821dd..aebf1da603 100644 --- a/phpBB/includes/style/template.php +++ b/phpBB/includes/style/template.php @@ -456,4 +456,40 @@ class phpbb_style_template } include($file); } + + /** + * Locates source template path, accounting for styles tree and verifying that + * the path exists. + * + * @param string or array $files List of templates to locate. If there is only + * one template, $files can be a string to make code easier to read. + * @param bool $return_default Determines what to return if template does not + * exist. If true, function will return location where template is + * supposed to be. If false, function will return false. + * @param bool $return_full_path If true, function will return full path + * to template. If false, function will return template file name. + * This parameter can be used to check which one of set of template + * files is available. + * @return string or boolean Source template path if template exists or $return_default is + * true. False if template does not exist and $return_default is false + */ + public function locate($files, $return_default = false, $return_full_path = true) + { + // add tempalte path prefix + $templates = array(); + if (is_string($files)) + { + $templates[] = $this->template_path . $files; + } + else + { + foreach ($files as $file) + { + $templates[] = $this->template_path . $file; + } + } + + // use resource locator to find files + return $this->locator->get_first_file_location($templates, $return_default, $return_full_path); + } } From 2509853ca530b3b5e0d5b2e10080eeba5a29d937 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 1 Apr 2012 09:53:23 +0300 Subject: [PATCH 289/335] [ticket/10733] Adding test for locator Adding test for $template->locate PHPBB3-10733 --- tests/template/template_locate_test.php | 84 +++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 tests/template/template_locate_test.php diff --git a/tests/template/template_locate_test.php b/tests/template/template_locate_test.php new file mode 100644 index 0000000000..591a6afe0c --- /dev/null +++ b/tests/template/template_locate_test.php @@ -0,0 +1,84 @@ +setup_engine(); + + // Locate template + $result = $this->template->locate($files, $return_default, $return_full_path); + $this->assertEquals($result, $expected); + } + + protected function setup_engine(array $new_config = array()) + { + global $phpbb_root_path, $phpEx, $user; + + $defaults = $this->config_defaults(); + $config = new phpbb_config(array_merge($defaults, $new_config)); + + $this->template_path = dirname(__FILE__) . '/templates'; + $this->parent_template_path = dirname(__FILE__) . '/parent_templates'; + $this->style_resource_locator = new phpbb_style_resource_locator(); + $this->style_provider = new phpbb_style_path_provider(); + $this->template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider); + $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template); + $this->style->set_custom_style('tests', array($this->template_path, $this->parent_template_path), ''); + } +} From a7d0ef90ea921b2ed876bb933bfa022863771a6e Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 1 Apr 2012 10:58:24 +0300 Subject: [PATCH 290/335] [ticket/10665] INCLUDEJS template tag Implementing INLCUDEJS template tag in style classes PHPBB3-10665 --- phpBB/includes/style/template.php | 21 +++++++- phpBB/includes/style/template_compile.php | 32 +++++++++++- phpBB/includes/style/template_filter.php | 61 ++++++++++++++++++++++- 3 files changed, 109 insertions(+), 5 deletions(-) diff --git a/phpBB/includes/style/template.php b/phpBB/includes/style/template.php index aebf1da603..4586e8dbf9 100644 --- a/phpBB/includes/style/template.php +++ b/phpBB/includes/style/template.php @@ -288,7 +288,7 @@ class phpbb_style_template return new phpbb_style_template_renderer_include($output_file, $this); } - $compile = new phpbb_style_template_compile($this->config['tpl_allow_php']); + $compile = new phpbb_style_template_compile($this->config['tpl_allow_php'], $this->locator, $this->phpbb_root_path); if ($compile->compile_file_to_file($source_file, $output_file) !== false) { @@ -492,4 +492,23 @@ class phpbb_style_template // use resource locator to find files return $this->locator->get_first_file_location($templates, $return_default, $return_full_path); } + + /** + * Include JS file + * + * @param string $file file name + * @param bool $locate True if file needs to be located + */ + function _js_include($file, $locate = false) + { + // Locate file + if ($locate) + { + $file = $this->locator->get_first_file_location(array($file), true, true); + } + + // Add HTML code + $code = ''; + $this->context->append_var('SCRIPTS', $code); + } } diff --git a/phpBB/includes/style/template_compile.php b/phpBB/includes/style/template_compile.php index 3ef3fffc00..bd9e18e102 100644 --- a/phpBB/includes/style/template_compile.php +++ b/phpBB/includes/style/template_compile.php @@ -25,6 +25,13 @@ stream_filter_register('phpbb_template', 'phpbb_style_template_filter'); */ class phpbb_style_template_compile { + /** + * Array of parameters to forward to template filter + * + * @var array + */ + private $filter_params; + /** * Whether tags are allowed * @@ -32,14 +39,31 @@ class phpbb_style_template_compile */ private $allow_php; + /** + * Style resource locator + * + * @var phpbb_style_resource_locator + */ + private $locator; + + /** + * @var string phpBB root path + */ + private $phpbb_root_path; + /** * Constructor. * * @param bool @allow_php Whether PHP code will be allowed in templates (inline PHP code, PHP tag and INCLUDEPHP tag) + * @param phpbb_style_resource_locator $locator Resource locator + * @param string $phpbb_root_path Path to phpBB root directory */ - public function __construct($allow_php) + public function __construct($allow_php, $locator, $phpbb_root_path) { + $this->filter_params = array(); $this->allow_php = $allow_php; + $this->locator = $locator; + $this->phpbb_root_path = $phpbb_root_path; } /** @@ -116,7 +140,11 @@ class phpbb_style_template_compile */ private function compile_stream_to_stream($source_stream, $dest_stream) { - stream_filter_append($source_stream, 'phpbb_template', null, array('allow_php' => $this->allow_php)); + $params = $this->filter_params; + $params['allow_php'] = $this->allow_php; + $params['locator'] = $this->locator; + $params['phpbb_root_path'] = $this->phpbb_root_path; + stream_filter_append($source_stream, 'phpbb_template', null, $params); stream_copy_to_stream($source_stream, $dest_stream); } } diff --git a/phpBB/includes/style/template_filter.php b/phpBB/includes/style/template_filter.php index 04fe85e07f..d62ad0ba1e 100644 --- a/phpBB/includes/style/template_filter.php +++ b/phpBB/includes/style/template_filter.php @@ -75,6 +75,18 @@ class phpbb_style_template_filter extends php_user_filter */ private $allow_php; + /** + * Resource locator. + * + * @var phpbb_template_locator + */ + private $locator; + + /** + * @var string phpBB root path + */ + private $phpbb_root_path; + /** * Stream filter * @@ -126,14 +138,16 @@ class phpbb_style_template_filter extends php_user_filter /** * Initializer, called on creation. * - * Get the allow_php option from params, which is passed - * to stream_filter_append. + * Get the allow_php option, root directory and locator from params, + * which are passed to stream_filter_append. */ public function onCreate() { $this->chunk = ''; $this->in_php = false; $this->allow_php = $this->params['allow_php']; + $this->locator = $this->params['locator']; + $this->phpbb_root_path = $this->params['phpbb_root_path']; return true; } @@ -281,6 +295,10 @@ class phpbb_style_template_filter extends php_user_filter return ($this->allow_php) ? 'compile_tag_include_php($matches[2]) . ' ?>' : ''; break; + case 'INCLUDEJS': + return 'compile_tag_include_js($matches[2]) . ' ?>'; + break; + case 'PHP': if ($this->allow_php) { @@ -856,6 +874,45 @@ class phpbb_style_template_filter extends php_user_filter return $tokens; } + /** + * Compile INCLUDEJS tag + * + * @param string $tag_args Expression given with INCLUDEJS in source template + * @return string compiled template code + */ + private function compile_tag_include_js($tag_args) + { + // Process dynamic includes + if ($tag_args[0] == '{') + { + $var = $this->get_varref($tag_args, $is_expr); + if (!$is_expr) + { + return " \$_template->_js_include($var, true);"; + } + return ''; + } + + // Locate file + $filename = $this->locator->get_first_file_location(array($tag_args), false, true); + + if ($filename === false) + { + // File does not exist, find it during run time + return ' $_template->_js_include(\'' . addslashes($tag_args) . '\', true); '; + } + + if (substr($filename, 0, strlen($this->phpbb_root_path)) != $this->phpbb_root_path) + { + // Absolute path, include as is + return ' $_template->_js_include(\'' . addslashes($filename) . '\', false); '; + } + + // Relative path, remove root path from it + $filename = substr($filename, strlen($this->phpbb_root_path)); + return ' global $phpbb_root_path; $_template->_js_include($phpbb_root_path . \'' . addslashes($filename) . '\', false); '; + } + /** * Generates a reference to the given variable inside the given (possibly nested) * block namespace. This is a string of the form: From 2225efc5609add8baf0dc0e7867d9f9f0fae4245 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 1 Apr 2012 10:58:59 +0300 Subject: [PATCH 291/335] [ticket/10665] INCLUDEJS template changes Implementing INLCUDEJS template tag in styles PHPBB3-10665 --- phpBB/styles/prosilver/template/overall_footer.html | 3 ++- phpBB/styles/prosilver/template/simple_footer.html | 1 + phpBB/styles/subsilver2/template/overall_footer.html | 1 + phpBB/styles/subsilver2/template/simple_footer.html | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html index 1561bae26a..47071ba4df 100644 --- a/phpBB/styles/prosilver/template/overall_footer.html +++ b/phpBB/styles/prosilver/template/overall_footer.html @@ -52,7 +52,8 @@ - + +{SCRIPTS} diff --git a/phpBB/styles/prosilver/template/simple_footer.html b/phpBB/styles/prosilver/template/simple_footer.html index 3458d02495..549c31cfb6 100644 --- a/phpBB/styles/prosilver/template/simple_footer.html +++ b/phpBB/styles/prosilver/template/simple_footer.html @@ -8,6 +8,7 @@ +{SCRIPTS} diff --git a/phpBB/styles/subsilver2/template/overall_footer.html b/phpBB/styles/subsilver2/template/overall_footer.html index 9b0b95372e..77b11034b9 100644 --- a/phpBB/styles/subsilver2/template/overall_footer.html +++ b/phpBB/styles/subsilver2/template/overall_footer.html @@ -10,6 +10,7 @@ +{SCRIPTS} diff --git a/phpBB/styles/subsilver2/template/simple_footer.html b/phpBB/styles/subsilver2/template/simple_footer.html index b51be3ac4c..4a65bafd1c 100644 --- a/phpBB/styles/subsilver2/template/simple_footer.html +++ b/phpBB/styles/subsilver2/template/simple_footer.html @@ -7,6 +7,7 @@ +{SCRIPTS} From 38c988fb5997f947976ca4c12e3e0d57d1e82b60 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 1 Apr 2012 11:16:57 +0300 Subject: [PATCH 292/335] [ticket/10665] Changing template compiler test Adding new constructor parameters to template compiler test PHPBB3-10665 --- tests/template/template_compile_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/template/template_compile_test.php b/tests/template/template_compile_test.php index fb158cabd5..e2264fb1b7 100644 --- a/tests/template/template_compile_test.php +++ b/tests/template/template_compile_test.php @@ -16,7 +16,7 @@ class phpbb_template_template_compile_test extends phpbb_test_case protected function setUp() { - $this->template_compile = new phpbb_style_template_compile(false); + $this->template_compile = new phpbb_style_template_compile(false, null, ''); $this->template_path = dirname(__FILE__) . '/templates'; } From 4b2ede433e9336cf115fdd41e5c88738b03aa448 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 1 Apr 2012 11:17:13 +0300 Subject: [PATCH 293/335] [ticket/10665] INCLUDEJS unit test Adding INLCUDEJS test PHPBB3-10665 --- tests/template/template_includejs_test.php | 48 ++++++++++++++++++++++ tests/template/templates/includejs.html | 5 +++ 2 files changed, 53 insertions(+) create mode 100644 tests/template/template_includejs_test.php create mode 100644 tests/template/templates/includejs.html diff --git a/tests/template/template_includejs_test.php b/tests/template/template_includejs_test.php new file mode 100644 index 0000000000..e0229e978b --- /dev/null +++ b/tests/template/template_includejs_test.php @@ -0,0 +1,48 @@ +setup_engine(); + + // Prepare correct result + $dir = dirname(__FILE__); + $scripts = array( + '', + '', + '' + ); + + // Run test + $cache_file = $this->template->cachepath . 'includejs.html.php'; + $this->run_template('includejs.html', array('PARENT' => 'parent_only.html'), array(), array(), implode('', $scripts), $cache_file); + } + + protected function setup_engine(array $new_config = array()) + { + global $phpbb_root_path, $phpEx, $user; + + $defaults = $this->config_defaults(); + $config = new phpbb_config(array_merge($defaults, $new_config)); + + $this->template_path = dirname(__FILE__) . '/templates'; + $this->parent_template_path = dirname(__FILE__) . '/parent_templates'; + $this->style_resource_locator = new phpbb_style_resource_locator(); + $this->style_provider = new phpbb_style_path_provider(); + $this->template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider); + $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template); + $this->style->set_custom_style('tests', array($this->template_path, $this->parent_template_path), ''); + $this->template->set_filenames(array('body' => 'includejs.html')); + } +} diff --git a/tests/template/templates/includejs.html b/tests/template/templates/includejs.html new file mode 100644 index 0000000000..186fc30b43 --- /dev/null +++ b/tests/template/templates/includejs.html @@ -0,0 +1,5 @@ + + + + +{SCRIPTS} \ No newline at end of file From e7cf4bfb2ed2b549e567c7237df799b6af0977ae Mon Sep 17 00:00:00 2001 From: Hari Sankar R Date: Sun, 1 Apr 2012 18:25:50 +0530 Subject: [PATCH 294/335] [ticket/10731] Fixed addquote() to work on opera browser. In opera, window.getSelection() returned incorrect values, should be using document.getSelection() instead. Fixed in prosilver and subsilver2 templates. PHPBB3-10731 --- phpBB/styles/prosilver/template/editor.js | 2 +- phpBB/styles/subsilver2/template/editor.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/styles/prosilver/template/editor.js b/phpBB/styles/prosilver/template/editor.js index 2c41b543b5..c16b0ef703 100644 --- a/phpBB/styles/prosilver/template/editor.js +++ b/phpBB/styles/prosilver/template/editor.js @@ -219,7 +219,7 @@ function addquote(post_id, username, l_wrote) // Get text selection - not only the post content :( // IE9 must use the document.selection method but has the *.getSelection so we just force no IE - if (window.getSelection && !is_ie) + if (window.getSelection && !is_ie && !window.opera) { theSelection = window.getSelection().toString(); } diff --git a/phpBB/styles/subsilver2/template/editor.js b/phpBB/styles/subsilver2/template/editor.js index b47583ec75..151cf53ff1 100644 --- a/phpBB/styles/subsilver2/template/editor.js +++ b/phpBB/styles/subsilver2/template/editor.js @@ -221,7 +221,7 @@ function addquote(post_id, username, l_wrote) // Get text selection - not only the post content :( // IE9 must use the document.selection method but has the *.getSelection so we just force no IE - if (window.getSelection && !is_ie) + if (window.getSelection && !is_ie && !window.opera) { theSelection = window.getSelection().toString(); } From 48616c7cf25555f2a5ae681a245ac0da9e812d89 Mon Sep 17 00:00:00 2001 From: Hari Sankar R Date: Sun, 1 Apr 2012 18:33:18 +0530 Subject: [PATCH 295/335] [ticket/10740] Changed styling of phpbb_alert box, to be centered. Changed the styling of the phpbb.alert() and phpbb.confirm() dialogue boxes to me more centered on a page. PHPBB3-10740 --- phpBB/styles/prosilver/theme/common.css | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index 31015b28f9..e154db236f 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -594,9 +594,10 @@ li.pagination { border: 1px solid transparent; position: fixed; display: none; - top: 100px; - left: 35%; + top: 40%; + left: 50%; width: 30%; + margin-left: -15%; z-index: 50; padding: 25px; padding: 0 25px 20px 25px; From b1b530f92cca7eb115e096ea8901133d421771d2 Mon Sep 17 00:00:00 2001 From: Hari Sankar R Date: Sun, 1 Apr 2012 18:25:50 +0530 Subject: [PATCH 296/335] [ticket/10731] Fixed addquote() to work on opera browser. In opera, window.getSelection() returned incorrect values, should be using document.getSelection() instead. Fixed in prosilver and subsilver2 templates. PHPBB3-10731 --- phpBB/styles/prosilver/template/editor.js | 4 ++-- phpBB/styles/subsilver2/template/editor.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/styles/prosilver/template/editor.js b/phpBB/styles/prosilver/template/editor.js index cfdb54f54b..c16b0ef703 100644 --- a/phpBB/styles/prosilver/template/editor.js +++ b/phpBB/styles/prosilver/template/editor.js @@ -219,7 +219,7 @@ function addquote(post_id, username, l_wrote) // Get text selection - not only the post content :( // IE9 must use the document.selection method but has the *.getSelection so we just force no IE - if (window.getSelection && !is_ie) + if (window.getSelection && !is_ie && !window.opera) { theSelection = window.getSelection().toString(); } @@ -456,4 +456,4 @@ function getCaretPosition(txtarea) } return caretPos; -} \ No newline at end of file +} diff --git a/phpBB/styles/subsilver2/template/editor.js b/phpBB/styles/subsilver2/template/editor.js index 7cc5de9034..151cf53ff1 100644 --- a/phpBB/styles/subsilver2/template/editor.js +++ b/phpBB/styles/subsilver2/template/editor.js @@ -221,7 +221,7 @@ function addquote(post_id, username, l_wrote) // Get text selection - not only the post content :( // IE9 must use the document.selection method but has the *.getSelection so we just force no IE - if (window.getSelection && !is_ie) + if (window.getSelection && !is_ie && !window.opera) { theSelection = window.getSelection().toString(); } @@ -459,4 +459,4 @@ function getCaretPosition(txtarea) } return caretPos; -} \ No newline at end of file +} From f5bac7686b1678dbd33eddd368d845237bb18943 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 1 Apr 2012 19:14:53 +0300 Subject: [PATCH 297/335] [ticket/10733] Removing static from data providers Removing static from data provider functions PHPBB3-10733 --- tests/dbal/select_test.php | 14 +++++++------- tests/dbal/write_test.php | 4 ++-- tests/group_positions/group_positions_test.php | 14 +++++++------- tests/request/request_var_test.php | 4 ++-- tests/security/extract_current_page_test.php | 2 +- tests/security/redirect_test.php | 2 +- tests/template/template_inheritance_test.php | 2 +- tests/template/template_locate_test.php | 2 +- tests/template/template_test.php | 4 ++-- tests/text_processing/make_clickable_test.php | 2 +- tests/utf/utf8_clean_string_test.php | 2 +- 11 files changed, 26 insertions(+), 26 deletions(-) diff --git a/tests/dbal/select_test.php b/tests/dbal/select_test.php index 21b12777dc..cc213f09bc 100644 --- a/tests/dbal/select_test.php +++ b/tests/dbal/select_test.php @@ -17,7 +17,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/three_users.xml'); } - public static function return_on_error_select_data() + public function return_on_error_select_data() { return array( array('phpbb_users', "username_clean = 'bertie'", array(array('username_clean' => 'bertie'))), @@ -44,7 +44,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case $this->assertEquals($expected, $db->sql_fetchrowset($result)); } - public static function fetchrow_data() + public function fetchrow_data() { return array( array('', array(array('username_clean' => 'barfoo'), @@ -95,7 +95,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case $db->sql_freeresult($result); } - public static function fetchfield_data() + public function fetchfield_data() { return array( array('', array('barfoo', 'foobar', 'bertie')), @@ -125,7 +125,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case $this->assertEquals($expected, $ary); } - public static function query_limit_data() + public function query_limit_data() { return array( array(0, 0, array(array('username_clean' => 'barfoo'), @@ -166,7 +166,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case $this->assertEquals($expected, $ary); } - public static function like_expression_data() + public function like_expression_data() { // * = any_char; # = one_char return array( @@ -203,7 +203,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case $db->sql_freeresult($result); } - public static function in_set_data() + public function in_set_data() { return array( array('user_id', 3, false, false, array(array('username_clean' => 'bertie'))), @@ -277,7 +277,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case $db->sql_freeresult($result); } - public static function build_array_data() + public function build_array_data() { return array( array(array('username_clean' => 'barfoo'), array(array('username_clean' => 'barfoo'))), diff --git a/tests/dbal/write_test.php b/tests/dbal/write_test.php index 596c50a220..987161a831 100644 --- a/tests/dbal/write_test.php +++ b/tests/dbal/write_test.php @@ -16,7 +16,7 @@ class phpbb_dbal_write_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/config.xml'); } - public static function build_array_insert_data() + public function build_array_insert_data() { return array( array(array( @@ -104,7 +104,7 @@ class phpbb_dbal_write_test extends phpbb_database_test_case $db->sql_freeresult($result); } - public static function update_data() + public function update_data() { return array( array( diff --git a/tests/group_positions/group_positions_test.php b/tests/group_positions/group_positions_test.php index fd9f57e78f..c17e25511b 100644 --- a/tests/group_positions/group_positions_test.php +++ b/tests/group_positions/group_positions_test.php @@ -15,7 +15,7 @@ class phpbb_group_positions_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/group_positions.xml'); } - public static function get_group_value_data() + public function get_group_value_data() { return array( array('teampage', 1, 0), @@ -38,7 +38,7 @@ class phpbb_group_positions_test extends phpbb_database_test_case $this->assertEquals($expected, $test_class->get_group_value($group_id)); } - public static function get_group_count_data() + public function get_group_count_data() { return array( array('teampage', 2), @@ -59,7 +59,7 @@ class phpbb_group_positions_test extends phpbb_database_test_case $this->assertEquals($expected, $test_class->get_group_count()); } - public static function add_group_data() + public function add_group_data() { return array( array('teampage', 1, array( @@ -93,7 +93,7 @@ class phpbb_group_positions_test extends phpbb_database_test_case $this->assertEquals($expected, $db->sql_fetchrowset($result)); } - public static function delete_group_data() + public function delete_group_data() { return array( array('teampage', 1, false, array( @@ -147,7 +147,7 @@ class phpbb_group_positions_test extends phpbb_database_test_case $this->assertEquals($expected, $db->sql_fetchrowset($result)); } - public static function move_up_data() + public function move_up_data() { return array( array('teampage', 1, array( @@ -186,7 +186,7 @@ class phpbb_group_positions_test extends phpbb_database_test_case $this->assertEquals($expected, $db->sql_fetchrowset($result)); } - public static function move_down_data() + public function move_down_data() { return array( array('teampage', 1, array( @@ -225,7 +225,7 @@ class phpbb_group_positions_test extends phpbb_database_test_case $this->assertEquals($expected, $db->sql_fetchrowset($result)); } - public static function move_data() + public function move_data() { return array( array('teampage', 1, 1, array( diff --git a/tests/request/request_var_test.php b/tests/request/request_var_test.php index 1fa0afae13..0e85d4694b 100644 --- a/tests/request/request_var_test.php +++ b/tests/request/request_var_test.php @@ -112,7 +112,7 @@ class phpbb_request_var_test extends phpbb_test_case $this->assertEquals($expected, $result, 'Testing deep access to multidimensional input arrays: ' . $path); } - public static function deep_access() + public function deep_access() { return array( // array(path, default, expected result) @@ -123,7 +123,7 @@ class phpbb_request_var_test extends phpbb_test_case ); } - public static function request_variables() + public function request_variables() { return array( // strings diff --git a/tests/security/extract_current_page_test.php b/tests/security/extract_current_page_test.php index b4a475ffb3..d77cbbcaf3 100644 --- a/tests/security/extract_current_page_test.php +++ b/tests/security/extract_current_page_test.php @@ -13,7 +13,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_security_extract_current_page_test extends phpbb_security_test_base { - public static function security_variables() + public function security_variables() { return array( array('http://localhost/phpBB/index.php', 'mark=forums&x=">', 'mark=forums&x=%22%3E%3Cscript%3Ealert(/XSS/);%3C/script%3E'), diff --git a/tests/security/redirect_test.php b/tests/security/redirect_test.php index da318209e2..1325466137 100644 --- a/tests/security/redirect_test.php +++ b/tests/security/redirect_test.php @@ -13,7 +13,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; class phpbb_security_redirect_test extends phpbb_security_test_base { - public static function provider() + public function provider() { // array(Input -> redirect(), expected triggered error (else false), expected returned result url (else false)) return array( diff --git a/tests/template/template_inheritance_test.php b/tests/template/template_inheritance_test.php index 7348da9a4a..a76658701a 100644 --- a/tests/template/template_inheritance_test.php +++ b/tests/template/template_inheritance_test.php @@ -14,7 +14,7 @@ class phpbb_template_template_inheritance_test extends phpbb_template_template_t /** * @todo put test data into templates/xyz.test */ - public static function template_data() + public function template_data() { return array( // First element of the array is test name - keep them distinct diff --git a/tests/template/template_locate_test.php b/tests/template/template_locate_test.php index 591a6afe0c..8edbd6a008 100644 --- a/tests/template/template_locate_test.php +++ b/tests/template/template_locate_test.php @@ -11,7 +11,7 @@ require_once dirname(__FILE__) . '/template_test_case.php'; class phpbb_template_template_locate_test extends phpbb_template_template_test_case { - public static function template_data() + public function template_data() { return array( // First element of the array is test name - keep them distinct diff --git a/tests/template/template_test.php b/tests/template/template_test.php index edf621e16c..739bbe9387 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -15,7 +15,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case /** * @todo put test data into templates/xyz.test */ - public static function template_data() + public function template_data() { return array( /* @@ -394,7 +394,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case $this->run_template('php.html', array(), array(), array(), 'test', $cache_file); } - public static function alter_block_array_data() + public function alter_block_array_data() { return array( array( diff --git a/tests/text_processing/make_clickable_test.php b/tests/text_processing/make_clickable_test.php index 8697907311..d94fac2ae4 100644 --- a/tests/text_processing/make_clickable_test.php +++ b/tests/text_processing/make_clickable_test.php @@ -12,7 +12,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; class phpbb_text_processing_make_clickable_test extends phpbb_test_case { - public static function make_clickable_data() + public function make_clickable_data() { // value => whether it should work $prefix_texts = array( diff --git a/tests/utf/utf8_clean_string_test.php b/tests/utf/utf8_clean_string_test.php index 70bd549d5b..ae11e00fbd 100644 --- a/tests/utf/utf8_clean_string_test.php +++ b/tests/utf/utf8_clean_string_test.php @@ -11,7 +11,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; class phpbb_utf_utf8_clean_string_test extends phpbb_test_case { - public static function cleanable_strings() + public function cleanable_strings() { return array( array('MiXed CaSe', 'mixed case', 'Checking case folding'), From eaba2ed9ca6025358de0432bb569cfb2e3ca6985 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 1 Apr 2012 19:20:42 +0300 Subject: [PATCH 298/335] [ticket/10733] Fixing test Changing expected and result in locator test PHPBB3-10733 --- tests/template/template_locate_test.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/template/template_locate_test.php b/tests/template/template_locate_test.php index 8edbd6a008..89a4ae6fb1 100644 --- a/tests/template/template_locate_test.php +++ b/tests/template/template_locate_test.php @@ -17,38 +17,38 @@ class phpbb_template_template_locate_test extends phpbb_template_template_test_c // First element of the array is test name - keep them distinct array( 'simple inheritance - only parent template exists', + dirname(__FILE__) . '/parent_templates/parent_only.html', 'parent_only.html', false, true, - dirname(__FILE__) . '/parent_templates/parent_only.html', ), array( 'simple inheritance - only child template exists', + dirname(__FILE__) . '/templates/child_only.html', 'child_only.html', false, true, - dirname(__FILE__) . '/templates/child_only.html', ), array( 'simple inheritance - both parent and child templates exist', + dirname(__FILE__) . '/templates/parent_and_child.html', 'parent_and_child.html', false, true, - dirname(__FILE__) . '/templates/parent_and_child.html', ), array( 'find first template - only child template exists in main style', + 'child_only.html', array('parent_only.html', 'child_only.html'), false, false, - 'child_only.html', ), array( 'find first template - both templates exist in main style', + 'parent_and_child.html', array('parent_and_child.html', 'child_only.html'), false, false, - 'parent_and_child.html', ), ); } @@ -56,14 +56,14 @@ class phpbb_template_template_locate_test extends phpbb_template_template_test_c /** * @dataProvider template_data */ - public function test_template($name, $files, $return_default, $return_full_path, $expected) + public function test_template($name, $expected, $files, $return_default, $return_full_path) { // Reset the engine state $this->setup_engine(); // Locate template $result = $this->template->locate($files, $return_default, $return_full_path); - $this->assertEquals($result, $expected); + $this->assertSame($expected, $result); } protected function setup_engine(array $new_config = array()) From f36a6f0ae35107ac75be3cffff2f0f341baee7a8 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sun, 1 Apr 2012 18:44:05 +0200 Subject: [PATCH 299/335] [ticket/10740] Revert margin-left changes of previous commit PHPBB3-10740 --- phpBB/styles/prosilver/theme/common.css | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css index e154db236f..77e2b8c0c6 100644 --- a/phpBB/styles/prosilver/theme/common.css +++ b/phpBB/styles/prosilver/theme/common.css @@ -595,9 +595,8 @@ li.pagination { position: fixed; display: none; top: 40%; - left: 50%; + left: 35%; width: 30%; - margin-left: -15%; z-index: 50; padding: 25px; padding: 0 25px 20px 25px; From fb0df8d2e398a634457b317a721734e53596f002 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 1 Apr 2012 20:19:07 +0300 Subject: [PATCH 300/335] [ticket/10665] Moving filter parameters to one array Moving filter parameters to one array in template compiler class PHPBB3-10665 --- phpBB/includes/style/template_compile.php | 34 ++++------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/phpBB/includes/style/template_compile.php b/phpBB/includes/style/template_compile.php index bd9e18e102..fa0928f424 100644 --- a/phpBB/includes/style/template_compile.php +++ b/phpBB/includes/style/template_compile.php @@ -32,25 +32,6 @@ class phpbb_style_template_compile */ private $filter_params; - /** - * Whether tags are allowed - * - * @var bool - */ - private $allow_php; - - /** - * Style resource locator - * - * @var phpbb_style_resource_locator - */ - private $locator; - - /** - * @var string phpBB root path - */ - private $phpbb_root_path; - /** * Constructor. * @@ -60,10 +41,11 @@ class phpbb_style_template_compile */ public function __construct($allow_php, $locator, $phpbb_root_path) { - $this->filter_params = array(); - $this->allow_php = $allow_php; - $this->locator = $locator; - $this->phpbb_root_path = $phpbb_root_path; + $this->filter_params = array( + 'allow_php' => $allow_php, + 'locator' => $locator, + 'phpbb_root_path' => $phpbb_root_path + ); } /** @@ -140,11 +122,7 @@ class phpbb_style_template_compile */ private function compile_stream_to_stream($source_stream, $dest_stream) { - $params = $this->filter_params; - $params['allow_php'] = $this->allow_php; - $params['locator'] = $this->locator; - $params['phpbb_root_path'] = $this->phpbb_root_path; - stream_filter_append($source_stream, 'phpbb_template', null, $params); + stream_filter_append($source_stream, 'phpbb_template', null, $this->filter_params); stream_copy_to_stream($source_stream, $dest_stream); } } From 1ffc7c1fab85b1eb732b31bfd8a0f48c7351e68a Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 1 Apr 2012 20:29:03 +0300 Subject: [PATCH 301/335] [ticket/10665] Changing template->_js_include to public Changing template->_js_include to public function PHPBB3-10665 --- phpBB/includes/style/template.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/style/template.php b/phpBB/includes/style/template.php index 4586e8dbf9..3f15355f7a 100644 --- a/phpBB/includes/style/template.php +++ b/phpBB/includes/style/template.php @@ -499,7 +499,7 @@ class phpbb_style_template * @param string $file file name * @param bool $locate True if file needs to be located */ - function _js_include($file, $locate = false) + public function _js_include($file, $locate = false) { // Locate file if ($locate) From 2d9d8d367389c6bc0cef7852849e3d43ac682789 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 1 Apr 2012 20:37:45 +0300 Subject: [PATCH 302/335] [ticket/10665] New test class for templates with tree New parent template test class for tests that use styles tree PHPBB3-10665 --- tests/template/template_includejs_test.php | 21 ++------------ tests/template/template_inheritance_test.php | 20 ++----------- tests/template/template_locate_test.php | 20 ++----------- .../template/template_test_case_with_tree.php | 29 +++++++++++++++++++ 4 files changed, 35 insertions(+), 55 deletions(-) create mode 100644 tests/template/template_test_case_with_tree.php diff --git a/tests/template/template_includejs_test.php b/tests/template/template_includejs_test.php index e0229e978b..fa23837553 100644 --- a/tests/template/template_includejs_test.php +++ b/tests/template/template_includejs_test.php @@ -7,9 +7,9 @@ * */ -require_once dirname(__FILE__) . '/template_test_case.php'; +require_once dirname(__FILE__) . '/template_test_case_with_tree.php'; -class phpbb_template_template_includejs_test extends phpbb_template_template_test_case +class phpbb_template_template_includejs_test extends phpbb_template_template_test_case_with_tree { public function test_includejs_compilation() { @@ -28,21 +28,4 @@ class phpbb_template_template_includejs_test extends phpbb_template_template_tes $cache_file = $this->template->cachepath . 'includejs.html.php'; $this->run_template('includejs.html', array('PARENT' => 'parent_only.html'), array(), array(), implode('', $scripts), $cache_file); } - - protected function setup_engine(array $new_config = array()) - { - global $phpbb_root_path, $phpEx, $user; - - $defaults = $this->config_defaults(); - $config = new phpbb_config(array_merge($defaults, $new_config)); - - $this->template_path = dirname(__FILE__) . '/templates'; - $this->parent_template_path = dirname(__FILE__) . '/parent_templates'; - $this->style_resource_locator = new phpbb_style_resource_locator(); - $this->style_provider = new phpbb_style_path_provider(); - $this->template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider); - $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template); - $this->style->set_custom_style('tests', array($this->template_path, $this->parent_template_path), ''); - $this->template->set_filenames(array('body' => 'includejs.html')); - } } diff --git a/tests/template/template_inheritance_test.php b/tests/template/template_inheritance_test.php index a76658701a..febfed9ef0 100644 --- a/tests/template/template_inheritance_test.php +++ b/tests/template/template_inheritance_test.php @@ -7,9 +7,9 @@ * */ -require_once dirname(__FILE__) . '/template_test_case.php'; +require_once dirname(__FILE__) . '/template_test_case_with_tree.php'; -class phpbb_template_template_inheritance_test extends phpbb_template_template_test_case +class phpbb_template_template_inheritance_test extends phpbb_template_template_test_case_with_tree { /** * @todo put test data into templates/xyz.test @@ -61,20 +61,4 @@ class phpbb_template_template_inheritance_test extends phpbb_template_template_t $this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file); } - - protected function setup_engine(array $new_config = array()) - { - global $phpbb_root_path, $phpEx, $user; - - $defaults = $this->config_defaults(); - $config = new phpbb_config(array_merge($defaults, $new_config)); - - $this->template_path = dirname(__FILE__) . '/templates'; - $this->parent_template_path = dirname(__FILE__) . '/parent_templates'; - $this->style_resource_locator = new phpbb_style_resource_locator(); - $this->style_provider = new phpbb_style_path_provider(); - $this->template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider); - $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template); - $this->style->set_custom_style('tests', array($this->template_path, $this->parent_template_path), ''); - } } diff --git a/tests/template/template_locate_test.php b/tests/template/template_locate_test.php index 89a4ae6fb1..d6e2e82a47 100644 --- a/tests/template/template_locate_test.php +++ b/tests/template/template_locate_test.php @@ -7,9 +7,9 @@ * */ -require_once dirname(__FILE__) . '/template_test_case.php'; +require_once dirname(__FILE__) . '/template_test_case_with_tree.php'; -class phpbb_template_template_locate_test extends phpbb_template_template_test_case +class phpbb_template_template_locate_test extends phpbb_template_template_test_case_with_tree { public function template_data() { @@ -65,20 +65,4 @@ class phpbb_template_template_locate_test extends phpbb_template_template_test_c $result = $this->template->locate($files, $return_default, $return_full_path); $this->assertSame($expected, $result); } - - protected function setup_engine(array $new_config = array()) - { - global $phpbb_root_path, $phpEx, $user; - - $defaults = $this->config_defaults(); - $config = new phpbb_config(array_merge($defaults, $new_config)); - - $this->template_path = dirname(__FILE__) . '/templates'; - $this->parent_template_path = dirname(__FILE__) . '/parent_templates'; - $this->style_resource_locator = new phpbb_style_resource_locator(); - $this->style_provider = new phpbb_style_path_provider(); - $this->template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider); - $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template); - $this->style->set_custom_style('tests', array($this->template_path, $this->parent_template_path), ''); - } } diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php new file mode 100644 index 0000000000..e76d9436cf --- /dev/null +++ b/tests/template/template_test_case_with_tree.php @@ -0,0 +1,29 @@ +config_defaults(); + $config = new phpbb_config(array_merge($defaults, $new_config)); + + $this->template_path = dirname(__FILE__) . '/templates'; + $this->parent_template_path = dirname(__FILE__) . '/parent_templates'; + $this->style_resource_locator = new phpbb_style_resource_locator(); + $this->style_provider = new phpbb_style_path_provider(); + $this->template = new phpbb_style_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider); + $this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template); + $this->style->set_custom_style('tests', array($this->template_path, $this->parent_template_path), ''); + } +} From c89ea703bda1006b382f8cc0da292f6e2a3701f5 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 1 Apr 2012 20:46:10 +0300 Subject: [PATCH 303/335] [ticket/10665] Solution for T_SUPER_TEMPLATE_PATH Temporary solution for T_SUPER_TEMPLATE_PATH pointing to wrong directory, variable will be completely removed later because it will be obsolete PHPBB3-10665 --- phpBB/includes/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 74db8cb8fd..a44ebb04e8 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4770,7 +4770,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'T_ASSETS_PATH' => "{$web_path}assets", 'T_THEME_PATH' => "{$web_path}styles/" . rawurlencode($user->theme['style_path']) . '/theme', 'T_TEMPLATE_PATH' => "{$web_path}styles/" . rawurlencode($user->theme['style_path']) . '/template', - 'T_SUPER_TEMPLATE_PATH' => ($user->theme['style_parent_id']) ? "{$web_path}styles/" . rawurlencode($user->theme['style_parent_tree']) . '/template' : "{$web_path}styles/" . rawurlencode($user->theme['style_path']) . '/template', + 'T_SUPER_TEMPLATE_PATH' => "{$web_path}styles/" . rawurlencode($user->theme['style_path']) . '/template', 'T_IMAGES_PATH' => "{$web_path}images/", 'T_SMILIES_PATH' => "{$web_path}{$config['smilies_path']}/", 'T_AVATAR_PATH' => "{$web_path}{$config['avatar_path']}/", From 37480e5594145bbead07c8f70644d52983f92913 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 1 Apr 2012 20:50:59 +0300 Subject: [PATCH 304/335] [ticket/10665] Adding includejs to acp templates Adding includejs to acp overall_footer.html PHPBB3-10665 --- phpBB/adm/style/overall_footer.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/adm/style/overall_footer.html b/phpBB/adm/style/overall_footer.html index 0337080f3d..a486a69514 100644 --- a/phpBB/adm/style/overall_footer.html +++ b/phpBB/adm/style/overall_footer.html @@ -39,7 +39,8 @@ - + +{SCRIPTS} From 06d26ef46e914c823889dab37627e7fa39d883ce Mon Sep 17 00:00:00 2001 From: Hari Sankar R Date: Mon, 2 Apr 2012 00:35:39 +0530 Subject: [PATCH 305/335] [ticket/10438] Alligning the Smileys on the same line as the text. Changed the styling of smilies to appear at the same level as text, by adding vertical-align: text-bottom css property to all smilies. Edited functions_content.php to add class="smilies" to all parsed smilies. PHPBB3-10438 --- phpBB/includes/functions_content.php | 2 +- phpBB/styles/prosilver/theme/common.css | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index f2faf20f43..6b2ee98d7a 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -739,7 +739,7 @@ function smiley_text($text, $force_option = false) else { $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path; - return preg_replace('#', $text); + return preg_replace('#

{L_TOPIC}: {TOPIC_TITLE}