public function PreWidget() { global $bb_account; if (BB_IsMemberOfPageGroup("_p")) { echo BB_CreateWidgetPropertiesLink(BB_Translate("Edit Language Map"), "bb_code_edit_langmap"); if ($bb_account["type"] == "dev") { echo BB_CreateWidgetPropertiesLink(BB_Translate("Edit Init"), "bb_code_edit_init"); echo BB_CreateWidgetPropertiesLink(BB_Translate("Edit Pre-HTML"), "bb_code_edit_prehtml"); echo BB_CreateWidgetPropertiesLink(BB_Translate("Edit Head"), "bb_code_edit_head"); echo BB_CreateWidgetPropertiesLink(BB_Translate("Edit Body"), "bb_code_edit_body"); echo BB_CreateWidgetPropertiesLink(BB_Translate("Edit Action"), "bb_code_edit_action"); } } }
public function PreWidget() { global $bb_widget, $bb_account; if (BB_IsMemberOfPageGroup("_p")) { if ($bb_account["type"] == "dev") { echo BB_CreateWidgetPropertiesLink(BB_Translate("Configure Security"), "bb_content_configure_security"); } echo BB_CreateWidgetPropertiesLink(BB_Translate("Edit"), "bb_content_edit", array(), "", true); } }
function BB_MasterWidgetPreWidget($displaymwm) { global $bb_account, $bb_widget, $bb_widget_id, $bb_widget_instances; ob_start(); $bb_widget_instances[$bb_widget_id]->PreWidget(); if ($displaymwm && ($bb_account["type"] == "dev" || $bb_account["type"] == "design")) { echo BB_CreateWidgetPropertiesLink(BB_Translate("Detach"), "bb_main_edit_widgets_detach_widget"); echo BB_CreateWidgetPropertiesLink(BB_Translate("Delete"), "bb_main_edit_widgets_delete_widget", array(), BB_Translate("Are you sure you want to detach and delete this widget?")); } $data = ob_get_contents(); ob_end_clean(); $data = trim($data); if ($data != "") { ?> <div class="bb_mw_manager"> <div class="bb_mw_manager_type">[<?php echo htmlspecialchars($bb_widget->_n); ?> ]</div> <b><?php echo htmlspecialchars(BB_Translate("%s Options", $bb_widget->_f)); ?> </b><br /> <div class="bb_mw_manager_links"> <?php echo $data; ?> </div> </div> <?php } }
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"); } } } } } } }