Skip to content

Instantly share code, notes, and snippets.

View ianchan's full-sized avatar

Ian Chan ianchan

View GitHub Profile
<div id="block-block-6" class="well well-small block block-block">
<div class="row-fluid">
<div class="span3">
<img src="/images/backgrounds/ask-librarian6.png">
</div>
<div class="span9">
<h2 class="pane-title">Ask a Librarian</h2>
<ul class="nav nav-pills" id="myTab">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<?php
$authurl= $data->node_node_data_field_authurl_value;
$vendorurl = $data->node_node_data_field_vendorurl_value;
echo $authurl . $vendorurl;
?>
@ianchan
ianchan / db_ft_indicator
Created August 12, 2013 15:04
Our database listings include a field describing availability of full-text within a database. We display our databases using Views for Drupal 6. When we migrated from our od ASP/Oracle setup, we retained the numeric indicators in the FT field. We also continued the use of icons for visually communicating FT availability. To make this work in Vie…
<?php
$imgurlpath = "/images/icons/";
echo "<div class='tipsy' title='";
switch ($data->node_node_data_field_top_dbs__node_data_field_trial_period_field_full_text_value) {
case "2":
$dbcontenttype = "CD ROMS are viewable over the web";
echo $dbcontenttype . "'><img src='" . $imgurlpath . "cd1-pub.png' width='18' height='19' alt='" . $dbcontenttype . "' />";
break;
case "4":
$dbcontenttype = "Database has some full-text";
@ianchan
ianchan / gist:4485605
Created January 8, 2013 17:04
jQuery for moving form labels into adjacent inputs
jQuery('#user-login-form .form-item input').each(function(){
var p = jQuery(this).prev('label').text();
jQuery(this).attr('placeholder',p);
});
jQuery('#user-login-form .form-item label').css('display','none');
@ianchan
ianchan / gist:3505888
Created August 29, 2012 01:26
Redirect /node for Drupal sites that aren't streaming nodes on front page
<?php
//put this in settings.php
function custom_url_rewrite_inbound(&$result, $path, $path_language) {
if ($path == 'node') {
//this will cause a page not found
$result = '';
}
}
?>
@ianchan
ianchan / computer-drupal.php
Created August 9, 2012 19:02 — forked from griggsk/computer-drupal.php
Computer Availability Map UI for Drupal
<?php
drupal_add_css("sites/all/themes/osulibraries/comp_map.css");
drupal_add_js('setTimeout("window.location.reload()",300000);', 'inline');
db_set_active('comp_map');
$total_pc_results = db_query("SELECT * FROM compstatus WHERE computer_type='PC'");
$avail_pc_results = db_query("SELECT * FROM compstatus WHERE status='0' AND computer_type='PC'");
$pcs = mysql_num_rows($avail_pc_results) . '/' . mysql_num_rows($total_pc_results);
@ianchan
ianchan / computers.php
Created August 9, 2012 19:02 — forked from griggsk/computers.php
Computer Availability Map UI
<?php
#add your database username and password
$user="username";
$password="password";
$database="computer_availability";
#connect to the database
$DB = mysql_connect('mysqlcluster.adm.yourmysqlserver.edu', $user, $password);
@mysql_select_db($database) or die("Unable to select database");
@ianchan
ianchan / computers.php
Created August 9, 2012 19:01 — forked from griggsk/computers.php
Computer Availability Map UI
<?php
#add your database username and password
$user="username";
$password="password";
$database="computer_availability";
#connect to the database
$DB = mysql_connect('mysqlcluster.adm.yourmysqlserver.edu', $user, $password);
@mysql_select_db($database) or die("Unable to select database");
@ianchan
ianchan / statuschange.php
Created August 9, 2012 17:12 — forked from griggsk/statuschange.php
Computer Availability status change script
#add your database username and password
$user="username";
$password="password";
$database="computer_availability";
#unless the computers name was empty
if($_POST['workstation'] != ""){
$workstation = strtoupper($_POST['workstation']);
}
else{ #build the computer's name from the host
@ianchan
ianchan / cg.php
Created June 26, 2012 22:41
Course guides XML feed - Library a la Carte
<?php
header("Content-type: text/xml");
// Please DO send ideas for improving this to libwebdev@csusm.edu
// Include the file with MySQL database connection info
include("/file-location/whatever-folder/db-connection-file.php");
// Database connection and tests
$database = "your-production-a-la-carte-db-name";