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


PHP ArrayHasValue函数代码示例

本文整理汇总了PHP中ArrayHasValue函数的典型用法代码示例。如果您正苦于以下问题:PHP ArrayHasValue函数的具体用法?PHP ArrayHasValue怎么用?PHP ArrayHasValue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: RenderMaster

 /**
  * Undocumented method.
  *
  * @todo Method RenderMaster() needs a description.
  */
 public function RenderMaster()
 {
     // Build the master view if necessary
     if (in_array($this->_DeliveryType, array(DELIVERY_TYPE_ALL))) {
         $this->MasterView = $this->MasterView();
         // Only get css & ui components if this is NOT a syndication request
         if ($this->SyndicationMethod == SYNDICATION_NONE && is_object($this->Head)) {
             if (ArrayHasValue($this->_CssFiles, 'style.css')) {
                 $this->AddCssFile('custom.css');
             }
             if (ArrayHasValue($this->_CssFiles, 'admin.css')) {
                 $this->AddCssFile('customadmin.css');
             }
             $this->EventArguments['CssFiles'] =& $this->_CssFiles;
             $this->FireEvent('BeforeAddCss');
             // And now search for/add all css files
             foreach ($this->_CssFiles as $CssInfo) {
                 $CssFile = $CssInfo['FileName'];
                 if (strpos($CssFile, '/') !== FALSE) {
                     // A direct path to the file was given.
                     $CssPaths = array(CombinePaths(array(PATH_ROOT, str_replace('/', DS, $CssFile))));
                 } else {
                     $CssGlob = preg_replace('/(.*)(\\.css)/', '\\1*\\2', $CssFile);
                     $AppFolder = $CssInfo['AppFolder'];
                     if ($AppFolder == '') {
                         $AppFolder = $this->ApplicationFolder;
                     }
                     // CSS comes from one of four places:
                     $CssPaths = array();
                     if ($this->Theme) {
                         // 1. Application-specific css. eg. root/themes/theme_name/app_name/design/
                         // $CssPaths[] = PATH_THEMES . DS . $this->Theme . DS . $AppFolder . DS . 'design' . DS . $CssGlob;
                         // 2. Theme-wide theme view. eg. root/themes/theme_name/design/
                         // a) Check to see if a customized version of the css is there.
                         if ($this->ThemeOptions) {
                             $Filenames = GetValueR('Styles.Value', $this->ThemeOptions);
                             if (is_string($Filenames) && $Filenames != '%s') {
                                 $CssPaths[] = PATH_THEMES . DS . $this->Theme . DS . 'design' . DS . ChangeBasename($CssFile, $Filenames);
                             }
                         }
                         // b) Use the default filename.
                         $CssPaths[] = PATH_THEMES . DS . $this->Theme . DS . 'design' . DS . $CssFile;
                     }
                     // 3. Application or plugin.
                     if (StringBeginsWith($AppFolder, 'plugins/')) {
                         // The css is coming from a plugin.
                         $AppFolder = substr($AppFolder, strlen('plugins/'));
                         $CssPaths[] = PATH_PLUGINS . "/{$AppFolder}/design/{$CssFile}";
                         $CssPaths[] = PATH_PLUGINS . "/{$AppFolder}/{$CssFile}";
                     } else {
                         // Application default. eg. root/applications/app_name/design/
                         $CssPaths[] = PATH_APPLICATIONS . DS . $AppFolder . DS . 'design' . DS . $CssFile;
                     }
                     // 4. Garden default. eg. root/applications/dashboard/design/
                     $CssPaths[] = PATH_APPLICATIONS . DS . 'dashboard' . DS . 'design' . DS . $CssFile;
                 }
                 // Find the first file that matches the path.
                 $CssPath = FALSE;
                 foreach ($CssPaths as $Glob) {
                     $Paths = SafeGlob($Glob);
                     if (is_array($Paths) && count($Paths) > 0) {
                         $CssPath = $Paths[0];
                         break;
                     }
                 }
                 // Check to see if there is a CSS cacher.
                 $CssCacher = Gdn::Factory('CssCacher');
                 if (!is_null($CssCacher)) {
                     $CssPath = $CssCacher->Get($CssPath, $AppFolder);
                 }
                 if ($CssPath !== FALSE) {
                     $CssPath = substr($CssPath, strlen(PATH_ROOT));
                     $CssPath = str_replace(DS, '/', $CssPath);
                     $this->Head->AddCss($CssPath, 'all', TRUE, $CssInfo['Options']);
                 }
             }
             // Add a custom js file.
             if (ArrayHasValue($this->_CssFiles, 'style.css')) {
                 $this->AddJsFile('custom.js');
             }
             // only to non-admin pages.
             // And now search for/add all JS files
             foreach ($this->_JsFiles as $Index => $JsInfo) {
                 $JsFile = $JsInfo['FileName'];
                 if (strpos($JsFile, '//') !== FALSE) {
                     // This is a link to an external file.
                     $this->Head->AddScript($JsFile);
                     continue;
                 }
                 if (strpos($JsFile, '/') !== FALSE) {
                     // A direct path to the file was given.
                     $JsPaths = array(CombinePaths(array(PATH_ROOT, str_replace('/', DS, $JsFile)), DS));
                 } else {
                     $AppFolder = $JsInfo['AppFolder'];
                     if ($AppFolder == '') {
//.........这里部分代码省略.........
开发者ID:ru4,项目名称:arabbnota,代码行数:101,代码来源:class.controller.php

示例2: ArrayHasValue

 /**
  * Searches $Array (and all arrays it contains) for $Value.
  */
 function ArrayHasValue($Array, $Value)
 {
     if (in_array($Value, $Array)) {
         return TRUE;
     } else {
         foreach ($Array as $k => $v) {
             if (is_array($v) && ArrayHasValue($v, $Value) === TRUE) {
                 return TRUE;
             }
         }
         return FALSE;
     }
 }
开发者ID:remobjects,项目名称:Garden,代码行数:16,代码来源:functions.general.php

示例3: arrayHasValue

 /**
  * Search an array (and all arrays it contains) for a value.
  *
  * @param array $Array The array to search.
  * @param mixed $Value The value to search for.
  */
 function arrayHasValue($Array, $Value)
 {
     if (in_array($Value, $Array)) {
         return true;
     } else {
         foreach ($Array as $k => $v) {
             if (is_array($v) && ArrayHasValue($v, $Value) === true) {
                 return true;
             }
         }
         return false;
     }
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:19,代码来源:functions.general.php

示例4: RenderMaster


//.........这里部分代码省略.........
                         $CssPaths[] = PATH_PLUGINS . "/{$AppFolder}/design/{$CssFile}";
                         $CssPaths[] = PATH_PLUGINS . "/{$AppFolder}/{$CssFile}";
                     } elseif (in_array($AppFolder, array('static', 'resources'))) {
                         // This is a static css file.
                         $CssPaths[] = PATH_ROOT . "/resources/css/{$CssFile}";
                     } else {
                         // Application default. eg. root/applications/app_name/design/
                         $CssPaths[] = PATH_APPLICATIONS . DS . $AppFolder . DS . 'design' . DS . $CssFile;
                     }
                     // 4. Garden default. eg. root/applications/dashboard/design/
                     $CssPaths[] = PATH_APPLICATIONS . DS . 'dashboard' . DS . 'design' . DS . $CssFile;
                 }
                 // Find the first file that matches the path.
                 $CssPath = FALSE;
                 foreach ($CssPaths as $Glob) {
                     $Paths = SafeGlob($Glob);
                     if (is_array($Paths) && count($Paths) > 0) {
                         $CssPath = $Paths[0];
                         break;
                     }
                 }
                 // Check to see if there is a CSS cacher.
                 $CssCacher = Gdn::Factory('CssCacher');
                 if (!is_null($CssCacher)) {
                     $CssPath = $CssCacher->Get($CssPath, $AppFolder);
                 }
                 if ($CssPath !== FALSE) {
                     $CssPath = substr($CssPath, strlen(PATH_ROOT));
                     $CssPath = str_replace(DS, '/', $CssPath);
                     $this->Head->AddCss($CssPath, 'all', TRUE, $CssInfo['Options']);
                 }
             }
             // Add a custom js file.
             if (ArrayHasValue($this->_CssFiles, 'style.css')) {
                 $this->AddJsFile('custom.js');
             }
             // only to non-admin pages.
             // And now search for/add all JS files.
             $Cdns = array();
             if (Gdn::Request()->Scheme() != 'https' && !C('Garden.Cdns.Disable', FALSE)) {
                 $Cdns = array('jquery.js' => 'http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js');
             }
             $this->EventArguments['Cdns'] =& $Cdns;
             $this->FireEvent('AfterJsCdns');
             foreach ($this->_JsFiles as $Index => $JsInfo) {
                 $JsFile = $JsInfo['FileName'];
                 if (isset($Cdns[$JsFile])) {
                     $JsFile = $Cdns[$JsFile];
                 }
                 if (strpos($JsFile, '//') !== FALSE) {
                     // This is a link to an external file.
                     $this->Head->AddScript($JsFile, 'text/javascript', GetValue('Options', $JsInfo, array()));
                     continue;
                 } elseif (strpos($JsFile, '/') !== FALSE) {
                     // A direct path to the file was given.
                     $JsPaths = array(CombinePaths(array(PATH_ROOT, str_replace('/', DS, $JsFile)), DS));
                 } else {
                     $AppFolder = $JsInfo['AppFolder'];
                     if ($AppFolder == '') {
                         $AppFolder = $this->ApplicationFolder;
                     }
                     // JS can come from a theme, an any of the application folder, or it can come from the global js folder:
                     $JsPaths = array();
                     if ($this->Theme) {
                         // 1. Application-specific js. eg. root/themes/theme_name/app_name/design/
                         $JsPaths[] = PATH_THEMES . DS . $this->Theme . DS . $AppFolder . DS . 'js' . DS . $JsFile;
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:67,代码来源:class.controller.php

示例5: RenderMaster

 /**
  * Undocumented method.
  *
  * @todo Method RenderMaster() needs a description.
  */
 public function RenderMaster()
 {
     // Build the master view if necessary
     if ($this->_DeliveryType == DELIVERY_TYPE_ALL) {
         // Define some default master views unless one was explicitly defined
         if ($this->MasterView == '') {
             // If this is a syndication request, use the appropriate master view
             if ($this->SyndicationMethod == SYNDICATION_ATOM) {
                 $this->MasterView = 'atom';
             } else {
                 if ($this->SyndicationMethod == SYNDICATION_RSS) {
                     $this->MasterView = 'rss';
                 } else {
                     $this->MasterView = 'default';
                 }
             }
             // Otherwise go with the default
         }
         // Only get css & ui components if this is NOT a syndication request
         if ($this->SyndicationMethod == SYNDICATION_NONE && is_object($this->Head)) {
             if (ArrayHasValue($this->_CssFiles, 'style.css')) {
                 $this->AddCssFile('custom.css');
             }
             if (ArrayHasValue($this->_CssFiles, 'admin.css')) {
                 $this->AddCssFile('customadmin.css');
             }
             $this->EventArguments['CssFiles'] =& $this->_CssFiles;
             $this->FireEvent('BeforeAddCss');
             // And now search for/add all css files
             foreach ($this->_CssFiles as $CssInfo) {
                 $CssFile = $CssInfo['FileName'];
                 if (strpos($CssFile, '/') !== FALSE) {
                     // A direct path to the file was given.
                     $CssPaths = array(CombinePaths(array(PATH_ROOT, str_replace('/', DS, $CssFile))));
                 } else {
                     $CssGlob = preg_replace('/(.*)(\\.css)/', '\\1*\\2', $CssFile);
                     $AppFolder = $CssInfo['AppFolder'];
                     if ($AppFolder == '') {
                         $AppFolder = $this->ApplicationFolder;
                     }
                     // CSS comes from one of four places:
                     $CssPaths = array();
                     if ($this->Theme) {
                         // 1. Application-specific css. eg. root/themes/theme_name/app_name/design/
                         // $CssPaths[] = PATH_THEMES . DS . $this->Theme . DS . $AppFolder . DS . 'design' . DS . $CssGlob;
                         // 2. Theme-wide theme view. eg. root/themes/theme_name/design/
                         $CssPaths[] = PATH_THEMES . DS . $this->Theme . DS . 'design' . DS . $CssFile;
                     }
                     // 3. Application default. eg. root/applications/app_name/design/
                     $CssPaths[] = PATH_APPLICATIONS . DS . $AppFolder . DS . 'design' . DS . $CssFile;
                     // 4. Garden default. eg. root/applications/dashboard/design/
                     $CssPaths[] = PATH_APPLICATIONS . DS . 'dashboard' . DS . 'design' . DS . $CssFile;
                 }
                 // Find the first file that matches the path.
                 $CssPath = FALSE;
                 foreach ($CssPaths as $Glob) {
                     $Paths = SafeGlob($Glob);
                     if (is_array($Paths) && count($Paths) > 0) {
                         $CssPath = $Paths[0];
                         break;
                     }
                 }
                 // Check to see if there is a CSS cacher.
                 $CssCacher = Gdn::Factory('CssCacher');
                 if (!is_null($CssCacher)) {
                     $CssPath = $CssCacher->Get($CssPath, $AppFolder);
                 }
                 if ($CssPath !== FALSE) {
                     $CssPath = substr($CssPath, strlen(PATH_ROOT));
                     $CssPath = str_replace(DS, '/', $CssPath);
                     $this->Head->AddCss($CssPath, 'screen');
                 }
             }
             // And now search for/add all JS files
             foreach ($this->_JsFiles as $JsInfo) {
                 $JsFile = $JsInfo['FileName'];
                 if (strpos($JsFile, '/') !== FALSE) {
                     // A direct path to the file was given.
                     $JsPaths = array(CombinePaths(array(PATH_ROOT, str_replace('/', DS, $JsFile)), DS));
                 } else {
                     $AppFolder = $JsInfo['AppFolder'];
                     if ($AppFolder == '') {
                         $AppFolder = $this->ApplicationFolder;
                     }
                     // JS can come from a theme, an any of the application folder, or it can come from the global js folder:
                     $JsPaths = array();
                     if ($this->Theme) {
                         // 1. Application-specific js. eg. root/themes/theme_name/app_name/design/
                         $JsPaths[] = PATH_THEMES . DS . $this->Theme . DS . $AppFolder . DS . 'js' . DS . $JsFile;
                         // 2. Garden-wide theme view. eg. root/themes/theme_name/design/
                         $JsPaths[] = PATH_THEMES . DS . $this->Theme . DS . 'js' . DS . $JsFile;
                     }
                     // 3. This application folder
                     $JsPaths[] = PATH_APPLICATIONS . DS . $AppFolder . DS . 'js' . DS . $JsFile;
                     // 4. Global JS folder. eg. root/js/
//.........这里部分代码省略.........
开发者ID:sipp11,项目名称:Garden,代码行数:101,代码来源:class.controller.php

示例6: Structure

 public function Structure()
 {
     /*		Gdn::Structure()
     			->Table('Comment')
     			->Column('ThankCount', 'usmallint', 0)
     			->Set();
     		
     		Gdn::Structure()
     			->Table('Discussion')
     			->Column('ThankCount', 'usmallint', 0)
     			->Set();*/
     Gdn::Structure()->Table('User')->Column('ReceivedThankCount', 'usmallint', 0)->Set();
     Gdn::Structure()->Table('ThanksLog')->Column('UserID', 'umediumint', False, 'key')->Column('CommentID', 'umediumint', 0)->Column('DiscussionID', 'umediumint', 0)->Column('DateInserted', 'datetime')->Column('InsertUserID', 'umediumint', False, 'key')->Engine('MyISAM')->Set();
     $RequestArgs = Gdn::Controller()->RequestArgs;
     if (ArrayHasValue($RequestArgs, 'vanilla')) {
         ThanksLogModel::RecalculateUserReceivedThankCount();
     }
     //ThanksLogModel::RecalculateCommentThankCount();
     //ThanksLogModel::RecalculateDiscussionThankCount();
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:20,代码来源:class.thankfulpeople.plugin.php

示例7: InformCheckedDiscussions

 /**
  * Looks at the user's attributes and form postback to see if any discussions
  * have been checked for administration, and if so, adds an inform message to
  * $Sender to take action.
  */
 public static function InformCheckedDiscussions($Sender, $Force = FALSE)
 {
     $Session = Gdn::Session();
     $HadCheckedDiscussions = $Force;
     $TransientKey = GetValue('TransientKey', $_POST);
     if ($Session->IsValid() && Gdn::Request()->IsPostBack()) {
         // Form was posted, so accept changes to checked items.
         $CheckIDs = GetValue('CheckIDs', $_POST);
         if (empty($CheckIDs)) {
             $CheckIDs = array();
         }
         $CheckIDs = (array) $CheckIDs;
         $CheckedDiscussions = Gdn::UserModel()->GetAttribute($Session->User->UserID, 'CheckedDiscussions', array());
         if (!is_array($CheckedDiscussions)) {
             $CheckedDiscussions = array();
         }
         // Were there checked discussions before the form was posted?
         $HadCheckedDiscussions |= count($CheckedDiscussions) > 0;
         foreach ($CheckIDs as $Check) {
             if (GetValue('checked', $Check)) {
                 if (!ArrayHasValue($CheckedDiscussions, $Check['checkId'])) {
                     $CheckedDiscussions[] = $Check['checkId'];
                 }
             } else {
                 RemoveValueFromArray($CheckedDiscussions, $Check['checkId']);
             }
         }
         Gdn::UserModel()->SaveAttribute($Session->User->UserID, 'CheckedDiscussions', $CheckedDiscussions);
     } else {
         if ($Session->IsValid()) {
             // No form posted, just retrieve checked items for display
             $CheckedDiscussions = Gdn::UserModel()->GetAttribute($Session->User->UserID, 'CheckedDiscussions', array());
             if (!is_array($CheckedDiscussions)) {
                 $CheckedDiscussions = array();
             }
         }
     }
     // Retrieve some information about the checked items
     $CountDiscussions = count($CheckedDiscussions);
     if ($CountDiscussions > 0) {
         $SelectionMessage = Wrap(sprintf(T('You have selected %1$s.'), Plural($CountDiscussions, '%s discussion', '%s discussions')), 'div');
         $ActionMessage = T('Take Action:');
         $ActionMessage .= ' ' . Anchor(T('Delete'), 'vanilla/moderation/confirmdiscussiondeletes/', 'Delete Popup');
         $ActionMessage .= ' ' . Anchor(T('Move'), 'vanilla/moderation/confirmdiscussionmoves/', 'Move Popup');
         $Sender->EventArguments['SelectionMessage'] =& $SelectionMessage;
         $Sender->EventArguments['ActionMessage'] =& $ActionMessage;
         $Sender->FireEvent('BeforeCheckDiscussions');
         $ActionMessage .= ' ' . Anchor(T('Cancel'), 'vanilla/moderation/cleardiscussionselections/{TransientKey}/?Target={SelfUrl}', 'CancelAction');
         $Sender->InformMessage($SelectionMessage . Wrap($ActionMessage, 'div', array('class' => 'Actions')), array('CssClass' => 'NoDismiss', 'id' => 'CheckSummary'));
     } else {
         if ($HadCheckedDiscussions) {
             // Remove the message completely if there were previously checked comments in this discussion, but none now
             $Sender->InformMessage('', array('id' => 'CheckSummary'));
         }
     }
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:61,代码来源:class.moderationcontroller.php


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