本文整理汇总了PHP中Conversation::find_by_filename方法的典型用法代码示例。如果您正苦于以下问题:PHP Conversation::find_by_filename方法的具体用法?PHP Conversation::find_by_filename怎么用?PHP Conversation::find_by_filename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Conversation
的用法示例。
在下文中一共展示了Conversation::find_by_filename方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
<?php
include "../../inc/init.inc";
if (isset($_GET['conversation']) && $_GET['conversation'] != 0 && Follower::isFriend($res->user->id, $_GET['conversation'])) {
$filename = $res->user->id > $_GET['conversation'] ? 'conversations/' . $_GET['conversation'] . "-" . $res->user->id . ".xml" : 'conversations/' . $res->user->id . "-" . $_GET['conversation'] . ".xml";
if (!Conversation::exists(array('conditions' => array('filename' => $filename)))) {
$attributes = array("user_id" => $res->user->id, "filename" => $filename);
$conversation = Conversation::create($attributes);
} else {
$conversation = Conversation::find_by_filename($filename);
}
if ($conversation == null) {
throw new Exception('can not init conversation', 504);
}
$xmlfile = VAR_PATH . $conversation->filename;
// <editor-fold defaultstate="collapsed" desc="creation d'un message">
if (isset($_GET['msg'])) {
$msg = $_GET['msg'];
$userChat = isset($_GET['userChat']) ? $_GET['userChat'] : "Invité";
//Load it using simpleXML
$doc = new DOMDocument();
$doc->load($xmlfile);
//Add a conversation item
$item = $doc->createElement("item", $msg);
//Add the sender's name as an attribute
$sender = $doc->createAttribute("sender");
$sender->appendChild($doc->createTextNode($userChat));
//Add another attribute for time on which the message was added
$time = $doc->createAttribute("time");
$time->appendChild($doc->createTextNode(date("H:i", time())));
//Put it together