當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Attribute函數代碼示例

本文整理匯總了PHP中Attribute函數的典型用法代碼示例。如果您正苦於以下問題:PHP Attribute函數的具體用法?PHP Attribute怎麽用?PHP Attribute使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Attribute函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Img

 /**
  * Returns an img tag.
  */
 function Img($Image, $Attributes = '', $WithDomain = FALSE)
 {
     if ($Attributes == '') {
         $Attributes = array();
     }
     if (substr($Image, 0, 7) != 'http://' && $Image != '') {
         $Image = Asset($Image, $WithDomain);
     }
     return '<img src="' . $Image . '"' . Attribute($Attributes) . ' />';
 }
開發者ID:jeastwood,項目名稱:Garden,代碼行數:13,代碼來源:functions.render.php

示例2: toString

 /**
  * Render the entire head module.
  */
 public function toString()
 {
     // Add the canonical Url if necessary.
     if (method_exists($this->_Sender, 'CanonicalUrl') && !c('Garden.Modules.NoCanonicalUrl', false)) {
         $CanonicalUrl = $this->_Sender->canonicalUrl();
         if (!isUrl($CanonicalUrl)) {
             $CanonicalUrl = Gdn::router()->ReverseRoute($CanonicalUrl);
         }
         $this->_Sender->canonicalUrl($CanonicalUrl);
         //            $CurrentUrl = url('', true);
         //            if ($CurrentUrl != $CanonicalUrl) {
         $this->addTag('link', array('rel' => 'canonical', 'href' => $CanonicalUrl));
         //            }
     }
     // Include facebook open-graph meta information.
     if ($FbAppID = c('Plugins.Facebook.ApplicationID')) {
         $this->addTag('meta', array('property' => 'fb:app_id', 'content' => $FbAppID));
     }
     $SiteName = c('Garden.Title', '');
     if ($SiteName != '') {
         $this->addTag('meta', array('property' => 'og:site_name', 'content' => $SiteName));
     }
     $Title = htmlEntityDecode(Gdn_Format::text($this->title('', true)));
     if ($Title != '') {
         $this->addTag('meta', array('name' => 'twitter:title', 'property' => 'og:title', 'content' => $Title));
     }
     if (isset($CanonicalUrl)) {
         $this->addTag('meta', array('property' => 'og:url', 'content' => $CanonicalUrl));
     }
     if ($Description = trim(Gdn_Format::reduceWhiteSpaces($this->_Sender->Description()))) {
         $this->addTag('meta', array('name' => 'description', 'property' => 'og:description', 'content' => $Description));
     }
     $hasRelevantImage = false;
     // Default to the site logo if there were no images provided by the controller.
     if (count($this->_Sender->Image()) == 0) {
         $Logo = c('Garden.ShareImage', c('Garden.Logo', ''));
         if ($Logo != '') {
             // Fix the logo path.
             if (stringBeginsWith($Logo, 'uploads/')) {
                 $Logo = substr($Logo, strlen('uploads/'));
             }
             $Logo = Gdn_Upload::url($Logo);
             $this->addTag('meta', array('property' => 'og:image', 'content' => $Logo));
         }
     } else {
         foreach ($this->_Sender->Image() as $Img) {
             $this->addTag('meta', array('name' => 'twitter:image', 'property' => 'og:image', 'content' => $Img));
             $hasRelevantImage = true;
         }
     }
     // For the moment at least, only discussions are supported.
     if ($Title && val('DiscussionID', $this->_Sender)) {
         if ($hasRelevantImage) {
             $twitterCardType = 'summary_large_image';
         } else {
             $twitterCardType = 'summary';
         }
         // Let's force a description for the image card since it makes sense to see a card with only an image and a title.
         if (!$Description && $twitterCardType === 'summary_large_image') {
             $Description = '...';
         }
         // Card && Title && Description are required
         if ($twitterCardType && $Description) {
             $this->addTag('meta', array('name' => 'twitter:description', 'content' => $Description));
             $this->addTag('meta', array('name' => 'twitter:card', 'content' => $twitterCardType));
         }
     }
     $this->fireEvent('BeforeToString');
     $Tags = $this->_Tags;
     // Make sure that css loads before js (for jquery)
     usort($this->_Tags, array('HeadModule', 'TagCmp'));
     // "link" comes before "script"
     $Tags2 = $this->_Tags;
     // Start with the title.
     $Head = '<title>' . Gdn_Format::text($this->title()) . "</title>\n";
     $TagStrings = array();
     // Loop through each tag.
     foreach ($this->_Tags as $Index => $Attributes) {
         $Tag = $Attributes[self::TAG_KEY];
         // Inline the content of the tag, if necessary.
         if (val('_hint', $Attributes) == 'inline') {
             $Path = val('_path', $Attributes);
             if ($Path && !stringBeginsWith($Path, 'http')) {
                 $Attributes[self::CONTENT_KEY] = file_get_contents($Path);
                 if (isset($Attributes['src'])) {
                     $Attributes['_src'] = $Attributes['src'];
                     unset($Attributes['src']);
                 }
                 if (isset($Attributes['href'])) {
                     $Attributes['_href'] = $Attributes['href'];
                     unset($Attributes['href']);
                 }
             }
         }
         // If we set an IE conditional AND a "Not IE" condition, we will need to make a second pass.
         do {
             // Reset tag string
//.........這裏部分代碼省略.........
開發者ID:vanilla,項目名稱:vanilla,代碼行數:101,代碼來源:class.headmodule.php

示例3: wrap

 function wrap($String, $Tag = 'span', $Attributes = '')
 {
     if ($Tag == '') {
         return $String;
     }
     if (is_array($Attributes)) {
         $Attributes = Attribute($Attributes);
     }
     // Strip the first part of the tag as the closing tag - this allows us to
     // easily throw 'span class="something"' into the $Tag field.
     $Space = strpos($Tag, ' ');
     $ClosingTag = $Space ? substr($Tag, 0, $Space) : $Tag;
     return '<' . $Tag . $Attributes . '>' . $String . '</' . $ClosingTag . '>';
 }
開發者ID:mcnasby,項目名稱:datto-vanilla,代碼行數:14,代碼來源:functions.render.php

示例4: toString

 /**
  *
  *
  * @param string $HighlightRoute
  * @return string
  * @throws Exception
  */
 public function toString($HighlightRoute = '')
 {
     if ($HighlightRoute == '') {
         $HighlightRoute = $this->_HighlightRoute;
     }
     if ($HighlightRoute == '') {
         $HighlightRoute = Gdn_Url::Request();
     }
     $this->fireEvent('BeforeToString');
     $Username = '';
     $UserID = '';
     $Session_TransientKey = '';
     $Session = Gdn::session();
     $Admin = false;
     if ($Session->isValid() === true) {
         $UserID = $Session->User->UserID;
         $Username = $Session->User->Name;
         $Session_TransientKey = $Session->TransientKey();
         $Admin = $Session->User->Admin > 0 ? true : false;
     }
     $Menu = '';
     if (count($this->Items) > 0) {
         // Apply the menu group sort if present...
         if (is_array($this->Sort)) {
             $Items = array();
             $Count = count($this->Sort);
             for ($i = 0; $i < $Count; ++$i) {
                 $Group = $this->Sort[$i];
                 if (array_key_exists($Group, $this->Items)) {
                     $Items[$Group] = $this->Items[$Group];
                     unset($this->Items[$Group]);
                 }
             }
             foreach ($this->Items as $Group => $Links) {
                 $Items[$Group] = $Links;
             }
         } else {
             $Items = $this->Items;
         }
         foreach ($Items as $GroupName => $Links) {
             $ItemCount = 0;
             $LinkCount = 0;
             $OpenGroup = false;
             $Group = '';
             foreach ($Links as $Key => $Link) {
                 $CurrentLink = false;
                 $ShowLink = false;
                 $RequiredPermissions = array_key_exists('Permission', $Link) ? $Link['Permission'] : false;
                 if ($RequiredPermissions !== false && !is_array($RequiredPermissions)) {
                     $RequiredPermissions = explode(',', $RequiredPermissions);
                 }
                 // Show if there are no permissions or the user has ANY of the specified permissions or the user is admin
                 $ShowLink = $Admin || $RequiredPermissions === false || Gdn::session()->checkPermission($RequiredPermissions, false);
                 if ($ShowLink === true) {
                     if ($ItemCount == 1) {
                         $Group .= '<ul>';
                         $OpenGroup = true;
                     } elseif ($ItemCount > 1) {
                         $Group .= "</li>\r\n";
                     }
                     $Url = val('Url', $Link);
                     if (substr($Link['Text'], 0, 1) === '\\') {
                         $Text = substr($Link['Text'], 1);
                     } else {
                         $Text = str_replace('{Username}', $Username, $Link['Text']);
                     }
                     $Attributes = val('Attributes', $Link, array());
                     $AnchorAttributes = val('AnchorAttributes', $Link, array());
                     if ($Url !== false) {
                         $Url = url(str_replace(array('{Username}', '{UserID}', '{Session_TransientKey}'), array(urlencode($Username), $UserID, $Session_TransientKey), $Link['Url']));
                         $CurrentLink = $Url == url($HighlightRoute);
                         $CssClass = val('class', $Attributes, '');
                         if ($CurrentLink) {
                             $Attributes['class'] = $CssClass . ' Highlight';
                         }
                         $Group .= '<li' . Attribute($Attributes) . '><a' . Attribute($AnchorAttributes) . ' href="' . $Url . '">' . $Text . '</a>';
                         ++$LinkCount;
                     } else {
                         $Group .= '<li' . Attribute($Attributes) . '>' . $Text;
                     }
                     ++$ItemCount;
                 }
             }
             if ($OpenGroup === true) {
                 $Group .= "</li>\r\n</ul>\r\n";
             }
             if ($Group != '' && $LinkCount > 0) {
                 $Menu .= $Group . "</li>\r\n";
             }
         }
         if ($Menu != '') {
             $Menu = '<ul id="' . $this->HtmlId . '"' . ($this->CssClass != '' ? ' class="' . $this->CssClass . '"' : '') . '>' . $Menu . '</ul>';
         }
//.........這裏部分代碼省略.........
開發者ID:vanilla,項目名稱:vanilla,代碼行數:101,代碼來源:class.menumodule.php

示例5: if

<?php if (!defined('APPLICATION')) exit(); ?>
<div>
   <?php
   $this->CheckPermissions();
   
   // Loop through all the groups.
   foreach ($this->Items as $Item) {
      // Output the group.
      echo '<div class="Box Group '.GetValue('class', $Item['Attributes']).'">';
      if ($Item['Text'] != '')
         echo "\n", '<h4>',
            isset($Item['Url']) ? Anchor($Item['Text'], $Item['Url']) : $Item['Text'],
            '</h4>';

      if (count($Item['Links'])) {
         echo "\n", '<ul class="PanelInfo">';

         // Loop through all the links in the group.
         foreach ($Item['Links'] as $Link) {
            echo "\n  <li".Attribute($Link['Attributes']).">",
               Anchor($Link['Text'], $Link['Url']);
               '</li>';
         }

         echo "\n", '</ul>';
      }

      echo "\n", '</div>';
   }
   ?>
</div>
開發者ID:nerdgirl,項目名稱:Forums-ILoveBadTV,代碼行數:31,代碼來源:sidemenu.php

示例6: FlashHtml

 function FlashHtml($Movie, $Attributes = array(), $Params = array(), $FlashVars = False)
 {
     static $DefaultAttributes = array('width' => 400, 'height' => 300, 'type' => 'application/x-shockwave-flash');
     static $DefaultParams = array('allowfullscreen' => 'true', 'allowscriptaccess' => 'always', 'quality' => 'best', 'menu' => 'false');
     // BUG: 'wmode' => 'transparent'
     $ScriptRender = GetValue('ScriptRender', $Attributes, False, True);
     if (!is_array($Params)) {
         $Params = array();
     }
     $Params = array_merge($DefaultParams, $Params);
     $Movie = Asset($Movie, True);
     // check size
     if (!array_key_exists('width', $Attributes) || !array_key_exists('height', $Attributes)) {
         $ImageInfo = GetImageSize($Movie);
         if ($ImageInfo != False) {
             $Attributes['width'] = $ImageInfo[0];
             $Attributes['height'] = $ImageInfo[1];
         }
     }
     $Attributes = array_merge($DefaultAttributes, $Attributes);
     $FlashVars = GetValue('FlashVars', $Attributes, $FlashVars, True);
     if ($FlashVars != False) {
         $FlashVars = Gdn_Format::ObjectAsArray($FlashVars);
         $Vars = array();
         foreach ($FlashVars as $Name => $Value) {
             $Vars[] = $Name . '=' . $Value;
         }
         // encodeuricomponent
         $Params['flashvars'] = implode('&', $Vars);
     }
     $MSIE = strpos(ArrayValue('HTTP_USER_AGENT', $_SERVER), 'MSIE') > 0;
     if ($MSIE != False) {
         $Mode = GetValue('wmode', $Attributes, False, True);
         if ($Mode !== False) {
             $Params['wmode'] = $Mode;
         }
         $Params['movie'] = $Movie;
         $ObjectParams = '';
         foreach ($Params as $Name => $Value) {
             $ObjectParams .= '<param name="' . $Name . '" value="' . $Value . '" />';
         }
         // TODO: ADD CLASSID FOR IE
         $Result = '<object' . Attribute($Attributes) . '>' . $ObjectParams . '</object>';
     } else {
         $Attributes['src'] = $Movie;
         $Attributes = array_merge($Attributes, $Params);
         $Result = '<embed' . Attribute($Attributes) . ' />';
     }
     if ($ScriptRender) {
         $Result = JavaScript($Result, True);
     }
     // detect flash version you should manually
     return $Result;
 }
開發者ID:unlight,項目名稱:UsefulFunctions,代碼行數:54,代碼來源:functions.output.php

示例7: Wrap

   function Wrap($String, $Tag = 'span', $Attributes = '') {
		if ($Tag == '')
			return $String;
		
      if (is_array($Attributes))
         $Attributes = Attribute($Attributes);
         
      return '<'.$Tag.$Attributes.'>'.$String.'</'.$Tag.'>';
   }
開發者ID:nerdgirl,項目名稱:Forums-ILoveBadTV,代碼行數:9,代碼來源:functions.render.php

示例8: ToString

 /**
  * Returns the "show x more (or less) items" link.
  *
  * @param string The type of link to return: more or less
  */
 public function ToString($Type = 'more')
 {
     if ($this->_PropertiesDefined === FALSE) {
         trigger_error(ErrorMessage('You must configure the pager with $Pager->Configure() before retrieving the pager.', 'MorePager', 'GetSimple'), E_USER_ERROR);
     }
     $Pager = '';
     if ($Type == 'more') {
         $ClientID = $this->ClientID == '' ? '' : $this->ClientID . 'More';
         if ($this->Offset + $this->Limit >= $this->TotalRecords) {
             $Pager = '';
             // $this->Offset .' + '. $this->Limit .' >= '. $this->TotalRecords;
         } else {
             $ActualRecordsLeft = $RecordsLeft = $this->TotalRecords - $this->_LastOffset;
             if ($RecordsLeft > $this->Limit) {
                 $RecordsLeft = $this->Limit;
             }
             $NextOffset = $this->Offset + $this->Limit;
             $Pager .= Anchor(sprintf(Translate($this->MoreCode), $ActualRecordsLeft), sprintf($this->Url, $NextOffset, $this->Limit));
         }
     } else {
         if ($Type == 'less') {
             $ClientID = $this->ClientID == '' ? '' : $this->ClientID . 'Less';
             if ($this->Offset <= 0) {
                 $Pager = '';
             } else {
                 $RecordsBefore = $this->Offset;
                 if ($RecordsBefore > $this->Limit) {
                     $RecordsBefore = $this->Limit;
                 }
                 $PreviousOffset = $this->Offset - $this->Limit;
                 if ($PreviousOffset < 0) {
                     $PreviousOffset = 0;
                 }
                 $Pager .= Anchor(sprintf(Translate($this->LessCode), $this->Offset), sprintf($this->Url, $PreviousOffset, $RecordsBefore));
             }
         }
     }
     if ($Pager == '') {
         return $this->PagerEmpty;
     } else {
         return sprintf($this->Wrapper, Attribute(array('id' => $ClientID, 'class' => $this->CssClass)), $Pager);
     }
 }
開發者ID:kidmax,項目名稱:Garden,代碼行數:48,代碼來源:class.morepagermodule.php

示例9: Anchor

            $Options[] = Anchor(T('Add'), 'candy/section/add/' . $Node->SectionID, '');
        }
        if (IsContentOwner($Node, 'Candy.Sections.Edit')) {
            $Options[] = Anchor(T('Edit'), 'candy/section/edit/' . $Node->SectionID, '');
        }
        if ($Node->Depth == 0) {
            // This is root
            //$Options[] = Anchor('Properties', 'candy/content/properties/'.$Node->ContentID, '');
        } else {
            if ($PermissionSwap) {
                $Options[] = Anchor(T('Swap'), 'candy/section/swap/' . $Node->SectionID, '');
            }
            if ($PermissionMove) {
                $Options[] = Anchor(T('Move'), 'candy/section/move/' . $Node->SectionID, '');
            }
            if ($PermissionDelete) {
                $Options[] = Anchor(T('Delete'), 'candy/section/delete/' . $Node->SectionID, 'PopConfirm');
            }
            //$Options[] = Anchor('Properties', 'candy/section/properties/'.$Node->SectionID, '');
        }
        echo "\n<li" . Attribute($ItemAttribute) . '>';
        echo '<div>';
        echo SectionAnchor($Node);
        if (count($Options) > 0) {
            echo Wrap(implode(', ', $Options), 'span', array('class' => 'Options'));
        }
        echo '</div>';
    }
    echo str_repeat("</li></ul>", $Node->Depth) . '</li>';
    echo "</ol>";
}
開發者ID:unlight,項目名稱:Candy,代碼行數:31,代碼來源:tree.php

示例10: foreach

<?php

if (!defined('APPLICATION')) {
    exit;
}
$this->CheckPermissions();
// Loop through all the groups.
foreach ($this->Items as $Item) {
    // Output the group.
    echo '<div class="Box Group ' . GetValue('class', $Item['Attributes']) . '">';
    if ($Item['Text'] != '') {
        echo "\n", '<h4>', isset($Item['Url']) ? anchor($Item['Text'], $Item['Url']) : $Item['Text'], '</h4>';
    }
    if (count($Item['Links'])) {
        echo "\n", '<ul class="PanelInfo">';
        // Loop through all the links in the group.
        foreach ($Item['Links'] as $Link) {
            echo "\n  <li" . Attribute($Link['Attributes']) . ">", anchor($Link['Text'], $Link['Url']), '</li>';
        }
        echo "\n", '</ul>';
    }
    echo "\n", '</div>';
}
開發者ID:caidongyun,項目名稱:vanilla,代碼行數:23,代碼來源:sidemenu.php

示例11: ToString

 public function ToString()
 {
     $String = '';
     return $String;
     // Use native breadcrumbs render
     if (!$this->bCrumbsWrapped && $this->bAutoWrapCrumbs) {
         $this->WrapCrumbs();
     }
     $this->FireEvent('BeforeToString');
     $CountItems = count($this->Items);
     if ($CountItems == 0) {
         return $String;
     }
     $LastCrumbLinked = C('Candy.Modules.BreadCrumbsLastCrumbLinked', False);
     $Count = 0;
     foreach ($this->Items as $GroupName => $Links) {
         foreach ($Links as $Key => $Link) {
             $AnchorAttributes = array();
             // not used yet
             $ListAttributes = array();
             $Text = $GroupName;
             //$Text = ArrayValue('Text', $Link);
             $Count = $Count + 1;
             $Attributes = ArrayValue('Attributes', $Link, array());
             if ($Count == 1) {
                 $CssClassSuffix = 'First';
                 $ListAttributes['class'] = 'BreadCrumbs';
             } elseif ($Count == $CountItems) {
                 $CssClassSuffix = 'Last';
             } else {
                 $CssClassSuffix = '';
             }
             $Attributes['class'] = trim($CssClassSuffix . 'Crumb ' . ArrayValue('class', $Attributes, ''));
             $Url = ArrayValue('Url', $Link);
             if ($Url === NULL && GetValue('HomeLink', $Attributes, False, True)) {
                 $Url = '/';
             }
             $AnchorAttributes['href'] = Url($Url, True);
             $Anchor = '<a' . Attribute($AnchorAttributes) . '>' . $Text . '</a>';
             if ($Count == $CountItems) {
                 if ($LastCrumbLinked) {
                     $Text = $Anchor;
                 }
                 $Item = '<li' . Attribute($Attributes) . '>' . $Text . '</li>';
             } else {
                 $Item = '<li' . Attribute($Attributes) . '>' . $Anchor;
             }
             $String .= str_repeat("\t", $Count);
             $String .= "\n<ul" . Attribute($ListAttributes) . '>' . $Item;
         }
     }
     $String .= str_repeat("\n</ul></li>", $Count - 1) . '</ul>';
     //if (!$this->bCustomAssetTarget) $String = Wrap($String, 'div', array('id' => $this->HtmlId));
     $String = Wrap($String, 'div', array('id' => $this->HtmlId));
     return $String;
 }
開發者ID:unlight,項目名稱:Candy,代碼行數:56,代碼來源:class.breadcrumbsmodule.php

示例12: ToString

 public function ToString()
 {
     $Head = '<title>' . Gdn_Format::Text($this->Title()) . "</title>\n";
     // Add the canonical Url if necessary.
     if (method_exists($this->_Sender, 'CanonicalUrl')) {
         $CanonicalUrl = $this->_Sender->CanonicalUrl();
         $CurrentUrl = Gdn::Request()->Url('', TRUE);
         if ($CurrentUrl != $CanonicalUrl) {
             $this->AddTag('link', array('rel' => 'canonical', 'href' => $CanonicalUrl));
         }
     }
     // Make sure that css loads before js (for jquery)
     ksort($this->_Tags);
     // "link" comes before "script"
     foreach ($this->_Tags as $Tag => $Collection) {
         $Count = count($Collection);
         for ($i = 0; $i < $Count; ++$i) {
             $Head .= '<' . $Tag . Attribute($Collection[$i]) . ($Tag == 'script' ? '></' . $Tag . '>' : ' />') . "\n";
         }
     }
     $Count = count($this->_Strings);
     for ($i = 0; $i < $Count; ++$i) {
         $Head .= $this->_Strings[$i];
     }
     return $Head;
 }
開發者ID:kerphi,項目名稱:Garden,代碼行數:26,代碼來源:class.headmodule.php

示例13: ToStringPrevNext

 public function ToStringPrevNext($Type = 'more')
 {
     $this->CssClass = ConcatSep(' ', $this->CssClass, 'PrevNextPager');
     $CurrentPage = PageNumber($this->Offset, $this->Limit);
     $Pager = '';
     if ($CurrentPage > 1) {
         $PageParam = 'p' . ($CurrentPage - 1);
         $Pager .= Anchor(T('Previous'), self::FormatUrl($this->Url, $PageParam), 'Previous');
     }
     $HasNext = TRUE;
     if ($this->CurrentRecords !== FALSE && $this->CurrentRecords < $this->Limit) {
         $HasNext = FALSE;
     }
     if ($HasNext) {
         $PageParam = 'p' . ($CurrentPage + 1);
         $Pager = ConcatSep(' ', $Pager, Anchor('Next', self::FormatUrl($this->Url, $PageParam), 'Next'));
     }
     $ClientID = $this->ClientID;
     $ClientID = $Type == 'more' ? $ClientID . 'After' : $ClientID . 'Before';
     if (isset($this->HtmlBefore)) {
         $Pager = $this->HtmlBefore . $Pager;
     }
     return $Pager == '' ? '' : sprintf($this->Wrapper, Attribute(array('id' => $ClientID, 'class' => $this->CssClass)), $Pager);
 }
開發者ID:seedbank,項目名稱:old-repo,代碼行數:24,代碼來源:class.pagermodule.php

示例14: ToString

 public function ToString($HighlightRoute = '')
 {
     if ($HighlightRoute == '') {
         $HighlightRoute = $this->_HighlightRoute;
     }
     if ($HighlightRoute == '') {
         $HighlightRoute = Gdn_Url::Request();
     }
     $Username = '';
     $UserID = '';
     $Session_TransientKey = '';
     $Permissions = array();
     $Session = Gdn::Session();
     $HasPermissions = FALSE;
     $Admin = FALSE;
     if ($Session->IsValid() === TRUE) {
         $UserID = $Session->User->UserID;
         $Username = $Session->User->Name;
         $Session_TransientKey = $Session->TransientKey();
         $Permissions = $Session->GetPermissions();
         $HasPermissions = count($Permissions) > 0;
         $Admin = $Session->User->Admin == '1' ? TRUE : FALSE;
     }
     $Menu = '';
     if (count($this->Items) > 0) {
         // Apply the menu sort if present...
         if (is_array($this->Sort)) {
             $Items = array();
             $Count = count($this->Sort);
             for ($i = 0; $i < $Count; ++$i) {
                 $Group = $this->Sort[$i];
                 if (array_key_exists($Group, $this->Items)) {
                     $Items[$Group] = $this->Items[$Group];
                     unset($this->Items[$Group]);
                 }
             }
             foreach ($Items as $Group => $Links) {
                 $LinkNames = ConsolidateArrayValuesByKey($Links, 'Text');
                 $SortedLinks = array();
                 for ($j = 0; $j < $Count; ++$j) {
                     $SortName = $this->Sort[$j];
                     $Key = array_search($SortName, $LinkNames);
                     if ($Key !== FALSE) {
                         $SortedLinks[] = $Links[$Key];
                         unset($Links[$Key]);
                         $LinkNames[$Key] = '-=EMPTY=-';
                     }
                 }
                 $SortedLinks = array_merge($SortedLinks, $Links);
                 $Items[$Group] = $SortedLinks;
             }
         } else {
             $Items = $this->Items;
         }
         // Build the menu
         foreach ($Items as $GroupName => $Links) {
             $ItemCount = 0;
             $LinkCount = 0;
             $OpenGroup = FALSE;
             $GroupIsActive = FALSE;
             $GroupAnchor = '';
             $Group = '';
             foreach ($Links as $Key => $Link) {
                 $CurrentLink = FALSE;
                 $ShowLink = FALSE;
                 $RequiredPermissions = array_key_exists('Permission', $Link) ? $Link['Permission'] : FALSE;
                 if ($RequiredPermissions !== FALSE && !is_array($RequiredPermissions)) {
                     $RequiredPermissions = explode(',', $RequiredPermissions);
                 }
                 // Show if there are no permissions or the user has the required permissions or the user is admin
                 $ShowLink = $Admin || $RequiredPermissions === FALSE || ArrayInArray($RequiredPermissions, $Permissions, FALSE) === TRUE;
                 if ($ShowLink === TRUE) {
                     if ($ItemCount == 1) {
                         $Group .= '<ul class="PanelInfo">';
                         $OpenGroup = TRUE;
                     } else {
                         if ($ItemCount > 1) {
                             $Group .= "</li>\r\n";
                         }
                     }
                     $Url = ArrayValue('Url', $Link);
                     if (substr($Link['Text'], 0, 1) === '\\') {
                         $Text = substr($Link['Text'], 1);
                     } else {
                         $Text = str_replace('{Username}', $Username, $Link['Text']);
                     }
                     $Attributes = ArrayValue('Attributes', $Link, array());
                     if ($Url !== FALSE) {
                         $Url = str_replace(array('{Username}', '{UserID}', '{Session_TransientKey}'), array(urlencode($Username), $UserID, $Session_TransientKey), $Link['Url']);
                         if (substr($Url, 0, 5) != 'http:') {
                             if ($GroupAnchor == '' && $this->AutoLinkGroups) {
                                 $GroupAnchor = $Url;
                             }
                             $Url = Url($Url);
                             $CurrentLink = $Url == Url($HighlightRoute);
                             if ($CurrentLink && !$GroupIsActive) {
                                 $GroupIsActive = TRUE;
                             }
                         }
                         $CssClass = ArrayValue('class', $Attributes, '');
//.........這裏部分代碼省略.........
開發者ID:kennyma,項目名稱:Garden,代碼行數:101,代碼來源:class.sidemenumodule.php

示例15: ToString

      public function ToString() {
         // Add the canonical Url if necessary.
         if (method_exists($this->_Sender, 'CanonicalUrl')) {
            $CanonicalUrl = $this->_Sender->CanonicalUrl();
            $CurrentUrl = Gdn::Request()->Url('', TRUE);
            if ($CurrentUrl != $CanonicalUrl)
               $this->AddTag('link', array('rel' => 'canonical', 'href' => $CanonicalUrl));
         }

         $this->FireEvent('BeforeToString');

         $Tags = $this->_Tags;
            
         // Make sure that css loads before js (for jquery)
         usort($this->_Tags, array('HeadModule', 'TagCmp')); // "link" comes before "script"

         $Tags2 = $this->_Tags;

         // Start with the title.
         $Head = '<title>'.Gdn_Format::Text($this->Title())."</title>\n";

         $TagStrings = array();
         // Loop through each tag.
         foreach ($this->_Tags as $Index => $Attributes) {
            $Tag = $Attributes[self::TAG_KEY];

            // Inline the content of the tag, if necessary.
            if (GetValue('_hint', $Attributes) == 'inline') {
               $Path = GetValue('_path', $Attributes);
               if (!StringBeginsWith($Path, 'http')) {
                  $Attributes[self::CONTENT_KEY] = file_get_contents($Path);

                  if (isset($Attributes['src'])) {
                     $Attributes['_src'] = $Attributes['src'];
                     unset($Attributes['src']);
                  }
                  if (isset($Attributes['href'])) {
                     $Attributes['_href'] = $Attributes['href'];
                     unset($Attributes['href']);
                  }
               }
            }
            
            $TagString = '<'.$Tag.Attribute($Attributes, '_');

            if (array_key_exists(self::CONTENT_KEY, $Attributes))
               $TagString .= '>'.$Attributes[self::CONTENT_KEY].'</'.$Tag.'>';
            elseif ($Tag == 'script') {
               $TagString .= '></script>';
            } else
               $TagString .= ' />';

            $TagStrings[] = $TagString;
         }
         $Head .= implode("\n", array_unique($TagStrings));

         foreach ($this->_Strings as $String) {
            $Head .= $String;
            $Head .= "\n";
         }

         return $Head;
      }
開發者ID:nerdgirl,項目名稱:Forums-ILoveBadTV,代碼行數:63,代碼來源:class.headmodule.php


注:本文中的Attribute函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。