本文整理汇总了PHP中gallery::get_image_new_name方法的典型用法代码示例。如果您正苦于以下问题:PHP gallery::get_image_new_name方法的具体用法?PHP gallery::get_image_new_name怎么用?PHP gallery::get_image_new_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gallery
的用法示例。
在下文中一共展示了gallery::get_image_new_name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_image
/**
* Add image to item
* @return void
* @param integer id of item
* @param string dir with images
*/
public function add_image($item, $dir)
{
// Check for user permission
if (user::is_got()) {
$this->set_title(Kohana::lang('gallery.add_image'));
$this->add_breadcrumb(Kohana::lang('gallery.add_image'), url::current());
// Set redirect URL
if (isset($_POST['redirect'])) {
$redirect = $_POST['redirect'];
} else {
$redirect = request::referrer();
}
$form = array('image' => '', 'redirect' => $redirect);
$errors = array();
if (isset($_FILES)) {
$files = new Validation($_FILES);
// Rules
$files->add_rules('image', 'upload::valid', 'upload::required', 'upload::type[jpg,jpeg]', 'upload::size[500K]');
if ($files->validate()) {
// Temporary file
$filename = upload::save('image');
// Get new name
$id = gallery::get_image_new_name($item, $dir);
// Save original and thumb
Image::factory($filename)->save('./data/' . $dir . '/' . $item . '_' . $id . '.jpg');
Image::factory($filename)->resize(128, 128, Image::AUTO)->quality(85)->save('./data/' . $dir . '/' . $item . '_' . $id . '_m.jpg');
// Remove the temporary file
unlink($filename);
url::redirect($form['redirect']);
} else {
// Repopulate form with error and original values
$form = arr::overwrite($form, $files->as_array());
$errors = $files->errors('gallery_errors');
}
}
// View
$this->template->content = new View('admin/add_image');
$this->template->content->errors = $errors;
$this->template->content->form = $form;
} else {
url::redirect('/denied');
}
}