first import

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-08 11:40:19 +02:00
commit 1bc61b12ad
8435 changed files with 1582817 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
<?php
/**
* @file
* Outputs the Flash XML node for piecemaker xml files
*
* @variables
* $item: An associative array. @see template_preprocess_piecemaker_xml for details
*/
?>
<Flash <?php print drupal_attributes($item['#attributes']); ?>>
<?php if (!empty($item['Image']['#attributes'])):?>
<Image <?php print drupal_attributes($item['Image']['#attributes']);?>/>
<?php endif;?>
</Flash>

View File

@@ -0,0 +1,17 @@
<?php
/**
* @file
* Outputs the Image XML node for piecemaker xml files
*
* @variables
* $item: An associative array. @see template_preprocess_piecemaker_xml for details
*/
?>
<Image <?php print drupal_attributes($item['#attributes']); ?>>
<?php if (!empty($item['Text'])):?>
<Text><?php print $item['Text']; ?></Text>
<?php endif;?>
<?php if (!empty($item['Hyperlink']['#attributes'])):?>
<Hyperlink <?php print drupal_attributes($item['Hyperlink']['#attributes']);?>/>
<?php endif;?>
</Image>

View File

@@ -0,0 +1,14 @@
<?php
/**
* @file
* Outputs the Flash XML node for piecemaker xml files
*
* @variables
* $item: An associative array. @see template_preprocess_piecemaker_xml for details
*/
?>
<Video <?php print drupal_attributes($item['#attributes']); ?>>
<?php if (!empty($item['Image']['#attributes'])):?>
<Image <?php print drupal_attributes($item['Image']['#attributes']);?>/>
<?php endif;?>
</Video>

View File

@@ -0,0 +1,14 @@
<?php
print "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
?>
<Piecemaker>
<Contents>
<?php print implode("\n",$ContentNodes); ?>
</Contents>
<Settings <?php print drupal_attributes($Settings); ?>></Settings>
<Transitions>
<?php foreach($Transitions as $transition):?>
<Transition <?php print drupal_attributes($transition); ?>></Transition>
<?php endforeach;?>
</Transitions>
</Piecemaker>

View File

@@ -0,0 +1,52 @@
<?php
/**
* @file
* Function related to the Building of the Piecemaker XML file
*/
/**
* Builds a Piecemaker XML file
*
*/
function piecemaker_xml_build($settings) {
drupal_add_http_header('Content-Type', 'text/xml; charset=utf-8');
print theme('piecemaker_xml', $settings);
exit();
}
/**
* Preprocess Function for the Settings XML file
* @param $vars
* An associative array of the needed items to generate an XML file
* - 'Settings': The settings array of to be used. Most likely this comes from a piecemaker profile
* - 'Transitions': The transitions array to be used. Once again this is most likely comming from a profile
* - 'Contents': An item array containing the following keys
* - '#type': Either 'Image', 'Video', or 'Flash'
* - '#attributes': An array of attributes to add to the main node
* - 'Source': The Source of the file. This should be generated using $base_url to ensure it points correctly. REQUIRED for all file types.
* - 'Title': The title of the file. Will be shown in the tooltip on the menu. Avaialable to all file types.
* - 'Width': Only used in Video files. The width of the video file.
* - 'Height': Only used in Video files. The height of the video file.
* - 'Autoplay': Only used in Video files. Autoplay defines whether or not the video will start playing as soon as its ready.
* - 'Text': Used in Image nodes. The Text node can hold a description text, which can be formatted with simple HTML tags.
* Which HTML tags are supported, is determined by the piecemaker.css file. Per default you can use <h1>, <p>, <p-italic>, <a>.
* But you can add and specify as many tags as you want, for example different headline types. If you want to use different fonts,
* you will have to make sure that you embed these fonts in the Flash file. If you dont add a Text node, no info text appears.
* - 'Hyperlink': An array that contains an #attributes key which holds the attributes URL and Target.
* - 'Image': The Flash and Video nodes must have a child array Image, which will also have a Source #attribute key. This will specify the path to a preview image to be loaded before the SWF/Video file is shown.
* This preview image might show the first image of the SWF/Video file though, which would cause a smooth transition from the image to the actual SWF/Video.
* Please note that this image will still be shown left and right of the video, in case that the video is not as wide as the image.
*/
function template_preprocess_piecemaker_xml(&$vars) {
foreach($vars['Contents'] as $item) {
$Contents[] = theme('piecemaker_xml_node', array('item' => $item));
}
$vars['ContentNodes'] = $Contents;
}
/**
* Generates the individual nodes for a piecemaker XML file.
*/
function theme_piecemaker_xml_node(&$vars) {
$hook = 'piecemaker_xml_node_' . $vars['item']['#type'];
return theme($hook, $vars);
}

View File

@@ -0,0 +1,147 @@
<?php
/**
* @file
* Contains various theme functions for Piecemaker API
*/
/**
* Themes the actuall Piecemaker element
*
* @param $vars
* An array that contains the handler, key, profile array, and alternate content callback function
*/
function theme_piecemaker($vars) {
$settings = &drupal_static('theme_piecemaker_settings');
$ids = &drupal_static(__FUNCTION__, array());
$handler = $vars['handler'];
$key = $vars['key'];
$profile = $vars['profile'];
$alternate_callback = $vars['alternate_callback'];
if (is_object($profile)) {
//Cast the profile to an array to make it easier to use
$profile = (array) $profile;
}
$id = 'piecemaker-' . $handler . '-' . $key;
$i = 0;
while (in_array($id, $ids)) {
//Ensure we have a unique html ID to use.
$id .= '-' . $i;
$i++;
}
//Store this id
$ids[] = $id;
$pm_path = libraries_get_path('piecemaker');
$path = drupal_get_path('module', 'piecemaker');
//Add The JS we need
drupal_add_js($pm_path . '/swfobject/swfobject.js');
drupal_add_js($path . '/js/Piecemaker.js', JS_THEME);
$settings['Piecemaker_URI'] = base_path() . $pm_path;
$settings['Piecemaker'][$id] = array(
'id' => $id,
'flashvars' => array(
'xmlSource' => base_path() . "piecemaker/{$handler}/{$key}/settings.xml",
'cssSource' => base_path() . $profile['flash_settings']['flashvars']['cssSource'],
),
'width' => $profile['flash_settings']['width'],
'height' => $profile['flash_settings']['height'],
);
$settings['Piecemaker'][$id]['params'] = $profile['flash_settings']['params'];
$alternate = '<p>You do not have flash enabled</p>';
if (function_exists($alternate_callback)) {
$alternate = call_user_func_array($alternate_callback, $vars);
}
$out = "<div id=\"{$id}\" class=\"piecemaker piecemaker-{$handler} piecemaker-{$handler}-{$key}\">
{$alternate}
</div>";
return $out;
}
/**
* Themes the tranistion add/delete protion of the proile form
*/
function theme_piecemaker_transition_form($vars) {
$form = $vars['form'];
$tvars['header'] = array(
t('Effect'),
t('Weight'),
t('Pieces'),
t('Time'),
t('Delay'),
t('Depth Offset'),
t('Cube Distance'),
t('Add/Delete')
);
foreach(element_children($form) as $key) {
$row = array();
if ($key === 'add') {
//We need to create a item list that will be appended to the bottom of the form
//since the descriptions are getting too big for the table and break the layout
$head = $tvars['header'];
$items[] = array_shift($head) . ': ' . $form[$key]['Transition']['#description'];
unset($form[$key]['Transition']['#description']);
array_shift($head); //To get rid of the weight column
$items[] = array_shift($head) . ': ' . $form[$key]['Pieces']['#description'];
unset($form[$key]['Pieces']['#description']);
$items[] = array_shift($head) . ': ' . $form[$key]['Time']['#description'];
unset($form[$key]['Time']['#description']);
$items[] = array_shift($head) . ': ' . $form[$key]['Delay']['#description'];
unset($form[$key]['Delay']['#description']);
$items[] = array_shift($head) . ': ' . $form[$key]['DepthOffset']['#description'];
unset($form[$key]['DepthOffset']['#description']);
$items[] = array_shift($head) . ': ' . $form[$key]['CubeDistance']['#description'];
unset($form[$key]['CubeDistance']['#description']);
}
$row[] = drupal_render($form[$key]['Transition']);
$row[] = drupal_render($form[$key]['weight']);
$row[] = drupal_render($form[$key]['Pieces']);
$row[] = drupal_render($form[$key]['Time']);
$row[] = drupal_render($form[$key]['Delay']);
$row[] = drupal_render($form[$key]['DepthOffset']);
$row[] = drupal_render($form[$key]['CubeDistance']);
$row[] = drupal_render($form[$key]['action']);
$tvars['rows'][] = array(
'data' => $row,
'class' => array('draggable'),
);
}
$tvars['attributes'] = array(
'id' => 'piecemaker-transitions',
'class' => array('no-sticky'),
);
//Sticky headers don't work with draggable tables.
$tvars['sticky'] = FALSE;
$fieldset = array(
'#type' => 'fieldset',
'#title' => 'Field Descriptions',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$fieldset['list']['#markup'] = theme('item_list', array('items' => $items));
drupal_add_tabledrag('piecemaker-transitions', 'order', 'sibling', 'trans-weight');
return theme('table', $tvars) . drupal_render($fieldset);
}
/**
* Themes the flash params protion of the proile form
*/
function theme_piecemaker_profile_params($vars) {
$form = $vars['form'];
$add = drupal_render($form['add']);
foreach(element_children($form) as $key) {
$row = array();
$row[] = drupal_render($form[$key]['key']);
$row[] = drupal_render($form[$key]['value']);
$tvars['rows'][] = $row;
}
$tvars['header'] = array(
t('Key'),
t('Value'),
);
$tvars['attributes'] = array(
'id' => 'piecemaker-params',
);
return theme('table', $tvars) . $add;
}