@@ -7,38 +7,38 @@ |
||
7 | 7 | use Battis\BootstrapSmarty\NotificationMessage; |
8 | 8 | |
9 | 9 | if (isset($_REQUEST['hack'])) { |
10 | - while (list($id, $setting) = each($_REQUEST['hack'])) { |
|
11 | - try { |
|
12 | - $hack = CanvasHack::getCanvasHackById($toolbox->getMySQL(), $id); |
|
13 | - if ($setting === 'enable') { |
|
14 | - $hack->enable(); |
|
15 | - } else { |
|
16 | - $hack->disable(); |
|
17 | - } |
|
18 | - } catch (CanvasHack_Exception $e) { |
|
19 | - $smarty->addMessage('Exception ' . $e->getCode(), $e->getMessage(), NotificationMessage::ERROR); |
|
20 | - } |
|
21 | - } |
|
10 | + while (list($id, $setting) = each($_REQUEST['hack'])) { |
|
11 | + try { |
|
12 | + $hack = CanvasHack::getCanvasHackById($toolbox->getMySQL(), $id); |
|
13 | + if ($setting === 'enable') { |
|
14 | + $hack->enable(); |
|
15 | + } else { |
|
16 | + $hack->disable(); |
|
17 | + } |
|
18 | + } catch (CanvasHack_Exception $e) { |
|
19 | + $smarty->addMessage('Exception ' . $e->getCode(), $e->getMessage(), NotificationMessage::ERROR); |
|
20 | + } |
|
21 | + } |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | $hacksContents = scandir(realpath(__DIR__ . '/hacks'), SCANDIR_SORT_ASCENDING); |
25 | 25 | $hacks = array(); |
26 | 26 | foreach ($hacksContents as $item) { |
27 | - if (is_dir($path = realpath(__DIR__ . "/hacks/$item")) && file_exists($manifest = "$path/manifest.xml")) { |
|
28 | - try { |
|
29 | - $hacks[$item] = new CanvasHack($toolbox->getMySQL(), $path); |
|
30 | - } catch (CanvasHack_Exception $e) { |
|
31 | - $smarty->addMessage( |
|
32 | - 'CanvasHack Manifest Error ['. $e->getCode() . ']', |
|
33 | - $e->getMessage(), |
|
34 | - NotificationMessage::ERROR |
|
35 | - ); |
|
36 | - } |
|
37 | - } |
|
27 | + if (is_dir($path = realpath(__DIR__ . "/hacks/$item")) && file_exists($manifest = "$path/manifest.xml")) { |
|
28 | + try { |
|
29 | + $hacks[$item] = new CanvasHack($toolbox->getMySQL(), $path); |
|
30 | + } catch (CanvasHack_Exception $e) { |
|
31 | + $smarty->addMessage( |
|
32 | + 'CanvasHack Manifest Error ['. $e->getCode() . ']', |
|
33 | + $e->getMessage(), |
|
34 | + NotificationMessage::ERROR |
|
35 | + ); |
|
36 | + } |
|
37 | + } |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | $smarty->assign([ |
41 | - 'appURL' => $toolbox->config('APP_URL'), |
|
42 | - 'hacks' => $hacks |
|
41 | + 'appURL' => $toolbox->config('APP_URL'), |
|
42 | + 'hacks' => $hacks |
|
43 | 43 | ]); |
44 | 44 | $smarty->display('control-panel.tpl'); |
@@ -15,4 +15,4 @@ |
||
15 | 15 | location: window.location.href |
16 | 16 | }; |
17 | 17 | $('head').append('<link id="canvashack-dynamic-css" rel="stylesheet" href="<?= $toolbox->config('APP_URL') ?>/canvashack.css.php?' + $.param(args) + '" />'); |
18 | -$.getScript('<?= $toolbox-config('APP_URL') ?>/canvashack.js.php?' + $.param(args)); |
|
18 | +$.getScript('<?= $toolbox - config('APP_URL') ?>/canvashack.js.php?' + $.param(args)); |
@@ -17,16 +17,16 @@ discard block |
||
17 | 17 | |
18 | 18 | function canonicalNamespaceId($id) |
19 | 19 | { |
20 | - return preg_replace('/[^a-z0-9]+/i', '_', $id); |
|
20 | + return preg_replace('/[^a-z0-9]+/i', '_', $id); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | function canvasHackNamespace($id, $javascript) |
24 | 24 | { |
25 | - return preg_replace( |
|
26 | - '/^(\s*var\s+)?canvashack\s*=\s*{\n*(.*)};/is', |
|
27 | - canonicalNamespaceId($id) . ": {\n$2\n}", |
|
28 | - $javascript |
|
29 | - ); |
|
25 | + return preg_replace( |
|
26 | + '/^(\s*var\s+)?canvashack\s*=\s*{\n*(.*)};/is', |
|
27 | + canonicalNamespaceId($id) . ": {\n$2\n}", |
|
28 | + $javascript |
|
29 | + ); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | $canvashacks = array(); |
@@ -42,14 +42,14 @@ discard block |
||
42 | 42 | "); |
43 | 43 | |
44 | 44 | while ($page = $enabledPages->fetch_assoc()) { |
45 | - if ((!empty($page['url']) && $page['url'] == $location) || |
|
46 | - (!empty($page['pattern']) && preg_match($page['pattern'], $location))) { |
|
47 | - if ($page['include']) { |
|
48 | - $canvashacks[$page['canvashack']] = true; |
|
49 | - } else { |
|
50 | - unset($canvashacks[$page['canvashack']]); |
|
51 | - } |
|
52 | - } |
|
45 | + if ((!empty($page['url']) && $page['url'] == $location) || |
|
46 | + (!empty($page['pattern']) && preg_match($page['pattern'], $location))) { |
|
47 | + if ($page['include']) { |
|
48 | + $canvashacks[$page['canvashack']] = true; |
|
49 | + } else { |
|
50 | + unset($canvashacks[$page['canvashack']]); |
|
51 | + } |
|
52 | + } |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | $css = array(); |
@@ -59,15 +59,15 @@ discard block |
||
59 | 59 | WHERE |
60 | 60 | `canvashack` = '" . implode("' OR `canvashack` = '", array_keys($canvashacks)) . "' |
61 | 61 | ")) == false) { |
62 | - exit; |
|
62 | + exit; |
|
63 | 63 | } |
64 | 64 | while ($entry = $applicableCSS->fetch_assoc()) { |
65 | - $css[$entry['canvashack']] = shell_exec("php \"{$entry['path']}\" \"{$location}\" 2>&1"); |
|
65 | + $css[$entry['canvashack']] = shell_exec("php \"{$entry['path']}\" \"{$location}\" 2>&1"); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | foreach ($css as $id => $stylesheet) { |
69 | - $plugin = new AppMetadata($toolbox->getMySQL(), $id); |
|
70 | - echo "/* CanvasHack ID $id begin */\n"; |
|
71 | - echo $plugin->derivedValues($stylesheet); |
|
72 | - echo "\n/* CanvasHack ID $id end */\n\n"; |
|
69 | + $plugin = new AppMetadata($toolbox->getMySQL(), $id); |
|
70 | + echo "/* CanvasHack ID $id begin */\n"; |
|
71 | + echo $plugin->derivedValues($stylesheet); |
|
72 | + echo "\n/* CanvasHack ID $id end */\n\n"; |
|
73 | 73 | } |