/
DialogView.php
92 lines (80 loc) · 2.59 KB
/
DialogView.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
namespace Concrete\Core\View;
use Concrete\Core\Asset\Asset;
use Concrete\Core\Asset\Output\JavascriptFormatter;
use View as ConcreteView;
use Concrete\Core\Asset\CssAsset;
use Concrete\Core\Asset\JavascriptAsset;
use Concrete\Core\Asset\JavascriptInlineAsset;
use Concrete\Core\User\User;
use Concrete\Core\Support\Facade\Application;
class DialogView extends ConcreteView
{
protected function onBeforeGetContents()
{
$this->markHeaderAssetPosition();
}
public function getViewTemplateFile()
{
return $this->template;
}
protected function loadViewThemeObject()
{
return null;
}
public function renderViewContents($scopeItems)
{
$contents = '<!--ccm:assets:'.Asset::ASSET_POSITION_HEADER.'//-->';
$contents .= '<!--ccm:assets:'.Asset::ASSET_POSITION_FOOTER.'//-->';
$contents .= parent::renderViewContents($scopeItems);
return $contents;
}
public function outputAssetIntoView($item)
{
if ($item instanceof Asset) {
$formatter = new JavascriptFormatter();
return $formatter->output($item);
} else {
return $item . "\n";
}
}
public function getScopeItems()
{
$app = Application::getFacadeApplication();
$items = parent::getScopeItems();
$u = $app->make(User::class);
$items['u'] = $u;
return $items;
}
protected function getAssetsToOutput()
{
$ouput = parent::getAssetsToOutput();
$return = array();
foreach ($ouput as $position => $assets) {
foreach ($assets as $asset) {
if ($asset instanceof Asset) {
$asset->setAssetPosition(Asset::ASSET_POSITION_HEADER);
$asset->setAssetSupportsMinification(false);
$asset->setAssetSupportsCombination(false);
}
$return[$position][] = $asset;
}
}
return $return;
}
/*
protected function onAfterGetContents() {
// now that we have the contents of the tool,
// we make sure any require assets get moved into the header
// since that's the only place they work in the AJAX output.
$r = Request::getInstance();
$assets = $r->getRequiredAssetsToOutput();
foreach($assets as $asset) {
$asset->setAssetPosition(Asset::ASSET_POSITION_HEADER);
$asset->setAssetSupportsMinification(false);
$asset->setAssetSupportsCombination(false);
$this->addOutputAsset($asset);
}
}
*/
}