Dotclear

Changeset 2108


Ignore:
Timestamp:
03/08/10 22:10:58 (14 years ago)
Author:
Oaz
Message:

fixed multipart email bug + added DB content display

Location:
plugins/myForms/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • plugins/myForms/trunk/Email.php

    r962 r2108  
    3434    $this->bodyformat = 
    3535      '--'.$this->altboundary."\n". 
    36       'Content-Type: text/%s; charset="iso-8859-1"'."\n". 
     36      'Content-Type: text/%s; charset="utf-8"'."\n". 
    3737      'Content-Transfer-Encoding: 7bit'."\n\n%s\n"; 
    3838       
     
    7878      sprintf($this->bodyformat, 'plain', self::html2text(nl2br($text))). 
    7979      sprintf($this->bodyformat, 'html', $text). 
    80       '--'.$this->altboundary."\n"; 
     80      '--'.$this->altboundary; 
    8181  } 
    8282   
     
    105105        '--'.$this->mixedboundary."\n". 
    106106        $alt."\n\n". 
    107         $this->body."\n". 
     107        $this->body."\n\n". 
    108108        $this->attachments. 
    109         '--'.$this->mixedboundary."\n"; 
     109        '--'.$this->mixedboundary."--\n"; 
    110110    } else { 
    111111      array_unshift($this->headers, $alt); 
    112       $message = $this->body; 
     112      $message = $this->body."--\n"; 
    113113    } 
    114114    try 
  • plugins/myForms/trunk/TplCore.php

    r728 r2108  
    2020 
    2121$core->tpl->addValue('myformsContext',array('MyFormsTplCore','Context')); 
     22$core->tpl->addBlock('myformsPassword',array('MyFormsTplCore','Password')); 
    2223$core->tpl->addBlock('myformsInfo',array('MyFormsTplCore','Info')); 
    2324$core->tpl->addValue('myformsInfo',array('MyFormsTplCore','DisplayInfo')); 
     
    5758    $checks .= ' ?>'; 
    5859    return $checks; 
     60  } 
     61 
     62  // Define the form password 
     63  public static function Password($attr,$content) 
     64  { 
     65    return '<?php MyForms::password("'.$content.'"); ?>'; 
    5966  } 
    6067 
  • plugins/myForms/trunk/TplDatabase.php

    r728 r2108  
    2525$core->tpl->addBlock('myformsRecordField',array('MyFormsTplDatabase','RecordField')); 
    2626 
     27$core->tpl->addBlock('myformsDbSelect',array('MyFormsTplDatabase','DbSelect')); 
     28$core->tpl->addBlock('myformsDbRecord',array('MyFormsTplDatabase','DbRecord')); 
     29$core->tpl->addValue('myformsDbField',array('MyFormsTplDatabase','DbField')); 
     30 
    2731class MyFormsTplDatabase 
    2832{ 
     
    4246  } 
    4347   
     48  public static function DbSelect($attr,$content) 
     49  { 
     50    $where = ""; 
     51    if(isset($attr['where'])) 
     52      $where = ' WHERE '.$attr['where']; 
     53    return '<?php $record = $core->con->select("SELECT * FROM ".$core->prefix."'.$attr['table'].$where.'"); ?>'.$content; 
     54     } 
     55   
     56  public static function DbRecord($attr,$content) 
     57  { 
     58    return '<?php while ($record->fetch()) { ?>'. 
     59           $content. 
     60           '<?php } ?>'; 
     61     } 
     62 
     63  public static function DbField($attr) 
     64  { 
     65    return '<?php print $record->field("'.$attr['name'].'"); ?>'; 
     66  } 
     67   
    4468} 
    4569?> 
  • plugins/myForms/trunk/_define.php

    r1730 r2108  
    2323     /* Description*/         "Create a custom form page with custom action (save in db, send email…)", 
    2424     /* Author */             "Olivier Azeau", 
    25      /* Version */            '0.3a', 
     25     /* Version */            '0.4', 
    2626     /* Permissions */        null 
    2727); 
  • plugins/myForms/trunk/_public.php

    r1048 r2108  
    2929$core->url->register('formPost','form','^form$',array('MyForms','formPost')); 
    3030 
     31class PostSimu 
     32{ 
     33  public function getURL() 
     34  { 
     35    return $_SERVER['REQUEST_URI']; 
     36  } 
     37} 
     38 
    3139class MyForms extends dcUrlHandlers 
    3240{ 
     
    3947  private static $allFieldsAreValidated; 
    4048  private static $captchaIsValidated; 
     49  private static $passwordProtected; 
    4150   
    4251  public static function formGet($args) 
     
    5564  public static function form() 
    5665  { 
    57     global $core, $_REQUEST; 
     66    global $core, $_REQUEST, $_ctx; 
    5867     
    5968    // add all 'default-templates' folders to form search path 
     
    6372               array_push($tplPath, $plugin['root'].'/default-templates'); 
    6473    $core->tpl->setPath($tplPath); 
     74 
     75    self::$passwordProtected = false; 
    6576     
    6677    self::loadForm(); 
     78     
     79    if(self::$passwordProtected) { 
     80      $_ctx->posts = new PostSimu(); 
     81               self::serveDocument('password-form.html','text/html',false); 
     82               return; 
     83          } 
    6784     
    6885    // process  form post 
     
    99116    $core->tpl->getData($formTpl); 
    100117     
     118    // form is password protected 
     119    if(self::$passwordProtected) { 
     120            // Get passwords cookie 
     121               if (isset($_COOKIE['dc_form_passwd'])) { 
     122                    $pwd_cookie = unserialize($_COOKIE['dc_form_passwd']); 
     123               } else { 
     124                    $pwd_cookie = array(); 
     125               } 
     126                          
     127               // Check for match 
     128               if ((!empty($_POST['password']) && $_POST['password'] == self::$passwordProtected) 
     129               || (isset($pwd_cookie[self::$formID]) && $pwd_cookie[self::$formID] == self::$passwordProtected))   { 
     130                 // store password in cookie and clear password protection 
     131                    $pwd_cookie[self::$formID] = self::$passwordProtected; 
     132                    setcookie('dc_form_passwd',serialize($pwd_cookie),0,'/'); 
     133        self::$passwordProtected = false; 
     134               } else { 
     135                 // incorrect password : no need to go further 
     136                 return; 
     137               } 
     138    } 
     139     
    101140    // field display and validation 
    102141    self::$allFieldsAreValidated = true; 
     
    143182  { 
    144183    print self::$htmlOut; 
     184  } 
     185   
     186  public static function password($pw) 
     187  { 
     188    self::$passwordProtected = $pw; 
    145189  } 
    146190   
  • plugins/myForms/trunk/demo/email.myforms.html

    r979 r2108  
    11<tpl:myformsInfo name="title">{{tpl:BlogName encode_html="1"}} - Send email</tpl:myformsInfo> 
     2<tpl:myformsPassword>secret</tpl:myformsPassword> 
    23 
    34<tpl:myformsOnInit> 
  • plugins/myForms/trunk/index.php

    r798 r2108  
    2525$core->themes = new dcThemes($core); 
    2626$core->themes->loadModules($core->blog->themes_path,null); 
    27 $themeEditorClass = path::real(dirname(__FILE__).'/../themeEditor/class.themeEditor.php'); 
    28 if($themeEditorClass) { 
    29   require_once($themeEditorClass); 
     27$themeEditorRootPath = $core->plugins->moduleRoot("themeEditor"); 
     28if($themeEditorRootPath) { 
     29  require_once($themeEditorRootPath."/class.themeEditor.php"); 
    3030  class myFormsTplFileFinder extends dcThemeEditor 
    3131  { 
     
    7777  } 
    7878 
    79   if($themeEditorClass) { 
     79  if($themeEditorRootPath) { 
    8080    print '<h2>'.__('Click on a form to modify it.').'</h2>'; 
    8181    $fileFinder = new myFormsTplFileFinder($core); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map