Exemplo n.º 1
0
 function edit()
 {
     if (!$this->haveAccessTo('edit')) {
         return $this->showAccessDenied();
     }
     $aData = array('content' => '', 'title' => '', 'filename' => '');
     $nRecordID = func::POSTGET('rec', false, true);
     if ($nRecordID <= 0) {
         $this->adminRedirect(Errors::IMPOSSIBLE);
     }
     if (func::isPostMethod()) {
         $sFilename = func::POST('filename', true);
         $sTitle = func::POST('title', true);
         $sMetaDescription = func::POST('mdescription', true);
         $sMetaKeywords = func::POST('mkeywords', true);
         $sContent = stripslashes(func::POST('content'));
         $sContent = eregi_replace('\\\\"', '"', $sContent);
         $sContent = eregi_replace('\\"', '"', $sContent);
         $sContent = eregi_replace('\\"', '"', $sContent);
         $sFilename = $this->db->one_data('SELECT filename FROM ' . TABLE_PAGES . ' WHERE id=' . $nRecordID . ' LIMIT 1');
         if ($this->errors->no()) {
             CDir::putFileContent(PAGES_PATH . $sFilename . PAGES_EXTENSION, $sContent);
             if (BFF_GENERATE_META_AUTOMATICALY) {
                 if ((empty($sMetaKeywords) || empty($sMetaDescription)) && !empty($sContent)) {
                     func::generateMeta($sContent, $aData);
                     if (empty($sMetaDescription)) {
                         $sMetaDescription = $aData['mdescription'];
                     }
                     if (empty($sMetaKeywords)) {
                         $sMetaKeywords = $aData['mkeywords'];
                     }
                 }
             }
             $this->db->execute('UPDATE ' . TABLE_PAGES . '
                              SET title = ' . $this->db->str2sql($sTitle) . ', 
                                  mkeywords = ' . $this->db->str2sql($sMetaKeywords) . ',
                                  mdescription = ' . $this->db->str2sql($sMetaDescription) . ", \n                                     modified = {$this->db->getNOW()}\n                                 WHERE id={$nRecordID}");
             $this->adminRedirect(Errors::SUCCESSFULL);
         }
         $aData = $_POST;
     } else {
         $aData = $this->db->one_array('SELECT * FROM ' . TABLE_PAGES . ' WHERE id=' . $nRecordID . ' LIMIT 1');
         $aData['content'] = CDir::getFileContent(PAGES_PATH . $aData['filename'] . PAGES_EXTENSION);
     }
     $this->tplAssign('aData', $aData);
     return $this->tplFetch('admin.form.tpl');
 }