NextGEN Gallery – WordPress Gallery Plugin - Version 2.1.50

Version Description

  • 08.30-2016 =
  • NEW: Added the ability to open galleries within albums using a lightbox
  • Changed: Increased freemius opt-in to 100%
  • Changed: Tamara Lackey's biography on the overview page
  • Fixed: Images not responsive for all display types
  • Fixed: Compatibility with the Imagely Lightroom plugin
  • Fixed: Removed Pope tests folder
  • Fixed: Maximum function nesting level fatal error when displaying two or more albums
  • Fixed: Ensure Insert Gallery Window background stays white
  • Fixed: PHP warning for C_NGG_Lightbox class using incompatible constructor
Download this release

Release Info

Developer photocrati
Plugin Icon 128x128 NextGEN Gallery – WordPress Gallery Plugin
Version 2.1.50
Comparing to
See all releases

Code changes from version 2.1.49 to 2.1.50

Files changed (53) hide show
  1. changelog.txt +11 -0
  2. nggallery.php +6 -4
  3. pope/run_tests.php +0 -24
  4. pope/tests/advanced.php +0 -102
  5. pope/tests/core.php +0 -227
  6. pope/tests/factories.php +0 -209
  7. pope/tests/method_properties.php +0 -175
  8. pope/tests/modules.php +0 -30
  9. pope/tests/post_hooks.php +0 -165
  10. pope/tests/pre_hooks.php +0 -197
  11. pope/tests/products/photocrati_animal/pope_modules/animal_farm/adapter.animal_cow.php +0 -9
  12. pope/tests/products/photocrati_animal/pope_modules/animal_farm/adapter.animal_dog.php +0 -9
  13. pope/tests/products/photocrati_animal/pope_modules/animal_farm/adapter.animal_factory.php +0 -9
  14. pope/tests/products/photocrati_animal/pope_modules/animal_farm/class.animal_empty.php +0 -5
  15. pope/tests/products/photocrati_animal/pope_modules/animal_farm/class.animal_library.php +0 -19
  16. pope/tests/products/photocrati_animal/pope_modules/animal_farm/interface.animal_library.php +0 -6
  17. pope/tests/products/photocrati_animal/pope_modules/animal_farm/module.animal_farm.php +0 -39
  18. pope/tests/products/photocrati_animal/product.photocrati_animal.php +0 -31
  19. pope/tests/products/photocrati_pope/modules/template/adapter.template_alternate.php +0 -9
  20. pope/tests/products/photocrati_pope/modules/template/adapter.template_factory.php +0 -9
  21. pope/tests/products/photocrati_pope/modules/template/adapter.template_normal.php +0 -9
  22. pope/tests/products/photocrati_pope/modules/template/class.template_library.php +0 -19
  23. pope/tests/products/photocrati_pope/modules/template/interface.template_library.php +0 -6
  24. pope/tests/products/photocrati_pope/modules/template/module.template.php +0 -54
  25. pope/tests/products/photocrati_pope/product.photocrati_pope.php +0 -35
  26. pope/tests/registry.php +0 -454
  27. pope/tests/wrappers.php +0 -106
  28. products/photocrati_nextgen/modules/attach_to_post/module.attach_to_post.php +1 -1
  29. products/photocrati_nextgen/modules/attach_to_post/static/iframely.css +1 -0
  30. products/photocrati_nextgen/modules/attach_to_post/static/iframely.min.css +1 -1
  31. products/photocrati_nextgen/modules/datamapper/module.datamapper.php +1 -1
  32. products/photocrati_nextgen/modules/datamapper/package.module.datamapper.php +28 -25
  33. products/photocrati_nextgen/modules/lightbox/module.lightbox.php +3 -2
  34. products/photocrati_nextgen/modules/lightbox/package.module.lightbox.php +50 -19
  35. products/photocrati_nextgen/modules/nextgen_basic_album/module.nextgen_basic_album.php +1 -1
  36. products/photocrati_nextgen/modules/nextgen_basic_album/package.module.nextgen_basic_album.php +28 -0
  37. products/photocrati_nextgen/modules/nextgen_basic_album/templates/compact.php +24 -5
  38. products/photocrati_nextgen/modules/nextgen_basic_album/templates/extended.php +27 -1
  39. products/photocrati_nextgen/modules/nextgen_basic_gallery/module.nextgen_basic_gallery.php +1 -1
  40. products/photocrati_nextgen/modules/nextgen_basic_gallery/static/thumbnails/nextgen_basic_thumbnails.css +21 -6
  41. products/photocrati_nextgen/modules/nextgen_basic_gallery/static/thumbnails/nextgen_basic_thumbnails.min.css +1 -1
  42. products/photocrati_nextgen/modules/nextgen_basic_gallery/templates/thumbnails/index.php +1 -1
  43. products/photocrati_nextgen/modules/nextgen_data/module.nextgen_data.php +1 -1
  44. products/photocrati_nextgen/modules/nextgen_data/package.module.nextgen_data.php +3 -1
  45. products/photocrati_nextgen/modules/nextgen_gallery_display/module.nextgen_gallery_display.php +1 -1
  46. products/photocrati_nextgen/modules/nextgen_gallery_display/package.module.nextgen_gallery_display.php +28 -6
  47. products/photocrati_nextgen/modules/nextgen_xmlrpc/module.nextgen_xmlrpc.php +1 -1
  48. products/photocrati_nextgen/modules/nextgen_xmlrpc/package.module.nextgen_xmlrpc.php +1 -1
  49. products/photocrati_nextgen/modules/ngglegacy/admin/overview.php +2 -2
  50. products/photocrati_nextgen/modules/ngglegacy/module.ngglegacy.php +1 -1
  51. products/photocrati_nextgen/modules/wordpress_routing/module.wordpress_routing.php +1 -1
  52. products/photocrati_nextgen/modules/wordpress_routing/package.module.wordpress_routing.php +5 -1
  53. readme.txt +12 -1
changelog.txt CHANGED
@@ -1,6 +1,17 @@
1
  NextGEN Gallery
2
  by Imagely
3
 
 
 
 
 
 
 
 
 
 
 
 
4
  = V2.1.49 - 07.26.2016 =
5
  * NEW: Add a "Default" template option to override ATP settings when a global setting is used
6
  * NEW: Added "generic" error reporting back during image upload.
1
  NextGEN Gallery
2
  by Imagely
3
 
4
+ = V2.1.50 - 08.30-2016 =
5
+ * NEW: Added the ability to open galleries within albums using a lightbox
6
+ * Changed: Increased freemius opt-in to 100%
7
+ * Changed: Tamara Lackey's biography on the overview page
8
+ * Fixed: Images not responsive for all display types
9
+ * Fixed: Compatibility with the Imagely Lightroom plugin
10
+ * Fixed: Removed Pope tests folder
11
+ * Fixed: Maximum function nesting level fatal error when displaying two or more albums
12
+ * Fixed: Ensure Insert Gallery Window background stays white
13
+ * Fixed: PHP warning for C_NGG_Lightbox class using incompatible constructor
14
+
15
  = V2.1.49 - 07.26.2016 =
16
  * NEW: Add a "Default" template option to override ATP settings when a global setting is used
17
  * NEW: Added "generic" error reporting back during image upload.
nggallery.php CHANGED
@@ -4,7 +4,7 @@ if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You
4
  /**
5
  * Plugin Name: NextGEN Gallery
6
  * Description: The most popular gallery plugin for WordPress and one of the most popular plugins of all time with over 15 million downloads.
7
- * Version: 2.1.49
8
  * Author: Imagely
9
  * Plugin URI: https://www.imagely.com/wordpress-gallery-plugin/nextgen-gallery/
10
  * Author URI: https://www.imagely.com
@@ -595,7 +595,7 @@ class C_NextGEN_Bootstrap
595
  define('NGG_PRODUCT_URL', path_join(str_replace("\\", '/', NGG_PLUGIN_URL), 'products'));
596
  define('NGG_MODULE_URL', path_join(str_replace("\\", '/', NGG_PRODUCT_URL), 'photocrati_nextgen/modules'));
597
  define('NGG_PLUGIN_STARTED_AT', microtime());
598
- define('NGG_PLUGIN_VERSION', '2.1.49');
599
 
600
  if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG)
601
  define('NGG_SCRIPT_VERSION', (string)mt_rand(0, mt_getrandmax()));
@@ -892,8 +892,10 @@ function ngg_fs() {
892
  $run_freemius = true;
893
  } else {
894
  // Run Freemius code on 20% of the new installations.
895
- $random = rand( 1, 10 );
896
- $run_freemius = ( 1 <= $random && $random <= 2 );
 
 
897
  }
898
 
899
  update_option('ngg_run_freemius', $run_freemius);
4
  /**
5
  * Plugin Name: NextGEN Gallery
6
  * Description: The most popular gallery plugin for WordPress and one of the most popular plugins of all time with over 15 million downloads.
7
+ * Version: 2.1.50
8
  * Author: Imagely
9
  * Plugin URI: https://www.imagely.com/wordpress-gallery-plugin/nextgen-gallery/
10
  * Author URI: https://www.imagely.com
595
  define('NGG_PRODUCT_URL', path_join(str_replace("\\", '/', NGG_PLUGIN_URL), 'products'));
596
  define('NGG_MODULE_URL', path_join(str_replace("\\", '/', NGG_PRODUCT_URL), 'photocrati_nextgen/modules'));
597
  define('NGG_PLUGIN_STARTED_AT', microtime());
598
+ define('NGG_PLUGIN_VERSION', '2.1.50');
599
 
600
  if (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG)
601
  define('NGG_SCRIPT_VERSION', (string)mt_rand(0, mt_getrandmax()));
892
  $run_freemius = true;
893
  } else {
894
  // Run Freemius code on 20% of the new installations.
895
+ // $random = rand( 1, 10 );
896
+ // $run_freemius = ( 1 <= $random && $random <= 2 );
897
+ // Update 2016-08: run on all new instances
898
+ $run_freemius = TRUE;
899
  }
900
 
901
  update_option('ngg_run_freemius', $run_freemius);
pope/run_tests.php DELETED
@@ -1,24 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * Point this towards your own simpletest installation
5
- */
6
- require_once(dirname(__FILE__) . '/../../simpletest-for-wordpress/lib/autorun.php');
7
-
8
- require_once('lib/autoload.php');
9
-
10
- $tests = array(
11
- 'core',
12
- 'pre_hooks',
13
- 'post_hooks',
14
- 'registry',
15
- 'factories',
16
- 'modules',
17
- 'wrappers',
18
- 'advanced',
19
- 'method_properties'
20
- );
21
-
22
- foreach ($tests as $test) {
23
- require_once('tests/'.$test . '.php');
24
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pope/tests/advanced.php DELETED
@@ -1,102 +0,0 @@
1
- <?php
2
-
3
- class Mixin_Core_Replace_Method extends Mixin
4
- {
5
- function run()
6
- {
7
- $this->object->Replaced_Method = True;
8
- }
9
- }
10
-
11
- class Test_Of_Core_Advanced extends UnitTestCase
12
- {
13
-
14
- public $str = 'test_string';
15
-
16
- public function test_Core_Advanced()
17
- {
18
- $core = new C_Core($this->str);
19
-
20
- /*
21
- * Pope internally caches some metadata about classes and which functions belong in those caches; including
22
- * previous return values and names.
23
- */
24
- $this->assertEqual(
25
- False,
26
- $core->is_cached('get_str'),
27
- 'is_cached() returned True on a function not yet run'
28
- );
29
- $core->get_str();
30
- $this->assertEqual(
31
- True, $core->is_cached('get_str'),
32
- 'is_cached() did not return True on an executed function'
33
- );
34
-
35
- /*
36
- * Ensure remove_mixin() works
37
- */
38
- $core->remove_mixin('Mixin_Core');
39
- $this->assertEqual(
40
- False,
41
- $core->get_mixin_providing('get_str'),
42
- 'A mixin still provides get_str() after remove_mixin() was called'
43
- );
44
- $core->add_mixin('Mixin_Core');
45
-
46
- /*
47
- * Make sure our classes are coming from the right places.
48
- */
49
- $this->assertEqual(
50
- 'core.php',
51
- basename($core->get_class_definition_file()),
52
- 'get_class_definition_file() did not return core.php'
53
- );
54
- $this->assertEqual(
55
- 'class.extensibleobject.php',
56
- basename($core->get_class_definition_file(True)),
57
- 'get_class_definition_file(True) did not return class.extensibleobject.php'
58
- );
59
- $this->assertEqual(
60
- 'tests',
61
- basename($core->get_class_definition_dir()),
62
- 'get_class_definition_dir() did not return this "tests" directory'
63
- );
64
- $this->assertEqual(
65
- 'lib',
66
- basename($core->get_class_definition_dir(True)),
67
- 'get_class_definition_dir(True) did not return the parent "lib" directory'
68
- );
69
-
70
- /*
71
- * replace_method isn't quite what you would imagine; it prevents the original method from running
72
- * and adds a new pre-hook to that method. While your new method will run the results from your method are
73
- * not returned. Here we check for an object variable that shouldn't exist, swap out our method for a new one,
74
- * and make sure it created that variable.
75
- */
76
- $this->assertEqual(
77
- False,
78
- isset($core->object->Replaced_Method),
79
- '$this->Replaced_Method was true before it should not have been'
80
- );
81
- $core->replace_method('get_str', 'Mixin_Core_Replace_Method', 'run');
82
- $this->assertEqual(
83
- null,
84
- $core->get_str(),
85
- 'replace_method() did not work'
86
- );
87
- $this->assertEqual(
88
- True,
89
- $core->object->Replaced_Method,
90
- '$this->Replaced_Method was not true when it should have been (run() was not called)'
91
- );
92
-
93
- // restore_method() reverts us back to a normal state
94
- $core->restore_method('get_str');
95
- $this->assertEqual(
96
- $this->str,
97
- $core->get_str(),
98
- 'restore_method() did not work'
99
- );
100
- }
101
-
102
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pope/tests/core.php DELETED
@@ -1,227 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * This is a brief tutorial on how to use Pope through some unit test demonstrations.
5
- *
6
- * We begin by creating a simple class with a couple of functions.
7
- *
8
- * To help keep some of our classes separated (and to later demonstrate how to use the autoloader and factories)
9
- * we're going to use the same naming scheme as Pope and prefix our classes with their class type.
10
- * We start with our core class.
11
- */
12
- class C_Core extends ExtensibleObject
13
- {
14
- /*
15
- * PHP imposes some limits that means our class variables and functions should ALL be public. "Private" variables
16
- * should be named with a prefixed underscore.
17
- */
18
-
19
- /*
20
- * This class exists to save and retrieve this string variable. We change our get/set functions with Mixins
21
- * which we'll cover soon.
22
- */
23
- public $_str;
24
-
25
- public function set_str($str)
26
- {
27
- $this->object->_str = $str;
28
- }
29
-
30
- /*
31
- * add_mixin() links the functions defined in Mixin_Core to this C_Core class. By assigning Mixin_Core we can
32
- * call the "get_str" function on a C_Core instance even though this C_Core definition doesn't include a get_str
33
- * function. You can even later add more Mixins that provide the same function; Pope tracks them by priority
34
- * to determine name conflicts.
35
- *
36
- * define() is run when your class is created and can be used to automatically attach mixins or hooks.
37
- */
38
- public function define()
39
- {
40
- $this->add_mixin('Mixin_Core');
41
- }
42
-
43
- /*
44
- * This function is called at the end of __construct
45
- */
46
- public function initialize($str)
47
- {
48
- $this->set_str($str);
49
- }
50
- }
51
-
52
- /*
53
- * Now about mixins: they're like small plugins that can be assigned to give other classes their functions
54
- * or to override their existing functions. They can access their parent data and can be added or removed
55
- * and then added & removed again at any time. Let's demonstrate.
56
- */
57
- class Mixin_Core extends Mixin
58
- {
59
- public function get_str()
60
- {
61
- /*
62
- * We can access the parent data with $this->object. When we attach this Mixin_Core to C_Core above this
63
- * function returns C_Core's _str. If we attached this Mixin to any other class this Mixin would return that
64
- * classes' _str variable.
65
- */
66
- return $this->object->_str;
67
- }
68
- }
69
-
70
- /*
71
- * We may need more than one way to retrieve that same string. This function returns our string inside of an HTML
72
- * comment. The same C_Core instance can use both this and Mixin_Core's get_str() functions as you need them.
73
- */
74
- class Mixin_Core_Override extends Mixin
75
- {
76
- public function get_str($parent = False)
77
- {
78
- if (True == $parent)
79
- {
80
- return $this->call_parent('get_str');
81
- } else {
82
- return '<!-- ' . $this->object->_str . ' -->';
83
- }
84
- }
85
- }
86
-
87
- /*
88
- * This tutorial also doubles as a valid unit test with SimpleTest. The parameters for simpleTest's assert functions
89
- * are (thing to compare one, thing to compare two, error message)
90
- */
91
- class Test_Of_Core extends UnitTestCase
92
- {
93
-
94
- public $str = 'test_string';
95
-
96
- /*
97
- * We start with the simplest test possible. We create a C_Core class then we ask whether the string it has
98
- * stored is the same as the string we gave it. Because we used add_mixin() in C_Core->define() we don't have
99
- * to do it for every new C_Core we instantiate.
100
- */
101
- public function test_Core()
102
- {
103
- $core = new C_Core($this->str);
104
-
105
- /*
106
- * First we'll make sure that the get_str() method has been assigned
107
- */
108
- $this->assertEqual(
109
- True,
110
- $core->has_method('get_str'),
111
- 'has_method() did not return True on a method that exists'
112
- );
113
-
114
- /*
115
- * Just in case has_method() is lying we ask about a method that doesnt exist
116
- */
117
- $this->assertEqual(
118
- False,
119
- $core->has_method('does_not_exist'),
120
- 'has_method() did not return False on a method that does not exist'
121
- );
122
-
123
- /*
124
- * Finally we'll call get_str()
125
- */
126
- $this->assertEqual(
127
- $this->str,
128
- $core->get_str(),
129
- 'Simplest test did not work, probably add_mixin()'
130
- );
131
-
132
- /*
133
- * We can ask pope what functions exist for our objects. Here we limit our results to functions provided by
134
- * Mixin_Core. If you want every function available just remove the name parameter.
135
- */
136
- $this->assertEqual(
137
- array(
138
- 0 => 'get_str'
139
- ),
140
- $core->get_instance_methods('Mixin_Core'),
141
- 'get_instance_methods() did not return a correct list'
142
- );
143
-
144
- /*
145
- * We can also ask which mixin provides our functions
146
- */
147
- $this->assertEqual(
148
- 'Mixin_Core',
149
- $core->get_mixin_providing('get_str'),
150
- 'get_mixin_providing() returned a wrong result'
151
- );
152
-
153
- $this->assertEqual(
154
- $this->str,
155
- $core->call_method('get_str'),
156
- 'call_method() returned a wrong result'
157
- );
158
-
159
- /*
160
- * Try calling a method for the object that doesn't exist
161
- */
162
- $this->expectException('Exception', "ExtensibleObject did not throw an exception when an undefined method was called");
163
- $core->this_method_does_not_exist();
164
- }
165
-
166
- /*
167
- * That's it! We created a C_Core class, assigned it a Mixin, and then called a function from the Mixin that the
168
- * C_Core class didn't have. You now have a very simple and easily modifiable plugin system.
169
- *
170
- * Now we demonstrate how to work with other Mixins.
171
- */
172
- public function test_Override()
173
- {
174
- /*
175
- * By assigning Mixin_Core_Override it is given higher priority than Mixin_Core (first in, last out). Because
176
- * our override returns the string as an HTML comment, we ask whether the override function ran.
177
- */
178
- $core = new C_Core($this->str);
179
- $core->add_mixin('Mixin_Core_Override');
180
- $this->assertEqual(
181
- "<!-- {$this->str} -->",
182
- $core->get_str(),
183
- 'add_mixin() with an override did not render correctly'
184
- );
185
-
186
- /*
187
- * Testing call_method() with our override
188
- */
189
- $this->assertEqual(
190
- "<!-- {$this->str} -->",
191
- $core->call_method('get_str'),
192
- 'call_method() returned a wrong result'
193
- );
194
-
195
- /*
196
- * Our override will use it's call_parent() method when given a True parameter. Mixins and classes in Pope
197
- * don't really have parents but it does maintain priority for each mixin added. If more than one mixin
198
- * implements the same function they can call the mixins that are above them in priority. We demonstrate that
199
- * by telling our override function to call it's parent -- the Mixin_Core->get_str()
200
- */
201
- $this->assertEqual(
202
- $this->str,
203
- $core->get_str(True),
204
- 'call_parent() did not function correctly'
205
- );
206
-
207
- /*
208
- * Again we test call_method, this time while passing a parameter
209
- */
210
- $this->assertEqual(
211
- $this->str,
212
- $core->call_method('get_str', array(True)),
213
- 'call_method() returned a wrong result (with parameters)'
214
- );
215
-
216
- /*
217
- * Just as easily as it was added we remove it and go back to our plain-old Mixin_Core.
218
- */
219
- $core->del_mixin('Mixin_Core_Override');
220
- $this->assertEqual(
221
- $this->str,
222
- $core->get_str(),
223
- 'del_mixin() did not remove the override mixin correctly'
224
- );
225
- }
226
-
227
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pope/tests/factories.php DELETED
@@ -1,209 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * In this example we introduce interfaces, factories and the registry. We're going to create a "Simple Template"
5
- * service and this means we an interface to implement, a class to implement it with, and a couple of mixins to attach
6
- * to it. In the core unit test we created a service that returned a string wrapped in code comments. We do that again
7
- * here.
8
- *
9
- * Start by creating the interface
10
- */
11
- interface I_Simple_Template
12
- {
13
- function render($arg);
14
- }
15
-
16
- /*
17
- * This is the default render() implementation. You may use your own default, but here we're going to requrie users
18
- * to supply their own render() implementation.
19
- */
20
- class Mixin_Simple_Template_Default
21
- {
22
- function render($arg)
23
- {
24
- throw new Exception('Expected adapter to override this method');
25
- }
26
- }
27
-
28
- /*
29
- * Our main class. We now extend C_Component instead of ExtensibleObject and we use $this->implement() to implement
30
- * the I_Simple_Template interface above. The context that initialize() asks for is used to juggle what kind of object
31
- * our factories should create; you'll see soon.
32
- */
33
- class C_Simple_Template extends C_Component
34
- {
35
- function define()
36
- {
37
- parent::define();
38
- $this->add_mixin('Mixin_Simple_Template_Default');
39
- $this->implement('I_Simple_Template');
40
- }
41
-
42
- function initialize($context = False)
43
- {
44
- parent::initialize($context);
45
- }
46
- }
47
-
48
- class C_Simple_Template_Two extends C_Component
49
- {
50
- function define()
51
- {
52
- parent::define();
53
- $this->add_mixin('Mixin_Simple_Template_Normal');
54
- }
55
- }
56
-
57
- /*
58
- * Let's create two implementations of render(). One will just return our string as is, and the other will be filtered
59
- * through strip_tags()
60
- */
61
- class A_Simple_Template_Normal extends Mixin
62
- {
63
- function render($arg)
64
- {
65
- return $arg;
66
- }
67
- }
68
-
69
- class A_Simple_Template_Alternate extends Mixin
70
- {
71
- function render($arg)
72
- {
73
- return strip_tags($arg);
74
- }
75
- }
76
-
77
- /*
78
- * This is our factory; it's functions are called by name when calling the I_Component_Factory->create(). So here we
79
- * name this function 'photocrati_simple_template' and use that same name again when doing $factory->create().
80
- */
81
- class A_Simple_Template_Factory extends Mixin
82
- {
83
- function photocrati_simple_template($context = False)
84
- {
85
- return new C_Simple_Template($context);
86
- }
87
- }
88
-
89
- /**
90
- * The SimpleTest class
91
- */
92
- class Test_Of_Simple_Template extends UnitTestCase
93
- {
94
-
95
- public $str = 'test_string';
96
-
97
- public function test_simple_template()
98
- {
99
- /*
100
- * We first setup Pope, and then tell I_Component_Factory that our Simple_Template factory exists.
101
- */
102
- $registry = C_Component_Registry::get_instance();
103
- $registry->add_utility('I_Component_Factory', 'C_Component_Factory');
104
- $registry->add_adapter('I_Component_Factory', 'A_Simple_Template_Factory');
105
-
106
- /*
107
- * Now we assign the Normal and Alternate implementations to the interface.
108
- */
109
- $registry->add_adapter('I_Simple_Template', 'A_Simple_Template_Normal', 'Normal');
110
- $registry->add_adapter('I_Simple_Template', 'A_Simple_Template_Alternate', 'Alternate');
111
-
112
- /*
113
- * Now we create our objects. By providing the context "normal" we are asking Pope to use our "normal" render
114
- * implementation. If we leave out the context parameter here our factory provides us with our default
115
- * implementation which will throw an exception.
116
- */
117
- $factory = $registry->get_utility('I_Component_Factory');
118
- $obj = $factory->create('photocrati_simple_template', 'Normal');
119
- $this->assertEqual(
120
- $this->str,
121
- $obj->render($this->str),
122
- 'The normal context did not render correctly'
123
- );
124
-
125
- /*
126
- * Because our default handler throws an exception when called, let's make certain it works as the fallback
127
- */
128
- $obj = $factory->create('photocrati_simple_template', 'Test');
129
- $error = False;
130
- try
131
- {
132
- $obj->render($this->str);
133
- } catch (Exception $exception)
134
- {
135
- $error = True;
136
- }
137
- $this->assertEqual(
138
- True,
139
- $error,
140
- 'The default throwback handler did not throw an exception (did not run)'
141
- );
142
-
143
- /*
144
- * Now let's add it and test it again
145
- */
146
- $registry->add_adapter('I_Simple_Template', 'A_Simple_Template_Normal', 'Test');
147
- $factory = $registry->get_utility('I_Component_Factory');
148
-
149
- $obj = $factory->create('photocrati_simple_template', 'Test');
150
- $this->assertEqual(
151
- $this->str,
152
- $obj->render($this->str),
153
- 'The test context did not render correctly after add_adapter()'
154
- );
155
-
156
- /*
157
- * That worked! Let's delete it and make sure it again throws an exception
158
- */
159
- $error = False;
160
- $registry->del_adapter('I_Simple_Template', 'A_Simple_Template_Normal', 'Test');
161
- $factory = $registry->get_utility('I_Component_Factory');
162
- $obj = $factory->create('photocrati_simple_template', 'Test');
163
- try
164
- {
165
- $obj->render($this->str);
166
- } catch (Exception $exception)
167
- {
168
- $error = True;
169
- }
170
- $this->assertEqual(
171
- True,
172
- $error,
173
- 'Factory creation of a context after calling del_adapter() did not throw an exception'
174
- );
175
-
176
- /*
177
- * We now swap out to the Alternate context where we ask for our text to be free of markup
178
- */
179
- $obj = $factory->create('photocrati_simple_template', 'Alternate');
180
- $this->assertEqual(
181
- $this->str,
182
- $obj->render('<p>' . $this->str . '</p>'),
183
- 'The alternative context did not render correctly'
184
- );
185
-
186
- /*
187
- * We can of course still create our objects outside of the factory generator. Here we moved the implement()
188
- * call outside of the class definition so that we can test it.
189
- */
190
- $obj = new C_Simple_Template_Two();
191
- $this->assertEqual(
192
- False,
193
- $obj->implements_interface('I_Simple_Template'),
194
- 'C_Simple_Template implemented I_Simple_Template_Two when it should not have'
195
- );
196
- $obj->implement('I_Simple_Template');
197
- $this->assertEqual(
198
- True,
199
- $obj->implements_interface('I_Simple_Template'),
200
- 'C_Simple_Template_Two did not implement I_Simple_Template when it should have'
201
- );
202
-
203
- /*
204
- * That's it. We've created an interface and a couple of implementations of it. We can switch between those
205
- * implementations based on context, and our factory maker provides the correct implementation.
206
- */
207
- }
208
-
209
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pope/tests/method_properties.php DELETED
@@ -1,175 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * We can make some significant changes to the Pope internals through the set_method_properties() function.
5
- *
6
- * Here we'll create two classes that capitalize & rot13 our string, each with a post and pre function. The capitalize
7
- * class will also check an object variable.
8
- *
9
- * Because Pope caches the return values from executed functions we can also override that return value in our post
10
- * hooks before it makes it is returned. We can also have one hook disable execution of other hooks and even the
11
- * original function called.
12
- */
13
- class Hook_MP_Capitalize extends Hook
14
- {
15
- public function capitalize()
16
- {
17
- $prop = ExtensibleObject::METHOD_PROPERTY_RETURN_VALUE;
18
-
19
- // method, property, value
20
- $this->object->set_method_property(
21
- 'get_str',
22
- $prop,
23
- strtoupper($this->object->get_method_property('get_str', $prop))
24
- );
25
-
26
- /*
27
- * The object variables are set later as a manual trigger
28
- */
29
- if (True == $this->object->disable_run_post_hooks)
30
- {
31
- $this->object->set_method_property('get_str', ExtensibleObject::METHOD_PROPERTY_RUN_POST_HOOKS, False);
32
- }
33
- }
34
-
35
- public function pre_capitalize()
36
- {
37
- $this->object->_str = strtoupper($this->object->_str);
38
-
39
- if (True == $this->object->disable_run_pre_hooks)
40
- {
41
- $this->object->set_method_property('get_str', ExtensibleObject::METHOD_PROPERTY_RUN_PRE_HOOKS, False);
42
- }
43
-
44
- if (True == $this->object->disable_run)
45
- {
46
- $this->object->set_method_property('get_str', ExtensibleObject::METHOD_PROPERTY_RUN, False);
47
- }
48
- }
49
- }
50
-
51
- /*
52
- * Now we repeat ourselves, but simpler as this class exists just to be disabled
53
- */
54
- class Hook_MP_Rot13 extends Hook
55
- {
56
- public function rot13()
57
- {
58
- $prop = ExtensibleObject::METHOD_PROPERTY_RETURN_VALUE;
59
-
60
- // method, property, value
61
- $this->object->set_method_property(
62
- 'get_str',
63
- $prop,
64
- str_rot13($this->object->get_method_property('get_str', $prop))
65
- );
66
- }
67
-
68
- public function pre_rot13()
69
- {
70
- $this->object->_str = str_rot13($this->object->_str);
71
- }
72
- }
73
-
74
- class Test_Of_Method_Properties extends UnitTestCase
75
- {
76
- public $str = 'test_string';
77
-
78
- public function test_Method_Properties()
79
- {
80
- $core = new C_Core($this->str);
81
- $core->add_mixin('Mixin_Core_Post');
82
-
83
- /*
84
- * This hook modifies the original return value to instead return its results directly through get_str()
85
- */
86
- $core->add_post_hook('get_str', 'Method Properties Capitalize', 'Hook_MP_Capitalize', 'capitalize');
87
- $this->assertEqual(
88
- strtoupper($this->str),
89
- $core->get_str(),
90
- 'set_method_property(return_value) did not capitalize our string'
91
- );
92
-
93
- /*
94
- * We need at least two hooks to test
95
- */
96
- $core->add_post_hook('get_str', 'Method Properties Rot13', 'Hook_MP_Rot13', 'rot13');
97
- $this->assertEqual(
98
- str_rot13(strtoupper($this->str)),
99
- $core->get_str(),
100
- 'set_method_property(return_value) did not capitalize and rot13 our string across two hooks'
101
- );
102
-
103
- /*
104
- * Our capitalize() function will check for this variable and disable other post hooks through
105
- * set_method_property()
106
- */
107
- $core->object->disable_run_post_hooks = True;
108
- $this->assertEqual(
109
- strtoupper($this->str),
110
- $core->get_str(),
111
- 'set_method_property(run_post_hooks) did not disable the rot13 hook'
112
- );
113
-
114
- $core->disable_post_hooks('get_str');
115
- $core->set_str($this->str);
116
-
117
- /*
118
- * Now we add our pre-hooks and test them
119
- */
120
- $core->add_pre_hook('get_str', 'Method Properties Pre-Capitalize', 'Hook_MP_Capitalize', 'pre_capitalize');
121
- $core->add_pre_hook('get_str', 'Method Properties Pre-Rot13', 'Hook_MP_Rot13', 'pre_rot13');
122
- $this->assertEqual(
123
- str_rot13(strtoupper($this->str)),
124
- $core->get_str(),
125
- 'Something stopped the two pre-hooks from running'
126
- );
127
-
128
- /*
129
- * Again our first pre-hook should disable the second from running
130
- */
131
- $core->object->disable_run_pre_hooks = True;
132
- $core->set_str($this->str);
133
- $this->assertEqual(
134
- strtoupper($this->str),
135
- $core->get_str(),
136
- 'set_method_property(run_pre_hooks) did not disable the rot13 hook'
137
- );
138
-
139
- /*
140
- * When run == False get_str() should not run and should return null
141
- */
142
- $core->set_str($this->str);
143
- $core->disable_run = True;
144
- $this->assertEqual(
145
- Null,
146
- $core->get_str(),
147
- 'set_method_properties(run) did not stop get_str() from running'
148
- );
149
-
150
- /*
151
- * And one last sanity check
152
- */
153
- $this->assertEqual(
154
- strtoupper($this->str),
155
- $core->object->_str,
156
- 'Something stopped the pre-hook from running'
157
- );
158
-
159
- /*
160
- * clear_method_properties() resets the entire method properties array
161
- */
162
- $core->reset_method_properties('get_str');;
163
- $this->assertEqual(
164
- array(
165
- ExtensibleObject::METHOD_PROPERTY_RUN => True,
166
- ExtensibleObject::METHOD_PROPERTY_RUN_PRE_HOOKS => True,
167
- ExtensibleObject::METHOD_PROPERTY_RUN_POST_HOOKS => True
168
- ),
169
- $core->_method_properties['get_str'],
170
- 'clear_method_properties() did not reset the method properties correctly'
171
- );
172
-
173
-
174
- }
175
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pope/tests/modules.php DELETED
@@ -1,30 +0,0 @@
1
- <?php
2
-
3
- class Test_Of_Modules extends UnitTestCase
4
- {
5
- public $str = 'test_string';
6
-
7
- public function test_Modules()
8
- {
9
- $registry = C_Component_Registry::get_instance();
10
- $factory = $registry->get_utility('I_Component_Factory');
11
-
12
- /*
13
- * photocrati_template is a continuation of the Simple_Template class, now reborn as "Template" that we have
14
- * put into a product called "Pope". We test it the same way we did our Simple_Template class.
15
- */
16
- $obj = $factory->create('photocrati_template', 'Normal');
17
- $this->assertEqual(
18
- $this->str,
19
- $obj->render($this->str),
20
- 'Factory creation of a normal context template did not render correctly'
21
- );
22
-
23
- $obj = $factory->create('photocrati_template', 'Alternate');
24
- $this->assertEqual(
25
- $this->str,
26
- $obj->render('<p>' . $this->str . '</p>'),
27
- 'Factory creation of an alternate context template did not render correctly'
28
- );
29
- }
30
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pope/tests/post_hooks.php DELETED
@@ -1,165 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * Continuing on we now have post-hooks.
5
- *
6
- * With our pre-hooks we just modified our string before it was sent, but post-hooks run after get_str() so they won't
7
- * help much. Instead we make a simple function for triggering our post-hooks, it doesn't do anything but trigger them.
8
- */
9
- class Mixin_Core_Post extends Mixin
10
- {
11
- public function do_nothing()
12
- {
13
- return null;
14
- }
15
- }
16
-
17
- /*
18
- * In an alternate reality we need to change our string into a Ruby comment, but only after we've seen the original.
19
- * We can do that as a post-hook. Again we create two for our tests and a global hook function.
20
- */
21
- class Hook_Core_Post extends Hook
22
- {
23
- public function change_str()
24
- {
25
- $this->object->_str = '=begin ' . $this->object->_str . ' =end';
26
- }
27
- public function global_change_str()
28
- {
29
- $this->object->_str = '; ' . $this->object->_str;
30
- }
31
- }
32
-
33
- class Hook_Core_Post_Second extends Hook
34
- {
35
- public function change_str()
36
- {
37
- $this->object->_str = '-- ' . $this->object->_str;
38
- }
39
- }
40
-
41
- class Test_Of_Post_Hooks extends UnitTestCase
42
- {
43
-
44
- public $str = 'test_string';
45
-
46
- public function test_Post_Hooks()
47
- {
48
- $core = new C_Core($this->str);
49
- $core->add_mixin('Mixin_Core_Post');
50
- $this->assertEqual(
51
- True,
52
- $core->has_method('do_nothing'),
53
- 'has_method() did not return True on a method that does exist'
54
- );
55
-
56
- $core->add_post_hook('do_nothing', 'Post-Hook Test', 'Hook_Core_Post', 'change_str');
57
- $core->do_nothing();
58
- $this->assertEqual(
59
- "=begin {$this->str} =end",
60
- $core->get_str(),
61
- 'add_post_hook() did not run correctly'
62
- );
63
-
64
- // make sure a posthook is registered for do_nothing()
65
- $this->assertEqual(
66
- True,
67
- $core->have_posthook_for('do_nothing'),
68
- 'have_posthook_for() did not return True on a function with a post-hook (one parameter)'
69
- );
70
-
71
- // and that we have one from "Post-Hook Test" and do_nothing()
72
- $this->assertEqual(
73
- True,
74
- $core->have_posthook_for('do_nothing', 'Post-Hook Test'),
75
- 'have_posthook_for() did not return True on a function with a post-hook (two parameter)'
76
- );
77
-
78
- // just to be safe, ensure we don't have posthooks that don't exist
79
- $this->assertEqual(
80
- False,
81
- $core->have_posthook_for('do_nothing', 'Does Not Exist'),
82
- 'have_posthook_for() did not return False on a post-hook label that does not exist'
83
- );
84
-
85
- // del_post_hook
86
- $core->del_post_hook('do_nothing', 'Post-Hook Test');
87
- $core->set_str($this->str);
88
- $this->assertEqual(
89
- $this->str,
90
- $core->get_str(),
91
- 'del_post_hook() did not run correctly'
92
- );
93
- $this->assertEqual(
94
- False,
95
- $core->have_posthook_for('do_nothing', 'Post-Hook Test'),
96
- 'have_posthook_for() did not return False after calling del_post_hook()'
97
- );
98
-
99
- // re-add to continue testing
100
- $core->add_post_hook('do_nothing', 'Post-Hook Test', 'Hook_Core_Post', 'change_str');
101
-
102
- // disable_post_hooks
103
- $core->disable_post_hooks('do_nothing');
104
- $this->assertEqual(
105
- $this->str,
106
- $core->get_str(),
107
- 'disable_post_hooks() did not run correctly'
108
- );
109
-
110
- // enable_post_hooks
111
- $core->enable_post_hooks('do_nothing');
112
- $core->do_nothing();
113
- $this->assertEqual(
114
- "=begin {$this->str} =end",
115
- $core->get_str(),
116
- 'enable_post_hooks() did not run correctly'
117
- );
118
-
119
- // are_post_hooks_enabled
120
- $this->assertEqual(
121
- True,
122
- $core->are_post_hooks_enabled('do_nothing'),
123
- 'are_post_hooks_enabled() did not return True on a function with post-hooks'
124
- );
125
-
126
- // are_post_hooks_enabled
127
- $core->disable_post_hooks('do_nothing');
128
- $this->assertEqual(
129
- False,
130
- $core->are_post_hooks_enabled('do_nothing'),
131
- 'are_post_hooks_enabled() did not return False after calling disable_post_hooks()'
132
- );
133
-
134
- // two post hooks
135
- $core->enable_post_hooks('do_nothing');
136
- $core->set_str($this->str);
137
- $core->add_post_hook('do_nothing', 'Post-Hook Test Two', 'Hook_Core_Post_Second', 'change_str');
138
- $core->do_nothing();
139
- $this->assertEqual(
140
- "-- =begin {$this->str} =end",
141
- $core->get_str(),
142
- 'enable_post_hooks() did not run correctly'
143
- );
144
-
145
- // del_post_hooks
146
- $core->del_post_hooks('do_nothing');
147
- $core->set_str($this->str);
148
- $this->assertEqual(
149
- $this->str,
150
- $core->get_str(),
151
- 'del_post_hooks() did not run correctly'
152
- );
153
-
154
- // add_global_post_hook
155
- $core->add_post_hook('do_nothing', 'Post-Hook Test Two', 'Hook_Core_Post_Second', 'change_str');
156
- $core->add_global_post_hook('Global Post-Hook', 'Hook_Core_Post', 'global_change_str');
157
- $core->add_post_hook('do_nothing', 'Post-Hook Test', 'Hook_Core_Post', 'change_str');
158
- $core->do_nothing();
159
- $this->assertEqual(
160
- True,
161
- "; =begin -- ; {$this->str} =end",
162
- 'add_global_post_hook() did not run correctly'
163
- );
164
- }
165
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pope/tests/pre_hooks.php DELETED
@@ -1,197 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * Now we are going to introduce hooks. Hooks extend the Mixin type and work in a similiar way.
5
- *
6
- * Like our previous Mixin override we put our string inside a C comment. With this we can filter our string through any
7
- * number of hooks and not just rely on manually assigning Mixins. We eventually want to test our ability to remove
8
- * both at once, so we setup hooks two. We also have global hooks (hooks that are assigned to ALL functions) so we
9
- * create a special method for that also.
10
- */
11
- class Hook_Core_Pre extends Hook
12
- {
13
- public function change_str()
14
- {
15
- $this->object->_str = '/* ' . $this->object->_str . ' */';
16
- }
17
-
18
- public function global_change_str()
19
- {
20
- $this->object->_str = '// ' . $this->object->_str;
21
- }
22
- }
23
- class Hook_Core_Pre_Second extends Hook
24
- {
25
- public function change_str()
26
- {
27
- $this->object->_str = '## ' . $this->object->_str;
28
- }
29
-
30
- /*
31
- * We can tell our hook functions to call the function they are anchored to.
32
- */
33
- public function test_call_anchor()
34
- {
35
- $this->object->_str = 'not the test string';
36
- return $this->call_anchor();
37
- }
38
- }
39
-
40
- /*
41
- * On to our unit tests
42
- */
43
- class Test_Of_Pre_Hooks extends UnitTestCase
44
- {
45
-
46
- public $str = 'test_string';
47
-
48
- public function test_Pre_Hooks()
49
- {
50
- /*
51
- * We assign Hook_Core_Pre->change_str to run before the $core->get_str function. Hooks are grouped by
52
- * name. You'll see when we get to del_pre_hook()
53
- */
54
- $core = new C_Core($this->str);
55
- $core->add_pre_hook('get_str', 'Pre-Hook Test', 'Hook_Core_Pre', 'change_str');
56
- $this->assertEqual(
57
- "/* {$this->str} */",
58
- $core->get_str(),
59
- 'add_pre_hook() did not change our var correctly'
60
- );
61
-
62
- /*
63
- * Just to be safe we're going to make sure the hook we just applied really is registered. We're being very
64
- * cautious today so we'll also make sure there isn't a hook group that shouldn't be there. The first check
65
- * is true if there's *any* hooks for get_str, the second only if there's a hook in the "Pre-Hook Test" group
66
- * for get_str.
67
- */
68
- $this->assertEqual(
69
- True,
70
- $core->have_prehook_for('get_str'),
71
- 'have_prehook_for() with one parameter did not return True when it should have'
72
- );
73
- $this->assertEqual(
74
- True,
75
- $core->have_prehook_for('get_str','Pre-Hook Test'),
76
- 'have_prehook_for() with both parameters did not return True when it should have'
77
- );
78
- $this->assertEqual(
79
- False,
80
- $core->have_prehook_for('get_str', 'Does Not Exist'),
81
- 'have_prehook_for() did not return False on a non-existent pre-hook'
82
- );
83
-
84
- /*
85
- * We don't actually NEED our string stored as a C comment, let's undo all that. Our filter up above
86
- * changed the string variable itself, so after deleting our hook we reset the string and then test ourselves
87
- * again.
88
- */
89
- $core->del_pre_hook('get_str', 'Pre-Hook Test');
90
- $core->set_str($this->str);
91
- $this->assertEqual(
92
- $this->str,
93
- $core->get_str(),
94
- 'del_pre_hook() did not run correctly'
95
- );
96
- $this->assertEqual(
97
- False,
98
- $core->have_prehook_for('get_str', 'Pre-Hook Test'),
99
- 'have_prehook_for() did not return False for a deleted hook'
100
- );
101
-
102
- /*
103
- * Wait, I've changed my mind. We need that hook back, but we're going to leave it disabled.
104
- */
105
- $core->add_pre_hook('get_str', 'Pre-Hook Test', 'Hook_Core_Pre', 'change_str');
106
- $core->disable_pre_hooks('get_str');
107
- $this->assertEqual(
108
- $this->str,
109
- $core->get_str(),
110
- 'disable_pre_hooks() did not run correctly'
111
- );
112
-
113
- /*
114
- * We've proven the hook isn't a renegade robot, so we turn it back on and run another systems check.
115
- */
116
- $core->enable_pre_hooks('get_str');
117
- $this->assertEqual(
118
- "/* {$this->str} */",
119
- $core->get_str(),
120
- 'enable_pre_hooks() did not run correctly'
121
- );
122
-
123
- /*
124
- * Like proper scientists we check our ability to check our ability to turn our hooks on and off
125
- */
126
- $this->assertEqual(
127
- True,
128
- $core->are_pre_hooks_enabled('get_str'),
129
- 'are_pre_hooks_enabled() did not return True after enable_pre_hooks() ran'
130
-
131
- );
132
- $core->disable_pre_hooks('get_str');
133
- $this->assertEqual(
134
- False,
135
- $core->are_pre_hooks_enabled('get_str'),
136
- 'are_pre_hooks_enabled() did not return False after disable_pre_hooks() ran'
137
- );
138
-
139
- /*
140
- * Now let's test our abilities to run more than one hook and to turn them all off at once
141
- */
142
- $core->enable_pre_hooks('get_str');
143
- $core->set_str($this->str);
144
- $core->add_pre_hook('get_str', 'Pre-Hook Test Two', 'Hook_Core_Pre_Second', 'change_str');
145
- $this->assertEqual(
146
- "## /* {$this->str} */",
147
- $core->get_str(),
148
- 'enable_pre_hooks() did not run correctly'
149
- );
150
-
151
- /*
152
- * Both hooks ran in the order we wanted, so we turn them both off.
153
- */
154
- $core->del_pre_hooks('get_str');
155
- $core->set_str($this->str);
156
- $this->assertEqual(
157
- $this->str,
158
- $core->get_str(),
159
- 'del_pre_hooks() did not run correctly'
160
- );
161
-
162
- /*
163
- * Let's add our global pre-hook. Just to demonstrate something, we'll add our "Second" hook first, then
164
- * our global hook, and then the original pre-hook. Global hooks are run first, and then regular hooks are
165
- * run in order they are attached.
166
- */
167
- $core->add_pre_hook('get_str', 'Pre-Hook Test Two', 'Hook_Core_Pre_Second', 'change_str');
168
- $core->add_global_pre_hook('Global Pre-Hook', 'Hook_Core_Pre', 'global_change_str');
169
- $core->add_pre_hook('get_str', 'Pre-Hook Test', 'Hook_Core_Pre', 'change_str');
170
- $this->assertEqual(
171
- "/* ## // {$this->str} */",
172
- $core->get_str(),
173
- 'add_global_pre_hook() did not run correctly'
174
- );
175
- }
176
-
177
- public function test_Pre_Hook_Anchor()
178
- {
179
- /*
180
- * Here we call a pre-hook that uses call_anchor() to invoke get_str() itself-after changing the set
181
- * string to something entirely different.
182
- */
183
- $core = new C_Core($this->str);
184
- $core->add_mixin('Mixin_Core_Override');
185
- $core->add_pre_hook('get_str', 'Pre-Hook Anchor Test', 'Hook_Core_Pre_Second', 'test_call_anchor');
186
-
187
- $this->assertEqual(
188
- '<!-- not the test string -->',
189
- $core->get_str(),
190
- 'A hooks call_anchor() did not run correctly'
191
- );
192
- }
193
-
194
- /*
195
- * That's all for pre-hooks. Post-hooks work identically so readers may want to skip that file.
196
- */
197
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pope/tests/products/photocrati_animal/pope_modules/animal_farm/adapter.animal_cow.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
-
3
- class A_Animal_Cow extends Mixin
4
- {
5
- function speak($arg)
6
- {
7
- return 'The cow moos: ' . $arg;
8
- }
9
- }
 
 
 
 
 
 
 
 
 
pope/tests/products/photocrati_animal/pope_modules/animal_farm/adapter.animal_dog.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
-
3
- class A_Animal_Dog extends Mixin
4
- {
5
- function speak($arg)
6
- {
7
- return 'The dog barks: ' . $arg;
8
- }
9
- }
 
 
 
 
 
 
 
 
 
pope/tests/products/photocrati_animal/pope_modules/animal_farm/adapter.animal_factory.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
-
3
- class A_Animal_Factory extends Mixin
4
- {
5
- function animal_farm($context = False)
6
- {
7
- return new C_Animal_Library($context);
8
- }
9
- }
 
 
 
 
 
 
 
 
 
pope/tests/products/photocrati_animal/pope_modules/animal_farm/class.animal_empty.php DELETED
@@ -1,5 +0,0 @@
1
- <?php
2
-
3
- class C_Animal_Empty extends C_Component
4
- {
5
- }
 
 
 
 
 
pope/tests/products/photocrati_animal/pope_modules/animal_farm/class.animal_library.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
-
3
- class C_Animal_Library extends C_Component
4
- {
5
- function define()
6
- {
7
- parent::define();
8
- $this->add_mixin('Mixin_Animal_Default_Speak');
9
- $this->implement('I_Animal_Library');
10
- }
11
- }
12
-
13
- class Mixin_Animal_Default_Speak
14
- {
15
- function speak($arg)
16
- {
17
- throw new Exception('Expected adapter to override this method');
18
- }
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pope/tests/products/photocrati_animal/pope_modules/animal_farm/interface.animal_library.php DELETED
@@ -1,6 +0,0 @@
1
- <?php
2
-
3
- interface I_Animal_Library
4
- {
5
- function speak($arg);
6
- }
 
 
 
 
 
 
pope/tests/products/photocrati_animal/pope_modules/animal_farm/module.animal_farm.php DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
-
3
- /***
4
- {
5
- Module: photocrati-animal-farm
6
- }
7
- ***/
8
-
9
- class M_Animal_Farm extends C_Base_Module
10
- {
11
- public $is_initialized = False;
12
-
13
- public function define()
14
- {
15
- parent::define(
16
- 'photocrati-animal-farm',
17
- 'Photocrati Animal Farm',
18
- 'An extremely simple animal-based "Hello World"',
19
- '0.1',
20
- 'https://www.imagely.com',
21
- 'Photocrati Media',
22
- 'https://www.imagely.com'
23
- );
24
- }
25
-
26
- public function _register_adapters()
27
- {
28
- $this->get_registry()->add_adapter('I_Component_Factory', 'A_Animal_Factory');
29
- $this->get_registry()->add_adapter('I_Animal_Library', 'A_Animal_Cow', 'Cow');
30
- $this->get_registry()->add_adapter('I_Animal_Library', 'A_Animal_Dog', 'Dog');
31
- }
32
-
33
- public function initialize()
34
- {
35
- $this->is_initialized = True;
36
- }
37
- }
38
-
39
- new M_Animal_Farm();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pope/tests/products/photocrati_animal/product.photocrati_animal.php DELETED
@@ -1,31 +0,0 @@
1
- <?php
2
-
3
- /***
4
- {
5
- Product: photocrati-animal
6
- }
7
- ***/
8
-
9
- class P_Photocrati_Animal extends C_Base_Product
10
- {
11
- public function define()
12
- {
13
- // id, name, description, version, uri, author, author_uri
14
- parent::define(
15
- 'photocrati-animal',
16
- 'Photocrati Animal',
17
- 'An extremely simple animal-based "Hello World"',
18
- '0.1',
19
- 'https://www.imagely.com',
20
- 'Photocrati Media',
21
- 'https://www.imagely.com'
22
- );
23
-
24
- $dir = dirname(__FILE__) . '/pope_modules/';
25
- $registry = $this->get_registry();
26
- $registry->set_product_module_path($this->module_id, $dir);
27
- $registry->add_module_path($dir, True, False);
28
- }
29
- }
30
-
31
- new P_Photocrati_Animal();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pope/tests/products/photocrati_pope/modules/template/adapter.template_alternate.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
-
3
- class A_Template_Alternate extends Mixin
4
- {
5
- function render($arg)
6
- {
7
- return strip_tags($arg);
8
- }
9
- }
 
 
 
 
 
 
 
 
 
pope/tests/products/photocrati_pope/modules/template/adapter.template_factory.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
-
3
- class A_Template_Factory extends Mixin
4
- {
5
- function photocrati_template($context = False)
6
- {
7
- return new C_Template_Library($context);
8
- }
9
- }
 
 
 
 
 
 
 
 
 
pope/tests/products/photocrati_pope/modules/template/adapter.template_normal.php DELETED
@@ -1,9 +0,0 @@
1
- <?php
2
-
3
- class A_Template_Normal extends Mixin
4
- {
5
- function render($arg)
6
- {
7
- return $arg;
8
- }
9
- }
 
 
 
 
 
 
 
 
 
pope/tests/products/photocrati_pope/modules/template/class.template_library.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
-
3
- class C_Template_Library extends C_Component
4
- {
5
- function define()
6
- {
7
- parent::define();
8
- $this->add_mixin('Mixin_Template_Default_Render');
9
- $this->implement('I_Template_Library');
10
- }
11
- }
12
-
13
- class Mixin_Template_Default_Render
14
- {
15
- function render($arg)
16
- {
17
- throw new Exception('Expected adapter to override this method');
18
- }
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pope/tests/products/photocrati_pope/modules/template/interface.template_library.php DELETED
@@ -1,6 +0,0 @@
1
- <?php
2
-
3
- interface I_Template_Library
4
- {
5
- function render($arg);
6
- }
 
 
 
 
 
 
pope/tests/products/photocrati_pope/modules/template/module.template.php DELETED
@@ -1,54 +0,0 @@
1
- <?php
2
-
3
- /***
4
- {
5
- Module: photocrati-template
6
- }
7
- ***/
8
-
9
- class M_Template extends C_Base_Module
10
- {
11
- public $is_initialized = False;
12
-
13
- public function define()
14
- {
15
- parent::define(
16
- 'photocrati-template',
17
- 'Photocrati Template',
18
- 'An extremely simple template system',
19
- '0.1',
20
- 'https://www.imagely.com',
21
- 'Photocrati Media',
22
- 'https://www.imagely.com'
23
- );
24
- }
25
-
26
- /*
27
- * _registery_adapters, _register_hooks(), and _register_utilities are run at the end of parent::define()
28
- */
29
- public function _register_adapters()
30
- {
31
- $this->get_registry()->add_adapter('I_Component_Factory', 'A_Template_Factory');
32
- $this->get_registry()->add_adapter('I_Template_Library', 'A_Template_Normal', 'Normal');
33
- $this->get_registry()->add_adapter('I_Template_Library', 'A_Template_Alternate', 'Alternate');
34
- }
35
-
36
- public function _register_hooks()
37
- {
38
- }
39
-
40
- public function _register_utilities()
41
- {
42
- }
43
-
44
- /*
45
- * You can use initialize() here to act as soon as initialize_module() has been called on it. That way modules
46
- * can be loaded but only started when desired. The initialize() function is only called once per object.
47
- */
48
- public function initialize()
49
- {
50
- $this->is_initialized = True;
51
- }
52
- }
53
-
54
- new M_Template();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pope/tests/products/photocrati_pope/product.photocrati_pope.php DELETED
@@ -1,35 +0,0 @@
1
- <?php
2
-
3
- /***
4
- {
5
- Product: photocrati-pope
6
- }
7
- ***/
8
-
9
- class P_Photocrati_Pope extends C_Base_Product
10
- {
11
- public function define()
12
- {
13
- // id, name, description, version, uri, author, author_uri
14
- parent::define(
15
- 'photocrati-pope',
16
- 'Photocrati Pope',
17
- 'Photocrati Pope',
18
- '0.1',
19
- 'https://bitbucket.org/photocrati/pope-framework',
20
- 'Photocrati Media',
21
- 'https://www.imagely.com'
22
- );
23
-
24
- /*
25
- * The modules can be stored anywhere under this project. In the Animal product the modules are kept in a dir
26
- * called "pope_modules"
27
- */
28
- $dir = dirname(__FILE__) . '/modules/';
29
- $registry = $this->get_registry();
30
- $registry->set_product_module_path($this->module_id, $dir);
31
- $registry->add_module_path($dir, True, False);
32
- }
33
- }
34
-
35
- new P_Photocrati_Pope();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pope/tests/registry.php DELETED
@@ -1,454 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * This is just an empty module to be used for testing later
5
- */
6
- class C_Test_Autoload extends C_Base_Module
7
- {
8
- function define()
9
- {
10
- parent::define(
11
- 'C_Test_Autoload',
12
- 'C_Test_Autoload Empty Class',
13
- 'An empty shell to test the base modules autoload()',
14
- '0.1',
15
- 'https://www.imagely.com/',
16
- 'Photocrati',
17
- 'https://www.imagely.com/'
18
- );
19
- }
20
- }
21
-
22
-
23
- /***
24
- {
25
- Product: photocrati-empty
26
- }
27
- ***/
28
-
29
- class P_Photocrati_Empty extends C_Base_Product
30
- {
31
- public function define()
32
- {
33
- // id, name, description, version, uri, author, author_uri
34
- parent::define(
35
- 'photocrati-empty',
36
- 'Photocrati Empty',
37
- 'AN empty shell used for unit testing',
38
- '0.1',
39
- 'https://bitbucket.org/photocrati/pope-framework',
40
- 'Photocrati Media',
41
- 'https://www.imagely.com'
42
- );
43
- }
44
- }
45
-
46
-
47
- class Test_Of_Registry extends UnitTestCase
48
- {
49
- /** @var string $path Path to the Pope products directory */
50
- public $path;
51
-
52
- public $registry;
53
-
54
- public function __construct()
55
- {
56
- $this->path = dirname(__FILE__) . '/products/';
57
- }
58
-
59
- /**
60
- * Tests the registration setup for Pope
61
- */
62
- public function test_Registry_Setup()
63
- {
64
- // Ensure we're working with an entirely new instance
65
- C_Component_Registry::$_instance = Null;
66
- $this->registry = C_Component_Registry::get_instance();
67
-
68
- // We *want* to cause an exception for once. This should come without any utilities; we'll check for them again
69
- // after we've added one
70
- $factory = false;
71
- try
72
- {
73
- $factory = $this->registry->get_utility('I_Component_Factory');
74
- } catch (Exception $exception) { }
75
- $this->assertEqual(
76
- False,
77
- $factory,
78
- 'A utility was registered to I_Component_Factory when it should be empty'
79
- );
80
-
81
- // Make sure we can set and retrieve utilities
82
- $this->registry->add_utility('I_Component_Factory', 'C_Component_Factory');
83
- $factory = $this->registry->get_utility('I_Component_Factory');
84
- $this->assertEqual(
85
- 'C_Component_Factory',
86
- get_class($factory),
87
- 'add_utility() followed by get_utility() did not return a C_Component_Factory utility'
88
- );
89
-
90
- // Pope can also handle singleton generation, just provide a get_instance() function for your class
91
- $factory = $this->registry->get_utility('I_Component_Factory');
92
- $this->assertEqual(
93
- 'C_Component_Factory',
94
- get_class($factory),
95
- 'get_utility did not return C_Component_Factory utility'
96
- );
97
-
98
- // We've just started so our product & module lists should be completely empty
99
- $this->assertEqual(
100
- array(),
101
- $this->registry->get_known_product_list(),
102
- 'No products should be known yet'
103
- );
104
- $this->assertEqual(
105
- array(),
106
- $this->registry->get_known_module_list(),
107
- 'No modules should be known yet'
108
- );
109
- $this->assertEqual(
110
- array(),
111
- $this->registry->get_product_list(),
112
- 'The product list should be empty'
113
- );
114
- $this->assertEqual(
115
- array(),
116
- $this->registry->get_module_list(),
117
- 'The module list should be empty'
118
- );
119
- }
120
-
121
- /**
122
- * Tests path setup and initial module loading
123
- */
124
- public function test_Registry_Add_Module_Path()
125
- {
126
- /*
127
- * Not every module has to set its own modules directory, add_module_path() will call set_default_module_path()
128
- * the first time it runs so that all of your modules will come from the same place.
129
- */
130
- $this->assertEqual(
131
- Null,
132
- $this->registry->get_default_module_path(),
133
- 'get_default_module_path() returned !null before add_module_path() or set_default_module_path() were called'
134
- );
135
-
136
- $this->registry->add_module_path($this->path, True, False);
137
-
138
- $this->assertEqual(
139
- $this->path,
140
- $this->registry->get_default_module_path(),
141
- 'add_module_path() did not call set_default_module_path() correctly'
142
- );
143
-
144
- /*
145
- * get_known_module_list and get_known_product_list return ALL registered objects, even
146
- * if they haven't been loaded yet (through load_all_products() or load_module() or such.
147
- * get_product_list & get_module_list returns only loaded objects.
148
- *
149
- * Make sure we know of but haven't loaded any products yet
150
- */
151
- $this->assertEqual(
152
- array(
153
- 0 => 'photocrati-animal',
154
- 1 => 'photocrati-pope'
155
- ),
156
- $this->registry->get_known_product_list(),
157
- 'Only the Pope and Animal-Farm products should be known'
158
- );
159
- $this->assertEqual(
160
- array(),
161
- $this->registry->get_product_list(),
162
- 'The product list should be empty'
163
- );
164
-
165
- // make sure we know about but haven't yet loaded any modules
166
- $this->assertEqual(
167
- array(
168
- 0 => 'photocrati-animal',
169
- 1 => 'photocrati-pope'
170
- ),
171
- $this->registry->get_known_module_list(),
172
- 'Only the pope product should be known'
173
- );
174
- $this->assertEqual(
175
- array(),
176
- $this->registry->get_module_list(),
177
- 'The module should should be empty'
178
- );
179
- }
180
-
181
- /**
182
- * Tests loading of (product|module)s
183
- */
184
- public function test_Registry_Load()
185
- {
186
- // test our ability to load & retrieve products
187
- $this->registry->load_product('photocrati-pope');
188
- $this->assertEqual(
189
- array(
190
- 0 => 'photocrati-pope'
191
- ),
192
- $this->registry->get_product_list(),
193
- 'get_product_list() did not return a correct list (see load_product() / add_product()?)'
194
- );
195
-
196
- // and then our ability to load & retrieve modules from products
197
- $this->registry->load_module('photocrati-template');
198
- $this->assertEqual(
199
- array(
200
- 0 => 'photocrati-pope',
201
- 1 => 'photocrati-template'
202
- ),
203
- $this->registry->get_module_list(),
204
- 'get_module_list() did not retrieve a correct list (see load_module() / add_module()?)'
205
- );
206
-
207
- // make sure we're loading from the correct path
208
- $this->assertEqual(
209
- $this->path . 'photocrati_pope/modules/',
210
- $this->registry->get_product_module_path('photocrati-pope'),
211
- 'get_product_module_path() did not return the correct product-module path'
212
- );
213
-
214
- // and that the module is also in the right place
215
- $this->assertEqual(
216
- $this->path . 'photocrati_pope/modules/template/module.template.php',
217
- $this->registry->get_module_path('photocrati-template'),
218
- 'get_module_path() did not return the correct module path'
219
- );
220
- $this->assertEqual(
221
- $this->path . 'photocrati_pope/modules/template',
222
- $this->registry->get_module_dir('photocrati-template'),
223
- 'get_module_dir() did not return the correct module directory'
224
- );
225
- }
226
-
227
- /**
228
- * Tests retrieval of product metadata
229
- */
230
- public function test_Registry_Get_Product()
231
- {
232
- // do we have the right product?
233
- $obj = $this->registry->get_product('photocrati-pope');
234
- $this->assertEqual(
235
- 'P_Photocrati_Pope',
236
- get_class($obj),
237
- 'get_product() did not return a P_Photocrati_Pope object (check add_product())'
238
- );
239
- $this->assertEqual(
240
- 'photocrati-pope',
241
- $this->registry->get_product_meta('photocrati-pope', 'id'),
242
- 'get_product_meta() did not return the correct product ID meta-information'
243
- );
244
- $this->assertEqual(
245
- array(
246
- 'type' => 'product',
247
- 'id' => 'photocrati-pope',
248
- 'path' => $this->path . 'photocrati_pope/product.photocrati_pope.php',
249
- 'product-module-path' => $this->path . 'photocrati_pope/modules/'),
250
- $this->registry->get_product_meta_list('photocrati-pope'),
251
- 'get_product_meta_list() did not return the correct product meta-information'
252
- );
253
- }
254
-
255
- /**
256
- * Tests retrieval of module metadata
257
- */
258
- public function test_Registry_Get_Module()
259
- {
260
- // do we have the right module?
261
- $obj = $this->registry->get_module('photocrati-template');
262
- $this->assertEqual(
263
- 'M_Template',
264
- get_class($obj),
265
- 'get_module did not return a M_Template object'
266
- );
267
- $this->assertEqual(
268
- 'photocrati-template',
269
- $this->registry->get_module_meta('photocrati-template', 'id'),
270
- 'get_module_meta() did not return the correct module ID meta-information'
271
- );
272
- $this->assertEqual(
273
- array(
274
- 'type' => 'module',
275
- 'id' => 'photocrati-template',
276
- 'path' => $this->path . 'photocrati_pope/modules/template/module.template.php'),
277
- $this->registry->get_module_meta_list('photocrati-template'),
278
- 'get_module_meta_list did not return the correct module meta-information'
279
- );
280
- }
281
-
282
- /**
283
- * Tests module initialization
284
- */
285
- public function test_Registry_Initialization()
286
- {
287
- $obj = $this->registry->get_module('photocrati-template');
288
-
289
- // we're looking at the correct product and module, let's initialize() it
290
- $this->assertEqual(
291
- False,
292
- (isset($obj->is_initialized) && True == $obj->is_initialized),
293
- 'Module was initialized prematurely'
294
- );
295
-
296
- $this->registry->initialize_module('photocrati-template');
297
-
298
- $this->assertEqual(
299
- True,
300
- (isset($obj->is_initialized) && True == $obj->is_initialized),
301
- 'initialize_module() did not run correctly'
302
- );
303
- }
304
-
305
- /**
306
- * Tests get_utility and factory creation
307
- */
308
- public function test_Registry_Get_Utility()
309
- {
310
- /*
311
- * We must again retrieve the factory class after having loaded our products & module.
312
- */
313
- $factory = $this->registry->get_utility('I_Component_Factory');
314
- try
315
- {
316
- $obj = $factory->create('photocrati_template', 'Normal');
317
- } catch (Exception $exception) { }
318
- $this->assertEqual(
319
- 'C_Template_Library',
320
- (isset($obj) && get_class($obj)),
321
- 'create() did not return a C_Template_Library object'
322
- );
323
- }
324
-
325
- /**
326
- * Some sanity checks
327
- */
328
- public function test_Registry_Paranoid_Check()
329
- {
330
- // Just to be paranoid we check to make sure we still have ONLY loaded the Pope product / Template module
331
- $this->assertEqual(
332
- array(
333
- 0 => 'photocrati-pope'
334
- ),
335
- $this->registry->get_product_list(),
336
- 'A product was loaded that should not have been'
337
- );
338
- $this->assertEqual(
339
- array(
340
- 0 => 'photocrati-pope',
341
- 1 => 'photocrati-template'
342
- ),
343
- $this->registry->get_module_list(),
344
- 'A module was loaded that should not have been'
345
- );
346
- }
347
-
348
- /**
349
- * Tests loading of all remaining modules
350
- */
351
- public function test_Registry_Load_All()
352
- {
353
- // load the remaining (Animal/AnimalFarm) products & modules
354
- $this->registry->load_all_products();
355
- $this->registry->load_all_modules();
356
-
357
- $this->assertEqual(
358
- array(
359
- 0 => 'photocrati-pope',
360
- 1 => 'photocrati-animal'
361
- ),
362
- $this->registry->get_product_list(),
363
- 'load_all_products() did not run correctly (Animal product was not loaded)'
364
- );
365
- $this->assertEqual(
366
- array(
367
- 0 => 'photocrati-pope',
368
- 1 => 'photocrati-template',
369
- 2 => 'photocrati-animal',
370
- 3 => 'photocrati-animal-farm'
371
- ),
372
- $this->registry->get_module_list(),
373
- 'load_all_modules() did not run correctly (The Animal Farm module was not loaded)'
374
- );
375
-
376
- $obj = $this->registry->get_module('photocrati-animal-farm');
377
- $this->assertEqual(
378
- False,
379
- (isset($obj->is_initialized) && True == $obj->is_initialized),
380
- 'Module was initialized prematurely'
381
- );
382
-
383
- $this->registry->initialize_all_modules();
384
-
385
- $obj = $this->registry->get_module('photocrati-animal-farm');
386
- $this->assertEqual(
387
- True,
388
- (isset($obj->is_initialized) && True == $obj->is_initialized),
389
- 'initialize_all_modules() did not run correctly (Animal Farm module was not initialized)'
390
- );
391
- }
392
-
393
- /**
394
- * Tests SPL autoloader
395
- */
396
- public function test_Registry_Autoload()
397
- {
398
- /*
399
- * The C_Animal_Empty class exists but is never referenced elsewhere in the code. We call class_exists()
400
- * on it here to trigger the autoload() function which should have been automatically registered with the SPL.
401
- */
402
- $this->assertEqual(
403
- True,
404
- class_exists('C_Animal_Empty'),
405
- 'C_Animal_Empty was not found by autoload()'
406
- );
407
- }
408
-
409
- /**
410
- * Tests registry (add|del)_(module|product) functions
411
- */
412
- public function test_Registry_CD()
413
- {
414
- $tmp = new C_Test_Autoload();
415
-
416
- /*
417
- * We add our empty module created above and dynamically add it to to our registry
418
- */
419
- $this->assertEqual(
420
- True,
421
- in_array('C_Test_Autoload', $this->registry->get_module_list()),
422
- 'add_module() did not run correctly for C_Test_Autoload'
423
- );
424
-
425
- /*
426
- * We remove it just as easily
427
- */
428
- $this->registry->del_module('C_Test_Autoload');
429
- $this->assertEqual(
430
- False,
431
- in_array('C_Test_Autoload', $this->registry->get_module_list()),
432
- 'del_module() did not remove C_Test_Autoload from get_module_list()'
433
- );
434
-
435
- /*
436
- * We can also instantiate our products manually and then pass them to Pope
437
- */
438
- $this->registry->add_product('photocrati-empty', new P_Photocrati_Empty());
439
-
440
- $this->assertEqual(
441
- True,
442
- in_array('photocrati-empty', $this->registry->get_product_list()),
443
- 'add_product() did not add to the get_product_list() results'
444
- );
445
-
446
- $this->registry->del_product('photocrati-empty');
447
-
448
- $this->assertEqual(
449
- False,
450
- in_array('photocrati-empty', $this->registry->get_product_list()),
451
- 'del_product() did not remove from the get_product_list() results'
452
- );
453
- }
454
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
pope/tests/wrappers.php DELETED
@@ -1,106 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * Pope will let us extend it's reach to classes we normally wouldn't be able to. In this case we've created a shell
5
- * called "ThirdPartyLibrary". We're going to extend it to add our own functions; in this case we'll pretend to be
6
- * adding a newsletter on top of a forum library.
7
- */
8
- class ThirdPartyLibrary
9
- {
10
- public $forum_setup = False;
11
-
12
- public function setup_forum()
13
- {
14
- $this->forum_setup = True;
15
- }
16
- }
17
-
18
- class Mixin_Third_Party_Lib extends Mixin
19
- {
20
- function setup_newsletter()
21
- {
22
- $this->object->newsletter_setup = True;
23
- }
24
- }
25
-
26
- /*
27
- * Now that we have our library and our mixin we bring them together. We wrap our mixin to this class and then we wrap
28
- * our class to the third party library. Here we tell wrap() to use the _create_new() function as it returns
29
- * ThirdPartyLibrary instances.
30
- */
31
- class C_Third_Party_Lib_Wrapper extends ExtensibleObject
32
- {
33
- public function define()
34
- {
35
- $this->add_mixin('Mixin_Third_Party_Lib');
36
- $this->wrap('ThirdPartyLibrary', array(&$this, '_create_new'));
37
- }
38
-
39
- function _create_new()
40
- {
41
- return new ThirdPartyLibrary();
42
- }
43
- }
44
-
45
- class Test_Of_Wrappers extends UnitTestCase
46
- {
47
- public $str = 'test_string';
48
-
49
- public function test_Wrappers()
50
- {
51
- $obj = new C_Third_Party_Lib_Wrapper();
52
-
53
- $obj->setup_forum();
54
- $obj->setup_newsletter();
55
-
56
- $this->assertEqual(
57
- True,
58
- $obj->object->forum_setup,
59
- 'The wrapped class forum_setup() did not run'
60
- );
61
-
62
- $this->assertEqual(
63
- True,
64
- $obj->object->newsletter_setup,
65
- 'The mixin class setup_newsletter() did not run'
66
- );
67
-
68
- /*
69
- * Sometimes you need to know if you're dealing with a wrapper
70
- */
71
- $core = new C_Core('test_string');
72
- $this->assertEqual(
73
- True,
74
- $obj->is_wrapper(),
75
- 'is_wrapper() returned false on a wrapper'
76
- );
77
- $this->assertEqual(
78
- False,
79
- $core->is_wrapper(),
80
- 'is_wrapper() returned true on a non-wrapper'
81
- );
82
-
83
- /*
84
- * wrapped_class_provides() lets us determine if the function we are calling is from the original class
85
- * (ThirdPartyLib).
86
- */
87
- $this->assertEqual(
88
- True,
89
- $obj->wrapped_class_provides('setup_forum'),
90
- 'wrapped_class_provides() did not return True when it should have'
91
- );
92
-
93
- $this->assertEqual(
94
- False,
95
- $obj->wrapped_class_provides('setup_newsletter'),
96
- 'wrapped_class_provides() did not return False when it should have'
97
- );
98
-
99
- $this->assertEqual(
100
- False,
101
- $obj->wrapped_class_provides('does_not_exist'),
102
- 'wrapped_class_provides() did not return False on a non-existent method'
103
- );
104
- }
105
-
106
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
products/photocrati_nextgen/modules/attach_to_post/module.attach_to_post.php CHANGED
@@ -24,7 +24,7 @@ class M_Attach_To_Post extends C_Base_Module
24
  'photocrati-attach_to_post',
25
  'Attach To Post',
26
  'Provides the "Attach to Post" interface for displaying galleries and albums',
27
- '0.12',
28
  'https://www.imagely.com/wordpress-gallery-plugin/nextgen-gallery/',
29
  'Photocrati Media',
30
  'https://www.imagely.com',
24
  'photocrati-attach_to_post',
25
  'Attach To Post',
26
  'Provides the "Attach to Post" interface for displaying galleries and albums',
27
+ '0.14',
28
  'https://www.imagely.com/wordpress-gallery-plugin/nextgen-gallery/',
29
  'Photocrati Media',
30
  'https://www.imagely.com',
products/photocrati_nextgen/modules/attach_to_post/static/iframely.css CHANGED
@@ -4,6 +4,7 @@ html#iframely {
4
  }
5
 
6
  #iframely, #iframely body {
 
7
  padding: 0px;
8
  width: 100%;
9
  height: 100%;
4
  }
5
 
6
  #iframely, #iframely body {
7
+ background: white !important;
8
  padding: 0px;
9
  width: 100%;
10
  height: 100%;
products/photocrati_nextgen/modules/attach_to_post/static/iframely.min.css CHANGED
@@ -1 +1 @@
1
- html#iframely{background:white !important}#iframely,#iframely body{padding:0;width:100%;height:100%}#iframely{-ms-filter:"alpha(opacity=0)";filter:alpha(opacity=0);opacity:0;background-position:center center;background-repeat:no-repeat;position:absolute;visibility:hidden}#iframely #wpbody-content{float:none;padding:0}#iframely h2,#iframely #icon-nextgen-gallery{display:none}
1
+ html#iframely{background:white !important}#iframely,#iframely body{background:white !important;padding:0;width:100%;height:100%}#iframely{-ms-filter:"alpha(opacity=0)";filter:alpha(opacity=0);opacity:0;background-position:center center;background-repeat:no-repeat;position:absolute;visibility:hidden}#iframely #wpbody-content{float:none;padding:0}#iframely h2,#iframely #icon-nextgen-gallery{display:none}
products/photocrati_nextgen/modules/datamapper/module.datamapper.php CHANGED
@@ -14,7 +14,7 @@ class M_DataMapper extends C_Base_Module
14
  'photocrati-datamapper',
15
  'DataMapper',
16
  'Provides a database abstraction layer following the DataMapper pattern',
17
- '0.9',
18
  'https://www.imagely.com',
19
  'Photocrati Media',
20
  'https://www.imagely.com'
14
  'photocrati-datamapper',
15
  'DataMapper',
16
  'Provides a database abstraction layer following the DataMapper pattern',
17
+ '0.10',
18
  'https://www.imagely.com',
19
  'Photocrati Media',
20
  'https://www.imagely.com'
products/photocrati_nextgen/modules/datamapper/package.module.datamapper.php CHANGED
@@ -1412,34 +1412,37 @@ class Mixin_DataMapper_Driver_Base extends Mixin
1412
  }
1413
  return $stdObject;
1414
  }
1415
- public function strip_slashes($stdObject)
1416
- {
1417
- foreach (get_object_vars($stdObject) as $key => $value) {
1418
- if (is_string($value)) {
1419
- $stdObject->{$key} = str_replace('\\\'', '\'', str_replace('\\"', '"', str_replace('\\\\', '\\', $value)));
1420
- } elseif (is_object($value)) {
1421
- $stdObject->{$key} = $this->strip_slashes_deep($value);
1422
- } elseif (is_array($value)) {
1423
- $stdObject->{$key} = $this->strip_slashes_deep($value);
1424
- }
1425
- }
1426
- return $stdObject;
1427
- }
1428
- public function strip_slashes_deep($input)
1429
- {
1430
- $retval = $input;
1431
- if (is_object($input)) {
1432
- foreach (get_object_vars($input) as $key => $value) {
1433
- $retval->{$key} = $this->strip_slashes_deep($value);
1434
  }
1435
- } elseif (is_array($input)) {
1436
- foreach ($input as $key => $value) {
1437
- $retval[$key] = $this->strip_slashes_deep($value);
 
 
 
1438
  }
1439
- } elseif (is_string($input)) {
1440
- $retval = str_replace('\\\'', '\'', str_replace('\\"', '"', str_replace('\\\\', '\\', $input)));
1441
  }
1442
- return $retval;
 
 
 
 
1443
  }
1444
  /**
1445
  * Converts a stdObject entity to a model
1412
  }
1413
  return $stdObject;
1414
  }
1415
+ public function strip_slashes($stdObject_or_array_or_string)
1416
+ {
1417
+ /**
1418
+ * Some objects have properties that are recursive objects. To avoid this we have to keep track
1419
+ * of what objects we've already processed when we're running this method recursively
1420
+ */
1421
+ static $level = 0;
1422
+ static $processed_objects = array();
1423
+ $level++;
1424
+ $processed_objects[] = $stdObject_or_array_or_string;
1425
+ if (is_string($stdObject_or_array_or_string)) {
1426
+ $stdObject_or_array_or_string = str_replace('\\\'', '\'', str_replace('\\"', '"', str_replace('\\\\', '\\', $stdObject_or_array_or_string)));
1427
+ } elseif (is_object($stdObject_or_array_or_string) && !in_array($stdObject_or_array_or_string, $processed_objects)) {
1428
+ foreach (get_object_vars($stdObject_or_array_or_string) as $key => $val) {
1429
+ if ($val != $stdObject_or_array_or_string && $key != '_mapper') {
1430
+ $stdObject_or_array_or_string->{$key} = $this->strip_slashes($val);
1431
+ }
 
 
1432
  }
1433
+ $processed_objects[] = $stdObject_or_array_or_string;
1434
+ } elseif (is_array($stdObject_or_array_or_string)) {
1435
+ foreach ($stdObject_or_array_or_string as $key => $val) {
1436
+ if ($key != '_mixins') {
1437
+ $stdObject_or_array_or_string[$key] = $this->strip_slashes($val);
1438
+ }
1439
  }
 
 
1440
  }
1441
+ $level--;
1442
+ if ($level == 0) {
1443
+ $processed_objects = array();
1444
+ }
1445
+ return $stdObject_or_array_or_string;
1446
  }
1447
  /**
1448
  * Converts a stdObject entity to a model
products/photocrati_nextgen/modules/lightbox/module.lightbox.php CHANGED
@@ -16,7 +16,7 @@ class M_Lightbox extends C_Base_Module
16
  'photocrati-lightbox',
17
  'Lightbox',
18
  "Provides integration with several JavaScript lightbox effect libraries",
19
- '0.15',
20
  'http://leandrovieira.com/projects/jquery/lightbox/',
21
  'Photocrati Media',
22
  'https://www.imagely.com'
@@ -49,7 +49,8 @@ class M_Lightbox extends C_Base_Module
49
  {
50
  return array(
51
  'C_Lightbox_Installer' => 'class.lightbox_legacy_installer.php',
52
- 'C_Lightbox_Library_Manager' => 'class.lightbox_library_manager.php'
 
53
  );
54
  }
55
  }
16
  'photocrati-lightbox',
17
  'Lightbox',
18
  "Provides integration with several JavaScript lightbox effect libraries",
19
+ '0.16',
20
  'http://leandrovieira.com/projects/jquery/lightbox/',
21
  'Photocrati Media',
22
  'https://www.imagely.com'
49
  {
50
  return array(
51
  'C_Lightbox_Installer' => 'class.lightbox_legacy_installer.php',
52
+ 'C_Lightbox_Library_Manager' => 'class.lightbox_library_manager.php',
53
+ 'C_NGG_Lightbox' => 'class.ngg_lightbox.php'
54
  );
55
  }
56
  }
products/photocrati_nextgen/modules/lightbox/package.module.lightbox.php CHANGED
@@ -14,16 +14,9 @@ class C_Lightbox_Installer
14
  }
15
  public function install_lightbox($name, $title, $code, $stylesheet_paths = array(), $script_paths = array(), $values = array(), $i18n = array())
16
  {
17
- $lightbox = new stdClass();
18
- $lightbox->name = $name;
19
- $lightbox->title = $title;
20
- $lightbox->code = $code;
21
- $lightbox->values = $values;
22
- $lightbox->i18n = $i18n;
23
- $lightbox->styles = implode('
24
- ', $stylesheet_paths);
25
- $lightbox->scripts = implode('
26
- ', $script_paths);
27
  C_Lightbox_Library_Manager::get_instance()->register($name, $lightbox);
28
  }
29
  }
@@ -49,18 +42,18 @@ class C_Lightbox_Library_Manager
49
  $fs = C_Fs::get_instance();
50
  $router = C_Router::get_instance();
51
  // Add none as an option
52
- $none = new stdClass();
53
  $none->title = __('None', 'nggallery');
54
  $this->register('none', $none);
55
  // Add Fancybox
56
- $fancybox = new stdClass();
57
  $fancybox->title = __('Fancybox', 'nggallery');
58
  $fancybox->code = 'class="ngg-fancybox" rel="%GALLERY_NAME%"';
59
  $fancybox->styles = array('photocrati-lightbox#fancybox/jquery.fancybox-1.3.4.css');
60
  $fancybox->scripts = array('photocrati-lightbox#fancybox/jquery.easing-1.3.pack.js', 'photocrati-lightbox#fancybox/jquery.fancybox-1.3.4.pack.js', 'photocrati-lightbox#fancybox/nextgen_fancybox_init.js');
61
  $this->register('fancybox', $fancybox);
62
  // Add Shutter
63
- $shutter = new stdClass();
64
  $shutter->title = __('Shutter', 'nggallery');
65
  $shutter->code = 'class="shutterset_%GALLERY_NAME%"';
66
  $shutter->styles = array('photocrati-lightbox#shutter/shutter.css');
@@ -68,7 +61,7 @@ class C_Lightbox_Library_Manager
68
  $shutter->values = array('nextgen_shutter_i18n' => array('msgLoading' => __('L O A D I N G', 'nggallery'), 'msgClose' => __('Click to Close', 'nggallery')));
69
  $this->register('shutter', $shutter);
70
  // Add shutter reloaded
71
- $shutter2 = new stdClass();
72
  $shutter2->title = __('Shutter Reloaded', 'nggallery');
73
  $shutter2->code = 'class="shutterset_%GALLERY_NAME%"';
74
  $shutter2->styles = array('photocrati-lightbox#shutter_reloaded/shutter.css');
@@ -76,7 +69,7 @@ class C_Lightbox_Library_Manager
76
  $shutter2->values = array('nextgen_shutter2_i18n' => array(__('Previous', 'nggallery'), __('Next', 'nggallery'), __('Close', 'nggallery'), __('Full Size', 'nggallery'), __('Fit to Screen', 'nggallery'), __('Image', 'nggallery'), __('of', 'nggallery'), __('Loading...', 'nggallery')));
77
  $this->register('shutter2', $shutter2);
78
  // Add Thickbox
79
- $thickbox = new stdClass();
80
  $thickbox->title = __('Thickbox', 'nggallery');
81
  $thickbox->code = 'class=\'thickbox\' rel=\'%GALLERY_NAME%\'';
82
  $thickbox->styles = array('wordpress#thickbox');
@@ -86,7 +79,7 @@ class C_Lightbox_Library_Manager
86
  // Allow third parties to integrate
87
  do_action('ngg_registered_default_lightboxes');
88
  // Add custom option
89
- $custom = new stdClass();
90
  $custom->title = __('Custom', 'nggallery');
91
  $custom->code = $settings->thumbEffectCode;
92
  $custom->styles = $settings->thumbEffectStyles;
@@ -208,7 +201,8 @@ class C_Lightbox_Library_Manager
208
  for ($i = 0; $i < count($lightbox->styles); $i++) {
209
  $src = $lightbox->styles[$i];
210
  if (strpos($src, 'wordpress#') === 0) {
211
- wp_enqueue_style(@array_pop(explode('wordpress#', $src)));
 
212
  } else {
213
  if (!empty($src)) {
214
  wp_enqueue_style($lightbox->name . "-{$i}", $this->_handle_url($src), FALSE, NGG_SCRIPT_VERSION);
@@ -220,8 +214,8 @@ class C_Lightbox_Library_Manager
220
  $src = $lightbox->scripts[$i];
221
  $handle = $lightbox->name . "-{$i}";
222
  if (strpos($src, 'wordpress#') === 0) {
223
- $handle = @array_pop(explode('wordpress#', $src));
224
- wp_enqueue_script($handle);
225
  } else {
226
  if (!empty($src)) {
227
  wp_enqueue_script($handle, $this->_handle_url($src), array('ngg_lightbox_context'), NGG_SCRIPT_VERSION, TRUE);
@@ -296,4 +290,41 @@ class C_Lightbox_Library_Manager
296
  $this->_lightboxes = array();
297
  $this->_registered_defaults = FALSE;
298
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
299
  }
14
  }
15
  public function install_lightbox($name, $title, $code, $stylesheet_paths = array(), $script_paths = array(), $values = array(), $i18n = array())
16
  {
17
+ $lightbox = new C_NGG_Lightbox($name, array('title' => $title, 'code' => $code, 'styles' => is_array($stylesheet_paths) ? implode('
18
+ ', $stylesheet_paths) : $stylesheet_paths, 'scripts' => is_array($script_paths) ? implode('
19
+ ', $script_paths) : $script_paths, 'values' => $values, 'i18n' => $i18n));
 
 
 
 
 
 
 
20
  C_Lightbox_Library_Manager::get_instance()->register($name, $lightbox);
21
  }
22
  }
42
  $fs = C_Fs::get_instance();
43
  $router = C_Router::get_instance();
44
  // Add none as an option
45
+ $none = new C_NGG_Lightbox('none');
46
  $none->title = __('None', 'nggallery');
47
  $this->register('none', $none);
48
  // Add Fancybox
49
+ $fancybox = new C_NGG_Lightbox('fancybox');
50
  $fancybox->title = __('Fancybox', 'nggallery');
51
  $fancybox->code = 'class="ngg-fancybox" rel="%GALLERY_NAME%"';
52
  $fancybox->styles = array('photocrati-lightbox#fancybox/jquery.fancybox-1.3.4.css');
53
  $fancybox->scripts = array('photocrati-lightbox#fancybox/jquery.easing-1.3.pack.js', 'photocrati-lightbox#fancybox/jquery.fancybox-1.3.4.pack.js', 'photocrati-lightbox#fancybox/nextgen_fancybox_init.js');
54
  $this->register('fancybox', $fancybox);
55
  // Add Shutter
56
+ $shutter = new C_NGG_Lightbox('shutter');
57
  $shutter->title = __('Shutter', 'nggallery');
58
  $shutter->code = 'class="shutterset_%GALLERY_NAME%"';
59
  $shutter->styles = array('photocrati-lightbox#shutter/shutter.css');
61
  $shutter->values = array('nextgen_shutter_i18n' => array('msgLoading' => __('L O A D I N G', 'nggallery'), 'msgClose' => __('Click to Close', 'nggallery')));
62
  $this->register('shutter', $shutter);
63
  // Add shutter reloaded
64
+ $shutter2 = new C_NGG_Lightbox('shutter2');
65
  $shutter2->title = __('Shutter Reloaded', 'nggallery');
66
  $shutter2->code = 'class="shutterset_%GALLERY_NAME%"';
67
  $shutter2->styles = array('photocrati-lightbox#shutter_reloaded/shutter.css');
69
  $shutter2->values = array('nextgen_shutter2_i18n' => array(__('Previous', 'nggallery'), __('Next', 'nggallery'), __('Close', 'nggallery'), __('Full Size', 'nggallery'), __('Fit to Screen', 'nggallery'), __('Image', 'nggallery'), __('of', 'nggallery'), __('Loading...', 'nggallery')));
70
  $this->register('shutter2', $shutter2);
71
  // Add Thickbox
72
+ $thickbox = new C_NGG_Lightbox('thickbox');
73
  $thickbox->title = __('Thickbox', 'nggallery');
74
  $thickbox->code = 'class=\'thickbox\' rel=\'%GALLERY_NAME%\'';
75
  $thickbox->styles = array('wordpress#thickbox');
79
  // Allow third parties to integrate
80
  do_action('ngg_registered_default_lightboxes');
81
  // Add custom option
82
+ $custom = new C_NGG_Lightbox('custom');
83
  $custom->title = __('Custom', 'nggallery');
84
  $custom->code = $settings->thumbEffectCode;
85
  $custom->styles = $settings->thumbEffectStyles;
201
  for ($i = 0; $i < count($lightbox->styles); $i++) {
202
  $src = $lightbox->styles[$i];
203
  if (strpos($src, 'wordpress#') === 0) {
204
+ $parts = explode('wordpress#', $src);
205
+ wp_enqueue_style(array_pop($parts));
206
  } else {
207
  if (!empty($src)) {
208
  wp_enqueue_style($lightbox->name . "-{$i}", $this->_handle_url($src), FALSE, NGG_SCRIPT_VERSION);
214
  $src = $lightbox->scripts[$i];
215
  $handle = $lightbox->name . "-{$i}";
216
  if (strpos($src, 'wordpress#') === 0) {
217
+ $parts = explode('wordpress#', $src);
218
+ wp_enqueue_script(array_pop($parts));
219
  } else {
220
  if (!empty($src)) {
221
  wp_enqueue_script($handle, $this->_handle_url($src), array('ngg_lightbox_context'), NGG_SCRIPT_VERSION, TRUE);
290
  $this->_lightboxes = array();
291
  $this->_registered_defaults = FALSE;
292
  }
293
+ }
294
+ /**
295
+ * Represents a lightbox available in NextGEN Gallery
296
+ * Class C_NGG_Lightbox
297
+ */
298
+ class C_NGG_Lightbox extends C_Component
299
+ {
300
+ public function define($context = FALSE, $properties = array())
301
+ {
302
+ parent::define($context);
303
+ $this->add_mixin('Mixin_NGG_Lightbox_Instance_Methods');
304
+ $this->implement('I_Lightbox');
305
+ }
306
+ public function initialize($name = '', $properties = array())
307
+ {
308
+ parent::initialize($name);
309
+ $properties['name'] = $name;
310
+ foreach ($properties as $k => $v) {
311
+ $this->{$k} = $v;
312
+ }
313
+ }
314
+ }
315
+ class Mixin_NGG_Lightbox_Instance_Methods extends Mixin
316
+ {
317
+ /**
318
+ * Returns true/false whether or not the lightbox supports displaying entities from the displayed gallery object
319
+ * @param $displayed_gallery. By default, lightboxes don't support albums
320
+ * @return bool
321
+ */
322
+ public function is_supported($displayed_gallery)
323
+ {
324
+ $retval = TRUE;
325
+ if (in_array($displayed_gallery->source, array('album', 'albums')) && !isset($displayed_gallery->display_settings['open_gallery_in_lightbox'])) {
326
+ $retval = FALSE;
327
+ }
328
+ return $retval;
329
+ }
330
  }
products/photocrati_nextgen/modules/nextgen_basic_album/module.nextgen_basic_album.php CHANGED
@@ -18,7 +18,7 @@ class M_NextGen_Basic_Album extends C_Base_Module
18
  'photocrati-nextgen_basic_album',
19
  'NextGEN Basic Album',
20
  "Provides support for NextGEN's Basic Album",
21
- '0.12',
22
  'https://www.imagely.com/wordpress-gallery-plugin/nextgen-gallery/',
23
  'Photocrati Media',
24
  'https://www.imagely.com'
18
  'photocrati-nextgen_basic_album',
19
  'NextGEN Basic Album',
20
  "Provides support for NextGEN's Basic Album",
21
+ '0.13',
22
  'https://www.imagely.com/wordpress-gallery-plugin/nextgen-gallery/',
23
  'Photocrati Media',
24
  'https://www.imagely.com'
products/photocrati_nextgen/modules/nextgen_basic_album/package.module.nextgen_basic_album.php CHANGED
@@ -291,6 +291,10 @@ class A_NextGen_Basic_Album_Controller extends Mixin_NextGen_Basic_Pagination
291
  */
292
  public function index_action($displayed_gallery, $return = FALSE)
293
  {
 
 
 
 
294
  $display_settings = $displayed_gallery->display_settings;
295
  // We need to fetch the album containers selected in the Attach
296
  // to Post interface. We need to do this, because once we fetch the
@@ -383,6 +387,27 @@ class A_NextGen_Basic_Album_Controller extends Mixin_NextGen_Basic_Pagination
383
  $params['pagination'] = $pagination_result['output'];
384
  $params['image_gen_params'] = $albums['image_gen_params'];
385
  $params['galleries'] = $albums['galleries'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
386
  $params['displayed_gallery'] = $displayed_gallery;
387
  $params = $this->object->prepare_display_parameters($displayed_gallery, $params);
388
  switch ($displayed_gallery->display_type) {
@@ -461,6 +486,8 @@ class A_NextGen_Basic_Album_Controller extends Mixin_NextGen_Basic_Pagination
461
  $gallery->previewurl = '';
462
  if ($gallery->previewpic && $gallery->previewpic > 0) {
463
  if ($image = $image_mapper->find(intval($gallery->previewpic))) {
 
 
464
  $gallery->previewurl = $storage->get_image_url($image, $image_gen->get_size_name($image_gen_params), TRUE);
465
  $gallery->previewname = $gallery->name;
466
  }
@@ -549,6 +576,7 @@ class A_NextGen_Basic_Album_Mapper extends Mixin
549
  $this->object->_set_default_value($entity, 'settings', 'disable_pagination', 0);
550
  $this->object->_set_default_value($entity, 'settings', 'enable_descriptions', 0);
551
  $this->object->_set_default_value($entity, 'settings', 'template', '');
 
552
  // Thumbnail dimensions -- only used by extended albums
553
  if ($entity->name == NGG_BASIC_EXTENDED_ALBUM) {
554
  $this->_set_default_value($entity, 'settings', 'override_thumbnail_settings', 0);
291
  */
292
  public function index_action($displayed_gallery, $return = FALSE)
293
  {
294
+ // Ensure that the open_gallery_in_lightbox setting is present
295
+ if (!array_key_exists('open_gallery_in_lightbox', $displayed_gallery->display_settings)) {
296
+ $displayed_gallery->display_settings['open_gallery_in_lightbox'] = 0;
297
+ }
298
  $display_settings = $displayed_gallery->display_settings;
299
  // We need to fetch the album containers selected in the Attach
300
  // to Post interface. We need to do this, because once we fetch the
387
  $params['pagination'] = $pagination_result['output'];
388
  $params['image_gen_params'] = $albums['image_gen_params'];
389
  $params['galleries'] = $albums['galleries'];
390
+ foreach ($params['galleries'] as &$gallery) {
391
+ $gallery->entity_type = isset($gallery->is_gallery) && intval($gallery->is_gallery) ? 'gallery' : 'album';
392
+ // If we're to open a gallery in a lightbox, we need to expose it to the lightbox
393
+ // as a displayed gallery
394
+ if (isset($params['open_gallery_in_lightbox']) && $gallery->entity_type == 'gallery') {
395
+ $gallery->displayed_gallery = new C_Displayed_Gallery();
396
+ $gallery->displayed_gallery->container_ids = array($gallery->{$gallery->id_field});
397
+ $gallery->displayed_gallery->display_settings = $displayed_gallery->display_settings;
398
+ $gallery->displayed_gallery->returns = 'included';
399
+ $gallery->displayed_gallery->source = 'galleries';
400
+ $gallery->displayed_gallery->images_list_count = $gallery->displayed_gallery->get_entity_count();
401
+ $gallery->displayed_gallery->is_album_gallery = TRUE;
402
+ $gallery->displayed_gallery->to_transient();
403
+ if ($this->does_lightbox_support_displayed_gallery($displayed_gallery)) {
404
+ $gallery->displayed_gallery->effect_code = $this->object->get_effect_code($gallery->displayed_gallery);
405
+ }
406
+ // Add "galleries.gallery_1 = {};"
407
+ $this->object->_add_script_data('ngg_common', 'galleries.gallery_' . $gallery->displayed_gallery->id(), (array) $gallery->displayed_gallery->get_entity(), FALSE);
408
+ $this->object->_add_script_data('ngg_common', 'galleries.gallery_' . $gallery->displayed_gallery->id() . '.wordpress_page_root', get_permalink(), FALSE);
409
+ }
410
+ }
411
  $params['displayed_gallery'] = $displayed_gallery;
412
  $params = $this->object->prepare_display_parameters($displayed_gallery, $params);
413
  switch ($displayed_gallery->display_type) {
486
  $gallery->previewurl = '';
487
  if ($gallery->previewpic && $gallery->previewpic > 0) {
488
  if ($image = $image_mapper->find(intval($gallery->previewpic))) {
489
+ $gallery->previewpic_image = $image;
490
+ $gallery->previewpic_fullsized_url = $storage->get_image_url($image, 'full');
491
  $gallery->previewurl = $storage->get_image_url($image, $image_gen->get_size_name($image_gen_params), TRUE);
492
  $gallery->previewname = $gallery->name;
493
  }
576
  $this->object->_set_default_value($entity, 'settings', 'disable_pagination', 0);
577
  $this->object->_set_default_value($entity, 'settings', 'enable_descriptions', 0);
578
  $this->object->_set_default_value($entity, 'settings', 'template', '');
579
+ $this->object->_set_default_value($entity, 'settings', 'open_gallery_in_lightbox', 0);
580
  // Thumbnail dimensions -- only used by extended albums
581
  if ($entity->name == NGG_BASIC_EXTENDED_ALBUM) {
582
  $this->_set_default_value($entity, 'settings', 'override_thumbnail_settings', 0);
products/photocrati_nextgen/modules/nextgen_basic_album/templates/compact.php CHANGED
@@ -4,11 +4,30 @@
4
  <div class="ngg-album-compact">
5
  <div class="ngg-album-compactbox">
6
  <div class="ngg-album-link">
7
- <a class="Link gallery_link" href="<?php echo nextgen_esc_url($gallery->pagelink); ?>">
8
- <img class="Thumb"
9
- alt="<?php echo esc_attr($gallery->title); ?>"
10
- src="<?php echo nextgen_esc_url($gallery->previewurl); ?>"/>
11
- </a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  </div>
13
  </div>
14
  <?php if (!empty($image_gen_params)) {
4
  <div class="ngg-album-compact">
5
  <div class="ngg-album-compactbox">
6
  <div class="ngg-album-link">
7
+ <?php $this->start_element('nextgen_gallery.album_gallery', 'item', $gallery); ?>
8
+ <?php if ($open_gallery_in_lightbox AND $gallery->entity_type == 'gallery'): ?>
9
+ <a
10
+ <?php echo $gallery->displayed_gallery->effect_code ?>
11
+ href="<?php echo esc_attr($gallery->previewpic_fullsized_url)?>"
12
+ data-fullsize="<?php echo esc_attr($gallery->previewpic_fullsized_url) ?>"
13
+ data-src="<?php echo esc_attr($gallery->previewpic_fullsized_url) ?>"
14
+ data-thumbnail="<?php echo esc_attr($gallery->previewurl)?>"
15
+ data-title="<?php echo esc_attr($gallery->previewpic_image->alttext)?>"
16
+ data-description="<?php echo esc_attr(stripslashes($gallery->previewpic_image->description))?>"
17
+ data-image-id="<?php echo esc_attr($gallery->previewpic)?>"
18
+ >
19
+ <img class="Thumb"
20
+ alt="<?php echo esc_attr($gallery->title); ?>"
21
+ src="<?php echo nextgen_esc_url($gallery->previewurl); ?>"/>
22
+ </a>
23
+ <?php else: ?>
24
+ <a class="Link gallery_link" href="<?php echo nextgen_esc_url($gallery->pagelink); ?>">
25
+ <img class="Thumb"
26
+ alt="<?php echo esc_attr($gallery->title); ?>"
27
+ src="<?php echo nextgen_esc_url($gallery->previewurl); ?>"/>
28
+ </a>
29
+ <?php endif ?>
30
+ <?php $this->end_element(); ?>
31
  </div>
32
  </div>
33
  <?php if (!empty($image_gen_params)) {
products/photocrati_nextgen/modules/nextgen_basic_album/templates/extended.php CHANGED
@@ -7,7 +7,33 @@
7
  </div>
8
  <div class="ngg-albumcontent">
9
  <div class="ngg-thumbnail">
10
- <a class="gallery_link" href="<?php echo nextgen_esc_url($gallery->pagelink); ?>"><img class="Thumb" alt="<?php echo esc_attr($gallery->title); ?>" src="<?php echo nextgen_esc_url($gallery->previewurl); ?>"/></a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  </div>
12
  <div class="ngg-description">
13
  <p><?php echo_safe_html($gallery->galdesc); ?></p>
7
  </div>
8
  <div class="ngg-albumcontent">
9
  <div class="ngg-thumbnail">
10
+ <?php if ($open_gallery_in_lightbox AND $gallery->entity_type == 'gallery'): ?>
11
+ <a
12
+ <?php echo $gallery->displayed_gallery->effect_code ?>
13
+ href="<?php echo esc_attr($gallery->previewpic_fullsized_url)?>"
14
+ data-fullsize="<?php echo esc_attr($gallery->previewpic_fullsized_url) ?>"
15
+ data-src="http://sandbox.dev/wp-content/gallery/wood-cutting/DSC_0236.JPG"
16
+ data-thumbnail="<?php echo esc_attr($gallery->previewurl)?>"
17
+ data-title="<?php echo esc_attr($gallery->previewpic_image->alttext)?>"
18
+ data-description="<?php echo esc_attr(stripslashes($gallery->previewpic_image->description))?>"
19
+ data-image-id="<?php echo esc_attr($gallery->previewpic)?>"
20
+ >
21
+ <img class="Thumb"
22
+ alt="<?php echo esc_attr($gallery->title); ?>"
23
+ src="<?php echo nextgen_esc_url($gallery->previewurl); ?>"/>
24
+ </a>
25
+ <?php else: ?>
26
+ <a
27
+ class="gallery_link"
28
+ href="<?php echo nextgen_esc_url($gallery->pagelink); ?>"
29
+ >
30
+ <img
31
+ class="Thumb"
32
+ alt="<?php echo esc_attr($gallery->title); ?>"
33
+ src="<?php echo nextgen_esc_url($gallery->previewurl); ?>"
34
+ />
35
+ </a>
36
+ <?php endif ?>
37
  </div>
38
  <div class="ngg-description">
39
  <p><?php echo_safe_html($gallery->galdesc); ?></p>
products/photocrati_nextgen/modules/nextgen_basic_gallery/module.nextgen_basic_gallery.php CHANGED
@@ -25,7 +25,7 @@ class M_NextGen_Basic_Gallery extends C_Base_Module
25
  'photocrati-nextgen_basic_gallery',
26
  'NextGEN Basic Gallery',
27
  "Provides NextGEN Gallery's basic thumbnail/slideshow integrated gallery",
28
- '0.14',
29
  'https://www.imagely.com/wordpress-gallery-plugin/nextgen-gallery/',
30
  'Photocrati Media',
31
  'https://www.imagely.com'
25
  'photocrati-nextgen_basic_gallery',
26
  'NextGEN Basic Gallery',
27
  "Provides NextGEN Gallery's basic thumbnail/slideshow integrated gallery",
28
+ '0.15',
29
  'https://www.imagely.com/wordpress-gallery-plugin/nextgen-gallery/',
30
  'Photocrati Media',
31
  'https://www.imagely.com'
products/photocrati_nextgen/modules/nextgen_basic_gallery/static/thumbnails/nextgen_basic_thumbnails.css CHANGED
@@ -16,7 +16,7 @@
16
 
17
  .ngg-gallery-thumbnail-box {
18
  float: left;
19
- margin-right: 5px;
20
  }
21
 
22
  .ngg-template-caption .ngg-gallery-thumbnail-box {
@@ -24,17 +24,32 @@
24
  }
25
 
26
  .ngg-gallery-thumbnail {
27
- float: left;
28
  text-align: center;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  }
30
 
31
  .ngg-gallery-thumbnail img {
32
- background-color: #FFFFFF;
33
- border: 1px solid #A9A9A9;
34
  display: block;
35
- margin: 4px 0px 4px 4px;
36
- padding: 4px;
37
  position: relative;
 
 
38
  }
39
 
40
  .ngg-gallery-thumbnail img:hover {
16
 
17
  .ngg-gallery-thumbnail-box {
18
  float: left;
19
+ max-width: 100% !important;
20
  }
21
 
22
  .ngg-template-caption .ngg-gallery-thumbnail-box {
24
  }
25
 
26
  .ngg-gallery-thumbnail {
 
27
  text-align: center;
28
+ max-width: 100% !important;
29
+ background-color: #FFFFFF;
30
+ border: 1px solid #A9A9A9;
31
+ margin-right: 5px;
32
+ margin: 5px;
33
+ }
34
+
35
+ .ngg-template-caption .ngg-gallery-thumbnail {
36
+ margin-right: 0px;
37
+ }
38
+
39
+ .ngg-gallery-thumbnail a {
40
+ display: block;
41
+ margin: 4px;
42
+ border: none;
43
+ box-shadow: none;
44
  }
45
 
46
  .ngg-gallery-thumbnail img {
 
 
47
  display: block;
48
+ margin: 0;
49
+ padding: 0;
50
  position: relative;
51
+ max-width: 100% !important;
52
+ height: auto;
53
  }
54
 
55
  .ngg-gallery-thumbnail img:hover {
products/photocrati_nextgen/modules/nextgen_basic_gallery/static/thumbnails/nextgen_basic_thumbnails.min.css CHANGED
@@ -1 +1 @@
1
- .ngg-galleryoverview{overflow:hidden;margin-top:10px;width:100%;clear:both;display:block !important}.ngg-galleryoverview .desc{margin:0 10px 10px 0;padding:5px}.ngg-gallery-thumbnail-box{float:left;margin-right:5px}.ngg-template-caption .ngg-gallery-thumbnail-box{margin-right:0}.ngg-gallery-thumbnail{float:left;text-align:center}.ngg-gallery-thumbnail img{background-color:#fff;border:1px solid #a9a9a9;display:block;margin:4px 0 4px 4px;padding:4px;position:relative}.ngg-gallery-thumbnail img:hover{background-color:#a9a9a9}.ngg-gallery-thumbnail span{font-size:90%;padding-left:5px;display:block}.ngg-galleryoverview ul li:before{content:'' !important}.ngg-gallery-list{list-style-type:none;padding:0 !important;text-indent:0 !important}.ngg-galleryoverview div.pic img{width:100%;border:0;border-radius:0}.ngg-gallery-list li{float:left;margin:0 2px 0 2px !important;overflow:hidden}.ngg-gallery-list li a{border:1px solid #ccc;display:block;padding:2px}.ngg-gallery-list li.selected a{-moz-background-inline-policy:continuous;-moz-background-origin:padding;background:#000 none repeat scroll 0 0}.ngg-gallery-list li img{height:40px;width:40px}li.ngg-next,li.ngg-prev{height:40px;width:40px;font-size:3.5em}li.ngg-next a,li.ngg-prev a{padding-top:10px;border:0;text-decoration:none}
1
+ .ngg-galleryoverview{overflow:hidden;margin-top:10px;width:100%;clear:both;display:block !important}.ngg-galleryoverview .desc{margin:0 10px 10px 0;padding:5px}.ngg-gallery-thumbnail-box{float:left;max-width:100% !important}.ngg-template-caption .ngg-gallery-thumbnail-box{margin-right:0}.ngg-gallery-thumbnail{text-align:center;max-width:100% !important;background-color:#fff;border:1px solid #a9a9a9;margin-right:5px;margin:5px}.ngg-template-caption .ngg-gallery-thumbnail{margin-right:0}.ngg-gallery-thumbnail a{display:block;margin:4px;border:0;box-shadow:none}.ngg-gallery-thumbnail img{display:block;margin:0;padding:0;position:relative;max-width:100% !important;height:auto}.ngg-gallery-thumbnail img:hover{background-color:#a9a9a9}.ngg-gallery-thumbnail span{font-size:90%;padding-left:5px;display:block}.ngg-galleryoverview ul li:before{content:'' !important}.ngg-gallery-list{list-style-type:none;padding:0 !important;text-indent:0 !important}.ngg-galleryoverview div.pic img{width:100%;border:0;border-radius:0}.ngg-gallery-list li{float:left;margin:0 2px 0 2px !important;overflow:hidden}.ngg-gallery-list li a{border:1px solid #ccc;display:block;padding:2px}.ngg-gallery-list li.selected a{-moz-background-inline-policy:continuous;-moz-background-origin:padding;background:#000 none repeat scroll 0 0}.ngg-gallery-list li img{height:40px;width:40px}li.ngg-next,li.ngg-prev{height:40px;width:40px;font-size:3.5em}li.ngg-next a,li.ngg-prev a{padding-top:10px;border:0;text-decoration:none}
products/photocrati_nextgen/modules/nextgen_basic_gallery/templates/thumbnails/index.php CHANGED
@@ -55,7 +55,7 @@ $this->start_element('nextgen_gallery.gallery_container', 'container', $displaye
55
  src="<?php echo esc_attr($storage->get_image_url($image, $thumbnail_size_name, TRUE))?>"
56
  width="<?php echo esc_attr($thumb_size['width'])?>"
57
  height="<?php echo esc_attr($thumb_size['height'])?>"
58
- style="max-width:none;"
59
  />
60
  </a>
61
  </div>
55
  src="<?php echo esc_attr($storage->get_image_url($image, $thumbnail_size_name, TRUE))?>"
56
  width="<?php echo esc_attr($thumb_size['width'])?>"
57
  height="<?php echo esc_attr($thumb_size['height'])?>"
58
+ style="max-width:100%;"
59
  />
60
  </a>
61
  </div>
products/photocrati_nextgen/modules/nextgen_data/module.nextgen_data.php CHANGED
@@ -15,7 +15,7 @@ class M_NextGen_Data extends C_Base_Module
15
  'photocrati-nextgen-data',
16
  'NextGEN Data Tier',
17
  "Provides a data tier for NextGEN gallery based on the DataMapper module",
18
- '0.11',
19
  'https://www.imagely.com',
20
  'Photocrati Media',
21
  'https://www.imagely.com'
15
  'photocrati-nextgen-data',
16
  'NextGEN Data Tier',
17
  "Provides a data tier for NextGEN gallery based on the DataMapper module",
18
+ '0.12',
19
  'https://www.imagely.com',
20
  'Photocrati Media',
21
  'https://www.imagely.com'
products/photocrati_nextgen/modules/nextgen_data/package.module.nextgen_data.php CHANGED
@@ -2005,9 +2005,11 @@ class Mixin_Gallery_Image_Mapper extends Mixin
2005
  $gallery_id = $gallery->{$key};
2006
  }
2007
  }
 
 
2008
  }
2009
  if ($gallery_id) {
2010
- $retval = $this->object->select()->where(array('galleryid = %s'), $gallery_id)->run_query(FALSE, $model);
2011
  }
2012
  return $retval;
2013
  }
2005
  $gallery_id = $gallery->{$key};
2006
  }
2007
  }
2008
+ } elseif (is_numeric($gallery)) {
2009
+ $gallery_id = $gallery;
2010
  }
2011
  if ($gallery_id) {
2012
+ $retval = $this->object->select()->where(array('galleryid = %s', $gallery_id))->run_query(FALSE, $model);
2013
  }
2014
  return $retval;
2015
  }
products/photocrati_nextgen/modules/nextgen_gallery_display/module.nextgen_gallery_display.php CHANGED
@@ -22,7 +22,7 @@ class M_Gallery_Display extends C_Base_Module
22
  'photocrati-nextgen_gallery_display',
23
  'Gallery Display',
24
  'Provides the ability to display gallery of images',
25
- '0.13',
26
  'https://www.imagely.com',
27
  'Photocrati Media',
28
  'https://www.imagely.com'
22
  'photocrati-nextgen_gallery_display',
23
  'Gallery Display',
24
  'Provides the ability to display gallery of images',
25
+ '0.14',
26
  'https://www.imagely.com',
27
  'Photocrati Media',
28
  'https://www.imagely.com'
products/photocrati_nextgen/modules/nextgen_gallery_display/package.module.nextgen_gallery_display.php CHANGED
@@ -313,6 +313,26 @@ class Mixin_Display_Type_Controller extends Mixin
313
  {
314
  return NULL;
315
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
316
  /**
317
  * Returns the effect HTML code for the displayed gallery
318
  * @param type $displayed_gallery
@@ -321,12 +341,14 @@ class Mixin_Display_Type_Controller extends Mixin
321
  {
322
  $retval = '';
323
  if ($lightbox = C_Lightbox_Library_Manager::get_instance()->get_selected()) {
324
- $retval = $lightbox->code;
325
- $retval = str_replace('%GALLERY_ID%', $displayed_gallery->id(), $retval);
326
- $retval = str_replace('%GALLERY_NAME%', $displayed_gallery->id(), $retval);
327
- global $post;
328
- if ($post && isset($post->ID) && $post->ID) {
329
- $retval = str_replace('%PAGE_ID%', $post->ID, $retval);
 
 
330
  }
331
  }
332
  // allow for customization
313
  {
314
  return NULL;
315
  }
316
+ public function does_lightbox_support_displayed_gallery($displayed_gallery, $lightbox = NULL)
317
+ {
318
+ if (!$lightbox) {
319
+ $lightbox = C_Lightbox_Library_Manager::get_instance()->get_selected();
320
+ }
321
+ $retval = FALSE;
322
+ if ($lightbox) {
323
+ // HANDLE COMPATIBILITY BREAK
324
+ // In NGG 2.1.48 and earlier, lightboxes were stdClass objects, and it was assumed
325
+ // that they only supported galleries that contained images, not albums that contained galleries.
326
+ // After NGG 2.1.48, lightboxes are now C_NGG_Lightbox instances which have a 'is_supported()' method
327
+ // to test if the lightbox can work with the displayed gallery settings
328
+ if (get_class($lightbox) == 'stdClass') {
329
+ $retval = !in_array($displayed_gallery->source, array('album', 'albums'));
330
+ } else {
331
+ $retval = $lightbox->is_supported($displayed_gallery);
332
+ }
333
+ }
334
+ return $retval;
335
+ }
336
  /**
337
  * Returns the effect HTML code for the displayed gallery
338
  * @param type $displayed_gallery
341
  {
342
  $retval = '';
343
  if ($lightbox = C_Lightbox_Library_Manager::get_instance()->get_selected()) {
344
+ if ($this->does_lightbox_support_displayed_gallery($displayed_gallery, $lightbox)) {
345
+ $retval = $lightbox->code;
346
+ $retval = str_replace('%GALLERY_ID%', $displayed_gallery->id(), $retval);
347
+ $retval = str_replace('%GALLERY_NAME%', $displayed_gallery->id(), $retval);
348
+ global $post;
349
+ if ($post && isset($post->ID) && $post->ID) {
350
+ $retval = str_replace('%PAGE_ID%', $post->ID, $retval);
351
+ }
352
  }
353
  }
354
  // allow for customization
products/photocrati_nextgen/modules/nextgen_xmlrpc/module.nextgen_xmlrpc.php CHANGED
@@ -14,7 +14,7 @@ class M_NextGen_XmlRpc extends C_Base_Module
14
  'photocrati-nextgen_xmlrpc',
15
  'NextGEN Gallery XML-RPC',
16
  'Provides an XML-RPC API for NextGEN Gallery',
17
- '0.4',
18
  'https://www.imagely.com/wordpress-gallery-plugin/nextgen-gallery/',
19
  'Photocrati Media',
20
  'https://www.imagely.com'
14
  'photocrati-nextgen_xmlrpc',
15
  'NextGEN Gallery XML-RPC',
16
  'Provides an XML-RPC API for NextGEN Gallery',
17
+ '0.5',
18
  'https://www.imagely.com/wordpress-gallery-plugin/nextgen-gallery/',
19
  'Photocrati Media',
20
  'https://www.imagely.com'
products/photocrati_nextgen/modules/nextgen_xmlrpc/package.module.nextgen_xmlrpc.php CHANGED
@@ -529,7 +529,7 @@ class C_NextGen_API extends C_Component
529
  $error = null;
530
  if ($gallery != null) {
531
  if ($task_type == 'gallery_remove') {
532
- if (!$gallery->destroy()) {
533
  $error = __('Failed to remove gallery (%1$s).', 'nggallery');
534
  }
535
  } else {
529
  $error = null;
530
  if ($gallery != null) {
531
  if ($task_type == 'gallery_remove') {
532
+ if (!$mapper->destroy($gallery, true)) {
533
  $error = __('Failed to remove gallery (%1$s).', 'nggallery');
534
  }
535
  } else {
products/photocrati_nextgen/modules/ngglegacy/admin/overview.php CHANGED
@@ -202,7 +202,7 @@ function nggallery_admin_overview()
202
  <div class="col">
203
  <a href="https://www.imagely.com/team-member/tamara-lackey/" target="_blank"><img src="https://f001.backblaze.com/file/nextgen-gallery/TamaraLackey-ngg.jpg" alt="Tamara Lackey" /></a>
204
  <h3><?php _e( 'Tamara Lackey' ); ?></h3>
205
- <p><?php _e( 'Tamara Lackey is a renowned professional photographer, speaker, and author. Her authentic lifestyle photography, from children’s portraits to celebrity portraits, is praised within her industry and published internationally. She is also founder of the charitable project, Beautiful Together.', 'nggallery' ); ?></p>
206
  </div>
207
  <div class="col">
208
  <a href="https://www.imagely.com/team-member/colby-brown/" target="_blank"><img src="https://f001.backblaze.com/file/nextgen-gallery/colby-brown-ngg.jpg" alt="Colby Brown" /></a>
@@ -400,4 +400,4 @@ function nggallery_admin_overview()
400
  </div>
401
 
402
  <?php
403
- }
202
  <div class="col">
203
  <a href="https://www.imagely.com/team-member/tamara-lackey/" target="_blank"><img src="https://f001.backblaze.com/file/nextgen-gallery/TamaraLackey-ngg.jpg" alt="Tamara Lackey" /></a>
204
  <h3><?php _e( 'Tamara Lackey' ); ?></h3>
205
+ <p><?php _e( 'Tamara Lackey is a renowned professional photographer, speaker, and author. Her authentic lifestyle photography, from children’s portraits to celebrity portraits, is praised within her industry and published internationally. She is a Nikon USA Ambassador, the host of The reDefine Show web series, and the co-founder of the non-profit charitable organization, Beautiful Together, in support of children waiting for families.', 'nggallery' ); ?></p>
206
  </div>
207
  <div class="col">
208
  <a href="https://www.imagely.com/team-member/colby-brown/" target="_blank"><img src="https://f001.backblaze.com/file/nextgen-gallery/colby-brown-ngg.jpg" alt="Colby Brown" /></a>
400
  </div>
401
 
402
  <?php
403
+ }
products/photocrati_nextgen/modules/ngglegacy/module.ngglegacy.php CHANGED
@@ -22,7 +22,7 @@ class M_NggLegacy extends C_Base_Module
22
  'photocrati-nextgen-legacy',
23
  'NextGEN Legacy',
24
  'Embeds the original version of NextGEN 1.9.3 by Alex Rabe',
25
- '0.15',
26
  'https://www.imagely.com/wordpress-gallery-plugin/nextgen-gallery/',
27
  'Photocrati Media',
28
  'https://www.imagely.com'
22
  'photocrati-nextgen-legacy',
23
  'NextGEN Legacy',
24
  'Embeds the original version of NextGEN 1.9.3 by Alex Rabe',
25
+ '0.16',
26
  'https://www.imagely.com/wordpress-gallery-plugin/nextgen-gallery/',
27
  'Photocrati Media',
28
  'https://www.imagely.com'
products/photocrati_nextgen/modules/wordpress_routing/module.wordpress_routing.php CHANGED
@@ -17,7 +17,7 @@ class M_WordPress_Routing extends C_Base_Module
17
  'photocrati-wordpress_routing',
18
  'WordPress Routing',
19
  "Integrates the MVC module's routing implementation with WordPress",
20
- '0.6',
21
  'https://www.imagely.com/wordpress-gallery-plugin/nextgen-gallery/',
22
  'Photocrati Media',
23
  'https://www.imagely.com'
17
  'photocrati-wordpress_routing',
18
  'WordPress Routing',
19
  "Integrates the MVC module's routing implementation with WordPress",
20
+ '0.7',
21
  'https://www.imagely.com/wordpress-gallery-plugin/nextgen-gallery/',
22
  'Photocrati Media',
23
  'https://www.imagely.com'
products/photocrati_nextgen/modules/wordpress_routing/package.module.wordpress_routing.php CHANGED
@@ -129,7 +129,11 @@ class A_WordPress_Routing_App extends Mixin
129
  $original_url = $generated_url;
130
  $generated_parts = explode($settings->router_param_slug, $generated_url);
131
  $generated_url = $generated_parts[0];
132
- $ngg_parameters = isset($generated_parts[1]) ? @array_shift(explode('?', $generated_parts[1])) : '/';
 
 
 
 
133
  $post_permalink = get_permalink(isset($_REQUEST['p']) ? $_REQUEST['p'] : 0);
134
  if ($post_permalink == '/') {
135
  $post_permalink = $base_url;
129
  $original_url = $generated_url;
130
  $generated_parts = explode($settings->router_param_slug, $generated_url);
131
  $generated_url = $generated_parts[0];
132
+ $ngg_parameters = '/';
133
+ if (isset($generated_parts[1])) {
134
+ $parts = explode('?', $generated_parts[1]);
135
+ $ngg_parameters = array_shift($parts);
136
+ }
137
  $post_permalink = get_permalink(isset($_REQUEST['p']) ? $_REQUEST['p'] : 0);
138
  if ($post_permalink == '/') {
139
  $post_permalink = $base_url;
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Contributors: photocrati, imagely
3
  Tags: nextgen, nextgen gallery, gallery, galleries, image, images, image gallery, photo, photos, photo gallery, picture, pictures, picture gallery, album, albums, photo albums, image album, media, media gallery, thumbnails, thumbnail gallery, thumbnail galleries, slideshow, slideshows, slideshow gallery, slideshow galleries, fancybox, lightbox, responsive, responsive gallery, responsive galleries, wordpress responsive gallery, nextcellent, wordpress gallery plugin, wordpress photo gallery plugin, wp gallery, wp gallery plugins, best gallery plugin, free photo gallery, singlepic, image captions imagebrowser, watermarks, watermarking, photography, photographer
4
  Requires at least: 4.0.0
5
- Stable tag: 2.1.49
6
  Tested up to: 4.6.0
7
  License: GPLv2
8
 
@@ -187,6 +187,17 @@ For more information, feel free to visit the official website for the NextGEN Ga
187
 
188
  == Changelog ==
189
 
 
 
 
 
 
 
 
 
 
 
 
190
  = V2.1.49 - 07.26.2016 =
191
  * NEW: Add a "Default" template option to override ATP settings when a global setting is used
192
  * NEW: Added "generic" error reporting back during image upload.
2
  Contributors: photocrati, imagely
3
  Tags: nextgen, nextgen gallery, gallery, galleries, image, images, image gallery, photo, photos, photo gallery, picture, pictures, picture gallery, album, albums, photo albums, image album, media, media gallery, thumbnails, thumbnail gallery, thumbnail galleries, slideshow, slideshows, slideshow gallery, slideshow galleries, fancybox, lightbox, responsive, responsive gallery, responsive galleries, wordpress responsive gallery, nextcellent, wordpress gallery plugin, wordpress photo gallery plugin, wp gallery, wp gallery plugins, best gallery plugin, free photo gallery, singlepic, image captions imagebrowser, watermarks, watermarking, photography, photographer
4
  Requires at least: 4.0.0
5
+ Stable tag: 2.1.50
6
  Tested up to: 4.6.0
7
  License: GPLv2
8
 
187
 
188
  == Changelog ==
189
 
190
+ = V2.1.50 - 08.30-2016 =
191
+ * NEW: Added the ability to open galleries within albums using a lightbox
192
+ * Changed: Increased freemius opt-in to 100%
193
+ * Changed: Tamara Lackey's biography on the overview page
194
+ * Fixed: Images not responsive for all display types
195
+ * Fixed: Compatibility with the Imagely Lightroom plugin
196
+ * Fixed: Removed Pope tests folder
197
+ * Fixed: Maximum function nesting level fatal error when displaying two or more albums
198
+ * Fixed: Ensure Insert Gallery Window background stays white
199
+ * Fixed: PHP warning for C_NGG_Lightbox class using incompatible constructor
200
+
201
  = V2.1.49 - 07.26.2016 =
202
  * NEW: Add a "Default" template option to override ATP settings when a global setting is used
203
  * NEW: Added "generic" error reporting back during image upload.