本文整理汇总了PHP中ForceInt函数的典型用法代码示例。如果您正苦于以下问题:PHP ForceInt函数的具体用法?PHP ForceInt怎么用?PHP ForceInt使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ForceInt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetPropertiesFromDataSet
function GetPropertiesFromDataSet($DataSet)
{
$this->ClippingID = ForceInt(@$DataSet["ClippingID"], 0);
$this->UserID = ForceInt(@$DataSet["UserID"], 0);
$this->Label = ForceString(@$DataSet["Label"], "");
$this->Contents = ForceString(@$DataSet["Contents"], "");
}
示例2: RemoveRole
function RemoveRole($RemoveRoleID, $ReplacementRoleID)
{
$s = $this->Context->ObjectFactory->NewContextObject($this->Context, 'SqlBuilder');
$s->SetMainTable('User', 'u');
$s->AddSelect('UserID', 'u');
$s->AddJoin('Role', 'r', 'RoleID', 'u', 'RoleID', 'inner join');
$s->AddWhere('u', 'RoleID', '', $RemoveRoleID, '=');
$s->AddWhere('r', 'Unauthenticated', '', '0', '=');
$OldRoleUsers = $this->Context->Database->Select($s, $this->Name, 'RemoveRole', 'An error occurred while attempting to remove the role.');
if ($this->Context->Database->RowCount($OldRoleUsers) > 0) {
$um = $this->Context->ObjectFactory->NewContextObject($this->Context, 'UserManager');
// Reset the role for all of the affected users
$urh = $this->Context->ObjectFactory->NewObject($this->Context, 'UserRoleHistory');
$urh->RoleID = $ReplacementRoleID;
$urh->AdminUserID = $this->Context->Session->UserID;
$urh->Notes = "The user's previous role has been made obselete.";
while ($row = $this->Context->Database->GetRow($OldRoleUsers)) {
$urh->UserID = ForceInt($row['UserID'], 0);
$um->AssignRole($urh);
}
}
$s->Clear();
$s->SetMainTable('Role', 'r');
$s->AddFieldNameValue('Active', '0');
$s->AddWhere('r', 'RoleID', '', $RemoveRoleID, '=');
$this->Context->Database->Update($s, $this->Name, 'RemoveRole', 'An error occurred while attempting to remove the role.');
return 1;
}
示例3: AddString
function AddString($String, $Position = '0', $ForcePosition = '0')
{
$this->CallDelegate('AddString');
$Position = ForceInt($Position, 0);
$StringKey = count($this->Strings);
$this->Strings[] = $String;
$this->AddItemToCollection($this->PanelElements, array('Type' => 'String', 'Key' => $StringKey), $Position, $ForcePosition);
}
示例4: GetPropertiesFromDataSet
function GetPropertiesFromDataSet($DataSet)
{
$this->CategoryID = ForceInt(@$DataSet['CategoryID'], 0);
$this->Name = ForceString(@$DataSet['Name'], '');
$this->Description = ForceString(@$DataSet['Description'], '');
$this->DiscussionCount = ForceInt(@$DataSet['DiscussionCount'], 0);
$this->Blocked = ForceBool(@$DataSet['Blocked'], 0);
$this->RoleBlocked = ForceBool(@$DataSet['RoleBlocked'], 0);
}
示例5: Start
function Start(&$Context, $UserID = "0")
{
if (!session_id()) {
session_start();
}
$UserID = ForceInt($UserID, 0);
if ($UserID > 0) {
$this->UserID = $UserID;
$this->SetVariable("UserID", $UserID);
} else {
$this->UserID = $this->GetVariable("UserID", "int");
}
$um = false;
// If the session vars are not defined, attempt to revalidate the session from cookies
if ($this->UserID == 0) {
// NOTE: the session object is not yet valid in the context object
$um = $Context->ObjectFactory->NewContextObject($Context, "UserManager");
$this->UserID = $um->ValidateCookieCredentials();
$this->SetVariable("UserID", $this->UserID);
}
// Now retrieve user information
if ($this->UserID > 0) {
if (!$um) {
$um = $Context->ObjectFactory->NewContextObject($Context, "UserManager");
}
$this->User = $um->GetSessionDataById($this->UserID);
$GrpTmp = $this->User->UserMainGroup;
foreach (array_keys($this->User->UserGroups) as $GrpID) {
$GrpTmp[$GrpID] = $this->User->UserGroups[$GrpID];
}
$this->SetVariable("UserGroups", @$GrpTmp);
$this->SetVariable("Settings", $this->User->Settings);
// If the session data retrieval failed for some reason, dump the user
if (!$this->User) {
$this->User = $Context->ObjectFactory->NewContextObject($Context, "User");
$this->User->Clear();
$this->UserID = 0;
}
} else {
$FauxContext = 0;
$this->User = $Context->ObjectFactory->NewObject($FauxContext, "User");
$this->User->Clear();
}
/*/ Handle Work-Safe Mode Switches
$HtmlOn = ForceIncomingString("h", "1");
if ($HtmlOn != "" && $this->UserID > 0) {
if (!$um) {
$um = $Context->ObjectFactory->NewContextObject($Context, "UserManager", $Context);
}
if (ForceBool($HtmlOn, 0)) {
$um->ShowHtml($this->UserID);
} else {
$um->HideHtml($this->UserID);
}
}*/
}
示例6: AddControl
function AddControl($Event, $Control, $Position = "0")
{
$Position = ForceInt($Position, -1);
if ($Position >= 0) {
$this->InsertControlAt($this->Controls[$Event], $Control, $Position);
} else {
$this->Controls[$Event][] = $Control;
}
}
示例7: ForceIntFrom
function ForceIntFrom($VariableName, $DefaultValue = 0)
{
if (isset($_GET[$VariableName])) {
return ForceInt($_GET[$VariableName], $DefaultValue);
} elseif (isset($_POST[$VariableName])) {
return ForceInt($_POST[$VariableName], $DefaultValue);
} else {
return $DefaultValue;
}
}
示例8: GetPropertiesFromDataSet
function GetPropertiesFromDataSet($DataSet, $ParseKeywords = '0')
{
$ParseKeywords = ForceBool($ParseKeywords, 0);
$this->SearchID = ForceInt(@$DataSet['SearchID'], 0);
$this->Label = ForceString(@$DataSet['Label'], '');
$this->Type = $this->DefineType(ForceString(@$DataSet['Type'], ''));
$this->Keywords = urldecode(ForceString(@$DataSet['Keywords'], ''));
if ($ParseKeywords) {
$this->ParseKeywords($this->Type, $this->Keywords);
}
}
示例9: GetSearchList
function GetSearchList($RecordsToRetrieve = '0', $UserID)
{
$RecordsToRetrieve = ForceInt($RecordsToRetrieve, 0);
$s = $this->Context->ObjectFactory->NewContextObject($this->Context, 'SqlBuilder');
$s = $this->GetSearchBuilder();
$s->AddWhere('us', 'UserID', '', $UserID, '=');
if ($RecordsToRetrieve > 0) {
$s->AddLimit(0, $RecordsToRetrieve);
}
return $this->Context->Database->Select($s, $this->Name, 'GetSearchList', 'An error occurred while retrieving saved searches.');
}
示例10: AddControl
function AddControl($Event, &$Control, $Position = '0')
{
$Position = ForceInt($Position, -1);
if ($Position >= 0) {
// Create the key/array if it doesn't exist yet
if (!array_key_exists($Event, $this->Controls)) {
$this->Controls[$Event] = array();
}
$this->InsertControlAt($this->Controls[$Event], $Control, $Position);
} else {
$this->Controls[$Event][] =& $Control;
}
}
示例11: GetPropertiesFromDataSet
function GetPropertiesFromDataSet($DataSet)
{
$this->UserID = ForceInt(@$DataSet['UserID'], 0);
$this->Username = ForceString(@$DataSet['Username'], '');
$this->FullName = ForceString(@$DataSet['FullName'], '');
$this->RoleID = ForceInt(@$DataSet['RoleID'], 0);
$this->Role = ForceString(@$DataSet['Role'], '');
$this->RoleDescription = ForceString(@$DataSet['RoleDescription'], '');
$this->RoleIcon = ForceString(@$DataSet['RoleIcon'], '');
$this->AdminUserID = ForceInt(@$DataSet['AdminUserID'], 0);
$this->AdminUsername = ForceString(@$DataSet['AdminUsername'], '');
$this->AdminFullName = ForceString(@$DataSet['AdminFullName'], '');
$this->Notes = ForceString(@$DataSet['Notes'], '');
$this->Date = UnixTimestamp(@$DataSet['Date']);
}
示例12: GetPropertiesFromDataSet
function GetPropertiesFromDataSet($DataSet, &$Context)
{
$this->Title = FormatHtmlStringInline(ForceString($DataSet["Name"], ""));
$this->Link = PrependString("http://", AppendFolder(agDOMAIN, "comments.php?DiscussionID=" . ForceInt($DataSet["DiscussionID"], 0)));
$this->Id = $this->Link;
$this->Published = FixDate(@$DataSet["DateCreated"]);
$this->Updated = FixDate(@$DataSet["DateLastActive"]);
$this->AuthorName = FormatHtmlStringInline(ForceString($DataSet["AuthUsername"], ""));
$this->AuthorUrl = PrependString("http://", AppendFolder(agDOMAIN, "account.php?u=" . ForceInt($DataSet["AuthUserID"], 0)));
$this->Content = $this->RemoveHtml(ForceString(@$DataSet["Body"], ""));
$this->Summary = SliceString($this->Content, 200);
$this->Summary = str_replace("\r\n", " ", $this->Content);
$this->Content = str_replace("\r\n", "<br />", $this->Content);
if (agUSE_CATEGORIES) {
$this->Category = FormatStringForDisplay(ForceString($DataSet["Category"], ""), true);
$this->CategoryLink = "http://" . AppendFolder(agDOMAIN, "?CategoryID=" . ForceInt($DataSet["CategoryID"], 0));
}
}
示例13: MultiFileUpload_AttachmentForm
function MultiFileUpload_AttachmentForm(&$AttachmentManager)
{
$AttachmentForm =& $AttachmentManager->DelegateParameters['AttachmentForm'];
$AttachmentForm = '
<ul><li><label for="Attachments"><span onclick="showMultiFileUpload(); return false;" style="cursor: pointer;" id="AttachmentsLabel">[+] ' . $AttachmentManager->Context->GetDefinition("Attachments") . '</span></label>
' . $AttachmentManager->GetAttachmentsList($AttachmentManager->CommentID) . '
<div id="MultiFileUpload" style="display: none;">
<div id="AttachmentsList"></div>
<input id="AttachmentFile" type="file" name="file" class="AttachmentInput" />
</div>
</li></ul>
<script type="text/javascript" language="javascript">
function showMultiFileUpload()
{
var txtAttachments = "' . $AttachmentManager->Context->GetDefinition("Attachments") . '";
var objAttachmentsLabel = document.getElementById("AttachmentsLabel");
var objMultiFileUpload = document.getElementById("MultiFileUpload");
if (objAttachmentsLabel.innerHTML == "[-] " + txtAttachments)
{
objAttachmentsLabel.innerHTML = "[+] " + txtAttachments;
objMultiFileUpload.style.display = "none";
}
else
{
objAttachmentsLabel.innerHTML = "[-] " + txtAttachments;
objMultiFileUpload.style.display = "block";
}
}
var f = document.getElementById(\'' . $AttachmentManager->FormName . '\');
f.encoding = \'multipart/form-data\';
';
if (ForceInt($AttachmentManager->Context->Configuration['MULTI_FILE_UPLOADS'], 0) > 1) {
$AttachmentForm .= '
var multi_selector = new MultiSelector(document.getElementById("AttachmentsList"), ' . $AttachmentManager->Context->Configuration['MULTI_FILE_UPLOADS'] . ');
multi_selector.addElement(document.getElementById("AttachmentFile"));
';
}
$AttachmentForm .= '
</script>
';
}
示例14: GetPropertiesFromDataSet
function GetPropertiesFromDataSet($DataSet)
{
$this->RoleID = ForceInt(@$DataSet['RoleID'], 0);
$this->RoleName = ForceString(@$DataSet['Name'], '');
$this->Icon = ForceString(@$DataSet['Icon'], '');
$this->Description = ForceString(@$DataSet['Description'], '');
$this->PERMISSION_SIGN_IN = ForceBool(@$DataSet['PERMISSION_SIGN_IN'], 0);
$this->PERMISSION_HTML_ALLOWED = ForceBool(@$DataSet['PERMISSION_HTML_ALLOWED'], 0);
$this->PERMISSION_RECEIVE_APPLICATION_NOTIFICATION = ForceBool(@$DataSet['PERMISSION_RECEIVE_APPLICATION_NOTIFICATION'], 0);
$this->Unauthenticated = ForceBool(@$DataSet['Unauthenticated'], 0);
$TempPermissions = '';
$TempPermissions = ForceString(@$DataSet['Permissions'], '');
$TempPermissions = UnserializeAssociativeArray($TempPermissions);
$this->Permissions['PERMISSION_SIGN_IN'] = $this->PERMISSION_SIGN_IN;
$this->Permissions['PERMISSION_HTML_ALLOWED'] = $this->PERMISSION_HTML_ALLOWED;
$this->Permissions['PERMISSION_RECEIVE_APPLICATION_NOTIFICATION'] = $this->PERMISSION_RECEIVE_APPLICATION_NOTIFICATION;
while (list($TempKey, $TempValue) = each($TempPermissions)) {
$this->Permissions[$TempKey] = $TempValue;
}
unset($TempPermissions);
}
示例15: HighlightTrimmedString
function HighlightTrimmedString($Haystack, $Needles, $TrimLength = '')
{
$Highlight = '<span class="Highlight">\\1</span>';
$Pattern = '#(?!<.*?)(%s)(?![^<>]*?>)#i';
$TrimLength = ForceInt($TrimLength, 0);
if ($TrimLength > 0) {
$Haystack = SliceString($Haystack, $TrimLength);
}
$WordsToHighlight = count($Needles);
if ($WordsToHighlight > 0) {
$i = 0;
for ($i = 0; $i < $WordsToHighlight; $i++) {
if (strlen($Needles[$i]) > 2) {
$CurrentWord = preg_quote($Needles[$i]);
$Regex = sprintf($Pattern, $CurrentWord);
$Haystack = preg_replace($Regex, $Highlight, $Haystack);
}
}
}
return $Haystack;
}