Example #1
0
                    BB_DeletePageCache();
                    ?>
<div class="success"><?php 
                    echo htmlspecialchars(BB_Translate("Options saved."));
                    ?>
</div>
<script type="text/javascript">
ReloadIFrame();
CloseProperties();
</script>
<?php 
                    BB_RunPluginAction("post_bb_main_edit_page_opt_properties_submit");
                } else {
                    if ($_REQUEST["bb_action"] == "bb_main_edit_page_opt_properties") {
                        BB_RunPluginAction("pre_bb_main_edit_page_opt_properties");
                        if (!BB_IsMemberOfPageGroup("_p")) {
                            BB_PropertyFormLoadError("You do not have permissions to edit the page properties.");
                        }
                        if ($bb_account["type"] == "content") {
                            if (!$bb_revision_writeable) {
                                BB_PropertyFormLoadError("Page properties are not writeable.");
                            }
                            $options = array("title" => "Edit Properties", "desc" => "Edit the page properties.", "fields" => array(array("title" => "Page Title", "type" => "text", "name" => "title", "value" => $bb_langpage["title"], "desc" => "The localized title of this page."), array("title" => "Meta Description", "type" => "text", "name" => "metadesc", "value" => $bb_langpage["metadesc"], "desc" => "The localized HTML meta description tag.  Used by some search engines.")), "submit" => "Save", "focus" => true);
                            BB_RunPluginAction("bb_main_edit_page_opt_properties_content_lang_options");
                            BB_PropertyForm($options);
                        } else {
                            if ($bb_account["type"] == "dev" || $bb_account["type"] == "design") {
                                $doctypes = array();
                                foreach ($bb_doctypes as $doctype => $html) {
                                    $doctypes[$doctype] = $doctype;
                                }
Example #2
0
    public function ProcessBBAction()
    {
        global $bb_widget, $bb_widget_id, $bb_account, $bb_revision_num, $g_bb_content_shortcodes, $g_bb_content_security, $g_bb_content_security_path;
        if (!BB_IsMemberOfPageGroup("_p")) {
            exit;
        }
        if ($bb_account["type"] == "dev" && $_REQUEST["bb_action"] == "bb_content_configure_security_submit") {
            BB_RunPluginAction("pre_bb_content_configure_security_submit");
            // Rebuild the security context array.
            $g_bb_content_security = array();
            foreach ($g_bb_content_shortcodes as $sname => $info) {
                if (isset($info["security"])) {
                    foreach ($info["security"] as $key => $desc) {
                        $key2 = $sname . "|" . $key;
                        if (isset($_REQUEST[$key2]) && $_REQUEST[$key2] != "" && ($_REQUEST[$key2] == "content" || $_REQUEST[$key2] == "design" || $_REQUEST[$key2] == "dev")) {
                            if (!isset($g_bb_content_security[$sname])) {
                                $g_bb_content_security[$sname] = array();
                            }
                            $g_bb_content_security[$sname][$key] = $_REQUEST[$key2];
                        }
                    }
                }
            }
            // Save security contexts.
            $data = "<" . "?php\n\t\$g_bb_content_security = " . BB_CreatePHPStorageData($g_bb_content_security) . ";\n?" . ">";
            if (BB_WriteFile($g_bb_content_security_path, $data) === false) {
                BB_PropertyFormError("Unable to save the shortcode security options.");
            }
            ?>
<div class="success"><?php 
            echo htmlspecialchars(BB_Translate("Global shortcode security options updated."));
            ?>
</div>
<script type="text/javascript">
window.parent.CloseProperties();
window.parent.ReloadIFrame();
</script>
<?php 
            BB_RunPluginAction("post_bb_content_configure_security_submit");
        } else {
            if ($bb_account["type"] == "dev" && $_REQUEST["bb_action"] == "bb_content_configure_security") {
                BB_RunPluginAction("pre_bb_content_configure_security");
                $options = array("title" => "Configure Global Shortcode Security", "desc" => "Configure the global shortcode display options based on login account type.", "fields" => array(), "submit" => "Save", "focus" => true);
                foreach ($g_bb_content_shortcodes as $sname => $info) {
                    if (isset($info["security"])) {
                        foreach ($info["security"] as $key => $desc) {
                            if ($key == "") {
                                $options["fields"][] = array("title" => $desc[0], "type" => "select", "name" => $sname . "|" . $key, "options" => array("dev" => "Developers only", "design" => "Developers and Web Designers", "content" => "Everyone"), "select" => isset($g_bb_content_security[$sname]) && isset($g_bb_content_security[$sname][$key]) ? $g_bb_content_security[$sname][$key] : "", "desc" => $desc[1]);
                            } else {
                                $options["fields"][] = array("title" => $desc[0], "type" => "select", "name" => $sname . "|" . $key, "options" => array("" => "None", "content" => "Content Editors only", "design" => "Web Designers and Content Editors", "dev" => "Everyone"), "select" => isset($g_bb_content_security[$sname]) && isset($g_bb_content_security[$sname][$key]) ? $g_bb_content_security[$sname][$key] : "", "desc" => $desc[1]);
                            }
                        }
                    }
                }
                BB_RunPluginActionInfo("bb_content_configure_security_options", $options);
                BB_PropertyForm($options);
                BB_RunPluginAction("post_bb_content_configure_security");
            } else {
                if ($_REQUEST["bb_action"] == "bb_content_edit_load") {
                    BB_RunPluginAction("pre_bb_content_edit_load");
                    if (isset($bb_widget->body)) {
                        echo rawurlencode(UTF8::ConvertToHTML($bb_widget->body));
                    } else {
                        echo rawurlencode("<p></p>");
                    }
                    BB_RunPluginAction("post_bb_content_edit_load");
                } else {
                    if ($_REQUEST["bb_action"] == "bb_content_edit_save") {
                        BB_RunPluginAction("pre_bb_content_edit_save");
                        $options = array("shortcodes" => true, "shortcode_placeholder" => "bb_content_shortcode_placeholder", "shortcode_ids" => array());
                        $shortcodes = $bb_widget->shortcodes;
                        $base = "wid_" . htmlspecialchars($bb_widget_id) . "_";
                        foreach ($shortcodes as $num => $shortcode) {
                            $options["shortcode_ids"][$base . $num] = isset($shortcode["_sn"]) && isset($g_bb_content_shortcodes[$shortcode["_sn"]]) ? htmlspecialchars($g_bb_content_shortcodes[$shortcode["_sn"]]["mainicon"]) : "";
                        }
                        $bb_widget->body = BB_HTMLPurifyForWYMEditor($_REQUEST["content"], $options);
                        if (!$this->RegenerateContent(true)) {
                            echo htmlspecialchars(BB_Translate("Unable to save content.  Try again."));
                        } else {
                            echo "OK\n";
                            echo "<script type=\"text/javascript\">ReloadIFrame();</script>";
                        }
                        BB_RunPluginAction("post_bb_content_edit_save");
                    } else {
                        if ($_REQUEST["bb_action"] == "bb_content_edit_add_shortcode" && BB_IsSecExtraOpt("sname")) {
                            BB_RunPluginAction("pre_bb_content_edit_add_shortcode");
                            if (!isset($_REQUEST["sname"]) || !isset($g_bb_content_shortcodes[$_REQUEST["sname"]])) {
                                ?>
<script type="text/javascript">
alert('<?php 
                                echo htmlspecialchars(BB_JSSafe(BB_Translate("Shortcode handler not found.")));
                                ?>
');
</script>
<?php 
                            } else {
                                if (!$this->IsShortcodeAllowed($_REQUEST["sname"], "")) {
                                    ?>
<script type="text/javascript">
alert('<?php 
                                    echo htmlspecialchars(BB_JSSafe(BB_Translate("Shortcode access denied.")));
                                    ?>
');
</script>
<?php 
                                } else {
                                    $sname = $_REQUEST["sname"];
                                    $sid = count($bb_widget->shortcodes);
                                    $bb_widget->shortcodes[] = array("_sn" => $sname, "_id" => $sid);
                                    if (!BB_SaveLangPage($bb_revision_num)) {
                                        ?>
<script type="text/javascript">
alert('<?php 
                                        echo htmlspecialchars(BB_JSSafe(BB_Translate("Unable to add a new %s.", $g_bb_content_shortcodes[$sname]["name"])));
                                        ?>
');
</script>
<?php 
                                    } else {
                                        ?>
<script type="text/javascript">
InsertWYMEditorContent('contenteditor', 'wid_<?php 
                                        echo BB_JSSafe($bb_widget_id);
                                        ?>
', '<img id="wid_<?php 
                                        echo BB_JSSafe($bb_widget_id);
                                        ?>
_<?php 
                                        echo $sid;
                                        ?>
" class="bb_content_shortcode_placeholder" src="<?php 
                                        echo htmlspecialchars(BB_JSSafe($g_bb_content_shortcodes[$sname]["mainicon"]));
                                        ?>
" />');
</script>
<?php 
                                    }
                                }
                            }
                            BB_RunPluginAction("post_bb_content_edit_add_shortcode");
                        } else {
                            if ($_REQUEST["bb_action"] == "bb_content_edit_edit_shortcode" && (!isset($_REQUEST["sc_action"]) || BB_IsSecExtraOpt("sid") && BB_IsSecExtraOpt("sc_action"))) {
                                BB_RunPluginAction("pre_bb_content_edit_edit_shortcode");
                                if (!isset($_REQUEST["sid"])) {
                                    BB_PropertyFormLoadError("Shortcode ID not specified.");
                                }
                                $sid = $_REQUEST["sid"];
                                $pos = strrpos($sid, "_");
                                if ($pos !== false) {
                                    $sid = substr($sid, $pos + 1);
                                }
                                $sid = (int) $sid;
                                if (!isset($bb_widget->shortcodes[$sid]) || !isset($bb_widget->shortcodes[$sid]["_sn"])) {
                                    BB_PropertyFormLoadError("Invalid shortcode ID.");
                                }
                                $sname = $bb_widget->shortcodes[$sid]["_sn"];
                                if (!isset($g_bb_content_shortcodes[$sname])) {
                                    BB_PropertyFormLoadError("Shortcode handler not found.");
                                }
                                if (!$this->IsShortcodeAllowed($sname, "")) {
                                    BB_PropertyFormLoadError("Shortcode access denied.");
                                }
                                if (!isset($_REQUEST["sc_action"])) {
                                    $_REQUEST["sc_action"] = $sname . "_configure";
                                }
                                $shortcode = "bb_content_shortcode_" . $sname;
                                $shortcode = new $shortcode();
                                $this->currsid = $sid;
                                $shortcode->ProcessShortcodeBBAction($this);
                                BB_RunPluginAction("post_bb_content_edit_edit_shortcode");
                            } else {
                                if ($_REQUEST["bb_action"] == "bb_content_edit") {
                                    BB_RunPluginAction("pre_bb_content_edit");
                                    ?>
<script type="text/javascript">
html = '<style type="text/css">\n';
<?php 
                                    foreach ($g_bb_content_shortcodes as $sname => $info) {
                                        $sname2 = preg_replace('/[^A-Za-z0-9_]/', "_", trim($sname));
                                        ?>
html += '.wym_skin_barebones .wym_buttons li.wym_tools_custom_<?php 
                                        echo htmlspecialchars(BB_JSSafe($sname2));
                                        ?>
 a  { background-image: url(<?php 
                                        echo htmlspecialchars(BB_JSSafe($info["toolbaricon"]));
                                        ?>
); background-repeat: no-repeat; }\n';
<?php 
                                    }
                                    ?>
html += '</style>\n';
$("head").append(html);

window.bb_content_WYMEditorPostInit = function(eid, id, wym) {
<?php 
                                    foreach ($g_bb_content_shortcodes as $sname => $info) {
                                        if ($this->IsShortcodeAllowed($sname, "")) {
                                            $sname2 = preg_replace('/[^A-Za-z0-9_]/', "_", trim($sname));
                                            ?>
	var html = '<li class="wym_tools_custom_<?php 
                                            echo htmlspecialchars(BB_JSSafe($sname2));
                                            ?>
"><a name="<?php 
                                            echo htmlspecialchars(BB_JSSafe($info["name"]));
                                            ?>
" href="#"><?php 
                                            echo htmlspecialchars(BB_JSSafe($info["name"]));
                                            ?>
</a></li>';
	$(wym._box).find(wym._options.toolsSelector + wym._options.toolsListSelector).append(html);
	$(wym._box).find('li.wym_tools_custom_<?php 
                                            echo BB_JSSafe($sname2);
                                            ?>
 a').click(function() {
		$('#' + eid + '_loader').load(Gx__URLBase, <?php 
                                            echo BB_CreateWidgetPropertiesJS("bb_content_edit_add_shortcode", array("sname" => $sname), true);
                                            ?>
);

		return false;
	});
<?php 
                                        }
                                    }
                                    ?>

	$(wym._doc).bind('dblclick', function(e) {
		if (e.target.tagName == 'IMG' && $(e.target).hasClass('bb_content_shortcode_placeholder') && typeof(e.target.id) == 'string' && e.target.id != '')
		{
			window.parent.LoadProperties({ 'bb_action' : 'bb_content_edit_edit_shortcode', 'wid' : '<?php 
                                    echo BB_JSSafe($bb_widget_id);
                                    ?>
', 'sid' : e.target.id, 'bbt' : '<?php 
                                    echo BB_JSSafe(BB_CreateSecurityToken("bb_content_edit_edit_shortcode", $bb_widget_id));
                                    ?>
' });
		}
	});
}

if (typeof(window.parent.CreateWYMEditorInstance) != 'function')
{
	window.bb_content_ClosedAllContent = function(eid) {
		setTimeout(function() { DestroyWYMEditorInstance(eid);  $('#' + eid).hide(); }, 250);
	}
}

window.parent.LoadConditionalScript(Gx__RootURL + '/' + Gx__SupportPath + '/editcontent.js?_=20090725', true, function(loaded) {
		return ((!loaded && typeof(window.CreateWYMEditorInstance) == 'function') || (loaded && !IsConditionalScriptLoading()));
	}, function(params) {
		$('#contenteditor').show();

		var fileopts = {
			loadurl : Gx__URLBase,
			loadparams : <?php 
                                    echo BB_CreateWidgetPropertiesJS("bb_content_edit_load", array(), true);
                                    ?>
,
			id : 'wid_<?php 
                                    echo BB_JSSafe($bb_widget_id);
                                    ?>
',
			display : '<?php 
                                    echo BB_JSSafe($bb_widget->_f);
                                    ?>
',
			saveurl : Gx__URLBase,
			saveparams : <?php 
                                    echo BB_CreateWidgetPropertiesJS("bb_content_edit_save", array(), true);
                                    ?>
,
			wymtoolbar : 'bold,italic,superscript,subscript,pasteword,undo,redo,createlink,unlink,insertorderedlist,insertunorderedlist,indent,outdent',
			wymeditorpostinit : bb_content_WYMEditorPostInit
		};

		var editopts = {
			ismulti : true,
			closelast : bb_content_ClosedAllContent,
			width : '100%',
			height : '300px'
		};

		CreateWYMEditorInstance('contenteditor', fileopts, editopts);
});
window.parent.CloseProperties2(false);
</script>
<?php 
                                    BB_RunPluginAction("post_bb_content_edit");
                                } else {
                                    if (isset($_REQUEST["action"])) {
                                        // Pass other requests onto the shortcode action handler.
                                        if (isset($_REQUEST["sid"])) {
                                            $sid = (int) $_REQUEST["sid"];
                                            if (isset($bb_widget->shortcodes[$sid]) && isset($bb_widget->shortcodes[$sid]["_sn"])) {
                                                $sname = $bb_widget->shortcodes[$sid]["_sn"];
                                                if (isset($g_bb_content_shortcodes[$sname])) {
                                                    $shortcode = "bb_content_shortcode_" . $sname;
                                                    $shortcode = new $shortcode();
                                                    $this->currsid = $sid;
                                                    $shortcode->ProcessShortcodeAction($this);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
Example #3
0
    public function ProcessBBAction()
    {
        global $bb_widget, $bb_widget_id, $bb_account, $bb_revision_num;
        if (!BB_IsMemberOfPageGroup("_p")) {
            exit;
        }
        if ($_REQUEST["bb_action"] == "bb_code_edit_langmap_submit") {
            BB_RunPluginAction("pre_bb_code_edit_langmap_submit");
            $bb_widget->langmap = $_REQUEST["langmap"];
            if (!BB_SaveLangPage($bb_revision_num)) {
                BB_PropertyFormError("Unable to save the language mapping.");
            }
            ?>
<div class="success"><?php 
            echo htmlspecialchars(BB_Translate("Language mapping saved."));
            ?>
</div>
<script type="text/javascript">
window.parent.CloseProperties();
window.parent.ReloadIFrame();
</script>
<?php 
            BB_RunPluginAction("post_bb_code_edit_langmap_submit");
        } else {
            if ($_REQUEST["bb_action"] == "bb_code_edit_langmap") {
                BB_RunPluginAction("pre_bb_code_edit_langmap");
                $options = array("title" => BB_Translate("Edit %s Language Map", $bb_widget->_f), "desc" => "Edit the language map.  One mapping entry per line.  First character indicates the termination character of the key.  Empty keys are ignored.", "fields" => array(array("title" => "", "type" => "textarea", "name" => "langmap", "value" => $bb_widget->langmap, "desc" => "Example:  |key|value")), "submit" => "Save", "focus" => true);
                BB_RunPluginActionInfo("bb_code_edit_langmap_options", $options);
                BB_PropertyForm($options);
                BB_RunPluginAction("post_bb_code_edit_langmap");
                return;
            }
        }
        if ($bb_account["type"] == "dev") {
            $types = array("init" => array("ltitle" => "init", "utitle" => "Init"), "action" => array("ltitle" => "action", "utitle" => "Action"), "prehtml" => array("ltitle" => "pre-HTML", "utitle" => "Pre-HTML"), "head" => array("ltitle" => "head", "utitle" => "Head"), "body" => array("ltitle" => "body", "utitle" => "Body"));
            foreach ($types as $key => $typeinfo) {
                if ($_REQUEST["bb_action"] == "bb_code_edit_" . $key . "_load") {
                    BB_RunPluginAction("pre_bb_code_edit_" . $key . "_load");
                    if (isset($bb_widget->{$key})) {
                        echo rawurlencode($bb_widget->{$key});
                    }
                    BB_RunPluginAction("post_bb_code_edit_" . $key . "_load");
                    return;
                } else {
                    if ($_REQUEST["bb_action"] == "bb_code_edit_" . $key . "_save") {
                        BB_RunPluginAction("pre_bb_code_edit_" . $key . "_save");
                        $bb_widget->{$key} = $_REQUEST["content"];
                        if (!BB_SaveLangPage($bb_revision_num)) {
                            echo htmlspecialchars(BB_Translate("Unable to save " . $typeinfo["ltitle"] . " content.  Try again."));
                        } else {
                            echo "OK\n";
                            echo "<script type=\"text/javascript\">ReloadIFrame();</script>";
                        }
                        BB_RunPluginAction("post_bb_code_edit_" . $key . "_save");
                        return;
                    } else {
                        if ($_REQUEST["bb_action"] == "bb_code_edit_" . $key) {
                            BB_RunPluginAction("pre_bb_code_edit_" . $key);
                            ?>
<script type="text/javascript">
window.parent.LoadConditionalScript(Gx__RootURL + '/' + Gx__SupportPath + '/editfile.js?_=20140418', true, function(loaded) {
		return ((!loaded && typeof(window.CreateEditAreaInstance) == 'function') || (loaded && !IsConditionalScriptLoading()));
	}, function(params) {
		$('#fileeditor').show();

		var fileopts = {
			loadurl : Gx__URLBase,
			loadparams : <?php 
                            echo BB_CreateWidgetPropertiesJS("bb_code_edit_" . $key . "_load", array(), true);
                            ?>
,
			id : 'wid_<?php 
                            echo BB_JSSafe($bb_widget_id);
                            ?>
_<?php 
                            echo BB_JSSafe($key);
                            ?>
',
			display : '<?php 
                            echo BB_JSSafe($bb_widget->_f . " - " . $typeinfo["utitle"]);
                            ?>
',
			saveurl : Gx__URLBase,
			saveparams : <?php 
                            echo BB_CreateWidgetPropertiesJS("bb_code_edit_" . $key . "_save", array(), true);
                            ?>
,
			syntax : 'php',
			aceopts : {
				'focus' : true,
				'theme' : 'crimson_editor'
			}
		};

		var editopts = {
			ismulti : true,
			closelast : ClosedAllFiles,
			width : '100%',
			height : '500px'
		};

		CreateEditAreaInstance('fileeditor', fileopts, editopts);
});
window.parent.CloseProperties(false);
</script>
<?php 
                            BB_RunPluginAction("post_bb_code_edit_" . $key);
                            return;
                        }
                    }
                }
            }
        }
        // Pass other requests onto the action handler.
        if (isset($_REQUEST["action"])) {
            foreach ($GLOBALS as $key => $val) {
                if (substr($key, 0, 3) == "bb_" || substr($key, 0, 2) == "g_") {
                    global ${$key};
                }
            }
            if (isset($bb_widget->action)) {
                eval("?" . ">" . $bb_widget->action);
            }
        }
    }