This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Move the feature tar file contents into your site and remove it | |
# | |
# Usage: | |
# move_feature.sh [feature file] [drupal directory] | |
# | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function my_module_form($form, &$form_state) { | |
$form['sample_field'] = array( | |
'#type' => 'checkboxes' | |
'#title' => 'Sample', | |
'#options' => array('test' => 'Test') | |
); | |
$form['select_box'] = array( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
IP=`curl -s http://whatismyip.org/` | |
echo $IP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// hook_block_info | |
/** | |
* Our block specific code | |
*/ | |
function custom_module_block_view($delta = '') { | |
if ($delta == ''){ | |
// current node |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_block_info | |
*/ | |
function custom_module_block_info() { | |
$blocks['custom_module_my_block'] = array( | |
'info' => t('My block'), | |
'cache' => DRUPAL_CACHE_PER_PAGE, | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function custom_content_pages_about() { | |
// load our content: since our path starts with the alias for this | |
// node, we can lookup the node source that way | |
$node_path = drupal_lookup_path('source', arg(0) .'/'. arg(1)); | |
// now we can the actual node | |
$node = menu_get_object('node', 1, $node_path); | |
// set the title |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implement hook_menu() | |
*/ | |
function custom_content_pages_menu() { | |
$items['custom/%/about'] = array( | |
'page callback' => 'custom_content_pages_about', | |
'access arguments' => array('access content'), | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Based on rules from http://en.wikipedia.org/wiki/Roman_numerals | |
*/ | |
function romanToInt($roman){ | |
$int = 0; | |
$characters = str_split($roman); | |
$previous = null; | |
$values = array('I' => 1, 'V' => 5, 'X' => 10, 'L' => 50, 'C' => 100, 'D' => 500, 'M' => 1000); | |
foreach($characters as $character){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$names = 'Jeff'; | |
// if User() is a class, this will be an error since classes are not callable. If it | |
// is a class then it would be "new User();" | |
$user = User(); | |
// $names is not iterable, so this will error out | |
foreach($names as $name) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
I felt it was best to treat this a bit more completely by pulling in an open source library. | |
So, cheating a bit and using simplehtmldom since it's best if we account for | |
both href & target attributes (if a link has a target, we don't want to repeat it) | |
http://simplehtmldom.sourceforge.net/ | |
A solution without using this library could use preg_match_all to parse out the href's but |