<?php BB_RunPluginAction("post_bb_main_edit_widgets_attach_widget"); } else { if (($bb_account["type"] == "dev" || $bb_account["type"] == "design") && $_REQUEST["bb_action"] == "bb_main_edit_widgets_detach_widget") { BB_RunPluginAction("pre_bb_main_edit_widgets_detach_widget"); if (!isset($_REQUEST["wid"])) { BB_PropertyFormLoadError("Widget ID not specified."); } if (!isset($bb_langpage["widgets"][$_REQUEST["wid"]])) { BB_PropertyFormLoadError("Invalid widget ID."); } $bb_widget->SetID($_REQUEST["wid"]); if ($bb_widget->_m === false && $bb_widget->_a !== false) { $bb_widget_instances[$_REQUEST["wid"]]->ProcessBBAction(); } if (!BB_DetachWidget($_REQUEST["wid"])) { BB_PropertyFormLoadError("Unable to detach widget."); } ?> <div class="success"><?php echo htmlspecialchars(BB_Translate("Widget detached.")); ?> </div> <script type="text/javascript"> ReloadIFrame(); CloseProperties(); </script> <?php BB_RunPluginAction("post_bb_main_edit_widgets_detach_widget"); } else { if (($bb_account["type"] == "dev" || $bb_account["type"] == "design") && $_REQUEST["bb_action"] == "bb_main_edit_widgets_delete_widget") {
public function Init() { global $bb_widget, $bb_widget_id, $bb_lastwidgetupdate, $bb_langpage, $bb_profile; $this->layoutpath = BB_GetRealPath(Str::ExtractPathname($bb_widget->_file) . "/layouts"); if (!isset($bb_widget->layout)) { $bb_widget->layout = ""; } if ($bb_widget->layout == "") { BB_DetachAllWidgets($bb_widget_id); return; } $this->info = false; $basefile = ROOT_PATH . "/" . WIDGET_PATH . "/" . $this->layoutpath . "/" . $bb_widget->layout; $datfile = $basefile . ".dat"; if (file_exists($datfile)) { $this->info = unserialize(file_get_contents($datfile)); } if ($this->info === false || !isset($this->info[$bb_profile]) || $this->info[$bb_profile]["ts"] < $bb_lastwidgetupdate || defined("BB_MODE_EDIT")) { $this->info = $this->ExtractFileInfo($basefile); if ($this->info !== false) { BB_WriteFile($datfile, serialize($this->info)); } } if ($this->info === false) { $bb_widget->layout = ""; BB_DetachAllWidgets($bb_widget_id); } else { if (!isset($this->info[$bb_profile])) { $profile = ""; } else { $profile = $bb_profile; } $ids = array(); foreach ($this->info[$profile]["widgets"] as $name) { if (substr($name, 0, 1) != "\$") { $multi = true; } else { $multi = false; $name = substr($name, 1); } $id = $bb_widget_id . "_" . $name; $ids[$id] = true; if (!BB_IsMasterWidgetConnected($bb_widget_id, $name)) { BB_AddMasterWidget($bb_widget_id, $name); } if (!$multi && isset($bb_langpage["widgets"][$id]) && !count($bb_langpage["widgets"][$id]["_ids"])) { BB_AddWidget($name, ucfirst(str_replace("_", " ", $name)), $id, true); } } if ($profile == "" && isset($bb_widget->_ids)) { foreach ($bb_widget->_ids as $id) { if (!isset($ids[$id])) { BB_DetachWidget($id); } } } } }