当前位置: 首页>>代码示例>>PHP>>正文


PHP Director::baseURL方法代码示例

本文整理汇总了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;
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:25,代码来源:VersionedRequestFilter.php

示例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';
             }
         }
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripers-continental-content,代码行数:31,代码来源:ImportIPToLocationTask.php

示例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;
 }
开发者ID:Thingee,项目名称:openstack-org,代码行数:7,代码来源:OpenStackIdCommon.php

示例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";
			}
		}
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:29,代码来源:TaskRunner.php

示例5: getContinueLink

 public function getContinueLink()
 {
     if ($maincategory = DataObject::get_one('ProductCategory', "", true, "ParentID ASC, ID ASC")) {
         return $maincategory->Link();
     }
     return Director::baseURL();
 }
开发者ID:8secs,项目名称:cocina,代码行数:7,代码来源:ViewableCart.php

示例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";
     }
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:26,代码来源:DevelopmentAdmin.php

示例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);
 }
开发者ID:helpfulrobot,项目名称:silverstripe-tenon,代码行数:31,代码来源:TenonAjax.php

示例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);
 }
开发者ID:helpfulrobot,项目名称:silverstripers-silverstripe-postmarked,代码行数:7,代码来源:ObjectSelectorField.php

示例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();
     }
 }
开发者ID:helpfulrobot,项目名称:mateusz-silverstripe-polls,代码行数:28,代码来源:PollForm.php

示例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";
     }
 }
开发者ID:prostart,项目名称:cobblestonepath,代码行数:28,代码来源:DevelopmentAdmin.php

示例11: getSmileyDir

 public static function getSmileyDir()
 {
     $smileyDir = Director::makeRelative(realpath(dirname(__FILE__) . "/../images/smileys/"));
     $smileyDir = str_replace("\\", "/", $smileyDir);
     $smileyDir = Director::baseURL() . $smileyDir;
     return $smileyDir;
 }
开发者ID:helpfulrobot,项目名称:cheesesucker-guestbook,代码行数:7,代码来源:Smiley.php

示例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";
     }
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:25,代码来源:DevelopmentAdmin.php

示例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;
 }
开发者ID:nimeso,项目名称:silverstripe-members,代码行数:7,代码来源:MemberProfileExtension.php

示例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;
     }
 }
开发者ID:helpfulrobot,项目名称:lekoala-silverstripe-theme-framework,代码行数:33,代码来源:ThemeHeadRequirements.php

示例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>';
        }
    }
开发者ID:helpfulrobot,项目名称:sunnysideup-dataobjectsorter,代码行数:51,代码来源:DataObjectSorterController.php


注:本文中的Director::baseURL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。