Пример #1
0
$p["field_types"] = $field_types;
// Get a list of custom field types so we can auto include any that modules rely on
$ft = $admin->getFieldTypes();
foreach ($ft as $type) {
    $custom_field_types[$type["id"]] = true;
}
// Infer tables/files to include from the modules
foreach ((array) $modules as $module_id) {
    if ($module_id) {
        $module = $admin->getModule($module_id);
        $actions = $admin->getModuleActions($module_id);
        // Get all the tables of the module's actions.
        foreach ($actions as $action) {
            if ($action["form"] || $action["view"] || $action["report"]) {
                if ($action["form"]) {
                    $auto = BigTreeAutoModule::getForm($action["form"]);
                    // Figure out what tables and field types the form uses and automatically add them.
                    foreach ($auto["fields"] as $field) {
                        // Database populated list? Include the table it pulls from.
                        if ($field["type"] == "list" && $field["options"]["list_type"] == "db") {
                            if (!in_array($field["options"]["pop-table"] . "#structure", $p["tables"]) && substr($field["options"]["pop-table"], 0, 8) != "bigtree_") {
                                $p["tables"][] = $field["options"]["pop-table"] . "#structure";
                            }
                        }
                        // Many to many? Include the connecting and "other" table.
                        if ($field["type"] == "many-to-many") {
                            if (!in_array($field["options"]["mtm-connecting-table"] . "#structure", $p["tables"]) && substr($field["options"]["mtm-connecting-table"], 0, 8) != "bigtree_") {
                                $p["tables"][] = $field["options"]["mtm-connecting-table"] . "#structure";
                            }
                            if (!in_array($field["options"]["mtm-other-table"] . "#structure", $p["tables"]) && substr($field["options"]["mtm-other-table"], 0, 8) != "bigtree_") {
                                $p["tables"][] = $field["options"]["mtm-other-table"] . "#structure";
Пример #2
0
 static function getAutoModuleActions($module)
 {
     $items = array();
     $id = sqlescape($module);
     $q = sqlquery("SELECT * FROM bigtree_module_actions WHERE module = '{$id}' AND (form != 0 OR view != 0) AND in_nav = 'on' ORDER BY position DESC, id ASC");
     while ($f = sqlfetch($q)) {
         if ($f["form"]) {
             $f["form"] = BigTreeAutoModule::getForm($f["form"]);
             $f["type"] = "form";
         } elseif ($f["view"]) {
             $f["view"] = BigTreeAutoModule::getView($f["view"]);
             $f["type"] = "view";
         }
         $items[] = $f;
     }
     return $items;
 }
Пример #3
0
// Setup JSON manifest
$package = array("type" => "package", "id" => $id, "version" => $version, "compatibility" => $compatibility, "title" => $title, "description" => $description, "keywords" => $keywords, "author" => $author, "licenses" => $license_array, "components" => array("module_groups" => array(), "modules" => array(), "templates" => array(), "callouts" => array(), "settings" => array(), "feeds" => array(), "field_types" => array(), "tables" => array()), "sql" => array("SET foreign_key_checks = 0"), "files" => array());
$used_forms = array();
$used_views = array();
$used_reports = array();
foreach ((array) $module_groups as $group) {
    $package["components"]["module_groups"][] = $admin->getModuleGroup($group);
}
foreach ((array) $modules as $module) {
    $module = $admin->getModule($module);
    if ($module) {
        $module["actions"] = $admin->getModuleActions($module["id"]);
        foreach ($module["actions"] as $a) {
            // If there's an auto module, include it as well.
            if ($a["form"] && !in_array($a["form"], $used_forms)) {
                $module["forms"][] = BigTreeAutoModule::getForm($a["form"], false);
                $used_forms[] = $a["form"];
            } elseif ($a["view"] && !in_array($a["view"], $used_views)) {
                $module["views"][] = BigTreeAutoModule::getView($a["view"], false);
                $used_views[] = $a["view"];
            } elseif ($a["report"] && !in_array($a["report"], $used_reports)) {
                $module["reports"][] = BigTreeAutoModule::getReport($a["report"]);
                $used_reports[] = $a["report"];
            }
        }
        $module["embed_forms"] = $admin->getModuleEmbedForms("title", $module["id"]);
        $package["components"]["modules"][] = $module;
    }
}
foreach ((array) $templates as $template) {
    $package["components"]["templates"][] = $cms->getTemplate($template);
Пример #4
0
<?php

// Get the form so we can walk through its fields
$form = BigTreeAutoModule::getForm($_GET["form"]);
// Create a generic module class to get the decoded item data
$m = new BigTreeModule();
$m->Table = $form["table"];
$item = $m->get($_GET["id"]);
// Loop through form resources and see if we have related page data, only check html and text fields
if (is_array($form["fields"])) {
    $check_data("", $external, $form["fields"], $item);
}
// Only retrieve these if we have errors as we only need them for URL generation
if (array_filter($integrity_errors)) {
    $action = $admin->getModuleActionForForm($form);
    $module = $admin->getModule($action["module"]);
}
foreach ($integrity_errors as $field => $error_types) {
    foreach ($error_types as $type => $errors) {
        foreach ($errors as $error) {
            ?>
<li>
	<section class="integrity_errors">
		<a href="<?php 
            echo ADMIN_ROOT . $module["route"] . "/" . $action["route"] . "/" . htmlspecialchars($_GET["id"]);
            ?>
/" target="_blank">Edit</a>
		<span class="icon_small icon_small_warning"></span>
		<p>Broken <?php 
            echo $type == "img" ? "Image" : "Link";
            ?>
Пример #5
0
<?php

// If the last command is numeric then we're editing something.
if (is_numeric(end($bigtree["commands"])) || is_numeric(substr(end($bigtree["commands"]), 1))) {
    $bigtree["edit_id"] = $edit_id = end($bigtree["commands"]);
    // Otherwise we're adding something or we're processing something we were editing.
} else {
    $bigtree["edit_id"] = $edit_id = $_POST["id"] ? $_POST["id"] : false;
}
$bigtree["form"] = $form = BigTreeAutoModule::getForm($bigtree["module_action"]["form"]);
$bigtree["form_root"] = ADMIN_ROOT . $bigtree["module"]["route"] . "/" . $bigtree["module_action"]["route"] . "/";
// Provide developers a nice handy link for edit/return of this form
if ($admin->Level > 1) {
    $bigtree["subnav_extras"][] = array("link" => ADMIN_ROOT . "developer/modules/forms/edit/" . $bigtree["form"]["id"] . "/?return=front", "icon" => "setup", "title" => "Edit in Developer");
}
// Audit Trail link
if ($bigtree["edit_id"]) {
    $bigtree["subnav_extras"][] = array("link" => ADMIN_ROOT . "developer/audit/search/?table=" . $bigtree["form"]["table"] . "&entry=" . $bigtree["edit_id"], "icon" => "trail", "title" => "View Audit Trail");
}
$action = $bigtree["commands"][0];
if (!$action || is_numeric($action) || is_numeric(substr($action, 1))) {
    if ($bigtree["edit_id"]) {
        if (isset($_GET["force"])) {
            $admin->unlock($bigtree["form"]["table"], $bigtree["edit_id"]);
        }
        include BigTree::path("admin/auto-modules/forms/edit.php");
    } else {
        include BigTree::path("admin/auto-modules/forms/add.php");
    }
} else {
    include BigTree::path("admin/auto-modules/forms/{$action}.php");
Пример #6
0
<?php

$form = BigTreeAutoModule::getForm(end($bigtree["commands"]));
$module = $admin->getModule(BigTreeAutoModule::getModuleForForm($form));
$table = $form["table"];
$fields = $form["fields"];
if (!is_array($form["hooks"])) {
    $form["hooks"] = array("pre" => "", "post" => "", "publish" => "");
}
if (!BigTree::tableExists($table)) {
    ?>
<div class="container">
	<section>
		<div class="alert">
			<span></span>
			<h3>Error</h3>
		</div>
		<p>The table for this form (<?php 
    echo $table;
    ?>
) no longer exists.</p>
	</section>
	<footer>
		<a href="javascript:history.go(-1);" class="button">Back</a>
		<a href="<?php 
    echo DEVELOPER_ROOT;
    ?>
modules/forms/delete/<?php 
    echo $form["id"];
    ?>
/?module=<?php