本文整理汇总了PHP中Comments::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Comments::add方法的具体用法?PHP Comments::add怎么用?PHP Comments::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comments
的用法示例。
在下文中一共展示了Comments::add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: article
public function article($slug = '')
{
// find article
$params = array('slug' => $slug);
// allow admin to view unpublished posts
if (Users::authed() === false) {
$params['status'] = 'published';
}
if (($article = Posts::find($params)) === false) {
return Response::error(404);
}
// add comment
if (Input::method() == 'POST') {
if (Comments::add($article->id)) {
$page = IoC::resolve('posts_page');
return Response::redirect($page->slug . '/' . $article->slug);
}
}
// register single item for templating functions
IoC::instance('article', $article, true);
Template::render('article');
}
示例2: httpResponse
httpResponse(array("seeders" => $seeders, "leechers" => $leechers));
break;
case validateRoute('GET', 'torrents/\\d+/snatchlog'):
$torrent = new Torrent($db, $user);
httpResponse($torrent->getSnatchLog((int) $params[1]));
break;
case validateRoute('GET', 'torrents/\\d+/comments'):
$torrent = new Torrent($db, $user);
$comments = new Comments($db, $user, $torrent);
list($result, $totalCount) = $comments->query((int) $params[1], (int) $_GET["limit"] ?: 10, (int) $_GET["index"] ?: 0);
httpResponse($result, $totalCount);
break;
case validateRoute('POST', 'torrents/\\d+/comments'):
$torrent = new Torrent($db);
$comments = new Comments($db, $user, $torrent);
$comments->add((int) $params[1], $postdata["data"]);
httpResponse($result, $totalCount);
break;
case validateRoute('PATCH', 'torrents/\\d+/comments/\\d+'):
$comments = new Comments($db, $user);
$comments->update((int) $params[1], (int) $params[3], $postdata["postData"]);
httpResponse($result, $totalCount);
break;
case validateRoute('DELETE', 'torrents/\\d+/comments/\\d+'):
$torrent = new Torrent($db, $user);
$comments = new Comments($db, $user, $torrent);
$comments->delete((int) $params[3]);
httpResponse();
break;
case validateRoute('GET', 'torrents/toplists'):
$cacheId = 'toplists-' . $_GET["limit"];
示例3: init
/**
* Retrieves info for the current user account
*
* @author Thibaud Rohmer
*/
public static function init()
{
CurrentUser::$accounts_file = Settings::$conf_dir . "/accounts.xml";
CurrentUser::$groups_file = Settings::$conf_dir . "/groups.xml";
/// Set path
if (isset($_GET['f'])) {
CurrentUser::$path = stripslashes(File::r2a($_GET['f']));
if (isset($_GET['p'])) {
switch ($_GET['p']) {
case 'n':
CurrentUser::$path = File::next(CurrentUser::$path);
break;
case 'p':
CurrentUser::$path = File::prev(CurrentUser::$path);
break;
}
}
} else {
/// Path not defined in URL
CurrentUser::$path = Settings::$photos_dir;
}
/// Set CurrentUser account
if (isset($_SESSION['login'])) {
self::$account = new Account($_SESSION['login']);
// groups sometimes can be null
$groups = self::$account->groups === NULL ? array() : self::$account->groups;
self::$admin = in_array("root", $groups);
self::$uploader = in_array("uploaders", $groups);
}
/// Set action (needed for page layout)
if (isset($_GET['t'])) {
switch ($_GET['t']) {
case "Page":
case "Img":
case "Thb":
CurrentUser::$action = $_GET['t'];
break;
case "Big":
case "BDl":
case "Zip":
if (!Settings::$nodownload) {
CurrentUser::$action = $_GET['t'];
}
break;
case "Reg":
if (isset($_POST['login']) && isset($_POST['password'])) {
if (!Account::create($_POST['login'], $_POST['password'], $_POST['verif'])) {
echo "Error creating account.";
}
}
case "Log":
if (isset($_SESSION['login'])) {
CurrentUser::logout();
echo "logged out";
break;
}
if (isset($_POST['login']) && isset($_POST['password'])) {
try {
if (!CurrentUser::login($_POST['login'], $_POST['password'])) {
echo "Wrong password";
}
} catch (Exception $e) {
echo "Account not found";
}
}
if (!isset(CurrentUser::$account)) {
CurrentUser::$action = $_GET['t'];
}
break;
case "Acc":
if (isset($_POST['old_password'])) {
Account::edit($_POST['login'], $_POST['old_password'], $_POST['password'], $_POST['name'], $_POST['email']);
}
CurrentUser::$action = "Acc";
break;
case "Adm":
if (CurrentUser::$admin) {
CurrentUser::$action = "Adm";
}
break;
case "Com":
Comments::add(CurrentUser::$path, $_POST['content'], $_POST['login']);
break;
case "Rig":
Judge::edit(CurrentUser::$path, $_POST['users'], $_POST['groups'], true);
CurrentUser::$action = "Judge";
break;
case "Pub":
Judge::edit(CurrentUser::$path);
CurrentUser::$action = "Judge";
break;
case "Pri":
Judge::edit(CurrentUser::$path, array(), array(), true);
CurrentUser::$action = "Judge";
break;
//.........这里部分代码省略.........
示例4: switch
$msg = 'You can\'t just leave your comment empty, nobody can read it.';
return;
}
if (strlen($content) <= 3) {
$msg = 'Your comment should ideally be over 4 characters long...';
return;
}
/* is this hack... shit? */
if (empty($table)) {
$msg = 'You need to include the table';
return;
}
switch ($table) {
case 1:
$table = tbl_blog;
break;
case 2:
$table = tbl_goals;
break;
}
event::register('COMMENT_POST', function ($args = array()) {
/*
We want to give a badge to every user who posts heaps...
*/
});
$add = $comments->add($userid, $pageid, $table, $content);
if (!empty($add)) {
event::fire('COMMENT_POST');
$msg = 'Thank you for adding your comment ' . $_SESSION['username'];
}
}
示例5: Comments
<?php
require_once "bd.php";
//Include connect to bd
require_once 'classes/base.php';
//Include main classes
//If comment submit
if (isset($_POST['userSubmit'])) {
//echo $_POST['userEmail'] . '|' . $_POST['userComment'];
$commentObject = new Comments();
//Create main object
//Get user comment info
$email = iconv('UTF-8', 'windows-1251', $_POST['userEmail']);
$comment = iconv('UTF-8', 'windows-1251', $_POST['userComment']);
$id = $_POST['commentId'];
//If user comment is not empty
if ($email == '' || $comment == '') {
echo 'False';
} else {
if ($commentObject->add($email, $comment, $id)) {
echo 'True';
} else {
echo 'False';
}
}
}
示例6: addComment
function addComment($message, $idpincho)
{
session_start();
$p = new Pincho();
$pinfo = $p->getbyCode($idpincho);
$idestablishment = $pinfo[0]["Establishment_idEstablishment"];
$pop = new Popular();
$popinfo = $pop->select($_SESSION["name"]);
$idpopular = $popinfo[0]["idPopular"];
$c = new Comments();
$boolean = $c->add($message, $idpincho, $idestablishment, $idpopular);
if ($boolean == false) {
echo "Database error";
} else {
viewComments($idpincho);
}
}