本文整理汇总了PHP中SC::jsonify方法的典型用法代码示例。如果您正苦于以下问题:PHP SC::jsonify方法的具体用法?PHP SC::jsonify怎么用?PHP SC::jsonify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SC
的用法示例。
在下文中一共展示了SC::jsonify方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: jsonify
public function jsonify($callback = null)
{
$fields = array("from", "author", "subject", "body", "to", "bcc", "header");
$props = array();
foreach ($fields as $id => $field) {
$props[$field] = $this->{$field};
}
return SC::jsonify($props, $callback);
}
示例2: handleResponse
public function handleResponse($resp, $methodname)
{
$content_type = $this->getResponseContentType();
switch ($content_type) {
case "html":
$partial = $this->{$methodname}(array("__partial" => true));
if ($partial) {
$partial_name = $partial["partial"];
if (isset($partial["val"])) {
$resp = array($partial["val"] => $resp);
}
return SCPartial::renderToString($partial_name, $resp);
}
throw new APIException("There is no html associated with this.", 400);
break;
case "json":
return SC::jsonify(SC::toArrayAll($resp));
break;
}
}
示例3: show
public function show()
{
SC::loginRequired();
$api = new SCApi();
$vars = $api->boards_show();
// $board & $view_counts
switch ($_GET["__content_type"]) {
case "json":
if ($_GET["since"]) {
$output = array("content" => SCPartial::renderToString("board/board_threads", $vars));
} else {
$output = array("threads" => $vars["board"]->threads());
}
echo SC::jsonify($output);
break;
case "html":
default:
$cs = array("title" => htmlspecialchars($vars["board"]->boardname), "util_links" => SCPartial::renderToString("board/util_links", $vars), "content" => SCPartial::renderToString("board/board", $vars));
SCLayout::render("main", $vars, $cs);
}
}
示例4: create
public function create()
{
SC::loginRequired();
global $current_user;
switch ($_GET["__content_type"]) {
case "json":
$api = new SCApi();
$thread = $api->boards_threads_create();
$output = array("transfer" => SCRoutes::set("threads", "show", array("boardid" => $thread->boardid, "threadid" => $thread->messageid)));
echo SC::jsonify($output);
break;
case "html":
default:
try {
$api = new SCApi();
$thread = $api->boards_threads_create();
SC::transfer(SCRoutes::set("threads", "show", array("boardid" => $thread->boardid, "threadid" => $thread->messageid)));
} catch (Exception $ex) {
SC::setFlashMessage($ex->getMessage(), "error");
$this->_new();
}
}
}
示例5: jsonify
public function jsonify($callback = false)
{
$props = $this->toArray();
return SC::jsonify($props, $callback);
}