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:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 
<?php
$plugin_is_filter = 5 | ADMIN_PLUGIN;
$plugin_description = gettext("Text editor TinyMCE 4.x");
$plugin_author = "Malte Müller (acrylian)";
$plugin_category = gettext('Admin');
$option_interface = 'tinymce4Options';
if (!defined('EDITOR_SANITIZE_LEVEL'))
    define('EDITOR_SANITIZE_LEVEL', 4);
zp_register_filter('texteditor_config', 'tinymce4ConfigJS');
class tinymce4Options {
    function __construct() {
        setOptionDefault('tinymce4_zenphoto', 'zenphoto-ribbon.js.php');
        setOptionDefault('tinymce4_zenpage', 'zenpage-slim.js.php');
        setOptionDefault('tinymce4_entitiyencoding', 'raw');
        if (getOption('zp_plugin_tiny_mce')) {
            setOptionDefault('zp_plugin_tinymce4', 5 | ADMIN_PLUGIN);
            purgeOption('zp_plugin_tiny_mce');
        }
    }
    function getOptionsSupported() {
        $configs_zenpage = getTinyMCE4ConfigFiles('zenpage');
        $configs_zenphoto = getTinyMCE4ConfigFiles('zenphoto');
        $options = array(
                gettext('Text editor configuration - Zenphoto') => array(
                        'key' => 'tinymce4_zenphoto',
                        'type' => OPTION_TYPE_SELECTOR,
                        'order' => 0,
                        'selections' => $configs_zenphoto,
                        'null_selection' => gettext('Disabled'),
                        'desc' => gettext('Applies to <em>admin</em> editable text other than for Zenpage pages and news articles.')),
                gettext('Text editor configuration - Zenpage') => array(
                        'key' => 'tinymce4_zenpage',
                        'type' => OPTION_TYPE_SELECTOR,
                        'order' => 0,
                        'selections' => $configs_zenpage,
                        'null_selection' => gettext('Disabled'),
                        'desc' => gettext('Applies to editing on the Zenpage <em>pages</em> and <em>news</em> tabs.')),
                gettext('Custom image size') => array(
                        'key' => 'tinymce_tinyzenpage_customimagesize',
                        'type' => OPTION_TYPE_TEXTBOX,
                        'order' => 2,
                        'desc' => gettext("Predefined size (px) for custom size images included using tinyZenpage.")),
                gettext('Custom image size') => array(
                        'key' => 'tinymce_tinyzenpage_customimagesize',
                        'type' => OPTION_TYPE_TEXTBOX,
                        'order' => 2,
                        'desc' => gettext("Predefined size (px) for custom size images included using tinyZenpage.")),
                gettext('Custom thumb crop - size') => array(
                        'key' => 'tinymce_tinyzenpage_customthumb_size',
                        'type' => OPTION_TYPE_TEXTBOX,
                        'order' => 2,
                        'desc' => gettext("Predefined size (px) for custom cropped thumb images included using tinyZenpage.")),
                gettext('Custom thumb crop - width') => array(
                        'key' => 'tinymce_tinyzenpage_customthumb_cropwidth',
                        'type' => OPTION_TYPE_TEXTBOX,
                        'order' => 2,
                        'desc' => gettext("Predefined crop width (%) for custom cropped thumb  images included using tinyZenpage.")),
                gettext('Custom thumb crop - height') => array(
                        'key' => 'tinymce_tinyzenpage_customthumb_cropheight',
                        'type' => OPTION_TYPE_TEXTBOX,
                        'order' => 2,
                        'desc' => gettext("Predefined crop height (%) for custom cropped thumb images included using tinyZenpage.")),
                gettext('Entity encoding') => array(
                        'key' => 'tinymce4_entityencoding',
                        'type' => OPTION_TYPE_SELECTOR,
                        'order' => 3,
                        'selections' => array(
                                gettext('Raw') => 'raw',
                                gettext('Numeric') => 'numeric',
                                gettext('Named') => 'named',
                                gettext('Named and numeric') => 'named+numeric'
                                ),
                        'null_selection' => 'raw',
                        'desc' => gettext('If encountering issues with special chars and other character entities change this. Note that this applies on re-saving content only. More info on the <a href="https://www.tinymce.com/docs/configure/content-filtering/#entity_encoding">tinyMCE docs</a>.')),
                gettext('Entities') => array(
                        'key' => 'tinymce4_entities',
                        'type' => OPTION_TYPE_TEXTBOX,
                        'order' => 3,
                        'desc' => gettext('You can adjust how entities are processed. More info on the <a href="https://www.tinymce.com/docs/configure/content-filtering/#entities">tinyMCE docs</a>.')),
        );
        return $options;
    }
    function handleOption($option, $currentValue) {
    }
}
function tinymce4ConfigJS($mode) {
    global $_editorconfig;
    if (empty($_editorconfig)) { 
        $locale = 'en';
        $loc = str_replace('_', '-', getOption("locale"));
        if ($loc) {
            if (file_exists(SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/tinymce4/langs/' . $loc . '.js')) {
                $locale = $loc;
            } else {
                $loc = substr($loc, 0, 2);
                if (file_exists(SERVERPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/tinymce4/langs/' . $loc . '.js')) {
                    $locale = $loc;
                }
            }
        }
        $_editorconfig = getOption('tinymce4_' . $mode);
        if (!empty($_editorconfig)) {
            $_editorconfig = getPlugin('/tinymce4/config/' . $_editorconfig, true);
            if (!empty($_editorconfig)) {
                require_once($_editorconfig);
            }
        }
    }
    return $mode;
}
function getTinyMCE4ConfigFiles($mode) {
    
    $files = getPluginFiles($mode . '-*.js.php', 'tinymce4/config/');
    $array = array();
    foreach ($files as $file) {
        $filename = strrchr($file, '/');
        $filename = substr($filename, 1);
        $option = preg_replace('/^' . $mode . '-/', '', $filename);
        $option = ucfirst(preg_replace('/.js.php$/', '', $option));
        $array[$option] = $filename;
    }
    return $array;
}
?>