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


PHP TouchValue函数代码示例

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


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

示例1: IsSpam

   /**
    * Check whether or not the record is spam.
    * @param string $RecordType By default, this should be one of the following:
    *  - Comment: A comment.
    *  - Discussion: A discussion.
    *  - User: A user registration.
    * @param array $Data The record data.
    * @param array $Options Options for fine-tuning this method call.
    *  - Log: Log the record if it is found to be spam.
    */
   public static function IsSpam($RecordType, $Data, $Options = array()) {
      // Set some information about the user in the data.
      TouchValue('IPAddress', $Data, Gdn::Request()->IpAddress());
      
      if ($RecordType == 'User') {
         TouchValue('Username', $Data, $Data['Name']);
      } else {
         TouchValue('Username', $Data, Gdn::Session()->User->Name);
         TouchValue('Email', $Data, Gdn::Session()->User->Email);
      }

      $Sp = self::_Instance();
      
      $Sp->EventArguments['RecordType'] = $RecordType;
      $Sp->EventArguments['Data'] = $Data;
      $Sp->EventArguments['Options'] = $Options;
      $Sp->EventArguments['IsSpam'] = FALSE;

      $Sp->FireEvent('CheckSpam');
      $Spam = $Sp->EventArguments['IsSpam'];

      // Log the spam entry.
      if ($Spam && GetValue('Log', $Options, TRUE)) {
         LogModel::Insert('Spam', $RecordType, $Data);
      }

      return $Spam;
   }
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:38,代码来源:class.spammodel.php

示例2: IsSpam

 /**
  * Check whether or not the record is spam.
  * @param string $RecordType By default, this should be one of the following:
  *  - Comment: A comment.
  *  - Discussion: A discussion.
  *  - User: A user registration.
  * @param array $Data The record data.
  * @param array $Options Options for fine-tuning this method call.
  *  - Log: Log the record if it is found to be spam.
  */
 public static function IsSpam($RecordType, $Data, $Options = array())
 {
     // Set some information about the user in the data.
     TouchValue('IPAddress', $Data, Gdn::Request()->IpAddress());
     if ($RecordType == 'Registration') {
         TouchValue('Username', $Data, $Data['Name']);
     } else {
         TouchValue('Username', $Data, Gdn::Session()->User->Name);
         TouchValue('Email', $Data, Gdn::Session()->User->Email);
     }
     $Sp = self::_Instance();
     $Sp->EventArguments['RecordType'] = $RecordType;
     $Sp->EventArguments['Data'] =& $Data;
     $Sp->EventArguments['Options'] =& $Options;
     $Sp->EventArguments['IsSpam'] = FALSE;
     $Sp->FireEvent('CheckSpam');
     $Spam = $Sp->EventArguments['IsSpam'];
     // Log the spam entry.
     if ($Spam && GetValue('Log', $Options, TRUE)) {
         $LogOptions = array();
         switch ($RecordType) {
             case 'Registration':
                 $LogOptions['GroupBy'] = array('RecordIPAddress');
                 break;
             case 'Comment':
             case 'Discussion':
                 $LogOptions['GroupBy'] = array('RecordID');
                 break;
         }
         LogModel::Insert('Spam', $RecordType, $Data, $LogOptions);
     }
     return $Spam;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:43,代码来源:class.spammodel.php

示例3: IsSpam

 /**
  * Check whether or not the record is spam.
  * @param string $RecordType By default, this should be one of the following:
  *  - Comment: A comment.
  *  - Discussion: A discussion.
  *  - User: A user registration.
  * @param array $Data The record data.
  * @param array $Options Options for fine-tuning this method call.
  *  - Log: Log the record if it is found to be spam.
  */
 public static function IsSpam($RecordType, $Data, $Options = array())
 {
     if (self::$Disabled) {
         return FALSE;
     }
     // Set some information about the user in the data.
     if ($RecordType == 'Registration') {
         TouchValue('Username', $Data, $Data['Name']);
     } else {
         TouchValue('InsertUserID', $Data, Gdn::Session()->UserID);
         $User = Gdn::UserModel()->GetID(GetValue('InsertUserID', $Data), DATASET_TYPE_ARRAY);
         if ($User) {
             if (GetValue('Verified', $User)) {
                 // The user has been verified and isn't a spammer.
                 return FALSE;
             }
             TouchValue('Username', $Data, $User['Name']);
             TouchValue('Email', $Data, $User['Email']);
             TouchValue('IPAddress', $Data, $User['LastIPAddress']);
         }
     }
     if (!isset($Data['Body']) && isset($Data['Story'])) {
         $Data['Body'] = $Data['Story'];
     }
     TouchValue('IPAddress', $Data, Gdn::Request()->IpAddress());
     $Sp = self::_Instance();
     $Sp->EventArguments['RecordType'] = $RecordType;
     $Sp->EventArguments['Data'] =& $Data;
     $Sp->EventArguments['Options'] =& $Options;
     $Sp->EventArguments['IsSpam'] = FALSE;
     $Sp->FireEvent('CheckSpam');
     $Spam = $Sp->EventArguments['IsSpam'];
     // Log the spam entry.
     if ($Spam && GetValue('Log', $Options, TRUE)) {
         $LogOptions = array();
         switch ($RecordType) {
             case 'Registration':
                 $LogOptions['GroupBy'] = array('RecordIPAddress');
                 break;
             case 'Comment':
             case 'Discussion':
             case 'Activity':
             case 'ActivityComment':
                 $LogOptions['GroupBy'] = array('RecordID');
                 break;
         }
         LogModel::Insert('Spam', $RecordType, $Data, $LogOptions);
     }
     return $Spam;
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:60,代码来源:class.spammodel.php

示例4: SmallImage

 function SmallImage($Source, $Attributes = array())
 {
     if (function_exists('Debug') && Debug()) {
         trigger_error('SmallImage() is deprecated. Use Thumbnail().', E_USER_DEPRECATED);
     }
     $Width = ArrayValue('width', $Attributes, '');
     $Height = ArrayValue('height', $Attributes, '');
     $ImageQuality = GetValue('ImageQuality', $Attributes, 100, True);
     $Crop = GetValue('Crop', $Attributes, False, True);
     $Hash = Crc32Value($Source, array($Width, $Height, $ImageQuality, $Crop));
     $TargetFolder = 'uploads/cached';
     // cache directory
     if (!is_dir($TargetFolder)) {
         mkdir($TargetFolder, 0777, True);
     }
     $Filename = pathinfo($Source, 8);
     $Extension = pathinfo($Source, 4);
     $SmallImage = GenerateCleanTargetName($TargetFolder, $Filename . '-' . $Hash, $Extension, False, True);
     if (!file_exists($SmallImage)) {
         Gdn_UploadImage::SaveImageAs($Source, $SmallImage, $Height, $Width, $Crop);
     }
     if (GetValue('MakeOnly', $Attributes, False, True)) {
         if (GetValue('OutOriginalImageSize', $Attributes, False, True)) {
             // TEMP, TODO: FIX ME
             $Return = array();
             $Return['ImageSize'] = getimagesize($Source);
             $Return['Result'] = Url($SmallImage);
             return $Return;
         }
         return Url($SmallImage);
     }
     TouchValue('alt', $Attributes, $Filename);
     // Fail. ImageSY expects parameter 1 to be resource
     //if (!array_key_exists('height', $Attributes)) TouchValue('height', $Attributes, ImageSY($SmallImage));
     //if (!array_key_exists('width', $Attributes)) TouchValue('width', $Attributes, ImageSX($SmallImage));
     return Img($SmallImage, $Attributes);
 }
开发者ID:ru4,项目名称:arabbnota,代码行数:37,代码来源:functions.deprecated.php

示例5: ClientRequest

 /**
  * Perform client request to server.
  * Options: see here http://www.php.net/manual/en/function.curl-setopt.php
  * Bool options: 
  * 	ReturnTransfer, Post, FollowLocation, Header
  * Integer options: 
  * 	ConnectTimeout, Timeout, Timeout_Ms
  * Other options: 
  * 	Url, Cookie, CookieFile, CustomRequest, PostFields, Referer, UserAgent, UserPwd
  * 
  * @param mixed $Url or array $Options.
  * @return mixed $Result.
  */
 function ClientRequest($Url, $Options = False)
 {
     static $Connections = array();
     static $ManualFollowLocation;
     $NumArgs = func_num_args();
     if ($NumArgs == 1) {
         $Options = $Url;
         if (is_string($Options)) {
             $Options = array('Url' => $Options);
         }
     } else {
         $Options['Url'] = $Url;
     }
     $NewOptions = $Options;
     $Cache = GetValue('Cache', $Options, False, True);
     if ($Cache !== False) {
         $Crc = sprintf('%u', crc32(serialize($Options)));
         $CacheDirectory = PATH_CACHE . '/client-request';
         $CacheFile = $CacheDirectory . DS . $Crc . '.php';
         if (file_exists($CacheFile)) {
             $IncludeCache = True;
             if (is_int($Cache)) {
                 $LifeTime = time() - filemtime($CacheFile);
                 $Expired = $LifeTime > $Cache;
                 if ($Expired) {
                     $IncludeCache = False;
                 }
             }
             if ($IncludeCache) {
                 $Result = (include $CacheFile);
                 return $Result;
             }
         }
     }
     $Url = GetValue('Url', $Options, False, True);
     $ConvertEncoding = GetValue('ConvertEncoding', $Options, False, True);
     $Header = GetValue('Header', $Options);
     $FollowLocation = GetValue('FollowLocation', $Options);
     if ($FollowLocation) {
         if ($ManualFollowLocation === Null) {
             $ManualFollowLocation = array_filter(array_map('ini_get', array('safe_mode', 'open_basedir'))) > 0;
         }
         if ($ManualFollowLocation) {
             unset($Options['FollowLocation']);
         }
     }
     $GetInfo = GetValue('GetInfo', $Options, False, True);
     TouchValue('ReturnTransfer', $Options, True);
     //TouchValue('ConnectTimeout', $Options, 30);
     //TouchValue('Timeout', $Options, 5);
     if (!array_key_exists($Url, $Connections)) {
         $Connections[$Url] = curl_init($Url);
     }
     $Connection =& $Connections[$Url];
     foreach ($Options as $Option => $Value) {
         $Constant = 'CURLOPT_' . strtoupper($Option);
         if (!defined($Constant)) {
             $InfoConstant = 'CURLINFO_' . strtoupper($Option);
             if (!defined($InfoConstant)) {
                 trigger_error("cURL. Unknown option: {$Constant} ({$InfoConstant})");
             } else {
                 $Constant = $InfoConstant;
             }
         }
         curl_setopt($Connection, constant($Constant), $Value);
     }
     $Result = curl_exec($Connection);
     if ($Result === False) {
         $ErrorMessage = curl_error($Connection);
         //$ErrorNo = curl_errno($Connection);
         trigger_error($ErrorMessage);
         return False;
     }
     if ($Header != False) {
         $ResponseLines = explode("\n", trim($Result));
         $Status = array_shift($ResponseLines);
         $Response = array();
         $Response['HTTP'] = trim($Status);
         $Response['StatusCode'] = array_pop(array_slice(explode(' ', trim($Status)), 1, 1));
         for ($Count = count($ResponseLines), $i = 0; $i < $Count; $i++) {
             $Line = trim($ResponseLines[$i]);
             unset($ResponseLines[$i]);
             if ($Line === '') {
                 break;
             }
             $Line = explode(':', $Line);
             $Key = trim(array_shift($Line));
//.........这里部分代码省略.........
开发者ID:unlight,项目名称:UsefulFunctions,代码行数:101,代码来源:functions.network.php

示例6: socialSignInButton

 function socialSignInButton($Name, $Url, $Type = 'button', $Attributes = array())
 {
     TouchValue('title', $Attributes, sprintf(T('Sign In with %s'), $Name));
     $Title = $Attributes['title'];
     $Class = val('class', $Attributes, '');
     unset($Attributes['class']);
     switch ($Type) {
         case 'icon':
             $Result = Anchor('<span class="Icon"></span>', $Url, 'SocialIcon SocialIcon-' . $Name . ' ' . $Class, $Attributes);
             break;
         case 'button':
         default:
             $Result = Anchor('<span class="Icon"></span><span class="Text">' . $Title . '</span>', $Url, 'SocialIcon SocialIcon-' . $Name . ' HasText ' . $Class, $Attributes);
             break;
     }
     return $Result;
 }
开发者ID:mcnasby,项目名称:datto-vanilla,代码行数:17,代码来源:functions.render.php

示例7: Save

 /**
  * Save message from form submission.
  * 
  * @since 2.0.0
  * @access public
  *
  * @param array $FormPostValues Values submitted via form.
  * @return int Unique ID of message created or updated.
  */
 public function Save($FormPostValues, $Conversation = NULL)
 {
     $Session = Gdn::Session();
     // Define the primary key in this model's table.
     $this->DefineSchema();
     // Add & apply any extra validation rules:
     $this->Validation->ApplyRule('Body', 'Required');
     $this->AddInsertFields($FormPostValues);
     // Validate the form posted values
     $MessageID = FALSE;
     if ($this->Validate($FormPostValues)) {
         $Fields = $this->Validation->SchemaValidationFields();
         // All fields on the form that relate to the schema
         TouchValue('Format', $Fields, C('Garden.InputFormatter', 'Html'));
         $MessageID = $this->SQL->Insert($this->Name, $Fields);
         $this->LastMessageID = $MessageID;
         $ConversationID = ArrayValue('ConversationID', $Fields, 0);
         if (!$Conversation) {
             $Conversation = $this->SQL->GetWhere('Conversation', array('ConversationID' => $ConversationID))->FirstRow(DATASET_TYPE_ARRAY);
         }
         // Get the new message count for the conversation.
         $SQLR = $this->SQL->Select('MessageID', 'count', 'CountMessages')->Select('MessageID', 'max', 'LastMessageID')->From('ConversationMessage')->Where('ConversationID', $ConversationID)->Get()->FirstRow(DATASET_TYPE_ARRAY);
         if (sizeof($SQLR)) {
             list($CountMessages, $LastMessageID) = array_values($SQLR);
         } else {
             return;
         }
         // Update the conversation's DateUpdated field.
         $DateUpdated = Gdn_Format::ToDateTime();
         $this->SQL->Update('Conversation c')->Set('CountMessages', $CountMessages)->Set('LastMessageID', $LastMessageID)->Set('UpdateUserID', Gdn::Session()->UserID)->Set('DateUpdated', $DateUpdated)->Where('ConversationID', $ConversationID)->Put();
         // Update the last message of the users that were previously up-to-date on their read messages.
         $this->SQL->Update('UserConversation uc')->Set('uc.LastMessageID', $MessageID)->Set('uc.DateConversationUpdated', $DateUpdated)->Where('uc.ConversationID', $ConversationID)->Where('uc.Deleted', '0')->Where('uc.CountReadMessages', $CountMessages - 1)->Where('uc.UserID <>', $Session->UserID)->Put();
         // Update the date updated of the users that were not up-to-date.
         $this->SQL->Update('UserConversation uc')->Set('uc.DateConversationUpdated', $DateUpdated)->Where('uc.ConversationID', $ConversationID)->Where('uc.Deleted', '0')->Where('uc.CountReadMessages <>', $CountMessages - 1)->Where('uc.UserID <>', $Session->UserID)->Put();
         // Update the sending user.
         $this->SQL->Update('UserConversation uc')->Set('uc.CountReadMessages', $CountMessages)->Set('Deleted', 0)->Set('uc.DateConversationUpdated', $DateUpdated)->Where('ConversationID', $ConversationID)->Where('UserID', $Session->UserID)->Put();
         // Find users involved in this conversation
         $UserData = $this->SQL->Select('UserID')->Select('LastMessageID')->Select('Deleted')->From('UserConversation')->Where('ConversationID', $ConversationID)->Get()->Result(DATASET_TYPE_ARRAY);
         $UpdateCountUserIDs = array();
         $NotifyUserIDs = array();
         // Collapse for call to UpdateUserCache and ActivityModel.
         $InsertUserFound = FALSE;
         foreach ($UserData as $UpdateUser) {
             $LastMessageID = GetValue('LastMessageID', $UpdateUser);
             $UserID = GetValue('UserID', $UpdateUser);
             $Deleted = GetValue('Deleted', $UpdateUser);
             if ($UserID == GetValue('InsertUserID', $Fields)) {
                 $InsertUserFound = TRUE;
                 if ($Deleted) {
                     $this->SQL->Put('UserConversation', array('Deleted' => 0, 'DateConversationUpdated' => $DateUpdated), array('ConversationID' => $ConversationID, 'UserID' => $UserID));
                 }
             }
             // Update unread for users that were up to date
             if ($LastMessageID == $MessageID) {
                 $UpdateCountUserIDs[] = $UserID;
             }
             // Send activities to users that have not deleted the conversation
             if (!$Deleted) {
                 $NotifyUserIDs[] = $UserID;
             }
         }
         if (!$InsertUserFound) {
             $UserConversation = array('UserID' => GetValue('InsertUserID', $Fields), 'ConversationID' => $ConversationID, 'LastMessageID' => $LastMessageID, 'CountReadMessages' => $CountMessages, 'DateConversationUpdated' => $DateUpdated);
             $this->SQL->Insert('UserConversation', $UserConversation);
         }
         if (sizeof($UpdateCountUserIDs)) {
             $ConversationModel = new ConversationModel();
             $ConversationModel->UpdateUserUnreadCount($UpdateCountUserIDs, TRUE);
         }
         $ActivityModel = new ActivityModel();
         foreach ($NotifyUserIDs as $NotifyUserID) {
             if ($Session->UserID == $NotifyUserID) {
                 continue;
             }
             // don't notify self.
             // Notify the users of the new message.
             $ActivityID = $ActivityModel->Add($Session->UserID, 'ConversationMessage', '', $NotifyUserID, '', "/messages/{$ConversationID}#{$MessageID}", FALSE);
             $Story = GetValue('Body', $Fields, '');
             if (C('Conversations.Subjects.Visible')) {
                 $Story = ConcatSep("\n\n", GetValue('Subject', $Conversation, ''), $Story);
             }
             $ActivityModel->SendNotification($ActivityID, $Story);
         }
     }
     return $MessageID;
 }
开发者ID:rnovino,项目名称:Garden,代码行数:95,代码来源:class.conversationmessagemodel.php

示例8: link

 /**
  *
  *
  * @param $Path
  * @param bool $Text
  * @param null $Format
  * @param array $Options
  * @return mixed|null|string
  */
 public static function link($Path, $Text = false, $Format = null, $Options = array())
 {
     $Session = Gdn::session();
     $Class = val('class', $Options, '');
     $WithDomain = val('WithDomain', $Options);
     $Target = val('Target', $Options, '');
     if ($Target == 'current') {
         $Target = trim(url('', true), '/ ');
     }
     if (is_null($Format)) {
         $Format = '<a href="%url" class="%class">%text</a>';
     }
     switch ($Path) {
         case 'activity':
             touchValue('Permissions', $Options, 'Garden.Activity.View');
             break;
         case 'category':
             $Breadcrumbs = Gdn::controller()->data('Breadcrumbs');
             if (is_array($Breadcrumbs) && count($Breadcrumbs) > 0) {
                 $Last = array_pop($Breadcrumbs);
                 $Path = val('Url', $Last);
                 $DefaultText = val('Name', $Last, T('Back'));
             } else {
                 $Path = '/';
                 $DefaultText = c('Garden.Title', T('Back'));
             }
             if (!$Text) {
                 $Text = $DefaultText;
             }
             break;
         case 'dashboard':
             $Path = 'dashboard/settings';
             touchValue('Permissions', $Options, array('Garden.Settings.Manage', 'Garden.Settings.View'));
             if (!$Text) {
                 $Text = t('Dashboard');
             }
             break;
         case 'home':
             $Path = '/';
             if (!$Text) {
                 $Text = t('Home');
             }
             break;
         case 'inbox':
             $Path = 'messages/inbox';
             touchValue('Permissions', $Options, 'Garden.SignIn.Allow');
             if (!$Text) {
                 $Text = t('Inbox');
             }
             if ($Session->isValid() && $Session->User->CountUnreadConversations) {
                 $Class = trim($Class . ' HasCount');
                 $Text .= ' <span class="Alert">' . $Session->User->CountUnreadConversations . '</span>';
             }
             if (!$Session->isValid() || !Gdn::applicationManager()->checkApplication('Conversations')) {
                 $Text = false;
             }
             break;
         case 'forumroot':
             $Route = Gdn::router()->getDestination('DefaultForumRoot');
             if (is_null($Route)) {
                 $Path = '/';
             } else {
                 $Path = combinePaths(array('/', $Route));
             }
             break;
         case 'profile':
             touchValue('Permissions', $Options, 'Garden.SignIn.Allow');
             if (!$Text && $Session->isValid()) {
                 $Text = $Session->User->Name;
             }
             if ($Session->isValid() && $Session->User->CountNotifications) {
                 $Class = trim($Class . ' HasCount');
                 $Text .= ' <span class="Alert">' . $Session->User->CountNotifications . '</span>';
             }
             break;
         case 'user':
             $Path = 'profile';
             touchValue('Permissions', $Options, 'Garden.SignIn.Allow');
             if (!$Text && $Session->isValid()) {
                 $Text = $Session->User->Name;
             }
             break;
         case 'photo':
             $Path = 'profile';
             TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
             if (!$Text && $Session->isValid()) {
                 $IsFullPath = strtolower(substr($Session->User->Photo, 0, 7)) == 'http://' || strtolower(substr($Session->User->Photo, 0, 8)) == 'https://';
                 $PhotoUrl = $IsFullPath ? $Session->User->Photo : Gdn_Upload::url(changeBasename($Session->User->Photo, 'n%s'));
                 $Text = img($PhotoUrl, array('alt' => $Session->User->Name));
             }
             break;
//.........这里部分代码省略.........
开发者ID:mcnasby,项目名称:datto-vanilla,代码行数:101,代码来源:class.theme.php

示例9: FlashObject

 function FlashObject($Movie, $Attributes = array(), $FlashVars = False)
 {
     //static $Defaults = array('allowfullscreen' => 'true', 'allowscriptaccess' => 'always', 'quality' => 'best', 'menu' => 'false');
     //$Attributes = array_merge($Defaults, $Attributes);
     $ScriptRender = GetValue('ScriptRender', $Attributes, False, True);
     $FlashVars = GetValue('FlashVars', $Attributes, $FlashVars, True);
     $Params = GetValue('Params', $Attributes, array(), True);
     $Movie = Asset($Movie, True);
     $AltContent = GetValue('AltContent', $Attributes, Anchor(Img('http://wwwimages.adobe.com/www.adobe.com/images/shared/download_buttons/get_flash_player.gif', array('alt' => 'Get Adobe Flash player')), 'http://www.adobe.com/go/getflashplayer', '', array('rel' => 'nofollow'), True), True);
     foreach (array('wmode', 'allowfullscreen', 'allowscriptaccess', 'quality', 'menu') as $Name) {
         $Value = GetValue($Name, $Attributes, False, True);
         if ($Value !== False) {
             $Params[$Name] = $Value;
         }
     }
     if (!array_key_exists('width', $Attributes) || !array_key_exists('height', $Attributes)) {
         $ImageInfo = GetImageSize($Movie);
         TouchValue('width', $Attributes, $ImageInfo[0]);
         TouchValue('height', $Attributes, $ImageInfo[1]);
     }
     $Attributes['type'] = 'application/x-shockwave-flash';
     $Attributes['data'] = $Movie;
     $HtmlParams = Wrap('', 'param', array('name' => 'movie', 'value' => $Movie));
     foreach ($Params as $Name => $Value) {
         $HtmlParams .= Wrap('', 'param', array('name' => $Name, 'value' => $Value));
     }
     if (is_array($FlashVars)) {
         foreach ($FlashVars as $Name => $Value) {
             $Variables[] = $Name . '=' . urlencode($Value);
         }
     }
     if (isset($Variables)) {
         $HtmlParams .= Wrap('', 'param', array('name' => 'flashvars', 'value' => implode('&', $Variables)));
     }
     /*		$Agent = ArrayValue('HTTP_USER_AGENT', $_SERVER);
     		if ($Agent != False && stripos($Agent, 'MSIE ') > 0) {
     			$Attributes['classid'] = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';
     		}*/
     $Return = Wrap($HtmlParams . $AltContent, 'object', $Attributes);
     //d($Return);
     if ($ScriptRender) {
         $Return = JavaScript($Return, True);
     }
     return $Return;
 }
开发者ID:unlight,项目名称:UsefulFunctions,代码行数:45,代码来源:functions.output.php

示例10: RenderMaster


//.........这里部分代码省略.........
                     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. The application or plugin folder.
                     if (StringBeginsWith(trim($AppFolder, '/'), 'plugins/')) {
                         $JsPaths[] = PATH_PLUGINS . strstr($AppFolder, '/') . "/js/{$JsFile}";
                         $JsPaths[] = PATH_PLUGINS . strstr($AppFolder, '/') . "/{$JsFile}";
                     } else {
                         $JsPaths[] = PATH_APPLICATIONS . "/{$AppFolder}/js/{$JsFile}";
                     }
                     // 4. Global JS folder. eg. root/js/
                     $JsPaths[] = PATH_ROOT . DS . 'js' . DS . $JsFile;
                     // 5. Global JS library folder. eg. root/js/library/
                     $JsPaths[] = PATH_ROOT . DS . 'js' . DS . 'library' . DS . $JsFile;
                 }
                 // Find the first file that matches the path.
                 $JsPath = FALSE;
                 foreach ($JsPaths as $Glob) {
                     $Paths = SafeGlob($Glob);
                     if (is_array($Paths) && count($Paths) > 0) {
                         $JsPath = $Paths[0];
                         break;
                     }
                 }
                 if ($JsPath !== FALSE) {
                     $JsSrc = str_replace(array(PATH_ROOT, DS), array('', '/'), $JsPath);
                     $Options = (array) $JsInfo['Options'];
                     $Options['path'] = $JsPath;
                     $Version = GetValue('Version', $JsInfo);
                     if ($Version) {
                         TouchValue('version', $Options, $Version);
                     }
                     $this->Head->AddScript($JsSrc, 'text/javascript', $Options);
                 }
             }
         }
         // 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();
     $MasterViewPath2 = ViewLocation($this->MasterView() . '.master', '', $this->ApplicationFolder);
     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. Application default. eg. root/app_name/views/
         $MasterViewPaths[] = CombinePaths(array(PATH_APPLICATIONS, $this->ApplicationFolder, 'views', $this->MasterView . '.master*'));
         // 4. 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;
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:67,代码来源:class.controller.php

示例11: Save

   /**
    * Generic save procedure.
    */
   public function Save($FormPostValues, $Settings = FALSE) {
      // See if the user's related roles should be saved or not.
      $SaveRoles = ArrayValue('SaveRoles', $Settings);

      // Define the primary key in this model's table.
      $this->DefineSchema();

      // Add & apply any extra validation rules:
      if (array_key_exists('Email', $FormPostValues))
         $this->Validation->ApplyRule('Email', 'Email');

      // Custom Rule: This will make sure that at least one role was selected if saving roles for this user.
      if ($SaveRoles) {
         $this->Validation->AddRule('OneOrMoreArrayItemRequired', 'function:ValidateOneOrMoreArrayItemRequired');
         // $this->Validation->AddValidationField('RoleID', $FormPostValues);
         $this->Validation->ApplyRule('RoleID', 'OneOrMoreArrayItemRequired');
      }

      // Make sure that the checkbox val for email is saved as the appropriate enum
      if (array_key_exists('ShowEmail', $FormPostValues))
         $FormPostValues['ShowEmail'] = ForceBool($FormPostValues['ShowEmail'], '0', '1', '0');

      // Validate the form posted values
      $UserID = GetValue('UserID', $FormPostValues);
      $Insert = $UserID > 0 ? FALSE : TRUE;
      if ($Insert) {
         $this->AddInsertFields($FormPostValues);
      } else {
         $this->AddUpdateFields($FormPostValues);
      }
      
      $this->EventArguments['FormPostValues'] = $FormPostValues;
      $this->FireEvent('BeforeSaveValidation');

      $RecordRoleChange = TRUE;
      if ($this->Validate($FormPostValues, $Insert) && $this->ValidateUniqueFields(GetValue('Name', $FormPostValues), GetValue('Email', $FormPostValues), $UserID)) {
         $Fields = $this->Validation->ValidationFields(); // All fields on the form that need to be validated (including non-schema field rules defined above)
         $RoleIDs = GetValue('RoleID', $Fields, 0);
         $Username = GetValue('Name', $Fields);
         $Email = GetValue('Email', $Fields);
         $Fields = $this->Validation->SchemaValidationFields(); // Only fields that are present in the schema
         // Remove the primary key from the fields collection before saving
         $Fields = RemoveKeyFromArray($Fields, $this->PrimaryKey);
         
         if (!$Insert && array_key_exists('Password', $Fields)) {
            // Encrypt the password for saving only if it won't be hashed in _Insert()
            $PasswordHash = new Gdn_PasswordHash();
            $Fields['Password'] = $PasswordHash->HashPassword($Fields['Password']);
            $Fields['HashMethod'] = 'Vanilla';
         }
         
         // Check for email confirmation.
         if (C('Garden.Registration.ConfirmEmail') && !GetValue('NoConfirmEmail', $Settings)) {
            if (isset($Fields['Email']) && $UserID == Gdn::Session()->UserID && $Fields['Email'] != Gdn::Session()->User->Email && !Gdn::Session()->CheckPermission('Garden.Users.Edit')) {
               $User = Gdn::Session()->User;
               $Attributes = Gdn::Session()->User->Attributes;
               $EmailKey = TouchValue('EmailKey', $Attributes, RandomString(8));

               if ($RoleIDs)
                  $ConfirmedEmailRoles = $RoleIDs;
               else
                  $ConfirmedEmailRoles = ConsolidateArrayValuesByKey($this->GetRoles($UserID), 'RoleID');
               $Attributes['ConfirmedEmailRoles'] = $ConfirmedEmailRoles;

               $RoleIDs = (array)C('Garden.Registration.ConfirmEmailRole');
               $SaveRoles = TRUE;
               $Fields['Attributes'] = serialize($Attributes);
            } 
         }
         
         $this->EventArguments['Fields'] = $Fields;
         $this->FireEvent('BeforeSave');
         
         // Check the validation results again in case something was added during the BeforeSave event.
         if (count($this->Validation->Results()) == 0) {
            // If the primary key exists in the validated fields and it is a
            // numeric value greater than zero, update the related database row.
            if ($UserID > 0) {
               // If they are changing the username & email, make sure they aren't
               // already being used (by someone other than this user)
               if (ArrayValue('Name', $Fields, '') != '' || ArrayValue('Email', $Fields, '') != '') {
                  if (!$this->ValidateUniqueFields($Username, $Email, $UserID))
                     return FALSE;
               }
   
               $this->SQL->Put($this->Name, $Fields, array($this->PrimaryKey => $UserID));
   
               // Record activity if the person changed his/her photo.
               $Photo = ArrayValue('Photo', $FormPostValues);
               if ($Photo !== FALSE) {
                  if (GetValue('CheckExisting', $Settings)) {
                     $User = $this->Get($UserID);
                     $OldPhoto = GetValue('Photo', $User);
                  }

                  if (!isset($OldPhoto) || $Photo != $Photo) {
                     if (strpos($Photo, '//'))
//.........这里部分代码省略.........
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:101,代码来源:class.usermodel.php

示例12: Link

   public static function Link($Path, $Text = FALSE, $Format = '<a href="%url" class="%class">%text</a>', $Options = array()) {
      $Session = Gdn::Session();
      $Class = GetValue('class', $Options, '');
      $WithDomain = GetValue('WithDomain', $Options);
      $Target = GetValue('Target', $Options, '');

      switch ($Path) {
         case 'activity':
            TouchValue('Permissions', $Options, 'Garden.Activity.View');
            break;
         case 'dashboard':
            $Path = 'dashboard/settings';
            TouchValue('Permissions', $Options, 'Garden.Settings.Manage');
            if (!$Text)
               $Text = T('Dashboard');
            break;
         case 'inbox':
            $Path = 'messages/inbox';
            TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
            if (!$Text)
               $Text = T('Inbox');
            if ($Session->IsValid() && $Session->User->CountUnreadConversations) {
               $Class = trim($Class.' HasCount');
               $Text .= ' <span class="Alert">'.$Session->User->CountUnreadConversations.'</span>';
            }
            break;
         case 'profile':
            TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
            if (!$Text && $Session->IsValid())
               $Text = $Session->User->Name;
            if ($Session->IsValid() && $Session->User->CountNotifications) {
               $Class = trim($Class.' HasCount');
               $Text .= ' <span class="Alert">'.$Session->User->CountNotifications.'</span>';
            }
            break;
         case 'user':
            $Path = 'profile';
            TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
            if (!$Text && $Session->IsValid())
               $Text = $Session->User->Name;

            break;
         case 'photo':
            $Path = 'profile';
            TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
            if (!$Text && $Session->IsValid()) {
               $IsFullPath = strtolower(substr($Session->User->Photo, 0, 7)) == 'http://' || strtolower(substr($Session->User->Photo, 0, 8)) == 'https://';
               $PhotoUrl = ($IsFullPath) ? $Session->User->Photo : Gdn_Upload::Url(ChangeBasename($Session->User->Photo, 'n%s'));
               $Text = Img($PhotoUrl, array('alt' => htmlspecialchars($Session->User->Name)));
            }

            break;
         case 'drafts':
            TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
            if (!$Text)
               $Text = T('My Drafts');
            if ($Session->IsValid() && $Session->User->CountDrafts) {
               $Class = trim($Class.' HasCount');
               $Text .= ' <span class="Alert">'.$Session->User->CountDrafts.'</span>';
            }
            break;
         case 'discussions/bookmarked':
            TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
            if (!$Text)
               $Text = T('My Bookmarks');
            if ($Session->IsValid() && $Session->User->CountBookmarks) {
               $Class = trim($Class.' HasCount');
               $Text .= ' <span class="Count">'.$Session->User->CountBookmarks.'</span>';
            }
            break;
         case 'discussions/mine':
            TouchValue('Permissions', $Options, 'Garden.SignIn.Allow');
            if (!$Text)
               $Text = T('My Discussions');
            if ($Session->IsValid() && $Session->User->CountDiscussions) {
               $Class = trim($Class.' HasCount');
               $Text .= ' <span class="Count">'.$Session->User->CountDiscussions.'</span>';
            }
            break;
         case 'signin':
         case 'signinout':
            // The destination is the signin/signout toggle link.
            if ($Session->IsValid()) {
               if(!$Text)
                  $Text = T('Sign Out');
               $Path =  SignOutUrl($Target);
               $Class = ConcatSep(' ', $Class, 'SignOut');
            } else {
               if(!$Text)
                  $Text = T('Sign In');
               $Attribs = array();

               $Path = SignInUrl($Target);
               if (SignInPopup() && strpos(Gdn::Request()->Url(), 'entry') === FALSE)
                  $Class = ConcatSep(' ', $Class, 'SignInPopup');
            }
            break;
      }

      if (GetValue('Permissions', $Options) && !$Session->CheckPermission($Options['Permissions']))
//.........这里部分代码省略.........
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:101,代码来源:class.theme.php

示例13: JoinRecentPosts

 public static function JoinRecentPosts(&$Data)
 {
     $DiscussionIDs = array();
     $CommentIDs = array();
     $Joined = FALSE;
     foreach ($Data as &$Row) {
         if (isset($Row['LastTitle']) && $Row['LastTitle']) {
             continue;
         }
         if ($Row['LastDiscussionID']) {
             $DiscussionIDs[] = $Row['LastDiscussionID'];
         }
         if ($Row['LastCommentID']) {
             $CommentIDs[] = $Row['LastCommentID'];
         }
         $Joined = TRUE;
     }
     // Grab the discussions.
     if (count($DiscussionIDs) > 0) {
         $Discussions = Gdn::SQL()->WhereIn('DiscussionID', $DiscussionIDs)->Get('Discussion')->ResultArray();
         $Discussions = Gdn_DataSet::Index($Discussions, array('DiscussionID'));
     }
     if (count($CommentIDs) > 0) {
         $Comments = Gdn::SQL()->WhereIn('CommentID', $CommentIDs)->Get('Comment')->ResultArray();
         $Comments = Gdn_DataSet::Index($Comments, array('CommentID'));
     }
     foreach ($Data as &$Row) {
         $Discussion = GetValue($Row['LastDiscussionID'], $Discussions);
         if ($Discussion) {
             $Row['LastTitle'] = Gdn_Format::Text($Discussion['Name']);
             $Row['LastUserID'] = $Discussion['InsertUserID'];
             $Row['LastDateInserted'] = $Discussion['DateInserted'];
             $Row['LastUrl'] = "/discussion/{$Discussion['DiscussionID']}/" . Gdn_Format::Text($Discussion['Name']);
         }
         $Comment = GetValue($Row['LastCommentID'], $Comments);
         if ($Comment) {
             $Row['LastUserID'] = $Comment['InsertUserID'];
             $Row['LastDateInserted'] = $Comment['DateInserted'];
             $Row['LastUrl'] = "/discussion/comment/{$Comment['CommentID']}#Comment_{$Comment['CommentID']}";
         } else {
             $Row['NoComment'] = TRUE;
         }
         TouchValue('LastTitle', $Row, '');
         TouchValue('LastUserID', $Row, NULL);
         TouchValue('LastDateInserted', $Row, NULL);
         TouchValue('LastUrl', $Row, NULL);
     }
     return $Joined;
 }
开发者ID:Raz0r,项目名称:Garden,代码行数:49,代码来源:class.categorymodel.php

示例14: AddInsertFields

 public function AddInsertFields(&$Fields)
 {
     $this->DefineSchema();
     // Set the hour offset based on the client's clock.
     $ClientHour = ArrayValue('ClientHour', $Fields, '');
     if (is_numeric($ClientHour) && $ClientHour >= 0 && $ClientHour < 24) {
         $HourOffset = $ClientHour - date('G', time());
         $Fields['HourOffset'] = $HourOffset;
     }
     // Set some required dates.
     $Now = Gdn_Format::ToDateTime();
     $Fields[$this->DateInserted] = $Now;
     TouchValue('DateFirstVisit', $Fields, $Now);
     $Fields['DateLastActive'] = $Now;
     $Fields['InsertIPAddress'] = Gdn::Request()->IpAddress();
     $Fields['LastIPAddress'] = Gdn::Request()->IpAddress();
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:17,代码来源:class.usermodel.php

示例15: Save

 /**
  * Generic save procedure.
  */
 public function Save($FormPostValues, $Settings = FALSE)
 {
     // See if the user's related roles should be saved or not.
     $SaveRoles = GetValue('SaveRoles', $Settings);
     // Define the primary key in this model's table.
     $this->DefineSchema();
     // Custom Rule: This will make sure that at least one role was selected if saving roles for this user.
     if ($SaveRoles) {
         $this->Validation->AddRule('OneOrMoreArrayItemRequired', 'function:ValidateOneOrMoreArrayItemRequired');
         // $this->Validation->AddValidationField('RoleID', $FormPostValues);
         $this->Validation->ApplyRule('RoleID', 'OneOrMoreArrayItemRequired');
     }
     // Make sure that checkbox vals are saved as the appropriate value
     if (array_key_exists('ShowEmail', $FormPostValues)) {
         $FormPostValues['ShowEmail'] = ForceBool($FormPostValues['ShowEmail'], '0', '1', '0');
     }
     if (array_key_exists('Banned', $FormPostValues)) {
         $FormPostValues['Banned'] = ForceBool($FormPostValues['Banned'], '0', '1', '0');
     }
     if (array_key_exists('Confirmed', $FormPostValues)) {
         $FormPostValues['Confirmed'] = ForceBool($FormPostValues['Confirmed'], '0', '1', '0');
     }
     // Validate the form posted values
     $UserID = GetValue('UserID', $FormPostValues);
     $User = array();
     $Insert = $UserID > 0 ? FALSE : TRUE;
     if ($Insert) {
         $this->AddInsertFields($FormPostValues);
     } else {
         $this->AddUpdateFields($FormPostValues);
         $User = $this->GetID($UserID, DATASET_TYPE_ARRAY);
         // Block banning the superadmin or System accounts
         if (GetValue('Admin', $User) == 2 && GetValue('Banned', $FormPostValues)) {
             $this->Validation->AddValidationResult('Banned', 'You may not ban a System user.');
         } elseif (GetValue('Admin', $User) && GetValue('Banned', $FormPostValues)) {
             $this->Validation->AddValidationResult('Banned', 'You may not ban a user with the Admin flag set.');
         }
     }
     $this->EventArguments['FormPostValues'] = $FormPostValues;
     $this->FireEvent('BeforeSaveValidation');
     $RecordRoleChange = TRUE;
     if ($UserID && GetValue('FixUnique', $Settings)) {
         $UniqueValid = $this->ValidateUniqueFields(GetValue('Name', $FormPostValues), GetValue('Email', $FormPostValues), $UserID, TRUE);
         if (!$UniqueValid['Name']) {
             unset($FormPostValues['Name']);
         }
         if (!$UniqueValid['Email']) {
             unset($FormPostValues['Email']);
         }
         $UniqueValid = TRUE;
     } else {
         $UniqueValid = $this->ValidateUniqueFields(GetValue('Name', $FormPostValues), GetValue('Email', $FormPostValues), $UserID);
     }
     // Add & apply any extra validation rules:
     if (array_key_exists('Email', $FormPostValues) && GetValue('ValidateEmail', $Settings, TRUE)) {
         $this->Validation->ApplyRule('Email', 'Email');
     }
     if ($this->Validate($FormPostValues, $Insert) && $UniqueValid) {
         $Fields = $this->Validation->ValidationFields();
         // All fields on the form that need to be validated (including non-schema field rules defined above)
         $RoleIDs = GetValue('RoleID', $Fields, 0);
         $Username = GetValue('Name', $Fields);
         $Email = GetValue('Email', $Fields);
         $Fields = $this->Validation->SchemaValidationFields();
         // Only fields that are present in the schema
         // Remove the primary key from the fields collection before saving
         $Fields = RemoveKeyFromArray($Fields, $this->PrimaryKey);
         if (in_array('AllIPAddresses', $Fields) && is_array($Fields['AllIPAddresses'])) {
             $Fields['AllIPAddresses'] = implode(',', $Fields['AllIPAddresses']);
         }
         if (!$Insert && array_key_exists('Password', $Fields)) {
             // Encrypt the password for saving only if it won't be hashed in _Insert()
             $PasswordHash = new Gdn_PasswordHash();
             $Fields['Password'] = $PasswordHash->HashPassword($Fields['Password']);
             $Fields['HashMethod'] = 'Vanilla';
         }
         // Check for email confirmation.
         if (self::RequireConfirmEmail() && !GetValue('NoConfirmEmail', $Settings)) {
             // Email address has changed
             if (isset($Fields['Email']) && (array_key_exists('Confirmed', $Fields) && $Fields['Confirmed'] == 0 || $UserID == Gdn::Session()->UserID && $Fields['Email'] != Gdn::Session()->User->Email && !Gdn::Session()->CheckPermission('Garden.Users.Edit'))) {
                 $Attributes = GetValue('Attributes', Gdn::Session()->User);
                 if (is_string($Attributes)) {
                     $Attributes = @unserialize($Attributes);
                 }
                 $ConfirmEmailRoleID = C('Garden.Registration.ConfirmEmailRole');
                 if (RoleModel::Roles($ConfirmEmailRoleID)) {
                     // The confirm email role is set and it exists so go ahead with the email confirmation.
                     $NewKey = RandomString(8);
                     $EmailKey = TouchValue('EmailKey', $Attributes, $NewKey);
                     $Fields['Attributes'] = serialize($Attributes);
                     $Fields['Confirmed'] = 0;
                 }
             }
         }
         $this->EventArguments['SaveRoles'] =& $SaveRoles;
         $this->EventArguments['RoleIDs'] =& $RoleIDs;
         $this->EventArguments['Fields'] =& $Fields;
//.........这里部分代码省略.........
开发者ID:bishopb,项目名称:vanilla,代码行数:101,代码来源:class.usermodel.php


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