Skip to content

Commit

Permalink
centralized the code and added micro publishers for other entities
Browse files Browse the repository at this point in the history
  • Loading branch information
blup committed Nov 29, 2010
1 parent d64ea03 commit 4a3bbc0
Show file tree
Hide file tree
Showing 19 changed files with 894 additions and 264 deletions.
25 changes: 25 additions & 0 deletions micro-publisher.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.form-item-micro-publisher-node-todos { float:left; width:200px;}
#todos-fieldset-wrapper {float:left; width:200px;}

.form-item-micro-publisher-node-events { float:left; width:200px;}
#events-fieldset-wrapper {float:left; width:200px;}

.form-item-micro-publisher-node-images { float:left; width:200px;}
#images-fieldset-wrapper {float:left; width:200px;}

.form-item-micro-publisher-node-videos { float:left; width:200px;}
#videos-fieldset-wrapper {float:left; width:200px;}

.form-item-micro-publisher-node-files { float:left; width:200px;}
#files-fieldset-wrapper {float:left; width:200px;}

.show { display: block;}
.hide { display: none;}

#micro-publisher-node { height: 200px; }
.tabs-bottom { position: relative; }
.tabs-bottom .ui-tabs-panel { height: 140px; overflow: auto; }
.tabs-bottom .ui-tabs-nav { position: absolute !important; left: 0; bottom: 0; right:0; padding: 0 0.2em 0.2em 0; }
.tabs-bottom .ui-tabs-nav li { margin-top: -2px !important; margin-bottom: 1px !important; border-top: none; border-bottom-width: 1px; }
.ui-tabs-selected { margin-top: -3px !important; }

92 changes: 92 additions & 0 deletions micro-publisher.tpl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php
// $Id: micro-publisher.tpl.php, v 1.0 2010/12/01 04:20:00 blup Exp $

/**
* @file
* Default theme implementation for micros.
*
* Available variables:
* - $author: micro author. Can be link or plain text.
* - $content: An array of micro items. Use render($content) to print them all, or
* print a subset such as render($content['field_example']). Use
* hide($content['field_example']) to temporarily suppress the printing of a
* given element.
* - $created: Formatted date and time for when the micro was created.
* Preprocess functions can reformat it by calling format_date() with the
* desired parameters on the $micro->created variable.
* - $changed: Formatted date and time for when the micro was last changed.
* Preprocess functions can reformat it by calling format_date() with the
* desired parameters on the $micro->changed variable.
* - $new: New micro marker.
* - $permalink: micro permalink.
* - $picture: Authors picture.
* - $signature: Authors signature.
* - $status: micro status. Possible values are:
* micro-unpublished, micro-published or micro-preview.
* - $title: Linked title.
* - $classes: String of classes that can be used to style contextually through
* CSS. It can be manipulated through the variable $classes_array from
* preprocess functions. The default values can be one or more of the following:
* - micro: The current template type, i.e., "theming hook".
* - micro-by-anonymous: micro by an unregistered user.
* - micro-by-node-author: micro by the author of the parent node.
* - micro-preview: When previewing a new or edited micro.
* The following applies only to viewers who are registered users:
* - micro-unpublished: An unpublished micro visible only to administrators.
* - micro-by-viewer: micro by the user currently viewing the page.
* - micro-new: New micro since last the visit.
* - $title_prefix (array): An array containing additional output populated by
* modules, intended to be displayed in front of the main title tag that
* appears in the template.
* - $title_suffix (array): An array containing additional output populated by
* modules, intended to be displayed after the main title tag that appears in
* the template.
*
* These two variables are provided for context:
* - $micro: Full micro object.
* - $node: Node object the micros are attached to.
*
* Other variables:
* - $classes_array: Array of html class attribute values. It is flattened
* into a string within the variable $classes.
*
* @see template_preprocess()
* @see template_preprocess_micro()
* @see template_process()
* @see theme_micro()
*/
?>
<div class="micro-publisher tabs-bottom">
<ul>
<?php if(isset($status_name)): ?><li><a href="#status"><?php print $status_name; ?></a></li><?php endif; ?>
<?php if(isset($image_name)): ?><li><a href="#image"><?php print $image_name; ?></a></li><?php endif; ?>
<?php if(isset($video_name)): ?><li><a href="#video"><?php print $video_name; ?></a></li><?php endif; ?>
<?php if(isset($file_name)): ?><li><a href="#file"><?php print $file_name; ?></a></li><?php endif; ?>
<?php if(isset($event_name)): ?><li><a href="#event"><?php print $event_name; ?></a></li><?php endif; ?>
</ul>
<?php if(isset($status_name)): ?>
<div id="status">
<?php print render($status_form); ?>
</div>
<?php endif; ?>
<?php if(isset($image_name)): ?>
<div id="image">
<?php print render($image_form); ?>
</div>
<?php endif; ?>
<?php if(isset($video_name)): ?>
<div id="video">
<?php print render($video_form); ?>
</div>
<?php endif; ?>
<?php if(isset($file_name)): ?>
<div id="file">
<?php print render($file_form); ?>
</div>
<?php endif; ?>
<?php if(isset($event_name)): ?>
<div id="event">
<?php print render($event_form); ?>
</div>
<?php endif; ?>
</div>
60 changes: 60 additions & 0 deletions micro_publisher.admin.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php
// $Id: micro_publisher.admin.inc,v 0.1 2011/01/01 04:20:00 blup Exp $

/**
* @file
* Administrative page callbacks for the micro publisher modules.
*/

function micro_publisher_settings_form($form, &$form_state, $entity) {
$entities = micro_get_entities();
$micro_types = micro_type_get_types();
$publisher_types = array('status', 'event', 'image', 'video', 'file');
$form['#entity_type'] = $entity;

foreach ($publisher_types as $type) {
$form[$type] = array(
'#type' => 'fieldset',
'#title' => t('@type', array('@type' => ucfirst($type))),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form[$type][$type . '_bundles'] = array(
'#type' => 'checkboxes',
'#title' => t('Bundles'),
'#options' => $entities[$entity]['bundles'],
'#default_value' => $micro_types['micro_publisher_' . $entity . '_' . $type]->bundles,
);
}

$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save micro type'),
'#weight' => 40,
);

return $form;
}

/**
* Submit function for micro_publisher_settings_form().
*/
function micro_publisher_settings_form_submit($form, &$form_state) {
$types = array('status', 'event', 'image', 'video', 'file');
$micro_types = micro_type_get_types();
foreach ($types as $type) {
$publisher_type = 'micro_publisher_' . $form['#entity_type'] . '_' . $type;
$publisher_type = $micro_types[$publisher_type];
$publisher_type->bundles = $form_state['values'][$type . '_bundles'];

$status = micro_type_save($publisher_type);
if ($status == SAVED_UPDATED) {
drupal_set_message(t('The micro type %name has been updated.', $t_args));
}
}

micro_types_rebuild();
$form_state['redirect'] = 'admin/structure/micro';
return;
}
16 changes: 16 additions & 0 deletions micro_publisher.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
; $Id: micro_publisher.info,v 0.1 2011/01/01 04:20:00 blup Exp $

name = Micro publisher
description = Base for micro publishers. Does not do anything by itself.
version = 7.x-1.0
core = 7.x

files[] = micro_publisher.module
files[] = micro_publisher.install
files[] = micro_publisher.admin.inc
files[] = micro_publisher.js

dependencies[] = micro
dependencies[] = date

configure = admin/config/micro-publisher/settings
14 changes: 14 additions & 0 deletions micro_publisher.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
// $Id: micro_publisher.install, v 1.0 2010/12/01 04:20:00 blup Exp $

/**
* @file
* Install function for the micro_publisher module.
*/

/**
* Implement hook_install().
*/
function micro_publisher_install() {
micro_types_rebuild();
}
9 changes: 9 additions & 0 deletions micro_publisher.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// $Id: micro_publisher.js, v 1.0 2010/12/01 04:20:00 blup Exp $

(function($){$(document).ready(function(){
$('.micro-publisher').tabs();
$( ".tabs-bottom .ui-tabs-nav, .tabs-bottom .ui-tabs-nav > *" )
.removeClass( "ui-corner-all ui-corner-top" )
.addClass( "ui-corner-bottom" );
});
})(jQuery);
Loading

0 comments on commit 4a3bbc0

Please sign in to comment.