function burntDisplayAsyncImage($imageURL, $options, $preload = false) { $classNames = array(); if (!empty($options['class'])) { $classNames[] = $options['class']; } if ($preload) { $classNames[] = 'loaded'; } else { $classNames[] = 'needsLoading'; } /* glazyElement(array( 'tagName' =>'img', 'src' => $preload ? $imageURL : TIDAL_BASE_CORE_IMAGES_URL. 'empty.png', 'width:check' => &$options['width'], 'height:check' => $options['height'], 'alt:check' => $options['alt'] )); */ ?> <img<?php glazyAttribute('src', $preload ? $imageURL : PVLP_BASE_CORE_IMAGES_URL . 'empty.png'); glazyAttributeCheck('width', $options['width']); glazyAttributeCheck('height', $options['height']); glazyAttributeCheck('alt', $options['alt']); if (!$preload) { glazyAttribute('data-original', $imageURL, GLAZE_TYPE_URL); } glazyAttribute('class', $classNames); ?> ><?php }
function glazyAttributesArray($attributes) { if (empty($attributes)) { return; } foreach ($attributes as $attributeName => $attributeValue) { glazyAttributeCheck($attributeName, $attributeValue); } }
// Build a list of classes using an array, don't fuss with appending to a string $classNamesArray = array('item', 'book'); $classNamesArray[] = !empty($info['published']) ? 'published' : 'upcoming'; $classNamesArray[] = 'genre-' . $info['genreIdentifier']; // e.g. 'genre-thriller' // Begin the <div> $bookItemDiv = glazyBegin('div'); glazyAttribute('id', "bookItem-{$info['itemID']}"); // Lets you use an array of strings for class attributes. glazyAttribute('class', $classNamesArray); // Only display the attribute if variable reference $info['salesCount'] is present. glazyAttributeCheck('data-sales-count', $info['salesCount']); glazyAttributeCheck('data-sales-count', $info['salesCount_NOPE']); // Only displays the attribute, with the value 'selected', if $info['selected'] is true. glazyAttributeCheck('selected', $info['selected'], 'selected'); glazyAttributeCheck('selected-nope', $info['selected_NOPE'], 'selected'); glazyElement('h5.authorName', glazyCheckContent($info['authorName'])); glazyElement('p.description', glazyPrepareContentJoinedByLineBreaks(glazyCheckContent($info['itemDescription']))); glazyElement('p.description', glazyPrepareContentJoinedByLineBreaks(glazyCheckContent($info['itemDescription_NOPE']))); // Finish and close the </div> glazyFinish($bookItemDiv); glazyElement('h2', 'These are already escaped & < >', GLAZE_TYPE_PREGLAZED); $img = glazyBegin('img'); glazyAttribute('src', 'http://placehold.it/150x50'); $escapedText = 'Bangers & Mash'; glazyAttribute('alt', $escapedText, GLAZE_TYPE_PREGLAZED); glazyFinish($img); glazyElement('hr'); glazyElement('p', array('Updating this file by using: ', glazyPrepareElement('br'), glazyPrepareElement('code', 'php -f example-update.php'))); glazyElement('p', array('Check this file with the last version by using: ', glazyPrepareElement('br'), glazyPrepareElement('code', 'php -f example-check.php'))); glazyElement('p', array('You can download glaze.php from here: ', glazyPrepareElement(array('tagName' => 'a', 'href' => 'http://github.com/BurntCaramel/glaze'), 'github.com/BurntCaramel/glaze')));
function perforatedFormDisplayEntry($entryID, $entryDetails, $options, $callbacks) { $baseID = $options['baseID']; $problemIDsToMessages = $options['problemIDsToMessages']; $entryTitle = $entryDetails['title']; $entryType = $entryDetails['type']; $entryValue = !empty($entryDetails['value']) ? $entryDetails['value'] : ''; $entryInputName = "{$baseID}[{$entryID}]"; $entryTextTag = !empty($options['textTagName']) ? $options['textTagName'] : 'h5'; $entryIsRequired = !empty($entryDetails['required']); $glazyLabel = glazyBegin(array('tagName' => 'label', 'id' => $entryID, 'class' => $entryType, 'data-entry-i-d' => $entryID)); $textElement = glazyBegin(array('tagName' => $entryTextTag)); glazyElement('span.title', $entryTitle); if (isset($options['problems'][$entryID])) { foreach ($options['problems'][$entryID] as $problemID => $problemValue) { if (isset($problemIDsToMessages['types'][$entryType][$problemID])) { $problemMessage = $problemIDsToMessages['types'][$entryType][$problemID]; } else { $problemMessage = $problemIDsToMessages['base'][$problemID]; } glazyElement('span.problem', $problemMessage); } } glazyFinish($textElement); if (empty($callbacks['inputElementTypeForEntryType'])) { throw new Exception('Perforated: A input element type for entry type callback *must* be set: $callbacks["inputElementTypeForEntryType"] is empty.'); } else { $inputElementTypeForEntryTypeCallback = $callbacks['inputElementTypeForEntryType']; } $inputType = call_user_func($inputElementTypeForEntryTypeCallback, $entryType); if ($inputType === 'text' && empty($entryDetails['multipleLines']) || $inputType === 'email' || $inputType === 'url' || $inputType === 'number' || $inputType === 'checkbox') { $input = glazyBegin('input'); glazyAttribute('type', $inputType); glazyAttribute('name', $entryInputName); glazyAttributeCheck('required', $entryIsRequired); if ($inputType === 'checkbox') { glazyAttributeCheck('checked', $entryDetails['value'], 'checked'); glazyAttribute('data-on-title', $entryDetails['titleWhenOn']); glazyAttribute('data-off-title', $entryDetails['titleWhenOff']); } else { glazyAttribute('value', $entryValue); } if ($entryType === 'integer') { glazyAttribute('step', '1'); } glazyFinish($input); } elseif ($inputType === 'text' && !empty($entryDetails['multipleLines'])) { glazyElement(array('tagName' => 'textarea', 'name' => $entryInputName, 'required' => !empty($entryDetails['required']), 'cols' => 40, 'rows' => 4), $entryValue); } glazyFinish($glazyLabel); }