t('LMO settings'),
'description' => t('Set the preferences to access LMO.'),
'page callback' => 'drupal_get_form',
'page arguments' => array('lmo_settings_form'),
'access arguments' => array('administer site configuration'),
'type' => MENU_NORMAL_ITEM,
);
$items['lmo'] = array(
'title' => t('League Manager Online'),
'page callback' => 'lmo_page',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
'weight' => 1,
);
$items['admin/content/lmo'] = array(
'title' => t('Administration LMO'),
'description' => t('Administrez vos leagues et classements avec LMO.'),
'access arguments' => array('administer lmo'),
'page callback' => 'lmo_page_backend',
);
$items['admin/content/lmo/backend'] = array(
'title' => t('Mode Admin LMO'),
'access arguments' => array('administer lmo'),
'page callback' => 'lmo_page_backend',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 0,
);
$items['admin/content/lmo/drupal'] = array(
'title' => t('Intégration LMO à Drupal'),
'access arguments' => array('administer lmo'),
'type' => MENU_LOCAL_TASK,
'page callback' => 'drupal_get_form',
'page arguments' => array('lmo_admin_integration_form'),
'weight' => 1,
);
$items['admin/content/lmo/drupal/content'] = array(
'title' => t('Options d\'intégration de contenu'),
'access arguments' => array('administer lmo'),
'type' => MENU_DEFAULT_LOCAL_TASK,
'page arguments' => array('lmo_admin_integration_form'),
'weight' => 0,
);
$items['admin/content/lmo/drupal/blocks'] = array(
'title' => t('Blocs'),
'access arguments' => array('administer lmo'),
'type' => MENU_LOCAL_TASK,
'page arguments' => array('lmo_admin_integration_form', 'blocks'),
'weight' => 1,
);
$items['admin/content/lmo/drupal/blocks/add'] = array(
'title' => t('Ajouter un bloc avec du contenu LMO'),
'access arguments' => array('administer lmo'),
'type' => MENU_CALLBACK,
'page arguments' => array('lmo_admin_integration_form', 'blocksadd'),
'weight' => 1,
);
$items['admin/content/lmo/drupal/blocks/delete'] = array(
'title' => t('Êtes-vous sûr de vouloir supprimer ce bloc?'),
'access arguments' => array('administer lmo'),
'type' => MENU_CALLBACK,
'page arguments' => array('lmo_admin_integration_form', 'blocksdelete', 6),
'weight' => 1,
);
$items['admin/content/lmo/drupal/blocks/conf'] = array(
'title' => t('Configuration du bloc LMO'),
'access arguments' => array('administer lmo'),
'type' => MENU_CALLBACK,
'page arguments' => array('lmo_admin_integration_form', 'blocksconf', 6),
'weight' => 1,
);
return $items;
}
function lmo_admin_integration_form(&$form_state, $task = 'options', $id = 0) {
$lmo_path= variable_get('lmo_local_path','');
$form=array();
switch ($task)
{
case 'blocks':
$blockarray = lmo_getblocksdata();
$form['text1'] = array(
'#type' => 'markup',
'#value' => t('Ici, c\'est une liste des blocs de contenu lmo mis en place sur votre site Drupal.
'.l('Creer un nouveau bloc ici ...', 'admin/content/lmo/drupal/blocks/add')),
);
$header = array (t('Title'),t('Type'), t('Status'), t('Actions'));
$rows = array();
foreach ($blockarray as $block)
{
$status = lmo_check_blockstatus ($block);
if ($status['ok'] == true) {
$statusmessage = t('o.k.');
} else $statusmessage = ''.t('broken').'';
/*$statusmessage .= ' | ';
if ($status['visible'] == true) {
$statusmessage .= t('visible');
} else $statusmessage .= t('not visible');*/
$actions = '
';
$actions .= '- '.l('Configurer','admin/content/lmo/drupal/blocks/conf/'.$block['delta']).'
';
$actions .= '- '.l('Supprimer','admin/content/lmo/drupal/blocks/delete/'.$block['delta']).'
';
$actions .= '
';
$rows[] = array(
$block['title'],
$block['type'],
$statusmessage,
$actions,
);
}
$form['table'] = array(
'#type' => 'markup',
'#value' => theme('table',$header, $rows),
);
break;
case 'blocksdelete':
$form['foo'] = array(
'#type' => 'markup',
'#title' => t('test'),
'#description' => t('test description'),
'#value' => t('Voulez-vous vraiment supprimer le bloc').' '.$id.'?',
);
$form['task'] = array('#type' => 'hidden', '#value' => 'blocksdelete');
$form['blockid'] = array('#type' => 'hidden', '#value' => $id);
$form['foo2'] = array(
'#type' => 'markup',
'#value' => '
',
);
$form['submit'] = array('#type' => 'submit', '#value' => t('Supprimer'), '#weight' => 51);
$form['cancel'] = array('#type' => 'button', '#value' => t('Annuler'), '#weight' => 50);
break;
case 'blocksadd':
$form['foo'] = array(
'#type' => 'markup',
'#value' => t('Ici, vous pouvez ajouter un bloc du contenu acctuel LMO sur votre site.'),
);
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#description' => t('Vous pouvez donner n\'importe quel titre à votre bloc'),
);
$form['blocktype'] = array(
'#type' => 'radios',
'#title' => t('Type de bloc'),
'#description' => t('Séléctionnez quel type de bloc LMO vous voulez créer!'),
'#options' => array('Liste de classement
Créer un bloc contenant les classements d\'une division spécifique.','Tableau
Créer un bloc dont le contenu d\'une équipe spécifique est affiché sous forme de tableau.'),
);
$form['task'] = array('#type' => 'hidden', '#value' => 'blocksadd');
$form['submit'] = array('#type' => 'submit', '#value' => t('Ajouter un bloc'));
break;
case 'blocksconf':
$block = lmo_getblock($id);
drupal_set_title(t('Configure block').' '.'"'.$block['title'].'"');
$status = lmo_check_blockstatus($block, true);
if ($status['message'] != '') {
$form['error'] = array(
'#type' => 'markup',
'#value' => ''.$status['message'].'',
);
}
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#description' => t('Vous pouvez donner n\'importe quel titre à votre bloc'),
'#default_value' => $block['title'],
);
$form['intro'] = array(
'#type' => 'textarea',
'#title' => t('Introduction'),
'#description' => t('Que souhaitez-vous afficher dans le haut des données LMO?'),
'#default_value' => $block['intro'],
);
$form['conclusion'] = array(
'#type' => 'textarea',
'#title' => t('Conclusion'),
'#description' => t('Que souhaitez-vous afficher dans le bas des données LMO?'),
'#default_value' => $block['intro'],
'#weight' => 30,
);
switch ($block['type']) {
case 'minitab':
require($lmo_path.'/init.php');
$dirliga = $lmo_path.'/'.$dirliga;
$dir = opendir($dirliga);
$files = array();
while ($file = readdir($dir)) {
if (substr($file, strlen($file)-4) == '.l98') $files[$file] = $file;
}
$form['option1'] = array(
'#type' => 'select',
'#title' => t('Fichier de la league'),
'#description' => t('Veuillez séléctionner la ligue dont vous voulez afficher les classements!'),
'#options' => $files,
'#return_value' => 1,
'#default_value' => $block['option1'],
);
$dir = opendir(PATH_TO_TEMPLATEDIR.'/mini');
$files2 = array();
while ($file = readdir($dir)) {
if (substr($file, strlen($file)-8) == '.tpl.php') {
$templatename = substr($file, 0, strlen($file)-8);
$files2[$templatename] = $templatename;
}
}
$form['option2'] = array(
'#type' => 'select',
'#title' => t('Template'),
'#description' => t('Veuillez séléctionner un template pour l\'affichage des classements!'),
'#options' => $files2,
'#return_value' => 1,
'#default_value' => $block['option2'],
);
$form['blockid'] = array('#type' => 'hidden', '#value' => $id);
$form['task'] = array('#type' => 'hidden', '#value' => 'blocksconf');
$form['submit'] = array('#type' => 'submit', '#value' => t('Save'), '#weight' => 51);
$form['cancel'] = array('#type' => 'button', '#value' => t('Cancel'), '#weight' => 50);
break;
default:
$form['foo'] = array(
'#type' => 'markup',
'#value' => t('Il y a une erreur avec la configuration du bloc, donc vous ne pouvez rien faire ici.').' ',
);
$form['foo2'] = array(
'#type' => 'markup',
'#value' => l(t('Retournez à la liste des blocs LMO ici!'), 'admin/content/lmo/drupal/blocks'),
);
}
break;
default:
$form['foo'] = array(
'#type' => 'markup',
'#value' => t('Ici devrait apparaître des options prochainement.'),
);
};
return $form;
}
function lmo_admin_integration_form_submit($form, &$form_state) {
$form_values = $form_state['values'];
$lmo_path= variable_get('lmo_local_path','');
switch ($form_values['task']) {
case 'blocksadd':
$type = 'undefined';
switch ($form_values['blocktype']) {
case 0:
$type = 'minitab';
break;
case 1:
$type = 'chart';
break;
}
db_query("INSERT INTO {lmo_blocks} SET type='".$type."', title='thisnewblock'");
$result = db_query("SELECT * FROM {lmo_blocks} WHERE title='thisnewblock'");
$blockdata = db_fetch_object($result);
db_query("UPDATE {lmo_blocks} SET title = '".$form_values['title']."' WHERE id='".$blockdata->id."'");
drupal_set_message('Le bloc a été crée "'.$form_values['title'].'". Veuillez configurer le contenu maintenant!');
drupal_goto('admin/content/lmo/drupal/blocks/conf/'.$blockdata->id);
break;
case 'blocksdelete':
db_query("DELETE FROM {lmo_blocks} WHERE id='".$form_values['blockid']."'");
db_query("DELETE FROM {blocks} WHERE delta='".$form_values['blockid']."' AND module='lmo'");
drupal_set_message(t('Le bloc a été supprimé'). ' '.$form_values['blockid']);
drupal_goto('admin/content/lmo/drupal/blocks');
break;
case 'blocksconf':
db_query("UPDATE {lmo_blocks} SET
option1='".$form_values['option1']."',
option2='".$form_values['option2']."',
intro='".$form_values['intro']."',
conclusion='".$form_values['conclusion']."',
title='".$form_values['title']."' WHERE id='".$form_values['blockid']."'");
drupal_set_message(t('La configuration du bloc a été sauvegardé'));
drupal_goto('admin/content/lmo/drupal/blocks');
break;
}
}