本文整理汇总了PHP中SSViewer::set_source_file_comments方法的典型用法代码示例。如果您正苦于以下问题:PHP SSViewer::set_source_file_comments方法的具体用法?PHP SSViewer::set_source_file_comments怎么用?PHP SSViewer::set_source_file_comments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SSViewer
的用法示例。
在下文中一共展示了SSViewer::set_source_file_comments方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: graph
function graph() {
SSViewer::set_source_file_comments(false);
$dotContent = $this->renderWith("ModelViewer_dotsrc");
$CLI_dotContent = escapeshellarg($dotContent);
$output= `echo $CLI_dotContent | neato -Tpng:gd &> /dev/stdout`;
if(substr($output,1,3) == 'PNG') header("Content-type: image/png");
else header("Content-type: text/plain");
echo $output;
}
示例2: jsonPacket
private function jsonPacket($data)
{
$this->response->addHeader('Content-Type', 'application/json');
SSViewer::set_source_file_comments(false);
$json = json_encode($data);
$json = str_replace('\\t', " ", $json);
$json = str_replace('\\r', " ", $json);
$json = str_replace('\\n', " ", $json);
$json = preg_replace('/\\s\\s+/', ' ', $json);
return $json;
}
示例3: testRenderWithSourceFileComments
public function testRenderWithSourceFileComments()
{
$origType = Director::get_environment_type();
Director::set_environment_type('dev');
SSViewer::set_source_file_comments(true);
$view = new SSViewer(array('SSViewerTestCommentsFullSource'));
$data = new ArrayData(array());
$result = $view->process($data);
$expected = '<!doctype html>
<html><!-- template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsFullSource.ss -->
<head></head>
<body></body>
<!-- end template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsFullSource.ss --></html>
';
$this->assertEquals($result, $expected);
$view = new SSViewer(array('SSViewerTestCommentsPartialSource'));
$data = new ArrayData(array());
$result = $view->process($data);
$expected = '<!-- template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsPartialSource.ss -->' . '<div class=\'typography\'></div><!-- end template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsPartialSource.ss -->';
$this->assertEquals($result, $expected);
$view = new SSViewer(array('SSViewerTestCommentsWithInclude'));
$data = new ArrayData(array());
$result = $view->process($data);
$expected = '<!-- template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsWithInclude.ss -->' . '<div class=\'typography\'><!-- include \'SSViewerTestCommentsInclude\' --><!-- template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsInclude.ss -->Included<!-- end template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsInclude.ss -->' . '<!-- end include \'SSViewerTestCommentsInclude\' --></div><!-- end template ' . FRAMEWORK_PATH . '/tests/templates/SSViewerTestCommentsWithInclude.ss -->';
$this->assertEquals($result, $expected);
SSViewer::set_source_file_comments(false);
Director::set_environment_type($origType);
}
示例4: EcommerceMenuTitle
/**
*@return String (HTML Snippet)
**/
function EcommerceMenuTitle()
{
$count = 0;
$order = ShoppingCart::current_order();
if ($order) {
$count = $order->TotalItems();
$oldSSViewer = SSViewer::get_source_file_comments();
SSViewer::set_source_file_comments(false);
$this->customise(array("Count" => $count, "OriginalMenuTitle" => $this->MenuTitle));
$s = $this->renderWith("AjaxNumItemsInCart");
SSViewer::set_source_file_comments($oldSSViewer);
return $s;
}
return $this->OriginalMenuTitle();
}
示例5: parseVariables
/**
* Load all the template variables into the internal variables, including
* the template into body. Called before send() or debugSend()
* $isPlain=true will cause the template to be ignored, otherwise the GenericEmail template will be used
* and it won't be plain email :)
*/
protected function parseVariables($isPlain = false)
{
SSViewer::set_source_file_comments(false);
if (!$this->parseVariables_done) {
$this->parseVariables_done = true;
// Parse $ variables in the base parameters
$data = $this->templateData();
// Process a .SS template file
$fullBody = $this->body;
if ($this->ss_template && !$isPlain) {
// Requery data so that updated versions of To, From, Subject, etc are included
$data = $this->templateData();
$template = new SSViewer($this->ss_template);
if ($template->exists()) {
$fullBody = $template->process($data);
}
}
// Rewrite relative URLs
$this->body = HTTP::absoluteURLs($fullBody);
}
}
示例6: setUp
//.........这里部分代码省略.........
if ($this->skipTest) {
$this->markTestSkipped(sprintf('Skipping %s ', get_class($this)));
return;
}
// Mark test as being run
$this->originalIsRunningTest = self::$is_running_test;
self::$is_running_test = true;
// i18n needs to be set to the defaults or tests fail
i18n::set_locale(i18n::default_locale());
i18n::set_date_format(null);
i18n::set_time_format(null);
// Set default timezone consistently to avoid NZ-specific dependencies
date_default_timezone_set('UTC');
// Remove password validation
$this->originalMemberPasswordValidator = Member::password_validator();
$this->originalRequirements = Requirements::backend();
Member::set_password_validator(null);
Cookie::set_report_errors(false);
if (class_exists('RootURLController')) {
RootURLController::reset();
}
if (class_exists('Translatable')) {
Translatable::reset();
}
Versioned::reset();
DataObject::reset();
if (class_exists('SiteTree')) {
SiteTree::reset();
}
Hierarchy::reset();
if (Controller::has_curr()) {
Controller::curr()->setSession(new Session(array()));
}
Security::$database_is_ready = null;
$this->originalTheme = SSViewer::current_theme();
if (class_exists('SiteTree')) {
// Save nested_urls state, so we can restore it later
$this->originalNestedURLsState = SiteTree::nested_urls();
}
$className = get_class($this);
$fixtureFile = eval("return {$className}::\$fixture_file;");
$prefix = defined('SS_DATABASE_PREFIX') ? SS_DATABASE_PREFIX : 'ss_';
// Todo: this could be a special test model
$this->model = DataModel::inst();
// Set up fixture
if ($fixtureFile || $this->usesDatabase || !self::using_temp_db()) {
if (substr(DB::getConn()->currentDatabase(), 0, strlen($prefix) + 5) != strtolower(sprintf('%stmpdb', $prefix))) {
//echo "Re-creating temp database... ";
self::create_temp_db();
//echo "done.\n";
}
singleton('DataObject')->flushCache();
self::empty_temp_db();
foreach ($this->requireDefaultRecordsFrom as $className) {
$instance = singleton($className);
if (method_exists($instance, 'requireDefaultRecords')) {
$instance->requireDefaultRecords();
}
if (method_exists($instance, 'augmentDefaultRecords')) {
$instance->augmentDefaultRecords();
}
}
if ($fixtureFile) {
$pathForClass = $this->getCurrentAbsolutePath();
$fixtureFiles = is_array($fixtureFile) ? $fixtureFile : array($fixtureFile);
$i = 0;
foreach ($fixtureFiles as $fixtureFilePath) {
// Support fixture paths relative to the test class, rather than relative to webroot
// String checking is faster than file_exists() calls.
$isRelativeToFile = strpos('/', $fixtureFilePath) === false || preg_match('/^\\.\\./', $fixtureFilePath);
if ($isRelativeToFile) {
$resolvedPath = realpath($pathForClass . '/' . $fixtureFilePath);
if ($resolvedPath) {
$fixtureFilePath = $resolvedPath;
}
}
$fixture = new YamlFixture($fixtureFilePath);
$fixture->saveIntoDatabase($this->model);
$this->fixtures[] = $fixture;
// backwards compatibility: Load first fixture into $this->fixture
if ($i == 0) {
$this->fixture = $fixture;
}
$i++;
}
}
$this->logInWithPermission("ADMIN");
}
// Set up email
$this->originalMailer = Email::mailer();
$this->mailer = new TestMailer();
Email::set_mailer($this->mailer);
Email::send_all_emails_to(null);
// Preserve memory settings
$this->originalMemoryLimit = ini_get('memory_limit');
// turn off template debugging
SSViewer::set_source_file_comments(false);
// Clear requirements
Requirements::clear();
}
示例7: feedContent
/**
* Return the content of the RSS feed
*/
function feedContent() {
SSViewer::set_source_file_comments(false);
return str_replace(' ', ' ', $this->renderWith('RSSFeed'));
}
示例8: feedContent
/**
* Return the content of the RSS feed.
*
* Also temporarily disabled source file comments, and restores
* to previous state once content has been rendered.
*
* @return string
*/
function feedContent()
{
$prevState = SSViewer::get_source_file_comments();
SSViewer::set_source_file_comments(false);
$content = str_replace(' ', ' ', $this->renderWith($this->getTemplate()));
SSViewer::set_source_file_comments($prevState);
return $content;
}
示例9: init
public function init()
{
SSViewer::set_source_file_comments(false);
parent::init();
}
示例10: define
<?php
define('LITECMS', basename(dirname(__FILE__)));
SSViewer::set_source_file_comments(false);
CMSMenu::remove_menu_item("CommentAdmin");
CMSMenu::remove_menu_item("ReportAdmin");
CMSMenu::remove_menu_item("SecurityAdmin");
CMSMenu::remove_menu_item("Help");
Object::add_extension('SiteConfig', 'LiteCMSBaseConfig');
Object::add_extension('LeftAndMain', 'LiteCMS');
Object::add_extension('SiteConfig', 'LiteCMSMaintenance');
Object::add_extension('Page', 'LiteCMSMaintenanceController_Decorator');
GD::set_default_quality(100);
LeftAndMain::setApplicationName("LiteCMS");
LeftAndMain::require_css('litecms/css/lite.css');
Image::add_extension('LiteCMSImage');
File::add_extension('LiteCMSAttachment');
示例11: ReturnCartData
/**
* Builds json object to be returned via ajax.
*
*@return JSON
**/
public function ReturnCartData($messages = array(), $data = null, $status = "success")
{
//add header
$this->addHeader('Content-Type', 'application/json');
SSViewer::set_source_file_comments(false);
if ($status != "success") {
$messagesImploded = '';
foreach ($messages as $messageArray) {
$messagesImploded .= '<span class="' . $messageArray["Type"] . '">' . $messageArray["Message"] . '</span>';
}
$this->setStatusCode(400, $messagesImploded);
}
//init Order - IMPORTANT
$currentOrder = ShoppingCart::current_order();
$currentOrder->calculateOrderAttributes(true);
//now we have done the calculations you may find that we need to reload...
$ajaxObject = $currentOrder->AJAXDefinitions();
// populate Javascript
$js = array();
//order items
$inCartArray = array();
if ($items = $currentOrder->Items()) {
foreach ($items as $item) {
$item->updateForAjax($js);
$buyable = $item->Buyable(true);
if ($buyable) {
//products in cart
$inCartArray[] = $buyable->AJAXDefinitions()->UniqueIdentifier();
//HACK TO INCLUDE PRODUCT IN PRODUCT VARIATION
if ($buyable instanceof ProductVariation) {
$inCartArray[] = $buyable->Product()->AJAXDefinitions()->UniqueIdentifier();
}
}
}
}
//in cart items
$js[] = array("t" => "replaceclass", "s" => $inCartArray, "p" => ".productActions.inCart", "v" => "inCart", "without" => "notInCart");
if (isset($_REQUEST["loadingindex"])) {
$js[] = array("t" => "loadingindex", "v" => $_REQUEST["loadingindex"]);
}
//order modifiers
if ($modifiers = $currentOrder->Modifiers()) {
foreach ($modifiers as $modifier) {
$modifier->updateForAjax($js);
}
}
//order
$currentOrder->updateForAjax($js);
//messages
if (is_array($messages)) {
$messagesImploded = '';
foreach ($messages as $messageArray) {
$messagesImploded .= '<span class="' . $messageArray["Type"] . '">' . $messageArray["Message"] . '</span>';
}
$js[] = array("t" => "id", "s" => $ajaxObject->TableMessageID(), "p" => "innerHTML", "v" => $messagesImploded, "isOrderMessage" => true);
$js[] = array("t" => "id", "s" => $ajaxObject->TableMessageID(), "p" => "hide", "v" => 0);
} else {
$js[] = array("t" => "id", "s" => $ajaxObject->TableMessageID(), "p" => "hide", "v" => 1);
}
//TO DO: set it up in such a way that ir specifically requests one of these
//tiny cart
$js[] = array("t" => "class", "s" => $ajaxObject->TinyCartClassName(), "p" => "innerHTML", "v" => $currentOrder->renderWith("CartTinyInner"));
//add basic cart
$js[] = array("t" => "id", "s" => $ajaxObject->SmallCartID(), "p" => "innerHTML", "v" => $currentOrder->renderWith("CartShortInner"));
//side bar cart
$js[] = array("t" => "id", "s" => $ajaxObject->SideBarCartID(), "p" => "innerHTML", "v" => $currentOrder->renderWith("Sidebar_Cart_Inner"));
//now can check if it needs to be reloaded
if (self::$force_reload) {
$js = array("reload" => 1);
} else {
$js[] = array("reload" => 0);
}
//merge and return
if (is_array($data)) {
$js = array_merge($js, $data);
}
//TODO: remove doubles!
$json = Convert::array2json($js);
$json = str_replace('\\t', " ", $json);
$json = str_replace('\\r', " ", $json);
$json = str_replace('\\n', " ", $json);
$json = preg_replace('/\\s\\s+/', ' ', $json);
$json = str_replace("{", "\r\n{", $json);
return $json;
}
示例12: outputToBrowser
/**
* Output the feed to the browser
*/
public function outputToBrowser()
{
$prevState = SSViewer::get_source_file_comments();
SSViewer::set_source_file_comments(false);
if (is_int($this->lastModified)) {
HTTP::register_modification_timestamp($this->lastModified);
header('Last-Modified: ' . gmdate("D, d M Y H:i:s", $this->lastModified) . ' GMT');
}
if (!empty($this->etag)) {
HTTP::register_etag($this->etag);
}
if (!headers_sent()) {
HTTP::add_cache_headers();
header("Content-type: text/xml");
}
SSViewer::set_source_file_comments($prevState);
return $this->renderWith($this->getTemplate());
}
示例13: index
function index($url)
{
if (self::$enabled) {
SSViewer::set_source_file_comments(false);
$this->getResponse()->addHeader('Content-Type', 'application/xml; charset="utf-8"');
// But we want to still render.
return array();
} else {
return new SS_HTTPResponse('Not allowed', 405);
}
}
示例14: index
function index($url)
{
if (self::$enabled) {
SSViewer::set_source_file_comments(false);
// We need to override the default content-type
ContentNegotiator::disable();
$this->getResponse()->addHeader('Content-Type', 'application/xml; charset="utf-8"');
// But we want to still render.
return array();
} else {
return new HTTPResponse('Not allowed', 405);
}
}
示例15: ReturnCartData
/**
* Builds json object to be returned via ajax.
* @param Array $message (Type, Message)
* @param Array $additionalData
* @param String $status
* @return HEADER + JSON
**/
public function ReturnCartData(array $messages = array(), array $additionalData = null, $status = "success")
{
//add header
if ($this->includeHeaders) {
$this->addHeader('Content-Type', 'application/json');
}
SSViewer::set_source_file_comments(false);
//merge messages
$messagesImploded = '';
if (is_array($messages) && count($messages)) {
foreach ($messages as $messageArray) {
$messagesImploded .= '<span class="' . $messageArray["Type"] . '">' . $messageArray["Message"] . '</span>';
}
}
//bad status
if ($status != "success") {
$this->setStatusCode(400, $messagesImploded);
}
//init Order - IMPORTANT
$currentOrder = ShoppingCart::current_order();
//THIS LINE TAKES UP MOST OF THE TIME OF THE RESPONSE!!!
$currentOrder->calculateOrderAttributes($force = false);
$ajaxObject = $currentOrder->AJAXDefinitions();
// populate Javascript
$js = array();
//must be first
if (isset($_REQUEST["loadingindex"])) {
$js[] = array("t" => "loadingindex", "v" => $_REQUEST["loadingindex"]);
}
//order items
$inCartArray = array();
$items = $currentOrder->Items();
if ($items->count()) {
foreach ($items as $item) {
$js = $item->updateForAjax($js);
$buyable = $item->Buyable(true);
if ($buyable) {
//products in cart
$inCartArray[] = $buyable->AJAXDefinitions()->UniqueIdentifier();
//HACK TO INCLUDE PRODUCT IN PRODUCT VARIATION
if (is_a($buyable, "ProductVariation")) {
$inCartArray[] = $buyable->Product()->AJAXDefinitions()->UniqueIdentifier();
}
}
}
}
//in cart items
$js[] = array("t" => "replaceclass", "s" => $inCartArray, "p" => $currentOrder->AJAXDefinitions()->ProductListItemClassName(), "v" => $currentOrder->AJAXDefinitions()->ProductListItemInCartClassName(), "without" => $currentOrder->AJAXDefinitions()->ProductListItemNotInCartClassName());
//order modifiers
$modifiers = $currentOrder->Modifiers();
if ($modifiers->count()) {
foreach ($modifiers as $modifier) {
$js = $modifier->updateForAjax($js);
}
}
//order
$js = $currentOrder->updateForAjax($js);
//messages
if (is_array($messages)) {
$js[] = array("t" => "id", "s" => $ajaxObject->TableMessageID(), "p" => "innerHTML", "v" => $messagesImploded, "isOrderMessage" => true);
$js[] = array("t" => "id", "s" => $ajaxObject->TableMessageID(), "p" => "hide", "v" => 0);
} else {
$js[] = array("t" => "id", "s" => $ajaxObject->TableMessageID(), "p" => "hide", "v" => 1);
}
//TO DO: set it up in such a way that it specifically requests one of these
$templates = EcommerceConfig::get("CartResponse", "cart_responses_required");
foreach ($templates as $idMethod => $template) {
$selector = $ajaxObject->{$idMethod}();
$classOrID = "id";
if (strpos($selector, "ID") === null || strpos($selector, "ClassName") !== null) {
$selector = "class";
}
$js[] = array("t" => $classOrID, "s" => $ajaxObject->{$idMethod}(), "p" => "innerHTML", "v" => " " . $currentOrder->renderWith($template));
}
//now can check if it needs to be reloaded
if (self::$force_reload) {
$js = array("reload" => 1);
} else {
$js[] = array("reload" => 0);
}
//merge and return
if (is_array($additionalData) && count($additionalData)) {
$js = array_merge($js, $additionalData);
}
//TODO: remove doubles?
//turn HTMLText (et al.) objects into text
foreach ($js as $key => $node) {
if (isset($node["v"])) {
if ($node["v"] instanceof DBField) {
$js[$key]["v"] = $node["v"]->forTemplate();
}
}
}
//.........这里部分代码省略.........