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


PHP Format::Serialize方法代码示例

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


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

示例1: Check

 public function Check($Type = '', $Name = '')
 {
     if ($Type != '' && $Name != '') {
         $this->AddItem($Type, $Name);
     }
     if (count($this->_Items) > 0) {
         // TODO: Use garden update check url instead of this:
         $UpdateUrl = Url('/lussumo/update', TRUE, TRUE);
         $Host = Gdn_Url::Host();
         $Path = CombinePaths(array(Gdn_Url::WebRoot(), 'lussumo', 'update'), '/');
         $Port = 80;
         /*
         $UpdateUrl = Gdn::Config('Garden.UpdateCheckUrl', '');
         $UpdateUrl = parse_url($UpdateUrl);
         $Host = ArrayValue('host', $UpdateUrl, 'www.lussumo.com');
         $Path = ArrayValue('path', $UpdateUrl, '/');
         $Port = ArrayValue('port', $UpdateUrl, '80');
         */
         $Path .= '?Check=' . urlencode(Format::Serialize($this->_Items));
         $Locale = Gdn::Config('Garden.Locale', 'Undefined');
         $Referer = Gdn_Url::WebRoot(TRUE);
         if ($Referer === FALSE) {
             $Referer = 'Undefined';
         }
         $Timeout = 10;
         $Response = '';
         // Connect to the update server.
         $Pointer = @fsockopen($Host, '80', $ErrorNumber, $Error, $Timeout);
         if (!$Pointer) {
             throw new Exception(sprintf(Gdn::Translate('Encountered an error when attempting to connect to the update server (%1$s): [%2$s] %3$s'), $UpdateUrl, $ErrorNumber, $Error));
         } else {
             // send the necessary headers to get the file
             fputs($Pointer, "GET {$Path} HTTP/1.0\r\n" . "Host: {$Host}\r\n" . "User-Agent: Lussumo Garden/1.0\r\n" . "Accept: */*\r\n" . "Accept-Language: " . $Locale . "\r\n" . "Accept-Charset: utf-8;\r\n" . "Keep-Alive: 300\r\n" . "Connection: keep-alive\r\n" . "Referer: {$Referer}\r\n\r\n");
             // Retrieve the response from the remote server
             while ($Line = fread($Pointer, 4096)) {
                 $Response .= $Line;
             }
             fclose($Pointer);
             // Remove response headers
             $Response = substr($Response, strpos($Response, "\r\n\r\n") + 4);
         }
         $Result = Format::Unserialize($Response);
         // print_r($Result);
         if (is_array($Result)) {
             $this->_Items = $Result;
         } else {
             $Result = FALSE;
         }
         return $Result;
     }
 }
开发者ID:kidmax,项目名称:Garden,代码行数:51,代码来源:class.updatemanager.php

示例2: AddUserToConversation

 public function AddUserToConversation($ConversationID, $UserID)
 {
     if (!is_array($UserID)) {
         $UserID = array($UserID);
     }
     // First define the current users in the conversation
     $OldContributorData = $this->GetRecipients($ConversationID);
     $OldContributorUserIDs = ConsolidateArrayValuesByKey($OldContributorData->ResultArray(), 'UserID');
     $AddedUserIDs = array();
     // Get some information about this conversation
     $ConversationData = $this->SQL->Select('MessageID', 'max', 'LastMessageID')->Select('MessageID', 'count', 'CountMessages')->From('ConversationMessage')->Where('ConversationID', $ConversationID)->Get()->FirstRow();
     // Add the user(s) if they are not already in the conversation
     foreach ($UserID as $NewUserID) {
         if (!in_array($NewUserID, $OldContributorUserIDs)) {
             $AddedUserIDs[] = $NewUserID;
             $this->SQL->Insert('UserConversation', array('UserID' => $NewUserID, 'ConversationID' => $ConversationID, 'LastMessageID' => $ConversationData->LastMessageID, 'CountMessages' => $ConversationData->CountMessages, 'CountNewMessages' => $ConversationData->CountMessages));
         }
     }
     if (count($AddedUserIDs) > 0) {
         $Session = Gdn::Session();
         // Update the Contributors field on the conversation
         $Contributors = array_unique(array_merge($AddedUserIDs, $OldContributorUserIDs));
         sort($Contributors);
         $this->SQL->Update('Conversation')->Set('Contributors', Format::Serialize($Contributors))->Where('ConversationID', $ConversationID)->Put();
         // NOTIFY ALL NEWLY ADDED USERS THAT THEY WERE ADDED TO THE CONVERSATION
         foreach ($AddedUserIDs as $AddedUserID) {
             AddActivity($Session->UserID, 'AddedToConversation', '', $AddedUserID, '/messages/' . $ConversationID);
         }
         // Update the unread conversation count for each affected user
         $this->SQL->Update('User')->Set('CountUnreadConversations', 'CountUnreadConversations + 1', FALSE)->WhereIn('UserID', $AddedUserIDs)->Put();
     }
 }
开发者ID:Beyzie,项目名称:Garden,代码行数:32,代码来源:class.conversationmodel.php

示例3: SaveToSerializedColumn

 /**
  * Saves a name/value to the user's specified $Column.
  *
  * This method throws exceptions when errors are encountered. Use try ...
  * catch blocks to capture these exceptions.
  *
  * @param string The name of the serialized column to save to. At the time of this writing there are three serialized columns on the user table: Permissions, Preferences, and Attributes.
  * @param int The UserID to save.
  * @param mixed The name of the value being saved, or an associative array of name => value pairs to be saved. If this is an associative array, the $Value argument will be ignored.
  * @param mixed The value being saved.
  */
 public function SaveToSerializedColumn($Column, $UserID, $Name, $Value = '')
 {
     // Load the existing values
     $UserData = $this->SQL->Select($Column)->From('User')->Where('UserID', $UserID)->Get()->FirstRow();
     if (!$UserData) {
         throw new Exception(Gdn::Translate('ErrorRecordNotFound'));
     }
     $Values = Format::Unserialize($UserData->{$Column});
     // Throw an exception if the field was not empty but is also not an object or array
     if (is_string($Values) && $Values != '') {
         throw new Exception(Gdn::Translate('Serialized column failed to be unserialized.'));
     }
     if (!is_array($Values)) {
         $Values = array();
     }
     // Assign the new value(s)
     if (!is_array($Name)) {
         $Name = array($Name => $Value);
     }
     $Values = Format::Serialize(array_merge($Values, $Name));
     // Save the values back to the db
     return $this->SQL->Put('User', array($Column => $Values), array('UserID' => $UserID));
 }
开发者ID:robi-bobi,项目名称:Garden,代码行数:34,代码来源:class.usermodel.php

示例4: Index

 public function Index()
 {
     $this->AddJsFile('settings.js');
     $this->Title(Translate('Dashboard'));
     $this->RequiredAdminPermissions[] = 'Garden.Settings.Manage';
     $this->RequiredAdminPermissions[] = 'Garden.Routes.Manage';
     $this->RequiredAdminPermissions[] = 'Garden.Applications.Manage';
     $this->RequiredAdminPermissions[] = 'Garden.Plugins.Manage';
     $this->RequiredAdminPermissions[] = 'Garden.Themes.Manage';
     $this->RequiredAdminPermissions[] = 'Garden.Registration.Manage';
     $this->RequiredAdminPermissions[] = 'Garden.Applicants.Manage';
     $this->RequiredAdminPermissions[] = 'Garden.Roles.Manage';
     $this->RequiredAdminPermissions[] = 'Garden.Users.Add';
     $this->RequiredAdminPermissions[] = 'Garden.Users.Edit';
     $this->RequiredAdminPermissions[] = 'Garden.Users.Delete';
     $this->RequiredAdminPermissions[] = 'Garden.Users.Approve';
     $this->FireEvent('DefineAdminPermissions');
     $this->Permission($this->RequiredAdminPermissions, '', FALSE);
     $this->AddSideMenu('garden/settings');
     $UserModel = Gdn::UserModel();
     // Load some data to display on the dashboard
     $this->BuzzData = array();
     // Get the number of users in the database
     $CountUsers = $UserModel->GetCountLike();
     $this->AddDefinition('CountUsers', $CountUsers);
     $this->BuzzData[Translate('Users')] = number_format($CountUsers);
     // Get the number of new users in the last day
     $this->BuzzData[Translate('New users in the last day')] = number_format($UserModel->GetCountWhere(array('DateInserted >=' => Format::ToDateTime(strtotime('-1 day')))));
     // Get the number of new users in the last week
     $this->BuzzData[Translate('New users in the last week')] = number_format($UserModel->GetCountWhere(array('DateInserted >=' => Format::ToDateTime(strtotime('-1 week')))));
     // Get recently active users
     $this->ActiveUserData = $UserModel->GetActiveUsers(5);
     // Check to see if the application needs to phone-home for updates. Doing
     // this here because this method is always called when admin pages are
     // loaded regardless of the application loading them.
     $UpdateCheckDate = Gdn::Config('Garden.UpdateCheckDate', '');
     if ($UpdateCheckDate == '' || !IsTimestamp($UpdateCheckDate) || $UpdateCheckDate < strtotime("-1 day")) {
         $UpdateData = array();
         // Grab all of the plugins & versions
         $PluginManager = Gdn::Factory('PluginManager');
         $Plugins = $PluginManager->AvailablePlugins();
         foreach ($Plugins as $Plugin => $Info) {
             $Name = ArrayValue('Name', $Info, $Plugin);
             $Version = ArrayValue('Version', $Info, '');
             if ($Version != '') {
                 $UpdateData[] = array('Name' => $Name, 'Version' => $Version, 'Type' => 'Plugin');
             }
         }
         // Grab all of the applications & versions
         $ApplicationManager = Gdn::Factory('ApplicationManager');
         $Applications = $ApplicationManager->AvailableApplications();
         foreach ($Applications as $Application => $Info) {
             $Name = ArrayValue('Name', $Info, $Application);
             $Version = ArrayValue('Version', $Info, '');
             if ($Version != '') {
                 $UpdateData[] = array('Name' => $Name, 'Version' => $Version, 'Type' => 'Application');
             }
         }
         // Grab all of the themes & versions
         $ThemeManager = new Gdn_ThemeManager();
         $Themes = $ThemeManager->AvailableThemes();
         foreach ($Themes as $Theme => $Info) {
             $Name = ArrayValue('Name', $Info, $Theme);
             $Version = ArrayValue('Version', $Info, '');
             if ($Version != '') {
                 $UpdateData[] = array('Name' => $Name, 'Version' => $Version, 'Type' => 'Theme');
             }
         }
         // Dump the entire set of information into the definition list (jQuery
         // will pick it up and ping the VanillaForums.org server with this info).
         $this->AddDefinition('UpdateChecks', Format::Serialize($UpdateData));
     }
     // Fire an event so other applications can add some data to be displayed
     $this->FireEvent('DashboardData');
     $this->Render();
 }
开发者ID:jeastwood,项目名称:Garden,代码行数:76,代码来源:settings.php

示例5: Set

 /**
  * Assigns a setting to the configuration array.
  *
  * @param string $Name The name of the configuration setting to assign. If the setting is
  * contained within an associative array, use dot denomination to get the
  * setting. ie. <code>$this->Set('Database.Host', $Value)</code> would set
  * <code>$Configuration[$Group]['Database']['Host'] = $Value</code>.
  * @param mixed $Value The value of the configuration setting.
  * @param boolean $Overwrite If the setting already exists, should it's value be overwritten? Defaults to true.
  */
 public function Set($Name, $Value, $Overwrite = TRUE)
 {
     if (!is_array($this->_Data)) {
         $this->_Data = array();
     }
     if (!is_array($this->_SaveData)) {
         $this->_SaveData = array();
     }
     $Keys = explode('.', $Name);
     $KeyCount = count($Keys);
     $Array =& $this->_Data;
     $SaveArray =& $this->_SaveData;
     for ($i = 0; $i < $KeyCount; ++$i) {
         $Key = $Keys[$i];
         $KeyExists = array_key_exists($Key, $Array);
         if ($i == $KeyCount - 1) {
             // If we are on the last iteration of the key, then set the value.
             if ($KeyExists === FALSE || $Overwrite === TRUE) {
                 $Array[$Key] = Format::Serialize($Value);
                 $SaveArray[$Key] = Format::Serialize($Value);
             }
         } else {
             // Otherwise, traverse the array
             if ($KeyExists === FALSE) {
                 $Array[$Key] = array();
                 $SaveArray[$Key] = array();
             }
             $Array =& $Array[$Key];
             $SaveArray =& $SaveArray[$Key];
         }
     }
 }
开发者ID:Aetasiric,项目名称:Garden,代码行数:42,代码来源:class.configuration.php

示例6: AddUpdateCheck

 /**
  * Adds information to the definition list that causes the app to "phone
  * home" and see if there are upgrades available. Currently added to the
  * dashboard only.
  * Nothing renders with this method. It is public so it can be added by
  * plugins.
  */
 public function AddUpdateCheck()
 {
     // Check to see if the application needs to phone-home for updates. Doing
     // this here because this method is always called when admin pages are
     // loaded regardless of the application loading them.
     $UpdateCheckDate = Gdn::Config('Garden.UpdateCheckDate', '');
     if ($UpdateCheckDate == '' || !IsTimestamp($UpdateCheckDate) || $UpdateCheckDate < strtotime("-1 day")) {
         $UpdateData = array();
         // Grab all of the plugins & versions
         $PluginManager = Gdn::Factory('PluginManager');
         $Plugins = $PluginManager->AvailablePlugins();
         foreach ($Plugins as $Plugin => $Info) {
             $Name = ArrayValue('Name', $Info, $Plugin);
             $Version = ArrayValue('Version', $Info, '');
             if ($Version != '') {
                 $UpdateData[] = array('Name' => $Name, 'Version' => $Version, 'Type' => 'Plugin');
             }
         }
         // Grab all of the applications & versions
         $ApplicationManager = Gdn::Factory('ApplicationManager');
         $Applications = $ApplicationManager->AvailableApplications();
         foreach ($Applications as $Application => $Info) {
             $Name = ArrayValue('Name', $Info, $Application);
             $Version = ArrayValue('Version', $Info, '');
             if ($Version != '') {
                 $UpdateData[] = array('Name' => $Name, 'Version' => $Version, 'Type' => 'Application');
             }
         }
         // Grab all of the themes & versions
         $ThemeManager = new Gdn_ThemeManager();
         $Themes = $ThemeManager->AvailableThemes();
         foreach ($Themes as $Theme => $Info) {
             $Name = ArrayValue('Name', $Info, $Theme);
             $Version = ArrayValue('Version', $Info, '');
             if ($Version != '') {
                 $UpdateData[] = array('Name' => $Name, 'Version' => $Version, 'Type' => 'Theme');
             }
         }
         // Dump the entire set of information into the definition list (jQuery
         // will pick it up and ping the VanillaForums.org server with this info).
         $this->AddDefinition('UpdateChecks', Format::Serialize($UpdateData));
     }
 }
开发者ID:robi-bobi,项目名称:Garden,代码行数:50,代码来源:settings.php

示例7: SaveToSerializedColumn

 public function SaveToSerializedColumn($Column, $RowID, $Name, $Value = '')
 {
     if (!isset($this->Schema)) {
         $this->DefineSchema();
     }
     // TODO: need to be sure that $this->PrimaryKey is only one primary key
     $FieldName = $this->PrimaryKey;
     // Load the existing values
     $Row = $this->SQL->Select($Column)->From($this->Name)->Where($FieldName, $RowID)->Get()->FirstRow();
     if (!$Row) {
         throw new Exception(Gdn::Translate('ErrorRecordNotFound'));
     }
     $Values = Format::Unserialize($Row->{$Column});
     if (is_string($Values) && $Values != '') {
         throw new Exception(Gdn::Translate('Serialized column failed to be unserialized.'));
     }
     if (!is_array($Values)) {
         $Values = array();
     }
     if (!is_array($Name)) {
         $Name = array($Name => $Value);
     }
     // Assign the new value(s)
     $Values = Format::Serialize(array_merge($Values, $Name));
     // Save the values back to the db
     return $this->SQL->From($this->Name)->Where($FieldName, $RowID)->Set($Column, $Values)->Put();
 }
开发者ID:stinie,项目名称:Garden,代码行数:27,代码来源:class.model.php


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