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


PHP Gdn_Format::alphaNumeric方法代码示例

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


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

示例1: extendedProfileFields

 /**
  * Output markup for extended profile fields.
  *
  * @param array $profileFields Formatted profile fields.
  * @param array $allFields Extended profile field data.
  * @param array $magicLabels "Magic" labels configured on the Profile Extender plug-in class.
  */
 function extendedProfileFields($profileFields, $allFields, $magicLabels = [])
 {
     foreach ($profileFields as $name => $value) {
         // Skip empty and hidden fields.
         if (!$value || !val('OnProfile', $allFields[$name])) {
             continue;
         }
         // Non-magic fields must be plain text, but we'll auto-link
         if (!in_array($name, $magicLabels)) {
             $value = Gdn_Format::links(Gdn_Format::text($value));
         }
         $class = 'Profile' . Gdn_Format::alphaNumeric($name);
         $label = Gdn_Format::text($allFields[$name]['Label']);
         $filteredVal = Gdn_Format::htmlFilter($value);
         echo " <dt class=\"ProfileExtend {$class}\">{$label}</dt> ";
         echo " <dd class=\"ProfileExtend {$class}\">{$filteredVal}</dd> ";
     }
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:25,代码来源:helper_functions.php

示例2: cssClass

 /**
  * Add CSS class names to a row depending on other elements/values in that row.
  *
  * Used by category, discussion, and comment lists.
  *
  * @param array|object $Row
  * @return string The CSS classes to be inserted into the row.
  */
 function cssClass($Row, $InList = true)
 {
     static $Alt = false;
     $Row = (array) $Row;
     $CssClass = 'Item';
     $Session = Gdn::session();
     // Alt rows
     if ($Alt) {
         $CssClass .= ' Alt';
     }
     $Alt = !$Alt;
     // Category list classes
     if (array_key_exists('UrlCode', $Row)) {
         $CssClass .= ' Category-' . Gdn_Format::alphaNumeric($Row['UrlCode']);
     }
     if (GetValue('CssClass', $Row)) {
         $CssClass .= ' Item-' . $Row['CssClass'];
     }
     if (array_key_exists('Depth', $Row)) {
         $CssClass .= " Depth{$Row['Depth']} Depth-{$Row['Depth']}";
     }
     if (array_key_exists('Archive', $Row)) {
         $CssClass .= ' Archived';
     }
     // Discussion list classes.
     if ($InList) {
         $CssClass .= val('Bookmarked', $Row) == '1' ? ' Bookmarked' : '';
         $Announce = val('Announce', $Row);
         if ($Announce == 2) {
             $CssClass .= ' Announcement Announcement-Category';
         } elseif ($Announce) {
             $CssClass .= ' Announcement Announcement-Everywhere';
         }
         $CssClass .= val('Closed', $Row) == '1' ? ' Closed' : '';
         $CssClass .= val('InsertUserID', $Row) == $Session->UserID ? ' Mine' : '';
         $CssClass .= val('Participated', $Row) == '1' ? ' Participated' : '';
         if (array_key_exists('CountUnreadComments', $Row) && $Session->isValid()) {
             $CountUnreadComments = $Row['CountUnreadComments'];
             if ($CountUnreadComments === true) {
                 $CssClass .= ' New';
             } elseif ($CountUnreadComments == 0) {
                 $CssClass .= ' Read';
             } else {
                 $CssClass .= ' Unread';
             }
         } elseif (($IsRead = val('Read', $Row, null)) !== null) {
             // Category list
             $CssClass .= $IsRead ? ' Read' : ' Unread';
         }
     }
     // Comment list classes
     if (array_key_exists('CommentID', $Row)) {
         $CssClass .= ' ItemComment';
     } elseif (array_key_exists('DiscussionID', $Row)) {
         $CssClass .= ' ItemDiscussion';
     }
     if (function_exists('IsMeAction')) {
         $CssClass .= isMeAction($Row) ? ' MeAction' : '';
     }
     if ($_CssClss = val('_CssClass', $Row)) {
         $CssClass .= ' ' . $_CssClss;
     }
     // Insert User classes.
     if ($UserID = val('InsertUserID', $Row)) {
         $User = Gdn::userModel()->getID($UserID);
         if ($_CssClss = val('_CssClass', $User)) {
             $CssClass .= ' ' . $_CssClss;
         }
     }
     return trim($CssClass);
 }
开发者ID:mcnasby,项目名称:datto-vanilla,代码行数:79,代码来源:functions.render.php

示例3: init

 /**
  *
  *
  * @param $Path
  * @param $Controller
  */
 public function init($Path, $Controller)
 {
     $Smarty = $this->smarty();
     // Get a friendly name for the controller.
     $ControllerName = get_class($Controller);
     if (StringEndsWith($ControllerName, 'Controller', true)) {
         $ControllerName = substr($ControllerName, 0, -10);
     }
     // Get an ID for the body.
     $BodyIdentifier = strtolower($Controller->ApplicationFolder . '_' . $ControllerName . '_' . Gdn_Format::alphaNumeric(strtolower($Controller->RequestMethod)));
     $Smarty->assign('BodyID', $BodyIdentifier);
     //$Smarty->assign('Config', Gdn::Config());
     // Assign some information about the user.
     $Session = Gdn::session();
     if ($Session->isValid()) {
         $User = array('Name' => $Session->User->Name, 'Photo' => '', 'CountNotifications' => (int) val('CountNotifications', $Session->User, 0), 'CountUnreadConversations' => (int) val('CountUnreadConversations', $Session->User, 0), 'SignedIn' => true);
         $Photo = $Session->User->Photo;
         if ($Photo) {
             if (!IsUrl($Photo)) {
                 $Photo = Gdn_Upload::Url(ChangeBasename($Photo, 'n%s'));
             }
         } else {
             if (function_exists('UserPhotoDefaultUrl')) {
                 $Photo = UserPhotoDefaultUrl($Session->User, 'ProfilePhoto');
             } elseif ($ConfigPhoto = C('Garden.DefaultAvatar')) {
                 $Photo = Gdn_Upload::url($ConfigPhoto);
             } else {
                 $Photo = Asset('/applications/dashboard/design/images/defaulticon.png', true);
             }
         }
         $User['Photo'] = $Photo;
     } else {
         $User = false;
         /*array(
           'Name' => '',
           'CountNotifications' => 0,
           'SignedIn' => FALSE);*/
     }
     $Smarty->assign('User', $User);
     // Make sure that any datasets use arrays instead of objects.
     foreach ($Controller->Data as $Key => $Value) {
         if ($Value instanceof Gdn_DataSet) {
             $Controller->Data[$Key] = $Value->resultArray();
         } elseif ($Value instanceof stdClass) {
             $Controller->Data[$Key] = (array) $Value;
         }
     }
     $BodyClass = val('CssClass', $Controller->Data, '', true);
     $Sections = Gdn_Theme::section(null, 'get');
     if (is_array($Sections)) {
         foreach ($Sections as $Section) {
             $BodyClass .= ' Section-' . $Section;
         }
     }
     $Controller->Data['BodyClass'] = $BodyClass;
     // Set the current locale for themes to take advantage of.
     $Locale = Gdn::locale()->Locale;
     $CurrentLocale = array('Key' => $Locale, 'Lang' => str_replace('_', '-', $Locale));
     if (class_exists('Locale')) {
         $CurrentLocale['Language'] = Locale::getPrimaryLanguage($Locale);
         $CurrentLocale['Region'] = Locale::getRegion($Locale);
         $CurrentLocale['DisplayName'] = Locale::getDisplayName($Locale, $Locale);
         $CurrentLocale['DisplayLanguage'] = Locale::getDisplayLanguage($Locale, $Locale);
         $CurrentLocale['DisplayRegion'] = Locale::getDisplayRegion($Locale, $Locale);
     }
     $Smarty->assign('CurrentLocale', $CurrentLocale);
     $Smarty->assign('Assets', (array) $Controller->Assets);
     $Smarty->assign('Path', Gdn::request()->path());
     // Assign the controller data last so the controllers override any default data.
     $Smarty->assign($Controller->Data);
     $Smarty->Controller = $Controller;
     // for smarty plugins
     $Smarty->security = true;
     $Smarty->security_settings['IF_FUNCS'] = array_merge($Smarty->security_settings['IF_FUNCS'], array('Category', 'CheckPermission', 'InSection', 'InCategory', 'MultiCheckPermission', 'GetValue', 'SetValue', 'Url'));
     $Smarty->security_settings['MODIFIER_FUNCS'] = array_merge($Smarty->security_settings['MODIFIER_FUNCS'], array('sprintf'));
     $Smarty->secure_dir = array($Path);
 }
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:83,代码来源:class.smarty.php

示例4: renderMaster


//.........这里部分代码省略.........
             if (arrayHasValue($this->_CssFiles, 'style.css')) {
                 $this->addJsFile('custom.js');
                 // only to non-admin pages.
             }
             $Cdns = array();
             if (!c('Garden.Cdns.Disable', false)) {
                 $Cdns = array('jquery.js' => "//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js");
             }
             // And now search for/add all JS files.
             $this->EventArguments['Cdns'] =& $Cdns;
             $this->fireEvent('AfterJsCdns');
             $this->Head->addScript('', 'text/javascript', false, array('content' => $this->definitionList(false)));
             foreach ($this->_JsFiles as $Index => $JsInfo) {
                 $JsFile = $JsInfo['FileName'];
                 if (!is_array($JsInfo['Options'])) {
                     $JsInfo['Options'] = array();
                 }
                 $Options =& $JsInfo['Options'];
                 if (isset($Cdns[$JsFile])) {
                     $JsFile = $Cdns[$JsFile];
                 }
                 $AppFolder = $JsInfo['AppFolder'];
                 $LookupFolder = !empty($AppFolder) ? $AppFolder : $this->ApplicationFolder;
                 $Search = AssetModel::JsPath($JsFile, $LookupFolder, $ThemeType);
                 if (!$Search) {
                     continue;
                 }
                 list($Path, $UrlPath) = $Search;
                 if ($Path !== false) {
                     $AddVersion = true;
                     if (!isUrl($Path)) {
                         $Path = substr($Path, strlen(PATH_ROOT));
                         $Path = str_replace(DS, '/', $Path);
                         $AddVersion = val('AddVersion', $Options, true);
                     }
                     $this->Head->addScript($Path, 'text/javascript', $AddVersion, $Options);
                     continue;
                 }
             }
         }
         // Add the favicon.
         $Favicon = C('Garden.FavIcon');
         if ($Favicon) {
             $this->Head->setFavIcon(Gdn_Upload::url($Favicon));
         }
         // Make sure the head module gets passed into the assets collection.
         $this->addModule('Head');
     }
     // Master views come from one of four places:
     $MasterViewPaths = array();
     if (strpos($this->MasterView, '/') !== false) {
         $MasterViewPaths[] = combinePaths(array(PATH_ROOT, str_replace('/', DS, $this->MasterView) . '.master*'));
     } else {
         if ($this->Theme) {
             // 1. Application-specific theme view. eg. root/themes/theme_name/app_name/views/
             $MasterViewPaths[] = combinePaths(array(PATH_THEMES, $this->Theme, $this->ApplicationFolder, 'views', $this->MasterView . '.master*'));
             // 2. Garden-wide theme view. eg. /path/to/application/themes/theme_name/views/
             $MasterViewPaths[] = combinePaths(array(PATH_THEMES, $this->Theme, 'views', $this->MasterView . '.master*'));
         }
         // 3. Plugin default. eg. root/plugin_name/views/
         $MasterViewPaths[] = combinePaths(array(PATH_ROOT, $this->ApplicationFolder, 'views', $this->MasterView . '.master*'));
         // 4. Application default. eg. root/app_name/views/
         $MasterViewPaths[] = combinePaths(array(PATH_APPLICATIONS, $this->ApplicationFolder, 'views', $this->MasterView . '.master*'));
         // 5. Garden default. eg. root/dashboard/views/
         $MasterViewPaths[] = combinePaths(array(PATH_APPLICATIONS, 'dashboard', 'views', $this->MasterView . '.master*'));
     }
     // Find the first file that matches the path.
     $MasterViewPath = false;
     foreach ($MasterViewPaths as $Glob) {
         $Paths = safeGlob($Glob);
         if (is_array($Paths) && count($Paths) > 0) {
             $MasterViewPath = $Paths[0];
             break;
         }
     }
     $this->EventArguments['MasterViewPath'] =& $MasterViewPath;
     $this->fireEvent('BeforeFetchMaster');
     if ($MasterViewPath === false) {
         trigger_error(errorMessage("Could not find master view: {$this->MasterView}.master*", $this->ClassName, '_FetchController'), E_USER_ERROR);
     }
     /// A unique identifier that can be used in the body tag of the master view if needed.
     $ControllerName = $this->ClassName;
     // Strip "Controller" from the body identifier.
     if (substr($ControllerName, -10) == 'Controller') {
         $ControllerName = substr($ControllerName, 0, -10);
     }
     // Strip "Gdn_" from the body identifier.
     if (substr($ControllerName, 0, 4) == 'Gdn_') {
         $ControllerName = substr($ControllerName, 4);
     }
     $this->setData('CssClass', $this->Application . ' ' . $ControllerName . ' ' . $this->RequestMethod . ' ' . $this->CssClass, true);
     // Check to see if there is a handler for this particular extension.
     $ViewHandler = Gdn::factory('ViewHandler' . strtolower(strrchr($MasterViewPath, '.')));
     if (is_null($ViewHandler)) {
         $BodyIdentifier = strtolower($this->ApplicationFolder . '_' . $ControllerName . '_' . Gdn_Format::alphaNumeric(strtolower($this->RequestMethod)));
         include $MasterViewPath;
     } else {
         $ViewHandler->render($MasterViewPath, $this);
     }
 }
开发者ID:battaglia01,项目名称:vanilla,代码行数:101,代码来源:class.controller.php

示例5: escapeID

 /**
  * Returns the provided fieldname with non-alpha-numeric values stripped and
  * $this->IDPrefix prepended.
  *
  * @param string $FieldName
  * @param bool $ForceUniqueID
  * @return string
  */
 public function escapeID($FieldName, $ForceUniqueID = true)
 {
     $ID = $FieldName;
     if (substr($ID, -2) == '[]') {
         $ID = substr($ID, 0, -2);
     }
     $ID = $this->IDPrefix . Gdn_Format::alphaNumeric(str_replace('.', '-dot-', $ID));
     $tmp = $ID;
     $i = 1;
     if ($ForceUniqueID === true) {
         if (array_key_exists($ID, $this->_IDCollection)) {
             $tmp = $ID . $this->_IDCollection[$ID];
             $this->_IDCollection[$ID]++;
         } else {
             $tmp = $ID;
             $this->_IDCollection[$ID] = 1;
         }
     } else {
         // If not forcing unique (ie. getting the id for a label's "for" tag),
         // get the last used copy of the requested id.
         $Found = false;
         $Count = val($ID, $this->_IDCollection, 0);
         if ($Count <= 1) {
             $tmp = $ID;
         } else {
             $tmp = $ID . ($Count - 1);
         }
     }
     return $tmp;
 }
开发者ID:bryanjamesmiller,项目名称:vanilla,代码行数:38,代码来源:class.form.php

示例6: userInfoModule_onBasicInfo_handler

 /**
  * Display custom fields on Profile.
  */
 public function userInfoModule_onBasicInfo_handler($Sender)
 {
     if ($Sender->User->Banned) {
         return;
     }
     try {
         // Get the custom fields
         $ProfileFields = Gdn::userModel()->getMeta($Sender->User->UserID, 'Profile.%', 'Profile.');
         // Import from CustomProfileFields if available
         if (!count($ProfileFields) && is_object($Sender->User) && c('Plugins.CustomProfileFields.SuggestedFields', false)) {
             $ProfileFields = Gdn::userModel()->getAttribute($Sender->User->UserID, 'CustomProfileFields', false);
             if ($ProfileFields) {
                 // Migrate to UserMeta & delete original
                 Gdn::userModel()->setMeta($Sender->User->UserID, $ProfileFields, 'Profile.');
                 Gdn::userModel()->saveAttribute($Sender->User->UserID, 'CustomProfileFields', false);
             }
         }
         // Send them off for magic formatting
         $ProfileFields = $this->parseSpecialFields($ProfileFields);
         // Get all field data, error check
         $AllFields = $this->getProfileFields();
         if (!is_array($AllFields) || !is_array($ProfileFields)) {
             return;
         }
         // DateOfBirth is special case that core won't handle
         // Hack it in here instead
         if (c('ProfileExtender.Fields.DateOfBirth.OnProfile')) {
             // Do not use Gdn_Format::Date because it shifts to local timezone
             $BirthdayStamp = Gdn_Format::toTimestamp($Sender->User->DateOfBirth);
             if ($BirthdayStamp) {
                 $ProfileFields['DateOfBirth'] = date(t('Birthday Format', 'F j, Y'), $BirthdayStamp);
                 $AllFields['DateOfBirth'] = array('Label' => t('Birthday'), 'OnProfile' => true);
             }
         }
         // Display all non-hidden fields
         $ProfileFields = array_reverse($ProfileFields);
         foreach ($ProfileFields as $Name => $Value) {
             // Skip empty and hidden fields.
             if (!$Value || !val('OnProfile', $AllFields[$Name])) {
                 continue;
             }
             // Non-magic fields must be plain text, but we'll auto-link
             if (!in_array($Name, $this->MagicLabels)) {
                 $Value = Gdn_Format::links(Gdn_Format::text($Value));
             }
             echo ' <dt class="ProfileExtend Profile' . Gdn_Format::alphaNumeric($Name) . '">' . Gdn_Format::text($AllFields[$Name]['Label']) . '</dt> ';
             echo ' <dd class="ProfileExtend Profile' . Gdn_Format::alphaNumeric($Name) . '">' . Gdn_Format::htmlFilter($Value) . '</dd> ';
         }
     } catch (Exception $ex) {
         // No errors
     }
 }
开发者ID:ReKungPaw,项目名称:vanilla,代码行数:55,代码来源:class.profileextender.plugin.php

示例7: formatRoleCss

 /**
  * Generate a valid css class from a role name.
  *
  * @param string $rawRole role name
  * @return string CSS class
  */
 private function formatRoleCss($rawRole)
 {
     return 'Role_' . str_replace(' ', '_', Gdn_Format::alphaNumeric($rawRole));
 }
开发者ID:vanilla,项目名称:addons,代码行数:10,代码来源:class.roletitle.plugin.php

示例8: _create

 /**
  * Creates the table defined with $this->Table() and $this->Column().
  */
 protected function _create()
 {
     $PrimaryKey = array();
     $UniqueKey = array();
     $FullTextKey = array();
     $AllowFullText = true;
     $Indexes = array();
     $Keys = '';
     $Sql = '';
     $ForceDatabaseEngine = C('Database.ForceStorageEngine');
     if ($ForceDatabaseEngine && !$this->_TableStorageEngine) {
         $this->_TableStorageEngine = $ForceDatabaseEngine;
         $AllowFullText = $this->_supportsFulltext();
     }
     foreach ($this->_Columns as $ColumnName => $Column) {
         if ($Sql != '') {
             $Sql .= ',';
         }
         $Sql .= "\n" . $this->_defineColumn($Column);
         $ColumnKeyTypes = (array) $Column->KeyType;
         foreach ($ColumnKeyTypes as $ColumnKeyType) {
             $KeyTypeParts = explode('.', $ColumnKeyType, 2);
             $ColumnKeyType = $KeyTypeParts[0];
             $IndexGroup = val(1, $KeyTypeParts, '');
             if ($ColumnKeyType == 'primary') {
                 $PrimaryKey[] = $ColumnName;
             } elseif ($ColumnKeyType == 'key') {
                 $Indexes['FK'][$IndexGroup][] = $ColumnName;
             } elseif ($ColumnKeyType == 'index') {
                 $Indexes['IX'][$IndexGroup][] = $ColumnName;
             } elseif ($ColumnKeyType == 'unique') {
                 $UniqueKey[] = $ColumnName;
             } elseif ($ColumnKeyType == 'fulltext' && $AllowFullText) {
                 $FullTextKey[] = $ColumnName;
             }
         }
     }
     // Build primary keys
     if (count($PrimaryKey) > 0) {
         $Keys .= ",\nprimary key (`" . implode('`, `', $PrimaryKey) . "`)";
     }
     // Build unique keys.
     if (count($UniqueKey) > 0) {
         $Keys .= ",\nunique index `" . Gdn_Format::alphaNumeric('UX_' . $this->_TableName) . '` (`' . implode('`, `', $UniqueKey) . "`)";
     }
     // Build full text index.
     if (count($FullTextKey) > 0) {
         $Keys .= ",\nfulltext index `" . Gdn_Format::alphaNumeric('TX_' . $this->_TableName) . '` (`' . implode('`, `', $FullTextKey) . "`)";
     }
     // Build the rest of the keys.
     foreach ($Indexes as $IndexType => $IndexGroups) {
         $CreateString = val($IndexType, array('FK' => 'key', 'IX' => 'index'));
         foreach ($IndexGroups as $IndexGroup => $ColumnNames) {
             if (!$IndexGroup) {
                 foreach ($ColumnNames as $ColumnName) {
                     $Keys .= ",\n{$CreateString} `{$IndexType}_{$this->_TableName}_{$ColumnName}` (`{$ColumnName}`)";
                 }
             } else {
                 $Keys .= ",\n{$CreateString} `{$IndexType}_{$this->_TableName}_{$IndexGroup}` (`" . implode('`, `', $ColumnNames) . '`)';
             }
         }
     }
     $Sql = 'create table `' . $this->_DatabasePrefix . $this->_TableName . '` (' . $Sql . $Keys . "\n)";
     // Check to see if there are any fulltext columns, otherwise use innodb.
     if (!$this->_TableStorageEngine) {
         $HasFulltext = false;
         foreach ($this->_Columns as $Column) {
             $ColumnKeyTypes = (array) $Column->KeyType;
             array_map('strtolower', $ColumnKeyTypes);
             if (in_array('fulltext', $ColumnKeyTypes)) {
                 $HasFulltext = true;
                 break;
             }
         }
         if ($HasFulltext) {
             $this->_TableStorageEngine = 'myisam';
         } else {
             $this->_TableStorageEngine = C('Database.DefaultStorageEngine', 'innodb');
         }
         if (!$this->hasEngine($this->_TableStorageEngine)) {
             $this->_TableStorageEngine = 'myisam';
         }
     }
     if ($this->_TableStorageEngine) {
         $Sql .= ' engine=' . $this->_TableStorageEngine;
     }
     if ($this->_CharacterEncoding !== false && $this->_CharacterEncoding != '') {
         $Sql .= ' default character set ' . $this->_CharacterEncoding;
     }
     if (array_key_exists('Collate', $this->Database->ExtendedProperties)) {
         $Sql .= ' collate ' . $this->Database->ExtendedProperties['Collate'];
     }
     $Sql .= ';';
     $Result = $this->query($Sql);
     $this->reset();
     return $Result;
 }
开发者ID:hvaleanu,项目名称:vanilla,代码行数:100,代码来源:class.mysqlstructure.php

示例9: init

 /**
  *
  *
  * @param string $Path
  * @param Gdn_Controller $Controller
  */
 public function init($Path, $Controller)
 {
     $Smarty = $this->smarty();
     // Get a friendly name for the controller.
     $ControllerName = get_class($Controller);
     if (StringEndsWith($ControllerName, 'Controller', true)) {
         $ControllerName = substr($ControllerName, 0, -10);
     }
     // Get an ID for the body.
     $BodyIdentifier = strtolower($Controller->ApplicationFolder . '_' . $ControllerName . '_' . Gdn_Format::alphaNumeric(strtolower($Controller->RequestMethod)));
     $Smarty->assign('BodyID', htmlspecialchars($BodyIdentifier));
     //$Smarty->assign('Config', Gdn::Config());
     // Assign some information about the user.
     $Session = Gdn::session();
     if ($Session->isValid()) {
         $User = array('Name' => htmlspecialchars($Session->User->Name), 'Photo' => '', 'CountNotifications' => (int) val('CountNotifications', $Session->User, 0), 'CountUnreadConversations' => (int) val('CountUnreadConversations', $Session->User, 0), 'SignedIn' => true);
         $Photo = $Session->User->Photo;
         if ($Photo) {
             if (!isUrl($Photo)) {
                 $Photo = Gdn_Upload::url(changeBasename($Photo, 'n%s'));
             }
         } else {
             $Photo = UserModel::getDefaultAvatarUrl($Session->User);
         }
         $User['Photo'] = $Photo;
     } else {
         $User = false;
         /*array(
           'Name' => '',
           'CountNotifications' => 0,
           'SignedIn' => FALSE);*/
     }
     $Smarty->assign('User', $User);
     // Make sure that any datasets use arrays instead of objects.
     foreach ($Controller->Data as $Key => $Value) {
         if ($Value instanceof Gdn_DataSet) {
             $Controller->Data[$Key] = $Value->resultArray();
         } elseif ($Value instanceof stdClass) {
             $Controller->Data[$Key] = (array) $Value;
         }
     }
     $BodyClass = val('CssClass', $Controller->Data, '', true);
     $Sections = Gdn_Theme::section(null, 'get');
     if (is_array($Sections)) {
         foreach ($Sections as $Section) {
             $BodyClass .= ' Section-' . $Section;
         }
     }
     $Controller->Data['BodyClass'] = $BodyClass;
     // Set the current locale for themes to take advantage of.
     $Locale = Gdn::locale()->Locale;
     $CurrentLocale = array('Key' => $Locale, 'Lang' => str_replace('_', '-', Gdn::locale()->language(true)));
     if (class_exists('Locale')) {
         $CurrentLocale['Language'] = Locale::getPrimaryLanguage($Locale);
         $CurrentLocale['Region'] = Locale::getRegion($Locale);
         $CurrentLocale['DisplayName'] = Locale::getDisplayName($Locale, $Locale);
         $CurrentLocale['DisplayLanguage'] = Locale::getDisplayLanguage($Locale, $Locale);
         $CurrentLocale['DisplayRegion'] = Locale::getDisplayRegion($Locale, $Locale);
     }
     $Smarty->assign('CurrentLocale', $CurrentLocale);
     $Smarty->assign('Assets', (array) $Controller->Assets);
     // 2016-07-07 Linc: Request used to return blank for homepage.
     // Now it returns defaultcontroller. This restores BC behavior.
     $isHomepage = val('isHomepage', $Controller->Data);
     $Path = $isHomepage ? "" : Gdn::request()->path();
     $Smarty->assign('Path', $Path);
     $Smarty->assign('Homepage', $isHomepage);
     // true/false
     // Assign the controller data last so the controllers override any default data.
     $Smarty->assign($Controller->Data);
     $security = new SmartySecurityVanilla($Smarty);
     $security->php_handling = Smarty::PHP_REMOVE;
     $security->allow_constants = false;
     $security->allow_super_globals = false;
     $security->streams = null;
     $security->setPhpFunctions(array_merge($security->php_functions, ['array', 'category', 'checkPermission', 'inSection', 'inCategory', 'ismobile', 'multiCheckPermission', 'getValue', 'setValue', 'url', 'useragenttype']));
     $security->php_modifiers = array_merge($security->php_functions, array('sprintf'));
     $Smarty->enableSecurity($security);
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:85,代码来源:class.smarty.php


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