示例#1
0
                                                                                                                                                                                                                                            if (!isset($bb_langpage["widgets"][$name]) || $bb_langpage["widgets"][$name]["_m"] === false) {
                                                                                                                                                                                                                                                BB_PropertyFormError("Invalid master widget ID.");
                                                                                                                                                                                                                                            }
                                                                                                                                                                                                                                            $data = BB_GetWidgetList();
                                                                                                                                                                                                                                            if (!count($data)) {
                                                                                                                                                                                                                                                BB_PropertyFormError("No widgets found.");
                                                                                                                                                                                                                                            }
                                                                                                                                                                                                                                            for ($x = 0; $x < count($data) && $data[$x]["_dir"] != $_REQUEST["dir"]; $x++) {
                                                                                                                                                                                                                                            }
                                                                                                                                                                                                                                            if ($x == count($data)) {
                                                                                                                                                                                                                                                BB_PropertyFormError("Unknown widget specified.");
                                                                                                                                                                                                                                            }
                                                                                                                                                                                                                                            if ($_REQUEST["name"] == "") {
                                                                                                                                                                                                                                                BB_PropertyFormError("Display Name not filled out.");
                                                                                                                                                                                                                                            }
                                                                                                                                                                                                                                            if (!BB_AddWidget($_REQUEST["dir"], $_REQUEST["name"], $_REQUEST["wid"])) {
                                                                                                                                                                                                                                                BB_PropertyFormError("Unable to add widget.");
                                                                                                                                                                                                                                            }
                                                                                                                                                                                                                                            ?>
<div class="success"><?php 
                                                                                                                                                                                                                                            echo htmlspecialchars(BB_Translate("Added Widget."));
                                                                                                                                                                                                                                            ?>
</div>
<script type="text/javascript">
ReloadMenu();
ReloadIFrame();
CloseProperties();
</script>
<?php 
                                                                                                                                                                                                                                            BB_RunPluginAction("post_bb_main_edit_widgets_add_widget_submit");
                                                                                                                                                                                                                                        } else {
示例#2
0
 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);
                 }
             }
         }
     }
 }