本文整理汇总了PHP中post::findBy方法的典型用法代码示例。如果您正苦于以下问题:PHP post::findBy方法的具体用法?PHP post::findBy怎么用?PHP post::findBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类post
的用法示例。
在下文中一共展示了post::findBy方法的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();
}
}
示例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']}");
}
}
}
}