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


PHP comment::prepareFromArray方法代码示例

本文整理汇总了PHP中comment::prepareFromArray方法的典型用法代码示例。如果您正苦于以下问题:PHP comment::prepareFromArray方法的具体用法?PHP comment::prepareFromArray怎么用?PHP comment::prepareFromArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在comment的用法示例。


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

示例1: edit

 public function edit($id = NULL)
 {
     $id = (int) $id;
     if (!$id) {
         $this->redirect('comments');
     }
     $this->view->conf = $this->conf;
     $Comment = new comment();
     $comment = $Comment->find($id);
     $comment['content'] = utils::convert2HTML($comment['content']);
     $Post = new post();
     $post = $Post->findBy('ID', $comment['ID_post']);
     $comment['post'] = array('urlfriendly' => $post['urlfriendly'], 'title' => $post['title']);
     $this->view->comment = $comment;
     $this->view->id = $id;
     $statuses = array("publish", "waiting");
     $this->view->statuses = $statuses;
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         if (isset($_POST['cancelar'])) {
             $this->redirect("comments");
         } else {
             ###########
             # Las siguientes dos lineas no deberian estar pero algo anda mal con el ActiveRecord que no deja las variables
             # de las consultas que se realizan directamente desde dentro de algun metodo en el model con $this->db->query e interfiere
             # con el actualizar por que podria haber campos que no se requieren en la actualizacion.
             ###########
             $comment = new comment();
             #######
             $comment->find($id);
             #######
             $comment->prepareFromArray($_POST);
             $comment->save();
             $this->redirect("comments/edit/{$id}");
         }
     } else {
         $this->view->setLayout("admin");
         $this->title_for_layout($this->l10n->__("Editar comentario - Codice CMS"));
         $this->render();
     }
 }
开发者ID:ravenlp,项目名称:CodiceCMS,代码行数:40,代码来源:comments_controller.php

示例2: addComment

 public function addComment($urlfriendly = null)
 {
     $C = new configuration();
     $codice = $C->getBlogConfiguration();
     if ($this->data) {
         if (is_null($urlfriendly) === true) {
             $this->redirect($codice['blog_siteurl'], true);
         }
         $P = new post();
         $post = $P->findBy('urlfriendly', $urlfriendly);
         if ($P->isNew() === true) {
             $this->redirect($codice['blog_siteurl'], true);
         }
         if (isset($this->data["resultado"]) === true) {
             $captcha = $this->data['resultado'];
             if ($captcha != '5') {
                 $this->session->flash('Tu comentario no puede ser agregado. Necesitas contestar la pregunta correctamente.');
                 $this->redirect("{$post['urlfriendly']}#comments");
             }
             unset($this->data['resultado']);
         } else {
             $this->session->flash('Tu comentario no puede ser agregado. Necesitas contestar la pregunta.');
             $this->redirect("{$post['urlfriendly']}#comments");
         }
         if ($this->cookie->check('id_user')) {
             $this->data['user_id'] = $this->cookie->id_user;
             $this->data['status'] = 'publish';
         } else {
             $this->data['user_id'] = 0;
             $this->data['status'] = 'waiting';
         }
         $this->data['type'] = '';
         //'pingback', 'trackback', ''
         $this->data['IP'] = utils::getIP();
         $this->data['ID_post'] = $post["ID"];
         $this->cookie->author = $this->data['author'];
         $this->cookie->email = $this->data['email'];
         $this->cookie->url = $this->data['url'];
         $C = new comment();
         $C->prepareFromArray($this->data);
         $valid = $C->save();
         if ($valid) {
             $this->registry->lastCommentID = $valid;
             $this->registry->postID = $post["ID"];
             $this->plugin->call("index_comment_added");
         }
         if ($valid and $this->isAjax()) {
             echo $valid;
         } else {
             if ($valid) {
                 $this->redirect("{$post['urlfriendly']}#comment-{$valid}");
             } else {
                 $this->redirect("{$post['urlfriendly']}");
             }
         }
     }
 }
开发者ID:ravenlp,项目名称:CodiceCMS,代码行数:57,代码来源:index_controller.php


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