Example #1
0
function i18n_customfields_list_pages_json()
{
    if (function_exists('find_i18n_url') && class_exists('I18nNavigationFrontend')) {
        $slug = isset($_GET['id']) ? $_GET['id'] : (isset($_GET['newid']) ? $_GET['newid'] : '');
        $pos = strpos($slug, '_');
        $lang = $pos !== false ? substr($slug, $pos + 1) : null;
        $structure = I18nNavigationFrontend::getPageStructure(null, false, null, $lang);
        $pages = array();
        $nbsp = html_entity_decode(' ', ENT_QUOTES, 'UTF-8');
        $lfloor = html_entity_decode('⌊', ENT_QUOTES, 'UTF-8');
        foreach ($structure as $page) {
            $text = ($page['level'] > 0 ? str_repeat($nbsp, 5 * $page['level'] - 2) . $lfloor . $nbsp : '') . cl($page['title']);
            $link = find_i18n_url($page['url'], $page['parent'], $lang ? $lang : return_i18n_default_language());
            $pages[] = array($text, $link);
        }
        return json_encode($pages);
    } else {
        return list_pages_json();
    }
}
/**
 * CKEditor Add Local Page Link
 *
 * This is used by the CKEditor to link to internal pages
 *
 * @author Joshas: mailto:joshas@gmail.com
 *
 * @since 3.0
 * @uses list_pages_json
 *
 * @returns array
 */
function ckeditor_add_page_link()
{
    echo "\r\n\t<script type=\"text/javascript\">\r\n\t//<![CDATA[\r\n\t// Get a CKEDITOR.dialog.contentDefinition object by its ID.\r\n\tvar getById = function(array, id, recurse) {\r\n\t\tfor (var i = 0, item; (item = array[i]); i++) {\r\n\t\t\tif (item.id == id) return item;\r\n\t\t\t\tif (recurse && item[recurse]) {\r\n\t\t\t\t\tvar retval = getById(item[recurse], id, recurse);\r\n\t\t\t\t\tif (retval) return retval;\r\n\t\t\t\t}\r\n\t\t}\r\n\t\treturn null;\r\n\t};\r\n\r\n\t// modify existing Link dialog\r\n\tCKEDITOR.on( 'dialogDefinition', function( ev )\t{\r\n\t\tif ((ev.editor != editor) || (ev.data.name != 'link')) return;\r\n\r\n\t\t// Overrides definition.\r\n\t\tvar definition = ev.data.definition;\r\n\t\tdefinition.onFocus = CKEDITOR.tools.override(definition.onFocus, function(original) {\r\n\t\t\treturn function() {\r\n\t\t\t\toriginal.call(this);\r\n\t\t\t\t\tif (this.getValueOf('info', 'linkType') == 'localPage') {\r\n\t\t\t\t\t\tthis.getContentElement('info', 'localPage_path').select();\r\n\t\t\t\t\t}\r\n\t\t\t};\r\n\t\t});\r\n\r\n\t\t// Overrides linkType definition.\r\n\t\tvar infoTab = definition.getContents('info');\r\n\t\tvar content = getById(infoTab.elements, 'linkType');\r\n\r\n\t\tcontent.items.unshift(['Link to local page', 'localPage']);\r\n\t\tcontent['default'] = 'localPage';\r\n\t\tinfoTab.elements.push({\r\n\t\t\ttype: 'vbox',\r\n\t\t\tid: 'localPageOptions',\r\n\t\t\tchildren: [{\r\n\t\t\t\ttype: 'select',\r\n\t\t\t\tid: 'localPage_path',\r\n\t\t\t\tlabel: 'Select page:',\r\n\t\t\t\trequired: true,\r\n\t\t\t\titems: " . list_pages_json() . ",\r\n\t\t\t\tsetup: function(data) {\r\n\t\t\t\t\tif ( data.localPage )\r\n\t\t\t\t\t\tthis.setValue( data.localPage );\r\n\t\t\t\t}\r\n\t\t\t}]\r\n\t\t});\r\n\t\tcontent.onChange = CKEDITOR.tools.override(content.onChange, function(original) {\r\n\t\t\treturn function() {\r\n\t\t\t\toriginal.call(this);\r\n\t\t\t\tvar dialog = this.getDialog();\r\n\t\t\t\tvar element = dialog.getContentElement('info', 'localPageOptions').getElement().getParent().getParent();\r\n\t\t\t\tif (this.getValue() == 'localPage') {\r\n\t\t\t\t\telement.show();\r\n\t\t\t\t\tif (editor.config.linkShowTargetTab) {\r\n\t\t\t\t\t\tdialog.showPage('target');\r\n\t\t\t\t\t}\r\n\t\t\t\t\tvar uploadTab = dialog.definition.getContents('upload');\r\n\t\t\t\t\tif (uploadTab && !uploadTab.hidden) {\r\n\t\t\t\t\t\tdialog.hidePage('upload');\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\telse {\r\n\t\t\t\t\telement.hide();\r\n\t\t\t\t}\r\n\t\t\t};\r\n\t\t});\r\n\t\tcontent.setup = function(data) {\r\n\t\t\tif (!data.type || (data.type == 'url') && !data.url) {\r\n\t\t\t\tdata.type = 'localPage';\r\n\t\t\t}\r\n\t\t\telse if (data.url && !data.url.protocol && data.url.url) {\r\n\t\t\t\tif (path) {\r\n\t\t\t\t\tdata.type = 'localPage';\r\n\t\t\t\t\tdata.localPage_path = path;\r\n\t\t\t\t\tdelete data.url;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tthis.setValue(data.type);\r\n\t\t};\r\n\t\tcontent.commit = function(data) {\r\n\t\t\tdata.type = this.getValue();\r\n\t\t\tif (data.type == 'localPage') {\r\n\t\t\t\tdata.type = 'url';\r\n\t\t\t\tvar dialog = this.getDialog();\r\n\t\t\t\tdialog.setValueOf('info', 'protocol', '');\r\n\t\t\t\tdialog.setValueOf('info', 'url', dialog.getValueOf('info', 'localPage_path'));\r\n\t\t\t}\r\n\t\t};\r\n\t});\r\n\t//]]>\r\n\t</script>";
}
Example #3
0
 * This file spits out a list of available themes to the control panel. 
 * This is provided thru an ajax call.
 *
 * @package GetSimple
 * @subpackage Available-Themes
 */
// Include common.php
include 'common.php';
login_cookie_check();
// JSON output of pages for ckeditor select
if (isset($_REQUEST['list_pages_json'])) {
    include_once 'plugin_functions.php';
    include_once 'caching_functions.php';
    getPagesXmlValues();
    header('Content-type: application/json');
    echo list_pages_json();
    die;
}
// Make sure register globals don't make this hackable again.
if (isset($TEMPLATE)) {
    unset($TEMPLATE);
}
/**
 * Sanitise first
 * @todo Maybe use Anti-XSS on this instead?
 */
if (isset($_GET['dir'])) {
    $TEMPLATE = '';
    $segments = explode('/', implode('/', explode('\\', $_GET['dir'])));
    foreach ($segments as $part) {
        if ($part !== '..') {