Example #1
0
     if ($bb_account["type"] == "dev") {
         $row[] = "";
     }
     $row[] = "";
     $row[] = BB_FormatTimestamp(filemtime($dir . "/" . $dirfile));
     if ($bb_account["type"] == "dev") {
         $row[] = BB_CreatePropertiesLink(BB_Translate("Rename"), "bb_main_edit_site_opt_file_explorer_rename", array("dir" => $dir, "file" => $dirfile)) . " | " . BB_CreatePropertiesLink(BB_Translate("Delete"), "bb_main_edit_site_opt_file_explorer_delete", array("dir" => $dir, "file" => $dirfile), BB_Translate("Are you sure you want to delete '%s' and all subdirectories?", $dirfile));
     }
     $rows[] = $row;
 }
 BB_RunPluginAction("bb_main_edit_site_opt_file_explorer_dirs");
 $urlbase = BB_GetRequestURLBase();
 foreach ($dirlist["files"] as $dirfile) {
     $row = array(($bb_account["type"] == "dev" ? "<a class=\"download\" href=\"" . $urlbase . "?bb_action=bb_main_edit_site_opt_file_explorer_download&file=" . htmlspecialchars(urlencode($dir . "/" . $dirfile)) . "&bbt=" . htmlspecialchars(BB_CreateSecurityToken("bb_main_edit_site_opt_file_explorer_download", "", array($dir . "/" . $dirfile))) . "&bb_sec_extra=file\" target=\"_blank\" title=\"Download\">D</a> " : "") . "<a href=\"" . htmlspecialchars(ROOT_URL . "/" . $dir . "/" . $dirfile) . "\" target=\"_blank\">" . htmlspecialchars($dirfile) . "</a>");
     if ($bb_account["type"] == "dev") {
         $row[] = BB_FileExplorer_GetActionStr($dir, $dirfile);
     }
     $row[] = number_format(filesize($dir . "/" . $dirfile), 0);
     $row[] = BB_FormatTimestamp(filemtime($dir . "/" . $dirfile));
     if ($bb_account["type"] == "dev") {
         $row[] = BB_CreatePropertiesLink(BB_Translate("Rename"), "bb_main_edit_site_opt_file_explorer_rename", array("dir" => $dir, "file" => $dirfile)) . " | " . BB_CreatePropertiesLink(BB_Translate("Delete"), "bb_main_edit_site_opt_file_explorer_delete", array("dir" => $dir, "file" => $dirfile), BB_Translate("Are you sure you want to delete '%s'?", $dirfile));
     }
     $rows[] = $row;
 }
 BB_RunPluginAction("bb_main_edit_site_opt_file_explorer_files");
 $desc = "";
 if ($bb_account["type"] == "dev" || $bb_account["type"] == "design") {
     $desc .= "<br />";
     if ($bb_account["type"] == "dev") {
         $desc .= BB_CreatePropertiesLink(BB_Translate("Create New Directory"), "bb_main_edit_site_opt_file_explorer_create", array("dir" => $dir)) . " | " . BB_CreatePropertiesLink(BB_Translate("Create New File"), "bb_main_edit_site_opt_file_explorer_create", array("file" => $dir)) . " | " . BB_CreatePropertiesLink(BB_Translate("Upload/Transfer Files"), "bb_main_edit_site_opt_file_explorer_upload", array("dir" => $dir)) . " | " . (class_exists("ZipArchive") ? BB_CreatePropertiesLink(BB_Translate("Create ZIP File"), "bb_main_edit_site_opt_file_explorer_zip", array("dir" => $dir)) . " | " : "");
     }
Example #2
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");
                            }
                        }
                    }
                }
            }
        }
    }