Пример #1
0
function con_to_html(array $row, $view = null)
{
    $cfg = new MCSettings();
    $siteroot = "//" . $cfg->base_uri . "/";
    switch ($view) {
        case 'dropdown':
            return <<<HTML
<li><a href="{$siteroot}dash/?section=update&cid={$row['cid']}" data-target="#this-modal">{$row['title']}</a></li>
HTML;
            break;
        case 'panel':
        default:
            $con = new DataBaseTable('content', true, DATACONF);
            $cq = $con->getData("pid:`= {$row['cid']}`");
            $cli = null;
            while ($child = $cq->fetch(PDO::FETCH_ASSOC)) {
                $cli .= con_to_html($child, 'dropdown');
            }
            if (!empty($cli)) {
                $cli = "<li class=\"divider\"></li>\n" . $cli;
            }
            $note = new DataBaseTable('notes', true, DATACONF);
            $nq = $note->getData("cid:`= {$row['cid']}`");
            $nli = null;
            while ($note = $nq->fetch(PDO::FETCH_ASSOC)) {
                $nli .= note_to_html($note, 'dropdown');
            }
            if (!empty($nli)) {
                $nli = "<li class=\"divider\"></li>\n" . $nli;
            }
            $art = new DataBaseTable('art', true, DATACONF);
            $aq = $art->getData("cid:`= {$row['cid']}`");
            $ali = null;
            while ($art = $aq->fetch(PDO::FETCH_ASSOC)) {
                $ali .= art_to_html($art, 'dropdown');
            }
            if (!empty($ali)) {
                $ali = "<li class=\"divider\"></li>\n" . $ali;
            }
            return <<<HTML
<div id="{$row['cid']}" class="panel panel-default">
<div class="panel-heading">{$row['title']}</div>
<div class="panel-body">{$row['data']}</div>
<div class="panel-footer"><a href="{$siteroot}dash/?section=update&cid={$row['cid']}" class="btn btn-info" data-target="#this-modal">Edit</a>
<div id="{$row['cid']}-Art" class="dropdown no-box">
<button class="btn btn-info" type="button" data-toggle="dropdown">Artwork <span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="{$siteroot}dash/?section=upload&cid={$row['cid']}" data-target="#this-modal">Add Artwork</a></li>
{$ali}
</ul>
</div>
<div id="{$row['cid']}-Children" class="dropdown no-box">
<button class="btn btn-success" type="button" data-toggle="dropdown">Children <span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="{$siteroot}dash/?section=put&pid={$row['cid']}" data-target="#this-modal">Add Child</a></li>
{$cli}
</ul>
</div>
<div id="{$row['cid']}-Notes" class="dropdown no-box">
<button class="btn btn-warning" type="button" data-toggle="dropdown">Notes <span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="{$siteroot}dash/?section=write&cid={$row['cid']}" data-target="#this-modal">Add Note</a></li>
{$nli}
</ul>
</div>
<a href="{$siteroot}dash/?section=drop&cid={$row['cid']}" class="btn btn-danger" data-target="#this-modal">Delete</a>
</div>
</div>
HTML;
    }
}
Пример #2
0
            $title = "Your Site";
            break;
        case 'library':
            $title = "Your Library";
            break;
        case 'projects':
        default:
            $title = "Your Projects";
            $body = null;
            $data = new DataBaseTable('content', true, DATACONF);
            $q = $data->getData("pid:`= 0` uid:`= {$session->uid}`");
            $c = 0;
            if ($q instanceof PDOStatement) {
                $projects = null;
                while ($row = $q->fetch(PDO::FETCH_ASSOC)) {
                    $projects .= con_to_html($row);
                    $c++;
                }
            }
            if ($c <= 0) {
                $body .= "<div class=\"alert alert-warning\">You have no projects! Would you like to <a href=\"//{$conf->base_uri}/dash/?section=put&type=project\" data-target=\"#this-modal\">add one</a>?</div>\n";
            } else {
                $body .= "<div id=\"List\" class=\"panel-group\">\n{$projects}\n</div>\n<span class=\"alert alert-info\">You have {$c} project(s). <a href=\"./dash.php?section=put&type=project\" data-target=\"#this-modal\">Add another</a>?</span> <a href=\"javascript:location.reload()\" class=\"right btn btn-info\">Reload Index</a>\n";
            }
    }
}
if (!empty($_GET['json'])) {
    header("Content-type:'text/json'");
    $return_arr['okay'] = $success;
    $return_arr['message'] = $message;
    echo json_encode($return_arr);
Пример #3
0
function build_manager_form(MCSession $session, $action, $ctype = null, $pid = null, $cid = null)
{
    $con = new DataBaseTable('content', true, DATACONF);
    $siteroot = SITEROOT;
    if ($action != 'drop') {
        $types = new DataBaseTable('types', true, DATACONF);
        if ($action == 'update' && $cid != NULL) {
            $asave = " autoSave";
            $q = $con->getData("cid:`{$cid}`");
            $values = $q->fetch(PDO::FETCH_ASSOC);
            $values['modified'] = date("Y-m-d H:i:s");
            $child_btn = <<<HTML
<a href="{$siteroot}dash/?section=put&pid={$values['cid']}" class="btn btn-success" data-target="#this-modal">Add Child</a>
HTML;
            if (empty($ctype)) {
                $cttid = $types->getData("ttid:`= {$values['ttid']}`");
                $cttid = $cttid->fetch(PDO::FETCH_ASSOC);
                $ctype = $cttid['ctype'];
            }
            $qstr = "?section={$action}&cid={$cid}";
        } else {
            $ttid_opts .= "</select>\n";
            $asave = null;
            if (empty($pid)) {
                $values['pid'] = 0;
            } else {
                $values['pid'] = $pid;
            }
            $child_btn = null;
            $values['created'] = date("Y-m-d H:i:s");
            $values['modified'] = null;
            $values['title'] = "New " . ucwords($ctype);
            $values['uid'] = $session->uid;
            $values['tags'] = null;
            $values['ttid'] = null;
            $values['price'] = "0.00";
            $values['data'] = "<p>Your text here...</p>";
            $values['file'] = null;
            $qstr = "?section={$action}&type={$ctype}";
        }
        if (empty($ctype) && !empty($pid)) {
            $parent = $con->getData("cid:`= {$pid}`", array('ttid'));
            $parent = $parent->fetch(PDO::FETCH_ASSOC);
            $ptype = $types->getData("ttid:`= {$parent['ttid']}`");
            $ptype = $ptype->fetch(PDO::FETCH_ASSOC);
            $ctype = $ptype['child_types'];
        }
        if (empty($ctype)) {
            $ctype = "project";
        }
        $html = "<h4>{$action} {$ctype}</h4>\n";
        $ttids = $types->getData("ctype:`{$ctype}`");
        $ttid_opts = "<select class=\"form-control\" id=\"ttid\" name=\"ttid\">\n";
        while ($type = $ttids->fetch(PDO::FETCH_ASSOC)) {
            if ($type['ttid'] == $values['ttid']) {
                $tval = " selected=\"selected\"";
            } else {
                $tval = null;
            }
            $ttid_opts .= "<option{$tval} value=\"{$type['ttid']}\">{$type['name']}</option>\n";
        }
        $ttid_opts .= "</select>\n";
        switch ($ctype) {
            case 'note':
                $type_extras = <<<HTML
<div class="form-group">
<label for="note">Note</label>
<textarea id="note" name="data" class="full editor">
{$values['data']}
</textarea>
</div>
HTML;
                break;
            case 'art':
                break;
            case 'page':
                $type_extras = <<<HTML
<div class="form-group">
<label for="script">Script</label>
<textarea id="script" name="data" class="script editor form-control">
{$values['data']}
</textarea>
</div>
HTML;
                break;
            case 'section':
            case 'chapter':
            case 'project':
            default:
                $type_extras = <<<HTML
<div class="form-group">
<label for="description">Description</label>
<textarea id="description" name="data" class="limited editor form-control">
{$values['data']}
</textarea>
</div>
HTML;
        }
        $html .= <<<HTML
<form action="{$siteroot}dash/{$qstr}" class="manager{$asave}" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="title">Title</label>
<input type="hidden" name="pid" value="{$values['pid']}">
<input type="hidden" name="uid" value="{$values['uid']}">
<input type="hidden" name="created" value="{$values['created']}">
<input type="hidden" name="modified" value="{$values['modified']}">
<input type="text" class="form-control" maxlength="160" id="title" name="title" value="{$values['title']}">
</div>
<div class="form-group">
<label for="price">Price</label>
<div class="input-group">
<span class="input-group-addon">\$</span><input type="number" class="form-control" maxlength="7" id="price" name="price" value="{$values['price']}"><span class="input-group-addon">USD</span>
</div>
</div>
<div class="form-group">
<label for="tags">Tags</label>
<input type="text" class="form-control" id="tags" name="tags" value="{$values['tags']}">
</div>
<div class="form-group">
<label for="ttid">Type</label>
{$ttid_opts}
</div>
<div id="Preferences">
{$type_extras}
</div>
<div class="form-group center">
<button class="btn btn-primary" type="button" data-target="#messageModal" name="save" value="1">Save</button>
{$child_btn}
<a href="{$siteroot}dash/?secton=projects" class="btn btn-danger" data-target="#this-modal">Cancel</a>
</div>
</form>
HTML;
        if ($action == 'update') {
            $children = $con->getData("pid:`= {$values['cid']}`");
            $cc = 0;
            $cdiv = null;
            while ($crow = $children->fetch(PDO::FETCH_ASSOC)) {
                $cdiv .= con_to_html($crow);
                $cc++;
            }
            if ($cc > 1) {
                $html .= "<div class=\"panel-group\">\n{$cdiv}\n</div>\n";
            } elseif ($cc == 1) {
                $html .= $cdiv;
            }
        }
    } else {
        $html = <<<HTML
<form action="{$siteroot}dash/?section=drop&cid={$cid}" method="post">
<div class="panel panel-danger">
<div class="panel-heading">Are you sure?</div>
<div class="panel-body">Are you really sure you want to drop this item? This action cannot be undone no matter how much you complain or wine</div>
<div class="panel-footer">
<input type="hidden" name="cid" value="{$_GET['cid']}">
<button type="button" class="btn btn-danger" data-target="#messageModal" name="confirm" value="1">Yes</button>
<a href="{$siteroot}dash/?section=projects" class="btn btn-info" data-target="#this-modal">No</a>
</div>
</div>
HTML;
    }
    return $html;
}