Skip to content

Commit

Permalink
Continued updates for multi-instance support, wrapping up dependency …
Browse files Browse the repository at this point in the history
…injection throughout the core. Optimization to PW's hooks system, plus update to more open licenses (MPL 2.0 and MIT).
  • Loading branch information
ryancramerdesign committed Oct 21, 2015
1 parent 766387b commit 515c6e5
Show file tree
Hide file tree
Showing 116 changed files with 2,400 additions and 1,805 deletions.
431 changes: 431 additions & 0 deletions LICENSE.TXT

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "processwire/processwire",
"type": "library",
"description": "ProcessWire CMS/CMF",
"keywords": ["cms","cmf", "content management system"],
"keywords": [ "cms","cmf", "content management system" ],
"homepage": "https://processwire.com",
"authors": [
{
Expand All @@ -17,6 +17,6 @@
"ext-gd": "*"
},
"autoload": {
"files": "wire/core/ProcessWire.php"
"files": [ "wire/core/ProcessWire.php" ]
}
}
3 changes: 3 additions & 0 deletions site-beginner/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
* In non-dedicated environments, you should lock down the permissions of this file so
* that it cannot be seen by other users on the system. For more information, please
* see the config.php section at: https://processwire.com/docs/security/file-permissions/
*
* This file is licensed under the MIT license
* https://processwire.com/about/license/mit/
*
* ProcessWire 3.x (development), Copyright 2015 by Ryan Cramer
* https://processwire.com
Expand Down
3 changes: 3 additions & 0 deletions site-blank/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
* In non-dedicated environments, you should lock down the permissions of this file so
* that it cannot be seen by other users on the system. For more information, please
* see the config.php section at: https://processwire.com/docs/security/file-permissions/
*
* This file is licensed under the MIT license
* https://processwire.com/about/license/mit/
*
* ProcessWire 3.x (development), Copyright 2015 by Ryan Cramer
* https://processwire.com
Expand Down
3 changes: 3 additions & 0 deletions site-classic/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
* In non-dedicated environments, you should lock down the permissions of this file so
* that it cannot be seen by other users on the system. For more information, please
* see the config.php section at: https://processwire.com/docs/security/file-permissions/
*
* This file is licensed under the MIT license
* https://processwire.com/about/license/mit/
*
* ProcessWire 3.x (development), Copyright 2015 by Ryan Cramer
* https://processwire.com
Expand Down
3 changes: 3 additions & 0 deletions site-default/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
* In non-dedicated environments, you should lock down the permissions of this file so
* that it cannot be seen by other users on the system. For more information, please
* see the config.php section at: https://processwire.com/docs/security/file-permissions/
*
* This file is licensed under the MIT license
* https://processwire.com/about/license/mit/
*
* ProcessWire 3.x (development), Copyright 2015 by Ryan Cramer
* https://processwire.com
Expand Down
3 changes: 3 additions & 0 deletions site-default/modules/Helloworld.module
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
*
* See README file for further links regarding module development.
*
* This file is licensed under the MIT license
* https://processwire.com/about/license/mit/
*
* ProcessWire 3.x (development), Copyright 2015 by Ryan Cramer
* https://processwire.com
*
Expand Down
3 changes: 3 additions & 0 deletions site-languages/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
* In non-dedicated environments, you should lock down the permissions of this file so
* that it cannot be seen by other users on the system. For more information, please
* see the config.php section at: https://processwire.com/docs/security/file-permissions/
*
* This file is licensed under the MIT license
* https://processwire.com/about/license/mit/
*
* ProcessWire 3.x (development), Copyright 2015 by Ryan Cramer
* https://processwire.com
Expand Down
25 changes: 14 additions & 11 deletions wire/core/AdminTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
* An abstract module intended as a base for admin themes.
*
* See the Module interface (Module.php) for details about each method.
*
* This file is licensed under the MIT license.
* https://processwire.com/about/license/mit/
*
* ProcessWire 3.x (development), Copyright 2015 by Ryan Cramer
* https://processwire.com
Expand All @@ -19,25 +22,25 @@ abstract class AdminTheme extends WireData implements Module {
/**
* Per the Module interface, return an array of information about the Module
*
*/
*/
public static function getModuleInfo() {
return array(
'title' => '', // printable name/title of module
'version' => 1, // version number of module
'summary' => '', // 1 sentence summary of module
'href' => '', // URL to more information (optional)
'title' => '', // printable name/title of module
'version' => 1, // version number of module
'summary' => '', // 1 sentence summary of module
'href' => '', // URL to more information (optional)

// all admin themes should have this as their autoload selector:
'autoload' => 'template=admin',
'autoload' => 'template=admin',
'singular' => true
);
);
}

/**
* Current admin theme version (cached from module info)
*
*
* @var int
*
*
*/
protected $version = 0;

Expand All @@ -49,9 +52,9 @@ public static function getModuleInfo() {

/**
* Additional classes for body tag
*
*
* @var array
*
*
*/
protected $bodyClasses = array();

Expand Down
3 changes: 3 additions & 0 deletions wire/core/Breadcrumbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
*
* Provides basic breadcrumb capability
*
* This file is licensed under the MIT license.
* https://processwire.com/about/license/mit/
*
* ProcessWire 3.x (development), Copyright 2015 by Ryan Cramer
* https://processwire.com
*
Expand Down
14 changes: 9 additions & 5 deletions wire/core/CacheFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
* Each cache file creates it's own directory based on the '$id' given.
* The dir is created so that secondary cache files can be created too,
* and these are automatically removed when the remove() method is called.
*
* This file is licensed under the MIT license
* https://processwire.com/about/license/mit/
*
* ProcessWire 3.x (development), Copyright 2015 by Ryan Cramer
* https://processwire.com
*
*/
class CacheFile {
class CacheFile extends Wire {

const cacheFileExtension = ".cache";
const globalExpireFilename = "lastgood";
Expand Down Expand Up @@ -46,16 +49,17 @@ class CacheFile {
*/
public function __construct($path, $id, $cacheTimeSeconds) {

$this->useFuel(false);
$path = rtrim($path, '/') . '/';
$this->globalExpireFile = $path . self::globalExpireFilename;
$this->path = $id ? $path . $id . '/' : $path;

if(!is_dir($path)) {
if(!wireMkdir($path, true)) throw new WireException("Unable to create path: $path");
if(!$this->wire('files')->mkdir($path, true)) throw new WireException("Unable to create path: $path");
}

if(!is_dir($this->path)) {
if(!wireMkdir($this->path)) throw new WireException("Unable to create path: {$this->path}");
if(!$this->wire('files')->mkdir($this->path)) throw new WireException("Unable to create path: {$this->path}");
}

if(is_file($this->globalExpireFile)) {
Expand Down Expand Up @@ -185,12 +189,12 @@ public function save($data) {
return false;
}
} else {
wireMkdir("$dirname/", true);
$this->wire('files')->mkdir("$dirname/", true);
}
}

$result = file_put_contents($filename, $data);
wireChmod($filename);
$this->wire('files')->chmod($filename);
return $result;
}

Expand Down
3 changes: 3 additions & 0 deletions wire/core/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
*
* Handles ProcessWire configuration data
*
* This file is licensed under the MIT license
* https://processwire.com/about/license/mit/
*
* ProcessWire 3.x (development), Copyright 2015 by Ryan Cramer
* https://processwire.com
*
Expand Down
3 changes: 3 additions & 0 deletions wire/core/ConfigurableModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
* ProcessWire ConfigurableModule Interface
*
* Provides the base interfaces required by modules.
*
* This file is licensed under the MIT license
* https://processwire.com/about/license/mit/
*
* ProcessWire 3.x (development), Copyright 2015 by Ryan Cramer
* https://processwire.com
Expand Down
39 changes: 33 additions & 6 deletions wire/core/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
*
* Serves as a wrapper to PHP's mysqli classes
*
* This file is licensed under the MIT license
* https://processwire.com/about/license/mit/
*
* ProcessWire 3.x (development), Copyright 2015 by Ryan Cramer
* https://processwire.com
*
*
*/



/**
* Database class provides a layer on top of mysqli
*
Expand All @@ -23,7 +24,7 @@ class Database extends \mysqli implements WireDatabase {
* Log of all queries performed in this instance
*
*/
static protected $queryLog = array();
protected $queryLog = array();

/**
* Should WireDatabaseException be thrown on error?
Expand Down Expand Up @@ -104,7 +105,7 @@ public function query($sql, $resultmode = MYSQLI_STORE_RESULT) {
$timerTotalSinceStart = Debug::timer() - $timerFirstStartTime;
$sql .= " [{$elapsed}s, {$timerTotalQueryTime}s, {$timerTotalSinceStart}s]";
}
self::$queryLog[] = $sql;
$this->queryLog($sql);
}

} else if($this->throwExceptions) {
Expand All @@ -119,11 +120,37 @@ public function query($sql, $resultmode = MYSQLI_STORE_RESULT) {
*
* Active in ProcessWire debug mode only
*
* @param ProcessWire $wire ProcessWire instance, if omitted returns queries for all instances
* @return array
* @deprecated
*
*/
static public function getQueryLog() {
return self::$queryLog;
static public function getQueryLog(ProcessWire $wire = null) {
if($wire) {
return $wire->database->queryLog();
} else {
$log = array();
foreach(ProcessWire::getInstances() as $wire) {
$log = array_merge($log, $wire->database->queryLog());
}
}
return $log;
}

/**
* Log a query or return the query log
*
* @param string $sql Omit to instead return the query log
* @return array|bool Returns query log array when $sql argument is omitted
*
*/
public function queryLog($sql = '') {
if($sql) {
$this->queryLog[] = $sql;
return true;
} else {
return $this->queryLog;
}
}

/**
Expand Down
3 changes: 3 additions & 0 deletions wire/core/DatabaseMysqli.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
* actually instantiating mysqli (and forming a mysql connection) until the $db
* variable is called upon to do something.
*
* This file is licensed under the MIT license
* https://processwire.com/about/license/mit/
*
*/

class DatabaseMysqli {
Expand Down
2 changes: 2 additions & 0 deletions wire/core/DatabaseQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* ProcessWire 3.x (development), Copyright 2015 by Ryan Cramer
* https://processwire.com
*
* This file is licensed under the MIT license
* https://processwire.com/about/license/mit/
*
* @property array $where
*
Expand Down
3 changes: 3 additions & 0 deletions wire/core/DatabaseQuerySelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
* of what other methods/objects have done to it. It also means being able
* to build a complex query without worrying about correct syntax placement.
*
* This file is licensed under the MIT license
* https://processwire.com/about/license/mit/
*
* ProcessWire 3.x (development), Copyright 2015 by Ryan Cramer
* https://processwire.com
*
Expand Down
3 changes: 3 additions & 0 deletions wire/core/DatabaseQuerySelectFulltext.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
* of what other methods/objects have done to it. It also means being able
* to build a complex query without worrying about correct syntax placement.
*
* This file is licensed under the MIT license
* https://processwire.com/about/license/mit/
*
* ProcessWire 3.x (development), Copyright 2015 by Ryan Cramer
* https://processwire.com
*
Expand Down
3 changes: 3 additions & 0 deletions wire/core/Debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
*
* Currently only provides timer capability.
*
* This file is licensed under the MIT license
* https://processwire.com/about/license/mit/
*
* ProcessWire 3.x (development), Copyright 2015 by Ryan Cramer
* https://processwire.com
*
Expand Down
3 changes: 3 additions & 0 deletions wire/core/Exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
* ProcessWire Exceptions
*
* Exceptions that aren't specific to a particular class.
*
* This file is licensed under the MIT license
* https://processwire.com/about/license/mit/
*
* ProcessWire 3.x (development), Copyright 2015 by Ryan Cramer
* https://processwire.com
Expand Down
3 changes: 3 additions & 0 deletions wire/core/FieldSelectorInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
* provide information about what properties can be selected, what operators, are used,
* and so on. In the future this class will likely come in handy in providing selector
* validation and improved help and error messaging when building/testing selectors.
*
* This file is licensed under the MIT license
* https://processwire.com/about/license/mit/
*
* ProcessWire 3.x (development), Copyright 2015 by Ryan Cramer
* https://processwire.com
Expand Down
3 changes: 2 additions & 1 deletion wire/core/Fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,15 @@ class Fields extends WireSaveableItems {
*
*/
public function __construct() {
$this->fieldsArray = $this->wire(new FieldsArray());
$this->fieldsArray = new FieldsArray();
}

/**
* Construct and load the Fields
*
*/
public function init() {
$this->wire($this->fieldsArray);
$this->load($this->fieldsArray);
}

Expand Down
Loading

0 comments on commit 515c6e5

Please sign in to comment.