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


PHP PageModel::PageUrl方法代码示例

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


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

示例1: Index

 /**
  * Loads default page view.
  *
  * @param string $PageUrlCode ; Unique page URL stub identifier.
  */
 public function Index($PageUrlCode = '')
 {
     $this->Page = $this->PageModel->GetByUrlCode($PageUrlCode);
     // Require the custom view permission if it exists.
     // Otherwise, the page is public by default.
     $ViewPermissionName = 'BasicPages.' . $PageUrlCode . '.View';
     if (array_key_exists($ViewPermissionName, Gdn::PermissionModel()->PermissionColumns())) {
         $this->Permission($ViewPermissionName);
     }
     // If page doesn't exist.
     if ($this->Page == null) {
         throw new Exception(sprintf(T('%s Not Found'), T('Page')), 404);
         return null;
     }
     $this->SetData('Page', $this->Page, false);
     // Add body CSS class.
     $this->CssClass = 'Page-' . $this->Page->UrlCode;
     if (IsMobile()) {
         $this->CssClass .= ' PageMobile';
     }
     // Set the canonical URL to have the proper page link.
     $this->CanonicalUrl(PageModel::PageUrl($this->Page));
     // Add modules
     $this->AddModule('GuestModule');
     $this->AddModule('SignedInModule');
     // Add CSS files
     $this->AddCssFile('page.css');
     $this->AddModule('NewDiscussionModule');
     $this->AddModule('DiscussionFilterModule');
     $this->AddModule('BookmarkedModule');
     $this->AddModule('DiscussionsModule');
     $this->AddModule('RecentActivityModule');
     // Setup head.
     if (!$this->Data('Title')) {
         $Title = C('Garden.HomepageTitle');
         $DefaultControllerDestination = Gdn::Router()->GetDestination('DefaultController');
         if ($Title != '' && strpos($DefaultControllerDestination, 'page/' . $this->Page->UrlCode) !== false) {
             // If the page is set as DefaultController.
             $this->Title($Title, '');
             // Add description meta tag.
             $this->Description(C('Garden.Description', null));
         } else {
             // If the page is NOT the DefaultController.
             $this->Title($this->Page->Name);
             // Add description meta tag.
             $this->Description(SliceParagraph(Gdn_Format::PlainText($this->Page->Body, $this->Page->Format), 160));
         }
     }
     $this->Render();
 }
开发者ID:oMadMartigaNo,项目名称:readjust-forum,代码行数:55,代码来源:class.pagecontroller.php

示例2: Base_Render_Before

 /**
  * Add pages in the config value array by ID to header site menu.
  */
 public function Base_Render_Before($Sender)
 {
     if (isset($Sender->Menu) && $Sender->MasterView != 'admin') {
         $PageModel = new PageModel();
         $Pages = $PageModel->GetAllSiteMenuLink()->Result();
         foreach ($Pages as $Page) {
             // Check permission.
             $Permission = false;
             if ($Page->ViewPermission == '1') {
                 $Permission = 'BasicPages.' . $Page->UrlCode . '.View';
             }
             // Add link to the menu.
             $Sender->Menu->AddLink('BasicPages-' . $Page->PageID, $Page->Name, PageModel::PageUrl($Page), $Permission, array('class' => 'Page-' . $Page->UrlCode));
         }
     }
 }
开发者ID:oMadMartigaNo,项目名称:readjust-forum,代码行数:19,代码来源:class.hooks.php

示例3: foreach

    foreach ($Pages as $Page) {
        ?>
            <li id="list_<?php 
        echo $Page->PageID;
        ?>
" class="NoNesting">
                <div>
                    <table>
                        <tbody>
                        <tr id="<?php 
        echo 'Page_' . $Page->PageID;
        ?>
">
                            <td><?php 
        echo '<strong>' . $Page->Name . '</strong>';
        $PageUrl = PageModel::PageUrl($Page);
        echo '<br />' . Anchor($PageUrl, $PageUrl);
        ?>
</td>
                            <td class="Buttons"><?php 
        echo Anchor(T('BasicPages.Settings.AllPages.PageEdit', 'Edit'), '/pagessettings/editpage/' . $Page->PageID, array('class' => 'SmallButton Edit'));
        echo ' ';
        echo Anchor(T('BasicPages.Settings.AllPages.PageDelete', 'Delete'), '/pagessettings/deletepage/' . $Page->PageID, array('class' => 'SmallButton Delete Popup'));
        ?>
</td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </li>
        <?php 
开发者ID:oMadMartigaNo,项目名称:readjust-forum,代码行数:31,代码来源:allpages.php

示例4: NewPage


//.........这里部分代码省略.........
         // Validate form values.
         if ($FormValues['Name'] == '') {
             $this->Form->AddError(T('BasicPages.Settings.NewPage.ErrorName', 'Page title is required.'), 'Name');
         }
         if ($FormValues['Body'] == '') {
             $this->Form->AddError(T('BasicPages.Settings.NewPage.ErrorBody', 'Page body is required.'), 'Body');
         }
         // Format Name
         $FormValues['Name'] = Gdn_Format::Text($FormValues['Name']);
         // Validate UrlCode.
         if ($FormValues['UrlCode'] == '') {
             $FormValues['UrlCode'] = $FormValues['Name'];
         }
         // Format the UrlCode.
         $FormValues['UrlCode'] = Gdn_Format::Url($FormValues['UrlCode']);
         $this->Form->SetFormValue('UrlCode', $FormValues['UrlCode']);
         $SQL = Gdn::Database()->SQL();
         // Make sure that the UrlCode is unique among pages.
         $SQL->Select('p.PageID')->From('Page p')->Where('p.UrlCode', $FormValues['UrlCode']);
         if (isset($Page)) {
             $SQL->Where('p.PageID <>', $Page->PageID);
         }
         $UrlCodeExists = isset($SQL->Get()->FirstRow()->PageID);
         if ($UrlCodeExists) {
             $this->Form->AddError(T('BasicPages.Settings.NewPage.ErrorUrlCode', 'The specified URL code is already in use by another page.'), 'UrlCode');
         }
         // Make sure sort is set if new page.
         if (!$Page) {
             $LastSort = $this->PageModel->GetLastSort();
             $FormValues['Sort'] = $LastSort + 1;
         }
         // Send CurrentFormat value to the page to be used for
         // setting the selected value of the formats drop-down.
         $this->AddDefinition('CurrentFormat', $FormValues['Format']);
         // Explicitly cast these values to an integer data type in case
         // they are equal to '' to be valid with MySQL strict mode, etc.
         $FormValues['SiteMenuLink'] = (int) $FormValues['SiteMenuLink'];
         // If all form values are validated.
         if ($this->Form->ErrorCount() == 0) {
             $PageID = $this->PageModel->Save($FormValues);
             $ValidationResults = $this->PageModel->ValidationResults();
             $this->Form->SetValidationResults($ValidationResults);
             // Create and clean up routes for UrlCode.
             if ($Page->UrlCode != $FormValues['UrlCode']) {
                 if (Gdn::Router()->MatchRoute($Page->UrlCode . $this->PageModel->RouteExpressionSuffix)) {
                     Gdn::Router()->DeleteRoute($Page->UrlCode . $this->PageModel->RouteExpressionSuffix);
                 }
             }
             if ($FormValues['HidePageFromURL'] == '1' && !Gdn::Router()->MatchRoute($FormValues['UrlCode'] . $this->PageModel->RouteExpressionSuffix)) {
                 Gdn::Router()->SetRoute($FormValues['UrlCode'] . $this->PageModel->RouteExpressionSuffix, 'page/' . $FormValues['UrlCode'] . $this->PageModel->RouteTargetSuffix, 'Internal');
             } elseif ($FormValues['HidePageFromURL'] == '0' && Gdn::Router()->MatchRoute($FormValues['UrlCode'] . $this->PageModel->RouteExpressionSuffix)) {
                 Gdn::Router()->DeleteRoute($FormValues['UrlCode'] . $this->PageModel->RouteExpressionSuffix);
             }
             // Set up a custom view permission.
             // The UrlCode must be unique and validated before this code.
             $ViewPermissionName = 'BasicPages.' . $FormValues['UrlCode'] . '.View';
             $PermissionTable = Gdn::Database()->Structure()->Table('Permission');
             $PermissionModel = Gdn::PermissionModel();
             // If a page is being edited, then check if UrlCode was changed by the user
             // and rename the custom view permission column for the page if it exists accordingly,
             // to keep the permission table clean.
             if (isset($Page) && $Page->UrlCode != $FormValues['UrlCode']) {
                 $OldViewPermissionName = 'BasicPages.' . $Page->UrlCode . '.View';
                 $PermissionModel->Undefine($OldViewPermissionName);
                 // The column must be dropped for now, because the RenameColumn method
                 // has a bug, which has been reported.
                 //$PermissionTable->RenameColumn($OldViewPermissionName, $ViewPermissionName);
             }
             $ViewPermissionExists = $PermissionTable->ColumnExists($ViewPermissionName);
             // Check if the user checked the setting to enable the custom view permission.
             if ((bool) $FormValues['ViewPermission']) {
                 // Check if the permission does not exist.
                 if (!$ViewPermissionExists) {
                     // Create the custom view permission.
                     $PermissionModel->Define($ViewPermissionName);
                     // Set initial permission for the Administrator role.
                     $PermissionModel->Save(array('Role' => 'Administrator', $ViewPermissionName => 1));
                 }
             } elseif ($ViewPermissionExists) {
                 // Delete the custom view permission if it exists.
                 $PermissionTable->DropColumn($ViewPermissionName);
             }
             if ($this->DeliveryType() == DELIVERY_TYPE_ALL) {
                 if (strtolower($this->RequestMethod) == 'newpage') {
                     Redirect('pagessettings/allpages#Page_' . $PageID);
                 }
                 $this->InformMessage('<span class="InformSprite Check"></span>' . T('BasicPages.Settings.NewPage.Saved', 'The page has been saved successfully. <br />Go back to ') . Anchor(T('BasicPages.Settings.AllPages', 'all pages'), 'pagessettings/allpages') . T('BasicPages.Settings.NewPage.Saved2', ' or ') . Anchor(T('BasicPages.Settings.NewPage.ViewPage', 'view the page'), PageModel::PageUrl($FormValues['UrlCode'])) . '.', 'Dismissable AutoDismiss HasSprite');
             }
         }
     }
     // Setup head.
     if ($this->Data('Title')) {
         $this->AddSideMenu();
         $this->Title($this->Data('Title'));
     } else {
         $this->AddSideMenu('pagessettings/newpage');
         $this->Title(T('BasicPages.Settings.NewPage', 'New Page'));
     }
     $this->Render();
 }
开发者ID:oMadMartigaNo,项目名称:readjust-forum,代码行数:101,代码来源:class.pagessettingscontroller.php


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