$account = $accounts[0];
$connection_objects = $account->getConnectionObjects([ConnectionObjectFields::ID, ConnectionObjectFields::NAME, ConnectionObjectFields::OBJECT_STORE_URLS, ConnectionObjectFields::TYPE, ConnectionObjectFields::URL]);
// Group the connection objects based on type
$groups = [];
foreach ($connection_objects as $object) {
    if (!isset($groups[$object->type])) {
        $groups[$object->type] = [];
    }
    $groups[$object->type][] = $object;
}
foreach ($groups as $type => $type_objects) {
    $type_name = get_type_name($type);
    echo "\n", $type_name, "\n";
    echo str_repeat('=', strlen($type_name)), "\n";
    foreach ($type_objects as $object) {
        render_object($object);
    }
}
function get_type_name($type)
{
    switch ($type) {
        case ConnectionObjectTypes::PAGE:
            return 'Page';
        case ConnectionObjectTypes::APPLICATION:
            return 'Application';
        case ConnectionObjectTypes::EVENT:
            return 'Event';
        case ConnectionObjectTypes::PLACE:
            return 'Place';
        case ConnectionObjectTypes::DOMAIN:
            return 'Domain';
Esempio n. 2
0
function render_object($object_tree, $objects, $admin = false)
{
    include "../settings.php";
    foreach ($object_tree as $obj_id => $obj_data) {
        if ($objects[$obj_id]['type'] == 'ul') {
            $width_html = ' width_percent="' . $objects[$obj_id]['width'] . '" style="width:' . $objects[$obj_id]['width'] . '%;"';
        }
        // edit & publish/unpublish buttons
        $header_html = '';
        if ($objects[$obj_id]['parent'] == 0 && $admin === true) {
            $header_html .= '<div id="edit_btn' . $obj_id . '" class="edit_btn" onclick="activate_tools(' . $obj_id . ')">EDIT</div>';
            $p_visible = '';
            $up_visible = '';
            if ($objects[$obj_id]['published'] == 0) {
                $p_visible = 'pub_unpub_visible';
            } else {
                $up_visible = 'pub_unpub_visible';
            }
            $header_html .= '<div id="publish_btn' . $obj_id . '" class="publish_btn ' . $p_visible . '" onclick="pub_unpub(' . $obj_id . ',1)">PUBLISH</div>';
            $header_html .= '<div id="unpublish_btn' . $obj_id . '" class="unpublish_btn ' . $up_visible . '" onclick="pub_unpub(' . $obj_id . ',0)">UNPUBLISH</div>';
        }
        // publish date and permalink
        if ($objects[$obj_id]['parent'] == 0) {
            $width_html = ' style="width:' . $objects[$obj_id]['width'] * 100 . 'px;"';
            $base_class = ' base';
            $pubdate = $days[strftime("%A", $objects[$obj_id]["time"])] . strftime(" %e ", $objects[$obj_id]["time"]) . $months[strftime("%B", $objects[$obj_id]["time"])] . strftime(" %Y", $objects[$obj_id]["time"]);
            // permalinks for admin
            if (strpos($_SERVER["REQUEST_URI"], 'admin')) {
                $front_url = $home_url . '/admin/' . $obj_id;
            } else {
                $front_url = $home_url . '/' . $obj_id . '/';
            }
            $header_html = '<div id="base_header' . $obj_id . '" class="base_header"' . $width_html . '>' . $header_html . '<a href="' . $front_url . '" class="pubdate">' . $pubdate . '</a></div>';
        }
        print $header_html . '<' . $objects[$obj_id]['type'] . ' id="obj' . $obj_id . '" class="object' . $base_class . '" sort_order="' . $objects[$obj_id]['sort_order'] . '"' . $width_html . '>';
        $numchildren = count($obj_data['children']);
        if ($numchildren > 0) {
            render_object($obj_data['children'], $objects, $admin);
        } else {
            print '<div class="object_content">';
            if ($objects[$obj_id]['content'] != '0') {
                print $objects[$obj_id]['content'];
            }
            print '</div>';
        }
        if ($objects[$obj_id]['type'] == 'li') {
            print '<div class="object_handle"></div>';
        }
        print '</' . $objects[$obj_id]['type'] . '>' . $base_buttons_html;
        unset($width_html, $base_class, $base_buttons_html);
    }
}
Esempio n. 3
0
function video_upload($args)
{
    $ext = filext($args['file']);
    if ($args['mime'] == 'video/ogg' || $ext == 'ogv' || $ext == 'ogg') {
        // notice: we also handle ogg here although this also could be a
        // different mime type
        // make sure mime type is set
        $mime = 'video/ogg';
    } elseif ($args['mime'] == 'video/h264' || $ext == 'h264') {
        // haven't seen these out there
        $mime = 'video/h264';
    } elseif ($args['mime'] == 'video/mp4' || $ext == 'mp4') {
        // think this need not be h264, but well
        $mime = 'video/mp4';
    } elseif ($args['mime'] == 'video/webm' || $ext == 'webm') {
        // again, webm could also be audio/webm
        $mime = 'video/webm';
    } else {
        return false;
    }
    load_modules('glue');
    $obj = create_object($args);
    if ($obj['#error']) {
        return false;
    } else {
        $obj = $obj['#data'];
    }
    $obj['type'] = 'video';
    $obj['module'] = 'video';
    $obj['video-file'] = $args['file'];
    $obj['video-file-mime'] = $mime;
    save_object($obj);
    $ret = render_object(array('name' => $obj['name'], 'edit' => true));
    if ($ret['#error']) {
        return false;
    } else {
        return $ret['#data'];
    }
}
Esempio n. 4
0
/**
 *	implements upload
 */
function image_upload($args)
{
    // check if supported file
    if (!in_array($args['mime'], array('image/jpeg', 'image/png', 'image/gif')) || $args['mime'] == '' && !in_array(filext($args['file']), array('jpg', 'jpeg', 'png', 'gif'))) {
        return false;
    }
    load_modules('glue');
    // create new object
    $obj = create_object($args);
    if ($obj['#error']) {
        return false;
    } else {
        $obj = $obj['#data'];
    }
    $obj['type'] = 'image';
    // this is for a potential future speedup
    $obj['module'] = 'image';
    $obj['image-file'] = $args['file'];
    $obj['image-file-mime'] = $args['mime'];
    // save original-{width,height} if we can calculate it
    if (_gd_available()) {
        $a = expl('.', $args['page']);
        $size = _gd_get_imagesize(CONTENT_DIR . '/' . $a[0] . '/shared/' . $obj['image-file']);
        $obj['image-file-width'] = $size[0];
        $obj['object-width'] = $size[0] . 'px';
        $obj['image-file-height'] = $size[1];
        $obj['object-height'] = $size[1] . 'px';
    }
    save_object($obj);
    // render object and return html
    $ret = render_object(array('name' => $obj['name'], 'edit' => true));
    log_msg('debug', 'image_upload: ' . print_r($ret, 1));
    if ($ret['#error']) {
        return false;
    } else {
        return $ret['#data'];
    }
}
Esempio n. 5
0
/**
 *	turn a page into an html string
 *
 *	the function also appends the resulting string to the output in 
 *	html.inc.php.
 *	@param array $args arguments
 *		key 'page' is the page (i.e. page.rev)
 *		key 'edit' are we editing or not
 *	@return array response
 *		html
 */
function render_page($args)
{
    // maybe move this to common.inc.php in the future and get rid of some of
    // these checks in the beginning
    if (empty($args['page'])) {
        return response('Required argument "page" missing or empty', 400);
    }
    if (!page_exists($args['page'])) {
        return response('Page ' . quot($args['page']) . ' does not exist', 404);
    }
    if (!isset($args['edit'])) {
        return response('Required argument "edit" missing', 400);
    }
    if ($args['edit']) {
        $args['edit'] = true;
    } else {
        $args['edit'] = false;
    }
    log_msg('debug', 'render_page: rendering ' . quot($args['page']));
    $bdy =& body();
    elem_add_class($bdy, 'page');
    elem_attr($bdy, 'id', $args['page']);
    invoke_hook('render_page_early', array('page' => $args['page'], 'edit' => $args['edit']));
    // for every file in the page directory
    $files = @scandir(CONTENT_DIR . '/' . str_replace('.', '/', $args['page']));
    foreach ($files as $f) {
        $fn = CONTENT_DIR . '/' . str_replace('.', '/', $args['page']) . '/' . $f;
        if ($f == '.' || $f == '..') {
            continue;
        } elseif (is_link($fn) && !is_file($fn) && !is_dir($fn)) {
            // delete dangling symlink
            if (@unlink($fn)) {
                log_msg('info', 'render_page: deleted dangling symlink ' . quot($args['page'] . '.' . $f));
            } else {
                log_msg('error', 'render_page: error deleting dangling symlink ' . quot($args['page'] . '.' . $f));
            }
            continue;
        }
        // render object
        render_object(array('name' => $args['page'] . '.' . $f, 'edit' => $args['edit']));
    }
    invoke_hook('render_page_late', array('page' => $args['page'], 'edit' => $args['edit']));
    log_msg('debug', 'render_page: finished ' . quot($args['page']));
    // return the body element as html-string as well
    return response(elem_finalize($bdy));
}
Esempio n. 6
0
function download_upload_fallback($args)
{
    // we handle everything
    load_modules('glue');
    $obj = create_object($args);
    if ($obj['#error']) {
        return false;
    } else {
        $obj = $obj['#data'];
    }
    $obj['type'] = 'download';
    $obj['module'] = 'download';
    $obj['download-file'] = $args['file'];
    $obj['download-file-mime'] = $args['mime'];
    save_object($obj);
    $ret = render_object(array('name' => $obj['name'], 'edit' => true));
    if ($ret['#error']) {
        return false;
    } else {
        return $ret['#data'];
    }
}
Esempio n. 7
0
<!DOCTYPE html>
<html lang="en">
<head><title>Myrimatch Object</title></head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="css/tracervis.css" rel="stylesheet" media="screen">

<body>
<div style="margin: 1em 0.5em">
<?php 
include_once "dao.php";
include_once "render.php";
dao_open();
$object_id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$operation_id = isset($_GET['operation_id']) ? intval($_GET['operation_id']) : -1;
render_object($object_id, $operation_id);
dao_close();
?>
</div>
<script src="bootstrap/js/bootstrap.min.js"></script>
</body>
</html>