本文整理汇总了PHP中Media::uri方法的典型用法代码示例。如果您正苦于以下问题:PHP Media::uri方法的具体用法?PHP Media::uri怎么用?PHP Media::uri使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Media
的用法示例。
在下文中一共展示了Media::uri方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_get_index_collection
public function action_get_index_collection()
{
// Get the post query
$posts_query = $this->_build_query();
// Get the count of ALL records
$count_query = clone $posts_query;
$total_records = (int) $count_query->select(array(DB::expr('COUNT(DISTINCT `post`.`id`)'), 'records_found'))->limit(NULL)->offset(NULL)->find_all()->get('records_found');
// Fetch posts from db
$posts = $posts_query->find_all();
// Get query count
$post_query_sql = $posts_query->last_query();
// Generate filename using hashed query params and ids
$filename = 'export-' . hash('sha256', implode('-', $this->request->query()) . '~' . '-' . $this->request->param('id')) . '.csv';
// Get existing tsv file
$tsv_file = Kohana::$config->load('media.media_upload_dir') . $filename;
// Only generate a new if the file doesn't exist
if (!file_exists($tsv_file)) {
// Supported headers for the TSV file
$tsv_headers = array("ID", "PARENT", "USER", "FORM", "TITLE", "CONTENT", "TYPE", "STATUS", "SLUG", "LOCALE", "CREATED", "UPDATED", "TAGS", "SETS");
// Generate tab separated values (tsv)
$tsv_text = $this->_generate_tsv($tsv_headers, $posts);
// Write tsv to file
$this->_write_tsv_to_file($tsv_text, $filename);
}
// Relative path
$relative_path = str_replace(APPPATH . 'media' . DIRECTORY_SEPARATOR, '', Kohana::$config->load('media.media_upload_dir'));
// Build download link
$download_link = URL::site(Media::uri($relative_path . $filename), Request::current());
// Respond with download link and record count
$this->_response_payload = array('total_count' => $total_records, 'link' => $download_link);
}
示例2: format_o_filename
protected function format_o_filename($value)
{
if ($cdnBaseUrl = Kohana::$config->load('cdn.baseurl')) {
return $cdnBaseUrl . $value;
} else {
return URL::site(Media::uri($this->get_relative_path() . $value), Request::current());
}
}
示例3: for_api
/**
* Prepare media data for API
*
* @return array $response - array to be returned by API (as json)
*/
public function for_api()
{
$response = array();
if ($this->loaded()) {
// Set image dimensions from the config file
$medium_width = Kohana::$config->load('media.image_medium_width');
$medium_height = Kohana::$config->load('media.image_medium_height');
$thumbnail_width = Kohana::$config->load('media.image_thumbnail_width');
$thumbnail_height = Kohana::$config->load('media.image_thumbnail_height');
$upload_path = Kohana::$config->load('media.media_upload_dir');
$relative_path = str_replace(Kohana::$config->load('imagefly.source_dir'), '', Kohana::$config->load('media.media_upload_dir'));
$original_file = $upload_path . $this->o_filename;
$response = array('id' => $this->id, 'user' => empty($this->user_id) ? NULL : array('id' => $this->user_id, 'url' => Ushahidi_Api::url('users', $this->user_id)), 'url' => Ushahidi_Api::url('media', $this->id), 'caption' => $this->caption, 'mime' => $this->mime, 'original_file_url' => URL::site(Media::uri($relative_path . $this->o_filename), Request::current()), 'original_file_size' => is_file($original_file) ? filesize($upload_path . $this->o_filename) : 0, 'original_width' => $this->o_width, 'original_height' => $this->o_height, 'medium_file_url' => $this->_resized_url($medium_width, $medium_height, $relative_path . $this->o_filename), 'medium_width' => $medium_width, 'medium_height' => $medium_height, 'thumbnail_file_url' => $this->_resized_url($thumbnail_width, $thumbnail_height, $relative_path . $this->o_filename), 'thumbnail_width' => $thumbnail_width, 'thumbnail_height' => $thumbnail_height, 'created' => ($created = DateTime::createFromFormat('U', $this->created)) ? $created->format(DateTime::W3C) : $this->created, 'updated' => ($updated = DateTime::createFromFormat('U', $this->updated)) ? $updated->format(DateTime::W3C) : $this->updated);
} else {
$response = array('errors' => array('Media does not exist'));
}
return $response;
}
示例4: format_o_filename
protected function format_o_filename($value)
{
return URL::site(Media::uri($this->get_relative_path() . $value), Request::current());
}