本文整理汇总了PHP中Profiler::unmark方法的典型用法代码示例。如果您正苦于以下问题:PHP Profiler::unmark方法的具体用法?PHP Profiler::unmark怎么用?PHP Profiler::unmark使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Profiler
的用法示例。
在下文中一共展示了Profiler::unmark方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct()
{
if (isset($_GET['debug_profile'])) {
Profiler::mark("Director", "construct");
}
Session::addToArray('history', substr($_SERVER['REQUEST_URI'], strlen(Director::baseURL())));
if (isset($_GET['debug_profile'])) {
Profiler::unmark("Director", "construct");
}
}
示例2: FieldHolder
function FieldHolder()
{
$fieldName = $this->name . 'ID';
$relationName = $this->name;
Profiler::mark("RelatedDataEditor.FieldHolder", "get data");
$record = $this->form->getRecord();
$relatedObject = $record->{$relationName}();
Profiler::unmark("RelatedDataEditor.FieldHolder", "get data");
$this->dropdownField->Name = $this->name . '[ID]';
$this->dropdownField->Value = $record->{$fieldName};
$extraclass = $this->IsNested() ? "nested" : "";
$result .= "<div id=\"{$this->name}\" class=\"{$this->class} groupfield {$extraclass}\" >";
$fieldholder = $this->dropdownField->FieldHolder();
if ($this->showkeydropdown) {
$result .= "<div id=\"{$this->name}_keyholder\" class=\"keyholder\">{$fieldholder}</div>";
if ($this->children) {
$result .= "<img id=\"{$this->name}_loading\" src=\"cms/images/network-save.gif\" style=\"display: none;\" />";
$result .= "<img id=\"{$this->name}_loaded\" src=\"cms/images/alert-good.gif\" style=\"display: none;\" />";
}
} else {
$result .= "<div id=\"{$this->name}_keyholder\" class=\"keyholder\" style=\"display: none\">{$fieldholder}</div>";
}
if ($this->children) {
$result .= "<div id= \"{$this->name}_childrenholder\" class=\"children_holder\">";
foreach ($this->children as $child) {
if (!$child->isComposite()) {
$childFieldName = $child->Name();
$child->Name = $this->name . '[' . $child->Name() . ']';
if ($this->dropdownField->isSelected()) {
$child->Value = $relatedObject->{$childFieldName};
}
$child->setForm($this->form);
$result .= $child->FieldHolder();
} else {
$fs = $child->FieldSet();
foreach ($fs as $subfield) {
$childFieldName = $subfield->Name();
$subfield->Name = $this->name . '[' . $subfield->Name() . ']';
if ($this->dropdownField->isSelected()) {
$subfield->Value = $relatedObject->{$childFieldName};
}
$subfield->setForm($this->form);
}
$result .= $child->FieldHolder();
}
}
$result .= "<div class=\"clear\"> </div>";
$result .= "</div>";
}
$result .= "</div>";
return $result;
}
示例3: runUpdate
/**
* updates database fields
* @param Bool $force - run it, even if it has run already
* @return void
*/
public function runUpdate($force = true)
{
if (isset($_GET['debug_profile'])) {
Profiler::mark('OrderMaker::runUpdate');
}
if (!$this->IsRemoved()) {
$this->checkField("OrderFor");
parent::runUpdate($force);
}
if (isset($_GET['debug_profile'])) {
Profiler::unmark('OrderMaker::runUpdate');
}
}
示例4: runUpdate
/**
* For all modifers with their own database fields, we need to include this...
* It will update each of the fields.
* Within this method, we need to create the methods
* Live{functionName}
* e.g LiveMyField() and LiveMyReduction() in this case...
* The OrderModifier already updates the basic database fields.
* @param Bool $force - run it, even if it has run already
*/
public function runUpdate($force = false)
{
if (isset($_GET['debug_profile'])) {
Profiler::mark('ModifierExample::runUpdate');
}
if (!$this->IsRemoved()) {
$this->checkField("MyField");
$this->checkField("MyReduction");
}
if (isset($_GET['debug_profile'])) {
Profiler::unmark('ModifierExample::runUpdate');
}
parent::runUpdate($force);
}
示例5: includeInHTML
/**
* Update the given HTML content with the appropriate include tags for the registered
* requirements. Needs to receive a valid HTML/XHTML template in the $content parameter,
* including a <head> tag. The requirements will insert before the closing <head> tag automatically.
*
* @todo Calculate $prefix properly
*
* @param string $templateFilePath Absolute path for the *.ss template file
* @param string $content HTML content that has already been parsed from the $templateFilePath through {@link SSViewer}.
* @return string HTML content thats augumented with the requirements before the closing <head> tag.
*/
function includeInHTML($templateFile, $content)
{
if (isset($_GET['debug_profile'])) {
Profiler::mark("Requirements::includeInHTML");
}
if (strpos($content, '</head') !== false && ($this->css || $this->javascript || $this->customCSS || $this->customScript || $this->customHeadTags)) {
$requirements = '';
$jsRequirements = '';
// Combine files - updates $this->javascript and $this->css
$this->process_combined_files();
foreach (array_diff_key($this->javascript, $this->blocked) as $file => $dummy) {
$path = $this->path_for_file($file);
if ($path) {
$jsRequirements .= "<script type=\"text/javascript\" src=\"{$path}\"></script>\n";
}
}
// add all inline javascript *after* including external files which
// they might rely on
if ($this->customScript) {
foreach (array_diff_key($this->customScript, $this->blocked) as $script) {
$jsRequirements .= "<script type=\"text/javascript\">\n//<![CDATA[\n";
$jsRequirements .= "{$script}\n";
$jsRequirements .= "\n//]]>\n</script>\n";
}
}
foreach (array_diff_key($this->css, $this->blocked) as $file => $params) {
$path = $this->path_for_file($file);
if ($path) {
$media = isset($params['media']) && !empty($params['media']) ? " media=\"{$params['media']}\"" : "";
$requirements .= "<link rel=\"stylesheet\" type=\"text/css\"{$media} href=\"{$path}\" />\n";
}
}
foreach (array_diff_key($this->customCSS, $this->blocked) as $css) {
$requirements .= "<style type=\"text/css\">\n{$css}\n</style>\n";
}
foreach (array_diff_key($this->customHeadTags, $this->blocked) as $customHeadTag) {
$requirements .= "{$customHeadTag}\n";
}
if ($this->write_js_to_body) {
// Remove all newlines from code to preserve layout
$jsRequirements = preg_replace('/>\\n*/', '>', $jsRequirements);
// We put script tags into the body, for performance.
// If your template already has script tags in the body, then we put our script
// tags just before those. Otherwise, we put it at the bottom.
$p1 = strripos($content, '<script');
$p2 = stripos($content, '<body');
if ($p1 !== false && $p1 > $p2) {
$content = substr($content, 0, $p1) . $jsRequirements . substr($content, $p1);
} else {
$content = preg_replace("/(<\\/body[^>]*>)/i", $jsRequirements . "\\1", $content);
}
// Put CSS at the bottom of the head
$content = preg_replace("/(<\\/head>)/i", $requirements . "\\1", $content);
} else {
$content = preg_replace("/(<\\/head>)/i", $requirements . "\\1", $content);
$content = preg_replace("/(<\\/head>)/i", $jsRequirements . "\\1", $content);
}
}
if (isset($_GET['debug_profile'])) {
Profiler::unmark("Requirements::includeInHTML");
}
return $content;
}
示例6: process
/**
* The process() method handles the "meat" of the template processing.
* It takes care of caching the output (via {@link SS_Cache}),
* as well as replacing the special "$Content" and "$Layout"
* placeholders with their respective subtemplates.
* The method injects extra HTML in the header via {@link Requirements::includeInHTML()}.
*
* Note: You can call this method indirectly by {@link ViewableData->renderWith()}.
*
* @param ViewableData $item
* @param SS_Cache $cache Optional cache backend
* @return String Parsed template output.
*/
public function process($item, $cache = null)
{
SSViewer::$topLevel[] = $item;
if (!$cache) {
$cache = SS_Cache::factory('cacheblock');
}
if (isset($this->chosenTemplates['main'])) {
$template = $this->chosenTemplates['main'];
} else {
$template = $this->chosenTemplates[reset($dummy = array_keys($this->chosenTemplates))];
}
if (isset($_GET['debug_profile'])) {
Profiler::mark("SSViewer::process", " for {$template}");
}
$cacheFile = TEMP_FOLDER . "/.cache" . str_replace(array('\\', '/', ':'), '.', realpath($template));
$lastEdited = filemtime($template);
if (!file_exists($cacheFile) || filemtime($cacheFile) < $lastEdited || isset($_GET['flush'])) {
if (isset($_GET['debug_profile'])) {
Profiler::mark("SSViewer::process - compile", " for {$template}");
}
$content = file_get_contents($template);
$content = SSViewer::parseTemplateContent($content, $template);
$fh = fopen($cacheFile, 'w');
fwrite($fh, $content);
fclose($fh);
if (isset($_GET['debug_profile'])) {
Profiler::unmark("SSViewer::process - compile", " for {$template}");
}
}
if (isset($_GET['showtemplate']) && !Director::isLive()) {
$lines = file($cacheFile);
echo "<h2>Template: {$cacheFile}</h2>";
echo "<pre>";
foreach ($lines as $num => $line) {
echo str_pad($num + 1, 5) . htmlentities($line);
}
echo "</pre>";
}
// Makes the rendered sub-templates available on the parent item,
// through $Content and $Layout placeholders.
foreach (array('Content', 'Layout') as $subtemplate) {
if (isset($this->chosenTemplates[$subtemplate])) {
$subtemplateViewer = new SSViewer($this->chosenTemplates[$subtemplate]);
$item = $item->customise(array($subtemplate => $subtemplateViewer->process($item, $cache)));
}
}
$itemStack = array();
$val = "";
$valStack = array();
include $cacheFile;
$output = $val;
$output = Requirements::includeInHTML($template, $output);
array_pop(SSViewer::$topLevel);
if (isset($_GET['debug_profile'])) {
Profiler::unmark("SSViewer::process", " for {$template}");
}
// If we have our crazy base tag, then fix # links referencing the current page.
if ($this->rewriteHashlinks && self::$options['rewriteHashlinks']) {
if (strpos($output, '<base') !== false) {
if (SSViewer::$options['rewriteHashlinks'] === 'php') {
$thisURLRelativeToBase = "<?php echo \$_SERVER['REQUEST_URI']; ?>";
} else {
$thisURLRelativeToBase = Director::makeRelative(Director::absoluteURL($_SERVER['REQUEST_URI']));
}
$output = preg_replace('/(<a[^>]+href *= *)"#/i', '\\1"' . $thisURLRelativeToBase . '#', $output);
}
}
return $output;
}
示例7: index
/**
* Run the controller (default action)
*
* @param array $requestParams Passed request parameters
*/
function index($requestParams)
{
if (isset($_GET['debug_profile'])) {
Profiler::mark("OpenIDAuthenticator_Controller");
}
$consumer = new Auth_OpenID_Consumer(new OpenIDStorage(), new SessionWrapper());
// Complete the authentication process using the server's response.
$response = $consumer->complete();
if ($response->status == Auth_OpenID_CANCEL) {
Session::set("Security.Message.message", _t('OpenIDAuthenticator.VERIFICATIONCANCELLED', 'The verification was cancelled. Please try again.'));
Session::set("Security.Message.type", "bad");
if (isset($_GET['debug_profile'])) {
Profiler::unmark("OpenIDAuthenticator_Controller");
}
Director::redirect("Security/login");
} else {
if ($response->status == Auth_OpenID_FAILURE) {
Session::set("Security.Message.message", _t('OpenIDAuthenticator.AUTHFAILED', 'The OpenID/i-name authentication failed.'));
Session::set("Security.Message.type", "bad");
if (isset($_GET['debug_profile'])) {
Profiler::unmark("OpenIDAuthenticator_Controller");
}
Director::redirect("Security/login");
} else {
if ($response->status == Auth_OpenID_SUCCESS) {
$openid = $response->identity_url;
if ($response->endpoint->canonicalID) {
$openid = $response->endpoint->canonicalID;
}
if (isset($_GET['debug_profile'])) {
Profiler::unmark("OpenIDAuthenticator_Controller");
}
$SQL_identity = Convert::raw2sql($openid);
if ($member = DataObject::get_one("Member", "Member.IdentityURL = '{$SQL_identity}'")) {
$firstname = Convert::raw2xml($member->FirstName);
Session::set("Security.Message.message", sprintf(_t('Member.WELCOMEBACK'), $firstname));
Session::set("Security.Message.type", "good");
$member->LogIn(Session::get('SessionForms.OpenIDLoginForm.Remember'));
Session::clear('SessionForms.OpenIDLoginForm.OpenIDURL');
Session::clear('SessionForms.OpenIDLoginForm.Remember');
if ($backURL = Session::get("BackURL")) {
Session::clear("BackURL");
Director::redirect($backURL);
} else {
Director::redirectBack();
}
} else {
Session::set("Security.Message.message", _t('OpenIDAuthenticator.LOGINFAILED', 'Login failed. Please try again.'));
Session::set("Security.Message.type", "bad");
if ($badLoginURL = Session::get("BadLoginURL")) {
Director::redirect($badLoginURL);
} else {
Director::redirectBack();
}
}
}
}
}
}
示例8: isset
}
// Connect to database
require_once "core/model/DB.php";
// Redirect to the installer if no database is selected
if (!isset($databaseConfig) || !isset($databaseConfig['database']) || !$databaseConfig['database']) {
$s = isset($_SERVER['SSL']) || isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 's' : '';
$installURL = "http{$s}://" . $_SERVER['HTTP_HOST'] . BASE_URL . '/install.php';
// The above dirname() will equate to "\" on Windows when installing directly from http://localhost (not using
// a sub-directory), this really messes things up in some browsers. Let's get rid of the backslashes
$installURL = str_replace('\\', '', $installURL);
header("Location: {$installURL}");
die;
}
if (isset($_GET['debug_profile'])) {
Profiler::mark('DB::connect');
}
DB::connect($databaseConfig);
if (isset($_GET['debug_profile'])) {
Profiler::unmark('DB::connect');
}
if (isset($_GET['debug_profile'])) {
Profiler::unmark('main.php init');
}
// Direct away - this is the "main" function, that hands control to the appropriate controller
Director::direct($url);
if (isset($_GET['debug_profile'])) {
Profiler::unmark('all_execution');
if (!Director::isLive()) {
Profiler::show(isset($_GET['profile_trace']));
}
}
示例9: includeInHTML
/**
* Update the given HTML content with the appropriate include tags for the registered
* requirements.
* @todo Calculate $prefix properly
*/
static function includeInHTML($templateFile, $content)
{
if (isset($_GET['debug_profile'])) {
Profiler::mark("Requirements::includeInHTML");
}
if (strpos($content, '</head') !== false && (Requirements::$javascript || Requirements::$css || Requirements::$customScript || Requirements::$customHeadTags)) {
$prefix = "";
$requirements = '';
foreach (array_diff_key(self::$javascript, self::$blocked) as $file => $dummy) {
if (substr($file, 0, 7) == 'http://' || Director::fileExists($file)) {
$requirements .= "<script type=\"text/javascript\" src=\"{$prefix}{$file}\"></script>\n";
}
}
if (self::$customScript) {
$requirements .= "<script type=\"text/javascript\">\n//<![CDATA[\n";
foreach (array_diff_key(self::$customScript, self::$blocked) as $script) {
$requirements .= "{$script}\n";
}
$requirements .= "\n//]]>\n</script>\n";
}
foreach (array_diff_key(self::$css, self::$blocked) as $file => $params) {
if (Director::fileExists($file)) {
$media = isset($params['media']) ? " media=\"{$params['media']}\"" : "";
$requirements .= "<link rel=\"stylesheet\" type=\"text/css\"{$media} href=\"{$prefix}{$file}\" />\n";
}
}
foreach (array_diff_key(self::$customCSS, self::$blocked) as $css) {
$requirements .= "<style type=\"text/css\">\n{$css}\n</style>\n";
}
$requirements .= self::$customHeadTags;
if (isset($_GET['debug_profile'])) {
Profiler::unmark("Requirements::includeInHTML");
}
return eregi_replace("(</head[^>]*>)", $requirements . "\\1", $content);
} else {
if (isset($_GET['debug_profile'])) {
Profiler::unmark("Requirements::includeInHTML");
}
return $content;
}
}
示例10: requireField
/**
* Generate the given field on the table, modifying whatever already exists as necessary.
* @param string $table The table name.
* @param string $field The field name.
* @param string $spec The field specification.
*/
function requireField($table, $field, $spec)
{
$newTable = false;
Profiler::mark('requireField');
// Collations didn't come in until MySQL 4.1. Anything earlier will throw a syntax error if you try and use
// collations.
if (!$this->supportsCollations()) {
$spec = eregi_replace(' *character set [^ ]+( collate [^ ]+)?( |$)', '\\2', $spec);
}
if (!isset($this->tableList[strtolower($table)])) {
$newTable = true;
}
if (!$newTable && !isset($this->fieldList[$table])) {
$this->fieldList[$table] = $this->fieldList($table);
}
if ($newTable || !isset($this->fieldList[$table][$field])) {
Profiler::mark('createField');
$this->transCreateField($table, $field, $spec);
Profiler::unmark('createField');
Database::alteration_message("Field {$table}.{$field}: created as {$spec}", "created");
} else {
if ($this->fieldList[$table][$field] != $spec) {
// If enums are being modified, then we need to fix existing data in the table.
// Update any records where the enum is set to a legacy value to be set to the default.
// One hard-coded exception is SiteTree - the default for this is Page.
if (substr($spec, 0, 4) == "enum") {
$new = substr($spec, 5);
$old = substr($this->fieldList[$table][$field], 5);
$new = substr($new, 0, strpos($new, ')'));
$old = substr($old, 0, strpos($old, ')'));
$new = str_replace("'", '', $new);
$old = str_replace("'", '', $old);
$new = explode(',', $new);
$old = explode(',', $old);
$holder = array();
foreach ($old as $check) {
if (!in_array($check, $new)) {
$holder[] = $check;
}
}
if (count($holder)) {
$default = explode('default ', $spec);
$default = $default[1];
if ($default == "'SiteTree'") {
$default = "'Page'";
}
$query = "UPDATE `{$table}` SET {$field}={$default} WHERE {$field} IN (";
for ($i = 0; $i + 1 < count($holder); $i++) {
$query .= "'{$holder[$i]}', ";
}
$query .= "'{$holder[$i]}')";
DB::query($query);
$amount = DB::affectedRows();
Database::alteration_message("Changed {$amount} rows to default value of field {$field} (Value: {$default})");
}
}
Profiler::mark('alterField');
$this->transAlterField($table, $field, $spec);
Profiler::unmark('alterField');
Database::alteration_message("Field {$table}.{$field}: changed to {$spec} <i style=\"color: #AAA\">(from {$this->fieldList[$table][$field]})</i>", "changed");
}
}
Profiler::unmark('requireField');
}
示例11: process
/**
* The process() method handles the "meat" of the template processing.
* It takes care of caching the output (via {@link SS_Cache}),
* as well as replacing the special "$Content" and "$Layout"
* placeholders with their respective subtemplates.
* The method injects extra HTML in the header via {@link Requirements::includeInHTML()}.
*
* Note: You can call this method indirectly by {@link ViewableData->renderWith()}.
*
* @param ViewableData $item
* @param SS_Cache $cache Optional cache backend
* @return String Parsed template output.
*/
public function process($item, $arguments = null)
{
SSViewer::$topLevel[] = $item;
if ($arguments && $arguments instanceof Zend_Cache_Core) {
Deprecation::notice('3.0', 'Use setPartialCacheStore to override the partial cache storage backend, the second argument to process is now an array of variables.');
$this->setPartialCacheStore($arguments);
$arguments = null;
}
if (isset($this->chosenTemplates['main'])) {
$template = $this->chosenTemplates['main'];
} else {
$keys = array_keys($this->chosenTemplates);
$key = reset($keys);
$template = $this->chosenTemplates[$key];
}
if (isset($_GET['debug_profile'])) {
Profiler::mark("SSViewer::process", " for {$template}");
}
$cacheFile = TEMP_FOLDER . "/.cache" . str_replace(array('\\', '/', ':'), '.', Director::makeRelative(realpath($template)));
$lastEdited = filemtime($template);
if (!file_exists($cacheFile) || filemtime($cacheFile) < $lastEdited || isset($_GET['flush'])) {
if (isset($_GET['debug_profile'])) {
Profiler::mark("SSViewer::process - compile", " for {$template}");
}
$content = file_get_contents($template);
$content = SSViewer::parseTemplateContent($content, $template);
$fh = fopen($cacheFile, 'w');
fwrite($fh, $content);
fclose($fh);
if (isset($_GET['debug_profile'])) {
Profiler::unmark("SSViewer::process - compile", " for {$template}");
}
}
$underlay = array('I18NNamespace' => basename($template));
// Makes the rendered sub-templates available on the parent item,
// through $Content and $Layout placeholders.
foreach (array('Content', 'Layout') as $subtemplate) {
if (isset($this->chosenTemplates[$subtemplate])) {
$subtemplateViewer = new SSViewer($this->chosenTemplates[$subtemplate]);
$subtemplateViewer->setPartialCacheStore($this->getPartialCacheStore());
$underlay[$subtemplate] = $subtemplateViewer->process($item, $arguments);
}
}
$val = $this->includeGeneratedTemplate($cacheFile, $item, $arguments, $underlay);
$output = Requirements::includeInHTML($template, $val);
array_pop(SSViewer::$topLevel);
if (isset($_GET['debug_profile'])) {
Profiler::unmark("SSViewer::process", " for {$template}");
}
// If we have our crazy base tag, then fix # links referencing the current page.
if ($this->rewriteHashlinks && self::$options['rewriteHashlinks']) {
if (strpos($output, '<base') !== false) {
if (SSViewer::$options['rewriteHashlinks'] === 'php') {
$thisURLRelativeToBase = "<?php echo strip_tags(\$_SERVER['REQUEST_URI']); ?>";
} else {
$thisURLRelativeToBase = strip_tags($_SERVER['REQUEST_URI']);
}
$output = preg_replace('/(<a[^>]+href *= *)"#/i', '\\1"' . $thisURLRelativeToBase . '#', $output);
}
}
return $output;
}
示例12: getEditForm
/**
* Determines fields and actions for the given {$data_type}, and populates
* these fields with values from {$data_type} and any connected {$data_type_extra}.
* Adds default actions ("save" and "delete") if no custom actions are found.
* Returns an empty form if no fields or actions are found (on first load).
*
* @param $id Number
* @return Form
*/
function getEditForm($id)
{
if (isset($_GET['debug_profile'])) {
Profiler::mark('getEditForm');
}
$genericData = DataObject::get_by_id($this->stat('data_type'), $id);
$fields = method_exists($genericData, 'getCMSFields') ? $genericData->getCMSFields() : new FieldSet();
if (!$fields->dataFieldByName('ID')) {
$fields->push($idField = new HiddenField("ID", "ID", $id));
$idField->setValue($id);
}
if (method_exists($genericData, 'getGenericStatus')) {
$genericDataStatus = $genericData->getGenericStatus();
if ($genericDataStatus) {
$fields->push($dataStatusField = new ReadonlyField("GenericDataStatus", "", $genericDataStatus));
$dataStatusField->dontEscape = true;
}
}
$actions = method_exists($genericData, 'getCMSActions') ? $genericData->getCMSActions() : new FieldSet();
if (!$actions->fieldByName('action_save')) {
$actions->push(new FormAction('save', _t('GenericDataAdmin.SAVE', 'Save'), 'ajaxAction-save'));
}
if (!$actions->fieldByName('action_delete')) {
$actions->push(new FormAction('delete', _t('GenericDataAdmin.DELETE', 'Delete'), 'ajaxAction-delete'));
}
$required = method_exists($genericData, 'getCMSRequiredField') ? $genericData->getCMSRequiredField() : new RequiredFields();
$form = new Form($this, "EditForm", $fields, $actions, $required);
if ($this->stat('data_type_extra')) {
foreach ($this->stat('data_type_extra') as $oneRelated) {
$oneExtra = $genericData->{$oneRelated}();
if ($oneExtra) {
$allFields = $oneExtra->getAllFields();
foreach ($allFields as $k => $v) {
$fieldname = $oneRelated . "[" . $k . "]";
$allFields[$fieldname] = $v;
unset($allFields[$k]);
}
$form->loadDataFrom($allFields);
}
}
}
$form->loadDataFrom($genericData);
$form->disableDefaultAction();
if (isset($_GET['debug_profile'])) {
Profiler::unmark('getEditForm');
}
return $form;
}
示例13: getControllerForURL
static function getControllerForURL($url)
{
if (isset($_GET['debug_profile'])) {
Profiler::mark("Director", "getControllerForURL");
}
$url = preg_replace(array('/\\/+/', '/^\\//', '/\\/$/'), array('/', '', ''), $url);
$urlParts = split('/+', $url);
krsort(Director::$rules);
if (isset($_REQUEST['debug'])) {
Debug::show(Director::$rules);
}
foreach (Director::$rules as $priority => $rules) {
foreach ($rules as $pattern => $controller) {
$patternParts = explode('/', $pattern);
$matched = true;
$arguments = array();
foreach ($patternParts as $i => $part) {
$part = trim($part);
if (isset($part[0]) && $part[0] == '$') {
$arguments[substr($part, 1)] = isset($urlParts[$i]) ? $urlParts[$i] : null;
if ($part == '$Controller' && !class_exists($arguments['Controller'])) {
$matched = false;
break;
}
} else {
if (!isset($urlParts[$i]) || $urlParts[$i] != $part) {
$matched = false;
break;
}
}
}
if ($matched) {
if (substr($controller, 0, 2) == '->') {
if ($_REQUEST['debug'] == 1) {
Debug::message("Redirecting to {$controller}");
}
if (isset($_GET['debug_profile'])) {
Profiler::unmark("Director", "getControllerForURL");
}
return "redirect:" . Director::absoluteURL(substr($controller, 2), true);
} else {
if (isset($arguments['Controller']) && $controller == "*") {
$controller = $arguments['Controller'];
}
if (isset($_REQUEST['debug'])) {
Debug::message("Using controller {$controller}");
}
if (isset($arguments['Action'])) {
$arguments['Action'] = str_replace('-', '', $arguments['Action']);
}
if (isset($arguments['Action']) && ClassInfo::exists($controller . '_' . $arguments['Action'])) {
$controller = $controller . '_' . $arguments['Action'];
}
Director::$urlParams = $arguments;
$controllerObj = new $controller();
$controllerObj->setURLParams($arguments);
if (isset($arguments['URLSegment'])) {
self::$urlSegment = $arguments['URLSegment'] . "/";
}
if (isset($_GET['debug_profile'])) {
Profiler::unmark("Director", "getControllerForURL");
}
return $controllerObj;
}
}
}
}
}
示例14: runUpdate
/**
* updates database fields
* @param Bool $force - run it, even if it has run already
* @return void
*/
public function runUpdate($force = true)
{
if (isset($_GET['debug_profile'])) {
Profiler::mark('AUPostDeliverModifier::runUpdate');
}
//ORDER IS CRUCIAL HERE...
$this->checkField("PostalCode");
$this->checkField("IsPickUp");
$this->checkField("TotalWeight");
$this->checkField("Country");
$this->checkField("ServiceType");
$this->LiveCalculatedTotal();
$this->checkField("TableSubTitle");
//this must be last!
if (isset($_GET['debug_profile'])) {
Profiler::unmark('AUPostDeliverModifier::runUpdate');
}
parent::runUpdate($force);
}
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce-au-connectivity,代码行数:24,代码来源:AUPostDeliverModifier.php
示例15: stageChildren
/**
* Overridden to load all children from Matrix. For now we're ignoring
* the $showAll param - we have a separate 'dependentChildren' method
* to specifically handle dependent and non-dependent children
*
* @param boolean $showAll
* @return ArrayList
*/
public function stageChildren($showAll = false)
{
if (!$this->ID) {
return MatrixContentSource::get();
}
if (!$this->objChildren) {
$this->objChildren = new ArrayList();
// For the first batch, just get all the immediate children of the
// top level
$repo = $this->source->getRemoteRepository();
if ($repo->isConnected()) {
if (isset($_GET['debug_profile'])) {
Profiler::mark("MatrixContentItem", "getChildren");
}
if (!isset($this->remoteProperties['id'])) {
// for some reason the call failed!
return $this->objChildren;
}
$childItems = $repo->getChildren(array('id' => $this->remoteProperties['id'], 'depth' => 1));
if (isset($_GET['debug_profile'])) {
Profiler::unmark("MatrixContentItem", "getChildren");
}
// make sure that there's no errors!!
if (!isset($childItems->error)) {
if (isset($_GET['debug_profile'])) {
Profiler::mark("MatrixContentItem", "loadChildren");
}
// means there weren't any children of this asset
foreach ($childItems as $childId => $properties) {
$item = $this->source->getObject($properties->id);
if (isset($properties->LinkType)) {
$item->ShowInMenus = true;
}
$this->objChildren->push($item);
}
if (isset($_GET['debug_profile'])) {
Profiler::unmark("MatrixContentItem", "loadChildren");
}
}
}
}
return $this->objChildren;
}