本文整理汇总了PHP中post::prepareFromArray方法的典型用法代码示例。如果您正苦于以下问题:PHP post::prepareFromArray方法的具体用法?PHP post::prepareFromArray怎么用?PHP post::prepareFromArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类post
的用法示例。
在下文中一共展示了post::prepareFromArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
public function edit($id = NULL)
{
$id = (int) $id;
if (!$id) {
$this->redirect('admin');
}
$statuses = array("publish", "draft");
if ($this->data) {
if (isset($this->data['cancelar'])) {
$this->redirect("admin/");
} else {
$P = new post();
$P->find($id);
if (!preg_match("/\\S+/", $this->data['title']) or $this->data['title'] == "") {
$this->data['title'] = "Untitled";
}
if (!preg_match("/\\S+/", $this->data['urlfriendly']) or $this->data['urlfriendly'] == "") {
$this->data['urlfriendly'] = $this->data['title'];
}
$this->data['urlfriendly'] = $P->buildUrl($this->data['urlfriendly'], $id);
$P->updateTags($id, $this->data['tags']);
unset($this->data['tags']);
$P->prepareFromArray($this->data);
$P->save();
$this->session->flash('Información guardada correctamente.');
$this->redirect("admin/edit/{$id}");
}
}
$P = new post();
$post = $P->find($id);
$post['title'] = utils::convert2HTML($P['title']);
$post['content'] = utils::convert2HTML($P['content']);
$post['tags'] = $P->getTags($id, 'string');
$this->title_for_layout($this->l10n->__("Editar post - Codice CMS"));
$this->view->id = $id;
$this->view->post = $post;
$this->view->statuses = $statuses;
$this->view->setLayout("admin");
$this->render();
}