Ignore:
Timestamp:
Sep 18, 2016, 6:41:49 PM (8 years ago)
Author:
chronos
Message:
  • Modified: Use TinyMCE editor for news content.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/News/NewsPage.php

    r790 r839  
    6666    if($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
    6767    {
     68      $this->System->PageHeaders[] = array($this, 'GetPageHeader');
    6869      $Output = '<strong>Vložení nové aktuality:</strong><br />';
    6970      // TODO: Static reference to dynamic category item
     
    121122        $Enclosures = substr($Enclosures, 1);
    122123
    123         $_POST['content'] = str_replace("\n",'<br />',$_POST['content']);
    124124        $this->Database->insert('News', array('Category' => $Category['Id'], 'Title' => $_POST['title'],
    125125          'Content' => $_POST['content'], 'Date' => 'NOW()', 'IP' => $RemoteAddr,
     
    133133  }
    134134
     135  function GetPageHeader()
     136  {
     137    return('<script src="'.$this->System->Link('/Packages/TinyMCE/tinymce.min.js').'"></script>'.
     138        "<script>tinymce.init({
     139  selector: 'textarea',
     140  force_p_newlines : false,
     141  force_br_newlines : true,
     142  convert_newlines_to_brs : false,
     143  remove_linebreaks : true,
     144  plugins: [
     145    'advlist autolink lists link image charmap print preview anchor',
     146    'searchreplace visualblocks code fullscreen',
     147    'insertdatetime media table contextmenu paste code'
     148  ],
     149  toolbar: 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image',
     150  language: 'cs_CZ',
     151});</script>");
     152  }
     153
    135154  function ShowEdit()
    136155  {
     
    143162      if(($this->System->User->User['Id'] == $Row['User']))
    144163      {
    145         $Row['Content'] = str_replace('<br />', '', $Row['Content']);
     164        $this->System->PageHeaders[] = array($this, 'GetPageHeader');
    146165        $Output .= '<strong>Editace aktuality v kategorii '.$Category['Caption'].':</strong><br />';
    147166        $Output .= '<form action="?action=update" method="post">'.
    148167        '<input type="hidden" value="'.$_GET['id'].'" name="id">'.
    149168        'Nadpis:<br /><input type="text" size="54" name="title" value="'.$Row['Title'].'"><br />'.
    150         'Obsah:<br /><textarea name="content" rows="20" cols="40">'.$Row['Content'].'</textarea><br />'.
     169        'Obsah:<br /><textarea name="content" rows="20" cols="40" style="width: 50%">'.$Row['Content'].'</textarea><br />'.
    151170        'Odkaz:<br /><input type="text" size="54" name="link" value="'.$Row['Link'].'"><br />'.
    152171        '<input type="hidden" name="category" value="'.$Category['Id'].'"><br />'.
     
    172191        if($this->System->User->User['Id'] == $Row['User'])
    173192        {
    174           $_POST['content'] = str_replace("\n", '<br />', $_POST['content']);
    175193          $this->Database->update('News', 'Id='.$_POST['id'], array('Title' => $_POST['title'],
    176194            'Content' => $_POST['content'], 'Link' => $_POST['link']));
Note: See TracChangeset for help on using the changeset viewer.