3, 'path' => drupal_get_path('module', 'bf_calendar_field')); } /** * bf_calendar_field_form_calendar_admin_settings_alter() * * @param mixed $form * @param mixed $form_state * @return void */ function bf_calendar_field_form_calendar_admin_settings_alter(&$form, &$form_state) { $calendars = _bf_calendar_field_get_calendars(); $values = array(); foreach ($calendars as $calendar) { $values[] = $calendar->name. '|'. $calendar->machine_name; } $form['bf_calendar'] = array( '#type' => 'fieldset', //'#title' => 'qwe', 'calendar_type' => array( '#title' => t('Calendars'), '#type' => 'textarea', '#default_value' => join("\n", $values), ), ); //$form['#validate'][] = ''; $form['#submit'][] = 'bf_calendar_field_settings_submit'; } /** * bf_calendar_field_settings_submit() * * @param mixed $form * @param mixed $form_state * @return void */ function bf_calendar_field_settings_submit(&$form, &$form_state) { $values = $form_state['values']; $calendars = preg_split( '/\r\n|\r|\n/', $values['calendar_type']); db_delete('calendar_field') ->execute(); foreach($calendars as &$calendar) { list($name, $machine_name) = explode('|', $calendar); if (!trim($name)) { continue; } if (!$machine_name) { $machine_name = preg_replace('@[^a-z0-9_]+@', '_', $name); } db_insert('calendar_field') ->fields(array( 'name' => $name, 'machine_name' => $machine_name, )) ->execute(); } } /** * _bf_calendar_field_get_calendars() * * @return */ function _bf_calendar_field_get_calendars() { $calendars = db_select('calendar_field', 'cf') ->fields('cf') ->execute() ->fetchAll(); return $calendars; } /** * bf_calendar_field_permission() * * @return void */ function bf_calendar_field_permission() { $perms = array(); $calendars = _bf_calendar_field_get_calendars(); foreach ($calendars as $calendar) { $perms[_bf_calendar_field_get_permission_name($calendar->machine_name, 'admin')] = array( 'title' => t('Create/edit events on calendar !calendar', array('!calendar' => $calendar->name)), 'description' => t('Perform administration tasks on calendar !calendar', array('!calendar' => $calendar->name)), ); $perms[_bf_calendar_field_get_permission_name($calendar->machine_name, 'view')] = array( 'title' => t('View events of calendar !calendar', array('!calendar' => $calendar->name)), 'description' => '', ); } return $perms; } /** * _bf_calendar_field_get_permission_name() * * @param mixed $machine_name * @param string $mode * @return */ function _bf_calendar_field_get_permission_name($machine_name, $mode = 'view') { return ($mode == 'admin' ? 'administer calendar ' : 'view calendar '). $machine_name; } /** * bf_calendar_field_date_format_types() * * @return */ function bf_calendar_field_date_format_types() { return array( 'bf_calendar_field_year' => t('Calendar - Year'), 'bf_calendar_field_month' => t('Calendar - Month'), 'bf_calendar_field_week' => t('Calendar - Week'), 'bf_calendar_field_day' => t('Calendar - Day'), ); } /** * bf_calendar_field_date_formats() * * @return */ function bf_calendar_field_date_formats() { return FALSE; } /** * bf_calendar_field_process_date_nav_title() * * @param mixed $vars * @return void */ function bf_calendar_field_process_date_nav_title(&$vars) { switch ($vars['granularity']) { case 'year': $vars['format'] = date_format_type_format('bf_calendar_field_year'); break; case 'month': $vars['format'] = date_format_type_format('bf_calendar_field_month'); break; case 'week': $vars['format'] = date_format_type_format('bf_calendar_field_week'); break; case 'day': $vars['format'] = date_format_type_format('bf_calendar_field_day'); break; } } array( 'render element' => 'element', ), ); } function bf_gallery_theme_registry_alter(&$theme_registry) { //$theme_registry['image_formatter']['path'] = drupal_get_path('module', 'bf_gallery'). '/theme'; //$theme_registry['image_formatter']['template'] = 'field--image'; } function _bf_gallery_get_library_path($module = 'galleria') { $library_path = libraries_get_path($module); if (!empty($library_path)) { // Attempt to use minified version of Galleria plugin. if ($galleria_path = array_shift(glob($library_path . '/galleria*.min.js'))) { return $galleria_path; } // Otherwise use non-minified version if available. elseif ($galleria_path = array_shift(glob($library_path . '/galleria*.js'))) { return $galleria_path; } } return false; } 'CSV export/import', 'description' => '', 'page callback' => 'drupal_get_form', 'page arguments' => array('bf_node_import_form'), 'access callback' => 'bf_node_import_access', 'access arguments' => array('import nodes'), 'type' => MENU_LOCAL_TASK, ); return $items; } /** * bf_node_import_permission() * * @return */ function bf_node_import_permission() { return array( 'import nodes' => array( 'title' => t('Import content from CSV'), 'description' => '', ), ); } /** * bf_node_import_access() * * @param mixed $permission * @return */ function bf_node_import_access($permission) { return user_access($permission); } /** * bf_node_import_form() * * @param mixed $form * @param mixed $form_state * @return */ function bf_node_import_form($form, &$form_state) { $nodeTypes = _node_types_build()->types; if (!isset($form_state['storage']['step'])) { $form_state['storage']['step'] = 1; } $nodeTypeOptions = array(); foreach ($nodeTypes as $nodeType => $Type) { $nodeTypeOptions[$nodeType] = $Type->name; } switch ($form_state['storage']['step']) { case 1: default: $form['set-node-type'] = array( '#type' => 'fieldset', '#title' => t('Node type'), 'node-type' => array( '#type' => 'select', '#default_value' => variable_get('bf_node_import_limit', 5), '#attributes' => array( ), '#options' => $nodeTypeOptions ), ); $form['actions'] = array( '#type' => 'actions', 'export' => array( '#type' => 'submit', '#name' => 'export', '#value' => t('Export'), ), 'import' => array( '#type' => 'submit', '#name' => 'import', '#value' => t('Import'), ), ); break; case 2: $op = $form_state['storage']['op']; switch($op) { case 'import': $form = _bf_node_import_form_import_2($form, $form_state); break; case 'export': $form = _bf_node_import_form_export_2($form, $form_state); break; } break; } return $form; } /** * _bf_node_import_form_import_2() * * @param mixed $form * @param mixed $form_state * @return */ function _bf_node_import_form_import_2($form, &$form_state) { $form['#attributes'] = array('enctype' => "multipart/form-data"); $form['set-import'] = array( '#type' => 'fieldset', '#title' => t('Select CSV file'), '#collapsible' => false, 'csv' => array( '#type' => 'file', '#title' => t('File'), ), ); $form['actions'] = array( '#type' => 'actions', 'upload' => array( '#type' => 'submit', '#name' => 'upload', '#value' => t('Upload'), ), ); return $form; } /** * _bf_node_import_form_export_2() * * @param mixed $form * @param mixed $form_state * @return */ function _bf_node_import_form_export_2($form, &$form_state) { $nodeType = $form_state['storage']['node-type']; $defaultFields = array( 'nid' => t('Node ID'), 'title' => t('Title'), ); $selectableFields = field_info_instances('node', $nodeType); $options = array(); foreach ($selectableFields as $field => $info) { $options[$field] = $info['label']; } $form['set-fields'] = array( '#type' => 'fieldset', '#title' => t('Select fields'), '#collapsible' => false, ); foreach ($defaultFields as $fieldName => $title) { $form['set-fields'][$fieldName] = array( '#type' => 'checkbox', '#title' => $title, '#default_value' => 1, '#disabled' => TRUE, ); } $form['set-fields']['fields'] = array( '#type' => 'checkboxes', '#options' => $options, '#default_value' => array_keys($options), ); $form['actions'] = array( '#type' => 'actions', 'download' => array( '#type' => 'submit', '#name' => 'download', '#value' => t('Download'), ), 'back' => array( '#type' => 'submit', '#name' => 'back', '#value' => t('Back'), ), ); return $form; } /** * bf_node_import_form_validate() * * @param mixed $form * @param mixed $form_state * @return void */ function bf_node_import_form_validate($form, &$form_state) { } /** * bf_node_import_form_submit() * * @param mixed $form * @param mixed $form_state * @return void */ function bf_node_import_form_submit($form, &$form_state) { $formValues = $form_state['values']; $op = $form_state['clicked_button']['#name']; switch ($form_state['storage']['step']) { case 1: $form_state['storage']['op'] = $op; $form_state['rebuild'] = TRUE; $form_state['storage']['node-type'] = $formValues['node-type']; $form_state['storage']['step'] = 2; switch ($op) { case 'export': break; case 'import': break; } break; case 2: switch ($op) { case 'upload': _bf_node_import_form_submit_import_2($form, $form_state); break; case 'download': _bf_node_import_form_submit_export_2($form, $form_state); break; default: } break; default: } } /** * _bf_node_import_import_form_submit_import_2() * * @param mixed $form * @param mixed $form_state * @return void */ function _bf_node_import_form_submit_import_2($form, &$form_state) { $files = $_FILES['files']; $fields = array(); $nodes = array(); $csvUploaded = array(); $nodeType = $form_state['storage']['node-type']; foreach ($files as $paramName => $param) { $csvUploaded[$paramName] = $param['csv']; } $csvPath = $csvUploaded['tmp_name']; if (($csv = fopen($csvPath, 'r')) != FALSE) { $first = TRUE; while (($row = fgetcsv($csv, 10000, ';', '"')) != FALSE) { if ($first) { $fields = $row; $first = FALSE; continue; } $nodes[] = array_combine($fields, $row); } } foreach ($nodes as $node) { $success = _bf_node_import_update_node($node, $nodeType); } } /** * _bf_node_import_update_node() * * @param mixed $data * @param mixed $nodeType * @return */ function _bf_node_import_update_node(array $data, $nodeType) { static $fieldInfo; $nid = $data['nid']; if (!(int)$nid) { return FALSE; } unset($data['nid']); $Node = node_load($nid); if ($Node->type !== $nodeType) { $nodeTypeInfo = node_type_load($nodeType); drupal_set_message(t('Node #!nid is not !type!', array('!nid' => $nid, '!type' => $nodeTypeInfo->name)), 'error'); return FALSE; } //$fields = field_info_instances('node', $nodeType); foreach ($data as $fieldName => $value) { if (!isset($fieldInfo[$fieldName])) { $fieldInfo[$fieldName] = field_info_field($fieldName); } switch ($fieldInfo[$fieldName]['module']) { case 'taxonomy': $tids = array(); $termNames = explode('|', $value); foreach ($termNames as $termName) { $vocab_name = $info['settings']['allowed_values'][0]['vocabulary']; $terms = taxonomy_get_term_by_name($termName, $vocab_name); foreach ($terms as $tid => $term) { $tids[] = $tid; } } _bf_node_import_set_taxonomy($Node, $fieldName, $tids); break; case 'text': $Node->body['und'][0]['value'] = $value; break; default: $Node->{$fieldName} = $value; } } //return TRUE; return node_save($Node); } /** * _bf_node_import_form_submit_export_2() * * @param mixed $form * @param mixed $form_state * @return void */ function _bf_node_import_form_submit_export_2($form, &$form_state) { $formValues = $form_state['values']; $op = $form_state['clicked_button']['#name']; $nodeType = $form_state['storage']['node-type']; $selectedFields = $formValues['fields']; switch($op) { case 'download': foreach ($selectedFields as $fieldName => $selected) { if (!$selected) { unset($selectedFields[$fieldName]); } } $rows = array(); $defaultFields = drupal_map_assoc(array('nid', 'title')); $selectedFields = array_merge($defaultFields, $selectedFields); $nids = db_select('node', 'n') ->fields('n', array('nid')) ->condition('type', $nodeType) ->execute() ->fetchCol(); $nodes = node_load_multiple($nids); $rows[0] = $selectedFields; foreach ($nodes as $nid => $node) { $row = array(); foreach ($selectedFields as $fieldName) { $row[] = _bf_node_import_get_field_value($node, $fieldName); } $rows[] = $row; } $tempDir = file_directory_temp(); $csvUri = 'temporary://node_export_'.$nodeType.'_'.date('Ymd').'_'.date('Hi').'.csv'; if (($f = fopen($csvUri, 'w+')) != FALSE) { foreach ($rows as $row) { fputcsv($f, $row, ';', '"'); } } _bf_node_import_download($csvUri); break; case 'back': break; } } /** * _bf_node_import_get_field_value() * * @param mixed $node * @param mixed $fieldName * @return */ function _bf_node_import_get_field_value(stdClass $node, $fieldName) { if (!isset($node->{$fieldName})) { return NULL; } $value = $node->{$fieldName}; if (is_array($value)) { $field = field_info_field($fieldName); switch ($field['type']) { case 'taxonomy_term_reference': $terms = array(); $values = $value[LANGUAGE_NONE]; foreach ($values as $v) { $term = taxonomy_term_load($v['tid']); $terms[] = $term->name; } return join('|', array_unique($terms)); break; case 'text_with_summary': foreach ($value as $lang => $values) { foreach ($values as $text) { return $text['value']; } } break; } } elseif (is_object($value)) { return FALSE; } else { return $value; } } /** * _bf_node_import_download() * * @param mixed $uri * @return void */ function _bf_node_import_download($uri) { $filePath = drupal_realpath($uri); $fileName = basename($filePath); $fileSize = filesize($filePath); $headers = array( 'Content-Type' => 'force-download', 'Content-Disposition' => 'attachment; filename="' . $fileName . '"', 'Content-Length' => $fileSize, 'Content-Transfer-Encoding' => 'binary', 'Pragma' => 'no-cache', 'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0', 'Expires' => '0', 'Accept-Ranges' => 'bytes' ); file_transfer($uri, $headers); } /** * _bf_node_import_set_taxonomy() * * @param mixed $Node * @param mixed $fieldName * @param mixed $tids * @return void */ function _bf_node_import_set_taxonomy(stdClass &$Node, $fieldName, $tids) { $Node->{$fieldName}[LANGUAGE_NONE] = array(); foreach ($tids as $tid) { $Node->{$fieldName}[LANGUAGE_NONE][] = array('tid' => $tid); } } 'Personal feeds configuration', 'description' => '', 'page callback' => 'drupal_get_form', 'page arguments' => array('bf_personal_feeds_admin_form'), 'access arguments' => array('administer site configuration'), 'file' => 'bf_personal_feeds.admin.inc', ); $terms_enabled = _bf_personal_feeds_get_terms_enabled(); if (!empty($terms_enabled)) { $items['user/%user/personal_feeds'] = array( 'title' => 'Feeds', 'page callback' => 'drupal_get_form', 'page arguments' => array('bf_personal_feeds_user_form'), 'access callback' => 'bf_personal_feeds_user_access', 'access arguments' => array(1), 'type' => MENU_LOCAL_TASK, ); } return $items; } function bf_personal_feeds_views_api() { return array('api' => 3, 'path' => drupal_get_path('module', 'bf_personal_feeds')); } /** * _bf_personal_feeds_get_terms() * * @param mixed $uid * @return */ function _bf_personal_feeds_get_terms($uid) { if (!(int)$uid) { return FALSE; } $rows = (array)db_select('personal_feeds', 'pn') ->fields('pn') ->condition('pn.uid', (int)$uid) ->execute() ->fetchAll(); $terms = array(); foreach ($rows as $row) { $terms[$row->node_type][] = (int)$row->tid; } return $terms; } /** * _bf_personal_feeds_get_terms_enabled() * * @return */ function _bf_personal_feeds_get_terms_enabled() { $rows = (array)db_select('personal_feeds_admin', 'pn') ->fields('pn') ->execute() ->fetchAll(); $terms = array(); foreach ($rows as $row) { $terms[$row->node_type][] = (int)$row->tid; } return $terms; } /** * _bf_personal_feeds_get_user_tids() * * @return */ function _bf_personal_feeds_get_user_tids() { global $user; $tids = array(); $nids = array(); $terms = array (); $limit = variable_get('bf_personal_feeds_limit', 5); $enabled = _bf_personal_feeds_get_terms_enabled(); if (is_object($user) && (int)$user->uid) { $terms = _bf_personal_feeds_get_terms((int)$user->uid); } if (is_array($terms) && !empty($terms)) { foreach ($terms as $nodeType => $tids_) { $tids = array_merge($tids, $tids_); } $tids = array_unique($tids); return $tids; } return FALSE; } array( 'render element' => 'element', ), 'bf_upload_items' => array( 'render element' => 'element' ) ); } /** * Theme Upload widget. */ function theme_bf_upload_uploader($variables) { $element = $variables['element']; $attributes = array(); if (isset($element['#id'])) { $attributes['id'] = $element['#id']; } if (!empty($element['#attributes']['class'])) { $attributes['class'] = (array)$element['#attributes']['class']; } $attributes['class'][] = 'bf_upload'; $hasTitle = isset($element['#bf_upload_override']['title_field']) && $element['#bf_upload_override']['title_field'] == 1; if ($hasTitle) { $attributes['class'][] = 'has-title'; } /* $hasAlt = (bool)(isset($element['#bf_upload_override']['alt_field']) && $element['#bf_upload_override']['alt_field'] == 1); if ($hasAlt) { $attributes['class'][] = 'has-alt'; } */ $output = '
    '. theme('bf_upload_items', array('element' => $element)).'
' . t('Drag files here') . '
' . implode("\n", $element['#info']) . '
'; return $output; } /** * Theme Batch upload items within widget. */ function theme_bf_upload_items($vars) { $element = &$vars['element']; if (isset($element['#default_value']) && !empty($element['#default_value'])) { $items = &$element['#default_value']; } else { return ''; } $output = ''; foreach ($items as $delta => $item) { // If user deleted all items I'll get array('fid' => 0) if ($item['fid'] > 0) { $hasTitle = $element['#bf_upload_override']['title_field'] == 1; $hasAlt = $element['#bf_upload_override']['alt_field'] == 1; $hasDescription = $element['#bf_upload_override']['description_field'] == 1; $name = $element['#name'] . '[' . $delta . ']'; $fileTypeThumb = '
%s %s
'; $fileTypeThumbCaption = (!empty($item['uri'])) ? $item['uri'] : print_r($item, true); $fileTypeThumb = sprintf($fileTypeThumb, theme('image', array('path' => '/'. _bf_upload_get_filetype_image($item))), $fileTypeThumbCaption); $output .= '
  • '. ($item['type'] == 'image' ? theme('image_style', array('style_name' => $element['#bf_upload']['image_style'], 'path' => $item['uri'])) : $fileTypeThumb) .'
    '. ($hasTitle ? '' : ''). ($hasDescription ? '' : ''). //($hasAlt ? '' : ''). ' '; (isset($item['rename']) ? '' : '').'
  • '; } } return $output; } array( 'label' => t('BIG FISH Uploader'), 'field types' => array('file', 'image'), 'behaviors' => array( 'multiple values' => FIELD_BEHAVIOR_CUSTOM, 'default value' => FIELD_BEHAVIOR_NONE, ), ), ); } /** * _field_widget_settings_form */ function bf_upload_field_widget_settings_form($field, $instance) { $form = array(); switch ($field['type']) { case 'image': $styles = array(); foreach (image_styles() as $name => $style) { $styles[$name] = $style['name']; } $form['image_style'] = array( '#type' => 'select', '#title' => t('Image style'), '#default_value' => isset($instance['widget']['settings']['image_style']) ? $instance['widget']['settings']['image_style'] : 'thumbnail', '#options' => $styles ); break; } return $form; } /** * _field_widget_form */ function bf_upload_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) { $parents = array_merge( array('values', $element['#field_name'], $element['#language']), $element['#field_parents'] ); $state_data = drupal_array_get_nested_value($form_state, $parents); // We inform user about restrictions $info = array(); if ($field['cardinality'] > 0) { $info[] = '
    '. t("You can upload up to !num files.", array('!num' => '' . $field['cardinality'] . '')). '
    '; } if (isset($instance['settings']['max_filesize']) && !empty($instance['settings']['max_filesize'])) { $info[] = '
    '. t("Maximal file size: !size", array('!size' => ''. $instance['settings']['max_filesize'] . '')). '
    '; } $info[] = '
    '. t("Allowed files types: !types.", array('!types' => '' . $instance['settings']['file_extensions'] . '')). '
    '; /* $max = $instance['settings']['max_resolution']; $min = $instance['settings']['min_resolution']; if ($min && $max && $min == $max) { $info[] = '
    '. t('Images must be exactly !size pixels.', array('!size' => '' . $max . '')). '
    '; } elseif ($min && $max) { $info[] = '
    '. t('Images must be between !min and !max pixels.', array('!min' =>'' . $min . '', '!max' => '' . $max . '')). '
    '; } elseif ($min) { $info[] = '
    '. t('Images must be larger than !min pixels.', array('!min' => '' . $min . '')). '
    '; } elseif ($max) { $info[] = '
    '. t('Images must be smaller than !max pixels.', array('!max' => '' . $max . '')). '
    '; } */ if (isset($state_data)) { $default_values = $state_data; } else { if (isset($items)) { $default_values = $items; } else { $default_values = array(); } } $images = array( '#type' => 'bf_upload', '#default_value' => $default_values, '#info' => $info ); // Allowed file types(extensions) needs to be set here $ext = new stdClass(); $ext->title = 'Allowed extensions'; // This won't show up anywhere so no t() $ext->extensions = (isset($instance['settings']['file_extensions']) && !empty($instance['settings']['file_extensions'])) ? strtr($instance['settings']['file_extensions'], ' ', ',') : 'jpg,png,gif'; $images['#bf_upload_override']['filters'] = array($ext); // Maximal file size if (isset($instance['settings']['max_filesize']) && !empty($instance['settings']['max_filesize'])) { $images['#bf_upload_override']['max_file_size'] = $instance['settings']['max_filesize']; } // URL callback for Plupload library has to be altered so we can get instance ID for later validation $images['#bf_upload_override']['url'] = url('bf_upload/' . $instance['id'], array( 'query' => array( 'bf_upload_token' => drupal_get_token('bf_upload-handle-uploads') ) )); $images['#bf_upload_override']['image_style'] = isset($instance['widget']['settings']['image_style']) ? $instance['widget']['settings']['image_style'] : 'thumbnail'; $images['#bf_upload_override']['alt_field'] = (int)$instance['settings']['alt_field']; $images['#bf_upload_override']['title_field'] = (int)$instance['settings']['title_field']; $images['#bf_upload_override']['description_field'] = (int)$instance['settings']['description_field']; // We set the maximum files user can upload $images['#bf_upload_override']['max_files'] = (int)$field['cardinality']; $element += $images; return $element; } true, '#title' => null, '#process' => array('bf_upload_process_element'), '#value_callback' => 'bf_upload_value_element', '#element_validate' => array('bf_upload_validate_element'), '#pre_render' => array('bf_upload_pre_render_element'), '#default_value' => null, '#required' => false, '#autocomplete_path' => false, '#theme_wrappers' => array('form_element'), '#theme' => 'bf_upload_uploader', '#upload_location' => null, '#info' => array(), '#attached' => array('library' => array(array('bf_upload', 'plupload'))), '#bf_upload' => array( 'container' => 'bf_upload-container', 'browse_button' => 'bf_upload-select', 'upload' => 'bf_upload-upload', 'runtimes' => 'html5,gears,flash,silverlight,browserplus,html4', 'max_file_size' => '512MB', 'chunk_size' => '2048K', 'url' => url('bf_upload', array( 'query' => array( 'bf_upload_token' => drupal_get_token('bf_upload-handle-uploads') ) ) ), 'filters' => array(), 'unique_names' => false, 'flash_swf_url' => base_path() . $plupload. '/js/plupload.flash.swf', 'silverlight_xap_url' => base_path() . $plupload. '/js/plupload.silverlight.xap', 'drop_element' => 'bf_upload-filelist', 'multipart' => true, 'dragdrop' => true, 'multiple_queues' => true, 'urlstream_upload' => false, 'image_style' => 'thumbnail', 'image_style_path' => '', 'max_files' => -1, ), '#bf_upload_override' => array() ); return $types; } /** * Value callback needed for removing all items. */ function bf_upload_value_element(&$element, $input = false, $form_state = null) { // Default state - no new data if ($input === false) { return null; } // Field was emptied - user deleted all files if (is_null($input)) { return array(array('fid' => 0)); } // Field has new data return $input; } /** * Process callback to set JS settings before Plupload init. */ function bf_upload_process_element($element, &$form_state, $form) { $rand = mt_rand(1,1000); $element['#bf_upload']['browse_button'] .= $rand; $element['#bf_upload']['container'] .= $rand; $element['#bf_upload']['upload'] .= $rand; $element['#default_value'] = isset($element['#value']) ? $element['#value'] : $element['#default_value']; $element['#bf_upload']['name'] = $element['#name']; $element['#bf_upload'] = array_merge($element['#bf_upload'], $element['#bf_upload_override']); $files = file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath(); $element['#bf_upload']['image_style_path'] = base_path() . $files . '/styles/' . $element['#bf_upload']['image_style']. '/'; $element['#attached']['js'][] = array( 'data' => array( 'bf_upload' => array($element['#bf_upload']) ), 'type' => 'setting', ); return $element; } /** * Pre-render callback to load existing items. */ function bf_upload_pre_render_element($element) { if (isset($element['#default_value']) && !empty($element['#default_value'])) { foreach ($element['#default_value'] as $delta => $item) { $element['#default_value'][$delta] = array_merge($item, (array)file_load($item['fid'])); } } return $element; } /** * Element validation callback. */ function bf_upload_validate_element($element, &$form_state, $form) { if ($element['#required'] == true && $element['#value'][0]['fid'] == 0) { form_error($element, t("@field field is required.", array('@field' => $element['#title']))); } $cardinality = isset($element['#bf_upload_override']['max_files']) ? $element['#bf_upload_override']['max_files'] : $element['#bf_upload']['max_files']; if ($cardinality > 0 && count($element['#value']) > $cardinality) { form_error($element, t("Only !num items are allowed.", array('!num' => $cardinality))); } } '', 'fields' => array( 'name' => array( 'description' => 'Name', 'type' => 'varchar', 'length' => 255, 'not null' => true, ), 'machine_name' => array( 'description' => 'Machine name', 'type' => 'varchar', 'length' => 32, 'not null' => true, ), ), 'unique keys' => array( 'machine_name' => array('machine_name'), ), 'primary key' => array('machine_name'), ); return $schema; } '', 'fields' => array( 'uid' => array( 'description' => 'User ID', 'type' => 'int', 'unsigned' => true, 'not null' => true, ), 'node_type' => array( 'description' => 'Node type', 'type' => 'varchar', 'length' => 32, 'not null' => true, ), 'tid' => array( 'description' => 'Term ID', 'type' => 'int', 'unsigned' => true, 'not null' => true, ), ), 'unique keys' => array( 'uid_node_type_tid' => array('uid', 'node_type', 'tid'), ), //'primary key' => array('aid'), 'foreign keys' => array( 'users' => array( 'table' => 'users', 'columns' => array( 'uid' => 'uid', ), ), 'taxonomy_term_data' => array( 'table' => 'taxonomy_term_data', 'columns' => array( 'tid' => 'tid', ), ), ) ); $schema['personal_feeds_admin'] = array( 'description' => '', 'fields' => array( 'node_type' => array( 'description' => 'Node type', 'type' => 'varchar', 'length' => 32, 'not null' => true, ), 'tid' => array( 'description' => 'Term ID', 'type' => 'int', 'unsigned' => true, 'not null' => true, ), ), 'unique keys' => array( 'node_type_tid' => array('node_type', 'tid'), ), //'primary key' => array('aid'), 'foreign keys' => array( 'taxonomy_term_data' => array( 'table' => 'taxonomy_term_data', 'columns' => array( 'tid' => 'tid', ), ), ), ); return $schema; } http://bat.kertk.szie.hu

    April 2024

    Mon Tue Wed Thu Fri Sat Sun
    1
    2
    3
    4
    5
    6
    7
     
     
     
     
     
     
     
    8
    9
    10
    11
    12
    13
    14
     
     
     
     
     
     
     
    15
    16
    17
    18
    19
    20
    21
     
     
     
     
     
     
     
    22
    23
    24
    25
    26
    27
    28
     
     
     
     
     
     
     
    29
    30
    1
    2
    3
    4
    5