示例#1
0
/**
 * Provide information about the way your module's aliases will be built.
 *
 * The information you provide here is used to build the form
 * on search/path/patterns. File pathauto.pathauto.inc provides example
 * implementations for system modules.
 *
 * @see node_pathauto
 *
 * @param $op
 *   At the moment this will always be 'settings'.
 *
 * @return object|null
 *   An object, or array of objects (if providing multiple groups of path
 *   patterns).  Each object should have the following members:
 *   - 'module': The module or entity type.
 *   - 'token_type': Which token type should be allowed in the patterns form.
 *   - 'groupheader': Translated label for the settings group
 *   - 'patterndescr': The translated label for the default pattern (e.g.,
 *      t('Default path pattern (applies to all content types with blank
 *      patterns below)')
 *   - 'patterndefault': Default pattern  (e.g. 'content/[node:title]'
 *   - 'batch_update_callback': The name of function that should be ran for
 *      bulk update. @see node_pathauto_bulk_update_batch_process for example
 *   - 'batch_file': The name of the file with the bulk update function.
 *   - 'patternitems': Optional. An array of descritpions keyed by bundles.
 */
function hook_pathauto($op)
{
    switch ($op) {
        case 'settings':
            $settings = array();
            $settings['module'] = 'file';
            $settings['token_type'] = 'file';
            $settings['groupheader'] = t('File paths');
            $settings['patterndescr'] = t('Default path pattern (applies to all file types with blank patterns below)');
            $settings['patterndefault'] = 'files/[file:name]';
            $settings['batch_update_callback'] = 'file_entity_pathauto_bulk_update_batch_process';
            $settings['batch_file'] = drupal_get_path('module', 'file_entity') . '/file_entity.pathauto.inc';
            foreach (file_type_get_enabled_types() as $file_type => $type) {
                $settings['patternitems'][$file_type] = t('Pattern for all @file_type paths.', array('@file_type' => $type->label));
            }
            return (object) $settings;
        default:
            break;
    }
}
 protected function getValidators()
 {
     $extensions = array();
     $types = file_type_get_enabled_types();
     foreach ($types as $t => $type) {
         $extensions = array_merge($extensions, _os_files_extensions_from_type($t));
     }
     $validators = array('file_validate_extensions' => array(implode(' ', $extensions)), 'file_validate_size' => array(parse_size(file_upload_max_size())));
     return $validators;
 }
示例#3
0
/**
 * Provide information about the way your module's aliases will be built.
 *
 * The information you provide here is used to build the form
 * on search/path/patterns
 *
 * @return array
 *   A 2-level array of automatic path settings. Each item should have a unique
 *   key (often the name of the providing module). Each sub-array should contain
 *   the following:
 *   - entity type: The type of entity on which patterns will be created. All
 *       entities of this type will have a "path" property added to their
 *       objects upon loading.
 *   - label: Translated label for the settings group.
 *   - pattern description: The translated label for the default pattern (e.g.,
 *       t('Default path pattern (applies to all content types with blank
 *       patterns)')
 *   - pattern default: Default pattern  (e.g. 'content/[node:title]')
 *   - batch update callback: The name of function that should be ran for
 *       bulk update. See node_path_bulk_update_batch_process() for an example.
 *   - batch file: The name of the file with the bulk update function.
 *   - source prefix: The prefix for source URLs generated for this type of
 *       path (e.g nodes have a source prefix of "node/" and taxonomy terms have
 *       a prefix of "taxonomy/term/". This is used when bulk deleting paths.
 *   - pattern items: Optional. An array of descriptions keyed by bundles.
 *
 * @see path_get_info()
 * @see path_entity_load()
 * @see path_entity_insert()
 * @see path_entity_update()
 * @see path_entity_delete()
 */
function hook_path_info()
{
    // Aliases on files are not normally supported, this would add support for
    // auto-aliasing files.
    $info['file'] = array('entity type' => 'file', 'label' => t('File paths'), 'pattern description' => t('Default path pattern (applies to all file types with blank patterns below)'), 'pattern default' => 'files/[file:name]', 'batch update callback' => 'file_entity_path_bulk_update_batch_process', 'batch file' => 'file.path.inc');
    foreach (file_type_get_enabled_types() as $file_type => $type) {
        $info['file']['pattern items'][$file_type] = t('Pattern for all @file_type paths.', array('@file_type' => $type->label));
    }
    return $info;
}