本文整理汇总了PHP中Gdn_Model::getID方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn_Model::getID方法的具体用法?PHP Gdn_Model::getID怎么用?PHP Gdn_Model::getID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn_Model
的用法示例。
在下文中一共展示了Gdn_Model::getID方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getID
/**
* Returns a single message object for the specified id or FALSE if not found.
*
* @param int $MessageID The MessageID to filter to.
* @return array Requested message.
*/
public function getID($MessageID)
{
if (Gdn::cache()->activeEnabled()) {
return self::messages($MessageID);
} else {
return parent::getID($MessageID);
}
}
示例2: getID
/**
* Returns a single message object for the specified id or FALSE if not found.
*
* @param int $messageID The MessageID to filter to.
* @param string|false $datasetType The format of the message.
* @param array $options Options to modify the behavior of the get.
* @return array Requested message.
*/
public function getID($messageID, $datasetType = false, $options = array())
{
if (Gdn::cache()->activeEnabled()) {
$message = self::messages($messageID);
if (!$message) {
return $message;
}
if ($message instanceof Gdn_DataSet) {
$message->datasetType($datasetType);
} elseif ($datasetType === DATASET_TYPE_OBJECT) {
return (object) $message;
} else {
return (array) $message;
}
} else {
return parent::getID($messageID, $datasetType, $options);
}
}
示例3: utilityController_mediaThumbnail_create
/**
* Create and display a thumbnail of an uploaded file.
*/
public function utilityController_mediaThumbnail_create($sender, $media_id)
{
// When it makes it into core, it will be available in
// functions.general.php
require 'generate_thumbnail.php';
$model = new Gdn_Model('Media');
$media = $model->getID($media_id, DATASET_TYPE_ARRAY);
if (!$media) {
throw notFoundException('File');
}
// Get actual path to the file.
$local_path = Gdn_Upload::copyLocal($media['Path']);
if (!file_exists($local_path)) {
throw notFoundException('File');
}
$file_extension = pathinfo($local_path, PATHINFO_EXTENSION);
// Generate new path for thumbnail
$thumb_path = $this->getBaseUploadDestinationDir() . '/' . 'thumb';
// Grab full path with filename, and validate it.
$thumb_destination_path = $this->getAbsoluteDestinationFilePath($local_path, $file_extension, $thumb_path);
// Create thumbnail, and grab debug data from whole process.
$thumb_payload = generate_thumbnail($local_path, $thumb_destination_path, array('height' => c('Plugins.FileUpload.ThumbnailHeight', 128)));
if ($thumb_payload['success'] === true) {
// Thumbnail dimensions
$thumb_height = round($thumb_payload['result_height']);
$thumb_width = round($thumb_payload['result_width']);
// Move the thumbnail to its proper location. Calling SaveAs with
// cloudfiles enabled will trigger the move to cloudfiles, so use
// same path for each arg in SaveAs. The file will be removed from the local filesystem.
$parsed = Gdn_Upload::parse($thumb_destination_path);
$target = $thumb_destination_path;
// $parsed['Name'];
$Upload = new Gdn_Upload();
$filepath_parsed = $Upload->saveAs($thumb_destination_path, $target, array('source' => 'content'));
// Save thumbnail information to DB.
$model->save(array('MediaID' => $media_id, 'StorageMethod' => $filepath_parsed['Type'], 'ThumbWidth' => $thumb_width, 'ThumbHeight' => $thumb_height, 'ThumbPath' => $filepath_parsed['SaveName']));
// Remove cf scratch copy, typically in cftemp, if there was actually a file pulled in from CF.
if (strpos($local_path, 'cftemp') !== false) {
if (!unlink($local_path)) {
// Maybe add logging for local cf copies not deleted.
}
}
$url = $filepath_parsed['Url'];
} else {
// Fix the thumbnail information so this isn't requested again and again.
$model->save(array('MediaID' => $media_id, 'ImageWidth' => 0, 'ImageHeight' => 0, 'ThumbPath' => ''));
$url = asset('/plugins/FileUpload/images/file.png');
}
redirect($url, 301);
}
示例4: getID
/**
* Get a user by ID.
*
* @param int $ID The ID of the user.
* @param string|false $DatasetType Whether to return an array or object.
* @param array $Options Additional options to affect fetching. Currently unused.
* @return array|object|false Returns the user or **false** if the user wasn't found.
*/
public function getID($ID, $DatasetType = false, $Options = [])
{
if (!$ID) {
return false;
}
$DatasetType = $DatasetType ?: DATASET_TYPE_OBJECT;
// Check page cache, then memcached
$User = $this->getUserFromCache($ID, 'userid');
// If not, query DB
if ($User === Gdn_Cache::CACHEOP_FAILURE) {
$User = parent::getID($ID, DATASET_TYPE_ARRAY);
// We want to cache a non-existent user no-matter what.
if (!$User) {
$User = null;
}
$this->userCache($User, $ID);
} elseif (!$User) {
return false;
}
// Apply calculated fields
$this->setCalculatedFields($User);
// Allow FALSE returns
if ($User === false || is_null($User)) {
return false;
}
if (is_array($User) && $DatasetType == DATASET_TYPE_OBJECT) {
$User = (object) $User;
}
if (is_object($User) && $DatasetType == DATASET_TYPE_ARRAY) {
$User = (array) $User;
}
$this->EventArguments['LoadedUser'] =& $User;
$this->fireEvent('AfterGetID');
return $User;
}
示例5: getID
/**
* {@inheritDoc}
* in addition; We CalculateRow on the record found (Add Attachments)
* @see Gdn_Model::GetID
*/
public function getID($ID, $DatasetType = DATASET_TYPE_ARRAY, $Options = array())
{
$DatasetType = DATASET_TYPE_ARRAY;
$Row = (array) parent::getID($ID, $DatasetType, $Options);
$this->calculateRow($Row);
return $Row;
}
示例6: getID
/**
* Get a particular activity record.
*
* @param int $activityID Unique ID of activity item.
* @param string $dataSetType The format of the resulting data.
* @param array $options Not used.
* @return array|object A single SQL result.
*/
public function getID($activityID, $dataSetType = false, $options = [])
{
$Activity = parent::getID($activityID, $dataSetType);
if ($Activity) {
$this->calculateRow($Activity);
$Activities = array($Activity);
self::joinUsers($Activities);
$Activity = array_pop($Activities);
}
return $Activity;
}