Esempio n. 1
0
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;
}
Esempio n. 2
0
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;
}
Esempio n. 3
0
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);
    }
}
Esempio n. 4
0
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;
}
Esempio n. 5
0
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;
}
Esempio n. 6
0
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;
}
Esempio n. 7
0
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;
}
Esempio n. 8
0
/**
 * [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]);
    }
}
Esempio n. 9
0
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;
}
Esempio n. 10
0
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;
}