$pages[] = array($text, $link); } return json_encode($pages); } else { return list_pages_json(); } } function i18n_customfields_customize_ckeditor($editorvar) { // copied and modified from ckeditor_add_page_link() echo "\n\t// modify existing Link dialog\n\tCKEDITOR.on( 'dialogDefinition', function( ev )\t{\n\t\tif ((ev.editor != " . $editorvar . ") || (ev.data.name != 'link')) return;\n\n\t\t// Overrides definition.\n\t\tvar definition = ev.data.definition;\n\t\tdefinition.onFocus = CKEDITOR.tools.override(definition.onFocus, function(original) {\n\t\t\treturn function() {\n\t\t\t\toriginal.call(this);\n\t\t\t\t\tif (this.getValueOf('info', 'linkType') == 'localPage') {\n\t\t\t\t\t\tthis.getContentElement('info', 'localPage_path').select();\n\t\t\t\t\t}\n\t\t\t};\n\t\t});\n\n\t\t// Overrides linkType definition.\n\t\tvar infoTab = definition.getContents('info');\n\t\tvar content = getById(infoTab.elements, 'linkType');\n\n\t\tcontent.items.unshift(['Link to local page', 'localPage']);\n\t\tcontent['default'] = 'localPage';\n\t\tinfoTab.elements.push({\n\t\t\ttype: 'vbox',\n\t\t\tid: 'localPageOptions',\n\t\t\tchildren: [{\n\t\t\t\ttype: 'select',\n\t\t\t\tid: 'localPage_path',\n\t\t\t\tlabel: 'Select page:',\n\t\t\t\trequired: true,\n\t\t\t\titems: " . i18n_customfields_list_pages_json() . ",\n\t\t\t\tsetup: function(data) {\n\t\t\t\t\tif ( data.localPage )\n\t\t\t\t\t\tthis.setValue( data.localPage );\n\t\t\t\t}\n\t\t\t}]\n\t\t});\n\t\tcontent.onChange = CKEDITOR.tools.override(content.onChange, function(original) {\n\t\t\treturn function() {\n\t\t\t\toriginal.call(this);\n\t\t\t\tvar dialog = this.getDialog();\n\t\t\t\tvar element = dialog.getContentElement('info', 'localPageOptions').getElement().getParent().getParent();\n\t\t\t\tif (this.getValue() == 'localPage') {\n\t\t\t\t\telement.show();\n\t\t\t\t\tif (" . $editorvar . ".config.linkShowTargetTab) {\n\t\t\t\t\t\tdialog.showPage('target');\n\t\t\t\t\t}\n\t\t\t\t\tvar uploadTab = dialog.definition.getContents('upload');\n\t\t\t\t\tif (uploadTab && !uploadTab.hidden) {\n\t\t\t\t\t\tdialog.hidePage('upload');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\telement.hide();\n\t\t\t\t}\n\t\t\t};\n\t\t});\n\t\tcontent.setup = function(data) {\n\t\t\tif (!data.type || (data.type == 'url') && !data.url) {\n\t\t\t\tdata.type = 'localPage';\n\t\t\t}\n\t\t\telse if (data.url && !data.url.protocol && data.url.url) {\n\t\t\t\tif (path) {\n\t\t\t\t\tdata.type = 'localPage';\n\t\t\t\t\tdata.localPage_path = path;\n\t\t\t\t\tdelete data.url;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.setValue(data.type);\n\t\t};\n\t\tcontent.commit = function(data) {\n\t\t\tdata.type = this.getValue();\n\t\t\tif (data.type == 'localPage') {\n\t\t\t\tdata.type = 'url';\n\t\t\t\tvar dialog = this.getDialog();\n\t\t\t\tdialog.setValueOf('info', 'protocol', '');\n\t\t\t\tdialog.setValueOf('info', 'url', dialog.getValueOf('info', 'localPage_path'));\n\t\t\t}\n\t\t};\n });"; } global $SITEURL, $TEMPLATE; global $data_edit; // SimpleXML to read from $isV3 = substr(i18n_customfields_gsversion(), 0, 1) == '3'; $isI18N = function_exists('return_i18n_languages'); $creDate = @$data_edit->creDate ? (string) $data_edit->creDate : (string) @$data_edit->pubDate; $defs = i18n_customfield_defs(); if ($isV3) { echo '<input type="hidden" name="creDate" value="' . htmlspecialchars($creDate) . '"/>'; } else { echo '<tr style="border:0 none;margin:0;padding:0;"><td colspan="2" style="border:0 none;margin:0;padding:0;"><input type="hidden" name="creDate" value="' . htmlspecialchars($creDate) . '"/></td></tr>'; } if (!$defs || count($defs) <= 0) { return; } $id = @$_GET['id']; if ($isV3) { echo '<table class="formtable" style="clear:both;width:100%;margin-left:0;"><tbody>'; }
$thisfile = basename(__FILE__, ".php"); define('I18N_CUSTOMFIELDS_FILE', 'customfields.xml'); # register plugin register_plugin($thisfile, 'I18N Custom Fields', '1.9.3', 'Martin Vlcek', 'http://mvlcek.bplaced.net/', 'Custom fields for pages (I18N enabled) - based on Mike Swan\'s plugin', 'plugins', 'i18n_customfields_configure'); i18n_merge('i18n_customfields') || i18n_merge('i18n_customfields', 'en_US'); add_action('index-pretemplate', 'i18n_get_custom_fields'); // add hook to make custom field values available to theme add_action('header', 'i18n_customfields_header'); // add hook to create styles for custom field editor. add_action('edit-extras', 'i18n_customfields_edit'); // add hook to create new inputs on the edit screen. add_action('changedata-save', 'i18n_customfields_save'); // add hook to save custom field values add_action('plugins-sidebar', 'createSideMenu', array($thisfile, i18n_r('i18n_customfields/CUSTOMFIELDS_VIEW'))); add_filter('search-index-page', 'i18n_customfields_index'); if (!i18n_customfields_is_frontend() && i18n_customfields_gsversion() == '3.0') { // workaround for GetSimple 3.0: if (isset($_COOKIE['GS_ADMIN_USERNAME'])) { setcookie('GS_ADMIN_USERNAME', $_COOKIE['GS_ADMIN_USERNAME'], 0, '/'); } } $i18n_customfield_defs = null; $i18n_customfield_types = null; $customfields = null; function i18n_customfields_is_frontend() { return function_exists('get_site_url'); } function i18n_customfields_gsversion() { @(include GSADMININCPATH . 'configuration.php');