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


PHP BasicAuth::enable方法代码示例

本文整理汇总了PHP中BasicAuth::enable方法的典型用法代码示例。如果您正苦于以下问题:PHP BasicAuth::enable方法的具体用法?PHP BasicAuth::enable怎么用?PHP BasicAuth::enable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BasicAuth的用法示例。


在下文中一共展示了BasicAuth::enable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

    function index($request)
    {
        // For 2.3 and 2.4 compatibility
        $bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`";
        BasicAuth::enable();
        BasicAuth::requireLogin("CMS RSS feed access.  Use your CMS login", "CMS_ACCESS_CMSMain");
        $member = $this->getBasicAuthMember();
        // Due to a bug in 2.3.0 we can't get the information that we need from $request
        $params = Director::urlParams();
        // Default value
        if (!isset($params['Data']) || !$params['Data']) {
            $params['Data'] = 'all';
        }
        switch ($params['Data']) {
            case 'all':
                $changes = $this->changes();
                break;
            case 'page':
                if ((int) $params['PageID']) {
                    $changes = $this->changes("{$bt}SiteTree{$bt}.{$bt}ID{$bt} = " . (int) $params['PageID']);
                } else {
                    return new HTTPResponse("<h1>Bad Page ID</h1><p>Bad page ID when getting RSS feed of changes to a page.</p>", 400);
                }
                break;
            default:
                user_error("CMSChangeTracker Data param value '{$params['Data']}' not implemented; this is probably due to a bad URL rule.", E_USER_ERROR);
        }
        $processedChanges = new DataObjectSet();
        foreach ($changes as $change) {
            if ($change->canEdit($member)) {
                $author = DataObject::get_by_id("Member", $change->AuthorID);
                $verbed = $change->Version == 1 ? "created" : "edited";
                if ($author) {
                    $changeTitle = "'{$change->Title}' {$verbed} by {$author->FirstName} {$author->Surname}";
                    $changeAuthor = "{$author->FirstName} {$author->Surname}";
                    $firstParagraph = "{$author->FirstName} {$author->Surname} (<a href=\"mailto:{$author->Email}\">{$author->Email}</a>) has {$verbed} the '{$change->Title}' page.";
                } else {
                    $changeTitle = "'{$change->Title}' {$verbed}";
                    $changeAuthor = "";
                    $firstParagraph = "The '{$change->Title}' page has been {$verbed}.";
                }
                $actionLinks = "";
                $cmsLink = Director::absoluteURL("admin/show/{$change->ID}");
                $actionLinks .= "<li><a href=\"{$cmsLink}\">Edit in CMS</a></li>\n";
                $page = DataObject::get_by_id('SiteTree', $change->ID);
                if ($page) {
                    $link = $page->AbsoluteLink();
                    $actionLinks .= "<li><a href=\"{$link}\">See the page on site</a></li>\n";
                }
                if ($change->Version > 1) {
                    $prevVersion = $change->Version - 1;
                    $diffLink = Director::absoluteURL("admin/compareversions/{$change->ID}/?From={$prevVersion}&To={$change->Version}");
                    $actionLinks .= "<li><a href=\"{$diffLink}\">See the changes in CMS</a></li>\n";
                }
                $changeDescription = <<<HTML
<p>{$firstParagraph}</p>

<h3>Actions and links</h3>

<ul>
\t{$actionLinks}
</ul>
HTML;
                $processedChange = new CMSChangeTracker_Change(array("ChangeTitle" => $changeTitle, "Author" => $changeAuthor, "Content" => $changeDescription, "Link" => $change->Link() . "version/{$change->Version}"));
                $processedChanges->push($processedChange);
            }
        }
        $feed = new RSSFeed($processedChanges, Director::absoluteURL("admin/"), "SilverStripe Content Changes", "", "ChangeTitle");
        return $feed->outputToBrowser();
    }
开发者ID:helpfulrobot,项目名称:silverstripe-cmsworkflow,代码行数:70,代码来源:CMSChangeTracker.php


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