function n1ed_preprocess_page in N1ED - Visual editor as CKEditor plugin with Bootstrap support 7
Implementation of hook_preprocess_page
File
- ./
n1ed.module, line 74
Code
function n1ed_preprocess_page(&$page) {
if ($page['page']['content']['system_main'] && @$page['page']['content']['system_main']['#node_edit_form']) {
if (!variable_get('n1edApiKey')) {
variable_set('n1edApiKey', 'N1D7DFLT');
}
$version = variable_get('n1ed_version') ?: '';
if ($version === '') {
$version = 'latest';
}
$urlCache = variable_get('urlCache') ?: '';
if ($urlCache === '') {
// Fix for: https://www.drupal.org/project/n1ed/issues/3111919
// Do not start URL with "https:" prefix.
// Notice about cookies: developers use it to specify debug server to use,.
// All other users will use old known cloud.n1ed.com address.
$path = '//' . (isset($_COOKIE["N1ED_PREFIX"]) ? $_COOKIE["N1ED_PREFIX"] . "." : "") . 'cloud.n1ed.com/cdn/' . variable_get('n1edApiKey') . '/' . $version . '/ckeditor/plugins/N1EDEco/plugin.js';
}
else {
// Fix for: https://www.drupal.org/project/n1ed/issues/3111919
// Do not start URL with "https:" prefix.
if (strpos($urlCache, "http:") === 0) {
$urlCache = substr($urlCache, 5);
}
elseif (strpos($urlCache, "https:") === 0) {
$urlCache = substr($urlCache, 6);
}
$path = $urlCache . variable_get('n1edApiKey') . '/' . $version . '/ckeditor/plugins/N1EDEco/plugin.js';
}
drupal_add_js([
'N1ED' => [
'urlPlugin' => $path,
'urlFileManager' => '/admin/config/content/n1ed/flmngr',
'urlFiles' => '/' . variable_get('file_public_path', conf_path() . '/files/'),
'defaultUploadDir' => '/uploads/',
],
], 'setting');
}
}