diff --git a/build/config/classes-to-concat/headonly.php b/build/config/classes-to-concat/headonly.php
index e29cbcdab..cc0daf3cf 100644
--- a/build/config/classes-to-concat/headonly.php
+++ b/build/config/classes-to-concat/headonly.php
@@ -46,17 +46,17 @@
'tubepress_app_impl_options_DispatchingReference',
'tubepress_app_impl_options_Persistence',
'tubepress_app_impl_shortcode_Parser',
- 'tubepress_app_impl_template_DelegatingEngine',
- 'tubepress_app_impl_template_php_Support',
- 'tubepress_app_impl_template_TemplatingService',
- 'tubepress_app_impl_template_ThemeTemplateLocator',
- 'tubepress_app_impl_template_twig_Engine',
- 'tubepress_app_impl_template_twig_EnvironmentBuilder',
- 'tubepress_app_impl_template_twig_FsLoader',
- 'tubepress_app_impl_template_twig_ThemeLoader',
'tubepress_app_impl_theme_AbstractTheme',
'tubepress_app_impl_theme_CurrentThemeService',
'tubepress_app_impl_theme_FilesystemTheme',
+ 'tubepress_app_template_impl_DelegatingEngine',
+ 'tubepress_app_template_impl_php_Support',
+ 'tubepress_app_template_impl_TemplatingService',
+ 'tubepress_app_template_impl_ThemeTemplateLocator',
+ 'tubepress_app_template_impl_twig_Engine',
+ 'tubepress_app_template_impl_twig_EnvironmentBuilder',
+ 'tubepress_app_template_impl_twig_FsLoader',
+ 'tubepress_app_template_impl_twig_ThemeLoader',
'tubepress_lib_api_event_EventDispatcherInterface',
'tubepress_lib_api_event_EventInterface',
'tubepress_lib_api_http_AjaxInterface',
diff --git a/build/config/common.properties b/build/config/common.properties
index 155e96b93..d0f8fe1c2 100644
--- a/build/config/common.properties
+++ b/build/config/common.properties
@@ -1,3 +1,3 @@
version.major=4
version.minor=1
-version.micro=9
+version.micro=10
diff --git a/build/include/common.xml b/build/include/common.xml
index 5c6d33c3e..102dafa56 100644
--- a/build/include/common.xml
+++ b/build/include/common.xml
@@ -90,7 +90,9 @@
+
+
diff --git a/composer.json b/composer.json
index cbe2b8f95..de7f9f920 100644
--- a/composer.json
+++ b/composer.json
@@ -40,11 +40,13 @@
"tubepress_api_const_" : "src/add-ons/deprecated/classes",
"tubepress_addons_" : "src/add-ons/deprecated/classes",
- "tubepress_embedplus_" : "src/add-ons/embedplus/classes",
- "tubepress_jwplayer5_" : "src/add-ons/jwplayer5/classes",
- "tubepress_vimeo2_" : "src/add-ons/vimeo_v2/classes",
- "tubepress_wordpress_" : "src/add-ons/wordpress/classes",
- "tubepress_youtube3_" : "src/add-ons/youtube_v3/classes",
+ "tubepress_htmlcache_" : "src/add-ons/htmlcache/classes",
+ "tubepress_embedplus_" : "src/add-ons/embedplus/classes",
+ "tubepress_jwplayer5_" : "src/add-ons/jwplayer5/classes",
+ "tubepress_app_template_" : "src/add-ons/template/classes",
+ "tubepress_vimeo2_" : "src/add-ons/vimeo_v2/classes",
+ "tubepress_wordpress_" : "src/add-ons/wordpress/classes",
+ "tubepress_youtube3_" : "src/add-ons/youtube_v3/classes",
"tubepress_test_integration_" : "tests/integration/classes",
"tubepress_test_platform_" : "tests/unit/platform/classes",
@@ -52,6 +54,7 @@
"tubepress_test_lib_" : "tests/unit/add-ons/core/classes",
"tubepress_test_boot_" : "tests/unit/platform/fixtures/mock-user-content-dir/add-ons/bootmocks/classes",
"tubepress_test_translations_" : "tests/unit/translations/classes",
+ "tubepress_test_app_template_" : "tests/unit/add-ons/template/classes",
"tubepress_test_" : "tests/unit/add-ons/core/classes"
}
}
diff --git a/src/add-ons/core/classes/tubepress/app/api/event/Events.php b/src/add-ons/core/classes/tubepress/app/api/event/Events.php
index 88406b9b2..bd4941303 100644
--- a/src/add-ons/core/classes/tubepress/app/api/event/Events.php
+++ b/src/add-ons/core/classes/tubepress/app/api/event/Events.php
@@ -63,6 +63,17 @@ interface tubepress_app_api_event_Events
*/
const HTML_GENERATION = 'tubepress.app.html.generation';
+ /**
+ * This event is fired after TubePress generates its "primary" HTML (e.g. a media gallery,
+ * search input widget, embedded media player, etc).
+ *
+ * @subject `string` The HTML that will be returned to the user.
+ *
+ * @api
+ * @since 4.1.10
+ */
+ const HTML_GENERATION_POST = 'tubepress.app.html.generation.post';
+
/**
* This event is fired immediately after TubePress assembles its list of scripts to print.
*
diff --git a/src/add-ons/core/classes/tubepress/app/api/options/Names.php b/src/add-ons/core/classes/tubepress/app/api/options/Names.php
index 9d2bb1b32..37da7effa 100644
--- a/src/add-ons/core/classes/tubepress/app/api/options/Names.php
+++ b/src/add-ons/core/classes/tubepress/app/api/options/Names.php
@@ -39,6 +39,36 @@ interface tubepress_app_api_options_Names
*/
const CACHE_LIFETIME_SECONDS = 'cacheLifetimeSeconds';
+ /**
+ * @api
+ * @since 4.1.10
+ */
+ const CACHE_HTML_CLEANING_FACTOR = 'htmlCacheCleaningFactor';
+
+ /**
+ * @api
+ * @since 4.1.10
+ */
+ const CACHE_HTML_CLEANING_KEY = 'htmlCacheCleaningKey';
+
+ /**
+ * @api
+ * @since 4.1.10
+ */
+ const CACHE_HTML_DIRECTORY = 'htmlCacheDirectory';
+
+ /**
+ * @api
+ * @since 4.1.10
+ */
+ const CACHE_HTML_ENABLED = 'htmlCacheEnabled';
+
+ /**
+ * @api
+ * @since 4.1.10
+ */
+ const CACHE_HTML_LIFETIME_SECONDS = 'htmlCacheLifetimeSeconds';
+
/**
* @api
* @since 4.0.0
diff --git a/src/add-ons/core/classes/tubepress/app/impl/html/HtmlGenerator.php b/src/add-ons/core/classes/tubepress/app/impl/html/HtmlGenerator.php
index 7b76f12ad..cabd74ea3 100644
--- a/src/add-ons/core/classes/tubepress/app/impl/html/HtmlGenerator.php
+++ b/src/add-ons/core/classes/tubepress/app/impl/html/HtmlGenerator.php
@@ -64,20 +64,29 @@ public function getHtml()
{
try {
- $htmlProviderSelectionEvent = $this->_eventDispatcher->newEventInstance('');
+ $htmlGenerationEventPre = $this->_eventDispatcher->newEventInstance('');
- $this->_eventDispatcher->dispatch(tubepress_app_api_event_Events::HTML_GENERATION, $htmlProviderSelectionEvent);
+ $this->_eventDispatcher->dispatch(tubepress_app_api_event_Events::HTML_GENERATION, $htmlGenerationEventPre);
/**
* @var $selected string
*/
- $html = $htmlProviderSelectionEvent->getSubject();
+ $html = $htmlGenerationEventPre->getSubject();
if ($html === null) {
throw new RuntimeException('Unable to generate HTML.');
}
+ $htmlGenerationEventPost = $this->_eventDispatcher->newEventInstance($html);
+
+ $this->_eventDispatcher->dispatch(tubepress_app_api_event_Events::HTML_GENERATION_POST, $htmlGenerationEventPost);
+
+ /**
+ * @var $html string
+ */
+ $html = $htmlGenerationEventPost->getSubject();
+
return $html;
} catch (Exception $e) {
diff --git a/src/add-ons/core/classes/tubepress/app/impl/vendor/stash/FilesystemCacheBuilder.php b/src/add-ons/core/classes/tubepress/app/impl/vendor/stash/FilesystemCacheBuilder.php
index adfda530b..cc2801e0d 100644
--- a/src/add-ons/core/classes/tubepress/app/impl/vendor/stash/FilesystemCacheBuilder.php
+++ b/src/add-ons/core/classes/tubepress/app/impl/vendor/stash/FilesystemCacheBuilder.php
@@ -24,21 +24,44 @@ class tubepress_app_impl_vendor_stash_FilesystemCacheBuilder
*/
private $_bootSettings;
+ /**
+ * @var tubepress_platform_api_log_LoggerInterface
+ */
+ private $_logger;
+
+ /**
+ * @var boolean
+ */
+ private $_shouldLog;
+
public function __construct(tubepress_app_api_options_ContextInterface $context,
- tubepress_platform_api_boot_BootSettingsInterface $bootSettings)
+ tubepress_platform_api_boot_BootSettingsInterface $bootSettings,
+ tubepress_platform_api_log_LoggerInterface $logger)
{
$this->_context = $context;
$this->_bootSettings = $bootSettings;
+ $this->_logger = $logger;
+ $this->_shouldLog = $logger->isEnabled();
}
public function buildFilesystemDriver()
{
$dir = $this->_context->get(tubepress_app_api_options_Names::CACHE_DIRECTORY);
+ if ($this->_shouldLog) {
+
+ $this->_logger->debug(sprintf('Starting to build API cache driver. User candidate is "%s
"', $dir));
+ }
+
/**
* If a path was given, but it's not a directory, let's try to create it.
*/
- if ($dir != '' && !is_dir($dir)) {
+ if ($dir && !is_dir($dir)) {
+
+ if ($this->_shouldLog) {
+
+ $this->_logger->debug(sprintf('"%s
" is not a directory. Let\'s try to create it...', $dir));
+ }
@mkdir($dir, 0755, true);
}
@@ -46,7 +69,12 @@ public function buildFilesystemDriver()
/**
* If the directory exists, but isn't writable, let's try to change that.
*/
- if (is_dir($dir) && !is_writable($dir)) {
+ if ($dir && is_dir($dir) && !is_writable($dir)) {
+
+ if ($this->_shouldLog) {
+
+ $this->_logger->debug(sprintf('"%s
" is a directory but we can\'t write to it. Let\'s try to change that...', $dir));
+ }
@chmod($dir, 0755);
}
@@ -56,7 +84,17 @@ public function buildFilesystemDriver()
*/
if (!is_dir($dir) || !is_writable($dir)) {
+ if ($this->_shouldLog) {
+
+ $this->_logger->debug(sprintf('We don\'t have a directory that we can use for the API cache. Giving up and falling back to system directory.', $dir));
+ }
+
$dir = $this->_bootSettings->getPathToSystemCacheDirectory() . '/api-calls';
+
+ if ($this->_shouldLog) {
+
+ $this->_logger->debug(sprintf('Final API cache directory is "%s
"', $dir));
+ }
}
$driver = new ehough_stash_driver_FileSystem();
diff --git a/src/add-ons/core/classes/tubepress/app/ioc/AppExtension.php b/src/add-ons/core/classes/tubepress/app/ioc/AppExtension.php
index 60085ab87..04844605c 100644
--- a/src/add-ons/core/classes/tubepress/app/ioc/AppExtension.php
+++ b/src/add-ons/core/classes/tubepress/app/ioc/AppExtension.php
@@ -40,7 +40,6 @@ public function load(tubepress_platform_api_ioc_ContainerBuilderInterface $conta
$this->_registerOptionsUiFieldProvider($containerBuilder);
$this->_registerPlayers($containerBuilder);
$this->_registerShortcode($containerBuilder);
- $this->_registerTemplatingService($containerBuilder);
$this->_registerTheme($containerBuilder);
$this->_registerVendorServices($containerBuilder);
}
@@ -615,9 +614,6 @@ private function _registerOptions(tubepress_platform_api_ioc_ContainerBuilderInt
tubepress_app_api_options_Names::SHORTCODE_KEYWORD => 'tubepress',
tubepress_app_api_options_Names::SINGLE_MEDIA_ITEM_ID => null,
tubepress_app_api_options_Names::SOURCES => null,
- tubepress_app_api_options_Names::TEMPLATE_CACHE_AUTORELOAD => false,
- tubepress_app_api_options_Names::TEMPLATE_CACHE_DIR => null,
- tubepress_app_api_options_Names::TEMPLATE_CACHE_ENABLED => true,
tubepress_app_api_options_Names::THEME => 'tubepress/default',
tubepress_app_api_options_Names::THEME_ADMIN => 'tubepress/admin-default',
@@ -672,9 +668,6 @@ private function _registerOptions(tubepress_platform_api_ioc_ContainerBuilderInt
tubepress_app_api_options_Names::RESPONSIVE_EMBEDS => 'Responsive embeds', //>(translatable)<
tubepress_app_api_options_Names::SEARCH_ONLY_USER => 'Restrict search results to videos from author', //>(translatable)<
tubepress_app_api_options_Names::SHORTCODE_KEYWORD => 'Shortcode keyword', //>(translatable)<
- tubepress_app_api_options_Names::TEMPLATE_CACHE_AUTORELOAD => 'Monitor templates for changes', //>(translatable)<
- tubepress_app_api_options_Names::TEMPLATE_CACHE_DIR => 'Template cache directory', //>(translatable)<
- tubepress_app_api_options_Names::TEMPLATE_CACHE_ENABLED => 'Enable template cache', //>(translatable)<
tubepress_app_api_options_Names::THEME => 'Theme', //>(translatable)<
),
@@ -683,7 +676,7 @@ private function _registerOptions(tubepress_platform_api_ioc_ContainerBuilderInt
tubepress_app_api_options_Names::CACHE_CLEANING_FACTOR => 'If you enter X, the entire cache will be cleaned every 1/X cache writes. Enter 0 to disable cache cleaning.', //>(translatable)<
tubepress_app_api_options_Names::CACHE_DIRECTORY => 'Leave blank to attempt to use your system\'s temp directory. Otherwise enter the absolute path of a writeable directory.', //>(translatable)<
tubepress_app_api_options_Names::CACHE_ENABLED => 'Store API responses in a cache file to significantly reduce load times for your galleries at the slight expense of freshness.', //>(translatable)<
- tubepress_app_api_options_Names::CACHE_LIFETIME_SECONDS => 'Cache entries will be considered stale after the specified number of seconds. Default is 3600 (one hour).', //>(translatable)<
+ tubepress_app_api_options_Names::CACHE_LIFETIME_SECONDS => 'Cache entries will be considered stale after the specified number of seconds. Default is 21600 (six hours).', //>(translatable)<
tubepress_app_api_options_Names::DEBUG_ON => 'If checked, anyone will be able to view your debugging information. This is a rather small privacy risk. If you\'re not having problems with TubePress, or you\'re worried about revealing any details of your TubePress pages, feel free to disable the feature.', //>(translatable)<
tubepress_app_api_options_Names::EMBEDDED_HEIGHT => sprintf('Default is %s.', 390), //>(translatable)<
tubepress_app_api_options_Names::EMBEDDED_LAZYPLAY => 'Auto-play each video after thumbnail click.', //>(translatable)<
@@ -1125,125 +1118,6 @@ private function _registerShortcode(tubepress_platform_api_ioc_ContainerBuilderI
->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_util_StringUtilsInterface::_));
}
- private function _registerTemplatingService(tubepress_platform_api_ioc_ContainerBuilderInterface $containerBuilder)
- {
- $parallelServices = array(
- '' => 'public',
- '.admin' => 'admin'
- );
-
- foreach ($parallelServices as $serviceSuffix => $templatePath) {
-
- /**
- * Theme template locators.
- */
- $containerBuilder->register(
- 'tubepress_app_impl_template_ThemeTemplateLocator' . $serviceSuffix,
- 'tubepress_app_impl_template_ThemeTemplateLocator'
- )->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_log_LoggerInterface::_))
- ->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_app_api_options_ContextInterface::_))
- ->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_contrib_RegistryInterface::_ . '.' . tubepress_app_api_theme_ThemeInterface::_ . $serviceSuffix))
- ->addArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_impl_theme_CurrentThemeService' . $serviceSuffix));
-
- /**
- * Twig loaders.
- */
- $containerBuilder->register(
- 'tubepress_app_impl_template_twig_ThemeLoader' . $serviceSuffix,
- 'tubepress_app_impl_template_twig_ThemeLoader'
- )->addArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_impl_template_ThemeTemplateLocator' . $serviceSuffix));
-
- $containerBuilder->register(
- 'Twig_Loader_Filesystem' . $serviceSuffix,
- 'tubepress_app_impl_template_twig_FsLoader'
- )->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_log_LoggerInterface::_))
- ->addArgument(array(
- TUBEPRESS_ROOT . '/src/add-ons/core/templates/' . $templatePath,
- ));
-
- $twigLoaderReferences = array(
- new tubepress_platform_api_ioc_Reference('tubepress_app_impl_template_twig_ThemeLoader' . $serviceSuffix),
- new tubepress_platform_api_ioc_Reference('Twig_Loader_Filesystem' . $serviceSuffix)
- );
- $containerBuilder->register(
- 'Twig_LoaderInterface' . $serviceSuffix,
- 'Twig_Loader_Chain'
- )->addArgument($twigLoaderReferences);
-
- /**
- * Twig environment builder.
- */
- $containerBuilder->register(
- 'tubepress_app_impl_template_twig_EnvironmentBuilder' . $serviceSuffix,
- 'tubepress_app_impl_template_twig_EnvironmentBuilder'
- )->addArgument(new tubepress_platform_api_ioc_Reference('Twig_LoaderInterface' . $serviceSuffix))
- ->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_boot_BootSettingsInterface::_))
- ->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_app_api_options_ContextInterface::_))
- ->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_lib_api_translation_TranslatorInterface::_));
-
- /**
- * Twig environment.
- */
- $containerBuilder->register(
- 'Twig_Environment' . $serviceSuffix,
- 'Twig_Environment'
- )->setFactoryService('tubepress_app_impl_template_twig_EnvironmentBuilder' . $serviceSuffix)
- ->setFactoryMethod('buildTwigEnvironment');
-
- /**
- * Twig engine
- */
- $containerBuilder->register(
- 'tubepress_app_impl_template_twig_Engine' . $serviceSuffix,
- 'tubepress_app_impl_template_twig_Engine'
- )->addArgument(new tubepress_platform_api_ioc_Reference('Twig_Environment' . $serviceSuffix));
- }
-
- /**
- * Register PHP engine support
- */
- $containerBuilder->register(
- 'tubepress_app_impl_template_php_Support',
- 'tubepress_app_impl_template_php_Support'
- )->addArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_impl_template_ThemeTemplateLocator'));
-
- /**
- * Register the PHP templating engine
- */
- $containerBuilder->register(
- 'ehough_templating_PhpEngine',
- 'ehough_templating_PhpEngine'
- )->addArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_impl_template_php_Support'))
- ->addArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_impl_template_php_Support'));
-
- /**
- * Public templating engine
- */
- $engineReferences = array(
- new tubepress_platform_api_ioc_Reference('ehough_templating_PhpEngine'),
- new tubepress_platform_api_ioc_Reference('tubepress_app_impl_template_twig_Engine')
- );
- $containerBuilder->register(
- 'tubepress_app_impl_template_DelegatingEngine',
- 'tubepress_app_impl_template_DelegatingEngine'
- )->addArgument($engineReferences)
- ->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_log_LoggerInterface::_));
-
- /**
- * Final templating services
- */
- $containerBuilder->register(
- tubepress_lib_api_template_TemplatingInterface::_,
- 'tubepress_app_impl_template_TemplatingService'
- )->addArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_impl_template_DelegatingEngine'))
- ->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_lib_api_event_EventDispatcherInterface::_));
- $containerBuilder->register(
- tubepress_lib_api_template_TemplatingInterface::_ . '.admin',
- 'tubepress_app_impl_template_TemplatingService'
- )->addArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_impl_template_twig_Engine.admin'))
- ->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_lib_api_event_EventDispatcherInterface::_));
- }
-
private function _registerTheme(tubepress_platform_api_ioc_ContainerBuilderInterface $containerBuilder)
{
$containerBuilder->register(
@@ -1297,7 +1171,8 @@ private function _registerVendorServices(tubepress_platform_api_ioc_ContainerBui
'tubepress_app_impl_vendor_stash_FilesystemCacheBuilder',
'tubepress_app_impl_vendor_stash_FilesystemCacheBuilder'
)->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_app_api_options_ContextInterface::_))
- ->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_boot_BootSettingsInterface::_));
+ ->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_boot_BootSettingsInterface::_))
+ ->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_log_LoggerInterface::_));
$containerBuilder->register(
diff --git a/src/add-ons/core/manifest.json b/src/add-ons/core/manifest.json
index 91f17d9de..e8031612f 100644
--- a/src/add-ons/core/manifest.json
+++ b/src/add-ons/core/manifest.json
@@ -18,8 +18,7 @@
"tubepress_app_ioc_compiler_EventDispatcherLoggingPass" : 0,
"tubepress_lib_ioc_compiler_TaggedServicesConsumerPass" : 70000,
- "tubepress_lib_ioc_compiler_EventListenersPass" : 70000,
- "tubepress_lib_ioc_compiler_TemplatePathProvidersPass" : 70000
+ "tubepress_lib_ioc_compiler_EventListenersPass" : 70000
},
"extensions" : [
"tubepress_app_ioc_AppExtension",
@@ -134,14 +133,6 @@
"tubepress_app_impl_player_SoloOrStaticPlayerLocation" : "classes/tubepress/app/impl/player/SoloOrStaticPlayerLocation.php",
"tubepress_app_impl_shortcode_Parser" : "classes/tubepress/app/impl/shortcode/Parser.php",
- "tubepress_app_impl_template_DelegatingEngine" : "classes/tubepress/app/impl/template/DelegatingEngine.php",
- "tubepress_app_impl_template_php_Support" : "classes/tubepress/app/impl/template/php/Support.php",
- "tubepress_app_impl_template_TemplatingService" : "classes/tubepress/app/impl/template/TemplatingService.php",
- "tubepress_app_impl_template_ThemeTemplateLocator" : "classes/tubepress/app/impl/template/ThemeTemplateLocator.php",
- "tubepress_app_impl_template_twig_Engine" : "classes/tubepress/app/impl/template/twig/Engine.php",
- "tubepress_app_impl_template_twig_EnvironmentBuilder" : "classes/tubepress/app/impl/template/twig/EnvironmentBuilder.php",
- "tubepress_app_impl_template_twig_FsLoader" : "classes/tubepress/app/impl/template/twig/FsLoader.php",
- "tubepress_app_impl_template_twig_ThemeLoader" : "classes/tubepress/app/impl/template/twig/ThemeLoader.php",
"tubepress_app_impl_theme_AbstractTheme" : "classes/tubepress/app/impl/theme/AbstractTheme.php",
"tubepress_app_impl_theme_CurrentThemeService" : "classes/tubepress/app/impl/theme/CurrentThemeService.php",
"tubepress_app_impl_theme_FilesystemTheme" : "classes/tubepress/app/impl/theme/FilesystemTheme.php",
@@ -192,7 +183,6 @@
"tubepress_lib_impl_util_TimeUtils" : "classes/tubepress/lib/impl/util/TimeUtils.php",
"tubepress_lib_ioc_compiler_EventListenersPass" : "classes/tubepress/lib/ioc/compiler/EventListenersPass.php",
"tubepress_lib_ioc_compiler_TaggedServicesConsumerPass" : "classes/tubepress/lib/ioc/compiler/TaggedServicesConsumerPass.php",
- "tubepress_lib_ioc_compiler_TemplatePathProvidersPass" : "classes/tubepress/lib/ioc/compiler/TemplatePathProvidersPass.php",
"tubepress_lib_ioc_LibExtension" : "classes/tubepress/lib/ioc/LibExtension.php"
}
}
diff --git a/src/add-ons/core/web/js/gallery.js b/src/add-ons/core/web/js/gallery.js
index 4c175a424..dc309d0d1 100644
--- a/src/add-ons/core/web/js/gallery.js
+++ b/src/add-ons/core/web/js/gallery.js
@@ -80,7 +80,7 @@
*/
var tubePressGalleryRegistrar;
-(function (jquery, tubepress) {
+(function (tubepress) {
/** http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/ */
'use strict';
@@ -132,6 +132,7 @@ var tubePressGalleryRegistrar;
environment = tubepress.Environment,
troo = true,
fawlse = false,
+ jquery = tubepress.Vendors.jQuery,
/**
* Provides convenient selectors to access the outermost gallery div.
@@ -667,4 +668,4 @@ var tubePressGalleryRegistrar;
*/
tubepress.Beacon.publish(text_tubepress + text_dot + text_js + text_dot + text_sys + text_dot + text_gallery);
-}(jQuery, TubePress));
\ No newline at end of file
+}(TubePress));
\ No newline at end of file
diff --git a/src/add-ons/core/web/js/players/jqmodal-player.js b/src/add-ons/core/web/js/players/jqmodal-player.js
index ce66b08b7..beafc6ecb 100644
--- a/src/add-ons/core/web/js/players/jqmodal-player.js
+++ b/src/add-ons/core/web/js/players/jqmodal-player.js
@@ -9,7 +9,7 @@
*/
/* jslint browser: true, devel: true */
/* global jQuery TubePress */
-(function (jquery, tubePress) {
+(function (tubePress) {
/** http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/ */
'use strict';
@@ -27,6 +27,7 @@
event_prefix_players = 'tubepress.' + text_gallery + '.player.',
text_galleryId = text_gallery + text_Id,
text_itemId = 'item' + text_Id,
+ jquery = tubePress.Vendors.jQuery,
hider = function (hash) {
@@ -76,4 +77,4 @@
subscribe(event_prefix_players + 'invoke.' + text_jqmodal, invoke);
subscribe(event_prefix_players + 'populate.' + text_jqmodal, populate);
-}(jQuery, TubePress));
\ No newline at end of file
+}(TubePress));
\ No newline at end of file
diff --git a/src/add-ons/core/web/js/players/normal-player.js b/src/add-ons/core/web/js/players/normal-player.js
index b2490ccbc..d66f5ab35 100644
--- a/src/add-ons/core/web/js/players/normal-player.js
+++ b/src/add-ons/core/web/js/players/normal-player.js
@@ -10,7 +10,7 @@
/*global jQuery, TubePressAjax, TubePressEvents */
/*jslint sloppy: true, white: true, undef: true, newcap: true, nomen: true, regexp: true, plusplus: true, bitwise: true, continue: true, browser: true, maxerr: 50, indent: 4 */
-(function (jquery, tubePress) {
+(function (tubePress) {
/** http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/ */
'use strict';
@@ -41,6 +41,7 @@
remStyle = styler.removeLoadingStyle,
fawlse = false,
+ jquery = tubePress.Vendors.jQuery,
getModernSelector = function (galleryId) {
@@ -144,4 +145,4 @@
subscribe(text_eventPrefix_player + 'invoke' + text_dot + text_normal, invoke);
subscribe(text_eventPrefix_player + 'populate' + text_dot + text_normal, populate);
-}(jQuery, TubePress));
\ No newline at end of file
+}(TubePress));
\ No newline at end of file
diff --git a/src/add-ons/core/web/js/players/popup-player.js b/src/add-ons/core/web/js/players/popup-player.js
index d83117b7f..03b8ef03d 100644
--- a/src/add-ons/core/web/js/players/popup-player.js
+++ b/src/add-ons/core/web/js/players/popup-player.js
@@ -11,7 +11,7 @@
/* global jQuery, TubePressEvents */
/* jslint white: true, onevar: true, undef: true, newcap: true, nomen: true, regexp: true, plusplus: true, bitwise: true, continue: true, browser: true, maxerr: 50, indent: 4 */
-(function (jquery, tubePress, screen, win) {
+(function (tubePress, screen, win) {
/** http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/ */
'use strict';
@@ -65,4 +65,4 @@
subscribe(event_prefix_players + 'invoke.' + text_popup, invoke);
subscribe(event_prefix_players + 'populate.' + text_popup, populate);
-}(jQuery, TubePress, screen, window));
\ No newline at end of file
+}(TubePress, screen, window));
\ No newline at end of file
diff --git a/src/add-ons/core/web/js/players/shadowbox-player.js b/src/add-ons/core/web/js/players/shadowbox-player.js
index a9b3a5fd8..4ec09c98d 100644
--- a/src/add-ons/core/web/js/players/shadowbox-player.js
+++ b/src/add-ons/core/web/js/players/shadowbox-player.js
@@ -12,7 +12,7 @@
/*jslint sloppy: true, white: true, onevar: true, undef: true, newcap: true, nomen: true, regexp: true, plusplus: true, bitwise: true, continue: true, browser: true, maxerr: 50, indent: 4 */
-(function (jquery, tubePress) {
+(function (tubePress) {
/** http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/ */
'use strict';
@@ -32,6 +32,7 @@
domInjector = tubePress.DomInjector,
event_prefix_players = 'tubepress.' + text_gallery + '.' + text_player + '.',
sbId = '#sb-' + text_player,
+ jquery = tubePress.Vendors.jQuery,
isShadowBoxAvailable = function () {
@@ -118,4 +119,4 @@
loadShadowboxIfNeeded();
-}(jQuery, TubePress));
\ No newline at end of file
+}(TubePress));
\ No newline at end of file
diff --git a/src/add-ons/core/web/js/tubepress.js b/src/add-ons/core/web/js/tubepress.js
index 65f68c153..cf0e68e40 100644
--- a/src/add-ons/core/web/js/tubepress.js
+++ b/src/add-ons/core/web/js/tubepress.js
@@ -623,7 +623,12 @@ var tubePressDomInjector,
Utils : langUtils
},
- Logger : logger
+ Logger : logger,
+
+ Vendors : {
+
+ jQuery : jquery
+ }
};
}(jQuery, window));
diff --git a/src/add-ons/deprecated/classes/tubepress/deprecated/ioc/compiler/LegacyThemesPrimerPass.php b/src/add-ons/deprecated/classes/tubepress/deprecated/ioc/compiler/LegacyThemesPrimerPass.php
index 6bd5f6173..9abab04d0 100644
--- a/src/add-ons/deprecated/classes/tubepress/deprecated/ioc/compiler/LegacyThemesPrimerPass.php
+++ b/src/add-ons/deprecated/classes/tubepress/deprecated/ioc/compiler/LegacyThemesPrimerPass.php
@@ -186,6 +186,7 @@ private function _findUserLegacyThemes(tubepress_platform_api_boot_BootSettingsI
*/
$themeFactory = $containerBuilder->get('tubepress_platform_impl_boot_helper_uncached_contrib_ThemeFactory');
$templateMap = $this->_getTemplateMapForLegacyDirectory($containerBuilder, $themeRoot);
+ $manifestPath = $bootSettings->getPathToSystemCacheDirectory() . DIRECTORY_SEPARATOR . 'foobar';
$manifestData = array(
'name' => "unknown/legacy-$baseName",
'version' => '1.0.0',
@@ -199,7 +200,7 @@ private function _findUserLegacyThemes(tubepress_platform_api_boot_BootSettingsI
),
'description' => "TubePress 3.x.x theme auto-generated from $themeRoot",
);
- $theme = $themeFactory->fromManifestData(sys_get_temp_dir() . '/foobar', $manifestData);
+ $theme = $themeFactory->fromManifestData($manifestPath, $manifestData);
if (!($theme instanceof tubepress_app_impl_theme_FilesystemTheme)) {
@@ -208,11 +209,11 @@ private function _findUserLegacyThemes(tubepress_platform_api_boot_BootSettingsI
$theme->setParentThemeName('tubepress/legacy-default');
$theme->setTemplateNamesToAbsPathsMap($templateMap);
- $theme->setManifestPath(sys_get_temp_dir() . '/foobar');
+ $theme->setManifestPath($manifestPath);
$toReturn[] = $theme;
}
return $toReturn;
}
-}
\ No newline at end of file
+}
diff --git a/src/add-ons/htmlcache/classes/tubepress/htmlcache/impl/options/ui/FieldProvider.php b/src/add-ons/htmlcache/classes/tubepress/htmlcache/impl/options/ui/FieldProvider.php
new file mode 100644
index 000000000..8e1d05fcb
--- /dev/null
+++ b/src/add-ons/htmlcache/classes/tubepress/htmlcache/impl/options/ui/FieldProvider.php
@@ -0,0 +1,137 @@
+_fields = $fields;
+ $this->_map = $map;
+ $this->_properties = new tubepress_platform_impl_collection_Map();
+ }
+
+ /**
+ * @return string The page-unique identifier for this item.
+ *
+ * @api
+ * @since 4.0.0
+ */
+ public function getId()
+ {
+ return 'field-provider-htmlcache';
+ }
+
+ /**
+ * @return tubepress_app_api_options_ui_ElementInterface[] The categories that this field provider supplies.
+ *
+ * @api
+ * @since 4.0.0
+ */
+ public function getCategories()
+ {
+ return array();
+ }
+
+ /**
+ * @return tubepress_app_api_options_ui_FieldInterface[] The fields that this field provider provides.
+ *
+ * @api
+ * @since 4.0.0
+ */
+ public function getFields()
+ {
+ return $this->_fields;
+ }
+
+ /**
+ * @return array An associative array, which may be empty, where the keys are category IDs and the values
+ * are arrays of field IDs that belong in the category.
+ *
+ * @api
+ * @since 4.0.0
+ */
+ public function getCategoryIdsToFieldIdsMap()
+ {
+ return $this->_map;
+ }
+
+ /**
+ * @return boolean True if this field provider should show up in the "Only show options to..." dropdown. False otherwise.
+ *
+ * @api
+ * @since 4.0.0
+ */
+ public function isAbleToBeFilteredFromGui()
+ {
+ return false;
+ }
+
+ /**
+ * @return boolean True if this field provider should separate its field into separate boxes. False otherwise.
+ *
+ * @api
+ * @since 4.0.0
+ */
+ public function fieldsShouldBeInSeparateBoxes()
+ {
+ return true;
+ }
+
+ /**
+ * @return tubepress_platform_api_collection_MapInterface
+ */
+ public function getProperties()
+ {
+ return $this->_properties;
+ }
+
+ /**
+ * @param string $name The property name.
+ * @param mixed $value The property value.
+ *
+ * @return void
+ *
+ * @api
+ * @since 4.0.0
+ */
+ public function setProperty($name, $value)
+ {
+ $this->_properties->put($name, $value);
+ }
+
+ /**
+ * @return string|null The untranslated display name of this element. May be null.
+ *
+ * @api
+ * @since 4.0.0
+ */
+ public function getUntranslatedDisplayName()
+ {
+ return 'HTML Cache';
+ }
+}
diff --git a/src/add-ons/htmlcache/classes/tubepress/htmlcache/ioc/HtmlCacheExtension.php b/src/add-ons/htmlcache/classes/tubepress/htmlcache/ioc/HtmlCacheExtension.php
new file mode 100644
index 000000000..f56f83a55
--- /dev/null
+++ b/src/add-ons/htmlcache/classes/tubepress/htmlcache/ioc/HtmlCacheExtension.php
@@ -0,0 +1,154 @@
+_registerOptions($containerBuilder);
+ $this->_registerOptionsUiFieldProvider($containerBuilder);
+ }
+
+ private function _registerOptions(tubepress_platform_api_ioc_ContainerBuilderInterface $containerBuilder)
+ {
+ $containerBuilder->register(
+ 'tubepress_app_api_options_Reference__htmlcache',
+ 'tubepress_app_api_options_Reference'
+ )->addTag(tubepress_app_api_options_ReferenceInterface::_)
+ ->addArgument(array(
+
+ tubepress_app_api_options_Reference::PROPERTY_DEFAULT_VALUE => array(
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_FACTOR => 100,
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_KEY => 'tubepress_clear_html_cache',
+ tubepress_app_api_options_Names::CACHE_HTML_DIRECTORY => null,
+ tubepress_app_api_options_Names::CACHE_HTML_ENABLED => false,
+ tubepress_app_api_options_Names::CACHE_HTML_LIFETIME_SECONDS => 21600, //six hours
+ ),
+
+ tubepress_app_api_options_Reference::PROPERTY_UNTRANSLATED_LABEL => array(
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_FACTOR => 'Cache cleaning factor', //>(translatable)<
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_KEY => 'Cache cleaning key', //>(translatable)<
+ tubepress_app_api_options_Names::CACHE_HTML_DIRECTORY => 'Cache directory', //>(translatable)<
+ tubepress_app_api_options_Names::CACHE_HTML_ENABLED => 'Enable HTML cache', //>(translatable)<
+ tubepress_app_api_options_Names::CACHE_HTML_LIFETIME_SECONDS => 'Cache expiration time (seconds)', //>(translatable) array(
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_FACTOR => 'If you enter X, the entire cache will be cleaned every 1/X cache writes. Enter 0 to disable cache cleaning.', //>(translatable)<
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_KEY => 'The name of the HTTP request parameter that, when set to true
, can remotely flush the cache. For instance, if you enter foobar
, then adding ?foobar=true
to the end of a URL would remotely trigger a clear of the cache.', //>(translatable)<
+ tubepress_app_api_options_Names::CACHE_HTML_DIRECTORY => 'Leave blank to attempt to use your system\'s temp directory. Otherwise enter the absolute path of a writeable directory.', //>(translatable)<
+ tubepress_app_api_options_Names::CACHE_HTML_ENABLED => 'Store TubePress\'s HTML output in a cache file to significantly improve performance at the slight expense of freshness.', //>(translatable)<
+ tubepress_app_api_options_Names::CACHE_HTML_LIFETIME_SECONDS => 'Cache entries will be considered stale after the specified number of seconds. Default is 21600 (six hours).', //>(translatable)<
+ ),
+ ))->addArgument(array(
+
+ tubepress_app_api_options_Reference::PROPERTY_PRO_ONLY => array(
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_FACTOR,
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_KEY,
+ tubepress_app_api_options_Names::CACHE_HTML_DIRECTORY,
+ tubepress_app_api_options_Names::CACHE_HTML_ENABLED,
+ tubepress_app_api_options_Names::CACHE_HTML_LIFETIME_SECONDS,
+ ),
+ ));
+
+ $toValidate = array(
+ tubepress_app_api_listeners_options_RegexValidatingListener::TYPE_INTEGER_POSITIVE => array(
+ tubepress_app_api_options_Names::CACHE_HTML_LIFETIME_SECONDS,
+ ),
+ tubepress_app_api_listeners_options_RegexValidatingListener::TYPE_INTEGER_NONNEGATIVE => array(
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_FACTOR,
+ ),
+ tubepress_app_api_listeners_options_RegexValidatingListener::TYPE_ONE_OR_MORE_WORDCHARS_OR_HYPHEN => array(
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_KEY
+ )
+ );
+
+ foreach ($toValidate as $type => $optionNames) {
+ foreach ($optionNames as $optionName) {
+ $containerBuilder->register(
+ 'regex_validator.' . $optionName,
+ 'tubepress_app_api_listeners_options_RegexValidatingListener'
+ )->addArgument($type)
+ ->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_app_api_options_ReferenceInterface::_))
+ ->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_lib_api_translation_TranslatorInterface::_))
+ ->addTag(tubepress_lib_api_ioc_ServiceTags::EVENT_LISTENER, array(
+ 'event' => tubepress_app_api_event_Events::OPTION_SET . ".$optionName",
+ 'priority' => 100000,
+ 'method' => 'onOption',
+ ));
+ }
+ }
+ }
+
+ private function _registerOptionsUiFieldProvider(tubepress_platform_api_ioc_ContainerBuilderInterface $containerBuilder)
+ {
+ $fieldReferences = array();
+ $fieldMap = array(
+ 'boolean' => array(
+ tubepress_app_api_options_Names::CACHE_HTML_ENABLED,
+ ),
+ 'text' => array(
+ tubepress_app_api_options_Names::CACHE_HTML_DIRECTORY,
+ tubepress_app_api_options_Names::CACHE_HTML_LIFETIME_SECONDS,
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_FACTOR,
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_KEY,
+ ),
+ );
+ foreach ($fieldMap as $type => $ids) {
+ foreach ($ids as $id) {
+
+ $serviceId = 'htmlcache_field_' . $id;
+
+ $containerBuilder->register(
+ $serviceId,
+ 'tubepress_app_api_options_ui_FieldInterface'
+ )->setFactoryService(tubepress_app_api_options_ui_FieldBuilderInterface::_)
+ ->setFactoryMethod('newInstance')
+ ->addArgument($id)
+ ->addArgument($type);
+
+ $fieldReferences[] = new tubepress_platform_api_ioc_Reference($serviceId);
+ }
+ }
+
+ $fieldMap = array(
+ tubepress_app_api_options_ui_CategoryNames::CACHE => array(
+ tubepress_app_api_options_Names::CACHE_HTML_ENABLED,
+ tubepress_app_api_options_Names::CACHE_HTML_DIRECTORY,
+ tubepress_app_api_options_Names::CACHE_HTML_LIFETIME_SECONDS,
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_FACTOR,
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_KEY,
+ ),
+ );
+
+ $containerBuilder->register(
+ 'tubepress_htmlcache_impl_options_ui_FieldProvider',
+ 'tubepress_htmlcache_impl_options_ui_FieldProvider'
+ )->addArgument($fieldReferences)
+ ->addArgument($fieldMap)
+ ->addTag('tubepress_app_api_options_ui_FieldProviderInterface');
+ }
+}
diff --git a/src/add-ons/htmlcache/manifest.json b/src/add-ons/htmlcache/manifest.json
new file mode 100644
index 000000000..b1a097fa1
--- /dev/null
+++ b/src/add-ons/htmlcache/manifest.json
@@ -0,0 +1,26 @@
+{
+ "name" : "tubepress/htmlcache",
+ "version": "99.99.99",
+ "title" : "TubePress HTML Cache",
+ "authors" : [
+ {
+ "name" : "TubePress LLC",
+ "url" : "http://tubepress.com"
+ }
+ ],
+ "license": {
+ "type" : "MPL-2.0",
+ "urls" : [ "http://www.mozilla.org/MPL/2.0/" ]
+ },
+ "container-builder": {
+ "extensions" : [
+ "tubepress_htmlcache_ioc_HtmlCacheExtension"
+ ]
+ },
+ "autoload":{
+ "classmap" : {
+ "tubepress_htmlcache_impl_options_ui_FieldProvider" : "classes/tubepress/htmlcache/impl/options/ui/FieldProvider.php",
+ "tubepress_htmlcache_ioc_HtmlCacheExtension" : "classes/tubepress/htmlcache/ioc/HtmlCacheExtension.php"
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/add-ons/core/classes/tubepress/app/impl/template/DelegatingEngine.php b/src/add-ons/template/classes/tubepress/app/template/impl/DelegatingEngine.php
similarity index 97%
rename from src/add-ons/core/classes/tubepress/app/impl/template/DelegatingEngine.php
rename to src/add-ons/template/classes/tubepress/app/template/impl/DelegatingEngine.php
index da22f4327..8222f2481 100644
--- a/src/add-ons/core/classes/tubepress/app/impl/template/DelegatingEngine.php
+++ b/src/add-ons/template/classes/tubepress/app/template/impl/DelegatingEngine.php
@@ -9,7 +9,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-class tubepress_app_impl_template_DelegatingEngine extends ehough_templating_DelegatingEngine
+class tubepress_app_template_impl_DelegatingEngine extends ehough_templating_DelegatingEngine
{
/**
* @var tubepress_platform_api_log_LoggerInterface
diff --git a/src/add-ons/core/classes/tubepress/app/impl/template/TemplatingService.php b/src/add-ons/template/classes/tubepress/app/template/impl/TemplatingService.php
similarity index 98%
rename from src/add-ons/core/classes/tubepress/app/impl/template/TemplatingService.php
rename to src/add-ons/template/classes/tubepress/app/template/impl/TemplatingService.php
index 752d9b1a9..d40a57b02 100644
--- a/src/add-ons/core/classes/tubepress/app/impl/template/TemplatingService.php
+++ b/src/add-ons/template/classes/tubepress/app/template/impl/TemplatingService.php
@@ -12,7 +12,7 @@
/**
*
*/
-class tubepress_app_impl_template_TemplatingService implements tubepress_lib_api_template_TemplatingInterface
+class tubepress_app_template_impl_TemplatingService implements tubepress_lib_api_template_TemplatingInterface
{
/**
* @var ehough_templating_EngineInterface
diff --git a/src/add-ons/core/classes/tubepress/app/impl/template/ThemeTemplateLocator.php b/src/add-ons/template/classes/tubepress/app/template/impl/ThemeTemplateLocator.php
similarity index 99%
rename from src/add-ons/core/classes/tubepress/app/impl/template/ThemeTemplateLocator.php
rename to src/add-ons/template/classes/tubepress/app/template/impl/ThemeTemplateLocator.php
index 278133c84..78ccb262b 100644
--- a/src/add-ons/core/classes/tubepress/app/impl/template/ThemeTemplateLocator.php
+++ b/src/add-ons/template/classes/tubepress/app/template/impl/ThemeTemplateLocator.php
@@ -12,7 +12,7 @@
/**
*
*/
-class tubepress_app_impl_template_ThemeTemplateLocator
+class tubepress_app_template_impl_ThemeTemplateLocator
{
/**
* @var tubepress_platform_api_contrib_RegistryInterface
diff --git a/src/add-ons/template/classes/tubepress/app/template/impl/options/ui/FieldProvider.php b/src/add-ons/template/classes/tubepress/app/template/impl/options/ui/FieldProvider.php
new file mode 100644
index 000000000..c002de91b
--- /dev/null
+++ b/src/add-ons/template/classes/tubepress/app/template/impl/options/ui/FieldProvider.php
@@ -0,0 +1,109 @@
+_fields = $fields;
+ $this->_map = $map;
+ $this->_properties = new tubepress_platform_impl_collection_Map();
+ }
+
+ /**
+ * @return tubepress_app_api_options_ui_ElementInterface[] The categories that this field provider supplies.
+ */
+ public function getCategories()
+ {
+ return array();
+ }
+
+ /**
+ * @return tubepress_app_api_options_ui_FieldInterface[] The fields that this field provider provides.
+ */
+ public function getFields()
+ {
+ return $this->_fields;
+ }
+
+ /**
+ * @return array An associative array, which may be empty, where the keys are category IDs and the values
+ * are arrays of field IDs that belong in the category.
+ */
+ public function getCategoryIdsToFieldIdsMap()
+ {
+ return $this->_map;
+ }
+
+ /**
+ * @return boolean True if this field provider should show up in the "Only show options to..." dropdown. False otherwise.
+ */
+ public function isAbleToBeFilteredFromGui()
+ {
+ return false;
+ }
+
+ /**
+ * @return boolean True if this field provider should separate its field into separate boxes. False otherwise.
+ */
+ public function fieldsShouldBeInSeparateBoxes()
+ {
+ return true;
+ }
+
+ /**
+ * @return string The name of the item that is displayed to the user.
+ */
+ public function getUntranslatedDisplayName()
+ {
+ return 'HTML Templates';
+ }
+
+ /**
+ * @return string The page-unique identifier for this item.
+ */
+ public function getId()
+ {
+ return 'field-provider-template';
+ }
+
+ /**
+ * @return tubepress_platform_api_collection_MapInterface
+ */
+ public function getProperties()
+ {
+ return $this->_properties;
+ }
+
+ /**
+ * @param string $name The property name.
+ * @param mixed $value The property value.
+ *
+ * @return void
+ *
+ * @api
+ * @since 4.0.0
+ */
+ public function setProperty($name, $value)
+ {
+ $this->_properties->put($name, $value);
+ }
+}
\ No newline at end of file
diff --git a/src/add-ons/core/classes/tubepress/app/impl/template/php/Support.php b/src/add-ons/template/classes/tubepress/app/template/impl/php/Support.php
similarity index 92%
rename from src/add-ons/core/classes/tubepress/app/impl/template/php/Support.php
rename to src/add-ons/template/classes/tubepress/app/template/impl/php/Support.php
index 95869e003..df5f8a48e 100644
--- a/src/add-ons/core/classes/tubepress/app/impl/template/php/Support.php
+++ b/src/add-ons/template/classes/tubepress/app/template/impl/php/Support.php
@@ -9,14 +9,14 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-class tubepress_app_impl_template_php_Support implements ehough_templating_loader_LoaderInterface, ehough_templating_TemplateNameParserInterface
+class tubepress_app_template_impl_php_Support implements ehough_templating_loader_LoaderInterface, ehough_templating_TemplateNameParserInterface
{
/**
- * @var tubepress_app_impl_template_ThemeTemplateLocator
+ * @var tubepress_app_template_impl_ThemeTemplateLocator
*/
private $_themeTemplateLocator;
- public function __construct(tubepress_app_impl_template_ThemeTemplateLocator $locator)
+ public function __construct(tubepress_app_template_impl_ThemeTemplateLocator $locator)
{
$this->_themeTemplateLocator = $locator;
}
diff --git a/src/add-ons/core/classes/tubepress/app/impl/template/twig/Engine.php b/src/add-ons/template/classes/tubepress/app/template/impl/twig/Engine.php
similarity index 98%
rename from src/add-ons/core/classes/tubepress/app/impl/template/twig/Engine.php
rename to src/add-ons/template/classes/tubepress/app/template/impl/twig/Engine.php
index f9ab80c55..620a5dd4a 100644
--- a/src/add-ons/core/classes/tubepress/app/impl/template/twig/Engine.php
+++ b/src/add-ons/template/classes/tubepress/app/template/impl/twig/Engine.php
@@ -38,7 +38,7 @@
*
* @author Fabien Potencier
*/
-class tubepress_app_impl_template_twig_Engine implements ehough_templating_EngineInterface
+class tubepress_app_template_impl_twig_Engine implements ehough_templating_EngineInterface
{
/**
* @var Twig_Environment
diff --git a/src/add-ons/core/classes/tubepress/app/impl/template/twig/EnvironmentBuilder.php b/src/add-ons/template/classes/tubepress/app/template/impl/twig/EnvironmentBuilder.php
similarity index 98%
rename from src/add-ons/core/classes/tubepress/app/impl/template/twig/EnvironmentBuilder.php
rename to src/add-ons/template/classes/tubepress/app/template/impl/twig/EnvironmentBuilder.php
index 809693234..17ae3cf63 100644
--- a/src/add-ons/core/classes/tubepress/app/impl/template/twig/EnvironmentBuilder.php
+++ b/src/add-ons/template/classes/tubepress/app/template/impl/twig/EnvironmentBuilder.php
@@ -9,7 +9,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-class tubepress_app_impl_template_twig_EnvironmentBuilder
+class tubepress_app_template_impl_twig_EnvironmentBuilder
{
/**
* @var Twig_LoaderInterface
diff --git a/src/add-ons/core/classes/tubepress/app/impl/template/twig/FsLoader.php b/src/add-ons/template/classes/tubepress/app/template/impl/twig/FsLoader.php
similarity index 95%
rename from src/add-ons/core/classes/tubepress/app/impl/template/twig/FsLoader.php
rename to src/add-ons/template/classes/tubepress/app/template/impl/twig/FsLoader.php
index 907d59969..a8c19d45e 100644
--- a/src/add-ons/core/classes/tubepress/app/impl/template/twig/FsLoader.php
+++ b/src/add-ons/template/classes/tubepress/app/template/impl/twig/FsLoader.php
@@ -9,7 +9,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-class tubepress_app_impl_template_twig_FsLoader extends Twig_Loader_Filesystem
+class tubepress_app_template_impl_twig_FsLoader extends Twig_Loader_Filesystem
{
/**
* @var tubepress_platform_api_log_LoggerInterface
diff --git a/src/add-ons/core/classes/tubepress/app/impl/template/twig/ThemeLoader.php b/src/add-ons/template/classes/tubepress/app/template/impl/twig/ThemeLoader.php
similarity index 92%
rename from src/add-ons/core/classes/tubepress/app/impl/template/twig/ThemeLoader.php
rename to src/add-ons/template/classes/tubepress/app/template/impl/twig/ThemeLoader.php
index a9464078b..9f4c62e17 100644
--- a/src/add-ons/core/classes/tubepress/app/impl/template/twig/ThemeLoader.php
+++ b/src/add-ons/template/classes/tubepress/app/template/impl/twig/ThemeLoader.php
@@ -9,14 +9,14 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-class tubepress_app_impl_template_twig_ThemeLoader implements Twig_LoaderInterface
+class tubepress_app_template_impl_twig_ThemeLoader implements Twig_LoaderInterface
{
/**
- * @var tubepress_app_impl_template_ThemeTemplateLocator
+ * @var tubepress_app_template_impl_ThemeTemplateLocator
*/
private $_themeTemplateLocator;
- public function __construct(tubepress_app_impl_template_ThemeTemplateLocator $locator)
+ public function __construct(tubepress_app_template_impl_ThemeTemplateLocator $locator)
{
$this->_themeTemplateLocator = $locator;
}
diff --git a/src/add-ons/template/classes/tubepress/app/template/ioc/TemplateExtension.php b/src/add-ons/template/classes/tubepress/app/template/ioc/TemplateExtension.php
new file mode 100644
index 000000000..b70a4b215
--- /dev/null
+++ b/src/add-ons/template/classes/tubepress/app/template/ioc/TemplateExtension.php
@@ -0,0 +1,229 @@
+_registerOptions($containerBuilder);
+ $this->_registerOptionsUiFieldProvider($containerBuilder);
+ $this->_registerTemplatingService($containerBuilder);
+ }
+
+ private function _registerOptions(tubepress_platform_api_ioc_ContainerBuilderInterface $containerBuilder)
+ {
+ $containerBuilder->register(
+ 'tubepress_app_api_options_Reference__template',
+ 'tubepress_app_api_options_Reference'
+ )->addTag(tubepress_app_api_options_ReferenceInterface::_)
+ ->addArgument(array(
+
+ tubepress_app_api_options_Reference::PROPERTY_DEFAULT_VALUE => array(
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_AUTORELOAD => false,
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_DIR => null,
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_ENABLED => true,
+ ),
+
+ tubepress_app_api_options_Reference::PROPERTY_UNTRANSLATED_LABEL => array(
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_AUTORELOAD => 'Monitor templates for changes', //>(translatable)<
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_DIR => 'Template cache directory', //>(translatable)<
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_ENABLED => 'Enable template cache', //>(translatable)<
+
+ ),
+
+ tubepress_app_api_options_Reference::PROPERTY_UNTRANSLATED_DESCRIPTION => array(
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_AUTORELOAD => 'Automatically recompile templates when they are changed. Turning on the monitor is very useful if you are developing custom templates, but doing so also incurs a performance penalty. If you are unsure, leave this disabled.', //>(translatable)<
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_DIR => 'Leave blank to attempt to use your system\'s temp directory. Otherwise enter the absolute path of a writeable directory where TubePress can store cached templates.', //>(translatable)<
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_ENABLED => 'Compile and cache Twig templates to pure PHP for maximum performance. Most users should leave this enabled.', //>(translatable)<
+ ),
+ ));
+ }
+
+ private function _registerOptionsUiFieldProvider(tubepress_platform_api_ioc_ContainerBuilderInterface $containerBuilder)
+ {
+ $fieldReferences = array();
+ $fieldMap = array(
+ 'boolean' => array(
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_AUTORELOAD,
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_ENABLED,
+ ),
+ 'text' => array(
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_DIR,
+ ),
+ );
+ foreach ($fieldMap as $type => $ids) {
+ foreach ($ids as $id) {
+
+ $serviceId = 'template_field_' . $id;
+
+ $containerBuilder->register(
+ $serviceId,
+ 'tubepress_app_api_options_ui_FieldInterface'
+ )->setFactoryService(tubepress_app_api_options_ui_FieldBuilderInterface::_)
+ ->setFactoryMethod('newInstance')
+ ->addArgument($id)
+ ->addArgument($type);
+
+ $fieldReferences[] = new tubepress_platform_api_ioc_Reference($serviceId);
+ }
+ }
+
+ $fieldMap = array(
+ tubepress_app_api_options_ui_CategoryNames::CACHE => array(
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_ENABLED,
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_DIR,
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_AUTORELOAD,
+ ),
+
+ );
+
+ $containerBuilder->register(
+ 'tubepress_app_template_impl_options_ui_FieldProvider',
+ 'tubepress_app_template_impl_options_ui_FieldProvider'
+ )->addArgument($fieldReferences)
+ ->addArgument($fieldMap)
+ ->addTag('tubepress_app_api_options_ui_FieldProviderInterface');
+ }
+
+ private function _registerTemplatingService(tubepress_platform_api_ioc_ContainerBuilderInterface $containerBuilder)
+ {
+ $parallelServices = array(
+ '' => 'public',
+ '.admin' => 'admin'
+ );
+
+ foreach ($parallelServices as $serviceSuffix => $templatePath) {
+
+ /**
+ * Theme template locators.
+ */
+ $containerBuilder->register(
+ 'tubepress_app_template_impl_ThemeTemplateLocator' . $serviceSuffix,
+ 'tubepress_app_template_impl_ThemeTemplateLocator'
+ )->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_log_LoggerInterface::_))
+ ->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_app_api_options_ContextInterface::_))
+ ->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_contrib_RegistryInterface::_ . '.' . tubepress_app_api_theme_ThemeInterface::_ . $serviceSuffix))
+ ->addArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_impl_theme_CurrentThemeService' . $serviceSuffix));
+
+ /**
+ * Twig loaders.
+ */
+ $containerBuilder->register(
+ 'tubepress_app_template_impl_twig_ThemeLoader' . $serviceSuffix,
+ 'tubepress_app_template_impl_twig_ThemeLoader'
+ )->addArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_template_impl_ThemeTemplateLocator' . $serviceSuffix));
+
+ $containerBuilder->register(
+ 'Twig_Loader_Filesystem' . $serviceSuffix,
+ 'tubepress_app_template_impl_twig_FsLoader'
+ )->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_log_LoggerInterface::_))
+ ->addArgument(array(
+ TUBEPRESS_ROOT . '/src/add-ons/core/templates/' . $templatePath,
+ ));
+
+ $twigLoaderReferences = array(
+ new tubepress_platform_api_ioc_Reference('tubepress_app_template_impl_twig_ThemeLoader' . $serviceSuffix),
+ new tubepress_platform_api_ioc_Reference('Twig_Loader_Filesystem' . $serviceSuffix)
+ );
+ $containerBuilder->register(
+ 'Twig_LoaderInterface' . $serviceSuffix,
+ 'Twig_Loader_Chain'
+ )->addArgument($twigLoaderReferences);
+
+ /**
+ * Twig environment builder.
+ */
+ $containerBuilder->register(
+ 'tubepress_app_template_impl_twig_EnvironmentBuilder' . $serviceSuffix,
+ 'tubepress_app_template_impl_twig_EnvironmentBuilder'
+ )->addArgument(new tubepress_platform_api_ioc_Reference('Twig_LoaderInterface' . $serviceSuffix))
+ ->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_boot_BootSettingsInterface::_))
+ ->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_app_api_options_ContextInterface::_))
+ ->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_lib_api_translation_TranslatorInterface::_));
+
+ /**
+ * Twig environment.
+ */
+ $containerBuilder->register(
+ 'Twig_Environment' . $serviceSuffix,
+ 'Twig_Environment'
+ )->setFactoryService('tubepress_app_template_impl_twig_EnvironmentBuilder' . $serviceSuffix)
+ ->setFactoryMethod('buildTwigEnvironment');
+
+ /**
+ * Twig engine
+ */
+ $containerBuilder->register(
+ 'tubepress_app_template_impl_twig_Engine' . $serviceSuffix,
+ 'tubepress_app_template_impl_twig_Engine'
+ )->addArgument(new tubepress_platform_api_ioc_Reference('Twig_Environment' . $serviceSuffix));
+ }
+
+ /**
+ * Register PHP engine support
+ */
+ $containerBuilder->register(
+ 'tubepress_app_template_impl_php_Support',
+ 'tubepress_app_template_impl_php_Support'
+ )->addArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_template_impl_ThemeTemplateLocator'));
+
+ /**
+ * Register the PHP templating engine
+ */
+ $containerBuilder->register(
+ 'ehough_templating_PhpEngine',
+ 'ehough_templating_PhpEngine'
+ )->addArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_template_impl_php_Support'))
+ ->addArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_template_impl_php_Support'));
+
+ /**
+ * Public templating engine
+ */
+ $engineReferences = array(
+ new tubepress_platform_api_ioc_Reference('ehough_templating_PhpEngine'),
+ new tubepress_platform_api_ioc_Reference('tubepress_app_template_impl_twig_Engine')
+ );
+ $containerBuilder->register(
+ 'tubepress_app_template_impl_DelegatingEngine',
+ 'tubepress_app_template_impl_DelegatingEngine'
+ )->addArgument($engineReferences)
+ ->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_log_LoggerInterface::_));
+
+ /**
+ * Final templating services
+ */
+ $containerBuilder->register(
+ tubepress_lib_api_template_TemplatingInterface::_,
+ 'tubepress_app_template_impl_TemplatingService'
+ )->addArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_template_impl_DelegatingEngine'))
+ ->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_lib_api_event_EventDispatcherInterface::_));
+ $containerBuilder->register(
+ tubepress_lib_api_template_TemplatingInterface::_ . '.admin',
+ 'tubepress_app_template_impl_TemplatingService'
+ )->addArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_template_impl_twig_Engine.admin'))
+ ->addArgument(new tubepress_platform_api_ioc_Reference(tubepress_lib_api_event_EventDispatcherInterface::_));
+ }
+}
diff --git a/src/add-ons/core/classes/tubepress/lib/ioc/compiler/TemplatePathProvidersPass.php b/src/add-ons/template/classes/tubepress/app/template/ioc/compiler/TemplatePathProvidersPass.php
similarity index 93%
rename from src/add-ons/core/classes/tubepress/lib/ioc/compiler/TemplatePathProvidersPass.php
rename to src/add-ons/template/classes/tubepress/app/template/ioc/compiler/TemplatePathProvidersPass.php
index 1ff84ac5b..06344dfa1 100644
--- a/src/add-ons/core/classes/tubepress/lib/ioc/compiler/TemplatePathProvidersPass.php
+++ b/src/add-ons/template/classes/tubepress/app/template/ioc/compiler/TemplatePathProvidersPass.php
@@ -9,7 +9,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-class tubepress_lib_ioc_compiler_TemplatePathProvidersPass implements tubepress_platform_api_ioc_CompilerPassInterface
+class tubepress_app_template_ioc_compiler_TemplatePathProvidersPass implements tubepress_platform_api_ioc_CompilerPassInterface
{
/**
* @param tubepress_platform_api_ioc_ContainerBuilderInterface $containerBuilder The primary service container builder.
diff --git a/src/add-ons/template/manifest.json b/src/add-ons/template/manifest.json
new file mode 100644
index 000000000..7ba8c8f08
--- /dev/null
+++ b/src/add-ons/template/manifest.json
@@ -0,0 +1,38 @@
+{
+ "name" : "tubepress/template",
+ "version": "99.99.99",
+ "title" : "TubePress Template Functionality",
+ "authors" : [
+ {
+ "name" : "TubePress LLC",
+ "url" : "http://tubepress.com"
+ }
+ ],
+ "license": {
+ "type" : "MPL-2.0",
+ "urls" : [ "http://www.mozilla.org/MPL/2.0/" ]
+ },
+ "container-builder": {
+ "compiler-passes" : {
+ "tubepress_app_template_ioc_compiler_TemplatePathProvidersPass" : 70000
+ },
+ "extensions" : [
+ "tubepress_app_template_ioc_TemplateExtension"
+ ]
+ },
+ "autoload":{
+ "classmap" : {
+ "tubepress_app_template_ioc_compiler_TemplatePathProvidersPass" : "classes/tubepress/app/template/ioc/compiler/TemplatePathProvidersPass.php",
+ "tubepress_app_template_ioc_TemplateExtension" : "classes/tubepress/app/template/ioc/TemplateExtension.php",
+ "tubepress_app_template_impl_options_ui_FieldProvider" : "classes/tubepress/app/template/impl/options/ui/FieldProvider.php",
+ "tubepress_app_template_impl_DelegatingEngine" : "classes/tubepress/app/template/impl/DelegatingEngine.php",
+ "tubepress_app_template_impl_php_Support" : "classes/tubepress/app/template/impl/php/Support.php",
+ "tubepress_app_template_impl_TemplatingService" : "classes/tubepress/app/template/impl/TemplatingService.php",
+ "tubepress_app_template_impl_ThemeTemplateLocator" : "classes/tubepress/app/template/impl/ThemeTemplateLocator.php",
+ "tubepress_app_template_impl_twig_Engine" : "classes/tubepress/app/template/impl/twig/Engine.php",
+ "tubepress_app_template_impl_twig_EnvironmentBuilder" : "classes/tubepress/app/template/impl/twig/EnvironmentBuilder.php",
+ "tubepress_app_template_impl_twig_FsLoader" : "classes/tubepress/app/template/impl/twig/FsLoader.php",
+ "tubepress_app_template_impl_twig_ThemeLoader" : "classes/tubepress/app/template/impl/twig/ThemeLoader.php"
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/add-ons/wordpress/web/js/wordpress-ajax.js b/src/add-ons/wordpress/web/js/wordpress-ajax.js
index 9b5fca4f7..011fbb61b 100644
--- a/src/add-ons/wordpress/web/js/wordpress-ajax.js
+++ b/src/add-ons/wordpress/web/js/wordpress-ajax.js
@@ -8,7 +8,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-(function (jquery, tubePress) {
+(function (tubePress) {
/** http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/ */
'use strict';
@@ -19,6 +19,7 @@
text_action = 'action',
text_data = 'data',
text_dataType = text_data + 'Type',
+ jquery = tubePress.Vendors.jQuery,
onAjax = function (options, originalOptions, jqxhr) {
@@ -58,4 +59,4 @@
jquery(init);
-}(jQuery, TubePress));
\ No newline at end of file
+}(TubePress));
\ No newline at end of file
diff --git a/src/platform/scripts/boot.php b/src/platform/scripts/boot.php
index 89909640f..7beb4dc66 100644
--- a/src/platform/scripts/boot.php
+++ b/src/platform/scripts/boot.php
@@ -9,9 +9,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-if (!class_exists('__tubePressBoot', false)) {
+if (!class_exists('tubePressBootScript', false)) {
- class __tubePressBoot
+ class tubePressBootScript
{
public static $SERVICE_CONTAINER = null;
@@ -76,4 +76,4 @@ private static function _calculateTubePressRoot()
}
}
-return __tubePressBoot::getServiceContainer();
\ No newline at end of file
+return tubePressBootScript::getServiceContainer();
\ No newline at end of file
diff --git a/src/platform/scripts/classloading/classmap.php b/src/platform/scripts/classloading/classmap.php
index ec5429ff0..d90960a6e 100644
--- a/src/platform/scripts/classloading/classmap.php
+++ b/src/platform/scripts/classloading/classmap.php
@@ -560,14 +560,6 @@
'tubepress_app_impl_player_JsPlayerLocation' => TUBEPRESS_ROOT . '/src/add-ons/core/classes/tubepress/app/impl/player/JsPlayerLocation.php',
'tubepress_app_impl_player_SoloOrStaticPlayerLocation' => TUBEPRESS_ROOT . '/src/add-ons/core/classes/tubepress/app/impl/player/SoloOrStaticPlayerLocation.php',
'tubepress_app_impl_shortcode_Parser' => TUBEPRESS_ROOT . '/src/add-ons/core/classes/tubepress/app/impl/shortcode/Parser.php',
- 'tubepress_app_impl_template_DelegatingEngine' => TUBEPRESS_ROOT . '/src/add-ons/core/classes/tubepress/app/impl/template/DelegatingEngine.php',
- 'tubepress_app_impl_template_TemplatingService' => TUBEPRESS_ROOT . '/src/add-ons/core/classes/tubepress/app/impl/template/TemplatingService.php',
- 'tubepress_app_impl_template_ThemeTemplateLocator' => TUBEPRESS_ROOT . '/src/add-ons/core/classes/tubepress/app/impl/template/ThemeTemplateLocator.php',
- 'tubepress_app_impl_template_php_Support' => TUBEPRESS_ROOT . '/src/add-ons/core/classes/tubepress/app/impl/template/php/Support.php',
- 'tubepress_app_impl_template_twig_Engine' => TUBEPRESS_ROOT . '/src/add-ons/core/classes/tubepress/app/impl/template/twig/Engine.php',
- 'tubepress_app_impl_template_twig_EnvironmentBuilder' => TUBEPRESS_ROOT . '/src/add-ons/core/classes/tubepress/app/impl/template/twig/EnvironmentBuilder.php',
- 'tubepress_app_impl_template_twig_FsLoader' => TUBEPRESS_ROOT . '/src/add-ons/core/classes/tubepress/app/impl/template/twig/FsLoader.php',
- 'tubepress_app_impl_template_twig_ThemeLoader' => TUBEPRESS_ROOT . '/src/add-ons/core/classes/tubepress/app/impl/template/twig/ThemeLoader.php',
'tubepress_app_impl_theme_AbstractTheme' => TUBEPRESS_ROOT . '/src/add-ons/core/classes/tubepress/app/impl/theme/AbstractTheme.php',
'tubepress_app_impl_theme_CurrentThemeService' => TUBEPRESS_ROOT . '/src/add-ons/core/classes/tubepress/app/impl/theme/CurrentThemeService.php',
'tubepress_app_impl_theme_FilesystemTheme' => TUBEPRESS_ROOT . '/src/add-ons/core/classes/tubepress/app/impl/theme/FilesystemTheme.php',
@@ -575,12 +567,25 @@
'tubepress_app_impl_vendor_stash_FilesystemCacheBuilder' => TUBEPRESS_ROOT . '/src/add-ons/core/classes/tubepress/app/impl/vendor/stash/FilesystemCacheBuilder.php',
'tubepress_app_ioc_AppExtension' => TUBEPRESS_ROOT . '/src/add-ons/core/classes/tubepress/app/ioc/AppExtension.php',
'tubepress_app_ioc_compiler_EventDispatcherLoggingPass' => TUBEPRESS_ROOT . '/src/add-ons/core/classes/tubepress/app/ioc/compiler/EventDispatcherLoggingPass.php',
+ 'tubepress_app_template_impl_DelegatingEngine' => TUBEPRESS_ROOT . '/src/add-ons/template/classes/tubepress/app/template/impl/DelegatingEngine.php',
+ 'tubepress_app_template_impl_TemplatingService' => TUBEPRESS_ROOT . '/src/add-ons/template/classes/tubepress/app/template/impl/TemplatingService.php',
+ 'tubepress_app_template_impl_ThemeTemplateLocator' => TUBEPRESS_ROOT . '/src/add-ons/template/classes/tubepress/app/template/impl/ThemeTemplateLocator.php',
+ 'tubepress_app_template_impl_options_ui_FieldProvider' => TUBEPRESS_ROOT . '/src/add-ons/template/classes/tubepress/app/template/impl/options/ui/FieldProvider.php',
+ 'tubepress_app_template_impl_php_Support' => TUBEPRESS_ROOT . '/src/add-ons/template/classes/tubepress/app/template/impl/php/Support.php',
+ 'tubepress_app_template_impl_twig_Engine' => TUBEPRESS_ROOT . '/src/add-ons/template/classes/tubepress/app/template/impl/twig/Engine.php',
+ 'tubepress_app_template_impl_twig_EnvironmentBuilder' => TUBEPRESS_ROOT . '/src/add-ons/template/classes/tubepress/app/template/impl/twig/EnvironmentBuilder.php',
+ 'tubepress_app_template_impl_twig_FsLoader' => TUBEPRESS_ROOT . '/src/add-ons/template/classes/tubepress/app/template/impl/twig/FsLoader.php',
+ 'tubepress_app_template_impl_twig_ThemeLoader' => TUBEPRESS_ROOT . '/src/add-ons/template/classes/tubepress/app/template/impl/twig/ThemeLoader.php',
+ 'tubepress_app_template_ioc_TemplateExtension' => TUBEPRESS_ROOT . '/src/add-ons/template/classes/tubepress/app/template/ioc/TemplateExtension.php',
+ 'tubepress_app_template_ioc_compiler_TemplatePathProvidersPass' => TUBEPRESS_ROOT . '/src/add-ons/template/classes/tubepress/app/template/ioc/compiler/TemplatePathProvidersPass.php',
'tubepress_deprecated_impl_listeners_LegacyMetadataTemplateListener' => TUBEPRESS_ROOT . '/src/add-ons/deprecated/classes/tubepress/deprecated/impl/listeners/LegacyMetadataTemplateListener.php',
'tubepress_deprecated_impl_listeners_LegacyTemplateListener' => TUBEPRESS_ROOT . '/src/add-ons/deprecated/classes/tubepress/deprecated/impl/listeners/LegacyTemplateListener.php',
'tubepress_deprecated_ioc_DeprecatedExtension' => TUBEPRESS_ROOT . '/src/add-ons/deprecated/classes/tubepress/deprecated/ioc/DeprecatedExtension.php',
'tubepress_deprecated_ioc_compiler_LegacyThemesPrimerPass' => TUBEPRESS_ROOT . '/src/add-ons/deprecated/classes/tubepress/deprecated/ioc/compiler/LegacyThemesPrimerPass.php',
'tubepress_embedplus_impl_EmbedPlus' => TUBEPRESS_ROOT . '/src/add-ons/embedplus/classes/tubepress/embedplus/impl/EmbedPlus.php',
'tubepress_embedplus_ioc_EmbedPlusExtension' => TUBEPRESS_ROOT . '/src/add-ons/embedplus/classes/tubepress/embedplus/ioc/EmbedPlusExtension.php',
+ 'tubepress_htmlcache_impl_options_ui_FieldProvider' => TUBEPRESS_ROOT . '/src/add-ons/htmlcache/classes/tubepress/htmlcache/impl/options/ui/FieldProvider.php',
+ 'tubepress_htmlcache_ioc_HtmlCacheExtension' => TUBEPRESS_ROOT . '/src/add-ons/htmlcache/classes/tubepress/htmlcache/ioc/HtmlCacheExtension.php',
'tubepress_jwplayer5_api_OptionNames' => TUBEPRESS_ROOT . '/src/add-ons/jwplayer5/classes/tubepress/jwplayer5/api/OptionNames.php',
'tubepress_jwplayer5_impl_embedded_JwPlayer5EmbeddedProvider' => TUBEPRESS_ROOT . '/src/add-ons/jwplayer5/classes/tubepress/jwplayer5/impl/embedded/JwPlayer5EmbeddedProvider.php',
'tubepress_jwplayer5_impl_options_ui_JwPlayerFieldProvider' => TUBEPRESS_ROOT . '/src/add-ons/jwplayer5/classes/tubepress/jwplayer5/impl/options/ui/JwPlayerFieldProvider.php',
@@ -626,7 +631,6 @@
'tubepress_lib_ioc_LibExtension' => TUBEPRESS_ROOT . '/src/add-ons/core/classes/tubepress/lib/ioc/LibExtension.php',
'tubepress_lib_ioc_compiler_EventListenersPass' => TUBEPRESS_ROOT . '/src/add-ons/core/classes/tubepress/lib/ioc/compiler/EventListenersPass.php',
'tubepress_lib_ioc_compiler_TaggedServicesConsumerPass' => TUBEPRESS_ROOT . '/src/add-ons/core/classes/tubepress/lib/ioc/compiler/TaggedServicesConsumerPass.php',
- 'tubepress_lib_ioc_compiler_TemplatePathProvidersPass' => TUBEPRESS_ROOT . '/src/add-ons/core/classes/tubepress/lib/ioc/compiler/TemplatePathProvidersPass.php',
'tubepress_platform_api_addon_AddonInterface' => TUBEPRESS_ROOT . '/src/platform/classes/tubepress/platform/api/addon/AddonInterface.php',
'tubepress_platform_api_boot_BootSettingsInterface' => TUBEPRESS_ROOT . '/src/platform/classes/tubepress/platform/api/boot/BootSettingsInterface.php',
'tubepress_platform_api_collection_MapInterface' => TUBEPRESS_ROOT . '/src/platform/classes/tubepress/platform/api/collection/MapInterface.php',
diff --git a/tests/unit/add-ons/core/classes/tubepress/test/app/impl/html/HtmlGeneratorTest.php b/tests/unit/add-ons/core/classes/tubepress/test/app/impl/html/HtmlGeneratorTest.php
index cab32edb8..cfc171579 100644
--- a/tests/unit/add-ons/core/classes/tubepress/test/app/impl/html/HtmlGeneratorTest.php
+++ b/tests/unit/add-ons/core/classes/tubepress/test/app/impl/html/HtmlGeneratorTest.php
@@ -75,14 +75,19 @@ public function testHtmlBad()
public function testHtmlOK()
{
- $mockGenerationEvent = $this->mock('tubepress_lib_api_event_EventInterface');
- $this->_mockEventDispatcher->shouldReceive('newEventInstance')->once()->with('')->andReturn($mockGenerationEvent);
- $this->_mockEventDispatcher->shouldReceive('dispatch')->once()->with(tubepress_app_api_event_Events::HTML_GENERATION, $mockGenerationEvent);
- $mockGenerationEvent->shouldReceive('getSubject')->once()->andReturn('abc');
+ $mockGenerationEventPre = $this->mock('tubepress_lib_api_event_EventInterface');
+ $this->_mockEventDispatcher->shouldReceive('newEventInstance')->once()->with('')->andReturn($mockGenerationEventPre);
+ $this->_mockEventDispatcher->shouldReceive('dispatch')->once()->with(tubepress_app_api_event_Events::HTML_GENERATION, $mockGenerationEventPre);
+ $mockGenerationEventPre->shouldReceive('getSubject')->once()->andReturn('abc');
+
+ $mockGenerationEventPost = $this->mock('tubepress_lib_api_event_EventInterface');
+ $this->_mockEventDispatcher->shouldReceive('newEventInstance')->once()->with('abc')->andReturn($mockGenerationEventPost);
+ $this->_mockEventDispatcher->shouldReceive('dispatch')->once()->with(tubepress_app_api_event_Events::HTML_GENERATION_POST, $mockGenerationEventPost);
+ $mockGenerationEventPost->shouldReceive('getSubject')->once()->andReturn('xyz');
$actual = $this->_sut->getHtml();
- $this->assertEquals('abc', $actual);
+ $this->assertEquals('xyz', $actual);
}
/**
diff --git a/tests/unit/add-ons/core/classes/tubepress/test/app/impl/vendor/stash/FilesystemCacheBuilderTest.php b/tests/unit/add-ons/core/classes/tubepress/test/app/impl/vendor/stash/FilesystemCacheBuilderTest.php
index 68c4b4845..04ad9562f 100644
--- a/tests/unit/add-ons/core/classes/tubepress/test/app/impl/vendor/stash/FilesystemCacheBuilderTest.php
+++ b/tests/unit/add-ons/core/classes/tubepress/test/app/impl/vendor/stash/FilesystemCacheBuilderTest.php
@@ -29,15 +29,25 @@ class tubepress_test_app_vendor_impl_stash_FilesystemCacheBuilderTest extends tu
*/
private $_mockBootSettings;
+ /**
+ * @var ehough_mockery_mockery_MockInterface
+ */
+ private $_mockLogger;
public function onSetup()
{
$this->_mockBootSettings = $this->mock(tubepress_platform_api_boot_BootSettingsInterface::_);
$this->_mockContext = $this->mock(tubepress_app_api_options_ContextInterface::_);
+ $this->_mockLogger = $this->mock(tubepress_platform_api_log_LoggerInterface::_);
+
+ $this->_mockLogger->shouldReceive('isEnabled')->once()->andReturn(true);
+ $this->_mockLogger->shouldReceive('debug')->atLeast(1);
+
$this->_sut = new tubepress_app_impl_vendor_stash_FilesystemCacheBuilder(
$this->_mockContext,
- $this->_mockBootSettings
+ $this->_mockBootSettings,
+ $this->_mockLogger
);
}
diff --git a/tests/unit/add-ons/core/classes/tubepress/test/app/ioc/AppExtensionTest.php b/tests/unit/add-ons/core/classes/tubepress/test/app/ioc/AppExtensionTest.php
index 9f1460280..c884a07e6 100644
--- a/tests/unit/add-ons/core/classes/tubepress/test/app/ioc/AppExtensionTest.php
+++ b/tests/unit/add-ons/core/classes/tubepress/test/app/ioc/AppExtensionTest.php
@@ -56,7 +56,9 @@ protected function getExpectedExternalServicesMap()
'tubepress_platform_impl_log_BootLogger' => $mockBootLogger,
tubepress_lib_api_util_TimeUtilsInterface::_ => tubepress_lib_api_util_TimeUtilsInterface::_,
tubepress_lib_api_http_HttpClientInterface::_ => tubepress_lib_api_http_HttpClientInterface::_,
- tubepress_app_api_options_PersistenceBackendInterface::_ => tubepress_app_api_options_PersistenceBackendInterface::_
+ tubepress_app_api_options_PersistenceBackendInterface::_ => tubepress_app_api_options_PersistenceBackendInterface::_,
+ tubepress_lib_api_template_TemplatingInterface::_ => tubepress_lib_api_template_TemplatingInterface::_,
+ tubepress_lib_api_template_TemplatingInterface::_ . '.admin' => tubepress_lib_api_template_TemplatingInterface::_,
);
}
@@ -121,7 +123,6 @@ protected function prepareForLoad()
$this->_registerOptionsUiFieldProvider();
$this->_registerPlayers();
$this->_registerShortcode();
- $this->_registerTemplatingService();
$this->_registerTheme();
$this->_registerVendorServices();
}
@@ -697,9 +698,6 @@ private function _registerOptions()
tubepress_app_api_options_Names::SHORTCODE_KEYWORD => 'tubepress',
tubepress_app_api_options_Names::SINGLE_MEDIA_ITEM_ID => null,
tubepress_app_api_options_Names::SOURCES => null,
- tubepress_app_api_options_Names::TEMPLATE_CACHE_AUTORELOAD => false,
- tubepress_app_api_options_Names::TEMPLATE_CACHE_DIR => null,
- tubepress_app_api_options_Names::TEMPLATE_CACHE_ENABLED => true,
tubepress_app_api_options_Names::THEME => 'tubepress/default',
tubepress_app_api_options_Names::THEME_ADMIN => 'tubepress/admin-default',
),
@@ -753,9 +751,6 @@ private function _registerOptions()
tubepress_app_api_options_Names::RESPONSIVE_EMBEDS => 'Responsive embeds', //>(translatable)<
tubepress_app_api_options_Names::SEARCH_ONLY_USER => 'Restrict search results to videos from author', //>(translatable)<
tubepress_app_api_options_Names::SHORTCODE_KEYWORD => 'Shortcode keyword', //>(translatable)<
- tubepress_app_api_options_Names::TEMPLATE_CACHE_AUTORELOAD => 'Monitor templates for changes', //>(translatable)<
- tubepress_app_api_options_Names::TEMPLATE_CACHE_DIR => 'Template cache directory', //>(translatable)<
- tubepress_app_api_options_Names::TEMPLATE_CACHE_ENABLED => 'Enable template cache', //>(translatable)<
tubepress_app_api_options_Names::THEME => 'Theme', //>(translatable)<
),
@@ -764,7 +759,7 @@ private function _registerOptions()
tubepress_app_api_options_Names::CACHE_CLEANING_FACTOR => 'If you enter X, the entire cache will be cleaned every 1/X cache writes. Enter 0 to disable cache cleaning.', //>(translatable)<
tubepress_app_api_options_Names::CACHE_DIRECTORY => 'Leave blank to attempt to use your system\'s temp directory. Otherwise enter the absolute path of a writeable directory.', //>(translatable)<
tubepress_app_api_options_Names::CACHE_ENABLED => 'Store API responses in a cache file to significantly reduce load times for your galleries at the slight expense of freshness.', //>(translatable)<
- tubepress_app_api_options_Names::CACHE_LIFETIME_SECONDS => 'Cache entries will be considered stale after the specified number of seconds. Default is 3600 (one hour).', //>(translatable)<
+ tubepress_app_api_options_Names::CACHE_LIFETIME_SECONDS => 'Cache entries will be considered stale after the specified number of seconds. Default is 21600 (six hours).', //>(translatable)<
tubepress_app_api_options_Names::DEBUG_ON => 'If checked, anyone will be able to view your debugging information. This is a rather small privacy risk. If you\'re not having problems with TubePress, or you\'re worried about revealing any details of your TubePress pages, feel free to disable the feature.', //>(translatable)<
tubepress_app_api_options_Names::EMBEDDED_HEIGHT => sprintf('Default is %s.', 390), //>(translatable)<
tubepress_app_api_options_Names::EMBEDDED_LAZYPLAY => 'Auto-play each video after thumbnail click.', //>(translatable)<
@@ -1208,125 +1203,6 @@ private function _registerShortcode()
->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_util_StringUtilsInterface::_));
}
- private function _registerTemplatingService()
- {
- $parallelServices = array(
- '' => 'public',
- '.admin' => 'admin'
- );
-
- foreach ($parallelServices as $serviceSuffix => $templatePath) {
-
- /**
- * Theme template locators.
- */
- $this->expectRegistration(
- 'tubepress_app_impl_template_ThemeTemplateLocator' . $serviceSuffix,
- 'tubepress_app_impl_template_ThemeTemplateLocator'
- )->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_log_LoggerInterface::_))
- ->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_app_api_options_ContextInterface::_))
- ->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_contrib_RegistryInterface::_ . '.' . tubepress_app_api_theme_ThemeInterface::_ . $serviceSuffix))
- ->withArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_impl_theme_CurrentThemeService' . $serviceSuffix));
-
- /**
- * Twig loaders.
- */
- $this->expectRegistration(
- 'tubepress_app_impl_template_twig_ThemeLoader' . $serviceSuffix,
- 'tubepress_app_impl_template_twig_ThemeLoader'
- )->withArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_impl_template_ThemeTemplateLocator' . $serviceSuffix));
-
- $this->expectRegistration(
- 'Twig_Loader_Filesystem' . $serviceSuffix,
- 'tubepress_app_impl_template_twig_FsLoader'
- )->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_log_LoggerInterface::_))
- ->withArgument(array(
- TUBEPRESS_ROOT . '/src/add-ons/core/templates/' . $templatePath,
- ));
-
- $twigLoaderReferences = array(
- new tubepress_platform_api_ioc_Reference('tubepress_app_impl_template_twig_ThemeLoader' . $serviceSuffix),
- new tubepress_platform_api_ioc_Reference('Twig_Loader_Filesystem' . $serviceSuffix)
- );
- $this->expectRegistration(
- 'Twig_LoaderInterface' . $serviceSuffix,
- 'Twig_Loader_Chain'
- )->withArgument($twigLoaderReferences);
-
- /**
- * Twig environment builder.
- */
- $this->expectRegistration(
- 'tubepress_app_impl_template_twig_EnvironmentBuilder' . $serviceSuffix,
- 'tubepress_app_impl_template_twig_EnvironmentBuilder'
- )->withArgument(new tubepress_platform_api_ioc_Reference('Twig_LoaderInterface' . $serviceSuffix))
- ->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_boot_BootSettingsInterface::_))
- ->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_app_api_options_ContextInterface::_))
- ->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_lib_api_translation_TranslatorInterface::_));
-
- /**
- * Twig environment.
- */
- $this->expectRegistration(
- 'Twig_Environment' . $serviceSuffix,
- 'Twig_Environment'
- )->withFactoryService('tubepress_app_impl_template_twig_EnvironmentBuilder' . $serviceSuffix)
- ->withFactoryMethod('buildTwigEnvironment');
-
- /**
- * Twig engine
- */
- $this->expectRegistration(
- 'tubepress_app_impl_template_twig_Engine' . $serviceSuffix,
- 'tubepress_app_impl_template_twig_Engine'
- )->withArgument(new tubepress_platform_api_ioc_Reference('Twig_Environment' . $serviceSuffix));
- }
-
- /**
- * Register PHP engine support
- */
- $this->expectRegistration(
- 'tubepress_app_impl_template_php_Support',
- 'tubepress_app_impl_template_php_Support'
- )->withArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_impl_template_ThemeTemplateLocator'));
-
- /**
- * Register the PHP templating engine
- */
- $this->expectRegistration(
- 'ehough_templating_PhpEngine',
- 'ehough_templating_PhpEngine'
- )->withArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_impl_template_php_Support'))
- ->withArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_impl_template_php_Support'));
-
- /**
- * Public templating engine
- */
- $engineReferences = array(
- new tubepress_platform_api_ioc_Reference('ehough_templating_PhpEngine'),
- new tubepress_platform_api_ioc_Reference('tubepress_app_impl_template_twig_Engine')
- );
- $this->expectRegistration(
- 'tubepress_app_impl_template_DelegatingEngine',
- 'tubepress_app_impl_template_DelegatingEngine'
- )->withArgument($engineReferences)
- ->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_log_LoggerInterface::_));
-
- /**
- * Final templating services
- */
- $this->expectRegistration(
- tubepress_lib_api_template_TemplatingInterface::_,
- 'tubepress_app_impl_template_TemplatingService'
- )->withArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_impl_template_DelegatingEngine'))
- ->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_lib_api_event_EventDispatcherInterface::_));
- $this->expectRegistration(
- tubepress_lib_api_template_TemplatingInterface::_ . '.admin',
- 'tubepress_app_impl_template_TemplatingService'
- )->withArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_impl_template_twig_Engine.admin'))
- ->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_lib_api_event_EventDispatcherInterface::_));
- }
-
private function _registerTheme()
{
$this->expectRegistration(
@@ -1380,7 +1256,8 @@ private function _registerVendorServices()
'tubepress_app_impl_vendor_stash_FilesystemCacheBuilder',
'tubepress_app_impl_vendor_stash_FilesystemCacheBuilder'
)->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_app_api_options_ContextInterface::_))
- ->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_boot_BootSettingsInterface::_));
+ ->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_boot_BootSettingsInterface::_))
+ ->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_log_LoggerInterface::_));
$this->expectRegistration(
diff --git a/tests/unit/add-ons/htmlcache/HtmlCacheManifestValidityTest.php b/tests/unit/add-ons/htmlcache/HtmlCacheManifestValidityTest.php
new file mode 100644
index 000000000..d859cc4fe
--- /dev/null
+++ b/tests/unit/add-ons/htmlcache/HtmlCacheManifestValidityTest.php
@@ -0,0 +1,32 @@
+getAddonFromManifest($this->getPathToManifest());
+
+ $this->assertEquals('tubepress/htmlcache', $addon->getName());
+ $this->assertEquals('99.99.99', $addon->getVersion());
+ $this->assertEquals('TubePress HTML Cache', $addon->getTitle());
+ $this->assertAuthors($addon, array(array('name' => 'TubePress LLC', 'url' => 'http://tubepress.com')));
+ $this->assertLicense($addon, array('type' => 'MPL-2.0', 'urls' => array('http://www.mozilla.org/MPL/2.0/')));
+ }
+
+ protected function getPathToManifest()
+ {
+ return TUBEPRESS_ROOT . '/src/add-ons/htmlcache/manifest.json';
+ }
+}
\ No newline at end of file
diff --git a/tests/unit/add-ons/htmlcache/classes/tubepress/test/htmlcache/impl/options/ui/FieldProviderTest.php b/tests/unit/add-ons/htmlcache/classes/tubepress/test/htmlcache/impl/options/ui/FieldProviderTest.php
new file mode 100644
index 000000000..1ad57703a
--- /dev/null
+++ b/tests/unit/add-ons/htmlcache/classes/tubepress/test/htmlcache/impl/options/ui/FieldProviderTest.php
@@ -0,0 +1,59 @@
+
+ */
+class tubepress_test_htmlcache_impl_options_ui_FieldProviderTest extends tubepress_test_TubePressUnitTest
+{
+ /**
+ * @var tubepress_jwplayer5_impl_options_ui_JwPlayerFieldProvider
+ */
+ private $_sut;
+
+ /**
+ * @var ehough_mockery_mockery_MockInterface[]
+ */
+ private $_mockFields;
+
+ /**
+ * @var ehough_mockery_mockery_MockInterface
+ */
+ private $_mockField;
+
+ public function onSetup()
+ {
+ $this->_mockField = $this->mock('tubepress_app_api_options_ui_FieldInterface');
+ $this->_mockFields = array($this->_mockField);
+
+ $this->_sut = new tubepress_htmlcache_impl_options_ui_FieldProvider(
+
+ $this->_mockFields,
+ array('foo' => 'bar')
+ );
+ }
+
+ public function testDefaults()
+ {
+ $map = array(
+
+ 'foo' => 'bar',
+ );
+
+ $this->assertEquals(array(), $this->_sut->getCategories());
+ $this->assertTrue($this->_sut->fieldsShouldBeInSeparateBoxes());
+ $this->assertFalse($this->_sut->isAbleToBeFilteredFromGui());
+ $this->assertEquals('HTML Cache', $this->_sut->getUntranslatedDisplayName());
+ $this->assertEquals($map, $this->_sut->getCategoryIdsToFieldIdsMap());
+ $this->assertEquals('field-provider-htmlcache', $this->_sut->getId());
+ $this->assertSame($this->_mockFields, $this->_sut->getFields());
+ }
+}
\ No newline at end of file
diff --git a/tests/unit/add-ons/htmlcache/classes/tubepress/test/htmlcache/ioc/HtmlCacheExtensionTest.php b/tests/unit/add-ons/htmlcache/classes/tubepress/test/htmlcache/ioc/HtmlCacheExtensionTest.php
new file mode 100644
index 000000000..56dc91a58
--- /dev/null
+++ b/tests/unit/add-ons/htmlcache/classes/tubepress/test/htmlcache/ioc/HtmlCacheExtensionTest.php
@@ -0,0 +1,175 @@
+
+ */
+class tubepress_test_htmlcache_ioc_HtmlCacheExtensionTest extends tubepress_test_platform_impl_ioc_AbstractContainerExtensionTest
+{
+ protected function buildSut()
+ {
+ return new tubepress_htmlcache_ioc_HtmlCacheExtension();
+ }
+
+ protected function prepareForLoad()
+ {
+ $this->_expectOptions();
+ $this->_expectOptionsUi();
+ }
+
+ private function _expectOptions()
+ {
+ $this->expectRegistration(
+ 'tubepress_app_api_options_Reference__htmlcache',
+ 'tubepress_app_api_options_Reference'
+ )->withTag(tubepress_app_api_options_ReferenceInterface::_)
+ ->withArgument(array(
+
+ tubepress_app_api_options_Reference::PROPERTY_DEFAULT_VALUE => array(
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_FACTOR => 100,
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_KEY => 'tubepress_clear_html_cache',
+ tubepress_app_api_options_Names::CACHE_HTML_DIRECTORY => null,
+ tubepress_app_api_options_Names::CACHE_HTML_ENABLED => false,
+ tubepress_app_api_options_Names::CACHE_HTML_LIFETIME_SECONDS => 21600, //six hours
+ ),
+
+ tubepress_app_api_options_Reference::PROPERTY_UNTRANSLATED_LABEL => array(
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_FACTOR => 'Cache cleaning factor', //>(translatable)<
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_KEY => 'Cache cleaning key', //>(translatable)<
+ tubepress_app_api_options_Names::CACHE_HTML_DIRECTORY => 'Cache directory', //>(translatable)<
+ tubepress_app_api_options_Names::CACHE_HTML_ENABLED => 'Enable HTML cache', //>(translatable)<
+ tubepress_app_api_options_Names::CACHE_HTML_LIFETIME_SECONDS => 'Cache expiration time (seconds)', //>(translatable)<
+ ),
+
+ tubepress_app_api_options_Reference::PROPERTY_UNTRANSLATED_DESCRIPTION => array(
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_FACTOR => 'If you enter X, the entire cache will be cleaned every 1/X cache writes. Enter 0 to disable cache cleaning.', //>(translatable)<
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_KEY => 'The name of the HTTP request parameter that, when set to true
, can remotely flush the cache. For instance, if you enter foobar
, then adding ?foobar=true
to the end of a URL would remotely trigger a clear of the cache.', //>(translatable)<
+ tubepress_app_api_options_Names::CACHE_HTML_DIRECTORY => 'Leave blank to attempt to use your system\'s temp directory. Otherwise enter the absolute path of a writeable directory.', //>(translatable)<
+ tubepress_app_api_options_Names::CACHE_HTML_ENABLED => 'Store TubePress\'s HTML output in a cache file to significantly improve performance at the slight expense of freshness.', //>(translatable)<
+ tubepress_app_api_options_Names::CACHE_HTML_LIFETIME_SECONDS => 'Cache entries will be considered stale after the specified number of seconds. Default is 21600 (six hours).', //>(translatable)<
+ ),
+ ))->withArgument(array(
+
+ tubepress_app_api_options_Reference::PROPERTY_PRO_ONLY => array(
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_FACTOR,
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_KEY,
+ tubepress_app_api_options_Names::CACHE_HTML_DIRECTORY,
+ tubepress_app_api_options_Names::CACHE_HTML_ENABLED,
+ tubepress_app_api_options_Names::CACHE_HTML_LIFETIME_SECONDS,
+ ),
+ ));
+
+ $toValidate = array(
+ tubepress_app_api_listeners_options_RegexValidatingListener::TYPE_INTEGER_POSITIVE => array(
+ tubepress_app_api_options_Names::CACHE_HTML_LIFETIME_SECONDS,
+ ),
+ tubepress_app_api_listeners_options_RegexValidatingListener::TYPE_INTEGER_NONNEGATIVE => array(
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_FACTOR,
+ ),
+ tubepress_app_api_listeners_options_RegexValidatingListener::TYPE_ONE_OR_MORE_WORDCHARS_OR_HYPHEN => array(
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_KEY
+ ),
+ );
+
+ foreach ($toValidate as $type => $optionNames) {
+ foreach ($optionNames as $optionName) {
+ $this->expectRegistration(
+ 'regex_validator.' . $optionName,
+ 'tubepress_app_api_listeners_options_RegexValidatingListener'
+ )->withArgument($type)
+ ->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_app_api_options_ReferenceInterface::_))
+ ->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_lib_api_translation_TranslatorInterface::_))
+ ->withTag(tubepress_lib_api_ioc_ServiceTags::EVENT_LISTENER, array(
+ 'event' => tubepress_app_api_event_Events::OPTION_SET . ".$optionName",
+ 'priority' => 100000,
+ 'method' => 'onOption',
+ ));
+ }
+ }
+ }
+
+ private function _expectOptionsUi()
+ {
+ $fieldReferences = array();
+ $fieldMap = array(
+ 'boolean' => array(
+ tubepress_app_api_options_Names::CACHE_HTML_ENABLED,
+ ),
+ 'text' => array(
+ tubepress_app_api_options_Names::CACHE_HTML_DIRECTORY,
+ tubepress_app_api_options_Names::CACHE_HTML_LIFETIME_SECONDS,
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_FACTOR,
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_KEY,
+ ),
+ );
+ foreach ($fieldMap as $type => $ids) {
+ foreach ($ids as $id) {
+
+ $serviceId = 'htmlcache_field_' . $id;
+
+ $this->expectRegistration(
+ $serviceId,
+ 'tubepress_app_api_options_ui_FieldInterface'
+ )->withFactoryService(tubepress_app_api_options_ui_FieldBuilderInterface::_)
+ ->withFactoryMethod('newInstance')
+ ->withArgument($id)
+ ->withArgument($type);
+
+ $fieldReferences[] = new tubepress_platform_api_ioc_Reference($serviceId);
+ }
+ }
+
+ $fieldMap = array(
+ tubepress_app_api_options_ui_CategoryNames::CACHE => array(
+ tubepress_app_api_options_Names::CACHE_HTML_ENABLED,
+ tubepress_app_api_options_Names::CACHE_HTML_DIRECTORY,
+ tubepress_app_api_options_Names::CACHE_HTML_LIFETIME_SECONDS,
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_FACTOR,
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_KEY,
+ ),
+ );
+
+ $this->expectRegistration(
+ 'tubepress_htmlcache_impl_options_ui_FieldProvider',
+ 'tubepress_htmlcache_impl_options_ui_FieldProvider'
+ )->withArgument($fieldReferences)
+ ->withArgument($fieldMap)
+ ->withTag('tubepress_app_api_options_ui_FieldProviderInterface');
+ }
+
+ protected function getExpectedExternalServicesMap()
+ {
+ $textFieldOptionNames = array(
+
+ tubepress_app_api_options_Names::CACHE_HTML_DIRECTORY,
+ tubepress_app_api_options_Names::CACHE_HTML_LIFETIME_SECONDS,
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_FACTOR,
+ tubepress_app_api_options_Names::CACHE_HTML_CLEANING_KEY,
+ );
+
+ $mockFieldBuilder = $this->mock(tubepress_app_api_options_ui_FieldBuilderInterface::_);
+
+ foreach ($textFieldOptionNames as $textOptionName) {
+
+ $textField = $this->mock('tubepress_app_api_options_ui_FieldInterface');
+ $mockFieldBuilder->shouldReceive('newInstance')->once()->with($textOptionName, 'text')->andReturn($textField);
+ }
+
+ $booleanField = $this->mock('tubepress_app_api_options_ui_FieldInterface');
+ $mockFieldBuilder->shouldReceive('newInstance')->once()->with(tubepress_app_api_options_Names::CACHE_HTML_ENABLED, 'boolean')->andReturn($booleanField);
+
+ return array(
+ tubepress_app_api_options_ReferenceInterface::_ => tubepress_app_api_options_ReferenceInterface::_,
+ tubepress_app_api_options_ui_FieldBuilderInterface::_ => $mockFieldBuilder,
+ tubepress_lib_api_translation_TranslatorInterface::_ => tubepress_lib_api_translation_TranslatorInterface::_
+ );
+ }
+}
\ No newline at end of file
diff --git a/tests/unit/add-ons/template/TemplateManifestValidityTest.php b/tests/unit/add-ons/template/TemplateManifestValidityTest.php
new file mode 100644
index 000000000..892f20261
--- /dev/null
+++ b/tests/unit/add-ons/template/TemplateManifestValidityTest.php
@@ -0,0 +1,33 @@
+getAddonFromManifest($this->getPathToManifest());
+
+ $this->assertEquals('tubepress/template', $addon->getName());
+ $this->assertEquals('99.99.99', $addon->getVersion());
+ $this->assertEquals('TubePress Template Functionality', $addon->getTitle());
+ $this->assertAuthors($addon, array(array('name' => 'TubePress LLC', 'url' => 'http://tubepress.com')));
+ $this->assertLicense($addon, array('type' => 'MPL-2.0', 'urls' => array('http://www.mozilla.org/MPL/2.0/')));
+ }
+
+ protected function getPathToManifest()
+ {
+ return TUBEPRESS_ROOT . '/src/add-ons/template/manifest.json';
+ }
+
+}
\ No newline at end of file
diff --git a/tests/unit/add-ons/core/classes/tubepress/test/app/impl/template/TemplatingServiceTest.php b/tests/unit/add-ons/template/classes/tubepress/test/app/template/impl/TemplatingServiceTest.php
similarity index 95%
rename from tests/unit/add-ons/core/classes/tubepress/test/app/impl/template/TemplatingServiceTest.php
rename to tests/unit/add-ons/template/classes/tubepress/test/app/template/impl/TemplatingServiceTest.php
index 426871252..5690e5710 100644
--- a/tests/unit/add-ons/core/classes/tubepress/test/app/impl/template/TemplatingServiceTest.php
+++ b/tests/unit/add-ons/template/classes/tubepress/test/app/template/impl/TemplatingServiceTest.php
@@ -10,12 +10,12 @@
*/
/**
- * @covers tubepress_app_impl_template_TemplatingService
+ * @covers tubepress_app_template_impl_TemplatingService
*/
class tubepress_test_app_impl_template_TemplatingServiceTest extends tubepress_test_TubePressUnitTest
{
/**
- * @var tubepress_app_impl_template_TemplatingService
+ * @var tubepress_app_template_impl_TemplatingService
*/
private $_sut;
@@ -34,7 +34,7 @@ public function onSetup()
$this->_mockDelegateEngine = $this->mock('ehough_templating_EngineInterface');
$this->_mockEventDispatcher = $this->mock(tubepress_lib_api_event_EventDispatcherInterface::_);
- $this->_sut = new tubepress_app_impl_template_TemplatingService(
+ $this->_sut = new tubepress_app_template_impl_TemplatingService(
$this->_mockDelegateEngine,
$this->_mockEventDispatcher
diff --git a/tests/unit/add-ons/core/classes/tubepress/test/app/impl/template/ThemeTemplateLocatorTest.php b/tests/unit/add-ons/template/classes/tubepress/test/app/template/impl/ThemeTemplateLocatorTest.php
similarity index 97%
rename from tests/unit/add-ons/core/classes/tubepress/test/app/impl/template/ThemeTemplateLocatorTest.php
rename to tests/unit/add-ons/template/classes/tubepress/test/app/template/impl/ThemeTemplateLocatorTest.php
index 800f7d3a4..53abdad52 100644
--- a/tests/unit/add-ons/core/classes/tubepress/test/app/impl/template/ThemeTemplateLocatorTest.php
+++ b/tests/unit/add-ons/template/classes/tubepress/test/app/template/impl/ThemeTemplateLocatorTest.php
@@ -10,12 +10,12 @@
*/
/**
- * @covers tubepress_app_impl_template_ThemeTemplateLocator
+ * @covers tubepress_app_template_impl_ThemeTemplateLocator
*/
class tubepress_test_app_impl_template_ThemeTemplateLocatorTest extends tubepress_test_TubePressUnitTest
{
/**
- * @var tubepress_app_impl_template_ThemeTemplateLocator
+ * @var tubepress_app_template_impl_ThemeTemplateLocator
*/
private $_sut;
@@ -61,7 +61,7 @@ public function onSetup()
$this->_mockLogger->shouldReceive('isEnabled')->once()->andReturn(true);
$this->_mockLogger->shouldReceive('debug')->atLeast(1);
- $this->_sut = new tubepress_app_impl_template_ThemeTemplateLocator(
+ $this->_sut = new tubepress_app_template_impl_ThemeTemplateLocator(
$this->_mockLogger,
$this->_mockContext,
diff --git a/tests/unit/add-ons/core/classes/tubepress/test/app/impl/template/php/SupportTest.php b/tests/unit/add-ons/template/classes/tubepress/test/app/template/impl/php/SupportTest.php
similarity index 91%
rename from tests/unit/add-ons/core/classes/tubepress/test/app/impl/template/php/SupportTest.php
rename to tests/unit/add-ons/template/classes/tubepress/test/app/template/impl/php/SupportTest.php
index 9028f86a3..9c41ca4a7 100644
--- a/tests/unit/add-ons/core/classes/tubepress/test/app/impl/template/php/SupportTest.php
+++ b/tests/unit/add-ons/template/classes/tubepress/test/app/template/impl/php/SupportTest.php
@@ -10,12 +10,12 @@
*/
/**
- * @covers tubepress_app_impl_template_php_Support
+ * @covers tubepress_app_template_impl_php_Support
*/
class tubepress_test_app_impl_template_php_SupportTest extends tubepress_test_TubePressUnitTest
{
/**
- * @var tubepress_app_impl_template_php_Support
+ * @var tubepress_app_template_impl_php_Support
*/
private $_sut;
@@ -31,10 +31,10 @@ class tubepress_test_app_impl_template_php_SupportTest extends tubepress_test_Tu
public function onSetup()
{
- $this->_mockThemeTemplateLocator = $this->mock('tubepress_app_impl_template_ThemeTemplateLocator');
+ $this->_mockThemeTemplateLocator = $this->mock('tubepress_app_template_impl_ThemeTemplateLocator');
$this->_mockTemplateReference = $this->mock('ehough_templating_TemplateReferenceInterface');
- $this->_sut = new tubepress_app_impl_template_php_Support($this->_mockThemeTemplateLocator);
+ $this->_sut = new tubepress_app_template_impl_php_Support($this->_mockThemeTemplateLocator);
}
public function testIsFresh()
diff --git a/tests/unit/add-ons/core/classes/tubepress/test/app/impl/template/twig/EngineTest.php b/tests/unit/add-ons/template/classes/tubepress/test/app/template/impl/twig/EngineTest.php
similarity index 93%
rename from tests/unit/add-ons/core/classes/tubepress/test/app/impl/template/twig/EngineTest.php
rename to tests/unit/add-ons/template/classes/tubepress/test/app/template/impl/twig/EngineTest.php
index 77a19c693..d0da7fc58 100644
--- a/tests/unit/add-ons/core/classes/tubepress/test/app/impl/template/twig/EngineTest.php
+++ b/tests/unit/add-ons/template/classes/tubepress/test/app/template/impl/twig/EngineTest.php
@@ -10,12 +10,12 @@
*/
/**
- * @covers tubepress_app_impl_template_twig_Engine
+ * @covers tubepress_app_template_impl_twig_Engine
*/
class tubepress_test_app_impl_template_twig_EngineTest extends tubepress_test_TubePressUnitTest
{
/**
- * @var tubepress_app_impl_template_twig_Engine
+ * @var tubepress_app_template_impl_twig_Engine
*/
private $_sut;
@@ -34,7 +34,7 @@ public function onSetup()
$this->_mockTwigEnvironment = $this->mock('Twig_Environment');
$this->_mockTwigLoader = $this->mock('Twig_LoaderInterface');
- $this->_sut = new tubepress_app_impl_template_twig_Engine($this->_mockTwigEnvironment);
+ $this->_sut = new tubepress_app_template_impl_twig_Engine($this->_mockTwigEnvironment);
}
public function testRenderNotExists()
diff --git a/tests/unit/add-ons/core/classes/tubepress/test/app/impl/template/twig/EnvironmentBuilderTest.php b/tests/unit/add-ons/template/classes/tubepress/test/app/template/impl/twig/EnvironmentBuilderTest.php
similarity index 92%
rename from tests/unit/add-ons/core/classes/tubepress/test/app/impl/template/twig/EnvironmentBuilderTest.php
rename to tests/unit/add-ons/template/classes/tubepress/test/app/template/impl/twig/EnvironmentBuilderTest.php
index fbe22ddaa..196ae546c 100644
--- a/tests/unit/add-ons/core/classes/tubepress/test/app/impl/template/twig/EnvironmentBuilderTest.php
+++ b/tests/unit/add-ons/template/classes/tubepress/test/app/template/impl/twig/EnvironmentBuilderTest.php
@@ -10,12 +10,12 @@
*/
/**
- * @covers tubepress_app_impl_template_twig_EnvironmentBuilder
+ * @covers tubepress_app_template_impl_twig_EnvironmentBuilder
*/
class tubepress_test_app_impl_template_twig_EnvironmentBuilderTest extends tubepress_test_TubePressUnitTest
{
/**
- * @var tubepress_app_impl_template_twig_EnvironmentBuilder
+ * @var tubepress_app_template_impl_twig_EnvironmentBuilder
*/
private $_sut;
@@ -54,7 +54,7 @@ public function onSetup()
$this->_mockSystemCacheDir = sys_get_temp_dir() . '/environment-builder-test';
mkdir($this->_mockSystemCacheDir, 0755, true);
- $this->_sut = new tubepress_app_impl_template_twig_EnvironmentBuilder(
+ $this->_sut = new tubepress_app_template_impl_twig_EnvironmentBuilder(
$this->_mockTwigLoader,
$this->_mockBootSettings,
$this->_mockContext,
diff --git a/tests/unit/add-ons/core/classes/tubepress/test/app/impl/template/twig/LoaderTest.php b/tests/unit/add-ons/template/classes/tubepress/test/app/template/impl/twig/LoaderTest.php
similarity index 91%
rename from tests/unit/add-ons/core/classes/tubepress/test/app/impl/template/twig/LoaderTest.php
rename to tests/unit/add-ons/template/classes/tubepress/test/app/template/impl/twig/LoaderTest.php
index d78629a28..88d019838 100644
--- a/tests/unit/add-ons/core/classes/tubepress/test/app/impl/template/twig/LoaderTest.php
+++ b/tests/unit/add-ons/template/classes/tubepress/test/app/template/impl/twig/LoaderTest.php
@@ -10,12 +10,12 @@
*/
/**
- * @covers tubepress_app_impl_template_twig_ThemeLoader
+ * @covers tubepress_app_template_impl_twig_ThemeLoader
*/
class tubepress_test_app_impl_template_twig_LoaderTest extends tubepress_test_TubePressUnitTest
{
/**
- * @var tubepress_app_impl_template_twig_ThemeLoader
+ * @var tubepress_app_template_impl_twig_ThemeLoader
*/
private $_sut;
@@ -26,9 +26,9 @@ class tubepress_test_app_impl_template_twig_LoaderTest extends tubepress_test_Tu
public function onSetup()
{
- $this->_mockThemeTemplateLocator = $this->mock('tubepress_app_impl_template_ThemeTemplateLocator');
+ $this->_mockThemeTemplateLocator = $this->mock('tubepress_app_template_impl_ThemeTemplateLocator');
- $this->_sut = new tubepress_app_impl_template_twig_ThemeLoader($this->_mockThemeTemplateLocator);
+ $this->_sut = new tubepress_app_template_impl_twig_ThemeLoader($this->_mockThemeTemplateLocator);
}
/**
diff --git a/tests/unit/add-ons/template/classes/tubepress/test/app/template/ioc/TemplateExtensionTest.php b/tests/unit/add-ons/template/classes/tubepress/test/app/template/ioc/TemplateExtensionTest.php
new file mode 100644
index 000000000..de753a35b
--- /dev/null
+++ b/tests/unit/add-ons/template/classes/tubepress/test/app/template/ioc/TemplateExtensionTest.php
@@ -0,0 +1,271 @@
+
+ */
+class tubepress_test_app_template_ioc_TemplateExtensionTest extends tubepress_test_platform_impl_ioc_AbstractContainerExtensionTest
+{
+ protected function buildSut()
+ {
+ return new tubepress_app_template_ioc_TemplateExtension();
+ }
+
+ protected function prepareForLoad()
+ {
+ $this->_expectOptions();
+ $this->_expectOptionsUi();
+ $this->_expectTemplateService();
+ }
+
+ private function _expectOptions()
+ {
+ $this->expectRegistration(
+ 'tubepress_app_api_options_Reference__template',
+ 'tubepress_app_api_options_Reference'
+ )->withTag(tubepress_app_api_options_ReferenceInterface::_)
+ ->withArgument(array(
+
+ tubepress_app_api_options_Reference::PROPERTY_DEFAULT_VALUE => array(
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_AUTORELOAD => false,
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_DIR => null,
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_ENABLED => true,
+ ),
+
+ tubepress_app_api_options_Reference::PROPERTY_UNTRANSLATED_LABEL => array(
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_AUTORELOAD => 'Monitor templates for changes', //>(translatable)<
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_DIR => 'Template cache directory', //>(translatable)<
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_ENABLED => 'Enable template cache', //>(translatable)<
+
+ ),
+
+ tubepress_app_api_options_Reference::PROPERTY_UNTRANSLATED_DESCRIPTION => array(
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_AUTORELOAD => 'Automatically recompile templates when they are changed. Turning on the monitor is very useful if you are developing custom templates, but doing so also incurs a performance penalty. If you are unsure, leave this disabled.', //>(translatable)<
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_DIR => 'Leave blank to attempt to use your system\'s temp directory. Otherwise enter the absolute path of a writeable directory where TubePress can store cached templates.', //>(translatable)<
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_ENABLED => 'Compile and cache Twig templates to pure PHP for maximum performance. Most users should leave this enabled.', //>(translatable)<
+ ),
+ ));
+ }
+
+ private function _expectOptionsUi()
+ {
+ $fieldReferences = array();
+ $fieldMap = array(
+ 'boolean' => array(
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_AUTORELOAD,
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_ENABLED,
+ ),
+ 'text' => array(
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_DIR,
+ ),
+ );
+ foreach ($fieldMap as $type => $ids) {
+ foreach ($ids as $id) {
+
+ $serviceId = 'template_field_' . $id;
+
+ $this->expectRegistration(
+ $serviceId,
+ 'tubepress_app_api_options_ui_FieldInterface'
+ )->withFactoryService(tubepress_app_api_options_ui_FieldBuilderInterface::_)
+ ->withFactoryMethod('newInstance')
+ ->withArgument($id)
+ ->withArgument($type);
+
+ $fieldReferences[] = new tubepress_platform_api_ioc_Reference($serviceId);
+ }
+ }
+
+ $fieldMap = array(
+ tubepress_app_api_options_ui_CategoryNames::CACHE => array(
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_ENABLED,
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_DIR,
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_AUTORELOAD,
+ ),
+
+ );
+
+ $this->expectRegistration(
+ 'tubepress_app_template_impl_options_ui_FieldProvider',
+ 'tubepress_app_template_impl_options_ui_FieldProvider'
+ )->withArgument($fieldReferences)
+ ->withArgument($fieldMap)
+ ->withTag('tubepress_app_api_options_ui_FieldProviderInterface');
+ }
+
+ private function _expectTemplateService()
+ {
+ $parallelServices = array(
+ '' => 'public',
+ '.admin' => 'admin'
+ );
+
+ foreach ($parallelServices as $serviceSuffix => $templatePath) {
+
+ /**
+ * Theme template locators.
+ */
+ $this->expectRegistration(
+ 'tubepress_app_template_impl_ThemeTemplateLocator' . $serviceSuffix,
+ 'tubepress_app_template_impl_ThemeTemplateLocator'
+ )->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_log_LoggerInterface::_))
+ ->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_app_api_options_ContextInterface::_))
+ ->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_contrib_RegistryInterface::_ . '.' . tubepress_app_api_theme_ThemeInterface::_ . $serviceSuffix))
+ ->withArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_impl_theme_CurrentThemeService' . $serviceSuffix));
+
+ /**
+ * Twig loaders.
+ */
+ $this->expectRegistration(
+ 'tubepress_app_template_impl_twig_ThemeLoader' . $serviceSuffix,
+ 'tubepress_app_template_impl_twig_ThemeLoader'
+ )->withArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_template_impl_ThemeTemplateLocator' . $serviceSuffix));
+
+ $this->expectRegistration(
+ 'Twig_Loader_Filesystem' . $serviceSuffix,
+ 'tubepress_app_template_impl_twig_FsLoader'
+ )->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_log_LoggerInterface::_))
+ ->withArgument(array(
+ TUBEPRESS_ROOT . '/src/add-ons/core/templates/' . $templatePath,
+ ));
+
+ $twigLoaderReferences = array(
+ new tubepress_platform_api_ioc_Reference('tubepress_app_template_impl_twig_ThemeLoader' . $serviceSuffix),
+ new tubepress_platform_api_ioc_Reference('Twig_Loader_Filesystem' . $serviceSuffix)
+ );
+ $this->expectRegistration(
+ 'Twig_LoaderInterface' . $serviceSuffix,
+ 'Twig_Loader_Chain'
+ )->withArgument($twigLoaderReferences);
+
+ /**
+ * Twig environment builder.
+ */
+ $this->expectRegistration(
+ 'tubepress_app_template_impl_twig_EnvironmentBuilder' . $serviceSuffix,
+ 'tubepress_app_template_impl_twig_EnvironmentBuilder'
+ )->withArgument(new tubepress_platform_api_ioc_Reference('Twig_LoaderInterface' . $serviceSuffix))
+ ->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_boot_BootSettingsInterface::_))
+ ->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_app_api_options_ContextInterface::_))
+ ->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_lib_api_translation_TranslatorInterface::_));
+
+ /**
+ * Twig environment.
+ */
+ $this->expectRegistration(
+ 'Twig_Environment' . $serviceSuffix,
+ 'Twig_Environment'
+ )->withFactoryService('tubepress_app_template_impl_twig_EnvironmentBuilder' . $serviceSuffix)
+ ->withFactoryMethod('buildTwigEnvironment');
+
+ /**
+ * Twig engine
+ */
+ $this->expectRegistration(
+ 'tubepress_app_template_impl_twig_Engine' . $serviceSuffix,
+ 'tubepress_app_template_impl_twig_Engine'
+ )->withArgument(new tubepress_platform_api_ioc_Reference('Twig_Environment' . $serviceSuffix));
+ }
+
+ /**
+ * Register PHP engine support
+ */
+ $this->expectRegistration(
+ 'tubepress_app_template_impl_php_Support',
+ 'tubepress_app_template_impl_php_Support'
+ )->withArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_template_impl_ThemeTemplateLocator'));
+
+ /**
+ * Register the PHP templating engine
+ */
+ $this->expectRegistration(
+ 'ehough_templating_PhpEngine',
+ 'ehough_templating_PhpEngine'
+ )->withArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_template_impl_php_Support'))
+ ->withArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_template_impl_php_Support'));
+
+ /**
+ * Public templating engine
+ */
+ $engineReferences = array(
+ new tubepress_platform_api_ioc_Reference('ehough_templating_PhpEngine'),
+ new tubepress_platform_api_ioc_Reference('tubepress_app_template_impl_twig_Engine')
+ );
+ $this->expectRegistration(
+ 'tubepress_app_template_impl_DelegatingEngine',
+ 'tubepress_app_template_impl_DelegatingEngine'
+ )->withArgument($engineReferences)
+ ->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_platform_api_log_LoggerInterface::_));
+
+ /**
+ * Final templating services
+ */
+ $this->expectRegistration(
+ tubepress_lib_api_template_TemplatingInterface::_,
+ 'tubepress_app_template_impl_TemplatingService'
+ )->withArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_template_impl_DelegatingEngine'))
+ ->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_lib_api_event_EventDispatcherInterface::_));
+ $this->expectRegistration(
+ tubepress_lib_api_template_TemplatingInterface::_ . '.admin',
+ 'tubepress_app_template_impl_TemplatingService'
+ )->withArgument(new tubepress_platform_api_ioc_Reference('tubepress_app_template_impl_twig_Engine.admin'))
+ ->withArgument(new tubepress_platform_api_ioc_Reference(tubepress_lib_api_event_EventDispatcherInterface::_));
+ }
+
+ protected function getExpectedExternalServicesMap()
+ {
+ $fieldBuilder = $this->mock(tubepress_app_api_options_ui_FieldBuilderInterface::_);
+
+ $text = array(
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_DIR
+ );
+ $bool = array(
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_ENABLED,
+ tubepress_app_api_options_Names::TEMPLATE_CACHE_AUTORELOAD
+ );
+
+ foreach ($text as $color) {
+
+ $mockSpectrumField = $this->mock('tubepress_app_api_options_ui_FieldInterface');
+ $fieldBuilder->shouldReceive('newInstance')->once()->with($color, 'text')->andReturn($mockSpectrumField);
+ }
+ foreach ($bool as $color) {
+
+ $mockSpectrumField = $this->mock('tubepress_app_api_options_ui_FieldInterface');
+ $fieldBuilder->shouldReceive('newInstance')->once()->with($color, 'boolean')->andReturn($mockSpectrumField);
+ }
+
+ $logger = $this->mock(tubepress_platform_api_log_LoggerInterface::_);
+ $logger->shouldReceive('isEnabled')->atLeast(1)->andReturn(true);
+
+ $context = $this->mock(tubepress_app_api_options_ContextInterface::_);
+ $context->shouldReceive('get')->twice()->with(tubepress_app_api_options_Names::TEMPLATE_CACHE_DIR)->andReturnNull();
+ $context->shouldReceive('get')->twice()->with(tubepress_app_api_options_Names::TEMPLATE_CACHE_ENABLED)->andReturn(true);
+ $context->shouldReceive('get')->twice()->with(tubepress_app_api_options_Names::TEMPLATE_CACHE_AUTORELOAD)->andReturn(true);
+
+ $bootSettings = $this->mock(tubepress_platform_api_boot_BootSettingsInterface::_);
+ $bootSettings->shouldReceive('getPathToSystemCacheDirectory')->twice()->andReturn(sys_get_temp_dir());
+
+ return array(
+
+ tubepress_platform_api_log_LoggerInterface::_ => $logger,
+ tubepress_app_api_options_ContextInterface::_ => $context,
+ tubepress_platform_api_contrib_RegistryInterface::_ . '.' . tubepress_app_api_theme_ThemeInterface::_ => tubepress_platform_api_contrib_RegistryInterface::_,
+ tubepress_platform_api_contrib_RegistryInterface::_ . '.' . tubepress_app_api_theme_ThemeInterface::_ . '.admin' => tubepress_platform_api_contrib_RegistryInterface::_,
+ 'tubepress_app_impl_theme_CurrentThemeService' => 'tubepress_app_impl_theme_CurrentThemeService',
+ 'tubepress_app_impl_theme_CurrentThemeService.admin' => 'tubepress_app_impl_theme_CurrentThemeService',
+ tubepress_platform_api_boot_BootSettingsInterface::_ => $bootSettings,
+ tubepress_lib_api_translation_TranslatorInterface::_ => tubepress_lib_api_translation_TranslatorInterface::_,
+ tubepress_lib_api_event_EventDispatcherInterface::_ => tubepress_lib_api_event_EventDispatcherInterface::_,
+ tubepress_app_api_options_ui_FieldBuilderInterface::_ => $fieldBuilder,
+ );
+ }
+}
\ No newline at end of file
diff --git a/tests/unit/add-ons/core/classes/tubepress/test/lib/ioc/compiler/TemplatePathProvidersPassTest.php b/tests/unit/add-ons/template/classes/tubepress/test/app/template/ioc/compiler/TemplatePathProvidersPassTest.php
similarity index 88%
rename from tests/unit/add-ons/core/classes/tubepress/test/lib/ioc/compiler/TemplatePathProvidersPassTest.php
rename to tests/unit/add-ons/template/classes/tubepress/test/app/template/ioc/compiler/TemplatePathProvidersPassTest.php
index 5ab70609f..ebd6c55cc 100644
--- a/tests/unit/add-ons/core/classes/tubepress/test/lib/ioc/compiler/TemplatePathProvidersPassTest.php
+++ b/tests/unit/add-ons/template/classes/tubepress/test/app/template/ioc/compiler/TemplatePathProvidersPassTest.php
@@ -10,12 +10,12 @@
*/
/**
- * @covers tubepress_lib_ioc_compiler_TemplatePathProvidersPass
+ * @covers tubepress_app_template_ioc_compiler_TemplatePathProvidersPass
*/
-class tubepress_test_lib_ioc_compiler_TemplatePathProvidersPassTest extends tubepress_test_TubePressUnitTest
+class tubepress_test_app_template_ioc_compiler_TemplatePathProvidersPassTest extends tubepress_test_TubePressUnitTest
{
/**
- * @var tubepress_lib_ioc_compiler_TemplatePathProvidersPass
+ * @var tubepress_app_template_ioc_compiler_TemplatePathProvidersPass
*/
private $_sut;
@@ -31,7 +31,7 @@ class tubepress_test_lib_ioc_compiler_TemplatePathProvidersPassTest extends tube
public function onSetup()
{
- $this->_sut = new tubepress_lib_ioc_compiler_TemplatePathProvidersPass();
+ $this->_sut = new tubepress_app_template_ioc_compiler_TemplatePathProvidersPass();
$this->_mockContainer = $this->mock('tubepress_platform_api_ioc_ContainerBuilderInterface');
$this->_mockTwigFsLoaderDefinition = $this->mock('tubepress_platform_api_ioc_Definition');
}