Skip to content

Commit 55cb5b5

Browse files
committed
EvolutionCMS() to evo() and related cleanup
1 parent 524ec24 commit 55cb5b5

47 files changed

Lines changed: 132 additions & 137 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

core/functions/laravel.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function storage_path($path = '')
5555
*/
5656
function base_path($path = '')
5757
{
58-
return evolutionCMS()->basePath().($path ? DIRECTORY_SEPARATOR.$path : $path);
58+
return evo()->basePath() . ($path ? DIRECTORY_SEPARATOR . $path : $path);
5959
}
6060
}
6161

@@ -68,7 +68,7 @@ function base_path($path = '')
6868
*/
6969
function public_path($path = '')
7070
{
71-
return evolutionCMS()->publicPath().($path ? DIRECTORY_SEPARATOR.$path : $path);
71+
return evo()->publicPath() . ($path ? DIRECTORY_SEPARATOR . $path : $path);
7272
}
7373
}
7474

@@ -81,7 +81,7 @@ function public_path($path = '')
8181
*/
8282
function resource_path($path = '')
8383
{
84-
return evolutionCMS()->publicPath().($path ? DIRECTORY_SEPARATOR.$path : $path);
84+
return evo()->publicPath() . ($path ? DIRECTORY_SEPARATOR . $path : $path);
8585
}
8686
}
8787

@@ -134,10 +134,10 @@ function config($key = null, $default = null)
134134
function app($abstract = null, array $parameters = [])
135135
{
136136
if (is_null($abstract)) {
137-
return evolutionCMS();
137+
return evo();
138138
}
139139

140-
return evolutionCMS()->make($abstract, $parameters);
140+
return evo()->make($abstract, $parameters);
141141
}
142142
}
143143

core/functions/nodes.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111
function makeHTML($indent, $parent, $expandAll, $hereid = '')
1212
{
13-
$modx = evolutionCMS();
13+
$modx = evo();
1414
global $icons, $_style, $_lang, $opened, $opened2, $closed2, $modx_textdir;
1515

1616
$output = '';
@@ -552,7 +552,7 @@ function getIconInfo($_style)
552552
*/
553553
function getNodeTitle($nodeNameSource, $row)
554554
{
555-
$modx = evolutionCMS();
555+
$modx = evo();
556556

557557
switch ($nodeNameSource) {
558558
case 'menutitle':
@@ -638,7 +638,7 @@ function checkIsFolder($parent = 0, $isfolder = 1)
638638
*/
639639
function _htmlentities($array)
640640
{
641-
$modx = evolutionCMS();
641+
$modx = evo();
642642

643643
$array = json_encode($array, JSON_UNESCAPED_UNICODE);
644644
$array = htmlentities($array, ENT_COMPAT, $modx->getConfig('modx_charset'));

core/functions/processors.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
function evalModule($moduleCode, $params)
1616
{
17-
$modx = evolutionCMS();
17+
$modx = evo();
1818
$modx->event->params = &$params; // store params inside event object
1919
if (is_array($params)) {
2020
extract($params, EXTR_SKIP);
@@ -109,7 +109,7 @@ function jsAlert($msg)
109109
*/
110110
function login($username, $givenPassword, $dbasePassword)
111111
{
112-
$modx = evolutionCMS();
112+
$modx = evo();
113113

114114
return $modx->getPasswordHash()->CheckPassword($givenPassword, $dbasePassword);
115115
}
@@ -125,7 +125,7 @@ function login($username, $givenPassword, $dbasePassword)
125125
*/
126126
function loginV1($internalKey, $givenPassword, $dbasePassword, $username)
127127
{
128-
$modx = evolutionCMS();
128+
$modx = evo();
129129

130130
$user_algo = $modx->getManagerApi()->getV1UserHashAlgorithm($internalKey);
131131

@@ -158,7 +158,7 @@ function loginV1($internalKey, $givenPassword, $dbasePassword, $username)
158158
*/
159159
function loginMD5($internalKey, $givenPassword, $dbasePassword, $username)
160160
{
161-
$modx = evolutionCMS();
161+
$modx = evo();
162162

163163
if ($dbasePassword != md5($givenPassword)) {
164164
return false;
@@ -176,7 +176,7 @@ function loginMD5($internalKey, $givenPassword, $dbasePassword, $username)
176176
*/
177177
function updateNewHash($username, $password)
178178
{
179-
$modx = evolutionCMS();
179+
$modx = evo();
180180

181181
$field = array();
182182
$field['password'] = $modx->getPasswordHash()->HashPassword($password);
@@ -191,7 +191,6 @@ function updateNewHash($username, $password)
191191
*/
192192
function saveUserGroupAccessPermissons()
193193
{
194-
$modx = evolutionCMS();
195194
global $id, $newid;
196195
global $use_udperms;
197196

@@ -272,7 +271,6 @@ function saveEventListeners($id, $sysevents, $mode)
272271
*/
273272
function getEventIdByName($name)
274273
{
275-
$modx = evolutionCMS();
276274
static $eventIds = array();
277275

278276
if (isset($eventIds[$name])) {
@@ -290,7 +288,6 @@ function getEventIdByName($name)
290288
*/
291289
function saveTemplateAccess($id)
292290
{
293-
$modx = evolutionCMS();
294291
if ($_POST['tvsDirty'] == 1) {
295292
$newAssignedTvs = isset($_POST['assignedTv']) ? $_POST['assignedTv'] : '';
296293

@@ -327,7 +324,6 @@ function saveTemplateAccess($id)
327324
*/
328325
function saveTemplateVarAccess($id)
329326
{
330-
$modx = evolutionCMS();
331327
$templates = isset($_POST['template']) ? $_POST['template'] : []; // get muli-templates based on S.BRENNAN mod
332328

333329
$siteTmlvarTemplates = EvolutionCMS\Models\SiteTmplvarTemplate::where('tmplvarid', '=', $id)->get();
@@ -358,7 +354,6 @@ function saveTemplateVarAccess($id)
358354
*/
359355
function saveVarRoles($id)
360356
{
361-
$modx = evolutionCMS();
362357
$roles = isset($_POST['role']) ? $_POST['role'] : [];
363358

364359
$exists = EvolutionCMS\Models\UserRoleVar::where('tmplvarid', '=', $id)->get();
@@ -383,7 +378,7 @@ function saveVarRoles($id)
383378
if (!function_exists('saveDocumentAccessPermissons')) {
384379
function saveDocumentAccessPermissons($id)
385380
{
386-
$modx = evolutionCMS();
381+
$modx = evo();
387382

388383
$docgroups = isset($_POST['docgroups']) ? $_POST['docgroups'] : '';
389384

@@ -414,7 +409,7 @@ function saveDocumentAccessPermissons($id)
414409
*/
415410
function sendMailMessageForUser($email, $uid, $pwd, $ufn, $message, $url)
416411
{
417-
$modx = evolutionCMS();
412+
$modx = evo();
418413
global $_lang;
419414
global $emailsubject, $emailsender;
420415
$message = sprintf($message, $uid, $pwd); // use old method

core/functions/tv.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212
function ProcessTVCommand($value, $name = '', $docid = '', $src = 'docform', $tvsArray = array())
1313
{
14-
$modx = evolutionCMS();
14+
$modx = evo();
1515
$docid = (int)$docid;
1616
if (!$docid) {
1717
$docid = $modx->documentIdentifier;
@@ -186,7 +186,7 @@ function parseTvValues($param, $tvsArray)
186186
return $param;
187187
}
188188

189-
$modx = evolutionCMS();
189+
$modx = evo();
190190
if (is_array($modx->documentObject)) {
191191
$tvsArray = array_merge($tvsArray, $modx->documentObject);
192192
}
@@ -224,7 +224,7 @@ function parseTvValues($param, $tvsArray)
224224
function getTVDisplayFormat($name, $value, $format, $paramstring = '', $tvtype = '', $docid = '', $sep = '')
225225
{
226226

227-
$modx = evolutionCMS();
227+
$modx = evo();
228228
$o = '';
229229

230230
// process any TV commands in value
@@ -593,7 +593,7 @@ function decodeParamValue($s)
593593
*/
594594
function parseInput($src, $delim = '||', $type = 'string', $columns = true)
595595
{ // type can be: string, array
596-
$modx = evolutionCMS();
596+
$modx = evo();
597597
if ($modx->getDatabase()->isResult($src)) {
598598
// must be a recordset
599599
$rows = array();
@@ -667,7 +667,7 @@ function renderFormElement(
667667
$content = null
668668
)
669669
{
670-
$modx = evolutionCMS();
670+
$modx = evo();
671671
if ($content === null) {
672672
global $content;
673673
}
@@ -974,7 +974,7 @@ function renderFormElement(
974974
*/
975975
function ParseIntputOptions($v)
976976
{
977-
$modx = evolutionCMS();
977+
$modx = evo();
978978
if (is_array($v)) {
979979
return $v;
980980
}

core/src/AbstractLaravel.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,11 +459,12 @@ public function isDeferredService($service)
459459
* Resolve the given type from the container.
460460
*
461461
* (Overriding Container::make)
462+
* @template TClass of object
462463
*
463-
* @param string $abstract
464+
* @param string|class-string<TClass> $abstract
464465
* @param array $parameters
465-
* @return mixed
466-
*/
466+
* @return ($abstract is class-string<TClass> ? \Closure(): TClass : \Closure(): mixed)
467+
*/
467468
public function make($abstract, array $parameters = [])
468469
{
469470
$abstract = $this->getAlias($abstract);

core/src/Console/ClearCacheFullCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function handle()
3333
@unlink($packagesPath);
3434
}
3535

36-
EvolutionCMS()->clearCache('full');
36+
evo()->clearCache('full');
3737
$this->info('Cache clear');
3838
}
3939
}

core/src/Console/Packages/ExtrasCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class ExtrasCommand extends Command
9090
public function __construct()
9191
{
9292
parent::__construct();
93-
$this->evo = EvolutionCMS();
93+
$this->evo = evo();
9494
$this->load_dir = $this->evo->getConfig('rb_base_dir');
9595
}
9696

core/src/Console/Packages/PackageCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class PackageCommand extends Command
5555
public function __construct()
5656
{
5757
parent::__construct();
58-
$this->evo = EvolutionCMS();
58+
$this->evo = evo();
5959
$this->load_dir = $this->evo->getConfig('rb_base_dir');
6060
}
6161

core/src/Console/SiteUpdateCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function handle()
4747

4848
public function startUpdate()
4949
{
50-
$evo = EvolutionCMS();
50+
$evo = evo();
5151
$updateRepository = $evo->getConfig('UpgradeRepository');
5252
if ($updateRepository == '') {
5353
$updateRepository = 'evolution-cms/evolution';
@@ -120,8 +120,8 @@ public function startUpdate()
120120
closedir($handle);
121121
}
122122

123-
SELF::moveFiles($temp_dir . '/' . $dir, MODX_BASE_PATH);
124-
SELF::rmdirs($temp_dir);
123+
self::moveFiles($temp_dir . '/' . $dir, MODX_BASE_PATH);
124+
self::rmdirs($temp_dir);
125125

126126
$ch = curl_init();
127127
$url = 'https://api.github.com/repos/' . $updateRepository . '/releases';
@@ -160,7 +160,7 @@ public function startUpdate()
160160
$file = str_replace('{core}', EVO_CORE_PATH, $file);
161161
if (file_exists($file)) {
162162
if (is_dir($file)) {
163-
SELF::rmdirs($file);
163+
self::rmdirs($file);
164164
} else {
165165
unlink($file);
166166
}

core/src/Controllers/Users/DeleteUser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function canView(): bool
3030
public function process() : bool
3131
{
3232
if($_GET['id'] == evo()->getLoginUserID()){
33-
EvolutionCMS()->webAlertAndQuit(Lang::get('global.delete_yourself'));
33+
evo()->webAlertAndQuit(Lang::get('global.delete_yourself'));
3434
}
3535
$user = Models\UserAttribute::query()->where('internalKey', $_GET['id'])->first();
3636
if($user->role == 1){

0 commit comments

Comments
 (0)