本文整理汇总了PHP中Director::protocolAndHost方法的典型用法代码示例。如果您正苦于以下问题:PHP Director::protocolAndHost方法的具体用法?PHP Director::protocolAndHost怎么用?PHP Director::protocolAndHost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Director
的用法示例。
在下文中一共展示了Director::protocolAndHost方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: canIncludeInGoogleShoppingFeed
/**
* Can we add this object to a shopping feed?
*
* @return boolean
*/
public function canIncludeInGoogleShoppingFeed()
{
$can = true;
// If object does not link to the current website or absolute
// link not set.
if ($this->owner->hasMethod('AbsoluteLink')) {
$hostHttp = parse_url(Director::protocolAndHost(), PHP_URL_HOST);
$objHttp = parse_url($this->owner->AbsoluteLink(), PHP_URL_HOST);
if ($objHttp != $hostHttp) {
$can = false;
}
} else {
$can = false;
}
// If no price or title.
if (!$this->owner->Title || !$this->owner->Price || !$this->owner->Condition || !$this->owner->Availability || !$this->owner->Brand || !$this->owner->MPN) {
$can = false;
}
// Can any user view this item
if ($can) {
$can = $this->owner->canView();
}
if ($can && $this->owner->RemoveFromShoppingFeed) {
$can = false;
}
$this->owner->invokeWithExtensions('alterCanIncludeInGoogleShoppingFeed', $can);
return $can;
}
示例2: onBeforeInit
public function onBeforeInit()
{
$host = GlobalNavSiteTreeExtension::get_toolbar_hostname();
if ((isset($_REQUEST['regenerate_nav']) || isset($_REQUEST['flush'])) && $host == Director::protocolAndHost() && (Permission::check('ADMIN') || Director::isDev())) {
GlobalNavSiteTreeExtension::create_static_navs();
}
}
示例3: __destruct
/**
* If emailLogFileTo and logFilePathName is set then email the logFilePathName content if not empty
*/
public function __destruct()
{
if ($this->emailLogFileTo && $this->logFilePathName) {
if ($body = file_get_contents($this->logFilePathName)) {
$email = new \Email($this->config()->get('send_emails_from'), $this->emailLogFileTo, 'Debug log from: ' . \Director::protocolAndHost(), $body);
$email->sendPlain();
}
}
}
示例4: CanTrackEvents
public static function CanTrackEvents(Controller $controller)
{
$bIsContentController = is_a($controller, 'ContentController');
if ($bIsContentController && SiteConfig::current_site_config()->GoogleAnalyticsTrackingID) {
$strCurrentDomain = str_replace(Director::protocol(), '', Director::protocolAndHost());
$arrDomains = explode(',', SiteConfig::current_site_config()->GoogleAnalyticsTrackDomain);
return in_array($strCurrentDomain, $arrDomains);
}
}
示例5: close
public function close()
{
$id = $this->getVar($this->attributes['name'] . 'ID');
if (!$id) {
return;
}
$image = DataObject::get_by_id('Image', $id);
if ($image) {
/* image specific attribute handling */
if (!empty($this->attributes['width'])) {
$newimage = $image->setWidth($this->attributes['width']);
if ($newimage) {
$image = $newimage;
}
}
if (!empty($this->attributes['height'])) {
$newimage = $image->setHeight($this->attributes['height']);
if ($newimage) {
$image = $newimage;
}
}
$path = $image->Filename;
$url = $image->getURL();
if (strpos($url, 'http://') !== 0) {
$url = '/' . ltrim($url, '/');
}
/* if(substr($path,0,1) !== '/')
$path = HOME_PATH . '/../userhomes/' . NSite::current_site()->PathName . '/' . $path;
$url = '/' . ltrim(Director::makeRelative(realpath($path)), '/');
}
*/
if (file_exists($path)) {
if (parse_url($url, PHP_URL_HOST) == '') {
// Convert relative url to absolute
$url = Director::protocolAndHost() . '/' . $url;
}
$title = $image->Title ? $image->Title : $image->Filename;
if ($title) {
$title = Convert::raw2att($title);
} else {
if (preg_match("/([^\\/]*)\\.[a-zA-Z0-9]{1,6}\$/", $title, $matches)) {
$title = Convert::raw2att($matches[1]);
}
}
echo "<img src=\"{$url}\" alt=\"{$title}\"";
$copy_attributes = array('style', 'align');
foreach ($copy_attributes as $name) {
if (isset($this->attributes[$name])) {
echo ' ' . $name . '="' . Convert::raw2att($this->attributes[$name]) . '"';
}
}
echo " />";
}
}
}
示例6: send
/**
* @param IFoundationMember $foundation_member
* @param IFoundationMemberRevocationNotification $notification
* @param IFoundationMemberRevocationNotificationRepository $notification_repository
*/
public function send(IFoundationMember $foundation_member, IFoundationMemberRevocationNotification $notification, IFoundationMemberRevocationNotificationRepository $notification_repository)
{
$email = EmailFactory::getInstance()->buildEmail(REVOCATION_NOTIFICATION_EMAIL_FROM, $foundation_member->Email, REVOCATION_NOTIFICATION_EMAIL_SUBJECT);
$email->setTemplate('RevocationNotificationEmail');
do {
$hash = $notification->generateHash();
} while ($notification_repository->existsHash($hash));
$link = sprintf('%s/revocation-notifications/%s/action', Director::protocolAndHost(), $hash);
$email->populateTemplate(array('TakeActionLink' => $link, 'EmailFrom' => REVOCATION_NOTIFICATION_EMAIL_FROM, 'ExpirationDate' => $notification->expirationDate()->format('F j')));
$email->send();
}
示例7: canIncludeInGoogleSiteMap
public function canIncludeInGoogleSiteMap()
{
$can = true;
if ($this->owner->hasMethod('AbsoluteLink')) {
$hostHttp = parse_url(Director::protocolAndHost(), PHP_URL_HOST);
$objHttp = parse_url($this->owner->AbsoluteLink(), PHP_URL_HOST);
if ($objHttp != $hostHttp) {
$can = false;
}
}
return $can;
}
示例8: sendDeleteNotification
public function sendDeleteNotification(IDupeMemberDeleteRequest $request)
{
$dupe = $request->getDupeAccount();
$email_to = $dupe->getEmail();
$email = EmailFactory::getInstance()->buildEmail(DUPE_EMAIL_FROM, $email_to, "You Have Requested to Delete Openstack Duplicated Account");
$template_data = array('FirstName' => $dupe->getFirstName(), 'LastName' => $dupe->getLastName(), 'DupeAccount' => $email_to);
$email->setTemplate('DupeMembers_DeleteAccountEmail');
do {
$token = $request->generateConfirmationHash();
} while ($this->delete_request_repository->existsConfirmationToken($token));
$template_data['ConfirmationLink'] = sprintf('%s/dupes-members/%s/delete', Director::protocolAndHost(), $token);
$email->populateTemplate($template_data);
$email->send();
}
示例9: Breadcrumbs
/**
* Generate breadcrumb links to the URL path being displayed
*
* @return string
*/
public function Breadcrumbs() {
$basePath = str_replace(Director::protocolAndHost(), '', Director::absoluteBaseURL());
$relPath = parse_url(substr($_SERVER['REQUEST_URI'], strlen($basePath), strlen($_SERVER['REQUEST_URI'])), PHP_URL_PATH);
$parts = explode('/', $relPath);
$base = Director::absoluteBaseURL();
$pathPart = "";
$pathLinks = array();
foreach($parts as $part) {
if ($part != '') {
$pathPart .= "$part/";
$pathLinks[] = "<a href=\"$base$pathPart\">$part</a>";
}
}
return implode('→ ', $pathLinks);
}
示例10: _getTablePages
private function _getTablePages()
{
$tablePages = '<table class="widgetify-related">';
$tablePages .= '<tr class="table-header"><td>Page Title</td><td>Page Link</td><td>CMS Link</td></tr>';
$pages = $this->WidgetifyPages();
if ($pages && $pages->count()) {
foreach ($pages as $page) {
$absLink = Controller::join_links(Director::protocolAndHost(), $page->Link());
$absCMSLink = Controller::join_links(Director::protocolAndHost(), '/admin/pages/edit/show/', $page->ID);
$tablePages .= '<tr><td>' . $page->MenuTitle . '</td><td><a href="' . $absLink . '" target="_blank">' . $absLink . '</a></td><td><a href="' . $absCMSLink . '" target="_blank">' . $absCMSLink . '</a></td></tr>';
}
}
$tablePages .= '</table>';
return $tablePages;
}
示例11: fifth
public function fifth()
{
$this->Title = 'The OpenStack Fifth Anniversary';
$this->FBImage = 'http://www.openstack.org/themes/openstack/images/anniversary/5/img/bot-facebook.jpg';
$this->FBImageW = '200';
$this->FBImageH = '284';
$this->FBDesc = 'Happy 5th OpenStack! Come celebrate at one of 40 global events.';
$this->FBUrl = Director::protocolAndHost() . $this->Link('fifth');
$this->CurrentDomain = Director::protocolAndHost();
Requirements::set_write_js_to_body(false);
Requirements::combine_files('5.css', array());
Requirements::css($this->ThemeDir() . '/images/anniversary/5/css/bootstrap.css');
Requirements::css($this->ThemeDir() . '/images/anniversary/5/css/styles.css');
Requirements::combine_files('5.js', array($this->ThemeDir() . '/images/anniversary/5/js/jquery.js', $this->ThemeDir() . '/images/anniversary/5/js/scripts.js', $this->ThemeDir() . '/images/anniversary/5/js/jquery.easing.min.js'));
return $this->getViewer('fifth')->process($this, array('ImgPath' => '/themes/openstack/images/anniversary/5/img', 'BadgeImgUrl' => 'http://841038e5aa7ad2e38487-650bfe6158d7143a3437ef4c83572bc4.r48.cf1.rackcdn.com/5/openstack-5th-anniversary.png', 'SlideDeckUrl' => '//www.dropbox.com/s/8bvbo2dzp9jd61o/OpenStack%205th%20Birthday%20slide%20deck.pptx?dl=0', 'LocalEventUrl' => '//www.openstack.org/blog/2015/06/openstack-turns-5-its-time-to-celebrate-the-community/', 'SummitUrl' => '//www.openstack.org/summit/tokyo-2015/', 'FBSharerUrl' => 'http://www.openstack.org/birthday/fifth', 'FBSharerImg' => 'http://www.openstack.org/themes/openstack/images/anniversary/5/img/bot-facebook.jpg'));
}
示例12: ContactForm
/**
* Post a contact form
*
* @return Form
*/
public function ContactForm()
{
$form = new ContactForm($this, 'ContactForm');
// we do not want to read a new URL when the form has already been submitted
// which in here, it hasn't been.
$url = isset($_SERVER['REQUEST_URI']) ? Director::protocolAndHost() . '' . $_SERVER['REQUEST_URI'] : false;
$form->loadDataFrom(array('ReturnURL' => $url));
$member = Member::currentUser();
if ($member) {
$form->loadDataFrom($member);
}
if ($form->hasExtension('FormSpamProtectionExtension')) {
$form->enableSpamProtection();
}
// hook to allow further extensions to alter the comments form
//$this->extend('alterContactForm', $form);
return $form;
}
示例13: testAlternativeBaseURL
public function testAlternativeBaseURL()
{
// relative base URLs - you should end them in a /
Director::setBaseURL('/relativebase/');
$this->assertEquals('/relativebase/', Director::baseURL());
$this->assertEquals(Director::protocolAndHost() . '/relativebase/', Director::absoluteBaseURL());
$this->assertEquals(Director::protocolAndHost() . '/relativebase/subfolder/test', Director::absoluteURL('subfolder/test'));
// absolute base URLs - you should end them in a /
Director::setBaseURL('http://www.example.org/');
$this->assertEquals('http://www.example.org/', Director::baseURL());
$this->assertEquals('http://www.example.org/', Director::absoluteBaseURL());
$this->assertEquals('http://www.example.org/subfolder/test', Director::absoluteURL('subfolder/test'));
// Setting it to false restores functionality
Director::setBaseURL(false);
$this->assertEquals(BASE_URL . '/', Director::baseURL());
$this->assertEquals(Director::protocolAndHost() . BASE_URL . '/', Director::absoluteBaseURL(BASE_URL));
$this->assertEquals(Director::protocolAndHost() . BASE_URL . '/subfolder/test', Director::absoluteURL('subfolder/test'));
}
示例14: getConfig
public function getConfig($page = null)
{
$themeDir = $this->owner->ThemeDir();
$baseDir = Director::baseURL();
$baseHref = Director::protocolAndHost() . $baseDir;
$editHref = $page ? $baseHref . $page->CMSEditLink() : null;
$pageHierarchy = array();
// if ($page) {
// $pageHierarchy = array($page->ID);
// $parent = $page->Parent();
// while ($parent && $parent->exists()) {
// $pageHierarchy[] = $parent->ID;
// $parent = $parent->Parent();
// }
// }
$jsConfig = array('linkURL' => Controller::join_links(FrontEndEditorToolbar::create()->Link(), "LinkForm"), 'mediaURL' => Controller::join_links(FrontEndEditorToolbar::create()->Link(), "MediaForm"), 'themeDir' => $themeDir, 'baseDir' => $baseDir, 'baseHref' => $baseHref, 'editHref' => $editHref, 'pageHierarchy' => Convert::raw2json(array_reverse($pageHierarchy)));
return $jsConfig;
}
开发者ID:helpfulrobot,项目名称:gdmedia-silverstripe-frontend-admin,代码行数:18,代码来源:FrontendEditingControllerExtension.php
示例15: canIncludeInGoogleSitemap
/**
* @return boolean
*/
public function canIncludeInGoogleSitemap()
{
$can = true;
if ($this->owner->hasMethod('AbsoluteLink')) {
$hostHttp = parse_url(Director::protocolAndHost(), PHP_URL_HOST);
$objHttp = parse_url($this->owner->AbsoluteLink(), PHP_URL_HOST);
if ($objHttp != $hostHttp) {
$can = false;
}
}
if ($can) {
$can = $this->owner->canView();
}
if ($can) {
$can = $this->owner->getGooglePriority();
}
$this->owner->invokeWithExtensions('alterCanIncludeInGoogleSitemap', $can);
return $can;
}