当前位置: 首页>>代码示例>>PHP>>正文


PHP parse_markdown函数代码示例

本文整理汇总了PHP中parse_markdown函数的典型用法代码示例。如果您正苦于以下问题:PHP parse_markdown函数的具体用法?PHP parse_markdown怎么用?PHP parse_markdown使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了parse_markdown函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: pre_output

 /**
  * Pre-Ouput content
  *
  * @access 	public
  * @return 	string
  */
 public function pre_output($input, $params)
 {
     $parse_tags = !isset($params['allow_tags']) ? 'n' : $params['allow_tags'];
     $content_type = !isset($params['content_type']) ? 'html' : $params['content_type'];
     // If this is the admin, show only the source
     // @TODO This is hacky, there will be times when the admin wants to see a preview or something
     if (defined('ADMIN_THEME')) {
         return $input;
     }
     // If this isn't the admin and we want to allow tags,
     // let it through. Otherwise we will escape them.
     if ($parse_tags == 'y') {
         $content = $this->CI->parser->parse_string($input, array(), true);
     } else {
         $this->CI->load->helper('text');
         $content = escape_tags($input);
     }
     // Not that we know what content is there, what format should we treat is as?
     switch ($content_type) {
         case 'md':
             $this->CI->load->helper('markdown');
             return parse_markdown($content);
         case 'html':
             return $content;
         default:
             return strip_tags($content);
     }
 }
开发者ID:nockout,项目名称:tshpro,代码行数:34,代码来源:field.textarea.php

示例2: parse_markdown

 public function parse_markdown($string)
 {
     $string = str_replace('_', '\\_', $string);
     $string = parse_markdown($string);
     $string = str_replace('\\_', '_', $string);
     return $string;
 }
开发者ID:RA2WP,项目名称:RA2WP,代码行数:7,代码来源:documentation_helper.php

示例3: create

 /**
  * Create page chunks
  *
  * @access 	public
  * @param 	array 	$input The sanitized $_POST
  * @return 	bool
  */
 public function create($input)
 {
     $chunk_slugs = $input['chunk_slug'] ? array_values($input['chunk_slug']) : array();
     $chunk_bodies = $input['chunk_body'] ? array_values($input['chunk_body']) : array();
     $chunk_types = $input['chunk_type'] ? array_values($input['chunk_type']) : array();
     $page->chunks = array();
     $chunk_bodies_count = count($input['chunk_body']);
     for ($i = 0; $i < $chunk_bodies_count; $i++) {
         $page->chunks[] = (object) array('id' => $i, 'slug' => !empty($chunk_slugs[$i]) ? $chunk_slugs[$i] : '', 'type' => !empty($chunk_types[$i]) ? $chunk_types[$i] : '', 'body' => !empty($chunk_bodies[$i]) ? $chunk_bodies[$i] : '');
     }
     if ($page->chunks) {
         // get rid of the old
         $this->delete_by('page_id', $input['id']);
         // And add the new ones
         $i = 1;
         foreach ($page->chunks as $chunk) {
             $this->insert(array('slug' => preg_replace('/[^a-zA-Z0-9_-\\s]/', '', $chunk->slug), 'page_id' => $input['id'], 'body' => $chunk->body, 'parsed' => $chunk->type == 'markdown' ? parse_markdown($chunk->body) : '', 'type' => $chunk->type, 'sort' => $i++));
         }
         return TRUE;
     }
     return FALSE;
 }
开发者ID:gamchantoi,项目名称:sisfo-ft,代码行数:29,代码来源:page_chunk_m.php

示例4: edit

 /**
  * Edit blog post
  *
  * @access public
  * @param int $id the ID of the blog post to edit
  * @return void
  */
 public function edit($id = 0)
 {
     $id or redirect('admin/blog');
     $post = $this->blog_m->get($id);
     $post->keywords = Keywords::get_string($post->keywords);
     // If we have a useful date, use it
     if ($this->input->post('created_on')) {
         $created_on = strtotime(sprintf('%s %s:%s', $this->input->post('created_on'), $this->input->post('created_on_hour'), $this->input->post('created_on_minute')));
     } else {
         $created_on = $post->created_on;
     }
     $this->form_validation->set_rules(array_merge($this->validation_rules, array('title' => array('field' => 'title', 'label' => 'lang:blog_title_label', 'rules' => 'trim|htmlspecialchars|required|max_length[100]|callback__check_title[' . $id . ']'), 'slug' => array('field' => 'slug', 'label' => 'lang:blog_slug_label', 'rules' => 'trim|required|alpha_dot_dash|max_length[100]|callback__check_slug[' . $id . ']'))));
     if ($this->form_validation->run()) {
         // They are trying to put this live
         if ($post->status != 'live' and $this->input->post('status') == 'live') {
             role_or_die('blog', 'put_live');
         }
         $author_id = empty($post->display_name) ? $this->current_user->id : $post->author_id;
         $result = $this->blog_m->update($id, array('title' => $this->input->post('title'), 'slug' => $this->input->post('slug'), 'category_id' => $this->input->post('category_id'), 'keywords' => Keywords::process($this->input->post('keywords')), 'intro' => $this->input->post('intro'), 'body' => $this->input->post('body'), 'status' => $this->input->post('status'), 'created_on' => $created_on, 'comments_enabled' => $this->input->post('comments_enabled'), 'author_id' => $author_id, 'type' => $this->input->post('type'), 'parsed' => $this->input->post('type') == 'markdown' ? parse_markdown($this->input->post('body')) : ''));
         if ($result) {
             $this->session->set_flashdata(array('success' => sprintf(lang('blog_edit_success'), $this->input->post('title'))));
             // They are trying to put this live
             if ($post->status != 'live' and $this->input->post('status') == 'live') {
                 // Fire an event, we're posting a new blog!
                 Events::trigger('blog_article_published', $id);
             }
         } else {
             $this->session->set_flashdata('error', $this->lang->line('blog_edit_error'));
         }
         // Redirect back to the form or main page
         $this->input->post('btnAction') == 'save_exit' ? redirect('admin/blog') : redirect('admin/blog/edit/' . $id);
     }
     // Go through all the known fields and get the post values
     foreach ($this->validation_rules as $key => $field) {
         if (isset($_POST[$field['field']])) {
             $post->{$field}['field'] = set_value($field['field']);
         }
     }
     $post->created_on = $created_on;
     $this->template->title($this->module_details['name'], sprintf(lang('blog_edit_title'), $post->title))->append_metadata($this->load->view('fragments/wysiwyg', $this->data, TRUE))->append_js('jquery/jquery.tagsinput.js')->append_js('module::blog_form.js')->append_css('jquery/jquery.tagsinput.css')->set('post', $post)->build('admin/form');
 }
开发者ID:gamchantoi,项目名称:sisfo-ft,代码行数:48,代码来源:admin.php

示例5: update

 /**
  * Update an existing comment
  *
  * @access public
  * @param int $id The ID of the comment to update
  * @param array $input The array containing the data to update
  * @return void
  */
 public function update($id, $input)
 {
     $this->load->helper('date');
     return parent::update($id, array('name' => isset($input['name']) ? ucwords(strtolower(strip_tags($input['name']))) : '', 'email' => isset($input['email']) ? strtolower($input['email']) : '', 'website' => isset($input['website']) ? prep_url(strip_tags($input['website'])) : '', 'comment' => htmlspecialchars($input['comment'], NULL, FALSE), 'parsed' => parse_markdown(htmlspecialchars($input['comment'], NULL, FALSE))));
 }
开发者ID:gamchantoi,项目名称:sisfo-ft,代码行数:13,代码来源:comments_m.php

示例6: create

 /**
  * Create a new comment
  *
  * @param type $module The module that has a comment-able model.
  * @param int $id The id for the respective comment-able model of a module.
  */
 public function create($module = 'home', $id = 0)
 {
     // Set the comment data
     $comment = $_POST;
     // Logged in? in which case, we already know their name and email
     if ($this->ion_auth->logged_in()) {
         $comment['user_id'] = $this->current_user->id;
         $comment['name'] = $this->current_user->display_name;
         $comment['email'] = $this->current_user->email;
         if (isset($this->current_user->website)) {
             $comment['website'] = $this->current_user->website;
         }
     } else {
         $this->validation_rules[0]['rules'] .= '|required';
         $this->validation_rules[1]['rules'] .= '|required';
     }
     // Set the validation rules
     $this->form_validation->set_rules($this->validation_rules);
     $comment['module'] = $module;
     $comment['module_id'] = $id;
     $comment['is_active'] = (bool) (isset($this->current_user->group) && $this->current_user->group == 'admin' or !$this->settings->moderate_comments);
     // Validate the results
     if ($this->form_validation->run()) {
         // ALLOW ZEH COMMENTS!? >:D
         $result = $this->_allow_comment();
         foreach ($comment as &$data) {
             // Remove {pyro} tags and html
             $data = escape_tags($data);
         }
         // Run Akismet or the crazy CSS bot checker
         if ($result['status'] !== true) {
             $this->session->set_flashdata('comment', $comment);
             $this->session->set_flashdata('error', $result['message']);
         } else {
             // Save the comment
             if ($comment_id = $this->comments_m->insert($comment)) {
                 // Approve the comment straight away
                 if (!$this->settings->moderate_comments or isset($this->current_user->group) && $this->current_user->group == 'admin') {
                     $this->session->set_flashdata('success', lang('comments.add_success'));
                     // Add an event so third-party devs can hook on
                     Events::trigger('comment_approved', $comment);
                 } else {
                     $this->session->set_flashdata('success', lang('comments.add_approve'));
                 }
                 $comment['comment_id'] = $comment_id;
                 // If markdown is allowed we will parse the body for the email
                 if (Settings::get('comment_markdown')) {
                     $comment['comment'] = parse_markdown($comment['comment']);
                 }
                 // Send the notification email
                 $this->_send_email($comment);
             } else {
                 $this->session->set_flashdata('error', lang('comments.add_error'));
             }
         }
     } else {
         $this->session->set_flashdata('error', validation_errors());
         // Loop through each rule
         foreach ($this->validation_rules as $rule) {
             if ($this->input->post($rule['field']) !== FALSE) {
                 $comment[$rule['field']] = escape_tags($this->input->post($rule['field']));
             }
         }
         $this->session->set_flashdata('comment', $comment);
     }
     // If for some reason the post variable doesnt exist, just send to module main page
     $redirect_to = $this->input->post('redirect_to') ? $this->input->post('redirect_to') : $module;
     if ($redirect_to == 'pages') {
         $redirect_to = 'home';
     }
     redirect($redirect_to);
 }
开发者ID:namdum,项目名称:pyrocms,代码行数:78,代码来源:comments.php

示例7: edit

 /**
  * Edit blog post
  *
  * @param int $id The ID of the blog post to edit
  */
 public function edit($id = 0)
 {
     $id or redirect('admin/blog');
     $post = $this->blog_m->get($id);
     // They are trying to put this live
     if ($post->status != 'live' and $this->input->post('status') == 'live') {
         role_or_die('blog', 'put_live');
     }
     // If we have keywords before the update, we'll want to remove them from keywords_applied
     $old_keywords_hash = trim($post->keywords) != '' ? $post->keywords : null;
     $post->keywords = Keywords::get_string($post->keywords);
     // If we have a useful date, use it
     if ($this->input->post('created_on')) {
         $created_on = strtotime(sprintf('%s %s:%s', $this->input->post('created_on'), $this->input->post('created_on_hour'), $this->input->post('created_on_minute')));
     } else {
         $created_on = $post->created_on;
     }
     // Load up streams
     $this->load->driver('Streams');
     $stream = $this->streams->streams->get_stream('blog', 'blogs');
     $stream_fields = $this->streams_m->get_stream_fields($stream->id, $stream->stream_namespace);
     // Get the validation for our custom blog fields.
     $blog_validation = $this->streams->streams->validation_array($stream->stream_slug, $stream->stream_namespace, 'new');
     $blog_validation = array_merge($this->validation_rules, array('title' => array('field' => 'title', 'label' => 'lang:global:title', 'rules' => 'trim|htmlspecialchars|required|max_length[100]|callback__check_title[' . $id . ']'), 'slug' => array('field' => 'slug', 'label' => 'lang:global:slug', 'rules' => 'trim|required|alpha_dot_dash|max_length[100]|callback__check_slug[' . $id . ']')));
     // Merge and set our validation rules
     $this->form_validation->set_rules(array_merge($this->validation_rules, $blog_validation));
     $hash = $this->input->post('preview_hash');
     if ($this->input->post('status') == 'draft' and $this->input->post('preview_hash') == '') {
         $hash = $this->_preview_hash();
     } elseif ($this->input->post('status') == 'live') {
         $hash = '';
     }
     if ($this->form_validation->run()) {
         $author_id = empty($post->display_name) ? $this->current_user->id : $post->author_id;
         $extra = array('title' => $this->input->post('title'), 'slug' => $this->input->post('slug'), 'category_id' => $this->input->post('category_id'), 'keywords' => Keywords::process($this->input->post('keywords'), $old_keywords_hash), 'body' => $this->input->post('body'), 'status' => $this->input->post('status'), 'created_on' => $created_on, 'updated_on' => $created_on, 'created' => date('Y-m-d H:i:s', $created_on), 'updated' => date('Y-m-d H:i:s', $created_on), 'comments_enabled' => $this->input->post('comments_enabled'), 'author_id' => $author_id, 'type' => $this->input->post('type'), 'parsed' => $this->input->post('type') == 'markdown' ? parse_markdown($this->input->post('body')) : '', 'preview_hash' => $hash);
         if ($this->streams->entries->update_entry($id, $_POST, 'blog', 'blogs', array('updated'), $extra)) {
             $this->session->set_flashdata(array('success' => sprintf(lang('blog:edit_success'), $this->input->post('title'))));
             // Blog article has been updated, may not be anything to do with publishing though
             Events::trigger('post_updated', $id);
             // They are trying to put this live
             if ($post->status != 'live' and $this->input->post('status') == 'live') {
                 // Fire an event, we're posting a new blog!
                 Events::trigger('post_published', $id);
             }
         } else {
             $this->session->set_flashdata('error', lang('blog:edit_error'));
         }
         // Redirect back to the form or main page
         $this->input->post('btnAction') == 'save_exit' ? redirect('admin/blog') : redirect('admin/blog/edit/' . $id);
     }
     // Go through all the known fields and get the post values
     foreach ($this->validation_rules as $key => $field) {
         if (isset($_POST[$field['field']])) {
             $post->{$field}['field'] = set_value($field['field']);
         }
     }
     $post->created_on = $created_on;
     // Set Values
     $values = $this->fields->set_values($stream_fields, $post, 'edit');
     // Run stream field events
     $this->fields->run_field_events($stream_fields, array(), $values);
     $this->template->title($this->module_details['name'], sprintf(lang('blog:edit_title'), $post->title))->append_metadata($this->load->view('fragments/wysiwyg', array(), true))->append_js('jquery/jquery.tagsinput.js')->append_js('module::blog_form.js')->set('stream_fields', $this->streams->fields->get_stream_fields($stream->stream_slug, $stream->stream_namespace, $values, $post->id))->append_css('jquery/jquery.tagsinput.css')->set('post', $post)->build('admin/form');
 }
开发者ID:nockout,项目名称:tshpro,代码行数:68,代码来源:admin.php

示例8: pre_save

 /**
  * Pre Save
  *
  * Process before saving to database. We have a dummy
  * value in the form so this gets processed, but we
  * ignore it and grab all the chunk inputs.
  *
  * @access	public
  * @param	array
  * @return	string
  */
 public function pre_save($raw_input, $field, $stream, $row_id, $input)
 {
     $this->CI->load->model('page_chunk_m');
     $slugs = array('chunk_slug', 'chunk_class', 'chunk_body', 'chunk_type');
     foreach ($slugs as $slug) {
         if (!isset($input[$slug])) {
             $input[$slug] = null;
         }
     }
     $chunk_slugs = $input['chunk_slug'] ? array_values($input['chunk_slug']) : array();
     $chunk_class = $input['chunk_class'] ? array_values($input['chunk_class']) : array();
     $chunk_bodies = $input['chunk_body'] ? array_values($input['chunk_body']) : array();
     $chunk_types = $input['chunk_type'] ? array_values($input['chunk_type']) : array();
     $chunks = array();
     $chunk_bodies_count = count($chunk_bodies);
     for ($i = 0; $i < $chunk_bodies_count; $i++) {
         $chunks[] = (object) array('slug' => !empty($chunk_slugs[$i]) ? $chunk_slugs[$i] : '', 'class' => !empty($chunk_class[$i]) ? $chunk_class[$i] : '', 'type' => !empty($chunk_types[$i]) ? $chunk_types[$i] : '', 'body' => !empty($chunk_bodies[$i]) ? $chunk_bodies[$i] : '');
     }
     // No matter what, we are going to need to get rid of
     // old page chunks.
     $this->CI->page_chunk_m->delete_by('page_id', ci()->page_id);
     // If we have chunks, let's go ahead and add them.
     if ($chunks) {
         $i = 1;
         foreach ($chunks as $chunk) {
             $this->CI->page_chunk_m->insert(array('slug' => preg_replace('/[^a-zA-Z0-9_-]/', '', $chunk->slug), 'class' => preg_replace('/[^a-zA-Z0-9_-\\s]/', '', $chunk->class), 'page_id' => ci()->page_id, 'body' => $chunk->body, 'parsed' => $chunk->type == 'markdown' ? parse_markdown($chunk->body) : '', 'type' => $chunk->type, 'sort' => $i++));
         }
     }
     return '*';
 }
开发者ID:blekedeg,项目名称:lbhpers,代码行数:41,代码来源:field.chunks.php

示例9: update

 /**
  * Update an existing comment
  *
  * @param int $id The ID of the comment to update
  * @param array $input The array containing the data to update
  * @return void
  */
 public function update($id, $input, $skip_validation = false)
 {
     return parent::update($id, array('user_name' => isset($input['user_name']) ? ucwords(strtolower(strip_tags($input['user_name']))) : '', 'user_email' => isset($input['user_email']) ? strtolower($input['user_email']) : '', 'user_website' => isset($input['user_website']) ? prep_url(strip_tags($input['user_website'])) : '', 'comment' => htmlspecialchars($input['comment'], null, false), 'parsed' => parse_markdown(htmlspecialchars($input['comment'], null, false))));
 }
开发者ID:nockout,项目名称:tshpro,代码行数:11,代码来源:comment_m.php

示例10: edit

 /**
  * Edit news post
  *
  * @param int $id The ID of the news post to edit
  */
 public function edit($id = 0)
 {
     $id or redirect('admin/news');
     $post = $this->news_m->get($id);
     // They are trying to put this live
     if ($post->status != 'live' and $this->input->post('status') == 'live') {
         role_or_die('news', 'put_live');
     }
     // If we have keywords before the update, we'll want to remove them from keywords_applied
     $old_keywords_hash = trim($post->keywords) != '' ? $post->keywords : null;
     $post->keywords = Keywords::get_string($post->keywords);
     // If we have a useful date, use it
     if ($this->input->post('created_on')) {
         $created_on = strtotime(sprintf('%s %s:%s', $this->input->post('created_on'), $this->input->post('created_on_hour'), $this->input->post('created_on_minute')));
     } else {
         $created_on = $post->created_on;
     }
     // Load up streams
     $this->load->driver('Streams');
     $stream = $this->streams->streams->get_stream('news', 'news');
     $stream_fields = $this->streams_m->get_stream_fields($stream->id, $stream->stream_namespace);
     // Get the validation for our custom news fields.
     $news_validation = $this->streams->streams->validation_array($stream->stream_slug, $stream->stream_namespace, 'new');
     $news_validation = array_merge($this->validation_rules, array('title' => array('field' => 'title', 'label' => 'lang:global:title', 'rules' => 'trim|htmlspecialchars|required|max_length[100]|callback__check_title[' . $id . ']'), 'slug' => array('field' => 'slug', 'label' => 'lang:global:slug', 'rules' => 'trim|required|alpha_dot_dash|max_length[100]|callback__check_slug[' . $id . ']')));
     // Upload image validation
     if ($_FILES) {
         $allowed = array('.jpg', '.jpeg', '.gif', '.png');
         $upload_key = array_keys($_FILES);
         if (!empty($_FILES[$upload_key[0]]['name']) && $_FILES[$upload_key[0]]['error'] == UPLOAD_ERR_OK) {
             $ext = strtolower(strrchr($_FILES[$upload_key[0]]['name'], '.'));
             if (!in_array($ext, $allowed)) {
                 $this->form_validation->set_error('Invalid image file extension. Allowed extension are .jpg, .jpeg, .png, .gif');
             }
         }
     }
     // Merge and set our validation rules
     $this->form_validation->set_rules(array_merge($this->validation_rules, $news_validation));
     $hash = $this->input->post('preview_hash');
     if ($this->input->post('status') == 'draft' and $this->input->post('preview_hash') == '') {
         $hash = $this->_preview_hash();
     } elseif ($this->input->post('status') == 'live') {
         $hash = '';
     }
     if ($this->form_validation->run()) {
         $author_id = empty($post->display_name) ? $this->current_user->id : $post->author_id;
         $extra = array('title' => $this->input->post('title'), 'slug' => $this->input->post('slug'), 'category_id' => $this->input->post('category_id'), 'keywords' => Keywords::process($this->input->post('keywords'), $old_keywords_hash), 'body' => $this->input->post('body'), 'status' => $this->input->post('status'), 'created_on' => $created_on, 'updated_on' => $created_on, 'created' => date('Y-m-d H:i:s', $created_on), 'updated' => date('Y-m-d H:i:s', $created_on), 'comments_enabled' => $this->input->post('comments_enabled'), 'author_id' => $author_id, 'type' => $this->input->post('type'), 'parsed' => $this->input->post('type') == 'markdown' ? parse_markdown($this->input->post('body')) : '', 'preview_hash' => $hash);
         if ($this->streams->entries->update_entry($id, $_POST, 'news', 'news', array('updated'), $extra)) {
             // Upload image
             if ($_FILES) {
                 $upload_key = array_keys($_FILES);
                 if (!empty($_FILES[$upload_key[0]]['name']) && $_FILES[$upload_key[0]]['error'] == UPLOAD_ERR_OK) {
                     $tmp_name = $_FILES[$upload_key[0]]['tmp_name'];
                     $ext = strtolower(strrchr($_FILES[$upload_key[0]]['name'], '.'));
                     $file_name = 'IMG_' . date('Ymd_His') . $ext;
                     if (@move_uploaded_file($tmp_name, $this->_news_base_file_dir . '/' . $file_name)) {
                         @unlink($this->_news_base_file_dir . '/' . $post->image);
                         $this->db->update('news', array('image' => $file_name), array('id' => $id));
                     }
                 }
             }
             $this->session->set_flashdata(array('success' => sprintf(lang('news:edit_success'), $this->input->post('title'))));
             // news article has been updated, may not be anything to do with publishing though
             Events::trigger('post_updated', $id);
             // They are trying to put this live
             if ($post->status != 'live' and $this->input->post('status') == 'live') {
                 // Fire an event, we're posting a new news!
                 Events::trigger('post_published', $id);
             }
         } else {
             $this->session->set_flashdata('error', lang('news:edit_error'));
         }
         // Redirect back to the form or main page
         $this->input->post('btnAction') == 'save_exit' ? redirect('admin/news') : redirect('admin/news/edit/' . $id);
     }
     // Go through all the known fields and get the post values
     foreach ($this->validation_rules as $key => $field) {
         if (isset($_POST[$field['field']])) {
             $post->{$field}['field'] = set_value($field['field']);
         }
     }
     if (file_exists(UPLOAD_PATH . 'news/' . $post->image) && is_file(UPLOAD_PATH . 'news/' . $post->image)) {
         $image = $this->_news_base_file_dir . '/' . $post->image;
         $this->load->model('files/image_m');
         $post->image = $this->_news_base_file_url . '/' . $post->image;
         $post->thumb = $this->image_m->resize($image, 100, 100, 'crop');
     }
     $post->created_on = $created_on;
     // Set Values
     $values = $this->fields->set_values($stream_fields, $post, 'edit');
     // Run stream field events
     $this->fields->run_field_events($stream_fields, array(), $values);
     $this->template->title($this->module_details['name'], sprintf(lang('news:edit_title'), $post->title))->append_metadata($this->load->view('fragments/wysiwyg', array(), true))->append_js('jquery/jquery.tagsinput.js')->append_js('module::news_form.js')->set('stream_fields', $this->streams->fields->get_stream_fields($stream->stream_slug, $stream->stream_namespace, $values, $post->id))->append_css('jquery/jquery.tagsinput.css')->set('post', $post)->build('admin/form');
 }
开发者ID:blekedeg,项目名称:lbhpers,代码行数:98,代码来源:admin.php

示例11: markdown

 /**
  * Markdown
  *
  * Takes content and formats it with the Markdown Library.
  *
  * Usage:
  * {{ format:markdown }}
  *   Formatted **text**
  * {{ /format:markdown }}
  *
  * Outputs: <p>Formatted <strong>text</strong></p>
  *
  * @return string The HTML generated by the Markdown Library.
  */
 public function markdown()
 {
     $this->load->helper('markdown');
     $content = $this->attribute('content', $this->content());
     return parse_markdown(trim($content));
 }
开发者ID:rishikeshwalawalkar,项目名称:GetARide,代码行数:20,代码来源:format.php

示例12: update

 /**
  * Update a Page
  *
  * @access public
  * @param int $id The ID of the page to update
  * @param array $input The data to update
  * @return void
  */
 public function update($id = 0, $input = array(), $chunks = array())
 {
     $this->db->trans_start();
     if (!empty($input['is_home'])) {
         // Remove other homepages
         $this->db->where('is_home', 1)->update($this->_table, array('is_home' => 0));
     }
     parent::update($id, array('title' => $input['title'], 'slug' => $input['slug'], 'uri' => NULL, 'parent_id' => $input['parent_id'], 'layout_id' => $input['layout_id'], 'css' => $input['css'], 'js' => $input['js'], 'meta_title' => $input['meta_title'], 'meta_keywords' => $input['meta_keywords'], 'meta_description' => $input['meta_description'], 'restricted_to' => $input['restricted_to'], 'rss_enabled' => (int) (!empty($input['rss_enabled'])), 'comments_enabled' => (int) (!empty($input['comments_enabled'])), 'is_home' => (int) (!empty($input['is_home'])), 'status' => $input['status'], 'updated_on' => now()));
     $this->build_lookup($id);
     if ($chunks) {
         // Remove the old chunks
         $this->db->delete('page_chunks', array('page_id' => $id));
         // And add the new ones
         $i = 1;
         foreach ($chunks as $chunk) {
             $this->db->insert('page_chunks', array('page_id' => $id, 'sort' => $i++, 'slug' => preg_replace('/[^a-zA-Z0-9_-\\s]/', '', $chunk->slug), 'body' => $chunk->body, 'type' => $chunk->type, 'parsed' => $chunk->type == 'markdown' ? parse_markdown($chunk->body) : ''));
         }
     }
     // Wipe cache for this model, the content has changd
     $this->pyrocache->delete_all('page_m');
     $this->pyrocache->delete_all('navigation_m');
     $this->db->trans_complete();
     return $this->db->trans_status() === FALSE ? FALSE : TRUE;
 }
开发者ID:phonglanpls,项目名称:jz-proj-2012,代码行数:32,代码来源:page_m.php

示例13: create

 /**
  * Create a new comment
  *
  * @param type $module The module that has a comment-able model.
  * @param int $id The id for the respective comment-able model of a module.
  */
 public function create($module = null)
 {
     if (!$module or !$this->input->post('entry')) {
         show_404();
     }
     // Get information back from the entry hash
     // @HACK This should be part of the controllers lib, but controllers & libs cannot share a name
     $entry = unserialize($this->encrypt->decode($this->input->post('entry')));
     $comment = array('module' => $module, 'entry_id' => $entry['id'], 'entry_title' => $entry['title'], 'entry_key' => $entry['singular'], 'entry_plural' => $entry['plural'], 'uri' => $entry['uri'], 'comment' => $this->input->post('comment'), 'is_active' => (bool) (isset($this->current_user->group) and $this->current_user->group == 'admin' or !Settings::get('moderate_comments')));
     // Logged in? in which case, we already know their name and email
     if ($this->current_user) {
         $comment['user_id'] = $this->current_user->id;
         $comment['user_name'] = $this->current_user->display_name;
         $comment['user_email'] = $this->current_user->email;
         $comment['user_website'] = $this->current_user->website;
         if (isset($this->current_user->website)) {
             $comment['website'] = $this->current_user->website;
         }
     } else {
         $this->validation_rules[0]['rules'] .= '|required';
         $this->validation_rules[1]['rules'] .= '|required';
         $comment['user_name'] = $this->input->post('name');
         $comment['user_email'] = $this->input->post('email');
         $comment['user_website'] = $this->input->post('website');
     }
     // Set the validation rules
     $this->form_validation->set_rules($this->validation_rules);
     // Validate the results
     if ($this->form_validation->run()) {
         // ALLOW ZEH COMMENTS!? >:D
         $result = $this->_allow_comment();
         foreach ($comment as &$data) {
             // Remove {pyro} tags and html
             $data = escape_tags($data);
         }
         // Run Akismet or the crazy CSS bot checker
         if ($result['status'] !== true) {
             $this->session->set_flashdata('comment', $comment);
             $this->session->set_flashdata('error', $result['message']);
             $this->_repopulate_comment();
         } else {
             // Save the comment
             if ($comment_id = $this->comment_m->insert($comment)) {
                 // Approve the comment straight away
                 if (!$this->settings->moderate_comments or isset($this->current_user->group) and $this->current_user->group == 'admin') {
                     $this->session->set_flashdata('success', lang('comments:add_success'));
                     // Add an event so third-party devs can hook on
                     Events::trigger('comment_approved', $comment);
                 } else {
                     $this->session->set_flashdata('success', lang('comments:add_approve'));
                 }
                 $comment['comment_id'] = $comment_id;
                 // If markdown is allowed we will parse the body for the email
                 if (Settings::get('comment_markdown')) {
                     $comment['comment'] = parse_markdown($comment['comment']);
                 }
                 // Send the notification email
                 $this->_send_email($comment, $entry);
             } else {
                 $this->session->set_flashdata('error', lang('comments:add_error'));
                 $this->_repopulate_comment();
             }
         }
     } else {
         $this->session->set_flashdata('error', validation_errors());
         $this->_repopulate_comment();
     }
     // If for some reason the post variable doesnt exist, just send to module main page
     $uri = !empty($entry['uri']) ? $entry['uri'] : $module;
     // If this is default to pages then just send it home instead
     $uri === 'pages' and $uri = '/';
     redirect($uri);
 }
开发者ID:nockout,项目名称:tshpro,代码行数:79,代码来源:comments.php

示例14: pre_output

 /**
  * Process before outputting
  *
  * @access  public
  * @param   array
  * @return  string
  */
 public function pre_output($input)
 {
     $CI =& get_instance();
     $CI->load->helper('markdown');
     return parse_markdown($input);
 }
开发者ID:jacksun101,项目名称:PyroAddons,代码行数:13,代码来源:field.markdown.php

示例15: view

 /**
  * View topic
  * @access public
  * @param int $topic_id the topic id
  * @param var $option options for comments - add, delete
  * @param int $id the comment id
  * @return void
  */
 public function view($topic_id = 0, $option = NULL, $id = 0)
 {
     $created_now = now();
     $add_comment = $this->input->post('add_comment');
     if (!$topic_id or !($topic = $this->db->get_where('discussions', array('id' => $topic_id, 'type' => 'topic'))->first_row())) {
         // nothing here. better redirect.
         redirect('admin/discussion');
     }
     // add comment
     if ($option === 'add') {
         $this->form_validation->set_rules($this->add_comment_rules);
         if ($this->form_validation->run()) {
             $rqstObj = array('type' => 'comment', 'belongs_to' => $topic_id, 'desc' => $this->input->post('add_comment'), 'parsed' => parse_markdown($this->input->post('add_comment')), 'created_on' => $created_now, 'created_by' => $this->current_user->id, 'user_email' => $this->current_user->email, 'display_name' => $this->current_user->display_name);
             // insert in the same table with type comment
             $comment_id = $this->db->insert('discussions', $rqstObj);
             if ($comment_id) {
                 // go and update the main record
                 $this->db->where('id', $topic_id);
                 $update = $this->db->update('discussions', array('last_updated' => $created_now, 'tot_comments' => $topic->tot_comments + 1));
                 $this->session->set_flashdata('success', $this->lang->line('topic.comment_success'));
                 redirect('admin/discussion/view/' . $topic_id);
             } else {
                 // not OK. display error.
                 $this->session->set_flashdata('error', $this->lang->line('topic.comment_error'));
             }
         } else {
             // validation fails. get the fields and populate it again.
             foreach ($this->add_comment_rules as $key => $field) {
                 $field['field'] = set_value($field['field']);
             }
         }
     } else {
         if ($option === 'delete') {
             $query = $this->discussion_m->get_where('discussions', array('id' => $id, 'belongs_to' => $topic_id))->first_row();
             if (!$query or $this->current_user->id != $query->created_by) {
                 // prevent direct access via URL. only HE is authorized to delete the comment.
                 redirect('admin/discussion');
             }
             $hrc = $this->db->delete('discussions', array('belongs_to' => $topic_id, 'id' => $id));
             if ($hrc) {
                 $this->session->set_flashdata('success', $this->lang->line('topic.comment_delete_success'));
             } else {
                 $this->session->set_flashdata('error', $this->lang->line('topic.comment_delete_success'));
             }
             redirect('admin/discussion/view/' . $topic_id);
         }
     }
     // get the comments for the view page
     $comments = $this->discussion_m->get_comments($topic_id);
     $this->template->title($this->module_details['name'], $topic->title)->append_metadata($this->load->view('fragments/wysiwyg', $this->data, TRUE))->append_css('module::discussion.css')->set('topic', $topic)->set('add_comment', $add_comment)->set('comments', $comments)->build('admin/view_topic');
 }
开发者ID:numerogeek,项目名称:PyroDiscuss,代码行数:59,代码来源:admin.php


注:本文中的parse_markdown函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。