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


PHP Gdn_Model::getID方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:14,代码来源:class.messagemodel.php

示例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);
     }
 }
开发者ID:sitexa,项目名称:vanilla,代码行数:26,代码来源:class.messagemodel.php

示例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);
 }
开发者ID:mcnasby,项目名称:datto-vanilla,代码行数:53,代码来源:class.editor.plugin.php

示例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;
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:43,代码来源:class.usermodel.php

示例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;
 }
开发者ID:R-J,项目名称:vanilla,代码行数:12,代码来源:class.attachmentmodel.php

示例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;
 }
开发者ID:bahill,项目名称:vanilla,代码行数:19,代码来源:class.activitymodel.php


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