Exemplo n.º 1
0
 public static function display_page()
 {
     $sites = TauchTerminal_Sites::getSites();
     $current = TauchTerminal_Sites::getCurrentSite();
     wp_enqueue_style('tauch-terminal-styles', plugins_url('tauch-terminal/css/dashboard.css', TAUCHTERMINAL__PLUGIN_DIR));
     TauchTerminal::view('start', array('sites' => $sites, 'currentsite' => $current));
 }
Exemplo n.º 2
0
 public static function default_website()
 {
     if (isset($_POST['action'])) {
         $action = $_POST['action'];
         TauchTerminal_DB::saveSettings($_POST);
     }
     $sites = self::getSites();
     $site = TauchTerminal_DB::getTTOption('default_site');
     $url = TauchTerminal_DB::getTTOption('default_prefix');
     TauchTerminal::view('sites/default', array('sites' => $sites, 'current' => $site, 'url' => $url));
 }
 public static function display_certifications()
 {
     $action = '';
     $data = '';
     $view = 'list';
     $certifications = self::getCertifications();
     if (isset($_POST['action'])) {
         $action = $_POST['action'];
         $data = $_POST;
     } else {
         if (isset($_GET['action'])) {
             $action = $_GET['action'];
             $data = $_GET;
         }
     }
     switch ($action) {
         case 'add':
             TauchTerminal::view('certifications/edit', array('action' => 'save-new'));
             break;
         case 'save-new':
             $id = self::addCertifications($data);
             $certifications = self::getCertifications(array($id));
             TauchTerminal::view('certifications/edit', array('certification' => $certifications[0], 'action' => 'save-edit'));
             break;
         case 'edit':
             $certifications = self::getCertifications($data["post"]);
             TauchTerminal::view('certifications/edit', array('certification' => $certifications[0], 'action' => 'save-edit'));
             break;
         case 'save-edit':
             $id = self::updateCertifications($data);
             $certifications = self::getCertifications(array($id));
             TauchTerminal::view('certifications/edit', array('certification' => $certifications[0], 'action' => 'save-edit'));
             break;
         case 'trash':
         default:
             if ($action == 'trash') {
                 TauchTerminal_Certifications::deleteCertifications($data["post"]);
             }
             wp_enqueue_style('tauch-terminal-styles', plugins_url('css/edit.css', __FILE__));
             TauchTerminal::view('certifications/list', array('certifications' => $certifications));
             break;
     }
 }
Exemplo n.º 4
0
 public static function ca_handler()
 {
     $cacheName = 'ca_api_external.xml.cache';
     $cacheNameReview = 'ca_api_reviews.xml.cache';
     $ageInSeconds = 86400;
     // one day
     $globalStatistics = '';
     $portalStatistics = '';
     $errors = array();
     libxml_use_internal_errors(true);
     // generate the cache version if it doesn't exist or it's too old!
     clearstatcache();
     if (!file_exists($cacheName) || filemtime($cacheName) + $ageInSeconds < time()) {
         $ca_api_external = TauchTerminal_DB::getTTOption('ca_api_external');
         if (($response_xml_data = file_get_contents($ca_api_external)) !== false) {
             file_put_contents($cacheName, $response_xml_data);
         }
     }
     if (!file_exists($cacheNameReview) || filemtime($cacheNameReview) + $ageInSeconds < time()) {
         $ca_api_reviews = TauchTerminal_DB::getTTOption('ca_api_reviews');
         if (($response_xml_data = file_get_contents($ca_api_reviews)) !== false) {
             file_put_contents($cacheNameReview, $response_xml_data);
         }
     }
     $data = simplexml_load_file($cacheName);
     if (!$data) {
         $errors[] = "Error loading XML " . $cacheName;
         foreach (libxml_get_errors() as $error) {
             $errors[] = $error->message;
         }
         libxml_clear_errors();
     } else {
         $globalStatistics = $data->globalStatistics;
         $portalStatistics = $data->portalStatistics;
     }
     $data_review = simplexml_load_file($cacheNameReview);
     if (!$data_review) {
         $errors[] = "Error loading XML " . $cacheNameReview;
         foreach (libxml_get_errors() as $error) {
             $errors[] = $error->message;
         }
         libxml_clear_errors();
     } else {
         $data_review = $data_review->reviews->review;
     }
     if (!empty($errors)) {
         TauchTerminal::view('tulamben/rating_default', array('error' => $errors));
     } else {
         // pagination
         global $wp_query;
         $page = $wp_query->query_vars['page'] ? $wp_query->query_vars['page'] : 1;
         $pagination = new LimitPagination($page, $data_review->count(), 20);
         TauchTerminal::view('tulamben/rating', array('data_review' => $pagination->getLimitIterator($data_review), 'globalStatistics' => $globalStatistics, 'portalStatistics' => $portalStatistics, 'pagination' => $pagination));
     }
 }