本文整理汇总了PHP中yaml函数的典型用法代码示例。如果您正苦于以下问题:PHP yaml函数的具体用法?PHP yaml怎么用?PHP yaml使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了yaml函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
public function load($filepath = null)
{
if (!is_null($filepath)) {
$this->parse(yaml($filepath));
}
return $this->get();
}
示例2: ScConfig
function ScConfig(&$Sc, $variant = NULL)
{
/* Function: ScConfig()
* Constructor.
*/
$this->Sc = $Sc;
// Find config file
$config_file = $Sc->findConfigFile();
if ($config_file === FALSE) {
ScStatus::error('No config file found. You may generate one using `ss makeconfig`.');
return;
}
// Load config file and validate
$this->cwd = dirname($config_file);
$this->_config = yaml($config_file);
if (!is_array($this->_config)) {
ScStatus::error('Configuration file is invalid.');
return;
}
if (!is_null($variant)) {
$vfile = str_replace('.conf', ".{$variant}.conf", $config_file);
if (!is_file($vfile)) {
ScStatus::error("Configuration for variant '{$variant}' not found.");
return;
}
$arr = yaml($vfile);
if (!is_array($arr)) {
ScStatus::error("Configuration for variant '{$variant}' is invalid.");
return;
}
$this->_config = array_merge($this->_config, $arr);
}
}
示例3: __construct
public function __construct($session, $username)
{
//istantiate object properties
$this->session = $session;
$this->sessionTests = yaml($this->session->tests());
$this->resultsFolderPath = $this->getResultsFolderPath($this->session);
$this->username = $username;
}
示例4: values
public function values()
{
if (is_array($this->value())) {
return $this->value();
} else {
return yaml($this->value());
}
}
示例5: related
function related($field)
{
global $site;
// parse the field with yaml
$raw = yaml($field);
$related = array();
$pages = $site->pages();
foreach ($raw as $r) {
// make sure to only add found related pages
if ($rel = $pages->find($r)) {
$related[] = $rel;
}
}
return new relatedPages($related);
}
示例6: guestsCount
/**
* Get the number of registered guests
*
* @return int
*/
public function guestsCount()
{
$count = 0;
foreach ($this->children()->find('orders')->children() as $order) {
$guests = yaml($order->guests());
$count += count($guests);
}
return $count;
}
示例7: firewall
public static function firewall($params = array())
{
//default options
$defaults = array('ignore' => array(c::get('account.login.folder'), c::get('account.logout.folder')), 'redirect' => site()->find(c::get('account.login.folder'))->url(), 'allow' => array(), 'deny' => array());
//merge defaults options with custom options
$options = array_merge($defaults, $params);
//get active page
$page = site()->activePage();
//if this is a public accessible page (i.e., included in ignore array option)
if (in_array($page->uid(), $options['ignore'])) {
return true;
}
//get current user
$user = Auth::loggedUser();
//if no user is logged in
if (!$user) {
//go to redirection page
go(url($options['redirect']));
}
//set expected schema for firewall allow and deny array
$arraySchema = array('user' => '', 'role' => '');
//throw error if allow array doesn't conform to expected array schema
if (array_diff_key($options['allow'], $arraySchema)) {
throw new Exception('Firewall schema incorrect');
}
//throw error if deny array doesn't conform to expected array schema
if (array_diff_key($options['deny'], $arraySchema)) {
throw new Exception('Firewall schema incorrect');
}
//set default value of $passFirewall
$passFirewall = false;
//*** ALLOWED PAGES LOOP
foreach ($options['allow'] as $key => $value) {
//see if user's username is allowed
if ($allow = str::contains($value, $user->username())) {
break;
}
//see if user's group is allowed
$allow = str::contains($value, $user->role());
}
//*** DENIED PAGES LOOP
foreach ($options['deny'] as $key => $value) {
//see if user's username is denied
if ($deny = str::contains($value, $user->username())) {
break;
}
//see if user's group is denied
$deny = str::contains($value, $user->role());
}
//*** ALLOWED TESTS LOOP
//if we are in the tests folder
if ($page->parent()->uid() == c::get('tests.folder')) {
//get session tests
$allowedTests = yaml(site()->find(implode(DS, array(c::get('sessions.folder'), $user->session())))->tests());
//loop though session's tests
foreach ($allowedTests as $test) {
//if current test is included in session's tests list and user's session status points to it
if ($allowTest = str::lower($page->uid()) == str::lower($test['Test']) && str::lower($page->uid()) == str::lower($user->status())) {
break;
}
}
} else {
//set $allowTest to true since we are not in tests folder
//and hence the firewall acts only on ALLOW and DENY loops
$allowTest = true;
}
//re-determine $passFirewall
$passFirewall = $allow && !$deny && $allowTest;
//if $passFirewall evaluates to false
if (!$passFirewall) {
//go to homepage for logged users.
//Non logged users were redirected to the login page before
go(site()->language()->url());
}
//just in case
return true;
}
示例8: load
protected static function load($username)
{
$username = str::lower($username);
$dir = c::get('root.site') . '/accounts';
$file = $dir . '/' . $username . '.php';
if (!is_dir($dir) || !file_exists($file)) {
return false;
}
$content = file_get_contents($file);
$yaml = yaml($content);
// remove the php direct access protection line
unset($yaml[0]);
return new AuthUser($yaml);
}
示例9: date_default_timezone_set
<?php
date_default_timezone_set('Europe/Riga');
?>
<section id="schedule" class="section--lightgray js-section">
<div class="section--lightgray__head">
<h1 class="section--lightgray__title"><?php
echo $data->title();
?>
</h1>
</div>
<div class="section--lightgray__body">
<div class="wrapper">
<?php
$day1 = yaml($data->day2());
?>
<?php
if (!empty($day1)) {
?>
<table class="t schedule">
<caption class="schedule__caption"><?php
echo $data->day2_title();
?>
<div class="schedule__desc"><?php
echo $data->day2_desc();
?>
</div>
</caption>
<tbody class="t-body">
<?php
foreach ($day1 as $key => $line) {
示例10: yaml
?>
><?php
echo $menuItem['label'];
?>
</a>
<?php
}
?>
</div>
</div>
</nav>
<nav class="nav navDesktop bg-black u-padd-top-quarter u-padd-btm-quarter" role="navigation">
<div class="l-container">
<?php
$menuItems = yaml($site->menuItems());
?>
<?php
foreach ($menuItems as $menuItem) {
?>
<a class="nav_item text-red" href="<?php
echo $menuItem['hyperlink'];
?>
" <?php
if ($menuItem['target'] == '1') {
?>
target="_blank"<?php
}
?>
><?php
echo $menuItem['label'];
示例11: html
?>
<main class="main" role="main">
<div class="col-4-6 last">
<article class="text">
<h1><?php
echo html($page->title());
?>
</h1>
<h2>Available Translations</h2>
<dl>
<?php
$langs = a::sort(yaml($page->languages()), 'lang', 'asc');
?>
<?php
foreach ($langs as $lang) {
?>
<dt class="gamma"><a href="https://github.com/getkirby/panel/blob/master/app/languages/<?php
echo $lang['code'];
?>
.php"><?php
echo $lang['lang'];
?>
</a></dt>
<dd><span>Author: </span><?php
echo $lang['author'];
?>
</dd>
示例12: function
return function ($site, $pages, $page) {
//set variables
$tests = null;
$sessionName = null;
$totalTestingTime = null;
$completedTestingTime = null;
$numberOfTests = null;
$sessionComplete = null;
//get logged user (if any)
if ($user = Auth::loggedUser()) {
//set session name
$sessionName = $user->session();
//if user's session exists
if ($testSession = $pages->find(implode(DS, array(c::get('sessions.folder'), $sessionName)))) {
//get array of session's tests
$testsInSession = yaml($testSession->tests());
//count number of session'a tests
$numberOfTests = count($testsInSession);
//set default test button CSS classes
$testButtonCSSClasses = c::get('test.button.completed');
//set default test button label
$testButtonLabel = l('test.completed');
//get session's tests specifications
foreach ($testsInSession as $test) {
//if current test exists
if ($t = $page->children()->find($test['Test'])) {
//store current test's specifications into array
$testSpecs = $t->content()->toArray();
//update total testing time, by adding current test's time
$totalTestingTime += (int) $testSpecs['minutes'];
//if the currently looping test equals the test stored into user's status field
示例13: foreach
<?php
foreach (page('events')->children() as $event) {
?>
<?php
$is_header_displayed = false;
?>
<?php
foreach (yaml($page->marks()) as $mark_group) {
?>
<!--# loops through all marks -->
<?php
if ($mark_group['event'] == $event->title()->html()) {
?>
<!--# checks to see if the category matches -->
<?php
if ($is_header_displayed == false) {
?>
<!--# displays event header -->
<span><?php
echo $event->title()->html();
?>
</span>
<?php
}
?>
<?php
foreach ($mark_group as $item) {
?>
<!--# shows mark, date and location -->
<?php
示例14: isset
<!-- Organism: Form Builder -->
<?php
$data = isset($content) ? $content : $page;
/* Zusätzliche Textspalten */
$additional_columns = yaml($data->columns());
$additional_columns = reset($additional_columns);
/* Layoutklassen */
$layout_classes = array();
$layout_classes["bildblock"] = "col-lg-8 col-sm-8 bild";
$layout_classes["textblock"] = "col-lg-4 col-sm-4 text";
/* Layout switcher */
$layout_data = "";
/* Layoutklassen */
$behavior_classes = "";
?>
<div class="clearfix"></div>
<div class='col-sm-12'>
<span class='js-form-status'></span>
</div>
<form class="text form-horizontal contactform js-form" method="POST" action="<?php
echo c::get('settings')['ajax-form-url'];
?>
" name="<?php
echo $data->title();
?>
" enctype="multipart/form-data" novalidate>
示例15: yaml
<span class="schedule__action"><?php
echo $line["title"];
?>
</span><?php
}
?>
</td>
</tr><?php
}
?>
</tbody>
</table><?php
}
?>
<?php
$day2 = yaml($data->day2());
?>
<?php
if (!empty($day2)) {
?>
<table class="t schedule">
<caption class="schedule__caption"><?php
echo $data->day2_title();
?>
<div class="schedule__desc"><?php
echo $data->day2_desc();
?>
</div>
</caption>
<tbody class="t-body"><?php
foreach ($day2 as $line) {