function __destruct() { // Need $admin back if it's already been destroyed global $admin; $admin = new BigTreeAdmin(); foreach ($this->AutoSaveSettings as $id => $obj) { if (is_object($obj)) { $admin->updateSettingValue($id, get_object_vars($obj)); } else { $admin->updateSettingValue($id, $obj); } } }
function __construct() { global $cms; $geo_service = $cms->getSetting("bigtree-internal-geocoding-service"); // If for some reason the setting doesn't exist, make one. if (!is_array($geo_service) || !$geo_service["service"]) { $this->Service = "google"; $admin = new BigTreeAdmin(); $admin->createSetting(array("id" => "bigtree-internal-geocoding-service", "encrypted" => "on", "system" => "on")); $admin->updateSettingValue("bigtree-internal-geocoding-service", array("service" => "google")); } else { $this->Service = $geo_service["service"]; $this->Settings = $geo_service; } // Yahoo BOSS Geocoding uses the Yahoo BOSS API. if ($this->Service == "yahoo-boss") { $this->API = new BigTreeYahooBOSSAPI(); } }
function __destruct() { foreach ($this->AutoSaveSettings as $id => $obj) { if (is_object($obj)) { BigTreeAdmin::updateSettingValue($id, get_object_vars($obj)); } else { BigTreeAdmin::updateSettingValue($id, $obj); } } }
function __construct() { $s = BigTreeAdmin::getSetting("bigtree-internal-email-service"); // Setting doesn't exist? Create it. if ($s === false) { sqlquery("INSERT INTO bigtree_settings (`id`,`system`,`encrypted`) VALUES ('bigtree-internal-email-service','on','on')"); $s = array("service" => "", "settings" => array()); BigTreeAdmin::updateSettingValue("bigtree-internal-email-service", $s); } $this->Service = !empty($s["value"]["service"]) ? $s["value"]["service"] : "local"; $this->Settings = !empty($s["value"]["settings"]) ? $s["value"]["settings"] : array(); }
static function getFilterQuery($view) { global $admin; $module = BigTreeAdmin::getModule(self::getModuleForView($view)); if (isset($module["gbp"]["enabled"]) && $module["gbp"]["enabled"] && $module["gbp"]["table"] == $view["table"]) { $groups = $admin->getAccessGroups($module["id"]); if (is_array($groups)) { $gfl = array(); foreach ($groups as $g) { if ($view["type"] == "nested" && $module["gbp"]["group_field"] == $view["options"]["nesting_column"]) { $gfl[] = "`id` = '" . sqlescape($g) . "' OR `gbp_field` = '" . sqlescape($g) . "'"; } else { $gfl[] = "`gbp_field` = '" . sqlescape($g) . "'"; } } return " AND (" . implode(" OR ", $gfl) . ")"; } } return ""; }
$_SESSION["bigtree_admin"]["post_max_hit"] = true; BigTree::redirect($_SERVER["HTTP_REFERER"]); } $admin->requireLevel(1); $item = $admin->getSetting($_POST["id"]); if ($item["system"] || $item["locked"] && $admin->Level < 2) { $admin->growl("Settings", "Access Denied", "error"); } else { $bigtree["crops"] = array(); $bigtree["errors"] = array(); $bigtree["post_data"] = $_POST; $bigtree["file_data"] = BigTree::parsedFilesArray(); // Pretend like we're a normal field $field = array("type" => $item["type"], "title" => $item["title"], "key" => "value", "options" => json_decode($item["options"], true), "ignore" => false, "input" => $bigtree["post_data"]["value"], "file_input" => $bigtree["file_data"]["value"]); // Process the input $output = BigTreeAdmin::processField($field); if (!is_null($output)) { $admin->updateSettingValue($_POST["id"], $output); } $admin->growl("Settings", "Updated Setting"); } $_SESSION["bigtree_admin"]["form_data"] = array("page" => true, "return_link" => ADMIN_ROOT . "settings/", "edit_link" => ADMIN_ROOT . "settings/edit/" . $_POST["id"] . "/", "errors" => $bigtree["errors"]); // Track resource allocation $admin->allocateResources("settings", $_POST["id"]); if (count($bigtree["crops"])) { $_SESSION["bigtree_admin"]["form_data"]["crop_key"] = $cms->cacheUnique("org.bigtreecms.crops", $bigtree["crops"]); BigTree::redirect(ADMIN_ROOT . "settings/crop/"); } elseif (count($bigtree["errors"])) { BigTree::redirect(ADMIN_ROOT . "settings/error/"); } BigTree::redirect(ADMIN_ROOT . "settings/");
?> > <p>Click "Add Item" to add an item to this list.</p> </section> <ul> <?php $x = 0; foreach ($field["value"] as $item) { ?> <li> <input type="hidden" class="bigtree_matrix_data" value="<?php echo base64_encode(json_encode($item)); ?> " /> <?php BigTreeAdmin::drawArrayLevel(array($x), $item, $field); ?> <input type="hidden" name="<?php echo $field["key"]; ?> [<?php echo $x; ?> ][__internal-title]" value="<?php echo BigTree::safeEncode($item["__internal-title"]); ?> " /> <input type="hidden" name="<?php echo $field["key"]; ?> [<?php
if (!BigTreeAdmin::urlExists($data)) { $integrity_errors[$field] = array("a" => array($data)); } } // Internal link } elseif (substr($data, 0, 4) == "http") { if (!BigTreeAdmin::urlExists($data)) { $integrity_errors[$field] = array("a" => array($data)); } } // HTML we just run through checkHTML } elseif ($resource["type"] == "html") { $integrity_errors[$field] = BigTreeAdmin::checkHTML($local_path, $data, $external); } elseif ($resource["type"] == "callouts" && is_array($data)) { foreach ($data as $callout_data) { $callout = BigTreeAdmin::getCallout($callout_data["type"]); if ($callout) { // We're going to modify the field titles so that it makes more sense when someone is diagnosing the issue $callout_resources = array_filter((array) $callout["resources"]); foreach ($callout_resources as &$column) { // If we have an internal title saved we can give even more context to which matrix entity has the problem if ($callout_data["display_title"]) { $column["title"] = $field . " » " . $callout_data["display_title"] . " » " . $column["title"]; } else { $column["title"] = $field . " » " . $column["title"]; } } $check_data($local_path, $external, $callout["resources"], $callout_data); } } } elseif ($resource["type"] == "matrix" && is_array($data)) {
function update($id, $fields, $values = false, $ignore_cache = false) { $id = sqlescape($id); // Turn a key => value array into pairs if ($values === false && is_array($fields)) { $values = $fields; $fields = array_keys($fields); } // Multiple columns to update if (is_array($fields)) { $query_parts = array(); foreach ($fields as $key) { $val = current($values); if (is_array($val)) { $val = BigTree::json(BigTree::translateArray($val)); } else { $val = BigTreeAdmin::autoIPL($val); } $query_parts[] = "`{$key}` = '" . sqlescape($val) . "'"; next($values); } sqlquery("UPDATE `" . $this->Table . "` SET " . implode(", ", $query_parts) . " WHERE id = '{$id}'"); // Single column to update } else { if (is_array($values)) { $val = json_encode(BigTree::translateArray($values)); } else { $val = BigTreeAdmin::autoIPL($values); } sqlquery("UPDATE `" . $this->Table . "` SET `{$fields}` = '" . sqlescape($val) . "' WHERE id = '{$id}'"); } if (!$ignore_cache) { BigTreeAutoModule::recacheItem($id, $this->Table); } }
function oAuthRedirect() { $this->Settings["token_secret"] = ""; $admin = new BigTreeAdmin(); $r = $this->callAPI("http://www.flickr.com/services/oauth/request_token", "GET", array("oauth_callback" => $this->ReturnURL)); parse_str($r); if ($oauth_callback_confirmed) { $this->Settings["token"] = $oauth_token; $this->Settings["token_secret"] = $oauth_token_secret; header("Location: http://www.flickr.com/services/oauth/authorize?perms=delete&oauth_token=" . $oauth_token); die; } else { $admin->growl($oauth_problem, "Flickr API", "error"); BigTree::redirect(ADMIN_ROOT . "developer/services/flickr/"); } }
// If we haven't failed, we're going to grab our image and set it up for crops and such if (!$field["ignore"]) { $local_image_copy = SITE_ROOT . "files/" . uniqid("temp-") . ".jpg"; BigTree::cURL($source_image, false, array(), false, $local_image_copy); list($width, $height) = getimagesize($local_image_copy); // If this is a YouTube video we don't have video dimensions so we're going to guess them from the image size if ($field["output"]["service"] == "youtube") { $field["output"]["height"] = $height; $field["output"]["width"] = $width; $field["output"]["embed"] = '<iframe width="' . $width . '" height="' . $height . '" src="https://www.youtube.com/embed/' . $video_id . '" frameborder="0" allowfullscreen></iframe>'; } // Normally we'd fail, but it's not like you can create a higher resolution video clip here. if ($width < $min_width || $height < $min_height) { BigTree::createUpscaledImage($local_image_copy, $local_image_copy, $min_width, $min_height); } // Pretend to be a normal image field and process it $field_copy = $field; $field_copy["file_input"] = array("name" => $field["output"]["service"] . "-video-" . $video_id . ".jpg", "tmp_name" => $local_image_copy, "error" => false); $field["output"]["image"] = BigTreeAdmin::processImageUpload($field_copy); } // Either this field has never been used or was explicitly deleted } elseif (empty($field["input"])) { $field["output"] = array(); // Using existing value } else { if ($field["input"]["existing"]) { $field["output"] = json_decode($field["input"]["existing"], true); } else { $field["ignore"] = true; } }
static function translateArray($array) { foreach ($array as &$piece) { if (is_array($piece)) { $piece = static::translateArray($piece); } else { $piece = BigTreeAdmin::autoIPL($piece); } } return $array; }
} ?> </label> <div class="contain"> <?php $x = 0; foreach ($field["value"] as $callout) { $type = $admin->getCallout($callout["type"]); ?> <article> <input type="hidden" class="callout_data" value="<?php echo base64_encode(json_encode($callout)); ?> " /> <?php BigTreeAdmin::drawArrayLevel(array($x), $callout); ?> <h4> <?php echo BigTree::safeEncode($callout["display_title"]); ?> <input type="hidden" name="<?php echo $field["key"]; ?> [<?php echo $x; ?> ][display_title]" value="<?php echo BigTree::safeEncode($callout["display_title"]); ?> " />
function installFTP($ftp_root) { $ftp_root = "/" . trim($ftp_root, "/") . "/"; // Create backups folder $this->Connection->createDirectory($ftp_root . "backups/"); // Doing a core upgrade if ($this->Extension === false) { // Backup database BigTreeAdmin::backupDatabase(SERVER_ROOT . "cache/backup.sql"); $this->Connection->rename($ftp_root . "cache/backup.sql", $ftp_root . "backups/core-" . BIGTREE_VERSION . "/backup.sql"); // Backup old core $this->Connection->rename($ftp_root . "core/", $ftp_root . "backups/core-" . BIGTREE_VERSION . "/"); // Move new core into place $this->Connection->rename($ftp_root . "cache/update/core/", $ftp_root . "core/"); // Doing an extension upgrade } else { $extension = $this->Extension; // Create a backups folder for this extension $this->Connection->createDirectory($ftp_root . "backups/extensions/"); $this->Connection->createDirectory($ftp_root . "backups/extensions/{$extension}/"); // Read manifest file for current version $current_manifest = json_decode(file_get_contents(SERVER_ROOT . "extensions/{$extension}/manifest.json"), true); $old_version = $current_manifest["version"]; // Get a unique directory name $old_version = BigTree::getAvailableFileName(SERVER_ROOT . "backups/extensions/{$extension}/", $old_version); // Move old extension into backups $this->Connection->rename($ftp_root . "extensions/{$extension}/", $ftp_root . "backups/extensions/{$extension}/{$old_version}/"); // Move new extension into place $this->Connection->rename($ftp_root . "cache/update/", $ftp_root . "extensions/{$extension}/"); } $this->cleanup(); }
?> > <p>Click "Add Item" to add an item to this list.</p> </section> <ul> <?php $x = 0; foreach ($field["value"] as $item) { ?> <li> <input type="hidden" class="bigtree_matrix_data" value="<?php echo base64_encode(json_encode($item)); ?> " /> <?php BigTreeAdmin::drawArrayLevel(array($x), $item); ?> <input type="hidden" name="<?php echo $field["key"]; ?> [<?php echo $x; ?> ][__internal-title]" value="<?php echo BigTree::safeEncode($item["__internal-title"]); ?> " /> <input type="hidden" name="<?php echo $field["key"]; ?> [<?php
function saveSettings() { $admin = new BigTreeAdmin(); $admin->updateSettingValue("bigtree-internal-payment-gateway", array("service" => $this->Service, "settings" => $this->Settings)); }
<?php $server_root = str_replace("core/cron.php", "", strtr(__FILE__, "\\", "/")); include $server_root . "custom/environment.php"; include $server_root . "custom/settings.php"; include $server_root . "core/bootstrap.php"; if (BIGTREE_CUSTOM_ADMIN_CLASS) { include BigTree::path(BIGTREE_CUSTOM_ADMIN_CLASS_PATH); // Can't instantiate class from a constant name, so we use a variable then unset it. $c = BIGTREE_CUSTOM_ADMIN_CLASS; $admin = new $c(); unset($c); } else { include BigTree::path("inc/bigtree/admin.php"); $admin = new BigTreeAdmin(); } // Send out Daily Digests and Content Alerts $admin->emailDailyDigest(); // Cache Google Analytics Information $analytics = new BigTreeGoogleAnalyticsAPI(); if ($analytics->API && $analytics->Profile) { $analytics->cacheInformation(); } // Let the CMS know we're running cron properly if (!$admin->settingExists("bigtree-internal-cron-last-run")) { $admin->createSetting(array("id" => "bigtree-internal-cron-last-run", "system" => "on")); } // Tell the admin we've ran cron recently. $admin->updateSettingValue("bigtree-internal-cron-last-run", time());
static function translateArray($array) { $admin = new BigTreeAdmin(); foreach ($array as &$piece) { if (is_array($piece)) { $piece = self::translateArray($piece); } else { $piece = $admin->autoIPL($piece); } } return $array; }
function _local_bigtree_update_200() { global $cms, $admin; // Drop unused comments column sqlquery("ALTER TABLE bigtree_pending_changes DROP COLUMN `comments`"); // Add extension columns sqlquery("ALTER TABLE bigtree_callouts ADD COLUMN `extension` VARCHAR(255)"); sqlquery("ALTER TABLE bigtree_callouts ADD FOREIGN KEY (extension) REFERENCES `bigtree_extensions` (id) ON DELETE CASCADE"); sqlquery("ALTER TABLE bigtree_feeds ADD COLUMN `extension` VARCHAR(255)"); sqlquery("ALTER TABLE bigtree_feeds ADD FOREIGN KEY (extension) REFERENCES `bigtree_extensions` (id) ON DELETE CASCADE"); sqlquery("ALTER TABLE bigtree_field_types ADD COLUMN `extension` VARCHAR(255)"); sqlquery("ALTER TABLE bigtree_field_types ADD FOREIGN KEY (extension) REFERENCES `bigtree_extensions` (id) ON DELETE CASCADE"); sqlquery("ALTER TABLE bigtree_modules ADD COLUMN `extension` VARCHAR(255)"); sqlquery("ALTER TABLE bigtree_modules ADD FOREIGN KEY (extension) REFERENCES `bigtree_extensions` (id) ON DELETE CASCADE"); sqlquery("ALTER TABLE bigtree_module_groups ADD COLUMN `extension` VARCHAR(255)"); sqlquery("ALTER TABLE bigtree_module_groups ADD FOREIGN KEY (extension) REFERENCES `bigtree_extensions` (id) ON DELETE CASCADE"); sqlquery("ALTER TABLE bigtree_settings ADD COLUMN `extension` VARCHAR(255)"); sqlquery("ALTER TABLE bigtree_settings ADD FOREIGN KEY (extension) REFERENCES `bigtree_extensions` (id) ON DELETE CASCADE"); sqlquery("ALTER TABLE bigtree_templates ADD COLUMN `extension` VARCHAR(255)"); sqlquery("ALTER TABLE bigtree_templates ADD FOREIGN KEY (extension) REFERENCES `bigtree_extensions` (id) ON DELETE CASCADE"); // New publish_hook column, consolidate other hooks into one column sqlquery("ALTER TABLE bigtree_pending_changes ADD COLUMN `publish_hook` VARCHAR(255)"); sqlquery("ALTER TABLE bigtree_module_forms ADD COLUMN `hooks` TEXT"); sqlquery("ALTER TABLE bigtree_module_embeds ADD COLUMN `hooks` TEXT"); $q = sqlquery("SELECT * FROM bigtree_module_forms"); while ($f = sqlfetch($q)) { $hooks = array(); $hooks["pre"] = $f["preprocess"]; $hooks["post"] = $f["callback"]; $hooks["publish"] = ""; sqlquery("UPDATE bigtree_module_forms SET hooks = '" . BigTree::json($hooks, true) . "' WHERE id = '" . $f["id"] . "'"); } $q = sqlquery("SELECT * FROM bigtree_module_embeds"); while ($f = sqlfetch($q)) { $hooks = array(); $hooks["pre"] = $f["preprocess"]; $hooks["post"] = $f["callback"]; $hooks["publish"] = ""; sqlquery("UPDATE bigtree_module_embeds SET hooks = '" . BigTree::json($hooks, true) . "' WHERE id = '" . $f["id"] . "'"); } sqlquery("ALTER TABLE bigtree_module_forms DROP COLUMN `preprocess`"); sqlquery("ALTER TABLE bigtree_module_forms DROP COLUMN `callback`"); sqlquery("ALTER TABLE bigtree_module_embeds DROP COLUMN `preprocess`"); sqlquery("ALTER TABLE bigtree_module_embeds DROP COLUMN `callback`"); // Adjust groups/callouts for multi-support -- first we drop the foreign key $table_desc = BigTree::describeTable("bigtree_callouts"); foreach ($table_desc["foreign_keys"] as $name => $definition) { if ($definition["local_columns"][0] === "group") { sqlquery("ALTER TABLE bigtree_callouts DROP FOREIGN KEY `{$name}`"); } } // Add the field to the groups sqlquery("ALTER TABLE bigtree_callout_groups ADD COLUMN `callouts` TEXT AFTER `name`"); // Find all the callouts in each group $q = sqlquery("SELECT * FROM bigtree_callout_groups"); while ($f = sqlfetch($q)) { $callouts = array(); $qq = sqlquery("SELECT * FROM bigtree_callouts WHERE `group` = '" . $f["id"] . "' ORDER BY position DESC, id ASC"); while ($ff = sqlfetch($qq)) { $callouts[] = $ff["id"]; } sqlquery("UPDATE bigtree_callout_groups SET `callouts` = '" . BigTree::json($callouts, true) . "' WHERE id = '" . $f["id"] . "'"); } // Drop the group column sqlquery("ALTER TABLE bigtree_callouts DROP COLUMN `group`"); // Security policy setting sqlquery("INSERT INTO `bigtree_settings` (`id`,`value`,`system`) VALUES ('bigtree-internal-security-policy','{}','on')"); sqlquery("CREATE TABLE `bigtree_login_attempts` (`id` int(11) unsigned NOT NULL AUTO_INCREMENT, `ip` int(11) DEFAULT NULL, `user` int(11) DEFAULT NULL, `timestamp` timestamp NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8"); sqlquery("CREATE TABLE `bigtree_login_bans` (`id` int(11) unsigned NOT NULL AUTO_INCREMENT, `ip` int(11) DEFAULT NULL, `user` int(11) DEFAULT NULL, `created` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `expires` datetime DEFAULT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8"); // Media settings sqlquery("INSERT INTO `bigtree_settings` (`id`,`value`,`system`) VALUES ('bigtree-internal-media-settings','{}','on')"); // New field types @unlink(SERVER_ROOT . "cache/bigtree-form-field-types.json"); // Setup an anonymous function for converting a resource set $resource_converter = function ($resources) { $new_resources = array(); foreach ($resources as $item) { // Array of Items no longer exists, switching to Matrix if ($item["type"] == "array") { $item["type"] = "matrix"; $item["columns"] = array(); $x = 0; foreach ($item["fields"] as $field) { $x++; $item["columns"][] = array("id" => $field["key"], "type" => $field["type"], "title" => $field["title"], "display_title" => $x == 1 ? "on" : ""); } unset($item["fields"]); } $r = array("id" => $item["id"], "type" => $item["type"], "title" => $item["title"], "subtitle" => $item["subtitle"], "options" => array()); foreach ($item as $key => $val) { if ($key != "id" && $key != "title" && $key != "subtitle" && $key != "type") { $r["options"][$key] = $val; } } $new_resources[] = $r; } return BigTree::json($new_resources, true); }; $field_converter = function ($fields) { $new_fields = array(); foreach ($fields as $id => $field) { // Array of Items no longer exists, switching to Matrix if ($field["type"] == "array") { $field["type"] = "matrix"; $field["columns"] = array(); $x = 0; foreach ($field["fields"] as $subfield) { $x++; $field["columns"][] = array("id" => $subfield["key"], "type" => $subfield["type"], "title" => $subfield["title"], "display_title" => $x == 1 ? "on" : ""); } unset($field["fields"]); } $r = array("column" => $id, "type" => $field["type"], "title" => $field["title"], "subtitle" => $field["subtitle"], "options" => array()); foreach ($field as $key => $val) { if ($key != "id" && $key != "title" && $key != "subtitle" && $key != "type") { $r["options"][$key] = $val; } } $new_fields[] = $r; } return $new_fields; }; // New resource format to be less restrictive on option names $q = sqlquery("SELECT * FROM bigtree_callouts"); while ($f = sqlfetch($q)) { $resources = $resource_converter(json_decode($f["resources"], true)); sqlquery("UPDATE bigtree_callouts SET resources = '{$resources}' WHERE id = '" . $f["id"] . "'"); } $q = sqlquery("SELECT * FROM bigtree_templates"); while ($f = sqlfetch($q)) { $resources = $resource_converter(json_decode($f["resources"], true)); sqlquery("UPDATE bigtree_templates SET resources = '{$resources}' WHERE id = '" . $f["id"] . "'"); } // Forms and Embedded Forms $q = sqlquery("SELECT * FROM bigtree_module_forms"); while ($f = sqlfetch($q)) { $fields = $field_converter(json_decode($f["fields"], true)); sqlquery("UPDATE bigtree_module_forms SET fields = '" . BigTree::json($fields, true) . "' WHERE id = '" . $f["id"] . "'"); } $q = sqlquery("SELECT * FROM bigtree_module_embeds"); while ($f = sqlfetch($q)) { $fields = $field_converter(json_decode($f["fields"], true)); sqlquery("UPDATE bigtree_module_embeds SET fields = '" . BigTree::json($fields, true) . "' WHERE id = '" . $f["id"] . "'"); } // Settings $q = sqlquery("SELECT * FROM bigtree_settings WHERE type = 'array'"); while ($f = sqlfetch($q)) { // Update settings options to turn array into matrix $options = json_decode($f["options"], true); $options["columns"] = array(); $x = 0; foreach ($options["fields"] as $field) { $x++; $options["columns"][] = array("id" => $field["key"], "type" => $field["type"], "title" => $field["title"], "display_title" => $x == 1 ? "on" : ""); if ($x == 1) { $display_key = $field["key"]; } } unset($options["fields"]); // Update the value to set an internal title key $value = BigTreeCMS::getSetting($f["id"]); foreach ($value as &$entry) { $entry["__internal-title"] = $entry[$display_key]; } unset($entry); // Update type/options sqlquery("UPDATE bigtree_settings SET type = 'matrix', options = '" . BigTree::json($options, true) . "' WHERE id = '" . $f["id"] . "'"); // Update value separately BigTreeAdmin::updateSettingValue($f["id"], $value); } }
?> "<?php } ?> > <img src="<?php echo $preview_image; ?> " alt="" /> </figure> <input type="hidden" class="bigtree_matrix_data" value="<?php echo base64_encode(json_encode($item)); ?> " /> <?php BigTreeAdmin::drawArrayLevel(array($current), $item); ?> <a href="#" class="icon_edit"></a> <a href="#" class="icon_delete"></a> </li> <?php $current++; } ?> </ul> <footer class="btx_media_gallery_footer"> <?php if (!$field["options"]["disable_photos"]) { ?> <a href="#" class="add_item button" data-type="photo"><span class="icon_small icon_small_picture"></span>Add Photo</a> <?php
} ?> <p class="error_message" style="display: none;">Errors found! Please fix the highlighted fields before submitting.</p> <div class="form_fields"> <?php $bigtree["html_fields"] = array(); $bigtree["simple_html_fields"] = array(); $bigtree["tabindex"] = 1; $bigtree["field_namespace"] = uniqid("template_field_"); $bigtree["field_counter"] = 0; // We alias $bigtree["entry"] to $bigtree["resources"] so that information is in the same place for field types. $bigtree["entry"] =& $bigtree["resources"]; if (is_array($bigtree["template"]["resources"]) && count($bigtree["template"]["resources"])) { foreach ($bigtree["template"]["resources"] as $resource) { $field = array("type" => $resource["type"], "title" => $resource["title"], "subtitle" => $resource["subtitle"], "key" => "resources[" . $resource["id"] . "]", "value" => isset($bigtree["resources"][$resource["id"]]) ? $bigtree["resources"][$resource["id"]] : "", "tabindex" => $bigtree["tabindex"], "options" => $resource["options"]); BigTreeAdmin::drawField($field); } } else { echo '<p>There are no resources for the selected template.</p>'; } ?> </div> <?php $bigtree["html_editor_width"] = 898; $bigtree["html_editor_height"] = 365; include BigTree::path("admin/layouts/_html-field-loader.php"); $bigtree["tinymce_fields"] = array_merge($bigtree["html_fields"], $bigtree["simple_html_fields"]); ?> <script> BigTree.TinyMCEFields = <?php echo json_encode($bigtree["tinymce_fields"]);
/** * Import data from GatherContent * * @param int $settingsId The gcontent record id * @param Object $data GatherContent data object * */ public static function import($settingsId, $data) { $data = json_decode($data); $data = $data->data; $btAdmin = new BigTreeAdmin(); // remove the existing site pages sqlquery("delete from bigtree_pages where id > 0"); // get the settings $gContent = new GatherContent(); $gContent = $gContent->get($settingsId); $dataMap = $gContent["data_map"]; // gatherContentPageId => bigtreePageId $newStructure = array(); $homeId = -1; foreach ($data as $dCounter => $pageData) { if ($pageData->parent_id == 0) { $homeId = $pageData->id; continue; } // get the page content data $c = curl_init(); curl_setopt($c, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($c, CURLOPT_HTTPHEADER, array('Accept: application/vnd.gathercontent.v0.5+json')); curl_setopt($c, CURLOPT_USERPWD, $gContent["username"] . ":" . $gContent["apikey"]); curl_setopt($c, CURLOPT_URL, "https://api.gathercontent.com/items/" . $pageData->id); curl_setopt($c, CURLOPT_RETURNTRANSFER, true); $contentData = json_decode(curl_exec($c)); $contentData = $contentData->data; curl_close($c); $btPage = array(); $btPage["trunk"] = ""; if ($pageData->parent_id == 0) { $btPage["parent"] = 0; } else { if (array_key_exists($pageData->parent_id, $newStructure)) { $btPage["parent"] = $newStructure[$pageData->parent_id]; } else { $btPage["parent"] = 0; } } $btPage["in_nav"] = "on"; $btPage["meta_description"] = ""; $btPage["meta_keywords"] = ""; $btPage["seo_invisible"] = ""; $btPage["template"] = "content"; $btPage["external"] = ""; $btPage["new_window"] = ""; $btPage["resources"] = ""; $btPage["archived"] = ""; $btPage["archived_inherited"] = ""; $btPage["max_age"] = 0; $btPage["last_edited_by"] = $_SESSION["bigtree_admin"]["id"]; $btPage["ga_page_views"] = 0; $btPage["position"] = 0; // store the data fields $hasResources = false; foreach ($dataMap as $fieldCounter => $fieldData) { switch (strtolower($fieldData["bigTreeField"])) { case "resource": $hasResources = true; break; default: $btPage[$fieldData["bigTreeField"]] = trim(strip_tags(GatherContent::getFieldData($contentData->config, $fieldData["gatherContentTab"], $fieldData["gatherContentField"]))); break; } } // store the page resource fields // // these are stored as a JSON string if ($hasResources) { $btPage["resources"] = "{"; foreach ($dataMap as $fieldCounter => $fieldData) { switch (strtolower($fieldData["bigTreeField"])) { case "resource": // add data to the JSON string in format: "name": "value" $btPage["resources"] .= "\"" . $fieldData["resourceField"] . "\": \"" . trim(strip_tags(GatherContent::getFieldData($contentData->config, $fieldData["gatherContentTab"], $fieldData["gatherContentField"]))) . "\","; break; } } // remove the last comma $btPage["resources"] = trim($btPage["resources"], ","); $btPage["resources"] .= "}"; } if (empty($btPage["title"])) { $btPage["title"] = trim(strip_tags($pageData->name)); } if (empty($btPage["nav_title"])) { $btPage["nav_title"] = trim(strip_tags($pageData->name)); } // create bigtree page $newId = $btAdmin->createPage($btPage); // store both page ids in $newStructure if (!empty($newId)) { $newStructure[$pageData->id] = $newId; } } }
} else { $bigtree["js"] = array(); } if (isset($bigtree["config"]["admin_css"]) && is_array($bigtree["config"]["admin_css"])) { $bigtree["css"] = $bigtree["config"]["admin_css"]; } else { $bigtree["css"] = array(); } // Instantiate the $admin var with either a custom class or the normal BigTreeAdmin. if (BIGTREE_CUSTOM_ADMIN_CLASS) { // Can't instantiate class from a constant name, so we use a variable then unset it. $c = BIGTREE_CUSTOM_ADMIN_CLASS; $admin = new $c(); unset($c); } else { $admin = new BigTreeAdmin(); } // Load the default layout. $bigtree["layout"] = "default"; $bigtree["subnav_extras"] = array(); // If we're not logged in and we're not trying to login or access an embedded form, redirect to the login page. if (!isset($admin->ID) && $bigtree["path"][1] != "login") { if (implode(array_slice($bigtree["path"], 1), "/") != "ajax/auto-modules/embeddable-form") { $_SESSION["bigtree_login_redirect"] = DOMAIN . $_SERVER["REQUEST_URI"]; BigTree::redirect(ADMIN_ROOT . "login/"); } } // Developer Mode On? if (isset($admin->ID) && !empty($bigtree["config"]["developer_mode"]) && $admin->Level < 2) { include BigTree::path("admin/pages/developer-mode.php"); $admin->stop();
} ?> </label> <div class="contain"> <?php $x = 0; foreach ($field["value"] as $callout) { $type = $admin->getCallout($callout["type"]); ?> <article> <input type="hidden" class="callout_data" value="<?php echo base64_encode(json_encode($callout)); ?> " /> <?php BigTreeAdmin::drawArrayLevel(array($x), $callout, $field); ?> <h4> <?php echo BigTree::safeEncode($callout["display_title"]); ?> <input type="hidden" name="<?php echo $field["key"]; ?> [<?php echo $x; ?> ][display_title]" value="<?php echo BigTree::safeEncode($callout["display_title"]); ?> " />