本文整理汇总了PHP中Director::baseURL方法的典型用法代码示例。如果您正苦于以下问题:PHP Director::baseURL方法的具体用法?PHP Director::baseURL怎么用?PHP Director::baseURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Director
的用法示例。
在下文中一共展示了Director::baseURL方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preRequest
public function preRequest(SS_HTTPRequest $request, Session $session, DataModel $model)
{
// Bootstrap session so that Session::get() accesses the right instance
$dummyController = new Controller();
$dummyController->setSession($session);
$dummyController->setRequest($request);
$dummyController->pushCurrent();
// Block non-authenticated users from setting the stage mode
if (!Versioned::can_choose_site_stage($request)) {
$permissionMessage = sprintf(_t("ContentController.DRAFT_SITE_ACCESS_RESTRICTION", 'You must log in with your CMS password in order to view the draft or archived content. ' . '<a href="%s">Click here to go back to the published site.</a>'), Controller::join_links(Director::baseURL(), $request->getURL(), "?stage=Live"));
// Force output since RequestFilter::preRequest doesn't support response overriding
$response = Security::permissionFailure($dummyController, $permissionMessage);
$session->inst_save();
$dummyController->popCurrent();
// Prevent output in testing
if (class_exists('SapphireTest', false) && SapphireTest::is_running_test()) {
throw new SS_HTTPResponse_Exception($response);
}
$response->output();
die;
}
Versioned::choose_site_stage();
$dummyController->popCurrent();
return true;
}
示例2: run
public function run($request)
{
$strCSVPath = CONTINENTAL_CONTENT_PATH . '/code/ThirdParty/IP2LOCATION-DB.CSV';
if (!file_exists($strCSVPath)) {
echo "<p>I cant find the IP2LOCATION-DB.CSV file to import any data.<br>\n\t\t\t\tPlease download DB3.LITE database from <a href='http://lite.ip2location.com/'>http://lite.ip2location.com/</a>.<br>\n\t\t\t\tNOTE: It's adviced to edit the DB to only include the countries you want to handle, it contains 2 million records!!!<br>\n\t\t\t\tOr make a CSV contain these columns<br>\n\t\t\t\t`IPFrom`,`IPTo`,`Country`,`CountryName`,`Region`,`City`\n\t\t\t\t</p>";
} else {
if (!isset($_REQUEST['confirm'])) {
$strLink = Director::baseURL() . 'dev/tasks/ImportIPToLocationTask?confirm=1';
echo "<p>CAUTION!!!<br>\n\t\t\t\t\tPlease confirm your action<br>\n\t\t\t\t\t<a href='{$strLink}'>I confirm the action</a><br>\n\t\t\t\t\t<a href='{$strLink}&emptydb=1'>I confirm the action, please empty the DB before you import</a>\n\t\t\t\t\t</p>";
} else {
increase_time_limit_to();
if (isset($_REQUEST['emptydb'])) {
DB::query('TRUNCATE `IpToLocation`;');
}
$arrFields = array_keys(Config::inst()->get('IpToLocation', 'db'));
$handle = fopen($strCSVPath, "r");
if ($handle) {
while (($line = fgets($handle)) !== false) {
$line = str_replace('","', '___', $line);
$line = str_replace('"', '', $line);
$arrParts = Convert::raw2sql(explode("___", $line));
unset($arrParts[3]);
DB::query('INSERT INTO `IpToLocation` (`' . implode('`,`', $arrFields) . '`) VALUES (\'' . implode('\',\'', $arrParts) . '\')');
}
fclose($handle);
} else {
echo 'Error opening file';
}
}
}
}
示例3: cleanBackUrl
public static function cleanBackUrl($back_url)
{
if (empty($back_url) || !empty($back_url) && !Director::is_site_url($back_url)) {
$back_url = Director::baseURL();
}
return $back_url;
}
示例4: index
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";
}
}
}
示例5: getContinueLink
public function getContinueLink()
{
if ($maincategory = DataObject::get_one('ProductCategory', "", true, "ParentID ASC, ID ASC")) {
return $maincategory->Link();
}
return Director::baseURL();
}
示例6: index
function index()
{
$actions = array("build" => "Build/rebuild this environment (formerly db/build). Call this whenever you have updated your project sources", "reset" => "Reset this environment - truncate the database and rebuild. This is useful after testing to start with a fresh working copy", "tests" => "See a list of unit tests to run", "tests/all" => "Run all tests", "jstests" => "See a list of JavaScript tests to run", "jstests/all" => "Run all JavaScript tests", "modules/add" => "Add a module, for example, 'sake dev/modules/add ecommerce'", "tasks" => "See a list of build tasks to run", "viewcode" => "Read source code in a literate programming style");
// Web mode
if (!Director::is_cli()) {
// This action is sake-only right now.
unset($actions["modules/add"]);
$renderer = new DebugView();
$renderer->writeHeader();
$renderer->writeInfo("Sapphire Development Tools", Director::absoluteBaseURL());
$base = Director::baseURL();
echo '<div class="options"><ul>';
foreach ($actions as $action => $description) {
echo "<li><a href=\"{$base}dev/{$action}\"><b>/dev/{$action}:</b> {$description}</a></li>\n";
}
$renderer->writeFooter();
// CLI mode
} else {
echo "SAPPHIRE DEVELOPMENT TOOLS\n--------------------------\n\n";
echo "You can execute any of the following commands:\n\n";
foreach ($actions as $action => $description) {
echo " sake dev/{$action}: {$description}\n";
}
echo "\n\n";
}
}
示例7: analyse
/**
* Ajax call from browser
* @param SS_HTTPRequest $request sent by browser
* @return string json response to send to back to the browser
*/
public function analyse(SS_HTTPRequest $request)
{
// Set the tenon options
$tenon_options = $this->buildOptions($request);
// Origin check
if (strpos($request->postVar('tURL'), Director::absoluteURL(Director::baseURL())) === 0) {
// Only proceed if the key is set
if (strlen(trim($tenon_options["key"])) > 28 && ctype_xdigit(trim($tenon_options["key"]))) {
// Store the page and create a hash of its contents
$this->tenon_page = $request->postVar('tURL');
$this->tenon_hash = $this->createHash($request);
$this->log("TenonAjax.requestTenon", "url=" . $this->tenon_url . ", options=" . print_r($tenon_options, true));
// If the page/hash combination has not already been checked, do it now
if (!$this->existingPageHash()) {
if ($this->requestSend($tenon_options) && $this->responseSave() && $this->savePageHash()) {
$out = $this->jsonResponse(true);
$this->log("TenonAjax.analyse", "out={$out}");
return $out;
}
}
}
} else {
$this->log('Invalid request received by ' . Director::absoluteURL(Director::baseURL()) . ' from ' . $request->postVar('tURL'));
}
return $this->jsonResponse(false);
}
示例8: Link
function Link($action = null)
{
if ($this->customLink) {
return Director::baseURL() . 'ObjectSelectorField_Controller/find/?sourceObject=' . $this->sourceObject . '&displayField=' . $this->getDisplayFieldOptions() . '&multi=' . $this->hasMultiSortOptions();
}
return parent::Link($action);
}
示例9: submitPoll
function submitPoll($data, $form)
{
$choiceIDs = is_array($data['PollChoices']) ? $data['PollChoices'] : array($data['PollChoices']);
$choicesIDs = implode(',', $choiceIDs);
$choices = DataObject::get('PollChoice', sprintf('"ID" IN (%s)', $choicesIDs));
if ($choices) {
foreach ($choices as $choice) {
$choice->addVote();
}
$form->poll->markAsVoted();
}
// Redirect back to anchor (partly copied from Director::redirectBack)
if (self::$redirect_to_anchor) {
if ($this->request->requestVar('_REDIRECT_BACK_URL')) {
$url = $this->request->requestVar('_REDIRECT_BACK_URL');
} else {
if ($this->request->getHeader('Referer')) {
$url = $this->request->getHeader('Referer');
} else {
$url = Director::baseURL();
}
}
$url .= '#' . self::$redirect_to_anchor . '-' . $this->poll->ID;
$this->controller->redirect($url);
} else {
$this->controller->redirectBack();
}
}
示例10: index
function index()
{
$actions = array("build" => "Build/rebuild this environment. Call this whenever you have updated your project sources", "buildcache" => "Rebuild the static cache, if you're using StaticPublisher", "tests" => "See a list of unit tests to run", "tests/all" => "Run all tests", "tests/startsession" => "Start a test session in your browser (gives you a temporary database with default content)", "tests/endsession" => "Ends a test session", "jstests" => "See a list of JavaScript tests to run", "jstests/all" => "Run all JavaScript tests", "tasks" => "See a list of build tasks to run");
// Web mode
if (!Director::is_cli()) {
// This action is sake-only right now.
unset($actions["modules/add"]);
$renderer = DebugView::create();
$renderer->writeHeader();
$renderer->writeInfo("SilverStripe Development Tools", Director::absoluteBaseURL());
$base = Director::baseURL();
echo '<div class="options"><ul>';
$evenOdd = "odd";
foreach ($actions as $action => $description) {
echo "<li class=\"{$evenOdd}\"><a href=\"{$base}dev/{$action}\"><b>/dev/{$action}:</b> {$description}</a></li>\n";
$evenOdd = $evenOdd == "odd" ? "even" : "odd";
}
$renderer->writeFooter();
// CLI mode
} else {
echo "SILVERSTRIPE DEVELOPMENT TOOLS\n--------------------------\n\n";
echo "You can execute any of the following commands:\n\n";
foreach ($actions as $action => $description) {
echo " sake dev/{$action}: {$description}\n";
}
echo "\n\n";
}
}
示例11: getSmileyDir
public static function getSmileyDir()
{
$smileyDir = Director::makeRelative(realpath(dirname(__FILE__) . "/../images/smileys/"));
$smileyDir = str_replace("\\", "/", $smileyDir);
$smileyDir = Director::baseURL() . $smileyDir;
return $smileyDir;
}
示例12: index
public function index()
{
// Web mode
if (!Director::is_cli()) {
$renderer = DebugView::create();
$renderer->writeHeader();
$renderer->writeInfo("SilverStripe Development Tools", Director::absoluteBaseURL());
$base = Director::baseURL();
echo '<div class="options"><ul>';
$evenOdd = "odd";
foreach (self::get_links() as $action => $description) {
echo "<li class=\"{$evenOdd}\"><a href=\"{$base}dev/{$action}\"><b>/dev/{$action}:</b>" . " {$description}</a></li>\n";
$evenOdd = $evenOdd == "odd" ? "even" : "odd";
}
$renderer->writeFooter();
// CLI mode
} else {
echo "SILVERSTRIPE DEVELOPMENT TOOLS\n--------------------------\n\n";
echo "You can execute any of the following commands:\n\n";
foreach (self::get_links() as $action => $description) {
echo " sake dev/{$action}: {$description}\n";
}
echo "\n\n";
}
}
示例13: getProfileLink
public function getProfileLink($action = null)
{
if ($directorypage = MembersDirectoryPage::get()->first()) {
return Controller::join_links($directorypage->Link(), "view", $this->owner->ID, $action);
}
return Director::baseURL() . MemberProfilePage_Controller::config()->url_segment;
}
示例14: path_for_file
/**
* Finds the path for specified file.
*
* @param string $fileOrUrl
* @return string|boolean
*/
protected static function path_for_file($fileOrUrl)
{
if (preg_match('{^//|http[s]?}', $fileOrUrl)) {
return $fileOrUrl;
} elseif (Director::fileExists($fileOrUrl)) {
$filePath = preg_replace('/\\?.*/', '', Director::baseFolder() . '/' . $fileOrUrl);
$prefix = Director::baseURL();
$mtimesuffix = "";
$suffix = '';
if (Requirements::get_suffix_requirements()) {
$mtimesuffix = "?m=" . filemtime($filePath);
$suffix = '&';
}
if (strpos($fileOrUrl, '?') !== false) {
if (strlen($suffix) == 0) {
$suffix = '?';
}
$suffix .= substr($fileOrUrl, strpos($fileOrUrl, '?') + 1);
$fileOrUrl = substr($fileOrUrl, 0, strpos($fileOrUrl, '?'));
} else {
$suffix = '';
}
return "{$prefix}{$fileOrUrl}{$mtimesuffix}{$suffix}";
} else {
return false;
}
}
示例15: popup_link
/**
* returns a link for sorting objects. You can use this in the CMS like this....
* <code>
* if(class_exists("DataObjectSorterController")) {
* $fields->addFieldToTab("Root.Position", new LiteralField("AdvertisementsSorter", DataObjectSorterController::popup_link("Advertisement", $filterField = "", $filterValue = "", $linkText = "sort ".Advertisement::$plural_name, $titleField = "FullTitle")));
* }
* else {
* $fields->addFieldToTab("Root.Position", new NumericField($name = "Sort", "Sort index number (the lower the number, the earlier it shows up"));
* }
* </code>
*
* @param String $className - DataObject Class Name you want to sort
* @param String | Int $filterField - Field you want to filter for OR ParentID number (i.e. you are sorting children of Parent with ID = $filterField)
* @param String $filterValue - filter field should be equal to this integer OR string. You can provide a list of IDs like this: 1,2,3,4 where the filterFiel is probably equal to ID or MyRelationID
* @param String $linkText - text to show on the link
* @param String $titleField - field to show in the sort list. This defaults to the DataObject method "getTitle", but you can use "name" or something like that.
* @return String
*/
public static function popup_link($className, $filterField = "", $filterValue = "", $linkText = "sort this list", $titleField = "")
{
Requirements::javascript("dataobjectsorter/javascript/jquery.simplemodal-1.4.4.js");
Requirements::javascript("dataobjectsorter/javascript/dataobjectmodalpopup.js");
Requirements::themedCSS("dataobjectmodalpopup", "dataobjectsorter");
$where = "";
if ($filterField) {
$singletonObj = singleton($className);
if ($singletonObj->hasDatabaseField($filterField)) {
$where = "\"{$filterField}\" = '{$filterValue}'";
}
}
$objects = $className::get();
if ($where) {
$objects = $objects->where($where);
}
$obj = $objects->first();
if ($obj && $obj->canEdit()) {
$link = 'dataobjectsorter/sort/' . $className . "/";
if ($filterField) {
$link .= $filterField . '/';
}
if ($filterValue) {
$link .= $filterValue . '/';
}
if ($titleField) {
$link .= $titleField . '/';
}
$link = Director::baseURL() . $link;
return '
<a href="' . $link . '" class="modalPopUp" data-width="800" data-height="600" data-rel="window.open(\'' . $link . '\', \'sortlistFor' . $className . $filterField . $filterValue . '\',\'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=600,left = 440,top = 200\'); return false;">' . $linkText . '</a>';
}
}