示例#1
0
 /**
  * Load a view file. The file should be located in Bizyhood/Views.
  * @param string $file The filename of the view without the extenstion (assumed
  *  to be PHP)
  * @param array $data An associative array of data that be be extracted and
  *  available to the view
  * @param bool $return Return the output instead of outputting it
  */
 public static function load($file, $data = array(), $return = false, $eval = true)
 {
     $file = dirname(__FILE__) . '/Views/' . $file . '.php';
     if (!file_exists($file)) {
         Bizyhood_Log::add('fatal', "View '{$file}' was not found");
         throw new Exception("View '{$file}' was not found");
     }
     # Extract the variables into the global scope so the views can use them
     extract($data);
     if (!$return) {
         if ($eval) {
             include $file;
         } else {
             readfile($file);
         }
     } else {
         ob_start();
         if ($eval) {
             include $file;
         } else {
             readfile($file);
         }
         return ob_get_clean();
     }
 }
示例#2
0
 /**
  * The name of a timer that has already been started. Writes the stopping
  *  point and result to the log automatically
  * @param string $timer_description The description of a timer that has
  *  already been started
  * @return The number of seconds elapsed if the timer exists, false if it
  *  doesn't
  */
 public static function stop($timer_description)
 {
     if (array_key_exists($timer_description, self::$_timers)) {
         $start = self::$_timers[$timer_description];
         $stop = microtime(true);
         $seconds = round($stop - $start, 6);
         Bizyhood_Log::add('info', "Stopped benchmark: {$seconds} seconds for '{$timer_description}'");
         return $seconds;
     } else {
         Bizyhood_Log::add('warn', "Unknown benchmark 'stopped': {$timer_description}");
         return FALSE;
     }
 }
示例#3
0
 public static function handleException(Exception $ex)
 {
     Bizyhood_Log::add('error', "Exception: " . $ex->__toString());
 }
示例#4
0
 /**
  * The callback that is executed when the user is loading the admin page.
  *  Basically, output the page content for the admin page. The function
  *  acts just like a controller method for and MVC app. That is, it loads
  *  a view.
  */
 public function adminMenuCallback()
 {
     Bizyhood_Log::add('debug', "Admin page callback executed");
     Bizyhood_Utility::sendInstallReportIfNew();
     $data = array();
     $data['api_url'] = Bizyhood_Utility::getApiUrl();
     $data['main_page_id'] = Bizyhood_Utility::getOption(self::KEY_MAIN_PAGE_ID);
     $data['signup_page_id'] = Bizyhood_Utility::getOption(self::KEY_SIGNUP_PAGE_ID);
     $data['zip_codes'] = Bizyhood_Utility::getOption(self::KEY_ZIP_CODES);
     $data['use_cuisine_types'] = Bizyhood_Utility::getOption(self::KEY_USE_CUISINE_TYPES);
     $data['categories'] = Bizyhood_Utility::getOption(self::KEY_CATEGORIES);
     $data['errors'] = array();
     if (!function_exists('curl_exec')) {
         $data['errors'][] = 'Bizyhood requires the PHP cURL module to be enabled. You may need to ask your web host or developer to enable this.';
     }
     if (get_page_by_path('businesses')) {
         $data['errors'][] = 'You have a page named "businesses", which will interfere with the business directory if you plan to use it. You must delete that page.';
     }
     if (get_category_by_slug('businesses')) {
         $data['errors'][] = 'You have a category named "businesses", which will interfere with the business directory if you plan to use it. You must delete that category.';
     }
     Bizyhood_View::load('admin/admin', $data);
 }