1: <?php
2:
3: /**
4: * ProcessWire ModuleJS
5: *
6: * An abstract module intended as a base for modules needing to autoload JS or CSS files.
7: *
8: * If you extend this, double check that the default isSingular() and isAutoload() methods
9: * are doing what you want -- you may want to override them.
10: *
11: * See the Module interface (Module.php) for details about each method.
12: *
13: * ProcessWire 2.x
14: * Copyright (C) 2010 by Ryan Cramer
15: * Licensed under GNU/GPL v2, see LICENSE.TXT
16: *
17: * http://www.processwire.com
18: * http://www.ryancramer.com
19: *
20: */
21:
22: abstract class ModuleJS extends WireData implements Module {
23:
24: /**
25: * Per the Module interface, return an array of information about the Module
26: *
27: */
28: public static function getModuleInfo() {
29: return array(
30: 'title' => '', // printable name/title of module
31: 'version' => 001, // version number of module
32: 'summary' => '', // 1 sentence summary of module
33: 'href' => '', // URL to more information (optional)
34: 'permanent' => false, // true if module is permanent and thus not uninstallable
35: );
36: }
37:
38: /**
39: * Per the Module interface, Initialize the Process, loading any related CSS or JS files
40: *
41: */
42: public function init() {
43: $class = $this->className();
44: if(is_file($this->config->paths->$class . "$class.css")) $this->config->styles->add($this->config->urls->$class . "$class.css");
45: if(is_file($this->config->paths->$class . "$class.js")) $this->config->scripts->add($this->config->urls->$class . "$class.js");
46: }
47:
48: public function ___install() { }
49: public function ___uninstall() { }
50: public function isSingular() { return true; }
51: public function isAutoload() { return false; }
52: }
53:
54: