コード例 #1
0
ファイル: V2EXCore.php プロジェクト: biaodianfu/project-babel
 public function vxBlogEditSave($rt)
 {
     $Entry =& $rt['Entry'];
     $_modes = Weblog::vxGetEditorModes();
     $_comment_permissions = Weblog::vxGetCommentPermissions();
     $Weblog = new Weblog($Entry->bge_pid);
     if ($Entry->bge_published != 0) {
         $published_date = date('Y-n-j', $Entry->bge_published);
         $published_time = date('G:i:s', $Entry->bge_published);
     } else {
         $published_date = date('Y-n-j', time());
         $published_time = date('G:i:s', time());
     }
     _v_m_s();
     echo '<link type="text/css" rel="stylesheet" href="/css/themes/' . BABEL_THEME . '/css_weblog.css" />';
     _v_b_l_s();
     _v_ico_map();
     echo ' <a href="/">' . Vocabulary::site_name . '</a> &gt; ' . $this->User->usr_nick_plain . ' &gt; <a href="/blog/admin.vx">博客网志</a> &gt; <a href="/blog/' . Weblog::DEFAULT_ACTION . '/' . $Weblog->blg_id . '.vx">' . make_plaintext($Weblog->blg_title) . '</a> &gt; ' . make_plaintext($Entry->bge_title) . ' &gt; 编辑文章 <span class="tip_i"><small>alpha</small></span>';
     _v_d_e();
     _v_b_l_s();
     echo '<div align="left"><table cellpadding="5" cellspacing="" border="0" class="form">';
     echo '<form action="/blog/edit/save/' . $Entry->bge_id . '.vx" method="post" id="form_blog_edit">';
     echo '<tr><td colspan="2" align="left"><h1 class="ititle">';
     _v_ico_tango_32('actions/document-new');
     echo ' 撰写新文章</h1> <span class="tip_i">刚才提交的数据中有些问题需要修正</span></td></tr>';
     echo '<tr><td colspan="2" align="right"><input onfocus="brightBox(this);" onblur="dimBox(this);" type="text" class="sllt" name="bge_title" value="' . make_single_return($rt['bge_title_value'], 0) . '" />';
     if ($rt['bge_title_error'] > 0) {
         echo '<br /><span class="tip_i">' . _vo_ico_silk('exclamation') . ' ' . $rt['bge_title_error_msg'][$rt['bge_title_error']] . '</span>';
     }
     echo '</td></tr>';
     echo '<tr><td colspan="2" align="right"><textarea class="ml" rows="30" name="bge_body" style="width: 550px;">' . make_multi_return($rt['bge_body_value'], 0) . '</textarea>';
     if ($rt['bge_body_error'] > 0) {
         echo '<br /><span class="tip_i">' . _vo_ico_silk('exclamation') . ' ' . $rt['bge_body_error_msg'][$rt['bge_body_error']] . '</span>';
     }
     echo '</td></tr>';
     echo '<tr><td width="100" align="right">格式</td><td align="left">';
     echo '<select name="bge_mode">';
     foreach ($_modes as $key => $mode) {
         if ($rt['bge_mode_value'] == $key) {
             echo '<option value="' . $key . '" selected="selected">' . $mode . '</option>';
         } else {
             echo '<option value="' . $key . '">' . $mode . '</option>';
         }
     }
     echo '</select>';
     echo '</td></tr>';
     echo '<tr><td width="100" align="right">评论许可</td><td align="left">';
     echo '<select name="bge_comment_permission">';
     foreach ($_comment_permissions as $key => $mode) {
         if ($rt['bge_comment_permission_value'] == $key) {
             echo '<option value="' . $key . '" selected="selected">' . $mode . '</option>';
         } else {
             echo '<option value="' . $key . '">' . $mode . '</option>';
         }
     }
     echo '</select>';
     echo '</td></tr>';
     echo '<tr><td width="100" align="right">标签</td><td align="left"><input onfocus="brightBox(this);" onblur="dimBox(this);" type="text" class="sll" name="bge_tags" value="" /></td></tr>';
     echo '<tr><td width="100" align="right">状态</td><td align="left">';
     echo '<select name="bge_status">';
     if ($rt['bge_status_value'] == 1) {
         echo '<option value="0">草稿</option>';
         echo '<option value="1" selected="selected">公开发布</option>';
     } else {
         echo '<option value="0" selected="selected">草稿</option>';
         echo '<option value="1">公开发布</option>';
     }
     echo '</select>';
     echo '</td></tr>';
     echo '<tr><td width="100" align="right">发布时间</td><td align="left"><input onfocus="brightBox(this);" onblur="dimBox(this);" type="text" class="sl" name="bge_published_date" value="' . $published_date . '" /> <input onfocus="brightBox(this);" onblur="dimBox(this);" type="text" class="sl" name="bge_published_time" value="' . $published_time . '" /></td></tr>';
     echo '<tr><td colspan="2" valign="middle" align="right" class="toolbar">';
     echo '<input type="submit" value="保存" class="btn_white" /> ';
     echo '<input type="button" value="取消" class="btn_white" onclick="location.href=' . "'/blog/list/{$Weblog->blg_id}.vx'" . ';" /> ';
     echo '<input type="button" value="删除" class="btn_white" onclick="if (confirm(' . "'确认删除?'" . ')) { location.href = ' . "'/blog/erase/24.vx'" . '; } else { return false; }" />';
     echo '</td></tr>';
     echo '</form>';
     echo '</table></div>';
     _v_d_e();
     _v_d_e();
 }
コード例 #2
0
 public function vxBlogComposeCheck()
 {
     $rt = array();
     $rt['errors'] = 0;
     /* bge_title (max: 50) */
     $rt['bge_title_value'] = '';
     $rt['bge_title_maxlength'] = 50;
     $rt['bge_title_error'] = 0;
     $rt['bge_title_error_msg'] = array(1 => '你没有写文章的标题', 2 => '你输入的文章的标题过长');
     if (isset($_POST['bge_title'])) {
         $rt['bge_title_value'] = fetch_single($_POST['bge_title']);
         if ($rt['bge_title_value'] == '') {
             $rt['errors']++;
             $rt['bge_title_error'] = 1;
         } else {
             if (mb_strlen($rt['bge_title_value'], 'UTF-8') > $rt['bge_title_maxlength']) {
                 $rt['errors']++;
                 $rt['bge_title_error'] = 2;
             }
         }
     } else {
         $rt['errors']++;
         $rt['bge_title_error'] = 1;
     }
     /* bge_body (null) (text) */
     $rt['bge_body_value'] = '';
     $rt['bge_body_maxlength'] = 1024 * 1024 * 2;
     $rt['bge_body_error'] = 0;
     $rt['bge_body_error_msg'] = array(2 => '你输入的文章内容过长');
     if (isset($_POST['bge_body'])) {
         $rt['bge_body_value'] = fetch_multi($_POST['bge_body']);
         if (mb_strlen($rt['bge_body_value'], 'UTF-8') > $rt['bge_body_maxlength']) {
             $rt['errors']++;
             $rt['bge_body_error'] = 2;
         }
     }
     /* bge_mode */
     $_modes = Weblog::vxGetEditorModes();
     $mode_default = Weblog::vxGetDefaultEditorMode();
     $rt['bge_mode_value'] = $mode_default;
     if (isset($_POST['bge_mode'])) {
         $rt['bge_mode_value'] = intval($_POST['bge_mode']);
         if (!in_array($rt['bge_mode_value'], array_keys($_modes))) {
             $rt['bge_mode_value'] = $mode_default;
         }
     }
     /* bge_comment_permission */
     $_comment_permissions = Weblog::vxGetCommentPermissions();
     $comment_permission_default = Weblog::vxGetDefaultCommentPermission();
     $rt['bge_comment_permission_value'] = $comment_permission_default;
     if (isset($_POST['bge_comment_permission'])) {
         $rt['bge_comment_permission_value'] = intval($_POST['bge_comment_permission']);
         if (!in_array($rt['bge_comment_permission_value'], array_keys($_comment_permissions))) {
             $rt['bge_comment_permission_value'] = $comment_permission_default;
         }
     }
     /* bge_status (0 => draft, 1 => publish) */
     $rt['bge_status_value'] = 0;
     if (isset($_POST['bge_status'])) {
         $rt['bge_status_value'] = intval($_POST['bge_status']);
         if (!in_array($rt['bge_status_value'], array(0, 1))) {
             $rt['bge_status_value'] = 0;
         }
     }
     /* bge_tags */
     if (isset($_POST['bge_tags'])) {
         $rt['bge_tags_value'] = fetch_single($_POST['bge_tags']);
         if ($rt['bge_tags_value'] != '') {
             $tags = filter_tags(strtolower(fetch_single($_POST['bge_tags'])));
             $tags = explode(' ', $tags);
             $tags = array_unique($tags);
             $rt['bge_tags_value'] = $tags;
         } else {
             $rt['bge_tags_value'] = array();
         }
     }
     /* bge_published_date & bge_published_time */
     if (isset($_POST['bge_published_date']) && isset($_POST['bge_published_time'])) {
         $rt['bge_published_date_value'] = fetch_single($_POST['bge_published_date']);
         $rt['bge_published_time_value'] = fetch_single($_POST['bge_published_time']);
         $rt['published'] = strtotime($rt['bge_published_date_value'] . ' ' . $rt['bge_published_time_value']);
         if ($rt['published'] - mktime(0, 0, 0, 5, 31, 1985, 0) < 3600) {
             $rt['published'] = time();
         }
     } else {
         $rt['published'] = time();
     }
     return $rt;
 }