Skip to content

Instantly share code, notes, and snippets.

@drupalista-br
drupalista-br / gist:4140887
Created November 24, 2012 18:46
ValidaCampos
lnCount: integer;
begin
Result := false;
for lnCount := 0 to ComponentCount - 1 do
begin
if Components[lnCount] is TLabeledEdit then
if TLabeledEdit(Components[lnCount]).Text = '' then
begin
MessageDlg('Existe campo obrigatorio em branco!', mtInformation, [mbOK], 0);
Result := true;
@drupalista-br
drupalista-br / gist:4223201
Created December 6, 2012 09:23
Drupal 7 Profile2 Custom User Tab Form ( MYMODULE_profile2_MYPROFILE2TYPE.inc )
<?php
/**
* @file
* User Profile2 MYPROFILE2TYPE.
*/
/**
* Page callback for user profile2 MYPROFILE2TYPE form.
*/
function MYMODULE_load_profile2_MYPROFILE2TYPE_form($form, &$form_state, $user = NULL) {
@drupalista-br
drupalista-br / gist:4223234
Created December 6, 2012 09:30
Drupal 7 Profile2 Custom User Tab Form ( MYMODULE.module )
<?php
/**
* Implements hook_menu().
*/
function MYMODULE_menu() {
// MYCUSTOMPATH can't be the world 'profile'
$items['user/%user/MYCUSTOMPATH'] = array(
'title' => 'Profile',
'description' => 'User Profile2',
<?php
/**
* @file
* AJAX Miscellaneous Topics.
*/
/**
* Demonstrates a clickable AJAX-enabled link using the 'use-ajax' class.
*
<?php
/**
* Implements hook_menu().
*
* Sets up calls to drupal_get_form() for all our example cases.
*
* @see menu_example.module
* @see menu_example_menu()
*/
<div class="view view-openlayers-maps view-id-openlayers_maps view-display-id-page_7 view-dom-id-85890fd4b4fd686fe8b9d22b6e9303d4">
<div class="view-filters">
<form class="ctools-auto-submit-full-form" action="/trip-planner/transport" method="get" id="views-exposed-form-openlayers-maps-page-7" accept-charset="UTF-8"><div><div class="views-exposed-form">
<div class="views-exposed-widgets clearfix">
<div id="edit-type-wrapper" class="views-exposed-widget views-widget-filter-name">
<label for="edit-type">
Type </label>
<div class="views-widget">
<div class="form-item form-type-select form-item-type">
options = { 'cow' : animal, 'cat' : animal, 'earth' : planet,
'venus' : planet, 'lettuce' : vegetable, 'apple' : fruit }
def animal():
print 'This is an animal'
def fruit():
print 'This is a fruit'
def vegetable():
def my_switch_case(value):
return {
'cow' : 'This is an animal',
'apple' : 'This is a fruit',
'lettuce' : 'This is a vegetable',
}.get(value, 'I dont know what that is')
my_switch_case('cow')
# This is an animal
# This class provides the functionality we want. You only need to look at
# this if you want to know how this works. It only needs to be defined
# once, no need to muck around with its internals.
class switch(object):
def __init__(self, value):
self.value = value
self.fall = False
def __iter__(self):
"""Return the match method once, then stop"""
<?php
// Structered array for convertion into XML.
$data_array = array(
array(
'#xml_tag' => 'a',
'#xml_value' => '',
'#tag_attributes' => array(
array(
'name' => 'a_attr_name',
'value' => 'a_attr_value',