Example #1
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);
            }
        }
    }
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_account, $bb_revision_num;
        $basepath = BB_GetRealPath(Str::ExtractPathname($bb_widget->_file) . "/base");
        if (($bb_account["type"] == "dev" || $bb_account["type"] == "design") && $_REQUEST["bb_action"] == "bb_layout_configure_widget_new_layout_submit") {
            BB_RunPluginAction("pre_bb_layout_configure_widget_new_layout_submit");
            $found = false;
            $dirlist = BB_GetDirectoryList(ROOT_PATH . "/" . WIDGET_PATH . "/" . $basepath);
            foreach ($dirlist["files"] as $name) {
                $pos = strrpos($name, ".");
                if ($pos !== false && substr($name, $pos) == ".html" && substr($name, 0, $pos) == $_REQUEST["pattern"]) {
                    $found = true;
                    break;
                }
            }
            if (!$found) {
                BB_PropertyFormError("Invalid pattern specified.");
            }
            $name = $_REQUEST["name"];
            if ($name == "") {
                BB_PropertyFormError("Name field not filled out.");
            }
            $dirfile = preg_replace('/[^A-Za-z0-9_\\-]/', "_", $name);
            if (file_exists(ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $dirfile . ".html")) {
                BB_PropertyFormError("A layout with that name already exists.");
            }
            if (file_exists(ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $dirfile . ".css")) {
                BB_PropertyFormError("A layout with that name already exists.");
            }
            $data = file_get_contents(ROOT_PATH . "/" . WIDGET_PATH . "/" . $basepath . "/" . $_REQUEST["pattern"] . ".html");
            $data = str_replace(htmlspecialchars($_REQUEST["pattern"]), htmlspecialchars($dirfile), $data);
            if (BB_WriteFile(ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $dirfile . ".html", $data) === false) {
                BB_PropertyFormError("Unable to create layout HTML.");
            }
            if (!copy(ROOT_PATH . "/" . WIDGET_PATH . "/" . $basepath . "/" . $_REQUEST["pattern"] . ".css", ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $dirfile . ".css")) {
                BB_PropertyFormError("Unable to create layout CSS.");
            }
            ?>
<div class="success"><?php 
            echo htmlspecialchars(BB_Translate("Layout created."));
            ?>
</div>
<script type="text/javascript">
window.parent.LoadProperties(<?php 
            echo BB_CreateWidgetPropertiesJS("bb_layout_configure_widget");
            ?>
);
</script>
<?php 
            BB_RunPluginAction("post_bb_layout_configure_widget_new_layout_submit");
        } else {
            if (($bb_account["type"] == "dev" || $bb_account["type"] == "design") && $_REQUEST["bb_action"] == "bb_layout_configure_widget_new_layout") {
                BB_RunPluginAction("pre_bb_layout_configure_widget_new_layout");
                $desc = "<br />";
                $desc .= BB_CreateWidgetPropertiesLink(BB_Translate("Back"), "bb_layout_configure_widget");
                $patterns = array();
                $dirlist = BB_GetDirectoryList(ROOT_PATH . "/" . WIDGET_PATH . "/" . $basepath);
                foreach ($dirlist["files"] as $name) {
                    $pos = strrpos($name, ".");
                    if ($pos !== false && substr($name, $pos) == ".html") {
                        $info = $this->ExtractFileInfo(ROOT_PATH . "/" . WIDGET_PATH . "/" . $basepath . "/" . $name);
                        if ($info !== false) {
                            $patterns[substr($name, 0, $pos)] = $info[""]["info"][0];
                        }
                    }
                }
                $options = array("title" => BB_Translate("Configure %s - New Layout", $bb_widget->_f), "desc" => "Create a new layout.", "htmldesc" => $desc, "fields" => array(array("title" => "Pattern", "type" => "select", "name" => "pattern", "options" => $patterns, "desc" => "The pattern to use for the new layout."), array("title" => "Name", "type" => "text", "name" => "name", "value" => "", "desc" => "The name of the new layout.")), "submit" => "Create", "focus" => true);
                BB_RunPluginActionInfo("bb_layout_configure_widget_new_layout_options", $options);
                BB_PropertyForm($options);
                BB_RunPluginAction("post_bb_layout_configure_widget_new_layout");
            } else {
                if (($bb_account["type"] == "dev" || $bb_account["type"] == "design") && $_REQUEST["bb_action"] == "bb_layout_configure_widget_activate_layout" && BB_IsSecExtraOpt("file")) {
                    BB_RunPluginAction("pre_bb_layout_configure_widget_activate_layout");
                    $found = false;
                    $dirlist = BB_GetDirectoryList(ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath);
                    foreach ($dirlist["files"] as $name) {
                        $pos = strrpos($name, ".");
                        if ($pos !== false && substr($name, $pos) == ".html" && $name == $_REQUEST["file"]) {
                            $info = $this->ExtractFileInfo(ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $name);
                            if ($info !== false) {
                                $bb_widget->layout = $name;
                                $found = true;
                                break;
                            }
                        }
                    }
                    if (!$found) {
                        BB_PropertyFormLoadError("Invalid layout specified.");
                    }
                    if (!BB_SaveLangPage($bb_revision_num)) {
                        BB_PropertyFormError("Unable to save the layout activation.");
                    }
                    ?>
<div class="success"><?php 
                    echo htmlspecialchars(BB_Translate("Layout activated."));
                    ?>
</div>
<script type="text/javascript">
window.parent.LoadProperties(<?php 
                    echo BB_CreateWidgetPropertiesJS("bb_layout_configure_widget");
                    ?>
);
window.parent.ReloadIFrame();
</script>
<?php 
                    BB_RunPluginAction("post_bb_layout_configure_widget_activate_layout");
                } else {
                    if (($bb_account["type"] == "dev" || $bb_account["type"] == "design") && $_REQUEST["bb_action"] == "bb_layout_configure_widget_deactivate_layout") {
                        BB_RunPluginAction("pre_bb_layout_configure_widget_deactivate_layout");
                        $bb_widget->layout = "";
                        if (!BB_SaveLangPage($bb_revision_num)) {
                            BB_PropertyFormError("Unable to save the layout deactivation.");
                        }
                        ?>
<div class="success"><?php 
                        echo htmlspecialchars(BB_Translate("Layout deactivated."));
                        ?>
</div>
<script type="text/javascript">
window.parent.LoadProperties(<?php 
                        echo BB_CreateWidgetPropertiesJS("bb_layout_configure_widget");
                        ?>
);
window.parent.ReloadIFrame();
</script>
<?php 
                        BB_RunPluginAction("post_bb_layout_configure_widget_deactivate_layout");
                    } else {
                        if (($bb_account["type"] == "dev" || $bb_account["type"] == "design") && $_REQUEST["bb_action"] == "bb_layout_configure_widget_delete_layout" && BB_IsSecExtraOpt("file")) {
                            BB_RunPluginAction("pre_bb_layout_configure_widget_delete_layout");
                            $found = false;
                            $dirlist = BB_GetDirectoryList(ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath);
                            foreach ($dirlist["files"] as $name) {
                                $pos = strrpos($name, ".");
                                if ($pos !== false && substr($name, $pos) == ".html" && $name == $_REQUEST["file"]) {
                                    $info = $this->ExtractFileInfo(ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $name);
                                    if ($info !== false) {
                                        if (!unlink(ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $name)) {
                                            BB_PropertyFormLoadError("Unable to delete the layout HTML.");
                                        }
                                        foreach ($info as $profile => $data) {
                                            $filename = ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . substr($name, 0, $pos) . ($profile != "" ? "." . $profile : "") . ".css";
                                            if (file_exists($filename)) {
                                                @unlink($filename);
                                            }
                                        }
                                        if (file_exists(ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $name . ".dat")) {
                                            @unlink(ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $name . ".dat");
                                        }
                                        if (isset($bb_widget->layout) && $bb_widget->layout == $name) {
                                            unset($bb_widget->layout);
                                        }
                                        $found = true;
                                        break;
                                    }
                                }
                            }
                            if (!$found) {
                                BB_PropertyFormLoadError("Invalid layout specified.");
                            }
                            if (!BB_SaveLangPage($bb_revision_num)) {
                                BB_PropertyFormLoadError("Unable to save the layout activation status.");
                            }
                            ?>
<div class="success"><?php 
                            echo htmlspecialchars(BB_Translate("Layout deleted."));
                            ?>
</div>
<script type="text/javascript">
window.parent.LoadProperties(<?php 
                            echo BB_CreateWidgetPropertiesJS("bb_layout_configure_widget");
                            ?>
);
window.parent.ReloadIFrame();
</script>
<?php 
                            BB_RunPluginAction("post_bb_layout_configure_widget_delete_layout");
                        } else {
                            if (($bb_account["type"] == "dev" || $bb_account["type"] == "design") && $_REQUEST["bb_action"] == "bb_layout_configure_widget") {
                                global $editmap, $extmap;
                                BB_RunPluginAction("pre_bb_layout_configure_widget");
                                $editmap = array("ea_html" => array("<a href=\"#\" onclick=\"return EditFile('%%HTML_JS_DIR%%', '%%HTML_JS_FILE%%', '%%HTML_JS_syntax%%', '%%HTML_JS_LOADTOKEN%%', '%%HTML_JS_SAVETOKEN%%');\">" . htmlspecialchars(BB_Translate("Edit HTML")) . "</a>", "syntax"), "ea_css" => array("<a href=\"#\" onclick=\"return EditFile('%%HTML_JS_DIR%%', '%%HTML_JS_FILE%%', '%%HTML_JS_syntax%%', '%%HTML_JS_LOADTOKEN%%', '%%HTML_JS_SAVETOKEN%%');\">" . htmlspecialchars(BB_Translate("Edit CSS")) . "</a>", "syntax"));
                                $extmap = array(".html" => array("edit" => "ea_html", "syntax" => "html"), ".css" => array("edit" => "ea_css", "syntax" => "css"));
                                BB_RunPluginAction("bb_layout_configure_widget_exteditmaps");
                                $desc = "<br />";
                                $desc .= BB_CreateWidgetPropertiesLink(BB_Translate("New Layout"), "bb_layout_configure_widget_new_layout");
                                if ($bb_widget->layout != "") {
                                    $desc .= " | " . BB_CreateWidgetPropertiesLink(BB_Translate("Deactivate Current Layout"), "bb_layout_configure_widget_deactivate_layout");
                                }
                                $rows = array();
                                $dirlist = BB_GetDirectoryList(ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath);
                                foreach ($dirlist["files"] as $name) {
                                    $pos = strrpos($name, ".");
                                    if ($pos !== false && substr($name, $pos) == ".html") {
                                        $info = $this->ExtractFileInfo(ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $name);
                                        if ($info !== false) {
                                            $rows[] = array("<a href=\"" . htmlspecialchars(ROOT_URL . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $name) . "\" target=\"_blank\">" . htmlspecialchars($name) . "</a>", BB_FileExplorer_GetActionStr(WIDGET_PATH . "/" . $this->layoutpath, $name) . " | " . BB_FileExplorer_GetActionStr(WIDGET_PATH . "/" . $this->layoutpath, substr($name, 0, $pos) . ".css") . " | " . ($bb_widget->layout != $name ? BB_CreateWidgetPropertiesLink(BB_Translate("Activate"), "bb_layout_configure_widget_activate_layout", array("file" => $name)) : BB_CreateWidgetPropertiesLink(BB_Translate("Deactivate"), "bb_layout_configure_widget_deactivate_layout")) . " | " . BB_CreateWidgetPropertiesLink(BB_Translate("Delete"), "bb_layout_configure_widget_delete_layout", array("file" => $name), BB_Translate("Deleting the '%s' layout will immediately affect any pages that utilize the layout.  Continue?", $name)));
                                        } else {
                                            if (file_exists(ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $name)) {
                                                $rows[] = array(BB_Translate("%s (Broken layout)", "<a href=\"" . htmlspecialchars(ROOT_URL . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $name) . "\" target=\"_blank\">" . htmlspecialchars($name) . "</a>"), BB_FileExplorer_GetActionStr(WIDGET_PATH . "/" . $this->layoutpath, $name));
                                            }
                                        }
                                    }
                                }
                                $options = array("title" => BB_Translate("Configure %s", $bb_widget->_f), "desc" => "Select an existing layout or create a new layout.", "htmldesc" => $desc);
                                if (count($rows)) {
                                    $options["fields"] = array(array("type" => "table", "cols" => array("Layout", "Options"), "rows" => $rows));
                                }
                                BB_RunPluginActionInfo("bb_layout_configure_widget_options", $options);
                                BB_PropertyForm($options);
                                BB_RunPluginAction("post_bb_layout_configure_widget");
                            }
                        }
                    }
                }
            }
        }
    }