public function load($filepath = null) { if (!is_null($filepath)) { $this->parse(yaml($filepath)); } return $this->get(); }
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); } }
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; }
public function values() { if (is_array($this->value())) { return $this->value(); } else { return yaml($this->value()); } }
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); }
/** * 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; }
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; }
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); }
<?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) {
?> ><?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'];
?> <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>
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
<?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
<!-- 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>
<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) {
/** * Splits the field value by the given separator * @param Field $field The calling Kirby Field instance * @param string $separator The string to split the field value by * @return array */ field::$methods['split'] = function ($field, $separator = ',') { return str::split($field->value, $separator); }; /** * Parses the field value as yaml and returns an array * @param Field $field The calling Kirby Field instance * @return array */ field::$methods['yaml'] = function ($field) { return yaml($field->value); }; /** * Checks if the field value is empty * @param Field $field The calling Kirby Field instance * @return boolean */ field::$methods['empty'] = field::$methods['isEmpty'] = function ($field) { return empty($field->value); }; /** * Checks if the field value is not empty * @param Field $field The calling Kirby Field instance * @return boolean */ field::$methods['isNotEmpty'] = function ($field) {
/** * Generate field content markup * * @since 1.0.0 * * @return string */ public function content() { /* Zusätzliche Textspalten */ $additional_columns = yaml($this->page()->columns()); $additional_columns = reset($additional_columns); /* Bildbeschnitt, falls vorhanden */ $image_crop = $this->page()->image_crop() != "" ? $this->page()->image_crop() : ""; $wrapper = new Brick('div'); $wrapper->addClass('layoutswitcher'); $wrapper->data(array('field' => 'layoutswitcher', 'name' => $this->name(), 'page' => $this->page())); $wrapper->html(tpl::load(__DIR__ . DS . 'template.php', array('field' => $this, 'text1' => $this->page()->text(), 'text2' => $additional_columns["text2"], 'text3' => $additional_columns["text3"], 'noc' => intval($additional_columns["noc"]), 'crop' => $image_crop, 'page_tpl' => $this->page()->intendedTemplate()))); return $wrapper; }
echo $service['service']; ?> </h6> <p><?php echo $service['description']; ?> </p> <?php } ?> </div> <!-- RIGHT COLUMN --> <div class="page-content__copy"> <?php $servicesRight = yaml($page->contentright()); ?> <?php foreach ($servicesRight as $service) { ?> <h6><i class="fa fa-asterisk"></i><?php echo $service['service']; ?> </h6> <p><?php echo $service['description']; ?> </p> <?php } ?>
snippet('info'); ?> </div> </section> <section class="team scroll-section" id="team"> <div class="full anim"> <h2>Team</h2> </div> <div class="full"> <?php $team = yaml($page->team()); ?> <?php foreach ($team as $person) { ?> <div class="third anim"> <div class="info"> <p><?php echo $person["name"]; ?> <br/> <?php echo $person["role"]; ?> </p>
public function getTax() { // Get all tax categories as an array $taxCategories = yaml(page('shop')->tax()); $taxes = array(); // Calculate total amount of taxable items $taxableAmount = 0; foreach ($this->items as $item) { $taxableAmount += $item->notax === 1 ? 0 : $item->amount * $item->quantity; } foreach ($taxCategories as $taxCategory) { if ($this->appliesToCountry($taxCategory)) { $taxes[] = $taxCategory['rate'] * $taxableAmount; } } if (count($taxes) > 0) { return max($taxes); } return 0; }
$data = $site->find($mypageid); } $containers = isset($use_containers) ? $use_containers : $data->children()->visible(); $container_count = 0; foreach ($containers as $container) { $next = $container->nextVisible(); $container_count++; // Wo kommt der Content her? if (preg_match("=^_shared=", $container->uri())) { c::set("lang_layouts", "de"); } else { c::remove("lang_layouts"); } // Layout Angaben $def_lang = c::get("lang_layouts") ? c::get("lang_layouts") : $site->defaultLanguage()->code(); $layout_data = yaml($data->content($def_lang)->layout_switcher()); $headline_position = $container->content($def_lang)->headline_position(); if (isset($show_ruler)) { $trennlinie = "show"; $next = $containers->count() == $container_count ? false : true; } else { $trennlinie = $data->content($def_lang)->trennlinie(); } $classes = get_additional_classes($container, $site); $behavior_classes = $classes["behavior_classes"]; $hide_in_lang = preg_match("=(1|true|TRUE)=", $container->hide_in_lang()) ? true : false; if ($hide_in_lang) { continue; } $classes["padding"] = ""; if ($data->content($def_lang)->padding_at_top() == "1" && $container_count == 1) {
<?php return function ($site, $pages, $page) { $faqs = yaml($page->faqs()); return compact('faqs'); };
public function getTax() { // Reset the cart tax $cartTax = 0; // Get shop-wide tax categories $taxCategories = yaml(page('shop')->tax()); // Calculate tax for each cart item foreach ($this->items as $item) { // Skip if product is exempt from tax if ($item->notax == 1) { continue; } // Initialize applicable taxes array. Start with 0 so we can use max() later on. $applicableTaxes = [0]; // Get taxable amount $taxableAmount = $item->sale_amount ? $item->sale_amount * $item->quantity : $item->amount * $item->quantity; // Check for product-specific tax rules $productTax = page($item->uri)->tax(); if ($productTax->exists() and !$productTax->isEmpty()) { $itemTaxCategories = yaml($productTax); } else { $itemTaxCategories = $taxCategories; } // Add applicable tax to the taxes array foreach ($itemTaxCategories as $i => $taxCategory) { if ($this->appliesToCountry($taxCategory)) { $applicableTaxes[] = $taxCategory['rate'] * $taxableAmount; } } // Add highest applicable tax to the cart tax $cartTax += max($applicableTaxes); } // Return the total Cart tax return $cartTax; }
<?php // $data = isset($content) ? $content : $page; /* Zusätzliche Textspalten */ $additional_columns = array(); if ($data->columns()->exists() && $data->columns()->toStructure()->count() > 0) { $additional_columns["text2"] = $data->columns()->toStructure()->first()->text2(); $additional_columns["text3"] = $data->columns()->toStructure()->first()->text3(); } /* Layoutklassen */ $layout_classes = array(); $layout_classes["bildblock"] = "col-lg-8 col-sm-8 col-xs-12 bild"; $layout_classes["textblock"] = "col-lg-4 col-sm-4 col-xs-12 text"; /* Layout switcher */ $def_lang = c::get("lang_layouts") ? c::get("lang_layouts") : $site->defaultLanguage()->code(); $layout_data_obj = set_up_layout_data(yaml($data->content($def_lang)->layout_switcher())); $layout_data = $layout_data_obj["layout_data"]; $layout_classes = array_merge($layout_classes, $layout_data_obj["layout_classes"]); $layout_classes = get_layout_classes_v2($layout_data, $layout_classes); if (!isset($behavior_classes)) { $behavior_classes = ""; } if (!isset($heading)) { $heading = ""; } if (!isset($bilder)) { $bilder = ""; } // Wurde eine Position mitgegeben? Sonst nehmen wir die aus dem Dokument $headline_position = isset($headline_position) ? $headline_position : $data->headline_position(); // Wurden Texte für die SLideshow übergeben?
</a></li> <?php } ?> </ul> <?php } ?> <?php if ($page->externals() != '') { ?> <h3 class="gamma">External resources</h3> <ul> <?php $externals = yaml($page->externals()); ?> <?php foreach ($externals as $external) { ?> <li><a href="<?php echo $external['link']; ?> "><?php echo $external['text']; ?> </a></li> <?php } ?> </ul>