linea21-core
[ class tree: linea21-core ] [ index: linea21-core ] [ all elements ]

Source for file tpl_contribute.php

Documentation is available at tpl_contribute.php

  1. <?php
  2. /**
  3.  * @package linea21.core
  4.  * @subpackage public
  5.  * @author Simon Georget <simon@linea21.com>
  6.  * @version $id SVN
  7.  * @access public
  8.  * @license http://opensource.org/licenses/gpl-3.0.html
  9.  */
  10. ?>
  11.  
  12. <?php
  13.  
  14. if(defined('MOD_COMMENT') && MOD_COMMENT == 1 && commentEnabled('contribute')) {
  15.  
  16.   $id = 1;
  17.   
  18.   SetHTMLTitle(_t('comment','contribute_title'));
  19.   setBreadcrumb(array(_t('comment','contribute_title') => false));
  20.   
  21.   postCommentAction(array('module'=> ActiveItemKey($GLOBALS['activeitem']), 'module_id'=> $id));
  22.   
  23.   echo '<h1>'._t('comment','contribute_title').'</h1>'.END_LINE;
  24.   echo '<div class="sub-title">'.END_LINE;
  25.   echo sprintf(_t('comment','contribute_chapo'), getNbComments(array('module'=> ActiveItemKey($GLOBALS['activeitem']), 'module_id'=> $id)));
  26.   echo '</div>'.END_LINE;
  27.   
  28.   displayCommentForm(array('module'=> ActiveItemKey($GLOBALS['activeitem']), 'module_id'=> $id));
  29.   
  30.  
  31. } else {
  32. }
  33.  
  34.  
  35. if( ActiveItemKey($GLOBALS['activeitem']) =='contact') {
  36.   // set HTML Title
  37.   SetHTMLTitle(_t('contact','contact_us'));
  38.   setBreadcrumb(array(_t('contact','contact_us') => false));
  39.   include_once('../class/system/class.form.php');
  40.  
  41.   $name='';
  42.   $email='';
  43.   $subject='';
  44.   $body='';
  45.  
  46.   if(isset($_POST['name'])) {
  47.     $passed = true;
  48.     $name=$_POST['name'];
  49.     $email=$_POST['email'];
  50.     $subject=$_POST['subject'];
  51.     $body=$_POST['body'];
  52.  
  53.     if(strlen($body)< 8) {
  54.       $msg=sprintf(_t('contact','str_error'), _t('contact', 'body'));
  55.       $class='error';
  56.       $passed = false;
  57.     }
  58.     if(strlen($subject)< 3) {
  59.       $msg=sprintf(_t('contact','str_error'), _t('contact', 'subject'));
  60.       $class='error';
  61.       $passed = false;
  62.     }
  63.     if(!validEmail($email)) {
  64.       $msg=sprintf(_t('contact','email_error'), $email);
  65.       $class='error';
  66.       $passed = false;
  67.     }
  68.     if(strlen($email)< 3) {
  69.       $msg=sprintf(_t('contact','str_error'), _t('contact', 'email'));
  70.       $class='error';
  71.       $passed = false;
  72.     }
  73.     if(strlen($name)< 3) {
  74.       $msg=sprintf(_t('contact','str_error'), _t('contact', 'name'));
  75.       $class='error';
  76.       $passed = false;
  77.     }
  78.     if($passed == true) {
  79.       $class = 'info';
  80.       $msg = _t('contact', 'message_sent');
  81.       $email_recipient = SITE_MAIL;
  82.       $email_fromname = $name;
  83.       $email_from = $email;
  84.       $email_subject = formatText($subject, '2HTML') . ' - '. SITE_NAME;
  85.       $email_html_body = formatText($body, '2HTML');
  86.       $email_text_body = strip_tags($email_html_body);
  87.       include_once(override('../mail/template.php'));
  88.     }
  89.   }
  90.   echo '<div>'.END_LINE;
  91.   echo '<h1>'._t('contact','contact_us').'</h1>'.END_LINE;
  92.   if(isset($passed)) echo '<div class="'.$class.'">'.$msg.'</div>'.END_LINE;
  93.  
  94.   if(!isset($passed) || $passed == false) {
  95.     $form = new genForm;
  96.     $form->startForm('index.php', '#contactform');
  97.     $form->textInput('name', _t('contact', 'name'). ' : ', 'shorttextfield', 'labelised', 'title', 100, 30, false, $name, false);
  98.     $form->insertBR();
  99.     $form->textInput('email', _t('contact', 'email'). ' : ', 'shorttextfield', 'labelised', 'title', 150, 30, false, $email, false);
  100.     $form->insertBR();
  101.     $form->textInput('subject', _t('contact', 'subject'). ' : ', 'shorttextfield', 'labelised', 'title', 150, 30, false, $subject, false);
  102.     $form->insertBR();
  103.     $form->textareaInput('body',ucfirst(_t('contact', 'body')) .' : ',false,'labelised', false, $body, 60, 10);
  104.     $form->insertBR();
  105.     $form->submitButton(false, _t('btn', 'valid'), true, 'submitbut');
  106.     $form->hiddenInput('rub', $_REQUEST['rub']);
  107.     $form->closeForm();
  108.     if(!$output = $form->getForm()) { die("error: " . $form->error); }
  109.     else { echo $output; }
  110.   }
  111.   echo '</div>'.END_LINE;
  112. }
  113.  
  114. ?>

Documentation generated on Thu, 20 Mar 2014 16:49:38 +0100 by phpDocumentor 1.4.1