array('key' => 'Icon', 'title' => 'Icon URL',
'type' => 'text'),
'Oneliner' => array('key' => 'Oneliner', 'title' => 'Oneliner',
'type' => 'text'),
'Summary' => array('key' => 'Summary', 'title' => 'Summary',
'type' => 'textarea'),
'End_Date' => array('key' => 'End_Date', 'title' => 'End Date',
'type' => 'text'),
'Location' => array('key' => 'Location', 'title' => 'Location',
'type' => 'text'),
'Affiliations' => array('key' => 'Affiliations', 'title' => 'Affiliations', 'type' => 'text'),
'Website' => array('key' => 'Website', 'title' => 'Website',
'type' => 'text'),
'Status' => array('key' => 'Status', 'title' => 'Status',
'type' => 'select',
'select_values' =>
'Active,Completed,Unreleased,Proposal,Cancelled,Idea'),
'Next_Step' => array('key' => 'Next_Step', 'title' => 'Next Step',
'type' => 'text'),
'Role' => array('key' => 'Role', 'title' => 'Role',
'type' => 'select',
'select_values' => 'Founder,Co-Founder,CEO,Developer,Contributor,Manager,Board Member,Advisor,Consultant,Adjunct Professor,Liaison,Artist,Writer,Researcher,Presenter,Teacher'),
'Collaborators' => array('key' => 'Collaborators',
'title'=> 'Collaborators', 'type' => 'text'),
'Tags' => array('key' => 'Tags', 'title' => 'Tags',
'type' => 'text'),
'Wiki' => array('key' => 'Wiki', 'title' => 'Wiki',
'type' => 'text'),
'Type' => array('key' => 'Type', 'title' => 'Type',
'type' => 'select',
'select_values' => 'Collection,Website,Community,Article,Book,Collection,Sculpture,Installation,Video,Research,Academic,Software,Business,Standard'),
);
/**
* Adds Project Management box to admin page only since added to action.
*/
function add_project_management_box ()
{
global $_PROJECT_META_KEYS;
if ( function_exists('mf_add_meta_box') )
mf_add_meta_box('Project Management', $_PROJECT_META_KEYS,
array('page'), 'left');
}
add_action('admin_menu','add_project_management_box', 5);
/**
* Print a box at the top of the content column with stuff we want in it.
*/
function get_priority_box ( $categories = '27' )
{
if ( '' == $categories )
return;
if ( is_home() )
{
global $post;
$myposts = get_posts('numberposts=1&category=' . $categories .
'&orderby=post_modified');
if ( count($myposts) > 0 )
{
foreach($myposts as $post) :
// Allow two specific custom template variables from a post
// true parameter says only return one result as a string.
$image = get_post_meta( $post->ID, 'image', true );
$reminders = get_post_meta( $post->ID, 'reminders', true );
setup_postdata($post);
?>
';
endforeach;
?>
ID . '&before=&with_descriptions=&link_type=&orderby=ASC' );
*
*/
function print_projects_box ($options = '')
{
// The following code finds 3 images that show what is on the parent category
// and links to it
//
$defaults = array(
'post_type' => 'attachment',
'numberposts' => 12, // get 12 since some might be dups, or crap
'post_status' => null,
'post_parent' => null, // any parent
'orderby' => 'rand', // rand
'exclude' => '',
/* adding custom default not in query_posts */
/* 'before' => 'Projects
', */
'before' => '',
'after' => '',
'with_descriptions' => true,
'link_type' => 'parent',
'posts_per_row' => 3,
'unique_parents' => false,
);
$options = wp_parse_args($options, $defaults);
/* MASSIVE HACK TO GET THIS TO WORK PROPER:Y FOR RANDOM ... BASICALLY
GETTING LARGER SAMPLE SIZE TO AVOID REPITITION */
if ( $options['orderby'] == 'rand' )
{
$options['shuffle'] = true;
$options['posts_limit'] = $options['numberposts'];
// gives us more to choose from ;) shitty hack
$options['numberposts'] = $options['numberposts'] * 6;
}
$buffer = '';
$attachments = get_posts($options);
// print_r_fmt($attachments);
if ($attachments) :
if ( $options['shuffle'] )
shuffle( $attachments );
$ct = 0;
$last_parent_ids = array();
foreach ($attachments as $post) :
// check to see if post is bullocks
if ( $options['shuffle'] &&
empty($post->post_parent) ||
( $options['unique_parents'] &&
in_array($post->post_parent,$last_parent_ids) ) ||
( $post->post_mime_type != 'image/jpeg' &&
$post->post_mime_type != 'image/png' &&
$post->post_mime_type != 'image/gif' ) )
{
continue;
}
$parent = get_post($post->post_parent);
if ( $parent->post_type != 'page' )
continue;
setup_postdata($post);
if ( $ct % $options['posts_per_row'] == 0 )
$buffer .= '';
$buffer .= "";
if ( $options['link_type'] == 'parent' ) {
$pretty_perm = get_permalink($post->post_parent);
} else if ( $options['link_type'] == 'page' ) {
$pretty_perm = get_attachment_link($post->ID);
} else {
$pretty_perm = $post->guid;
}
/* a bit hacky to just add lightbox in, but who cares */
// $link_meta = ' rel="lightbox[' . $post->ID . ']"';
$link_meta = '';
$str = '%s';
$buffer .= sprintf($str, $pretty_perm, $link_meta,
wp_get_attachment_image($post->ID)) . " ";
// print_r_fmt( wp_get_attachment_thumb_url($post->ID));
if ( $options['with_descriptions'] )
$buffer .= sprintf($str, $pretty_perm, $link_meta,
$parent->post_title);
$buffer .= " | ";
$ct++;
if ( $options['unique_parents'] )
$last_parent_ids[] = $post->post_parent;
if ( $options['numberposts'] == $ct ||
( !empty($options['posts_limit']) &&
$options['posts_limit'] == $ct ) ||
0 == $ct % $options['posts_per_row'] ) {
$buffer .= "
";
if ( !empty($options['posts_limit']) &&
$options['posts_limit'] == $ct )
break;
}
endforeach;
endif;
?>
0 )
{
?>
$arr)
{
$value = &$meta_arr[$key];
if ( empty($value) /* AUTO-SETS WIKI PAGE && $key != 'Wiki' */ )
continue;
$buffer .= '';
$buffer .= '| ' . $arr['title'] . " | \n";
switch ($key) {
case 'Date':
case 'End_Date':
case 'End Date':
$buffer .= get_meta_iter(date(F_DATE_FMT,
strtotime($value[0])), '', '');
break;
case 'Website':
$buffer .= get_meta_iter($value, '');
break;
case 'Wiki':
if ( empty($value) )
$value[] = '/wiki/' . $post->post_title;
$buffer .= get_meta_iter($value, '');
break;
case 'Next_Step':
$buffer .= $value[0] .
' ' . F_SEPARATOR . ' ' .
_('Contact, if interested.') . '';
break;
case 'Type':
case 'Tags':
if ( strpos($value[0], ', ') !== false )
$value = explode(', ', $value[0]);
$buffer .= get_meta_iter($value, '/tag/');
break;
case 'Icon':
$buffer .= get_meta_iter($value, '', ' ');
break;
case 'Role':
case 'Collaborators':
case 'Affiliations':
if ( strpos($value[0], ', ') !== false )
$value = explode(', ', $value[0]);
default:
$buffer .= get_meta_iter($value, '', '%s');
}
$buffer .= " | \n
";
}
?>
');
*/
function get_meta_iter ($value, $link = '', $str_fmt = '%s',
$separator = ', ')
{
$buf = '';
$ct = 1;
if ( empty($str_fmt) )
$buf .= $value;
else
foreach ($value as $entry) {
// print list according to formatting, adding separator if desired
$buf .= sprintf($str_fmt . ($ct < count($value) ? $separator : ''),
$link . $entry, $entry);
$ct++;
}
return "$buf\n";
}
/**
* Uses standard wordpress query to get related posts according to a tag.
*
* @usage:
* if ( function_exists('print_related_posts') )
* print_related_posts('tag=' . $post->post_name );
*/
function print_related_posts ($options = '')
{
global $post;
$defaults = array(
'numberposts' => 7,
'post_status' => null,
'before' => '',
'after' => '',
);
$options = wp_parse_args($options, $defaults);
if ( !empty($options['tag']) )
$options['more_link'] = '/tag/' . $options['tag'] ;
$myposts = get_posts($options);
if ( count($myposts) > 0 ) :
echo $options['before'];
?>
0 ) :
?>
ID . '&showposts=-1&use_summary=true&use_title=&use_quicklinks=true&orderby=title&order=ASC&use_update=true&use_icon=true')
*/
function print_projects_all ($options = '')
{
global $_PROJECT_META_KEYS;
$defaults = array(
'post_type' => 'page',
'orderby' => 'modified',
'order' => 'DESC',
'title_li' => '',
'post_parent' => 469,
'status' => 'published',
'showposts' => '5',
// my custom options below
'use_summary' => false,
'use_status' => true,
'use_title' => true,
'use_update' => true,
'use_quicklinks' => false,
'use_icon' => false,
'default_icon' => '/wp-content/plugins/fabricatorz/media/projects-box.png',
'use_more_link' => true,
'use_sort_options' => false,
);
$options = wp_parse_args($options, $defaults);
// NOTE: no custom search with meta values here...
$sort_allowed = array('orderby' => _('Sort by'),
'order' => _('Order'));
// Our filters, with display title as well
$sort_options = array('Status' => array('Active' => _('Active'),
'Completed' => _('Completed'),
'Proposal' => _('Proposal'),
'Cancelled' => _('Cancelled'),
'Idea' => _('Idea')),
'orderby'
=> array('date' => _('Date'),
'modified' => _('Date Modified'),
'name' => _('Name'),
'rand' => _('Random'),
'title' => _('Title')),
'order'
=> array('ASC' => _('Ascending'),
'DESC' => _('Descending')),
);
// process input
if ( $options['use_sort_options'] )
{
// using meta key and value allows for us to use our custom fields
if ( !empty($_REQUEST['meta_key']) && !empty($_REQUEST['meta_value']) )
{
$saved_query['meta_key'] = $options['meta_key'] =
$_REQUEST['meta_key'];
$saved_query['meta_value'] = $options['meta_value'] =
$_REQUEST['meta_value'];
}
// iterate over the allowed in case we want to add more, etc
foreach ($sort_allowed as $sort_key => $sort_val) {
if ( empty($_REQUEST[$sort_key] ) )
$saved_query[$sort_key] = $options[$sort_key];
else
$saved_query[$sort_key] = $options[$sort_key] =
$_REQUEST[$sort_key];
}
}
$pages = get_posts($options);
// handle ui for sort options
if ( ($options['use_sort_options'] && count($pages) > 3) ||
!empty($options['meta_key'])) {
?>
{
Found }
3 ) {
?>
{
post_name . '">' . $page->post_title . '' .
' ';
}
?>
}
ID);
$tmp_meta = get_post_custom($page->ID);
$tmp_strings = array();
if ($options['use_status'] && !empty($tmp_meta['Status'][0])) {
$tmp_strings['status'] = $tmp_meta['Status'][0];
}
if ($options['use_update'])
$tmp_strings['update'] = F_TIME_PREFIX . ' ' .
date(F_DATE_FMT, strtotime($page->post_modified));
if (!empty($tmp_meta['Website'][0]) )
$tmp_strings['site'] = ' Official Site';
if (!empty($tmp_meta['Wiki'][0]) )
$tmp_strings['wiki'] = ' Wiki';
echo '- ';
if ($options['use_icon']) {
echo '
';
if ( !empty($tmp_meta['Icon'][0]) )
$tmp_icon = $tmp_meta['Icon'][0];
else if ( !empty($options['default_icon']) )
$tmp_icon = $options['default_icon'];
if ( !empty($tmp_icon) )
echo '

';
echo "
\n";
}
echo sprintf('
%s' .
'%s
%s',
$local_site, $page->post_title,
( !empty($tmp_meta['Oneliner'][0]) ?
'
'.$tmp_meta['Oneliner'][0].
'' : ''),
implode(", ", $tmp_strings) );
if ( $options['use_summary'])
echo '
' . $tmp_meta['Summary'][0] . '
';
if ($options['use_icon'])
echo "
\n";
?>
' .
F_VIEW_MORE . '';
?>
%s';
$crumb_sep = ' / ';
?>
%s')
{
$buf = '';
$query_string = '?';
$saved_query_sz = count($saved_query);
$is_filter_set = false;
$reset_link_buf = '';
if ( $saved_query_sz > 0 ) {
$ct = 0;
foreach ($saved_query as $q_key => $q_val) {
// skip same setting in saved queries
if ( isset($values[$q_val]) ||
// nastiness because of two types of queries
( empty($sort_allowed[$key]) &&
( $key == $q_val ) ||
isset($values[$q_val]) ) ) {
$is_filter_set = true;
continue;
}
$tmp_string = "$q_key=$q_val" .
( $ct < $saved_query_sz ? '&' : '' );
$query_string .= $tmp_string;
// for making a reset per filter
if ( $key != $q_key || $key == $q_val )
$reset_link .= $tmp_string;
$ct++;
}
}
$active_fmt = '%s';
foreach ($values as $name => $title) {
// nastiness because there are two formats for query search
if ( empty($sort_allowed[$key]) ) {
if ( $saved_query['meta_value'] == $name )
$buf .= sprintf($active_fmt, $title);
else
$buf .= sprintf($fmt, "$query_string" .
"meta_key=$key&meta_value=$name", $name);
}
// handles normal queries
else if ( $saved_query[$key] != $name ) {
$buf .= sprintf($fmt, "$query_string$key=$name", $title);
} else {
$buf .= sprintf($active_fmt, $title); // if active (no link)
}
$buf .= ' ';
}
if ( $is_filter_set )
$reset_link_buf = ' Reset';
return "{ $buf } $reset_link_buf";
}
function print_sort_ui ($sort_options, $sort_allowed, $saved_query)
{
foreach ($sort_options as $key => $values) {
echo '' .
( empty($sort_allowed[$key]) ? $key : $sort_allowed[$key]) .
' ' .F_SEPARATOR . ' ';
echo format_query($key, $values, $saved_query, $sort_allowed);
}
}
// $Id: rglob.php,v 1.0 2008/11/24 17:20:00 hm2k Exp $
/**
* Recursive glob()
*/
/**
* @param int $pattern
* the pattern passed to glob()
* @param int $flags
* the flags passed to glob()
* @param string $path
* the path to scan
* @return mixed
* an array of files in the given path matching the pattern.
*/
function rglob($pattern='*', $flags = 0, $path='')
{
$paths=glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT);
$files=glob($path.$pattern, $flags);
foreach ($paths as $path) { $files=array_merge($files,rglob($pattern, $flags, $path)); }
return $files;
}
/**
* Prints a variable with
formatting so we don't lose it in the html.
*/
function print_r_fmt ($var, $msg = '')
{
echo "$msg
";
echo '';
print_r($var);
echo '';
}
?>