Exemplo n.º 1
0
	function index() {
		$tasks = $this->getTasks();

		// Web mode
		if(!Director::is_cli()) {
			$renderer = new DebugView();
			$renderer->writeHeader();
			$renderer->writeInfo("Sapphire Development Tools: Tasks", Director::absoluteBaseURL());
			$base = Director::baseURL();
			if(strpos($base,-1) != '/') $base .= '/';
			
			echo "<ul>";
			foreach($tasks as $task) {
				echo "<li>";
				echo "<a href=\"{$base}dev/tasks/" . $task['class'] . "\">" . $task['title'] . "</a><br />";
				echo "<span class=\"description\">" . $task['description'] . "</span>";
				echo "</li>\n";
			}
			echo "</ul>";

			$renderer->writeFooter();
		// CLI mode
		} else {
			echo "SAPPHIRE DEVELOPMENT TOOLS: Tasks\n--------------------------\n\n";
			foreach($tasks as $task) {
				echo " * $task: sake dev/tasks/" . $task['class'] . "\n";
			}
		}
	}
Exemplo n.º 2
0
 public function index()
 {
     $tasks = $this->getTasks();
     // Web mode
     if (!Director::is_cli()) {
         $renderer = new DebugView();
         $renderer->writeHeader();
         $renderer->writeInfo("SilverStripe Development Tools: Tasks", Director::absoluteBaseURL());
         $base = Director::absoluteBaseURL();
         echo "<div class=\"options\">";
         echo "<ul>";
         foreach ($tasks as $task) {
             echo "<li><p>";
             echo "<a href=\"{$base}dev/tasks/" . $task['segment'] . "\">" . $task['title'] . "</a><br />";
             echo "<span class=\"description\">" . $task['description'] . "</span>";
             echo "</p></li>\n";
         }
         echo "</ul></div>";
         $renderer->writeFooter();
         // CLI mode
     } else {
         echo "SILVERSTRIPE DEVELOPMENT TOOLS: Tasks\n--------------------------\n\n";
         foreach ($tasks as $task) {
             echo " * {$task['title']}: sake dev/tasks/" . $task['segment'] . "\n";
         }
     }
 }
Exemplo n.º 3
0
	function build() {
		$renderer = new DebugView();
		$renderer->writeHeader();
		$renderer->writeInfo("Environment Builder (formerly db/build)", Director::absoluteBaseURL());
		echo "<div style=\"margin: 0 2em\">";

		$da = new DatabaseAdmin();
		$da->build();
		
		echo "</div>";
		$renderer->writeFooter();
	}
Exemplo n.º 4
0
 /**
  * Render a user-facing error page, using the default HTML error template
  * rendered by {@link ErrorPage} if it exists. Doesn't use the standard {@link SS_HTTPResponse} class
  * the keep dependencies minimal. 
  * 
  * @uses ErrorPage
  *
  * @param int $statusCode HTTP Status Code (Default: 500)
  * @param string $friendlyErrorMessage User-focused error message. Should not contain code pointers
  *                                     or "tech-speak". Used in the HTTP Header and ajax responses.
  * @param string $friendlyErrorDetail Detailed user-focused message. Is just used if no {@link ErrorPage} is found
  *                                    for this specific status code.
  * @return string HTML error message for non-ajax requests, plaintext for ajax-request.
  */
 public static function friendlyError($statusCode = 500, $friendlyErrorMessage = null, $friendlyErrorDetail = null)
 {
     if (!$friendlyErrorMessage) {
         $friendlyErrorMessage = Config::inst()->get('Debug', 'friendly_error_header');
     }
     if (!$friendlyErrorDetail) {
         $friendlyErrorDetail = Config::inst()->get('Debug', 'friendly_error_detail');
     }
     if (!headers_sent()) {
         $currController = Controller::has_curr() ? Controller::curr() : null;
         // Ensure the error message complies with the HTTP 1.1 spec
         $msg = strip_tags(str_replace(array("\n", "\r"), '', $friendlyErrorMessage));
         if ($currController) {
             $response = $currController->getResponse();
             $response->setStatusCode($statusCode, $msg);
         } else {
             header($_SERVER['SERVER_PROTOCOL'] . " {$statusCode} {$msg}");
         }
     }
     if (Director::is_ajax()) {
         echo $friendlyErrorMessage;
     } else {
         if (class_exists('ErrorPage')) {
             $errorFilePath = ErrorPage::get_filepath_for_errorcode($statusCode, class_exists('Translatable') ? Translatable::get_current_locale() : null);
             if (file_exists($errorFilePath)) {
                 $content = file_get_contents(ASSETS_PATH . "/error-{$statusCode}.html");
                 // $BaseURL is left dynamic in error-###.html, so that multi-domain sites don't get broken
                 echo str_replace('$BaseURL', Director::absoluteBaseURL(), $content);
             }
         } else {
             $renderer = new DebugView();
             $renderer->writeHeader();
             $renderer->writeInfo("Website Error", $friendlyErrorMessage, $friendlyErrorDetail);
             if (Email::config()->admin_email) {
                 $mailto = Email::obfuscate(Email::config()->admin_email);
                 $renderer->writeParagraph('Contact an administrator: ' . $mailto . '');
             }
             $renderer->writeFooter();
         }
     }
     return false;
 }
Exemplo n.º 5
0
 /**
  * Render a user-facing error page, using the default HTML error template
  * rendered by {@link ErrorPage} if it exists. Doesn't use the standard {@link SS_HTTPResponse} class
  * the keep dependencies minimal. 
  * 
  * @uses ErrorPage
  *
  * @param int $statusCode HTTP Status Code (Default: 500)
  * @param string $friendlyErrorMessage User-focused error message. Should not contain code pointers or "tech-speak".
  *    Used in the HTTP Header and ajax responses.
  * @param string $friendlyErrorDetail Detailed user-focused message. Is just used if no {@link ErrorPage} is found
  *    for this specific status code.
  * @return string HTML error message for non-ajax requests, plaintext for ajax-request.
  */
 static function friendlyError($statusCode = 500, $friendlyErrorMessage = null, $friendlyErrorDetail = null)
 {
     if (!$friendlyErrorMessage) {
         $friendlyErrorMessage = self::$friendly_error_header;
     }
     if (!$friendlyErrorDetail) {
         $friendlyErrorDetail = self::$friendly_error_detail;
     }
     if (!headers_sent()) {
         header(sprintf('%s %d %s', $_SERVER['SERVER_PROTOCOL'], $statusCode, strip_tags(str_replace(array("\n", "\r"), '', $friendlyErrorMessage))));
     }
     if (Director::is_ajax()) {
         echo $friendlyErrorMessage;
     } else {
         $errorFilePath = ErrorPage::get_filepath_for_errorcode($statusCode, Translatable::get_current_locale());
         if (file_exists($errorFilePath)) {
             $content = file_get_contents(ASSETS_PATH . "/error-{$statusCode}.html");
             // $BaseURL is left dynamic in error-###.html, so that multi-domain sites don't get broken
             echo str_replace('$BaseURL', Director::absoluteBaseURL(), $content);
         } else {
             $renderer = new DebugView();
             $renderer->writeHeader();
             $renderer->writeInfo("Website Error", $friendlyErrorMessage, $friendlyErrorDetail);
             if (Email::getAdminEmail()) {
                 $mailto = Email::obfuscate(Email::getAdminEmail());
                 $renderer->writeParagraph('Contact an administrator: ' . $mailto . '');
             }
             $renderer->writeFooter();
         }
     }
 }
<?php

/**
 * @package silverstripe-memberprofiles
 */
if (!ClassInfo::exists('Orderable')) {
    $view = new DebugView();
    $link = 'https://github.com/ajshort/silverstripe-orderable';
    if (!headers_sent()) {
        header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error');
    }
    $view->writeHeader();
    $view->writeInfo('Dependency Error', 'The Member Profiles module requires the Orderable module.');
    $view->writeParagraph("Please install the <a href=\"{$link}\">Orderable</a> module.");
    $view->writeFooter();
    exit;
}
Director::addRules(20, array('member-approval' => 'MemberApprovalController'));
Object::add_extension('Member', 'MemberProfileExtension');
Exemplo n.º 7
0
 /**
  * Render a user-facing error page, using the default HTML error template
  * rendered by {@link ErrorPage} if it exists. Doesn't use the standard {@link HTTPResponse} class
  * the keep dependencies minimal. 
  * 
  * @uses ErrorPage
  *
  * @param int $statusCode HTTP Status Code (Default: 500)
  * @param string $friendlyErrorMessage User-focused error message. Should not contain code pointers or "tech-speak".
  *    Used in the HTTP Header and ajax responses.
  * @param string $friendlyErrorDetail Detailed user-focused message. Is just used if no {@link ErrorPage} is found
  *    for this specific status code.
  * @return string HTML error message for non-ajax requests, plaintext for ajax-request.
  */
 static function friendlyError($statusCode = 500, $friendlyErrorMessage = null, $friendlyErrorDetail = null)
 {
     if (!$friendlyErrorMessage) {
         $friendlyErrorMessage = 'There has been an error';
     }
     if (!$friendlyErrorDetail) {
         $friendlyErrorDetail = 'The website server has not been able to respond to your request.';
     }
     if (!headers_sent()) {
         header($_SERVER['SERVER_PROTOCOL'] . " {$statusCode} {$friendlyErrorMessage}");
     }
     if (Director::is_ajax()) {
         echo $friendlyErrorMessage;
     } else {
         $errorFilePath = ErrorPage::get_filepath_for_errorcode($statusCode, Translatable::get_current_locale());
         if (file_exists($errorFilePath)) {
             echo file_get_contents($errorFilePath);
         } else {
             $renderer = new DebugView();
             $renderer->writeHeader();
             $renderer->writeInfo("Website Error", $friendlyErrorMessage, $friendlyErrorDetail);
             if (Email::getAdminEmail()) {
                 $mailto = Email::obfuscate(Email::getAdminEmail());
                 $renderer->writeParagraph('Contact an administrator: ' . $mailto . '');
             }
             $renderer->writeFooter();
         }
     }
 }
Exemplo n.º 8
0
 function reset()
 {
     global $databaseConfig;
     $databaseName = $databaseConfig['database'];
     if (Director::is_cli()) {
         echo "\nPlease run dev/reset from your web browser.\n";
     } else {
         $renderer = new DebugView();
         $renderer->writeHeader();
         $renderer->writeInfo('Database reset', 'Completely truncate and rebuild the current database');
         echo '<div style="margin: 0 2em">';
         if (isset($_GET['done'])) {
             echo "<p style=\"color: green\"><b>{$databaseName}</b> has been completely truncated and rebuilt.</p>";
             echo "<p>Note: If you had <i>SS_DEFAULT_ADMIN_USERNAME</i> and <i>SS_DEFAULT_ADMIN_PASSWORD</i>\n\t\t\t\t\t\tdefined in your <b>_ss_environment.php</b> file, a default admin Member record has been created\n\t\t\t\t\t\twith those credentials.</p>";
         } else {
             echo $this->ResetForm()->renderWith('Form');
         }
         echo '</div>';
         $renderer->writeFooter();
     }
 }
Exemplo n.º 9
0
	/**
	 * Render a user-facing error page, using the default HTML error template
	 * rendered by {@link ErrorPage} if it exists. Doesn't use the standard {@link HTTPResponse} class
	 * the keep dependencies minimal. 
	 * 
	 * @uses ErrorPage
	 *
	 * @param int $statusCode HTTP Status Code (Default: 500)
	 * @param string $friendlyErrorMessage User-focused error message. Should not contain code pointers or "tech-speak".
	 *    Used in the HTTP Header and ajax responses.
	 * @param string $friendlyErrorDetail Detailed user-focused message. Is just used if no {@link ErrorPage} is found
	 *    for this specific status code.
	 * @return string HTML error message for non-ajax requests, plaintext for ajax-request.
	 */
	static function friendlyError($statusCode = 500, $friendlyErrorMessage = null, $friendlyErrorDetail = null) {
		if(!$friendlyErrorMessage) $friendlyErrorMessage = 'There has been an error';
		if(!$friendlyErrorDetail) $friendlyErrorDetail = 'The website server has not been able to respond to your request.';

		if(!headers_sent()) header($_SERVER['SERVER_PROTOCOL'] . " $statusCode $friendlyErrorMessage");

		if(Director::is_ajax()) {
			echo $friendlyErrorMessage;
		} else {
			if(file_exists(ASSETS_PATH . "/error-$statusCode.html")) {
				echo file_get_contents(ASSETS_PATH . "/error-$statusCode.html");
			} else {
				$renderer = new DebugView();
				$renderer->writeHeader();
				$renderer->writeInfo("Website Error", $friendlyErrorMessage, $friendlyErrorDetail);
				
				if(Email::getAdminEmail()) {
					$mailto = Email::obfuscate(Email::getAdminEmail());
					$renderer->writeParagraph('Contact an administrator: ' . $mailto . '');
				}

				$renderer->writeFooter();
			}
		}
	}
Exemplo n.º 10
0
 /**
  * Render a user-facing error page, using the default HTML error template
  * rendered by {@link ErrorPage} if it exists. Doesn't use the standard {@link SS_HTTPResponse} class
  * the keep dependencies minimal.
  *
  * @uses ErrorPage
  *
  * @param int $statusCode HTTP Status Code (Default: 500)
  * @param string $friendlyErrorMessage User-focused error message. Should not contain code pointers
  *                                     or "tech-speak". Used in the HTTP Header and ajax responses.
  * @param string $friendlyErrorDetail Detailed user-focused message. Is just used if no {@link ErrorPage} is found
  *                                    for this specific status code.
  * @return string HTML error message for non-ajax requests, plaintext for ajax-request.
  */
 public static function friendlyError($statusCode = 500, $friendlyErrorMessage = null, $friendlyErrorDetail = null)
 {
     // Ensure the error message complies with the HTTP 1.1 spec
     if (!$friendlyErrorMessage) {
         $friendlyErrorMessage = Config::inst()->get('Debug', 'friendly_error_header');
     }
     $friendlyErrorMessage = strip_tags(str_replace(array("\n", "\r"), '', $friendlyErrorMessage));
     if (!$friendlyErrorDetail) {
         $friendlyErrorDetail = Config::inst()->get('Debug', 'friendly_error_detail');
     }
     if (!headers_sent()) {
         // Allow toggle between legacy behaviour and correctly setting HTTP response code
         // In 4.0 this should be fixed to always set this response code.
         if (Config::inst()->get('Debug', 'friendly_error_httpcode') || !Controller::has_curr()) {
             header($_SERVER['SERVER_PROTOCOL'] . " {$statusCode} {$friendlyErrorMessage}");
         }
     }
     if (Director::is_ajax()) {
         echo $friendlyErrorMessage;
     } else {
         if (!headers_sent()) {
             header('Content-Type: text/html');
         }
         if (class_exists('ErrorPage')) {
             $errorFilePath = ErrorPage::get_filepath_for_errorcode($statusCode, class_exists('Translatable') ? Translatable::get_current_locale() : null);
             if (file_exists($errorFilePath)) {
                 $content = file_get_contents($errorFilePath);
                 // $BaseURL is left dynamic in error-###.html, so that multi-domain sites don't get broken
                 echo str_replace('$BaseURL', Director::absoluteBaseURL(), $content);
             }
         } else {
             $renderer = new DebugView();
             $renderer->writeHeader();
             $renderer->writeInfo("Website Error", $friendlyErrorMessage, $friendlyErrorDetail);
             if (Email::config()->admin_email) {
                 $mailto = Email::obfuscate(Email::config()->admin_email);
                 $renderer->writeParagraph('Contact an administrator: ' . $mailto . '');
             }
             $renderer->writeFooter();
         }
     }
     return false;
 }