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
/** | |
* Implements of hook_ranking(). Copied from node_ranking(). | |
*/ | |
function MYMODULE_ranking() { | |
$ranking = array(); | |
// Add ranking based on just the creation date (node_ranking() also uses modified | |
// date). | |
if ($node_cron_last = variable_get('node_cron_last', 0)) { | |
$ranking['MYMODULE_recent'] = array( | |
'title' => t('Recently posted, ignore modification date'), |
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
<!-- Include complex media queries for all browsers except IE < 9. | |
See bottom of http://www.quirksmode.org/css/condcom.html for info about | |
the comment tag. Using document.write() to aviod invalid markup. --> | |
<script> | |
document.write('<comment><link rel="stylesheet" href="/path/to/complex-media-queries.css" media="all" /></comment>'); | |
</script> | |
<!-- Only include respond.js for IE < 9. --> | |
<!--[if lt IE 9]> | |
<script src="/path/to/respond.min.js?v=v1.1.0"></script> |
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
// ... | |
// Development settings | |
$conf['cache'] = 0; | |
$conf['preprocess_css'] = 0; | |
$conf['preprocess_js'] = 0; | |
$conf['error_level'] = 2; |
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
/** | |
* Implements hook_requirements(). | |
*/ | |
function mymodule_requirements($phase) { | |
$requirements = array(); | |
// Ensure translations don't break at install time | |
$t = get_t(); | |
if (defined('MYMODULE_RID')) { | |
// Test role ID, make sure it equals MYMODULE_RID. |
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
var $div = $('#container'); | |
var divh = $div.height(); | |
var text = $div.text(); | |
var $p; | |
$div.html('<p>' + text + '</p>'); | |
$p = $div.find('p'); | |
var factor = $p.outerHeight() / divh; |
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
// Tell Drupal to cancel this user. | |
// The third argument can be one of the following: | |
// - user_cancel_block: disable user, leave content | |
// - user_cancel_block_unpublish: disable user, unpublish content | |
// - user_cancel_reassign: delete user, reassign content to uid=0 | |
// - user_cancel_delete: delete user, delete content | |
user_cancel(array(), $uid, 'user_cancel_reassign'); | |
// user_cancel() initiates a batch process. Run it manually. | |
$batch =& batch_get(); |
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
/** | |
* Implements hook_form_alter(). | |
*/ | |
function mymodule_form_alter(&$form, &$form_state, $form_id) { | |
if (in_array($form_id, array('user_login', 'user_login_block'))) { | |
$form['name']['#element_validate'][] = 'mymodule_user_login_validate'; | |
} | |
} | |
/** |
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
/** | |
* Implements hook_element_info_alter(). | |
*/ | |
function mymodule_element_info_alter(&$type) { | |
// Rather than implementing hook_css_alter(), we'll add a custom pre render | |
// function for the styles elemement. This is to allow us to override | |
// seven_css_alter(), which always runs after any module's implementation. | |
if (isset($type['styles']['#pre_render'])) { | |
array_unshift($type['styles']['#pre_render'], 'mymodule_pre_render_styles'); | |
} |
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
$(document).ready(function() { | |
var $handle = $("#handle"), | |
dragging = false; | |
// Make the slider handle draggable. | |
var dragStart = function(e) { | |
dragging = true; | |
$handle.addClass("dragging"); | |
// Prevent text select while dragging. |
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
# Remove whitespace and special characters and replace with dashes (-). | |
def self.filename(input) | |
input.split(%r{ |!|/|:|&|-|$|,|\?|%|\(|\)}).map { |i| i.downcase if i != '' }.compact.join('-') | |
end | |
# Convert to ascii and replace non-ascii letters. | |
def self.transliterate(input) | |
replacements = { | |
'å' => 'a', | |
'ä' => 'a', |
OlderNewer