Skip to content

Commit

Permalink
Added TinyMCE as optional WYSWYG HTML editor
Browse files Browse the repository at this point in the history
  • Loading branch information
mbeccati committed Sep 8, 2017
1 parent 91b5f9d commit 2f022aa
Show file tree
Hide file tree
Showing 13 changed files with 304 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -21,6 +21,7 @@ phpinfo.php
/var/templates_compiled/*.php
/var/templates_compiled/*.serial
/www/admin/plugins/*
/www/admin/assets/tinymce
/www/images/
/plugins_repo/build-ap.xml
/plugins_repo/release/*.zip
Expand Down
7 changes: 7 additions & 0 deletions RELEASE_NOTES.txt
Expand Up @@ -57,6 +57,13 @@ What's New in Revive Adserver 4.1.0
* Added new security feature to invalidate all the active sessions of the
current user when changing or recovering the password.

* Added the option to use TinyMCE as WYSWYG HTML editor when creating and
editing HTML banners. The editor is switched off by default, for
increased backwards compatibility, but it can be enabled by default via
the user interface account preferences. Such preference is however
ignored when editing HTML ads containing scripts or iframes in order to
avoid inadvertently altering 3rd party tags.

Bug Fixes
---------

Expand Down
6 changes: 5 additions & 1 deletion build-filelist.xml
Expand Up @@ -27,8 +27,10 @@
<exclude name="etc/changesfantasy/**"/>
<include name="etc/permanentcache/**"/>
<include name="lib/**"/>
<exclude name="lib/simpletest/**"/>
<exclude name="lib/ant/**"/>
<exclude name="lib/simpletest/**"/>
<exclude name="lib/vendor/figdice/**"/>
<exclude name="lib/vendor/tinymce/**"/>
<include name="maintenance/**"/>
<include name="plugins/**"/>
<include name="scripts/maintenance/**"/>
Expand Down Expand Up @@ -86,6 +88,8 @@
<include name="etc/changesfantasy/**"/>
<include name="lib/ant/**"/>
<include name="lib/simpletest/**"/>
<include name="lib/vendor/figdice/**"/>
<include name="lib/vendor/tinymce/**"/>
<exclude name="plugins/**"/>
<include name="scripts/db_dataobject/**"/>
<include name="scripts/delivery/**"/>
Expand Down
19 changes: 19 additions & 0 deletions composer.json
Expand Up @@ -20,9 +20,28 @@
},
"require": {
"sinergi/browser-detector": "^6.0",
"figdice/asseteer": "dev-master",
"tinymce/tinymce": "^4.6",
"jeremykendall/php-domain-parser": "~2.0"
},
"require-dev": {
"symfony/finder": "^3.1"
},
"extra": {
"post-install-asseteer": [
{
"vendor": "tinymce",
"target": "www/admin/assets",
"filters": [ "\\.min.(js|css)$", "\\.(eot|ttf|svg|woff)" ]
}
]
},
"scripts" :{
"post-install-cmd": [
"asseteer\\AssetInstaller::postInstall"
],
"post-update-cmd": [
"asseteer\\AssetInstaller::postInstall"
]
}
}
128 changes: 114 additions & 14 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 7 additions & 10 deletions lib/Max.php
Expand Up @@ -22,15 +22,13 @@
*/
class MAX
{

/**
* Converts error code constants into equivalent strings.
*
* @access public
* @param integer $errorCode The error code.
* @return string Text representing the error code.
*/
function errorConstantToString($errorCode)
public static function errorConstantToString($errorCode)
{
$aErrorCodes = array(
MAX_ERROR_INVALIDARGS => 'invalid arguments',
Expand Down Expand Up @@ -61,14 +59,15 @@ function errorConstantToString($errorCode)
return 'PEAR';
}
}

/**
* A method to convert PEAR_Error objects to strings.
*
* @static
* @param PEAR_Error $oError A {@link PEAR_Error} object
* @param string $additionalInfo
*
* @return string
*/
function errorObjToString($oError, $additionalInfo = null)
public static function errorObjToString($oError, $additionalInfo = null)
{
$aConf = $GLOBALS['_MAX']['CONF'];
$message = htmlspecialchars($oError->getMessage());
Expand Down Expand Up @@ -103,7 +102,7 @@ function errorObjToString($oError, $additionalInfo = null)
* @param integer $behaviour Optional behaviour (i.e. PEAR_ERROR_DIE to halt on this error).
* @return PEAR_Error $error A (@link PEAR_Error} object.
*/
function raiseError($message, $type = null, $behaviour = null)
public static function raiseError($message, $type = null, $behaviour = null)
{
// If fatal
if ($behaviour == PEAR_ERROR_DIE) {
Expand All @@ -126,7 +125,7 @@ function raiseError($message, $type = null, $behaviour = null)
* @param string $file An optional file name.
* @return string The URL to the file.
*/
function constructURL($type, $file = null)
public static function constructURL($type, $file = null)
{
$aConf = $GLOBALS['_MAX']['CONF'];
// Prepare the base URL
Expand All @@ -151,8 +150,6 @@ function constructURL($type, $file = null)
// Return the URL
return $GLOBALS['_MAX']['HTTP'] . $path . $file;
}


}

/**
Expand Down
35 changes: 32 additions & 3 deletions lib/OX/Extension/bannerTypeHtml/bannerTypeHtml.php
Expand Up @@ -55,6 +55,10 @@ function getOptionDescription()
*/
function buildForm(&$form, &$row)
{
if (!function_exists('_adRenderBuildImageUrlPrefix')) {
require_once (MAX_PATH . '/lib/max/Delivery/adRender.php');
}

$form->setAttribute("onSubmit", "return max_formValidateHtml(this.banner)");
$header = $form->createElement('header', 'header_html', $GLOBALS['strHTMLBanner']." - banner code");
$header->setAttribute('icon', 'icon-banner-html.gif');
Expand All @@ -69,14 +73,35 @@ function buildForm(&$form, &$row)
$adPluginsList[$adPluginKey] = $adPluginName;
}

$imgUrlPrefixJs = json_encode(_adRenderBuildImageUrlPrefix());

$useTinyMCE = !empty($GLOBALS['_MAX']['PREF']['ui_html_wyswyg_enabled']) &&
!preg_match('#<(?:script|iframe)#i', $row['htmltemplate']);

$htmlG['textarea'] = $form->createElement('textarea', 'htmltemplate', null,
array(
'class' =>'code', 'cols'=>'45', 'rows'=>'10', 'wrap'=>'off',
'dir' => 'ltr', 'style'=>'width:550px;'
'class' =>'code', 'cols'=>'70', 'rows'=>'10', 'wrap'=>'off',
'dir' => 'ltr', 'style'=>'width:728px;'
));
$aSelectAttributes = array('id'=>'adserver', 'style' => 'margin-left: 15px;width:230px');
$aSelectLabel = sprintf(
'%1$s <a href="%3$s" title="%2$s""><img src="%4$s" alt="%2$s"></a>',
$GLOBALS['strUseWyswygHtmlEditor'],
$GLOBALS['strChangeDefault'],
htmlspecialchars(MAX::constructURL(MAX_URL_ADMIN, 'account-preferences-user-interface.php')),
htmlspecialchars(MAX::constructURL(MAX_URL_ADMIN, 'assets/images/help-book.gif'))
);
$htmlG['tinyMCE'] = HTML_QuickForm::createElement('checkbox', 'tinymce', $aSelectLabel, '', ['id'=>'tinymce', 'onclick' => "rv_tinymce('#htmltemplate', this.checked, {$imgUrlPrefixJs})"]);
$htmlG['select'] = HTML_QuickForm::createElement('select', 'adserver', $GLOBALS['strAlterHTML'], $adPluginsList, $aSelectAttributes);
$form->addGroup($htmlG, 'html_banner_g', null, array("<br>", ""), false);
$htmlG['js'] = HTML_QuickForm::createElement('html', '', <<<EOF
<script>
jQuery(function() {
rv_tinymce("#htmltemplate", jQuery('#tinymce')[0].checked, {$imgUrlPrefixJs});
});
</script>
EOF
);
$form->addGroup($htmlG, 'html_banner_g', null, array("<br>", "<br><br>", ''), false);

$form->addElement('advcheckbox', 'iframe_friendly', $GLOBALS['strIframeFriendly']);

Expand Down Expand Up @@ -112,6 +137,10 @@ function buildForm(&$form, &$row)
$form->addGroupRule('size', array(
'width' => array($widthRequiredRule, $numericRule),
'height' => array($heightRequiredRule, $numericRule)));

$form->setDefaults([
'tinymce' => $useTinyMCE,
]);
}

function preprocessForm($insert, $bannerid, &$aFields, &$aVariables)
Expand Down

0 comments on commit 2f022aa

Please sign in to comment.