function loadMain() { $main = \shgysk8zer0\DOM\HTML::getInstance()->createElement('main'); $extensions = array('PDO', 'dom', 'fileinfo', 'SPL', 'session', 'Reflection', 'SimpleXML', 'json', 'mcrypt', 'mysql', 'mysqli', 'pdo_mysql'); $extensions = array_filter($extensions, '\\' . __NAMESPACE__ . '\\extension_not_loaded'); listExtenions($extensions, $main); return $main; }
function loadReadme() { $readme = \shgysk8zer0\DOM\HTML::getInstance()->createElement('dialog'); $readme->id = 'README-dailog'; $readme->append('button', null, ['type' => 'button', 'data-delete' => "#{$readme->id}"]); $readme->append('button', null, ['type' => 'button', 'data-fullscreen' => "#{$readme->id}"]); $readme->append('br'); $readme->importHTML(get_readme()); return $readme; }
function init() { $headers = Core\Headers::getInstance(); $dom = DOM\HTML::getInstance(); if (in_array('text/html', explode(',', $headers->accept))) { build_head($dom->head); build_body($dom->body); return $dom; } elseif ($headers->accept === 'application/json' and !empty($_REQUEST)) { require_once './components/handlers/request.php'; return \Components\Handlers\Request\handle($_REQUEST); } else { http_response_code(API\Abstracts\HTTPStatusCodes::BAD_REQUEST); } }
function loadDialog() { $size = ['height' => 60, 'width' => 60]; $package = json_decode(file_get_contents('package.json')); $dialog = \shgysk8zer0\DOM\HTML::getInstance()->createElement('dialog'); $dialog->id = 'contact-dialog'; $dialog->append('button', null, ['type' => 'button', 'data-close' => "#{$dialog->id}"]); $dialog->append('br'); $dialog->append('a', null, ['href' => "mailto:{$package->author->email}?Subject={$package->name}", 'title' => 'Email'])->import(SVG::useIcon('mail-read', $size), true); $dialog->append('a', null, ['href' => 'tel:+17603793667', 'title' => 'Call'])->import(SVG::useIcon('device-mobile', $size)); $dialog->append('a', null, ['href' => 'https://gitter.im/KVSun/ad-insertion', 'target' => '_blank', 'title' => 'Chat on Gitter'])->import(SVG::useIcon('comment', $size), true); $dialog->append('a', null, ['href' => str_replace('.git', null, $package->repository->url), 'target' => '_blank', 'title' => 'GitHub'])->import(SVG::useIcon('mark-github', $size), true); $dialog->append('a', null, ['href' => $package->bugs->url, 'target' => '_blank', 'title' => 'Open Issue'])->import(SVG::useIcon('issue-opened', $size), true); return $dialog; }
function loadHead() { $dom = \shgysk8zer0\DOM\HTML::getInstance(); $url = \shgysk8zer0\Core\URL::getInstance(); unset($url->path, $url->query, $url->fragment, $url->user, $url->pass); $frag = $dom->createDocumentFragment(); $frag('title', 'Ad Insertion'); $frag('link', null, ['rel' => 'icon', 'href' => 'favicon.svg', 'type' => 'image/svg+xml', 'sizes' => 'any']); $frag('link', null, ['rel' => 'stylesheet', 'href' => 'stylesheets/styles/styles.css', 'media' => 'all']); $frag('link', null, ['rel' => 'prefetch', 'href' => 'images/icons.svg', 'type' => 'image/svg+xml']); $frag('base', null, ['href' => $url]); $frag('script', null, ['type' => 'application/javascript', 'src' => 'scripts/custom.js', 'defer' => true]); $frag('meta', null, ['name' => 'description', 'content' => 'An ad insertion form for the Kern Valley Sun']); return $frag; }
function loadFooter() { $size = ['height' => 50, 'width' => 50]; $params = new \shgysk8zer0\Core\URLSearchParams(); $params->load = 'readme'; $footer = DOM\HTML::getInstance()->createElement('footer'); $footer->append('a', null, ['title' => 'View README/documentation', 'href' => "?{$params}", 'role' => 'button'])->import(DOM\SVG::useIcon('info', $size)); $contact = $footer('contact_dialog')[0]; $footer->append('button', null, ['title' => 'Contact info', 'data-show-modal' => "#{$contact->id}"])->import(DOM\SVG::useIcon('organization', $size)); $params->load = 'login'; $footer->append('a', null, ['href' => "?{$params}", 'title' => 'login', 'role' => 'button'])->import(DOM\SVG::useIcon('sign-in', $size)); $params->load = 'ad_insertion'; $footer->append('a', null, ['href' => "?{$params}", 'title' => 'Ad Insertion', 'role' => 'button'])->import(DOM\SVG::useIcon('smiley', $size)); return $footer; }
function buildForm() { $form = \shgysk8zer0\DOM\HTML::getInstance()->createElement('form'); $form->name = basename(__FILE__, '.php'); $form->method = 'POST'; $form->action = \shgysk8zer0\Core\URL::getInstance(); $form->append('label', 'Email', ['for' => "{$form->name}[user]"]); $form->append('input', null, ['type' => 'email', 'name' => "{$form->name}[user]", 'id' => "{$form->name}[user]", 'placeholder' => '*****@*****.**', 'required' => '']); $form->append('br'); $form->append('label', 'Password', ['for' => "{$form->name}[password]"]); $form->append('input', null, ['type' => 'password', 'name' => "{$form->name}[password]", 'id' => "{$form->name}[password]", 'placeholder' => '************', 'required' => '']); $form->append('hr'); $form->append('button', null, ['type' => 'submit', 'title' => 'Submit'])->import(\shgysk8zer0\DOM\SVG::useIcon('check', ['height' => 30, 'width' => 30])); $form->append('button', null, ['type' => 'reset', 'title' => 'Reset'])->import(\shgysk8zer0\DOM\SVG::useIcon('x', ['height' => 30, 'width' => 30])); return $form; }
/** * [load_request description] * @param [type] $request [description] * @return [type] [description] */ function load_request($request) { $resp = \shgysk8zer0\Core\JSON_Response::getInstance(); $dom = \shgysk8zer0\DOM\HTML::getInstance(); switch ($request) { case 'readme': $readme = call_user_func($dom->body, 'readme')[0]; return $resp->append('body', $readme)->showModal("#{$readme->id}"); break; case 'ad_insertion': return load_form('ad_insertion'); break; case 'login': return load_form('login'); break; default: \shgysk8zer0\Core\Console::getInstance()->error(sprintf(ERROR_FORMAT, $request)); return $resp->notify('Unhandled request', sprintf(ERROR_FORMAT, $_REQUEST['load']), 'images/octicons/svg/bug.svg')->error(['$_REQUEST' => $_REQUEST]); } }
function loadHeader() { $header = \shgysk8zer0\DOM\HTML::getInstance()->createElement('header'); $header->append('h1', 'KV Sun Ad Insertion', ['class' => 'center'])->append('img', null, ['alt' => 'KV Sun Logo', 'src' => 'sun.svg', 'width' => 266, 'height' => 90]); return $header; }
function loadHeader() { $header = \shgysk8zer0\DOM\HTML::getInstance()->createElement('header'); $header->append('h1', 'KV Sun Ad Insertion', ['class' => 'center'])->importHTML(file_get_contents('sun.svg')); return $header; }
function loadAdInsertion() { $size = ['width' => 30, 'height' => 30]; $form = DOM\HTML::getinstance()->createElement('form'); $form->name = basename(__FILE__, '.php'); $form->action = '.'; $form->method = 'POST'; $section = $form->append('fieldset', null, ['form' => $form->name]); $section->append('legend', 'Section'); $section->append('label', 'Date: ', ['for' => 'ad-insertion[date]']); $section->append('input', null, ['type' => 'date', 'name' => 'ad-insertion[date]', 'id' => 'ad-insertion[date]', 'placeholder' => 'YYYY-mm-dd', 'require' => true]); $section->append('label', 'By: ', ['for' => 'ad-insertion[by]']); $section->append('input', null, ['type' => 'text', 'name' => 'ad-insertion[by]', 'id' => 'ad-insertion[by]', 'pattern' => '[A-z ]+', 'placeholder' => 'Your name', 'required' => true]); $section->append('br'); $section->append('label', 'A', ['for' => 'ad-insertion[section][a]']); $section->append('input', null, ['type' => 'checkbox', 'name' => 'ad-insertion[section][a]', 'id' => 'ad-insertion[section][a]']); $section->append('label', 'B', ['for' => 'ad-insertion[section][b]']); $section->append('input', null, ['type' => 'checkbox', 'name' => 'ad-insertion[section][b]', 'id' => 'ad-insertion[section][b]']); $section->append('label', 'C', ['for' => 'ad-insertion[section][c]']); $section->append('input', null, ['type' => 'checkbox', 'name' => 'ad-insertion[section][c]', 'id' => 'ad-insertion[section][c]']); $section->append('label', 'D', ['for' => 'ad-insertion[section][d]']); $section->append('input', null, ['type' => 'checkbox', 'name' => 'ad-insertion[section][d]', 'id' => 'ad-insertion[section][d]']); $section->append('label', ' Classification', ['for' => 'ad-insertion[classification]']); $section->append('input', null, ['type' => 'text', 'name' => 'ad-insertion[classification]', 'id' => 'ad-insertion[classification]', 'placeholder' => '???', 'required' => true]); $section->append('label', null, ['for' => 'ad-insertion[special-edition]'])->append('i', 'Special Edition'); $section->append('input', null, ['type' => 'text', 'name' => 'ad-insertion[special-edition]', 'placeholder' => '???', 'id' => 'ad-insertion[special-edition]']); unset($section); $contact = $form->append('fieldset', null, ['for' => 'ad-insertion']); $contact->append('legend', 'Contact Info'); $contact->append('label', 'Account name: ', ['for' => 'ad-insertion[acct-name]']); $contact->append('input', null, ['type' => 'text', 'name' => 'ad-insertion[acct-name]', 'id' => 'ad-insertion[acct-name]', 'pattern' => '[\\w ]+', 'placeholder' => 'Business name', 'required' => '']); $contact->append('br'); $contact->append('label', 'Contact: ', ['for' => 'ad-insertion[contact]']); $contact->append('input', null, ['type' => 'text', 'name' => 'ad-insertion[contact]', 'id' => 'ad-insertion[contact]', 'placeholder' => 'First Last', 'pattern' => '[A-z \\.]+', 'required' => '']); $contact->append('label', 'Phone: ', ['for' => 'ad-insertion[phone]']); $contact->append('input', null, ['type' => 'tel', 'name' => 'ad-insertion[phone]', 'id' => 'ad-insertion[phone]', 'placeholder' => '123456789', 'required' => '']); $contact->append('br'); $contact->append('label', 'Address: ', ['for' => 'ad-insertion[address]']); $contact->append('input', null, ['type' => 'text', 'name' => 'ad-insertion[address]', 'id' => 'ad-insertion[address]', 'pattern' => '[\\w \\.]+', 'placeholder' => '123 Easy St.', 'required' => '']); unset($contact); $charges = $form->append('fieldset', null, ['form' => 'ad-insertion']); $charges->append('legend', 'Charges'); $charges->append('label', 'Rate: ', ['for' => 'ad-insertion[rate]']); $charges->append('input', null, ['type' => 'number', 'name' => 'ad-insertion[rate]', 'id' => 'ad-insertion[rate]', 'min' => '0', 'step' => 0.01, 'value' => '0', 'placeholder' => '50.00', 'required' => '']); $charges->append('label', 'Color Rate: ', ['for' => 'ad-insertion[color-rate]']); $charges->append('input', null, ['type' => 'number', 'name' => 'ad-insertion[color-rate]', 'id' => 'ad-insertion[color-rate]', 'min' => '0', 'step' => 0.01, 'value' => '0', 'placeholder' => 5.25, 'required' => '']); $charges->append('label', 'Full ', ['for' => 'ad-insertion[q][full]']); $charges->append('input', null, ['type' => 'radio', 'name' => 'ad-insertion[q]', 'id' => 'ad-insertion[q][full]', 'value' => 'full', 'placeholder' => '???']); $charges->append('label', '1 ', ['for' => 'ad-insertion[q][1]']); $charges->append('input', null, ['type' => 'radio', 'name' => 'ad-insertion[q]', 'id' => 'ad-insertion[q][1]', 'value' => '1']); $charges->append('label', '2 ', ['for' => 'ad-insertion[q][2]']); $charges->append('input', null, ['type' => 'radio', 'name' => 'ad-insertion[q]', 'id' => 'ad-insertion[q][2]', 'value' => '2']); $charges->append('br'); $charges->append('h2', 'Size'); $charges->append('hr'); $charges->append('label', 'Width: ', ['for' => 'ad-insertion[size][width]']); $charges->append('input', null, ['type' => 'number', 'name' => 'ad-insertion[size][width]', 'id' => 'ad-insertion[size][width]', 'min' => '1', 'max' => '6', 'step' => '1', 'placeholder' => 3, 'required' => '']); $charges->append('label', 'Height: ', ['for' => 'ad-insertion[size][height]']); $charges->append('input', null, ['type' => 'number', 'name' => 'ad-insertion[size][height]', 'id' => 'ad-insertion[size][height]', 'min' => '1', 'max' => '21', 'step' => '0.5', 'placeholder' => 5, 'required' => '']); $charges->append('h2', 'Run Dates'); $charges->append('hr'); $charges->append('label', 'From: ', ['for' => 'ad-insertion[run][start]']); $charges->append('input', null, ['type' => 'week', 'name' => 'ad-insertion[run][start]', 'id' => 'ad-insertion[run][start]', 'placeholder' => 'YYYY-W##', 'required' => '']); $charges->append('label', 'To: ', ['for' => 'ad-insertion[run][end]']); $charges->append('input', null, ['type' => 'week', 'name' => 'ad-insertion[run][end]', 'id' => 'ad-insertion[run][end]', 'placeholder' => 'YYYY-W##', 'required' => '']); $charges->append('label', null, ['for' => 'ad-insertion[sheets]'])->append('b')->append('abbr', 'TFN', ['title' => 'Tile Further Notice']); $charges->append('input', null, ['type' => 'text', 'name' => 'ad-insertion[sheets]', 'id' => 'ad-insertion[sheets]', 'placeholder' => '???']); $charges->append('br'); $charges->append('label', null, ['for' => 'ad-insertion[pu]'])->append('abbr', 'P/U', ['title' => 'Pick-Up']); $charges->append('input', null, ['type' => 'text', 'name' => 'ad-insertion[pu]', 'id' => 'ad-insertion[pu]', 'placeholder' => '???']); unset($charges); $info = $form->append('fieldset'); $info->append('legend', 'Ad Description & Info'); $info->append('br'); $info->append('textarea', null, ['name' => 'ad-insertion[info]', 'id' => 'ad-insertion[info]', 'placeholder' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor.', 'required' => '']); $info->append('br'); $info->append('label', 'Attachments: ', ['for' => 'ad-insertion[attachments]']); $info->append('input', null, ['type' => 'file', 'name' => 'ad-insertion[attachments]', 'id' => 'ad-insertion[attachments]']); unset($info); $form->append('button', null, ['type' => 'submit', 'title' => 'Submit'])->import(DOM\SVG::useIcon('check', $size)); $form->append('button', null, ['type' => 'reset', 'title' => 'Reset'])->import(DOM\SVG::useIcon('x', $size)); $form->append('hr'); return $form; }