cluesshop.com

Showing posts with label mutiple image upload file. Show all posts
Showing posts with label mutiple image upload file. Show all posts

Monday, 19 May 2014

mutiple image uplaod

 custome_block.module

<?php

/**
 * Implements hook_block_info().
 */
function custom_block_block_info() {
  $blocks = array();
  $blocks['my_block'] = array(
    'info' => t('My Custom Block'),
  );

  return $blocks;
}

/**
**
 * Implements hook_block_configure().
 */
function custom_block_block_configure($delta='') {
  $form = array();

  switch($delta) {
    case 'my_block' :
      // Text field form element
      $form['text_body'] = array(
        '#type' => 'text_format',
        '#title' => t('Enter your text here in WYSIWYG format'),
        '#default_value' => variable_get('text_variable', ''),
      );

      // File selection form element
      $form['file'] = array(
        '#name' => 'block_image',
        '#type' => 'managed_file',
        '#title' => t('Choose an Image File'),
        '#description' => t('Select an Image for the custom block.  Only *.gif, *.png, *.jpg, and *.jpeg images allowed.'),
        '#default_value' => variable_get('block_image_fid', ''),
        '#upload_location' => 'public://block_image/',
        '#upload_validators' => array(
          'file_validate_extensions' => array('gif png jpg jpeg'),
        ),
      );
      break;
  }
  return $form;
}

/**
 * Implements hook_block_save().
 */
function custom_block_block_save($delta = '', $edit = array()) {
  switch($delta) {
    case 'my_block' :
      // Saving the WYSIWYG text     
      variable_set('text_variable', $edit['text_body']['value']);

      // Saving the file, setting it to a permanent state, setting a FID variable
      $file = file_load($edit['file']);
      $file->status = FILE_STATUS_PERMANENT;
      file_save($file);
      $block = block_load('custom_block', $delta);
      file_usage_add($file, 'custom_block', 'block', $block->bid);
      variable_set('block_image_fid', $file->fid);
      break;
  }
}


/**
 * Implements hook_block_view().
 */
function custom_block_block_view($delta='') {
  $block = array();

  switch($delta) {
    case 'my_block' :
      $block['content'] = my_block_view();
      break;
  }

  return $block;
}

/**
 * Custom function to assemble renderable array for block content.
 * Returns a renderable array with the block content.
 * @return
 *   returns a renderable array of block content.
 */
//function my_block_view() {
//  $block = array();
//
// 
// 
//  // Capture the image file path and form into HTML with attributes
//  $image_file = file_load(variable_get('block_image_fid', ''));
//  $image_path = '';
//
//  if (isset($image_file->uri)) {
//    $image_path = $image_file->uri;
//  }
//
//  $image = theme_image(array(
//    'path' => ($image_path),
//    'alt' => t('Image description here.'),
//    'title' => t('This is our block image.'),
//    'attributes' => array('class' => 'class_name'),
//  ));
//
//  // Capture WYSIWYG text from the variable
//  $text = variable_get('text_variable', '');
//
//  // Block output in HTML with div wrapper
//  $block = array(
//    'image' => array(
//      '#prefix' => '<div class="class_name">',
//      '#type' => 'markup',
//      '#markup' => $image,
//    ),
//    'message' => array(
//      '#type' => 'markup',
//      '#markup' => $text,
//      '#suffix' => '</div>',
//    ),
//  );
//
//  return $block;
//}


//function my_block_view($delta = ''){
//    $block = array();
//   switch ($delta) {
//    case 'slider_custom_block':
//      $block['subject'] = '';
//      $block['content'] = _bannerblocks_slider();
//      break;
// 
//  }
//  return $block;
//}


function my_block_view() {
   
    $image_file = file_load(variable_get('block_image_fid', ''));
  $image_path = '';

  if (isset($image_file->uri)) {
    $image_path = $image_file->uri;
  }
  $image = theme_image(array(
    'path' => ($image_path),
  ));

//  var_dump($image);
//  exit();
  // Capture WYSIWYG text from the variable
  $text = variable_get('text_variable', '');
     
    $bannerHtml='';
   $bannerHtml.='<div class="container-fluid">';
     $bannerHtml.='<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">';
              
                $bannerHtml.='<ol class="carousel-indicators">';
                    $bannerHtml.='<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>';
                    $bannerHtml.='<li data-target="#carousel-example-generic" data-slide-to="1"></li>';
                    $bannerHtml.='<li data-target="#carousel-example-generic" data-slide-to="2"></li>';
                    $bannerHtml.='<li data-target="#carousel-example-generic" data-slide-to="3"></li>';
                $bannerHtml.='</ol>';

                $bannerHtml.='<div class="carousel-inner">';
               
               
                    $bannerHtml.='<div class="item active">';
                    $bannerHtml.='<img src="'.base_path() . path_to_theme().'/images/banner1.jpg" alt="">';
                   $bannerHtml.='</div>';
                                    
                    $bannerHtml.='<div class="item">';
                    $bannerHtml.=$image;
                    $bannerHtml.='</div>';               
                    $bannerHtml.='<div class="item">';
                    $bannerHtml.='<img src="'.base_path() . path_to_theme().'/images/banner2.jpg" alt="">';
                    $bannerHtml.='</div>';
                   
                   
                    $bannerHtml.='<div class="item">';
                    $bannerHtml.='<img src="'.base_path() . path_to_theme().'/images/banner4.jpg" alt="">';
                    $bannerHtml.='</div>';
                   
              

                $bannerHtml.='</div>';
                $bannerHtml.='<a href="#" class="download-banner-pdf"><div class="carousel-caption downloder">';
                    $bannerHtml.='<div class="d_tag">';
                        $bannerHtml.='<p>';
                            $bannerHtml.='<span class="download-tag1">download guide</span><span class="download-tag2">: how to<br />';
                            $bannerHtml.='file a successful long term<br />';
                             $bannerHtml.='care insurance claim</span>';
                           
                        $bannerHtml.='</p>';
                        $bannerHtml.='</div>';
                    $bannerHtml.='<div class="d_image">';
                   
                       $bannerHtml.='<img src="'.base_path() . path_to_theme().'/images/downloader.png" class="img-responsive" alt="">';
                    $bannerHtml.='</div>';
                        $bannerHtml.='</div>';

              
                $bannerHtml.='<a class="left carousel-control extra"  data-slide="prev">';

                     $bannerHtml.='<img id="left_carousel" src="'.base_path() . path_to_theme().'/images/prev.png" class="img-responsive" alt="">';
                  $bannerHtml.='</a>';
                  $bannerHtml.='<a class="right carousel-control extra"  data-slide="next">';

                       $bannerHtml.='<img id="right_carousel" src="'.base_path() . path_to_theme().'/images/next.png" class="img-responsive" alt="">';
                  $bannerHtml.='</a>';
            $bannerHtml.='</div>';
           
$bannerHtml.='</div>';
   
      return $bannerHtml;
}

=============
.info
name = custom block
description = Test banner images test
core = 7.x
package =Claim Jockey