本文整理汇总了PHP中cockpit函数的典型用法代码示例。如果您正苦于以下问题:PHP cockpit函数的具体用法?PHP cockpit怎么用?PHP cockpit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cockpit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processPosts
public static function processPosts($posts)
{
$urls = "";
$keys = [];
foreach ($posts as $i => $post) {
if (array_key_exists('share', $post) && $post['share'] !== null && $post['share'] !== "") {
$urls .= $post['share'] . ",";
array_push($keys, $i);
} else {
$ct = cockpit("cockpit")->markdown($post['Content']);
$posts[$i]['Content'] = explode('</p>', $ct)[0];
}
}
$urls = trim($urls, ",");
if (strlen($urls) > 4) {
$shares = json_decode(file_get_contents("http://api.embed.ly/1/extract?key=" . EMBEDLY_CONFIG . "&urls=" . $urls), true);
foreach ($shares as $i => $share) {
$posts[$keys[$i]]['embed'] = $shares[$i];
}
}
usort($posts, function ($a, $b) {
return $b['created'] - $a['created'];
});
return $posts;
}
示例2: saveconfig
public function saveconfig()
{
$return = ["message" => 'Saving settings failed', "status" => 'danger'];
$settings = $this->param("settings", false);
if (cockpit("printdesigner")->saveConfig($settings)) {
$return = ["message" => 'Settings saved', "status" => 'success'];
}
return json_encode($return);
}
示例3: getErrorPage
public function getErrorPage($pageName)
{
$errorPage = cockpit('collections')->collection('Error Pages')->findOne(["name" => $pageName]);
if (!sizeof($errorPage)) {
throw new Exception("Unable to load {$pageName}.");
}
try {
$errorPageTemplate = new Templates($this->cabin);
$errorPageTemplate->renderPage($errorPage, get_markdown($errorPage["content"]));
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
}
示例4: thumbnail
function thumbnail($image, $width = null, $height = null, $options = array())
{
if ($width && is_array($height)) {
$options = $height;
$height = $width;
} else {
$height = $height ?: $width;
}
$url = cockpit("mediamanager")->thumbnail($image, $width, $height, $options);
// generate attributes list
$attributes = \Lime\fetch_from_array($options, 'attrs', []);
if (is_array($attributes)) {
$tmp = [];
$attributes = array_merge(['alt' => $image], $attributes);
foreach ($attributes as $key => $val) {
$tmp[] = $key . '="' . $val . '"';
}
$attributes = implode(' ', $tmp);
}
echo '<img src="' . $url . '" ' . $attributes . '>';
}
示例5: cockpit
<?php
$options = ["rebuild" => false, "cachefolder" => "cache:thumbs", "quality" => 100, "base64" => false, "mode" => "best_fit"];
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link href='http://fonts.googleapis.com/css?family=Inconsolata:400,700' rel='stylesheet' type='text/css'>
<?php
cockpit("cockpit")->assets(["js/jquery-2.1.1.js", "js/imagesloaded.pkgd.min.js", "js/packery.pkgd.min.js", "js/intense.min.js", "js/spin.min.js", "js/script.js", "css/reset.css", "css/style.css"], 'style');
?>
</head>
<body>
<?php
region('header');
?>
<div class="content">
<div class="content-wrapper grid">
<?php
foreach (gallery('home') as $image) {
?>
<?php
$thumburl = thumbnail_url($image["path"], 1280, $options);
?>
<div class="item">
示例6: region_field
function region_field($region, $field, $key = null, $default = null)
{
return cockpit('regions')->region_field($region, $field, $key, $default);
}
示例7: getSessionToken
function getSessionToken()
{
return cockpit("printdesigner")->getSessionToken();
}
示例8: function
$app->get('/blog/page/{page}/', $blog);
$app->get('/blog/{postslug}/', function ($postslug) use($app) {
$data = collection("posts")->findOne(["Title_slug" => $postslug]);
if ($data === null) {
$app->abort(404, "Post '{$postslug}' does not exist.");
}
return $app['twig']->render('post.twig', array('data' => $data));
});
$app->get('/portfolio/', function () use($app) {
$data = gallery("Portfolio");
d($data);
return $app['twig']->render('gallery.twig', array('data' => $data));
});
$app->get('/cv/', function () use($app) {
$content = Cms::curlGet(CV_URL . ".md");
$content = cockpit("cockpit")->markdown($content);
$content = Cms::cleanHtml($content);
$data = ["Title" => "Curriculum Vitae", "Subtitle" => "Lorem ipsum", "content" => "<section class='cv'>" . $content . "</section>"];
d($data);
return $app['twig']->render('page.twig', array('data' => $data));
});
$app->get('/{pageslug}/', function ($pageslug) use($app) {
$data = collection("Pages")->findOne(["Title" => $pageslug]);
if ($data === null) {
$data = collection("Pages")->findOne(["Title_slug" => $pageslug]);
}
if ($data === null) {
$app->abort(404, "Page '{$pageslug}' does not exist.");
}
return $app['twig']->render('page.twig', array('data' => $data));
});
示例9: PDO
$sqlitesupport = false;
// check whether sqlite is supported
try {
if (extension_loaded('pdo')) {
$test = new PDO('sqlite::memory:');
$sqlitesupport = true;
}
} catch (Exception $e) {
}
// misc checks
$checks = array("Php version >= 5.4.0" => version_compare(PHP_VERSION, '5.4.0') >= 0, "PDO extension loaded with Sqlite support" => $sqlitesupport, 'Data folder is writable: /storage/data' => is_writable(__DIR__ . '/../storage/data'), 'Cache folder is writable: /storage/cache' => is_writable(__DIR__ . '/../storage/cache'), 'Cache folder is writable: /storage/cache/assets' => is_writable(__DIR__ . '/../storage/cache/assets'), 'Cache folder is writable: /storage/cache/thumbs' => is_writable(__DIR__ . '/../storage/cache/thumbs'));
foreach ($checks as $info => $check) {
if (!$check) {
include __DIR__ . "/fail.php";
exit;
}
}
require __DIR__ . '/../bootstrap.php';
$app = cockpit();
// check whether cockpit is already installed
try {
if ($app->db->getCollection("cockpit/accounts")->count()) {
header('Location: ' . $app->baseUrl('/'));
exit;
}
} catch (Exception $e) {
}
$account = ["user" => "admin", "name" => "", "email" => "test@test.de", "active" => 1, "group" => "admin", "password" => $app->hash("admin"), "i18n" => "en"];
$app->db->insert("cockpit/accounts", $account);
include __DIR__ . "/success.php";
示例10: unserialize
require_once __DIR__ . '/config.php';
require_once __DIR__ . '/functions.php';
$app = new Silex\Application();
$app['debug'] = true;
$app->register(new Silex\Provider\TwigServiceProvider(), unserialize(TWIG_CONFIG));
$app['twig'] = $app->share($app->extend('twig', function (Twig_Environment $twig, Silex\Application $app) {
$twig->addGlobal('globals', unserialize(TWIG_GLOBALS));
$filter = new Twig_SimpleFilter('form', function ($string) {
return form($string);
});
$twig->addFilter($filter);
$click = new Twig_SimpleFilter('clickable', function ($string) {
return Twitter::clickable($string);
});
$twig->addFilter($click);
$markdown = new Twig_SimpleFilter('md', function ($string) {
return cockpit("cockpit")->markdown($string);
});
$twig->addFilter($markdown);
$thumb = new Twig_SimpleFilter('thumb', function ($string) {
return cockpit("mediamanager")->thumbnail($string, "300", "100");
});
$twig->addFilter($thumb);
$crop = new Twig_SimpleFilter('crop', function ($string, $size) {
$par = explode(",", $size);
return cockpit("mediamanager")->thumbnail($string, $par[0], $par[1]);
});
$twig->addFilter($crop);
return $twig;
}));
return $app;
示例11: cockpit
echo '
{"status":false,"message":"Provide organization _id!"}
';
}
}
// Get Organization
if ($_POST["organization"]) {
if (@$_POST["_id"]) {
$organization = cockpit('collections:findOne', 'organizations', ['_id' => $_POST["_id"]]);
echo json_encode($organization);
} else {
echo '
{"status":false,"message":"Provide organization _id!"}
';
}
}
// Donate
if ($_POST["Action"] == "Donate") {
if (@$_POST["need_id"]) {
$need = cockpit('collections:findOne', 'needs', ['_id' => $_POST["need_id"]]);
$Donation = ["donator" => $_POST["donator_id"], "need" => $_POST["need_id"], "message" => $_POST["message"]];
cockpit('collections:save_entry', 'donations', $Donation);
echo '
{"status":true,"message":"Thank you for your donation!"}
';
} else {
echo '
{"status":false,"message":"Provide donator_id and need_id!"}
';
}
}
示例12: generate
function generate()
{
return cockpit('robots')->generate();
}
示例13: collection_populate_one
function collection_populate_one($collection, $item)
{
return cockpit('collections')->populateOne($collection, $item);
}
示例14: collection
<?php
$options = ["rebuild" => false, "cachefolder" => "cache:thumbs", "quality" => 100, "base64" => false, "mode" => "best_fit"];
$items = collection('posts')->find()->toArray();
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link href='http://fonts.googleapis.com/css?family=Inconsolata:400,700' rel='stylesheet' type='text/css'>
<?php
cockpit("cockpit")->assets(["css/reset.css", "css/style.css", "css/about.css"], 'style-about');
?>
</head>
<body>
<?php
region('header');
?>
<div class="content">
<div class="content-wrapper about">
<?php
thumbnail($items[0]["media"], 350, $options);
?>
<h2><?php
echo $items[0]['title'];
?>
</h2>
<?php
示例15: gallery
function gallery($name)
{
return cockpit("galleries")->gallery($name);
}