| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996 |
- <?php return array (
- '04129a4c69c5a8ade222db08d9721f9c' =>
- array (
- 'criteria' =>
- array (
- 'name' => 'fred',
- ),
- 'object' =>
- array (
- 'name' => 'fred',
- 'path' => '{core_path}components/fred/',
- 'assets_path' => '{assets_path}components/fred/',
- ),
- ),
- 'fc273ac310c52306b978d37bea7648ce' =>
- array (
- 'criteria' =>
- array (
- 'key' => 'fred.launcher_position',
- ),
- 'object' =>
- array (
- 'key' => 'fred.launcher_position',
- 'value' => 'bottom_left',
- 'xtype' => 'textfield',
- 'namespace' => 'fred',
- 'area' => 'default',
- 'editedon' => NULL,
- ),
- ),
- 'd88e7ea6d8d85302c058041666b66871' =>
- array (
- 'criteria' =>
- array (
- 'key' => 'fred.icon_editor',
- ),
- 'object' =>
- array (
- 'key' => 'fred.icon_editor',
- 'value' => 'IconEditor',
- 'xtype' => 'textfield',
- 'namespace' => 'fred',
- 'area' => 'default',
- 'editedon' => NULL,
- ),
- ),
- 'c34523a31af71ace4bad2ba255604b45' =>
- array (
- 'criteria' =>
- array (
- 'key' => 'fred.image_editor',
- ),
- 'object' =>
- array (
- 'key' => 'fred.image_editor',
- 'value' => 'ImageEditor',
- 'xtype' => 'textfield',
- 'namespace' => 'fred',
- 'area' => 'default',
- 'editedon' => NULL,
- ),
- ),
- '7631e9928799387322a2102d0cb574d5' =>
- array (
- 'criteria' =>
- array (
- 'key' => 'fred.rte',
- ),
- 'object' =>
- array (
- 'key' => 'fred.rte',
- 'value' => 'TinyMCE',
- 'xtype' => 'textfield',
- 'namespace' => 'fred',
- 'area' => 'default',
- 'editedon' => '2018-11-29 05:47:02',
- ),
- ),
- '434d64fb137569682a0495d1c1e3a73b' =>
- array (
- 'criteria' =>
- array (
- 'key' => 'fred.element_group_sort',
- ),
- 'object' =>
- array (
- 'key' => 'fred.element_group_sort',
- 'value' => 'name',
- 'xtype' => 'textfield',
- 'namespace' => 'fred',
- 'area' => 'default',
- 'editedon' => NULL,
- ),
- ),
- '00f17ded51254b836d514514a56a017a' =>
- array (
- 'criteria' =>
- array (
- 'key' => 'fred.element_sort',
- ),
- 'object' =>
- array (
- 'key' => 'fred.element_sort',
- 'value' => 'name',
- 'xtype' => 'textfield',
- 'namespace' => 'fred',
- 'area' => 'default',
- 'editedon' => NULL,
- ),
- ),
- '2ba0d04599604971601dfe319808e233' =>
- array (
- 'criteria' =>
- array (
- 'key' => 'fred.blueprint_category_sort',
- ),
- 'object' =>
- array (
- 'key' => 'fred.blueprint_category_sort',
- 'value' => 'name',
- 'xtype' => 'textfield',
- 'namespace' => 'fred',
- 'area' => 'default',
- 'editedon' => NULL,
- ),
- ),
- '090664b763d26d136ab538ff3f0b97cb' =>
- array (
- 'criteria' =>
- array (
- 'key' => 'fred.blueprint_sort',
- ),
- 'object' =>
- array (
- 'key' => 'fred.blueprint_sort',
- 'value' => 'name',
- 'xtype' => 'textfield',
- 'namespace' => 'fred',
- 'area' => 'default',
- 'editedon' => NULL,
- ),
- ),
- '8b35f2ca9134305a444a28327f0e4c85' =>
- array (
- 'criteria' =>
- array (
- 'key' => 'fred.secret',
- ),
- 'object' =>
- array (
- 'key' => 'fred.secret',
- 'value' => '7d4cb8c8e6d4513332b7168a86845062927b701796e404ccb0545799b5f81287e78238a1',
- 'xtype' => 'text-password',
- 'namespace' => 'fred',
- 'area' => 'default',
- 'editedon' => '2018-11-29 00:01:43',
- ),
- ),
- 'ff72aa76d1721def64610be2496ad42f' =>
- array (
- 'criteria' =>
- array (
- 'category' => 'Fred',
- ),
- 'object' =>
- array (
- 'id' => 27,
- 'parent' => 0,
- 'category' => 'Fred',
- 'rank' => 0,
- ),
- ),
- 'd326a485440e71a2c3479466cf4ad432' =>
- array (
- 'criteria' =>
- array (
- 'name' => 'Fred',
- ),
- 'object' =>
- array (
- 'id' => 14,
- 'source' => 0,
- 'property_preprocess' => 0,
- 'name' => 'Fred',
- 'description' => '',
- 'editor_type' => 0,
- 'category' => 27,
- 'cache_type' => 0,
- 'plugincode' => '/*
- * This file is part of the Fred package.
- *
- * Copyright (c) MODX, LLC
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- $corePath = $modx->getOption(\'fred.core_path\', null, $modx->getOption(\'core_path\', null, MODX_CORE_PATH) . \'components/fred/\');
- /** @var Fred $fred */
- $fred = $modx->getService(
- \'fred\',
- \'Fred\',
- $corePath . \'model/fred/\',
- array(
- \'core_path\' => $corePath
- )
- );
- switch ($modx->event->name) {
- case \'OnDocFormPrerender\':
- if(!empty($resource) && !empty($fred->getTheme($resource->template))) {
- //Disable ContentBlocks
- $isContentBlocks = $resource->getProperty(\'_isContentBlocks\', \'contentblocks\', null);
- if($isContentBlocks !== false){
- $resource->setProperty(\'_isContentBlocks\', false, \'contentblocks\');
- $resource->save();
- }
- $data = $resource->getProperty(\'data\', \'fred\');
- $fingerprint = !empty($data[\'fingerprint\']) ? $data[\'fingerprint\'] : \'\';
-
- //Load Open in Fred button
- $modx->lexicon->load(\'fred:default\');
- $modx->controller->addLexiconTopic(\'fred:default\');
- $modx->controller->addHtml("
- <script>
- Ext.ComponentMgr.onAvailable(\'modx-resource-content\', function(right) {
- right.on(\'beforerender\', function() {
- var content = Ext.getCmp(\'ta\'),
- contentvalue = content.getValue(),
- panel = Ext.getCmp(\'modx-page-update-resource\');
-
- content.destroy();
-
- right.insert(0,{
- xtype: \'button\'
- ,fieldLabel: _(\'fred.open_in_fred\')
- ,hideLabel: true
- ,cls: \'primary-button\'
- ,style: {padding: \'10px 15px\'}
- ,html: _(\'fred.open_in_fred\')
- ,handler: function(){
- window.open(panel.config.preview_url)
- }
- });
-
- right.insert(1,{
- xtype: \'textarea\'
- ,hideLabel: true
- ,anchor: \'100%\'
- ,grow: true
- ,style: {marginTop:\'15px\'}
- ,disabled: true
- ,value: contentvalue
- });
- });
-
- right.on(\'afterrender\', function() {
- var panel = Ext.getCmp(\'modx-panel-resource\');
-
- panel.on(\'success\', function(){
- location.reload();
- });
-
- var fingerprint = document.createElement(\'input\');
- fingerprint.setAttribute(\'type\', \'hidden\');
- fingerprint.setAttribute(\'name\', \'fingerprint\');
- fingerprint.setAttribute(\'value\', \'" . $fingerprint . "\');
- panel.form.el.dom.appendChild(fingerprint);
- });
- });
-
- </script>");
- }
- break;
- case \'OnLoadWebDocument\':
- $theme = $fred->getTheme($modx->resource->template);
- if (!empty($theme)) {
- $themeUri = $theme->getThemeFolderUri();
- $modx->setPlaceholder(\'+fred.theme_dir\', $themeUri);
- $modx->setOption(\'fred.theme_dir\', $themeUri);
- }
- break;
- case \'OnWebPagePrerender\':
- $theme = $fred->getTheme($modx->resource->template);
- if (!empty($theme)) {
-
- if (!$modx->user) return;
- if (!($modx->user->hasSessionContext(\'mgr\') || $modx->user->hasSessionContext($modx->resource->context_key))) return;
- if (!$modx->hasPermission(\'fred\')) return;
- $modx->lexicon->load(\'fred:fe\');
-
- $fredMode = 1;
-
- if (isset($_SESSION[\'fred\'])) {
- $fredMode = intval($_SESSION[\'fred\']);
- }
-
- if (isset($_GET[\'fred\'])) {
- $fredMode = intval($_GET[\'fred\']);
- }
-
- if ($fredMode === 4) {
- $fredMode = 0;
- $_SESSION[\'fred\'] = 0;
- }
-
- if ($fredMode === 1) {
- $_SESSION[\'fred\'] = 1;
- }
- $get = $_GET;
- unset($get[$modx->getOption(\'request_param_alias\', [], \'q\')]);
-
- if ($fredMode === 0) {
- $button = "<a href=\\"" . str_replace(\'&\', \'&\', $modx->makeUrl($modx->resource->id, \'\', array_merge($get, [\'fred\' => 1]) , \'abs\')) . "\\" title=\\"" . $modx->lexicon(\'fred.fe.turn_on_fred\') . "\\" role=\\"button\\" style=\\"display: block; text-decoration: none; background-color: #4D4D4D; background-image: url("data:image/svg+xml, %3Csvg xmlns=\'http://www.w3.org/2000/svg\' width=\'48\' height=\'48\' viewBox=\'-14.584 -8.583 48 48\'%3E%3ClinearGradient id=\'a\' gradientUnits=\'userSpaceOnUse\' x1=\'2164.318\' y1=\'-2519.043\' x2=\'2047.448\' y2=\'-2442.941\' gradientTransform=\'matrix(.1471 0 0 -.1471 -290.574 -365.794)\'%3E%3Cstop offset=\'0\' stop-color=\'%2380c3e6\'/%3E%3Cstop offset=\'1\' stop-color=\'%233380c2\'/%3E%3C/linearGradient%3E%3Cpath fill=\'url(%23a)\' d=\'M22.035 11.468l9.602-15.406H8.488L5.236 1.17z\'/%3E%3Cpath opacity=\'.15\' d=\'M5.236 1.17l1.702-2.633 15.097 12.931z\'/%3E%3ClinearGradient id=\'b\' gradientUnits=\'userSpaceOnUse\' x1=\'2184.769\' y1=\'-2694.977\' x2=\'2097.394\' y2=\'-2637.275\' gradientTransform=\'matrix(.1471 0 0 -.1471 -290.574 -365.794)\'%3E%3Cstop offset=\'0\' stop-color=\'%23f38649\'/%3E%3Cstop offset=\'.185\' stop-color=\'%23f28147\'/%3E%3Cstop offset=\'.409\' stop-color=\'%23ef7242\'/%3E%3Cstop offset=\'.654\' stop-color=\'%23ea5a3a\'/%3E%3Cstop offset=\'.911\' stop-color=\'%23e4382e\'/%3E%3Cstop offset=\'1\' stop-color=\'%23e12a29\'/%3E%3C/linearGradient%3E%3Cpath fill=\'url(%23b)\' d=\'M27.068 39.416V16.268l-4.957-3.176L11.583 29.74z\'/%3E%3Cpath opacity=\'.15\' d=\'M11.583 29.74l2.632 1.625 7.896-18.273z\'/%3E%3ClinearGradient id=\'c\' gradientUnits=\'userSpaceOnUse\' x1=\'1896.918\' y1=\'-2571.592\' x2=\'2064.08\' y2=\'-2467.137\' gradientTransform=\'matrix(.1471 0 0 -.1471 -290.574 -365.794)\'%3E%3Cstop offset=\'0\' stop-color=\'%2342ab4a\'/%3E%3Cstop offset=\'1\' stop-color=\'%23add155\'/%3E%3C/linearGradient%3E%3Cpath fill=\'url(%23c)\' d=\'M-10.25-8.583v23.148l5.419 3.175 26.866-6.272z\'/%3E%3ClinearGradient id=\'d\' gradientUnits=\'userSpaceOnUse\' x1=\'1933.576\' y1=\'-2758.292\' x2=\'2069.413\' y2=\'-2540.907\' gradientTransform=\'matrix(.1471 0 0 -.1471 -290.574 -365.794)\'%3E%3Cstop offset=\'0\' stop-color=\'%2342ab4a\'/%3E%3Cstop offset=\'1\' stop-color=\'%23add155\'/%3E%3C/linearGradient%3E%3Cpath fill=\'url(%23d)\' d=\'M-4.985 19.52l-9.599 15.093H8.565l13.546-21.521z\'/%3E%3C/svg%3E"); height: 48px; width: 48px; border-radius: 50%; outline: 0; border: none; background-repeat: no-repeat; background-size: 60%; background-position: center; box-shadow: rgba(18,55,100,0.34) 0 4px 8px; margin: 0; padding: 0; text-indent: -9999px; cursor: pointer; position: fixed; z-index: 10010; margin: 32px; bottom: 0; left: 0; opacity: 0.8; transition: .3s; box-sizing: border-box;\\" onmouseover=\\"this.style.transform=\'scale(1.05)\';\\" onmouseout=\\"this.style.transform=\'initial\'\\";>Fred</a>";
-
- $modx->resource->_output = preg_replace(\'/(<\\/body>(?:<\\/body>)?)/i\', "{$button}\\r\\n$1", $modx->resource->_output);
- return;
- }
- if ($fredMode === 3) {
- $modx->resource->_output = \'\';
- return;
- }
-
- $html = Wa72\\HtmlPageDom\\HtmlPageCrawler::create($modx->resource->_output);
- $dzs = $html->filter(\'[data-fred-dropzone]\');
- $dzs->each(function(Wa72\\HtmlPageDom\\HtmlPageCrawler $node, $i) {
- $node->setInnerHtml(\'\');
- });
-
- $modx->resource->_output = $html->saveHTML();
-
- if ($fredMode === 2) {
- return;
- }
-
- $scripts = $html->filter(\'script\');
- $scripts->each(function(Wa72\\HtmlPageDom\\HtmlPageCrawler $node, $i) {
- $newNode = Wa72\\HtmlPageDom\\HtmlPageCrawler::create(\'<script-fred></script-fred>\');
-
- $attrs = $node->getNode(0)->attributes;
- foreach ($attrs as $attr) {
- $newNode->attr($attr->nodeName, $attr->nodeValue);
- }
-
- $newNode->setAttribute(\'data-fred-script\', $node->getInnerHtml());
-
- $node->replaceWith($newNode);
-
- });
- $modx->resource->_output = $html->saveHTML();
-
- $beforeRenderResults = $modx->invokeEvent(\'FredBeforeRender\');
- $includes = \'\';
- $beforeRender = \'\';
- $lexicons = [];
- foreach ($beforeRenderResults as $result) {
-
- if ($result[\'includes\']) {
- $includes .= $result[\'includes\'];
- }
-
- if ($result[\'beforeRender\']) {
- $beforeRender .= $result[\'beforeRender\'];
- }
-
- if ($result[\'lexicons\'] && is_array($result[\'lexicons\'])) {
- $lexicons = array_merge($lexicons, $result[\'lexicons\']);
- }
- }
-
- /** @var FredElementRTEConfig[] $rteConfigs */
- $rteConfigs = $modx->getIterator(\'FredElementRTEConfig\');
- $rteConfigString = [];
-
- foreach ($rteConfigs as $rteConfig) {
- if (empty($rteConfig->get(\'data\'))) continue;
-
- $rteConfigString[] = $rteConfig->name . \':\' . $rteConfig->data;
- }
- $rteConfigString = implode(\',\', $rteConfigString);
- $payload = [
- \'iss\' => $modx->user->id,
- \'resource\' => $modx->resource->id,
- \'queryParams\' => $_GET
- ];
-
- $jwt = \\Firebase\\JWT\\JWT::encode($payload, $fred->getSecret());
- $fredContent = \'
- <script type="text/javascript" src="\' . $fred->getOption(\'webAssetsUrl\') . \'fred.min.js"></script>
- <link rel="stylesheet" href="\' . $fred->getOption(\'webAssetsUrl\') . \'fred.css" type="text/css" />
- \' . $includes . \'
- <script>
- var fred = new Fred({
- theme: \' . $theme->id . \',
- assetsUrl: "\' . $fred->getOption(\'webAssetsUrl\') . \'",
- managerUrl: "\' . MODX_MANAGER_URL . \'",
- fredOffUrl: "\' . str_replace(\'&\', \'&\', $modx->makeUrl($modx->resource->id, \'\', array_merge($get, [\'fred\' => 4]) , \'abs\')) . \'",
- contextKey: "\' . $modx->resource->context_key. \'",
- launcherPosition: "\' . $fred->getOption(\'launcher_position\') . \'",
- iconEditor: "\' . $fred->getOption(\'icon_editor\') . \'",
- imageEditor: "\' . $fred->getOption(\'image_editor\') . \'",
- rte: "\' . $fred->getOption(\'rte\') . \'",
- rteConfig: {\' . $rteConfigString . \'},
- jwt: "\' . $jwt . \'",
- resource: {
- "id": \' . $modx->resource->id . \',
- "previewUrl": "\' . str_replace(\'&\', \'&\', $modx->makeUrl($modx->resource->id, \'\', array_merge($get, [\'fred\' => 2]) , \'abs\')) . \'",
- "emptyUrl": "\' . str_replace(\'&\', \'&\', $modx->makeUrl($modx->resource->id, \'\', array_merge($get, [\'fred\' => 3]) , \'abs\')) . \'",
- "save": \' . (int)$modx->resource->checkPolicy(\'save\') . \',
- "delete": \' . (int)$modx->resource->checkPolicy(\'delete\') . \',
- "undelete": \' . (int)$modx->resource->checkPolicy(\'undelete\') . \',
- "publish": \' . (int)$modx->resource->checkPolicy(\'publish\') . \',
- "unpublish": \' . (int)$modx->resource->checkPolicy(\'unpublish\') . \',
- },
- permission: {
- "fred_settings": \' . (int)$modx->hasPermission(\'fred_settings\') . \',
- "fred_settings_advanced": \' . (int)$modx->hasPermission(\'fred_settings_advanced\') . \',
- "fred_settings_tags": \' . (int)$modx->hasPermission(\'fred_settings_tags\') . \',
- "fred_settings_tvs": \' . (int)$modx->hasPermission(\'fred_settings_tvs\') . \',
- "fred_elements": \' . (int)$modx->hasPermission(\'fred_elements\') . \',
- "fred_blueprints": \' . (int)$modx->hasPermission(\'fred_blueprints\') . \',
- "fred_element_screenshot": \' . (int)$modx->hasPermission(\'fred_element_screenshot\') . \',
- "fred_element_move": \' . (int)$modx->hasPermission(\'fred_element_move\') . \',
- "fred_element_delete": \' . (int)$modx->hasPermission(\'fred_element_delete\') . \',
- "fred_blueprint_categories_save": \' . (int)$modx->hasPermission(\'fred_blueprint_categories_save\') . \',
- "fred_blueprint_categories_create_public": \' . (int)$modx->hasPermission(\'fred_blueprint_categories_create_public\') . \',
- "fred_blueprints_save": \' . (int)$modx->hasPermission(\'fred_blueprints_save\') . \',
- "fred_blueprints_create_public": \' . (int)$modx->hasPermission(\'fred_blueprints_create_public\') . \',
-
- "save_document": \' . (int)$modx->hasPermission(\'save_document\') . \',
- "delete_document" : \' . (int)$modx->hasPermission(\'delete_document\') . \',
- "undelete_document" : \' . (int)$modx->hasPermission(\'undelete_document\') . \',
- "publish_document" : \' . (int)$modx->hasPermission(\'publish_document\') . \',
- "unpublish_document" : \' . (int)$modx->hasPermission(\'unpublish_document\') . \',
- "new_document" : \' . (int)$modx->hasPermission(\'new_document\') . \',
- "resource_duplicate" : \' . (int)$modx->hasPermission(\'resource_duplicate\') . \',
- "new_document_in_root" : \' . (int)$modx->hasPermission(\'new_document_in_root\') . \'
- },
- lexicons: \' . json_encode($lexicons) . \',
- beforeRender: function() {
- \' . $beforeRender . \'
- }
- });
- </script>\';
- $modx->resource->_output = preg_replace(\'/(<\\/head>(?:<\\/head>)?)/i\', "{$fredContent}\\r\\n$1", $modx->resource->_output);
- }
- break;
- case \'OnBeforeDocFormSave\':
- if ($mode !== \'upd\') return;
- if (empty($fred->getTheme($resource->template))) return;
-
- $data = $resource->getProperty(\'data\', \'fred\');
- if (!empty($data[\'fingerprint\'])) {
- if (empty($resource->fingerprint)) {
- $modx->event->_output = \'No fingerprint was provided.\';
- return;
- }
- if ($data[\'fingerprint\'] !== $resource->fingerprint) {
- $modx->event->_output = \'Your page is outdated, please reload the page.\';
- return;
- }
- }
-
- break;
- case \'OnDocFormSave\':
- if ($mode !== \'upd\') return;
- if (empty($fred->getTheme($resource->template))) return;
-
- $renderResource = new \\Fred\\RenderResource($resource, $modx);
- $renderResource->render();
-
- break;
- case \'OnTemplateRemove\':
- /** @var modTemplate $template */
- $templateId = $template->id;
- if (!empty($templateId)) {
- /** @var FredThemedTemplate $themedTemplate */
- $themedTemplate = $modx->getObject(\'FredThemedTemplate\', [\'template\' => $templateId]);
- if ($themedTemplate) {
- $themedTemplate->remove();
- }
- }
-
- break;
- case \'OnTVInputRenderList\':
- $modx->event->output($corePath . \'elements/tvs/input/\');
- break;
- case \'OnTVInputPropertiesList\':
- $modx->event->output($corePath . \'elements/tvs/input/options/\');
- break;
- case \'OnManagerPageBeforeRender\':
- $modx->controller->addLexiconTopic(\'fred:default\');
- break;
- }
- return;',
- 'locked' => 0,
- 'properties' => 'a:0:{}',
- 'disabled' => 0,
- 'moduleguid' => '',
- 'static' => 0,
- 'static_file' => '',
- 'content' => '/*
- * This file is part of the Fred package.
- *
- * Copyright (c) MODX, LLC
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- $corePath = $modx->getOption(\'fred.core_path\', null, $modx->getOption(\'core_path\', null, MODX_CORE_PATH) . \'components/fred/\');
- /** @var Fred $fred */
- $fred = $modx->getService(
- \'fred\',
- \'Fred\',
- $corePath . \'model/fred/\',
- array(
- \'core_path\' => $corePath
- )
- );
- switch ($modx->event->name) {
- case \'OnDocFormPrerender\':
- if(!empty($resource) && !empty($fred->getTheme($resource->template))) {
- //Disable ContentBlocks
- $isContentBlocks = $resource->getProperty(\'_isContentBlocks\', \'contentblocks\', null);
- if($isContentBlocks !== false){
- $resource->setProperty(\'_isContentBlocks\', false, \'contentblocks\');
- $resource->save();
- }
- $data = $resource->getProperty(\'data\', \'fred\');
- $fingerprint = !empty($data[\'fingerprint\']) ? $data[\'fingerprint\'] : \'\';
-
- //Load Open in Fred button
- $modx->lexicon->load(\'fred:default\');
- $modx->controller->addLexiconTopic(\'fred:default\');
- $modx->controller->addHtml("
- <script>
- Ext.ComponentMgr.onAvailable(\'modx-resource-content\', function(right) {
- right.on(\'beforerender\', function() {
- var content = Ext.getCmp(\'ta\'),
- contentvalue = content.getValue(),
- panel = Ext.getCmp(\'modx-page-update-resource\');
-
- content.destroy();
-
- right.insert(0,{
- xtype: \'button\'
- ,fieldLabel: _(\'fred.open_in_fred\')
- ,hideLabel: true
- ,cls: \'primary-button\'
- ,style: {padding: \'10px 15px\'}
- ,html: _(\'fred.open_in_fred\')
- ,handler: function(){
- window.open(panel.config.preview_url)
- }
- });
-
- right.insert(1,{
- xtype: \'textarea\'
- ,hideLabel: true
- ,anchor: \'100%\'
- ,grow: true
- ,style: {marginTop:\'15px\'}
- ,disabled: true
- ,value: contentvalue
- });
- });
-
- right.on(\'afterrender\', function() {
- var panel = Ext.getCmp(\'modx-panel-resource\');
-
- panel.on(\'success\', function(){
- location.reload();
- });
-
- var fingerprint = document.createElement(\'input\');
- fingerprint.setAttribute(\'type\', \'hidden\');
- fingerprint.setAttribute(\'name\', \'fingerprint\');
- fingerprint.setAttribute(\'value\', \'" . $fingerprint . "\');
- panel.form.el.dom.appendChild(fingerprint);
- });
- });
-
- </script>");
- }
- break;
- case \'OnLoadWebDocument\':
- $theme = $fred->getTheme($modx->resource->template);
- if (!empty($theme)) {
- $themeUri = $theme->getThemeFolderUri();
- $modx->setPlaceholder(\'+fred.theme_dir\', $themeUri);
- $modx->setOption(\'fred.theme_dir\', $themeUri);
- }
- break;
- case \'OnWebPagePrerender\':
- $theme = $fred->getTheme($modx->resource->template);
- if (!empty($theme)) {
-
- if (!$modx->user) return;
- if (!($modx->user->hasSessionContext(\'mgr\') || $modx->user->hasSessionContext($modx->resource->context_key))) return;
- if (!$modx->hasPermission(\'fred\')) return;
- $modx->lexicon->load(\'fred:fe\');
-
- $fredMode = 1;
-
- if (isset($_SESSION[\'fred\'])) {
- $fredMode = intval($_SESSION[\'fred\']);
- }
-
- if (isset($_GET[\'fred\'])) {
- $fredMode = intval($_GET[\'fred\']);
- }
-
- if ($fredMode === 4) {
- $fredMode = 0;
- $_SESSION[\'fred\'] = 0;
- }
-
- if ($fredMode === 1) {
- $_SESSION[\'fred\'] = 1;
- }
- $get = $_GET;
- unset($get[$modx->getOption(\'request_param_alias\', [], \'q\')]);
-
- if ($fredMode === 0) {
- $button = "<a href=\\"" . str_replace(\'&\', \'&\', $modx->makeUrl($modx->resource->id, \'\', array_merge($get, [\'fred\' => 1]) , \'abs\')) . "\\" title=\\"" . $modx->lexicon(\'fred.fe.turn_on_fred\') . "\\" role=\\"button\\" style=\\"display: block; text-decoration: none; background-color: #4D4D4D; background-image: url("data:image/svg+xml, %3Csvg xmlns=\'http://www.w3.org/2000/svg\' width=\'48\' height=\'48\' viewBox=\'-14.584 -8.583 48 48\'%3E%3ClinearGradient id=\'a\' gradientUnits=\'userSpaceOnUse\' x1=\'2164.318\' y1=\'-2519.043\' x2=\'2047.448\' y2=\'-2442.941\' gradientTransform=\'matrix(.1471 0 0 -.1471 -290.574 -365.794)\'%3E%3Cstop offset=\'0\' stop-color=\'%2380c3e6\'/%3E%3Cstop offset=\'1\' stop-color=\'%233380c2\'/%3E%3C/linearGradient%3E%3Cpath fill=\'url(%23a)\' d=\'M22.035 11.468l9.602-15.406H8.488L5.236 1.17z\'/%3E%3Cpath opacity=\'.15\' d=\'M5.236 1.17l1.702-2.633 15.097 12.931z\'/%3E%3ClinearGradient id=\'b\' gradientUnits=\'userSpaceOnUse\' x1=\'2184.769\' y1=\'-2694.977\' x2=\'2097.394\' y2=\'-2637.275\' gradientTransform=\'matrix(.1471 0 0 -.1471 -290.574 -365.794)\'%3E%3Cstop offset=\'0\' stop-color=\'%23f38649\'/%3E%3Cstop offset=\'.185\' stop-color=\'%23f28147\'/%3E%3Cstop offset=\'.409\' stop-color=\'%23ef7242\'/%3E%3Cstop offset=\'.654\' stop-color=\'%23ea5a3a\'/%3E%3Cstop offset=\'.911\' stop-color=\'%23e4382e\'/%3E%3Cstop offset=\'1\' stop-color=\'%23e12a29\'/%3E%3C/linearGradient%3E%3Cpath fill=\'url(%23b)\' d=\'M27.068 39.416V16.268l-4.957-3.176L11.583 29.74z\'/%3E%3Cpath opacity=\'.15\' d=\'M11.583 29.74l2.632 1.625 7.896-18.273z\'/%3E%3ClinearGradient id=\'c\' gradientUnits=\'userSpaceOnUse\' x1=\'1896.918\' y1=\'-2571.592\' x2=\'2064.08\' y2=\'-2467.137\' gradientTransform=\'matrix(.1471 0 0 -.1471 -290.574 -365.794)\'%3E%3Cstop offset=\'0\' stop-color=\'%2342ab4a\'/%3E%3Cstop offset=\'1\' stop-color=\'%23add155\'/%3E%3C/linearGradient%3E%3Cpath fill=\'url(%23c)\' d=\'M-10.25-8.583v23.148l5.419 3.175 26.866-6.272z\'/%3E%3ClinearGradient id=\'d\' gradientUnits=\'userSpaceOnUse\' x1=\'1933.576\' y1=\'-2758.292\' x2=\'2069.413\' y2=\'-2540.907\' gradientTransform=\'matrix(.1471 0 0 -.1471 -290.574 -365.794)\'%3E%3Cstop offset=\'0\' stop-color=\'%2342ab4a\'/%3E%3Cstop offset=\'1\' stop-color=\'%23add155\'/%3E%3C/linearGradient%3E%3Cpath fill=\'url(%23d)\' d=\'M-4.985 19.52l-9.599 15.093H8.565l13.546-21.521z\'/%3E%3C/svg%3E"); height: 48px; width: 48px; border-radius: 50%; outline: 0; border: none; background-repeat: no-repeat; background-size: 60%; background-position: center; box-shadow: rgba(18,55,100,0.34) 0 4px 8px; margin: 0; padding: 0; text-indent: -9999px; cursor: pointer; position: fixed; z-index: 10010; margin: 32px; bottom: 0; left: 0; opacity: 0.8; transition: .3s; box-sizing: border-box;\\" onmouseover=\\"this.style.transform=\'scale(1.05)\';\\" onmouseout=\\"this.style.transform=\'initial\'\\";>Fred</a>";
-
- $modx->resource->_output = preg_replace(\'/(<\\/body>(?:<\\/body>)?)/i\', "{$button}\\r\\n$1", $modx->resource->_output);
- return;
- }
- if ($fredMode === 3) {
- $modx->resource->_output = \'\';
- return;
- }
-
- $html = Wa72\\HtmlPageDom\\HtmlPageCrawler::create($modx->resource->_output);
- $dzs = $html->filter(\'[data-fred-dropzone]\');
- $dzs->each(function(Wa72\\HtmlPageDom\\HtmlPageCrawler $node, $i) {
- $node->setInnerHtml(\'\');
- });
-
- $modx->resource->_output = $html->saveHTML();
-
- if ($fredMode === 2) {
- return;
- }
-
- $scripts = $html->filter(\'script\');
- $scripts->each(function(Wa72\\HtmlPageDom\\HtmlPageCrawler $node, $i) {
- $newNode = Wa72\\HtmlPageDom\\HtmlPageCrawler::create(\'<script-fred></script-fred>\');
-
- $attrs = $node->getNode(0)->attributes;
- foreach ($attrs as $attr) {
- $newNode->attr($attr->nodeName, $attr->nodeValue);
- }
-
- $newNode->setAttribute(\'data-fred-script\', $node->getInnerHtml());
-
- $node->replaceWith($newNode);
-
- });
- $modx->resource->_output = $html->saveHTML();
-
- $beforeRenderResults = $modx->invokeEvent(\'FredBeforeRender\');
- $includes = \'\';
- $beforeRender = \'\';
- $lexicons = [];
- foreach ($beforeRenderResults as $result) {
-
- if ($result[\'includes\']) {
- $includes .= $result[\'includes\'];
- }
-
- if ($result[\'beforeRender\']) {
- $beforeRender .= $result[\'beforeRender\'];
- }
-
- if ($result[\'lexicons\'] && is_array($result[\'lexicons\'])) {
- $lexicons = array_merge($lexicons, $result[\'lexicons\']);
- }
- }
-
- /** @var FredElementRTEConfig[] $rteConfigs */
- $rteConfigs = $modx->getIterator(\'FredElementRTEConfig\');
- $rteConfigString = [];
-
- foreach ($rteConfigs as $rteConfig) {
- if (empty($rteConfig->get(\'data\'))) continue;
-
- $rteConfigString[] = $rteConfig->name . \':\' . $rteConfig->data;
- }
- $rteConfigString = implode(\',\', $rteConfigString);
- $payload = [
- \'iss\' => $modx->user->id,
- \'resource\' => $modx->resource->id,
- \'queryParams\' => $_GET
- ];
-
- $jwt = \\Firebase\\JWT\\JWT::encode($payload, $fred->getSecret());
- $fredContent = \'
- <script type="text/javascript" src="\' . $fred->getOption(\'webAssetsUrl\') . \'fred.min.js"></script>
- <link rel="stylesheet" href="\' . $fred->getOption(\'webAssetsUrl\') . \'fred.css" type="text/css" />
- \' . $includes . \'
- <script>
- var fred = new Fred({
- theme: \' . $theme->id . \',
- assetsUrl: "\' . $fred->getOption(\'webAssetsUrl\') . \'",
- managerUrl: "\' . MODX_MANAGER_URL . \'",
- fredOffUrl: "\' . str_replace(\'&\', \'&\', $modx->makeUrl($modx->resource->id, \'\', array_merge($get, [\'fred\' => 4]) , \'abs\')) . \'",
- contextKey: "\' . $modx->resource->context_key. \'",
- launcherPosition: "\' . $fred->getOption(\'launcher_position\') . \'",
- iconEditor: "\' . $fred->getOption(\'icon_editor\') . \'",
- imageEditor: "\' . $fred->getOption(\'image_editor\') . \'",
- rte: "\' . $fred->getOption(\'rte\') . \'",
- rteConfig: {\' . $rteConfigString . \'},
- jwt: "\' . $jwt . \'",
- resource: {
- "id": \' . $modx->resource->id . \',
- "previewUrl": "\' . str_replace(\'&\', \'&\', $modx->makeUrl($modx->resource->id, \'\', array_merge($get, [\'fred\' => 2]) , \'abs\')) . \'",
- "emptyUrl": "\' . str_replace(\'&\', \'&\', $modx->makeUrl($modx->resource->id, \'\', array_merge($get, [\'fred\' => 3]) , \'abs\')) . \'",
- "save": \' . (int)$modx->resource->checkPolicy(\'save\') . \',
- "delete": \' . (int)$modx->resource->checkPolicy(\'delete\') . \',
- "undelete": \' . (int)$modx->resource->checkPolicy(\'undelete\') . \',
- "publish": \' . (int)$modx->resource->checkPolicy(\'publish\') . \',
- "unpublish": \' . (int)$modx->resource->checkPolicy(\'unpublish\') . \',
- },
- permission: {
- "fred_settings": \' . (int)$modx->hasPermission(\'fred_settings\') . \',
- "fred_settings_advanced": \' . (int)$modx->hasPermission(\'fred_settings_advanced\') . \',
- "fred_settings_tags": \' . (int)$modx->hasPermission(\'fred_settings_tags\') . \',
- "fred_settings_tvs": \' . (int)$modx->hasPermission(\'fred_settings_tvs\') . \',
- "fred_elements": \' . (int)$modx->hasPermission(\'fred_elements\') . \',
- "fred_blueprints": \' . (int)$modx->hasPermission(\'fred_blueprints\') . \',
- "fred_element_screenshot": \' . (int)$modx->hasPermission(\'fred_element_screenshot\') . \',
- "fred_element_move": \' . (int)$modx->hasPermission(\'fred_element_move\') . \',
- "fred_element_delete": \' . (int)$modx->hasPermission(\'fred_element_delete\') . \',
- "fred_blueprint_categories_save": \' . (int)$modx->hasPermission(\'fred_blueprint_categories_save\') . \',
- "fred_blueprint_categories_create_public": \' . (int)$modx->hasPermission(\'fred_blueprint_categories_create_public\') . \',
- "fred_blueprints_save": \' . (int)$modx->hasPermission(\'fred_blueprints_save\') . \',
- "fred_blueprints_create_public": \' . (int)$modx->hasPermission(\'fred_blueprints_create_public\') . \',
-
- "save_document": \' . (int)$modx->hasPermission(\'save_document\') . \',
- "delete_document" : \' . (int)$modx->hasPermission(\'delete_document\') . \',
- "undelete_document" : \' . (int)$modx->hasPermission(\'undelete_document\') . \',
- "publish_document" : \' . (int)$modx->hasPermission(\'publish_document\') . \',
- "unpublish_document" : \' . (int)$modx->hasPermission(\'unpublish_document\') . \',
- "new_document" : \' . (int)$modx->hasPermission(\'new_document\') . \',
- "resource_duplicate" : \' . (int)$modx->hasPermission(\'resource_duplicate\') . \',
- "new_document_in_root" : \' . (int)$modx->hasPermission(\'new_document_in_root\') . \'
- },
- lexicons: \' . json_encode($lexicons) . \',
- beforeRender: function() {
- \' . $beforeRender . \'
- }
- });
- </script>\';
- $modx->resource->_output = preg_replace(\'/(<\\/head>(?:<\\/head>)?)/i\', "{$fredContent}\\r\\n$1", $modx->resource->_output);
- }
- break;
- case \'OnBeforeDocFormSave\':
- if ($mode !== \'upd\') return;
- if (empty($fred->getTheme($resource->template))) return;
-
- $data = $resource->getProperty(\'data\', \'fred\');
- if (!empty($data[\'fingerprint\'])) {
- if (empty($resource->fingerprint)) {
- $modx->event->_output = \'No fingerprint was provided.\';
- return;
- }
- if ($data[\'fingerprint\'] !== $resource->fingerprint) {
- $modx->event->_output = \'Your page is outdated, please reload the page.\';
- return;
- }
- }
-
- break;
- case \'OnDocFormSave\':
- if ($mode !== \'upd\') return;
- if (empty($fred->getTheme($resource->template))) return;
-
- $renderResource = new \\Fred\\RenderResource($resource, $modx);
- $renderResource->render();
-
- break;
- case \'OnTemplateRemove\':
- /** @var modTemplate $template */
- $templateId = $template->id;
- if (!empty($templateId)) {
- /** @var FredThemedTemplate $themedTemplate */
- $themedTemplate = $modx->getObject(\'FredThemedTemplate\', [\'template\' => $templateId]);
- if ($themedTemplate) {
- $themedTemplate->remove();
- }
- }
-
- break;
- case \'OnTVInputRenderList\':
- $modx->event->output($corePath . \'elements/tvs/input/\');
- break;
- case \'OnTVInputPropertiesList\':
- $modx->event->output($corePath . \'elements/tvs/input/options/\');
- break;
- case \'OnManagerPageBeforeRender\':
- $modx->controller->addLexiconTopic(\'fred:default\');
- break;
- }
- return;',
- ),
- ),
- 'a0f4192e60d8cc6038bbb32254ad6896' =>
- array (
- 'criteria' =>
- array (
- 'pluginid' => 14,
- 'event' => 'OnWebPagePrerender',
- ),
- 'object' =>
- array (
- 'pluginid' => 14,
- 'event' => 'OnWebPagePrerender',
- 'priority' => 0,
- 'propertyset' => 0,
- ),
- ),
- 'dfaedf785eab506f6b48f37c84e53714' =>
- array (
- 'criteria' =>
- array (
- 'pluginid' => 14,
- 'event' => 'OnDocFormPrerender',
- ),
- 'object' =>
- array (
- 'pluginid' => 14,
- 'event' => 'OnDocFormPrerender',
- 'priority' => 0,
- 'propertyset' => 0,
- ),
- ),
- '501111671ee829b4eb1e037381ebbd95' =>
- array (
- 'criteria' =>
- array (
- 'pluginid' => 14,
- 'event' => 'OnDocFormSave',
- ),
- 'object' =>
- array (
- 'pluginid' => 14,
- 'event' => 'OnDocFormSave',
- 'priority' => 0,
- 'propertyset' => 0,
- ),
- ),
- 'e8f6b20202e9416e30a454a6c1d5888f' =>
- array (
- 'criteria' =>
- array (
- 'pluginid' => 14,
- 'event' => 'OnBeforeDocFormSave',
- ),
- 'object' =>
- array (
- 'pluginid' => 14,
- 'event' => 'OnBeforeDocFormSave',
- 'priority' => 0,
- 'propertyset' => 0,
- ),
- ),
- '51e45e7d35ca8da67bd6512f1c12a5b5' =>
- array (
- 'criteria' =>
- array (
- 'pluginid' => 14,
- 'event' => 'OnTemplateRemove',
- ),
- 'object' =>
- array (
- 'pluginid' => 14,
- 'event' => 'OnTemplateRemove',
- 'priority' => 0,
- 'propertyset' => 0,
- ),
- ),
- 'd40c0e6d1d8d1648c963a68cde3798d4' =>
- array (
- 'criteria' =>
- array (
- 'pluginid' => 14,
- 'event' => 'OnLoadWebDocument',
- ),
- 'object' =>
- array (
- 'pluginid' => 14,
- 'event' => 'OnLoadWebDocument',
- 'priority' => 0,
- 'propertyset' => 0,
- ),
- ),
- '6a7f166b5c0ab6d45db23e30d83c1271' =>
- array (
- 'criteria' =>
- array (
- 'pluginid' => 14,
- 'event' => 'OnTVInputRenderList',
- ),
- 'object' =>
- array (
- 'pluginid' => 14,
- 'event' => 'OnTVInputRenderList',
- 'priority' => 0,
- 'propertyset' => 0,
- ),
- ),
- 'da2e9bb714656f59c006ff47c6d9f864' =>
- array (
- 'criteria' =>
- array (
- 'pluginid' => 14,
- 'event' => 'OnTVInputPropertiesList',
- ),
- 'object' =>
- array (
- 'pluginid' => 14,
- 'event' => 'OnTVInputPropertiesList',
- 'priority' => 0,
- 'propertyset' => 0,
- ),
- ),
- 'ec13d93ab8ec9930ac9afb5f2e60acfb' =>
- array (
- 'criteria' =>
- array (
- 'pluginid' => 14,
- 'event' => 'OnManagerPageBeforeRender',
- ),
- 'object' =>
- array (
- 'pluginid' => 14,
- 'event' => 'OnManagerPageBeforeRender',
- 'priority' => 0,
- 'propertyset' => 0,
- ),
- ),
- '80956ebc997d6cdb547f0466311f2610' =>
- array (
- 'criteria' =>
- array (
- 'text' => 'fred.menu.fred',
- ),
- 'object' =>
- array (
- 'text' => 'fred.menu.fred',
- 'parent' => 'components',
- 'action' => 'home',
- 'description' => 'fred.menu.fred_desc',
- 'icon' => '',
- 'menuindex' => 0,
- 'params' => '',
- 'handler' => '',
- 'permissions' => 'fred',
- 'namespace' => 'fred',
- ),
- ),
- );
|