array( 'tid' => array( 'description' => 'Template ID', 'type' => 'serial', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, ), 'mask' => array( 'description' => 'File mask', 'type' => 'varchar', 'length' => 200, 'not null' => TRUE, 'default' => '', ), 'path' => array( 'description' => 'Upload path', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', ), 'max_filesize' => array( 'description' => 'Max filesize in bytes', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, ), 'template' => array( 'description' => 'Template', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '!filename', ), 'template_select' => array( 'description' => 'Template for replace selected text', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '!text', ), 'image_style' => array( 'description' => 'Image style', 'type' => 'varchar', 'length' => 50, 'not null' => TRUE, 'default' => '', ), 'image_style_original' => array( 'description' => 'Image style for original image', 'type' => 'varchar', 'length' => 50, 'not null' => TRUE, 'default' => '', ), 'link_to_original' => array( 'description' => 'Wrap template link to original image', 'type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, ), 'link_only_big' => array( 'description' => '1 - wrap template only big images, 0 - wrap all images', 'type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, ), 'show_in_colorbox' => array( 'description' => '1 - show original image in colorbox, 0 - open in new page', 'type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, ), 'max_dimensions' => array( 'description' => 'Maximum image resolution', 'type' => 'varchar', 'length' => 20, 'not null' => TRUE, 'default' => '', ), 'rename_file' => array( 'description' => '1 - change filename to unique number (datetime), 0 - not change', 'type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 1, ), ), 'primary key' => array('tid'), 'description' => 'Module templates', ); return $shema; } /** * Implements hook_install(). */ function ocupload_install() { module_load_include('inc', 'ocupload'); $templates = array( array( 'mask' => 'jpg,jpeg,gif,png', 'path' => 'images', 'template' => '', 'template_select' => '!text', 'image_style' => 'large', 'link_to_original' => 1, 'link_only_big' => 1, 'show_in_colorbox' => module_exists('colorbox') ? 1 : 0, 'rename_file' => 1, ), array( 'mask' => 'rar,zip,doc,xls', 'path' => 'files', 'template' => '!filename', 'template_select' => '!text', 'rename_file' => 0, ), array( 'mask' => 'webm,mp4,ogv', 'path' => 'video', 'template' => '', 'template_select' => '!text', 'rename_file' => 0, ), ); foreach ($templates as $template) { $directory = 'public://' . $template['path']; file_prepare_directory($directory, FILE_CREATE_DIRECTORY); } ocupload_template_save($templates, TRUE); } /** * Implements hook_uninstall(). */ function ocupload_uninstall() { foreach (array('ocupload_delete_unused_files') as $name) { variable_del($name); } } /** * Add new col {ocupload_templates}.show_in_colorbox */ function ocupload_update_7100() { db_add_field('ocupload_templates', 'show_in_colorbox', array( 'description' => '1 - show original image in colorbox, 0 - open in new page', 'type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0, )); } /** * Change col length {ocupload_templates}.path */ function ocupload_update_7101() { db_change_field('ocupload_templates', 'path', 'path', array( 'description' => 'Upload path', 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => '', )); } /** * Add new col {ocupload_templates}.image_style_original */ function ocupload_update_7102() { db_add_field('ocupload_templates', 'image_style_original', array( 'description' => 'Image style for original image', 'type' => 'varchar', 'length' => 50, 'not null' => TRUE, 'default' => '', )); } /** * Add new col {ocupload_templates}.max_filesize */ function ocupload_update_7103() { db_add_field('ocupload_templates', 'max_filesize', array( 'description' => 'Max filesize in bytes', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, )); } /** * Add new col {ocupload_templates}.max_dimensions */ function ocupload_update_7104() { db_add_field('ocupload_templates', 'max_dimensions', array( 'description' => 'Maximum image resolution', 'type' => 'varchar', 'length' => 20, 'not null' => TRUE, 'default' => '', )); }