/** * Enqueue scripts and styles for the front end. * * @since Twenty Thirteen 1.0 * * @return void */ function utthehill_scripts_styles() { if (!is_admin()) { wp_deregister_script('jquery'); wp_register_script('jquery', "//code.jquery.com/jquery-1.11.2.min.js", array(), null, false); wp_enqueue_script('jquery'); } /* * Adds JavaScript to pages with the comment form to support * sites with threaded comments (when in use). */ if (is_singular() && comments_open() && get_option('thread_comments')) { wp_enqueue_script('comment-reply'); } // Loads UTK JavaScript with added object data fromthe WP table // FOR TESTING // wp_register_script( 'utthehill-utk', get_template_directory_uri() . '/library/js/build/utk-build.js', array( 'jquery' ), '2015-05-13', true ); // FOR PROD wp_register_script('utthehill-utk', get_template_directory_uri() . '/library/js/min/utk-min.js', array('jquery'), '2015-05-20', true); // Setup some vars to pass to js $tempDirectory = get_template_directory_uri(); global $blog_id; $siteId = $blog_id; $contentArray = generateJson(); $translation_array = array('templateDirectory' => $tempDirectory, 'siteId' => $siteId, 'contentArray' => $contentArray); wp_localize_script('utthehill-utk', 'url_object', $translation_array); // run it Lola wp_enqueue_script('utthehill-utk'); // Loads our main stylesheet. wp_enqueue_style('utthehill-style', get_stylesheet_uri(), array(), '2015-05-20'); // Loads the Internet Explorer specific stylesheet. wp_enqueue_style('utthehill-ie', get_template_directory_uri() . '/library/css/ie.css', array('utthehill-style'), '2015-05-20'); wp_style_add_data('utthehill-ie', 'conditional', 'lt IE 9'); }
//ok, everything seems to be fine, it is time to install the tables if (installTables()) { exit(generateJson("✅ Database Tables successfully created.<br>Please wait while we add some initial data...", 1, "install_data", true)); } else { die(generateJson("❌ Oops, something went wrong.", 0, "")); } } elseif ($_POST['action'] == "install_data") { if (installData()) { exit(generateJson("✅ Initial data successfully added", 1, "install_finished", true)); } else { die(generateJson("❌ Can not enter any data!", 0, "")); } } } } else { die(generateJson("❌ please make sure you fill all the boxes", 0, "")); } return null; } else { return null; } } /** * Save database authentication details to setting.php file * * @return bool */ function saveDatabaseDetails() { $settingArray = file(dirname(__FILE__) . '/setting.php'); $settingArray[9] = "define('DB_HOST', '{$_POST['host']}');\n";
$matches = array(); preg_match( '~^generate_form_image_(.+)$~', $action['action'], $matches ); if ( count( $matches ) == 0 ) { $actionName = $action['action']; } else { $actionName = 'generate_form_image'; $sourceId = $matches[1]; } switch ( $actionName ) { case 'generate_lang_js': generateJson( $action ); break; case 'generate_form_image': generateFormImage( $action, $sourceId ); break; } $sql = sprintf( "DELETE FROM ezpending_actions WHERE id = %s", $action['id'] ); $db->query( $sql ); } /** * @param array $action */ function generateJson( $action )
if (substr($data['geom'], 0, 3) == "BOX") { foreach (explode(",", substr($data['geom'], 4, -1)) as $i) { foreach (explode(" ", $i) as $j) { $bbox_array[] = $j; } } } if ($type === "ort") { $title = $data['ort_name']; } elseif ($type === "ortsteil") { $title = $data['stadtteil_name']; } elseif ($type === "straße") { $title = $data['strasse_name'] . " " . $data["zusatz"]; } elseif ($type === "adresse") { $title = $data["strasse"] . " " . $data["hausnummer"] . $data["hausnummerzusatz"] . " " . $data["zusatz"]; } elseif ($type === "poi") { $title = $data['poi_titel']; } else { $title = ""; } $bbox_string = implode(",", $bbox_array); if ($backend) { $href = 'javascript:map.zoomToExtent(new OpenLayers.Bounds(' . $bbox_string . '));'; } else { $href = URL . '?BBOX=' . $bbox_string; } $resultJson["result"] .= generateHtml($href, $bbox_string, $data["type"], $title, $backend); $resultJson["array"][] = generateJson($bbox_array, $data["type"], $title); } header('Content-Type: application/json'); echo json_encode($resultJson);
function saveCache($dir = null, $fileName = null, $data = null, $keep = true) { $tempFile = fopen($dir . '/' . $fileName, "w"); fputs($tempFile, $data); fclose($tempFile); if ($keep === false) { unlink($tempFile); } return $tempFile; } function generateJson() { date_default_timezone_set('Asia/Dhaka'); $time1 = new DateTime(date('Y-m-d h:i:s')); $time2 = new DateTime(date('Y-m-d h:i:s', filectime('cache/dseData.json'))); $interval = $time1->diff($time2); if ($interval->i > 0 || file_exists('cache/dseData.json') === false) { unlink('cache/dseData.json'); $api = new Request(); saveCache('cache', "dseData.json", $api->getResponse('json')); } } if ($requestType == "json") { //re-generate json cache file if the previous file was created more than 1 min ago generateJson(); header('Content-type: application/json'); header("Access-Control-Allow-Origin: *"); print file_get_contents('cache/dseData.json'); } else { exit; }