Form

Form API

https://api.drupal.org/api/examples/form_example!form_example.module/group/form_example/7

---------------------------------------- form_example.info -----------------------------------------
core = "7.x"
description = "An example module used to learn module development and forms creation."
name = "Form Example Module"

-------------------------------------- form_example.module --------------------------------
<?php

function form_example_menu() {
  $items = array();

  $items['examples/form-example'] = array( //this creates a URL that will call this form at "examples/form-example"
    'title' => 'Example Form', //page title
    'description' => 'A form to mess around with.',
    'page callback' => 'drupal_get_form', //this is the function that will be called when the page is accessed.  for a form, use drupal_get_form
    'page arguments' => array('form_example_form'), //put the name of the form here
    'access callback' => TRUE
  );

  return $items;
}

function form_example_form($form, &$form_state) {

 $form['Overview'] = array(
'#markup' => t('This is just a markup'),
'#prefix' => '<p>',
'#suffix' => '</p>',
 );

 $form['check_box'] = array(
'#title' => t('Just a check box'),
'#description' => t('when enabled .....'),
'#type' => 'checkbox',
'#default_value' => 1,
 );

 $form['default_center'] = array(
'#title' => t('map center'),
'#description' => t('map setter'),
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => FALSE,
 );

 $form['default_center']['inner_elements'] = array(
'#title' => t('latitude'),
'#description' => t('latitude value'),
'#type' => 'textfield',
'#default_value' => 45.225,
'#required' => TRUE,
 );

 $options = range(0,20,1);
 $options[0] = t('0 - furthers');
 $options[20] = t('20 - closest');

 $form['default_zoomer'] = array(
'#title' => t('Gmap zoomer'),
'#description' => t('Zoome google maps'),
'#type' => 'select',
'#options' => $options,
'#default_value' => 8,
'#required' => TRUE,
 );


 $form['price'] = array(
    '#type' => 'textfield', //you can find a list of available types in the form api
    '#title' => 'What is Your Price?',
    '#size' => 10,
    '#maxlength' => 10,
    '#required' => TRUE, //make this field required
  );

  $form['submit_button'] = array(
    '#type' => 'submit',
    '#value' => t('Click Here!'),
  );
 
  return $form;
}

function form_example_form_validate($form, &$form_state) {
  if (!($form_state['values']['price'] > 0)){
    form_set_error('price', t('Price must be a positive number.'));
  }

}

function form_example_form_submit($form, &$form_state) {
}

Import XML Content

Administration menu
https://www.drupal.org/project/admin_menu

Writing module .info files
https://www.drupal.org/node/542202

function hook_block_info
https://api.drupal.org/api/drupal/modules%21block%21block.api.php/function/hook_block_info/7

simplexml_load_file
http://php.net/manual/en/function.simplexml-load-file.php

---------------------- xml_importer.info ------------------------------
name = XML Importer
description = Import XML file
core = 7.x
package = XML_Importer



------------------- xml_importer.module -------------------------------
<?php

function xml_importer_block_info() {
  $blocks['xml_view'] = array(
    'info' => t('xml_view'),
    'cache' => DRUPAL_NO_CACHE,
'region' => 'content',
'visibility' => BLOCK_VISIBILITY_PHP
  );

  return $blocks;
}

function xml_importer_block_view($delta = '') {
  // This example is adapted from node.module.
  $block = array();

  if($delta == 'xml_view'){
 $path = $_SERVER['DOCUMENT_ROOT']."/drupal-xml/sites/all/modules/xml_importer/books.xml";

$xml=simplexml_load_file($path) or die("Error: Cannot create object");
$items = array();
foreach($xml->children() as $books) {

$items[] = array(
'data' => 'Title - '.$books->title .'<BR/>'. 'Author - ' .$books->author .'<BR/>'. 'Genre - ' .$books->genre,

);
}

$block['content'] = theme('item_list', array('items' => $items));

  }
 
  return $block;
}

hello_hook

hello_hook.module

<?php

function hello_hook_init(){
//drupal_set_message("Hello module");
}

function hello_hook_menu(){
$items = array();

$items['hellopage'] = array(
'title' => 'My first item',
'description' => 'hello users',
'page callback' => 'drupal_get_form',
'page arguments' => array('hello_hook_showForm'),
'access callback' => 'user_access',
'access arguments' => array('access content'),
'type' => MENU_NORMAL_ITEM
);

return $items;
}

function hello_hook_showForm(){
$form = array();

$form['name'] = array(
'#type' => 'textfield',
'#title' => 'Enter your name'
);

$form['submit'] = array(
'#type' => 'submit',
'#value' => 'My button'
);

$form['#submit'][] =  'hello_hook_showForm_submit';

return $form;
}

function hello_hook_showForm_submit($form, &$form_state){

if($form_state['values']['name'] == ""){
form_set_error('name', 'name can not be null');
}else{
drupal_set_message("Button pressed ".$form_state['values']['name'] );
}


}


---------------------------------------------------------------------
hello_hook.info

name = Hello Hook
description = Print hello hook
core = 7.x

current_posts

current_posts.module

<?php
/**
 * @file
 * A block module that displays recent blog and forum posts.
 */

 /**
 * Implements hook_help().
 *
 * Displays help and module information.
 *
 * @param path
 *   Which path of the site we're using to display help
 * @param arg
 *   Array that holds the current path as returned from arg() function
 */
function current_posts_help($path, $arg) {
  switch ($path) {
    case "admin/help#current_posts":
      return '<p>' . t("Displays links to nodes created on this date") . '</p>';
      break;
  }
}

/**
 * Implements hook_block_info().
 */
function current_posts_block_info() {
  $blocks['current_posts'] = array(
    // The name that will appear in the block list.
    'info' => t('Current posts'),
    // Default setting.
    'cache' => DRUPAL_CACHE_PER_ROLE,
  );
  return $blocks;
}

/**
 * Custom content function.
 *
 * Set beginning and end dates, retrieve posts from database
 * saved in that time period.
 *
 * @return
 *   A result set of the targeted posts.
 */
function current_posts_contents(){
  //Get today's date.
  $today = getdate();
  //Calculate the date a week ago.
  $start_time = mktime(0, 0, 0,$today['mon'],($today['mday'] - 7), $today['year']);
  //Get all posts from one week ago to the present.
  $end_time = time();

  //Use Database API to retrieve current posts.
  $query = db_select('node', 'n')
    ->fields('n', array('nid', 'title', 'created'))
    ->condition('status', 1) //Published.
    ->condition('created', array($start_time, $end_time), 'BETWEEN')
    ->orderBy('created', 'DESC') //Most recent first.
    ->execute();
  return $query;
}

/**
 * Implements hook_block_view().
 *
 * Prepares the contents of the block.
 */
function current_posts_block_view($delta = '') {
  switch ($delta) {
    case 'current_posts':
      $block['subject'] = t('Current posts');
      if (user_access('access content')) {
        // Use our custom function to retrieve data.
        $result = current_posts_contents();
        // Array to contain items for the block to render.
        $items = array();
        // Iterate over the resultset and format as links.
        foreach ($result as $node) {
          $items[] = array(
            'data' => l($node->title, 'node/' . $node->nid),
          );
        }
       // No content in the last week.
        if (empty($items)) {
          $block['content'] = t('No posts available.');
        }
        else {
          // Pass data through theme function.
          $block['content'] = theme('item_list', array(
            'items' => $items));
        }
      }
    return $block;
  }
 
}

/**
 * Implements hook_menu().
 */
function current_posts_menu() {
  $items = array();

  $items['admin/config/content/current_posts'] = array(
    'title' => 'Current posts',
    'description' => 'Configuration for Current posts module',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('current_posts_form'),
    'access arguments' => array('access administration pages'),
    'type' => MENU_NORMAL_ITEM,
  );

  return $items;
}


------------------------------------------
current_posts.info

name = Current Posts
description = A block module that lists links to recent posts.
core = 7.x

configure = admin/config/content/current_posts

What is 3D Printing?

You’ve heard of 3D printing from newscasters and journalists, astonished at what they’ve witnessed. A machine reminiscent of the Star Trek Replicator, something magical that can create objects out of thin air. It can “print” in plastic, metal, nylon, and over a hundred other materials. It can be used for making nonsensical little models like the over-printed Yoda, yet it can also print manufacturing prototypes, end user products, quasi-legal guns, aircraft engine parts and even human organs using a person’s own cells.


Fantastical? Yes. True? Yes. Here now? Yes.


We live in an age that is witness to what many are calling the Third Industrial Revolution. 3D printing, more professionally called additive manufacturing, moves us away from the Henry Ford era mass production line, and will bring us to a new reality of customizable, one-off production.

Need a part for your washing machine? As it is now, you’d order from your repairman who gets it from a distributor, who got it shipped from China, where they mass-produced thousands of them at once, probably injection-molded from a very expensive mold. In the future, the beginning of which is already here now, you will simply 3D print the part right in your home, from a CAD file you downloaded. If you don’t have the right printer, just print it at your local fab (think Kinkos).

3D printers use a variety of very different types of additive manufacturing technologies, but they all share one core thing in common: they create a three dimensional object by building it layer by successive layer, until the entire object is complete. It’s much like printing in two dimensions on a sheet of paper, but with an added third dimension: UP. The Z-axis.

Each of these printed layers is a thinly-sliced, horizontal cross-section of the eventual object. Imagine a multi-layer cake, with the baker laying down each layer one at a time until the entire cake is formed. 3D printing is somewhat similar, but just a bit more precise than 3D baking.

Stick with us and we’ll go through the various types of additive manufacturing. From FDM printing, where a material is melted and extruded in layers, one upon the other, to SLS printing, where a bed of powder material such as nylon or titanium is “sintered” (hardened) layer upon thin layer within it until a model is pulled out of it. It’s a fascinating and quickly advancing world that will change our lives as we know it.

It Begins with a Digital File

autodesk 123d 3D printingIn the 2D world, a sheet of printed paper output from a printer was “designed” on the computer in a program such as Microsoft Word. The file — the Word document — contains the instructions that tell the printer what to do.

In the 3D world, a 3D printer also needs to have instructions for what to print. It needs a file as well. The file — a Computer Aided Design (CAD) file — is created with the use of a 3D modeling program, either from scratch or beginning with a 3D model created by a 3D scanner. Either way, the program creates a file that is sent to the 3D printer. Along the way, software slices the design into hundreds, or more likely thousands, of horizontal layers. These layers will be printed one atop the other until the 3D object is done.

Is it 3D Printing or Additive Manufacturing?





The term 3D printing is the common term for the correct manufacturing term of “additive manufacturing.” But 3D printing will remain the term of choice as who really is going to run around saying things like, “I’m going to go additively manufacture a new iPhone case.” No, they are going to “3D print” it. It just sounds so much cooler too, doesn’t it?


There’s no way subtractive manufacturing is going to make something like this in one clean run.

So what the heck is additive manufacturing? Someday soon enough in the future, people will look back and view our current manufacturing processes as we today view something such as blacksmithing. What’s interesting about that last sentence is that much of today’s manufacturing processes are actually very similar to blacksmithing. Both are what’s called “subtractive manufacturing.”

Subtractive manufacturing relies upon the removal of material to create something. The blacksmith hammered away at heated metal to create a product. Today, a CNC machine cuts and drills and otherwise removes material from a larger initial block of material to create a product. It’s inefficient and wasteful. Other manufacturing techniques abound but they all essentially whittle down raw material into a product.

As you’ve already surmised, additive manufacturing creates something by adding material to the object. Some here, some there, and no where it’s not needed. No waste. Very efficient. You’ll read about many types of 3D printers, but no matter the technology involved, it’s additive.

Commercial 3D printers


While most people have yet to even hear the term 3D printing, the process has been in use for decades. Manufacturers have long used the printers in the design process to create prototypes for traditional manufacturing. But until the last few years, the equipment has been expensive and slow.

Now, fast 3D printers can be had for tens of thousands of dollars, and end up saving the companies many times that amount in the prototyping process. For example, Nike uses 3D printers to create multi-colored prototypes of shoes. They used to spend thousands of dollars on a prototype and wait weeks for it. Now, the cost is only in the hundreds of dollars, and changes can be made instantly on the computer and the prototype reprinted on the same day.

Some companies are using 3D printers for short run or custom manufacturing, where the printed objects are not prototypes, but the actual end user product. As the speeds of 3D printing go up and the prices come down, look for more and more of this. And expect more availability of personally customized products.
Personal 3D Printers


A Huxley RepRap 3D printer that has printed out its own parts.

So far we’ve only talked about commercial 3D printers. There is a whole other world of 3D printers: personal and DIY hobbyist models. And they are getting cheap, with prices typically in the range of $300 – $2,000.

The RepRap open source project really ignited this hobbyist market in the same way the Apple I microcomputer ignited the hobbyist desktop computer market in the late 1970s. For about a thousand dollars, people have been able to buy the RepRap kit and put together their own personal 3D printer, complete with any customizations they were capable of making. And what’s more, these printers print most of the parts for more printers. RepRap is short for replicating rapid prototyper, so complete self-replication, including electronic circuit boards, is the goal.

The interest in RepRap spawned scores of other low-cost 3D printers, both DIY and fully-assembled, and as the prices keep coming down, it puts 3D printers into more and more and more hands.

But do you have to be an engineer or a 3D modeling expert to create 3D models on your own 3D printer? No, not at all. While complex and expensive CAD software like AutoCAD and Solidworks have a steep learning curve, there are a number of other programs, many free, that are very easy to learn. The free version of Google SketchUp, for example, is very popular for its ease of use; and the free Blender program is popular for its advanced features.

If you don’t have your very own 3D printer, not to worry, there are 3D printing service bureaus like Shapeways and Ponoko that can very inexpensively print and deliver an object from a digital file that you simply upload to their user-friendly website. It’s almost as easy as ordering a custom t-shirt from Cafepress or Zazzle.

Even if you don’t design your own 3D model, you can still print some very cool pieces. There are model repositories such as Thingiverse, 3D Parts Database, and 3D Warehouse that have model files you can download for free.

What do all these people print? It’s limitless. Some print things like jewelry, some print replacement parts for appliances such as their dishwasher, some invent all sorts of original things, some create art, and some make toys for their kids. With the many types of metal, plastic, glass, and other materials available (even gold and silver), just about anything can be printed.
3D Printing Methods
Stereolithography (SLA)
3D Systems explains the process of Stereolithography

The first commercially available 3D printer (not called a 3D printer back then) used the stereolithography (SLA) method. This was invented in 1986 by Charles Hull, who also at the time founded the company, 3D Systems. A SLA 3D printer works by concentrating a beam of ultraviolet light focused onto the surface of a vat filled with liquid photocurable resin. The UV laser beam draws out the 3D model one thin layer at a time, hardening that “slice” of the eventual 3D model as the light hits the resin. Slice after slice is created, with each one bonded to the other, and next thing you know you have a full, extremely high-resolution three dimensional model lifted out of the vat. Unused resin is reusable for the next job.
Fused Deposition Modeling (FDM)
Stratasys explains Fused Deposition Modeling at a trade show

Also invented in the late 1980s, by Scott Crump, was Fused Deposition Modeling (FDM) technology. With patent in hand, he and his wife founded Stratasys in 1988. With FDM, the object is produced by extruding a stream of melted thermoplastic material to form layers. Each layer stacks on top of and fuses with the previous layer as the material hardens almost immediately after leaving the extrusion nozzle. It is one of the less expensive 3D printing methods. Most FDM printers print with ABS plastic (think Lego), as well as PLA (Polylactic acid), a biodegradable polymer, which is produced from organic material.

The actual term “Fused Deposition Modeling” and its abbreviation “FDM” are trademarked by Stratasys. RepRap uses a similar process, but has called it “Fused Filament Fabrication” (FFF), so as to not step on the trademark. With FFF, the material is fed via filament from a spool of the material.
Selective Laser Sintering (SLS)
3D Systems demonstrates the SinterStation Pro SLS 3D printer

The 1980s were big for inventing 3D printing technologies. Not only were SLA and FDM invented and patented then, but so was Selective Laser Sintering (SLS), by Carl Deckard and colleagues at the University of Texas in Austin. SLS works similarly to SLA, but instead of liquid photopolymer in a vat, you’ll find powdered materials, such as polystyrene, ceramics, glass, nylon, and metals including steel, titanium, aluminum, and silver. When the laser hits the powder, the powder is fused at that point (sintered). All unsintered powder remains as is, and becomes a support structure for the object. The lack of necessity for any support structure with SLS is an advantage over FDM/FFF and SLA — there’s none to remove after the model is complete, and no extra waste was created. All unused powder can be used for the next printing.
PolyJet photopolymer

Objet (acquired by Stratasys) developed this technology: much like a traditional inkjet printer deposits ink, a photopolymer liquid is precisely jetted out and then hardened with a UV light. The layers are stacked successively. The technology allows for various materials and colors to be incorporated into single prints, and at high resolutions.
Syringe Extrusion

Almost any material that has a creamy viscosity can be used in 3D printers equipped with syringe extruders. This includes materials like clay, cement, silicone, and Play-Doh. Certain foods like chocolate, frosting, and cheese can also be printed with these systems. The syringe may or may not need to be heated, depending on the material; chocolate may need to be kept warm while silicone can be kept at room temperature.
Other Methods

There are other variants of these technologies. For example there is Selective Laser Melting (SLM), which is like SLS but it fully melts the powder rather than just fusing the powder granules at a lower temperature. This is similar to Electron Beam Melting (EBM) which uses an electron beam instead of a UV laser. And then there is a completely different technology called Laminated Object Manufacturing (LOM), where layers of adhesive-coated paper, plastic, or metal laminates are successively glued together and cut to shape with a knife or laser cutter.
3D Printing is a Game Changer

Instantly printing parts and entire products, anywhere in the world, is a game changer. But it doesn’t stop there. 3D printing will affect almost every aspect of industry and our personal lives.

Medicine will forever be changed as new bioprinters actually print human tissue for both pharmaceutical testing and eventually entire organs and bones.

Architecture and construction are changing as well. Now, 3D-printed models of complex architectural drawings are created quickly and inexpensively, rather than the expensive and time-consuming process of handcrafting models out of cardboard. And experimental, massive 3D printers are printing concrete structures, with the goal of someday creating entire buildings with a 3D printer.

Art is already forever changed. Digital artists are creating magnificent pieces that seem almost impossible to have been made by traditional methods. From sculptures to light fixtures, beautiful objects no longer need to be handcrafted, just designed on a computer.

And there are developments where you least expect them: for example, archeologists can 3D scan priceless and delicate artifacts, and then print copies of them so they can handle them without fear of breakage. Replicas can be easily made and distributed to other research facilities or museums. It has been used to create a full-size reproduction of King Tutankhamun’s mummy and to repair Rodin’s sculpture, The Thinker.
The Future of 3D Printing

This is a disruptive technology of mammoth proportions, with effects on energy use, waste, customization, product availability, art, medicine, construction, the sciences, and of course manufacturing. It will change the world as we know it. Before you know it.

Inventing the Future of Connectivity


Every one of us. Everywhere. Connected.

Internet.org is a global partnership between technology leaders, nonprofits, local communities and experts who are working together to bring the internet to the two thirds of the world’s population that doesn't have it.

How to Set up an Android Development Environment


The Android is a tremendous mobile operating system humans have every created. As of today, Android is the world's most popular mobile platform. You can check more statistics on Android Dashboard.

This article shows how to set up the initial development environment for creating Android applications. I can grantee you can start making Android applications at the end of this article.

1. Download an IDE (Integrated Development Environment

There are many IDEs out there for Android development, but I urge you to use well established Eclipse IDE and I will be using Eclipse though out the entire article as my IDE.
You can download the latest version of the software here : Link http://www.eclipse.org/downloads/packages/release/indigo/r

This is the link to a stackoverflow question "What is the best IDE to develop Android apps in?"
Complete guide for Android Studio

2. Install Eclipse 

Keep a note of the installation directory and workspace for later reference.

3. Download and install the Java Runtime Environment (JRE)

PS :- Ignore this step if you already have JRE installed on your computer
You can find the download file here : Link  http://www.oracle.com/technetwork/java/javase/downloads/jre-6u25-download-346243.html
It's must to download the compatible JRE version with the Ecipse
(ex :- It causes an error if you try to open 32-bit Ecipse on 64-bit JRE)
Make sure you set the correct PATH environment variable after the JRE installation.

4. Download and install the Java Development Kit (JDK)

You can find the download file from the same link : Link  http://www.oracle.com/technetwork/java/javase/downloads/jre-6u25-download-346243.html
5.