コード例 #1
0
ファイル: 10.php プロジェクト: rasel-sk/etomite
function makeHTML($indent, $parent, $expandAll)
{
    global $etomiteDBConn, $output, $dbase, $table_prefix, $_lang, $opened, $opened2, $closed2;
    //added global vars
    $spacer = "";
    for ($i = 1; $i <= $indent; $i++) {
        $spacer .= "&nbsp;&nbsp;&nbsp;";
    }
    $orderby = "isfolder DESC";
    if (isset($_SESSION['tree_sortby']) && isset($_SESSION['tree_sortdir'])) {
        $orderby = $_SESSION['tree_sortby'] . " " . $_SESSION['tree_sortdir'];
    } else {
        $_SESSION['tree_sortby'] = 'isfolder';
        $_SESSION['tree_sortdir'] = 'DESC';
    }
    if ($_SESSION['tree_sortby'] == 'isfolder') {
        $orderby .= ", pagetitle";
    }
    $result = mysql_query("SELECT id, pagetitle, parent, isfolder, published, deleted, type, menuindex, alias FROM {$dbase}." . $table_prefix . "site_content WHERE parent={$parent} ORDER BY {$orderby}", $etomiteDBConn);
    if (mysql_num_rows($result) == 0) {
        $output .= '<div style="white-space: nowrap;">' . $spacer . '<img align="absmiddle" src="media/images/tree/deletedpage.gif" width="18" height="18">&nbsp;<span class="emptyNode">' . $_lang['empty_folder'] . '</span></div>';
    }
    while (list($id, $pagetitle, $parent, $isfolder, $published, $deleted, $type, $menuindex, $alias) = mysql_fetch_row($result)) {
        $pagetitleDisplay = $published == 0 ? "<span class='unpublishedNode'>{$pagetitle}</span>" : "<span class='publishedNode'>{$pagetitle}</span>";
        $pagetitleDisplay = $deleted == 1 ? "<span class='deletedNode'>{$pagetitle}</span>" : $pagetitleDisplay;
        $weblinkDisplay = $type == "reference" ? '&nbsp;<img align="absmiddle" src="media/images/tree/web.gif">' : '';
        $alt = !empty($alias) ? $_lang['alias'] . ": " . $alias : $_lang['alias'] . ": -";
        $alt .= "\n" . $_lang['document_opt_menu_index'] . ": " . $menuindex;
        if (!$isfolder) {
            $output .= '<div style="white-space: nowrap;">' . $spacer . '<img align="absmiddle" src="media/images/tree/page.gif" width="18" height="18">&nbsp;<span oncontextmenu="dopopup(event.x,event.y);return false;" onclick="treeAction(' . $id . ', \'' . addslashes($pagetitle) . '\'); setSelected(this);" onmouseover="setHoverClass(this, 1);" onmouseout="setHoverClass(this, 0);" class="treeNode" onmousedown="itemToChange=' . $id . '; selectedObjectName=\'' . addslashes($pagetitle) . '\'; selectedObjectDeleted=' . $deleted . ';"  title="' . addslashes($alt) . '">' . $pagetitleDisplay . $weblinkDisplay . '</span> <small>(' . $id . ')</small></div>';
        } else {
            if ($expandAll == 1 || $expandAll == 2 && in_array($id, $opened)) {
                if ($expandAll == 1) {
                    array_push($opened2, $id);
                }
                $output .= '<div style="white-space: nowrap;">' . $spacer . '<img align="absmiddle" style="cursor: pointer" src="media/images/tree/folderopen.gif" width="18" height="18" oncontextmenu="toggleNode(this,' . ($indent + 1) . ',' . $id . ',1); return false;" onclick="toggleNode(this,' . ($indent + 1) . ',' . $id . ',0); return false;" >&nbsp;<span oncontextmenu="dopopup(event.x,event.y);return false;" onclick="treeAction(' . $id . ', \'' . addslashes($pagetitle) . '\'); setSelected(this);" onmouseover="setHoverClass(this, 1);" onmouseout="setHoverClass(this, 0);" class="treeNode" onmousedown="itemToChange=' . $id . '; selectedObjectName=\'' . addslashes($pagetitle) . '\'; selectedObjectDeleted=' . $deleted . ';"  title="' . addslashes($alt) . '">' . $pagetitleDisplay . $weblinkDisplay . '</span> <small>(' . $id . ')</small><div style="display:block">';
                makeHTML($indent + 1, $id, $expandAll);
                $output .= '</div></div>';
            } else {
                $output .= '<div style="white-space: nowrap;">' . $spacer . '<img align="absmiddle" style="cursor: pointer" src="media/images/tree/folder.gif" width="18" height="18" oncontextmenu="toggleNode(this,' . ($indent + 1) . ',' . $id . ',1); return false;" onclick="toggleNode(this,' . ($indent + 1) . ',' . $id . ',0); return false;" >&nbsp;<span oncontextmenu="dopopup(event.x,event.y);return false;" onclick="treeAction(' . $id . ', \'' . addslashes($pagetitle) . '\'); setSelected(this);" onmouseover="setHoverClass(this, 1);" onmouseout="setHoverClass(this, 0);" class="treeNode" onmousedown="itemToChange=' . $id . '; selectedObjectName=\'' . addslashes($pagetitle) . '\'; selectedObjectDeleted=' . $deleted . ';"  title="' . addslashes($alt) . '">' . $pagetitleDisplay . $weblinkDisplay . '</span> <small>(' . $id . ')</small><div style="display:none"></div></div>';
                array_push($closed2, $id);
            }
        }
        if ($expandAll == 1) {
            echo '<script language="JavaScript">';
            foreach ($opened2 as $item) {
                printf("parent.openedArray[%d] = 1;", $item);
            }
            echo '</script>';
        } elseif ($expandAll == 0) {
            echo '<script language="JavaScript">';
            foreach ($closed2 as $item) {
                printf("parent.openedArray[%d] = 0;", $item);
            }
            echo '</script>';
        }
    }
}
コード例 #2
0
ファイル: nodes.php プロジェクト: jgrau/MODx-CMS
function makeHTML($indent, $parent, $expandAll, $theme)
{
    global $modx;
    global $icons, $theme, $_style;
    global $modxDBConn, $output, $dbase, $table_prefix, $_lang, $opened, $opened2, $closed2;
    //added global vars
    $pad = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    // setup spacer
    $spacer = "";
    for ($i = 1; $i <= $indent; $i++) {
        $spacer .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    }
    if (!isset($_SESSION['tree_sortby']) && !isset($_SESSION['tree_sortdir'])) {
        // This is the first startup, set default sort order
        $_SESSION['tree_sortby'] = 'menuindex';
        $_SESSION['tree_sortdir'] = 'ASC';
    }
    $orderby = $_SESSION['tree_sortby'] . " " . $_SESSION['tree_sortdir'];
    // Folder sorting gets special setup ;) Add menuindex and pagetitle
    if ($_SESSION['tree_sortby'] == 'isfolder') {
        $orderby .= ", menuindex ASC, pagetitle";
    }
    $tblsc = $dbase . ".`" . $table_prefix . "site_content`";
    $tbldg = $dbase . ".`" . $table_prefix . "document_groups`";
    $tbldgn = $dbase . ".`" . $table_prefix . "documentgroup_names`";
    // get document groups for current user
    if ($_SESSION['mgrDocgroups']) {
        $docgrp = implode(",", $_SESSION['mgrDocgroups']);
    }
    $showProtected = false;
    if (isset($modx->config['tree_show_protected'])) {
        $showProtected = (bool) $modx->config['tree_show_protected'];
    }
    $mgrRole = isset($_SESSION['mgrRole']) && (string) $_SESSION['mgrRole'] === '1' ? '1' : '0';
    if ($showProtected == false) {
        $access = "AND (1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? ")" : " OR dg.document_group IN ({$docgrp}))");
    }
    $sql = "SELECT DISTINCT sc.id, pagetitle, parent, isfolder, published, deleted, type, menuindex, hidemenu, alias, contentType, privateweb, privatemgr,\n                MAX(IF(1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? "" : " OR dg.document_group IN ({$docgrp})") . ", 1, 0)) AS has_access\n                FROM {$tblsc} AS sc\n                LEFT JOIN {$tbldg} dg on dg.document = sc.id\n                WHERE (parent={$parent})\n                {$access}\n                GROUP BY sc.id\n                ORDER BY {$orderby}";
    $result = mysql_query($sql, $modxDBConn);
    if (mysql_num_rows($result) == 0) {
        $output .= '<div style="white-space: nowrap;">' . $spacer . $pad . '<img align="absmiddle" src="' . $_style["tree_deletedpage"] . '">&nbsp;<span class="emptyNode">' . $_lang['empty_folder'] . '</span></div>';
    }
    // Make sure to pass in the $modx_textdir variable to the node builder
    global $modx_textdir;
    while (list($id, $pagetitle, $parent, $isfolder, $published, $deleted, $type, $menuindex, $hidemenu, $alias, $contenttype, $privateweb, $privatemgr, $hasAccess) = mysql_fetch_row($result)) {
        $pagetitle = htmlspecialchars($pagetitle);
        $protectedClass = $hasAccess == 0 ? ' protectedNode' : '';
        $pagetitleDisplay = $published == 0 ? "<span class=\"unpublishedNode\">{$pagetitle}</span>" : ($hidemenu == 1 ? "<span class=\"notInMenuNode{$protectedClass}\">{$pagetitle}</span>" : "<span class=\"publishedNode{$protectedClass}\">{$pagetitle}</span>");
        $pagetitleDisplay = $deleted == 1 ? "<span class=\"deletedNode\">{$pagetitle}</span>" : $pagetitleDisplay;
        $weblinkDisplay = $type == "reference" ? '&nbsp;<img src="' . $_style["tree_linkgo"] . '">' : '';
        $pageIdDisplay = '<small>(' . ($modx_textdir ? '&rlm;' : '') . $id . ')</small>';
        $alt = !empty($alias) ? $_lang['alias'] . ": " . $alias : $_lang['alias'] . ": -";
        $alt .= " " . $_lang['document_opt_menu_index'] . ": " . $menuindex;
        $alt .= " " . $_lang['document_opt_show_menu'] . ": " . ($hidemenu == 1 ? $_lang['no'] : $_lang['yes']);
        $alt .= " " . $_lang['page_data_web_access'] . ": " . ($privateweb ? $_lang['private'] : $_lang['public']);
        $alt .= " " . $_lang['page_data_mgr_access'] . ": " . ($privatemgr ? $_lang['private'] : $_lang['public']);
        if (!$isfolder) {
            $icon = $_style["tree_page"];
            if ($privateweb || $privatemgr) {
                $icon = $_style["tree_page_secure"];
            } else {
                if (isset($icons[$contenttype])) {
                    $icon = $icons[$contenttype];
                }
            }
            $output .= '<div id="node' . $id . '" p="' . $parent . '" style="white-space: nowrap;">' . $spacer . $pad . '<img id="p' . $id . '" align="absmiddle" title="' . $_lang['click_to_context'] . '" style="cursor: pointer" src="' . $icon . '" onclick="showPopup(' . $id . ',\'' . addslashes($pagetitle) . '\',event);return false;" oncontextmenu="this.onclick(event);return false;" onmouseover="setCNS(this, 1)" onmouseout="setCNS(this, 0)" onmousedown="itemToChange=' . $id . '; selectedObjectName=\'' . addslashes($pagetitle) . '\'; selectedObjectDeleted=' . $deleted . ';" />&nbsp;';
            $output .= '<span p="' . $parent . '" onclick="treeAction(' . $id . ', \'' . addslashes($pagetitle) . '\'); setSelected(this);" onmouseover="setHoverClass(this, 1);" onmouseout="setHoverClass(this, 0);" class="treeNode" onmousedown="itemToChange=' . $id . '; selectedObjectName=\'' . addslashes($pagetitle) . '\'; selectedObjectDeleted=' . $deleted . ';" oncontextmenu="document.getElementById(\'p' . $id . '\').onclick(event);return false;" title="' . addslashes($alt) . '">' . $pagetitleDisplay . $weblinkDisplay . '</span> ' . $pageIdDisplay . '</div>';
        } else {
            // expandAll: two type for partial expansion
            if ($expandAll == 1 || $expandAll == 2 && in_array($id, $opened)) {
                if ($expandAll == 1) {
                    array_push($opened2, $id);
                }
                $output .= '<div id="node' . $id . '" p="' . $parent . '" style="white-space: nowrap;">' . $spacer . '<img id="s' . $id . '" align="absmiddle" style="cursor: pointer" src="' . $_style["tree_minusnode"] . '" onclick="toggleNode(this,' . ($indent + 1) . ',' . $id . ',0,' . ($privateweb == 1 || $privatemgr == 1 ? '1' : '0') . '); return false;" oncontextmenu="this.onclick(event); return false;" />&nbsp;<img id="f' . $id . '" align="absmiddle" title="' . $_lang['click_to_context'] . '" style="cursor: pointer" src="' . ($privateweb == 1 || $privatemgr == 1 ? $_style["tree_folderopen_secure"] : $_style["tree_folderopen"]) . '" onclick="showPopup(' . $id . ',\'' . addslashes($pagetitle) . '\',event);return false;" oncontextmenu="this.onclick(event);return false;" onmouseover="setCNS(this, 1)" onmouseout="setCNS(this, 0)" onmousedown="itemToChange=' . $id . '; selectedObjectName=\'' . addslashes($pagetitle) . '\'; selectedObjectDeleted=' . $deleted . ';" />&nbsp;';
                $output .= '<span onclick="treeAction(' . $id . ', \'' . addslashes($pagetitle) . '\'); setSelected(this);" onmouseover="setHoverClass(this, 1);" onmouseout="setHoverClass(this, 0);" class="treeNode" onmousedown="itemToChange=' . $id . '; selectedObjectName=\'' . addslashes($pagetitle) . '\'; selectedObjectDeleted=' . $deleted . ';" oncontextmenu="document.getElementById(\'f' . $id . '\').onclick(event);return false;" title="' . addslashes($alt) . '">' . $pagetitleDisplay . $weblinkDisplay . '</span> ' . $pageIdDisplay . '<div style="display:block">';
                makeHTML($indent + 1, $id, $expandAll, $theme);
                $output .= '</div></div>';
            } else {
                $output .= '<div id="node' . $id . '" p="' . $parent . '" style="white-space: nowrap;">' . $spacer . '<img id="s' . $id . '" align="absmiddle" style="cursor: pointer" src="' . $_style["tree_plusnode"] . '" onclick="toggleNode(this,' . ($indent + 1) . ',' . $id . ',0,' . ($privateweb == 1 || $privatemgr == 1 ? '1' : '0') . '); return false;" oncontextmenu="this.onclick(event); return false;" />&nbsp;<img id="f' . $id . '" title="' . $_lang['click_to_context'] . '" align="absmiddle" style="cursor: pointer" src="' . ($privateweb == 1 || $privatemgr == 1 ? $_style["tree_folder_secure"] : $_style["tree_folder"]) . '" onclick="showPopup(' . $id . ',\'' . addslashes($pagetitle) . '\',event);return false;" oncontextmenu="this.onclick(event);return false;" onmouseover="setCNS(this, 1)" onmouseout="setCNS(this, 0)" onmousedown="itemToChange=' . $id . '; selectedObjectName=\'' . addslashes($pagetitle) . '\'; selectedObjectDeleted=' . $deleted . ';" />&nbsp;';
                $output .= '<span onclick="treeAction(' . $id . ', \'' . addslashes($pagetitle) . '\'); setSelected(this);" onmouseover="setHoverClass(this, 1);" onmouseout="setHoverClass(this, 0);" class="treeNode" onmousedown="itemToChange=' . $id . '; selectedObjectName=\'' . addslashes($pagetitle) . '\'; selectedObjectDeleted=' . $deleted . ';" oncontextmenu="document.getElementById(\'f' . $id . '\').onclick(event);return false;" title="' . addslashes($alt) . '">' . $pagetitleDisplay . $weblinkDisplay . '</span> ' . $pageIdDisplay . '<div style="display:none"></div></div>';
                array_push($closed2, $id);
            }
        }
        // store vars in Javascript
        if ($expandAll == 1) {
            echo '<script type="text/javascript"> ';
            foreach ($opened2 as $item) {
                printf("parent.openedArray[%d] = 1; ", $item);
            }
            echo '</script> ';
        } elseif ($expandAll == 0) {
            echo '<script type="text/javascript"> ';
            foreach ($closed2 as $item) {
                printf("parent.openedArray[%d] = 0; ", $item);
            }
            echo '</script> ';
        }
    }
}
コード例 #3
0
ファイル: nodes.php プロジェクト: WorkForFood/MODxPress
function makeHTML($indent, $parent, $expandAll, $theme)
{
    global $modx;
    global $icons, $iconsPrivate, $_style;
    global $_lang, $opened, $opened2, $closed2;
    //added global vars
    global $renderer;
    $output = "";
    $pad = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    // setup spacer
    $spacer = "";
    for ($i = 1; $i <= $indent; $i++) {
        $spacer .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    }
    if (!isset($_SESSION['tree_sortby']) && !isset($_SESSION['tree_sortdir'])) {
        // This is the first startup, set default sort order
        $_SESSION['tree_sortby'] = 'menuindex';
        $_SESSION['tree_sortdir'] = 'ASC';
    }
    $orderby = $modx->db->escape($_SESSION['tree_sortby'] . " " . $_SESSION['tree_sortdir']);
    // Folder sorting gets special setup ;) Add menuindex and pagetitle
    /*if(in_array($parent, array(1, 2, 3))) $orderby = "pagetitle ASC"; // tree custom sorting*/
    if ($_SESSION['tree_sortby'] == 'isfolder') {
        $orderby .= ", menuindex ASC, pagetitle";
    }
    $tblsc = $modx->getFullTableName('site_content');
    $tbldg = $modx->getFullTableName('document_groups');
    // get document groups for current user
    $docgrp = isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups']) ? implode(",", $_SESSION['mgrDocgroups']) : '';
    $showProtected = false;
    if (isset($modx->config['tree_show_protected'])) {
        $showProtected = (bool) $modx->config['tree_show_protected'];
    }
    $mgrRole = isset($_SESSION['mgrRole']) && (string) $_SESSION['mgrRole'] === '1' ? '1' : '0';
    if ($showProtected == false) {
        $access = "AND (1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? ")" : " OR dg.document_group IN ({$docgrp}))");
    } else {
        $access = '';
    }
    $result = $modx->db->select("DISTINCT sc.id, pagetitle, menutitle, parent, isfolder, published, deleted, type, template, menuindex, donthit, hidemenu, alias, contentType, privateweb, privatemgr,\n\t\t\t\tMAX(IF(1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? "" : " OR dg.document_group IN ({$docgrp})") . ", 1, 0)) AS has_access", "{$tblsc} AS sc LEFT JOIN {$tbldg} dg on dg.document = sc.id", "(parent={$parent}) {$access} GROUP BY sc.id", $orderby);
    if ($modx->db->getRecordCount($result) == 0) {
        $renderer->setPlaceholder("spacer", $spacer);
        $renderer->setPlaceholder("pad", $pad);
        $output .= $renderer->render('node_empty');
    }
    // Make sure to pass in the $modx_textdir variable to the node builder
    global $modx_textdir;
    $node_name_source = $modx->config['resource_tree_node_name'];
    while (list($id, $pagetitle, $menutitle, $parent, $isfolder, $published, $deleted, $type, $template, $menuindex, $donthit, $hidemenu, $alias, $contenttype, $privateweb, $privatemgr, $hasAccess) = $modx->db->getRow($result, 'num')) {
        $renderer = new Render();
        $renderer->lang = $_lang;
        $renderer->style = $_style;
        $renderer->ph = array();
        $renderer->templatesDir = MODX_MANAGER_PATH . 'media/style/' . $modx->config['manager_theme'] . '/templates';
        switch ($node_name_source) {
            case 'menutitle':
                $nodetitle = $menutitle ? $menutitle : $pagetitle;
                break;
            case 'alias':
                $nodetitle = $alias ? $alias : $id;
                if (strpos($alias, '.') === false) {
                    if ($isfolder != 1 || $modx->config['make_folders'] !== '1') {
                        $nodetitle .= $modx->config['friendly_url_suffix'];
                    }
                }
                $nodetitle = $modx->config['friendly_url_prefix'] . $nodetitle;
                break;
            case 'pagetitle':
                $nodetitle = $pagetitle;
                break;
            case 'createdon':
            case 'editedon':
            case 'publishedon':
            case 'pub_date':
            case 'unpub_date':
                $doc = $modx->getDocumentObject('id', $id);
                $date = $doc[$node_name_source];
                if (!empty($date)) {
                    $nodetitle = $modx->toDateFormat($date);
                } else {
                    $nodetitle = '- - -';
                }
                break;
            default:
                $nodetitle = $pagetitle;
        }
        $nodetitle = htmlspecialchars(str_replace(array("\r\n", "\n", "\r"), ' ', $nodetitle));
        $protectedClass = $hasAccess == 0 ? ' protectedNode' : '';
        $nodetitleDisplay = $published == 0 ? "<span class=\"unpublishedNode\">{$nodetitle}</span>" : ($hidemenu == 1 ? "<span class=\"notInMenuNode{$protectedClass}\">{$nodetitle}</span>" : "<span class=\"publishedNode{$protectedClass}\">{$nodetitle}</span>");
        $nodetitleDisplay = $deleted == 1 ? "<span class=\"deletedNode\">{$nodetitle}</span>" : $nodetitleDisplay;
        $weblinkDisplay = $type == "reference" ? '&nbsp;<img src="' . $_style["tree_linkgo"] . '">' : '';
        $pageIdDisplay = '<div class="treeNodeId">[ ' . ($modx_textdir ? '&rlm;' : '') . $id . ' ]</div>';
        $url = $modx->makeUrl($id);
        $alt = !empty($alias) ? $_lang['alias'] . ": " . $alias : $_lang['alias'] . ": -";
        $alt .= " " . $_lang['resource_opt_menu_index'] . ": " . $menuindex;
        $alt .= " " . $_lang['resource_opt_show_menu'] . ": " . ($hidemenu == 1 ? $_lang['no'] : $_lang['yes']);
        $alt .= " " . $_lang['page_data_web_access'] . ": " . ($privateweb ? $_lang['private'] : $_lang['public']);
        $alt .= " " . $_lang['page_data_mgr_access'] . ": " . ($privatemgr ? $_lang['private'] : $_lang['public']);
        $data = array('id' => $id, 'pagetitle' => $pagetitle, 'menutitle' => $menutitle, 'parent' => $parent, 'isfolder' => $isfolder, 'published' => $published, 'deleted' => $deleted, 'type' => $type, 'menuindex' => $menuindex, 'donthit' => $donthit, 'hidemenu' => $hidemenu, 'alias' => $alias, 'contenttype' => $contenttype, 'privateweb' => $privateweb, 'privatemgr' => $privatemgr, 'hasAccess' => $hasAccess, 'template' => $template, 'nodetitle' => $nodetitle, 'spacer' => $spacer, 'pad' => $pad, 'url' => $url, 'alt' => $alt, 'nodetitleDisplay' => $nodetitleDisplay, 'weblinkDisplay' => $weblinkDisplay, 'pageIdDisplay' => $pageIdDisplay);
        $renderer->setPlaceholders($data, "ph.");
        // invoke OnManagerNodePrerender event
        $evtOut = $modx->invokeEvent('OnManagerNodePrerender', $data);
        if (is_array($evtOut)) {
            $evtOut = implode("\n", $evtOut);
        }
        $node = $evtOut;
        if ($replace == '') {
            if ($donthit) {
                $icon = $privateweb || $privatemgr ? $_style["tree_folder_secure"] : $_style["tree_folder"];
                $renderer->setPlaceholders(array("ph.icon" => $icon, "ph.nodetitle" => addslashes($nodetitle)));
                $node .= $renderer->render('node');
                continue;
            }
            if (!$isfolder) {
                $icon = $privateweb || $privatemgr ? $_style["tree_page_secure"] : $_style["tree_page"];
                if ($privateweb || $privatemgr) {
                    if (isset($iconsPrivate[$contenttype])) {
                        $icon = $iconsPrivate[$contenttype];
                    }
                } else {
                    if (isset($icons[$contenttype])) {
                        $icon = $icons[$contenttype];
                    }
                }
                if ($id == $modx->config['site_start']) {
                    $icon = $_style["tree_page_home"];
                } elseif ($id == $modx->config['error_page']) {
                    $icon = $_style["tree_page_404"];
                } elseif ($id == $modx->config['site_unavailable_page']) {
                    $icon = $_style["tree_page_hourglass"];
                } elseif ($id == $modx->config['unauthorized_page']) {
                    $icon = $_style["tree_page_info"];
                }
                $renderer->setPlaceholders(array("ph.icon" => $icon, "ph.nodetitle" => addslashes($nodetitle)));
                $node .= $renderer->render('node');
            } else {
                // expandAll: two type for partial expansion
                if ($expandAll == 1 || $expandAll == 2 && in_array($id, $opened)) {
                    if ($expandAll == 1) {
                        array_push($opened2, $id);
                    }
                    $privatewebmgr = $privateweb == 1 || $privatemgr == 1 ? '1' : '0';
                    $tree_folderopen = $privateweb == 1 || $privatemgr == 1 ? $_style["tree_folderopen_secure"] : $_style["tree_folderopen"];
                    $childnodes .= makeHTML($indent + 1, $id, $expandAll, $theme);
                    $renderer->setPlaceholders(array('ph.id' => $id, 'ph.pagetitle' => $pagetitle, 'ph.menutitle' => $menutitle, 'ph.parent' => $parent, 'ph.isfolder' => $isfolder, 'ph.published' => $published, 'ph.deleted' => $deleted, 'ph.type' => $type, 'ph.menuindex' => $menuindex, 'ph.donthit' => $donthit, 'ph.hidemenu' => $hidemenu, 'ph.alias' => $alias, 'ph.contenttype' => $contenttype, 'ph.privateweb' => $privateweb, 'ph.privatemgr' => $privatemgr, 'ph.hasAccess' => $hasAccess, 'ph.template' => $template, 'ph.nodetitle' => $nodetitle, 'ph.spacer' => $spacer, 'ph.pad' => $pad, 'ph.url' => $url, 'ph.alt' => $alt, 'ph.nodetitleDisplay' => $nodetitleDisplay, 'ph.weblinkDisplay' => $weblinkDisplay, 'ph.pageIdDisplay' => $pageIdDisplay, "tree_folderopen" => $tree_folderopen, "ph.nodetitle" => addslashes($nodetitle), "ph.tree_minusnode" => $_style["tree_minusnode"], "ph.indentplus" => $indent + 1, "ph.privatewebmgr" => $privatewebmgr, "ph.expandAll" => $expandAll, "ph.childnodes" => $childnodes, "ph.display" => "block"));
                    $node .= $renderer->render('node_container');
                    $output .= $node;
                    $node = '';
                } else {
                    $privatewebmgr = $privateweb == 1 || $privatemgr == 1 ? '1' : '0';
                    $tree_folderopen = $privateweb == 1 || $privatemgr == 1 ? $_style["tree_folder_secure"] : $_style["tree_folder"];
                    $renderer->setPlaceholders(array("tree_folderopen" => $tree_folderopen, "ph.nodetitle" => addslashes($nodetitle), "ph.tree_minusnode" => $_style["tree_plusnode"], "ph.indentplus" => $indent + 1, "ph.privatewebmgr" => $privatewebmgr, "ph.expandAll" => $expandAll, "ph.display" => "none"));
                    $node .= $renderer->render('node_container_closed');
                    array_push($closed2, $id);
                }
            }
        } else {
            $node = $evtOut;
        }
        // invoke OnManagerNodeRender event
        $data['node'] = $node;
        $evtOut = $modx->invokeEvent('OnManagerNodeRender', $data);
        if (is_array($evtOut)) {
            $evtOut = implode("\n", $evtOut);
        }
        if ($evtOut != '') {
            $node = $evtOut;
        }
        $output .= $node;
        // store vars in Javascript
        if ($expandAll == 1) {
            echo '<script type="text/javascript"> ';
            foreach ($opened2 as $item) {
                printf("parent.openedArray[%d] = 1; ", $item);
            }
            echo '</script> ';
        } elseif ($expandAll == 0) {
            echo '<script type="text/javascript"> ';
            foreach ($closed2 as $item) {
                printf("parent.openedArray[%d] = 0; ", $item);
            }
            echo '</script> ';
        }
    }
    return $output;
}
コード例 #4
0
    if (is_array($nav)) {
      //  build HTML file using $navigation array
      foreach($nav as $items => $detail) {
        echo '<strong>city: </strong>' . $items . '<br />';

        //  make sure we don't cause error when traversing the tree/array.
        //  since the last element is a single key,value pair.
        if (is_array($detail)) {
          foreach($detail as $key => $value) {
            echo '<strong>' . $key . ': </strong>' . $value . '<br />';
          }
          echo '<br /><br />';
        }
        else {
        }
      } //  foreach($nav as $items => $detail) {
    } //  if (is_array($nav)) {

    echo '        </li>';
    echo '    </ul>';
    echo '</body>';
    echo '</html>';
  
} //  end of function makeHTML($nav);



  makeHTML($navigation);

?>
コード例 #5
0
ファイル: nodes.php プロジェクト: foxcoonn/modx.evo.custom
function makeHTML($indent, $parent, $expandAll, $theme)
{
    global $modx;
    global $icons, $iconsPrivate, $_style;
    global $output, $_lang, $opened, $opened2, $closed2;
    //added global vars
    $pad = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    // setup spacer
    $spacer = "";
    for ($i = 1; $i <= $indent; $i++) {
        $spacer .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    }
    if (!isset($_SESSION['tree_sortby']) && !isset($_SESSION['tree_sortdir'])) {
        // This is the first startup, set default sort order
        $_SESSION['tree_sortby'] = 'menuindex';
        $_SESSION['tree_sortdir'] = 'ASC';
    }
    $orderby = $modx->db->escape($_SESSION['tree_sortby'] . " " . $_SESSION['tree_sortdir']);
    // Folder sorting gets special setup ;) Add menuindex and pagetitle
    if ($_SESSION['tree_sortby'] == 'isfolder') {
        $orderby .= ", menuindex ASC, pagetitle";
    }
    $tblsc = $modx->getFullTableName('site_content');
    $tbldg = $modx->getFullTableName('document_groups');
    // get document groups for current user
    $docgrp = isset($_SESSION['mgrDocgroups']) && is_array($_SESSION['mgrDocgroups']) ? implode(",", $_SESSION['mgrDocgroups']) : '';
    $showProtected = false;
    if (isset($modx->config['tree_show_protected'])) {
        $showProtected = (bool) $modx->config['tree_show_protected'];
    }
    $mgrRole = isset($_SESSION['mgrRole']) && (string) $_SESSION['mgrRole'] === '1' ? '1' : '0';
    if ($showProtected == false) {
        $access = "AND (1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? ")" : " OR dg.document_group IN ({$docgrp}))");
    } else {
        $access = '';
    }
    $result = $modx->db->select("DISTINCT sc.id, pagetitle, menutitle, parent, isfolder, published, deleted, type, template, menuindex, donthit, hidemenu, alias, contentType, privateweb, privatemgr,\r\n\t\t\t\tMAX(IF(1={$mgrRole} OR sc.privatemgr=0" . (!$docgrp ? "" : " OR dg.document_group IN ({$docgrp})") . ", 1, 0)) AS has_access", "{$tblsc} AS sc LEFT JOIN {$tbldg} dg on dg.document = sc.id", "(parent={$parent}) {$access} GROUP BY sc.id", $orderby);
    if ($modx->db->getRecordCount($result) == 0) {
        $output .= '<div style="white-space: nowrap;">' . $spacer . $pad . '<img align="absmiddle" src="' . $_style["tree_deletedpage"] . '">&nbsp;<span class="emptyNode">' . $_lang['empty_folder'] . '</span></div>';
    }
    // Make sure to pass in the $modx_textdir variable to the node builder
    global $modx_textdir;
    $node_name_source = $modx->config['resource_tree_node_name'];
    while (list($id, $pagetitle, $menutitle, $parent, $isfolder, $published, $deleted, $type, $template, $menuindex, $donthit, $hidemenu, $alias, $contenttype, $privateweb, $privatemgr, $hasAccess) = $modx->db->getRow($result, 'num')) {
        switch ($node_name_source) {
            case 'menutitle':
                $nodetitle = $menutitle ? $menutitle : $pagetitle;
                break;
            case 'alias':
                $nodetitle = $alias ? $alias : $id;
                if (strpos($alias, '.') === false) {
                    if ($isfolder != 1 || $modx->config['make_folders'] !== '1') {
                        $nodetitle .= $modx->config['friendly_url_suffix'];
                    }
                }
                $nodetitle = $modx->config['friendly_url_prefix'] . $nodetitle;
                break;
            case 'pagetitle':
                $nodetitle = $pagetitle;
                break;
            case 'createdon':
            case 'editedon':
            case 'publishedon':
            case 'pub_date':
            case 'unpub_date':
                $doc = $modx->getDocumentObject('id', $id);
                $date = $doc[$node_name_source];
                if (!empty($date)) {
                    $nodetitle = $modx->toDateFormat($date);
                } else {
                    $nodetitle = '- - -';
                }
                break;
            default:
                $nodetitle = $pagetitle;
        }
        $nodetitle = $modx->htmlspecialchars(str_replace(array("\r\n", "\n", "\r"), ' ', $nodetitle), ENT_COMPAT);
        $nodetitle_esc = addslashes($nodetitle);
        $protectedClass = $hasAccess == 0 ? ' protectedNode' : '';
        $nodetitleDisplay = $published == 0 ? "<span class=\"unpublishedNode\">{$nodetitle}</span>" : ($hidemenu == 1 ? "<span class=\"notInMenuNode{$protectedClass}\">{$nodetitle}</span>" : "<span class=\"publishedNode{$protectedClass}\">{$nodetitle}</span>");
        $nodetitleDisplay = $deleted == 1 ? "<span class=\"deletedNode\">{$nodetitle}</span>" : $nodetitleDisplay;
        $weblinkDisplay = $type == "reference" ? '&nbsp;<img src="' . $_style["tree_linkgo"] . '">' : '';
        $pageIdDisplay = '<small>(' . ($modx_textdir ? '&rlm;' : '') . $id . ')</small>';
        $url = $modx->makeUrl($id);
        $alt = !empty($alias) ? $_lang['alias'] . ": " . $alias : $_lang['alias'] . ": -";
        $alt .= " " . $_lang['resource_opt_menu_index'] . ": " . $menuindex;
        $alt .= " " . $_lang['resource_opt_show_menu'] . ": " . ($hidemenu == 1 ? $_lang['no'] : $_lang['yes']);
        $alt .= " " . $_lang['page_data_web_access'] . ": " . ($privateweb ? $_lang['private'] : $_lang['public']);
        $alt .= " " . $_lang['page_data_mgr_access'] . ": " . ($privatemgr ? $_lang['private'] : $_lang['public']);
        $alt = $modx->htmlspecialchars($alt);
        $data = array('id' => $id, 'pagetitle' => $pagetitle, 'menutitle' => $menutitle, 'parent' => $parent, 'isfolder' => $isfolder, 'published' => $published, 'deleted' => $deleted, 'type' => $type, 'menuindex' => $menuindex, 'donthit' => $donthit, 'hidemenu' => $hidemenu, 'alias' => $alias, 'contenttype' => $contenttype, 'privateweb' => $privateweb, 'privatemgr' => $privatemgr, 'hasAccess' => $hasAccess, 'template' => $template, 'nodetitle' => $nodetitle, 'spacer' => $spacer, 'pad' => $pad, 'url' => $url, 'alt' => $alt, 'nodetitleDisplay' => $nodetitleDisplay, 'weblinkDisplay' => $weblinkDisplay, 'pageIdDisplay' => $pageIdDisplay);
        // invoke OnManagerNodePrerender event
        $evtOut = $modx->invokeEvent('OnManagerNodePrerender', $data);
        if (is_array($evtOut)) {
            $evtOut = implode("\n", $evtOut);
        }
        $node = $evtOut;
        if ($replace == '') {
            if ($donthit) {
                $icon = $privateweb || $privatemgr ? $_style["tree_folder_secure"] : $_style["tree_folder"];
                $output .= '<div id="node' . $id . '" p="' . $parent . '" style="white-space: nowrap;">' . $spacer . $pad . '<img id="p' . $id . '" align="absmiddle" title="' . $_lang['click_to_context'] . '" style="cursor: pointer" src="' . $icon . '" onclick="showPopup(' . $id . ',\'' . addslashes($nodetitle) . '\',event);return false;" oncontextmenu="this.onclick(event);return false;" onmouseover="setCNS(this, 1)" onmouseout="setCNS(this, 0)" onmousedown="itemToChange=' . $id . '; selectedObjectName=\'' . addslashes($nodetitle) . '\'; selectedObjectDeleted=' . $deleted . '; selectedObjectUrl=\'' . $url . '\'" />&nbsp;';
                $output .= '<span p="' . $parent . '" onclick="treeAction(' . $id . ', \'' . addslashes($nodetitle) . '\',0); setSelected(this);" onmouseover="setHoverClass(this, 1);" onmouseout="setHoverClass(this, 0);" class="treeNode" onmousedown="itemToChange=' . $id . '; selectedObjectName=\'' . addslashes($nodetitle) . '\'; selectedObjectDeleted=' . $deleted . '; selectedObjectUrl=\'' . $url . '\';" oncontextmenu="document.getElementById(\'p' . $id . '\').onclick(event);return false;" title="' . addslashes($alt) . '">' . $nodetitleDisplay . $weblinkDisplay . '</span> ' . $pageIdDisplay . '</div>';
                continue;
            }
            if (!$isfolder) {
                $icon = $privateweb || $privatemgr ? $_style["tree_page_secure"] : $_style["tree_page"];
                if ($privateweb || $privatemgr) {
                    if (isset($iconsPrivate[$contenttype])) {
                        $icon = $iconsPrivate[$contenttype];
                    }
                } else {
                    if (isset($icons[$contenttype])) {
                        $icon = $icons[$contenttype];
                    }
                }
                if ($id == $modx->config['site_start']) {
                    $icon = $_style["tree_page_home"];
                } elseif ($id == $modx->config['error_page']) {
                    $icon = $_style["tree_page_404"];
                } elseif ($id == $modx->config['site_unavailable_page']) {
                    $icon = $_style["tree_page_hourglass"];
                } elseif ($id == $modx->config['unauthorized_page']) {
                    $icon = $_style["tree_page_info"];
                }
                $node .= '<div id="node' . $id . '" p="' . $parent . '" style="white-space: nowrap;">' . $spacer . $pad . '<img id="p' . $id . '" align="absmiddle" title="' . $_lang['click_to_context'] . '" style="cursor: pointer" src="' . $icon . '" onclick="showPopup(' . $id . ',\'' . $nodetitle_esc . '\',event);return false;" oncontextmenu="this.onclick(event);return false;" onmouseover="setCNS(this, 1)" onmouseout="setCNS(this, 0)" onmousedown="itemToChange=' . $id . '; selectedObjectName=\'' . $nodetitle_esc . '\'; selectedObjectDeleted=' . $deleted . '; selectedObjectUrl=\'' . $url . '\'" />&nbsp;';
                $node .= '<span p="' . $parent . '" onclick="treeAction(' . $id . ', \'' . $nodetitle_esc . '\'); setSelected(this);" onmouseover="setHoverClass(this, 1);" onmouseout="setHoverClass(this, 0);" class="treeNode" onmousedown="itemToChange=' . $id . '; selectedObjectName=\'' . $nodetitle_esc . '\'; selectedObjectDeleted=' . $deleted . '; selectedObjectUrl=\'' . $url . '\';" oncontextmenu="document.getElementById(\'p' . $id . '\').onclick(event);return false;" title="' . $alt . '">' . $nodetitleDisplay . $weblinkDisplay . '</span> ' . $pageIdDisplay . '</div>';
            } else {
                // expandAll: two type for partial expansion
                if ($expandAll == 1 || $expandAll == 2 && in_array($id, $opened)) {
                    if ($expandAll == 1) {
                        array_push($opened2, $id);
                    }
                    $node .= '<div id="node' . $id . '" p="' . $parent . '" style="white-space: nowrap;">' . $spacer . '<img id="s' . $id . '" align="absmiddle" style="margin-left:-3px;cursor: pointer" src="' . $_style["tree_minusnode"] . '" onclick="toggleNode(this,' . ($indent + 1) . ',' . $id . ',' . $expandAll . ',' . ($privateweb == 1 || $privatemgr == 1 ? '1' : '0') . '); return false;" oncontextmenu="this.onclick(event); return false;" />&nbsp;<img id="f' . $id . '" align="absmiddle" title="' . $_lang['click_to_context'] . '" style="cursor: pointer;margin-left:-3px;" src="' . ($privateweb == 1 || $privatemgr == 1 ? $_style["tree_folderopen_secure"] : $_style["tree_folderopen"]) . '" onclick="showPopup(' . $id . ',\'' . $nodetitle_esc . '\',event);return false;" oncontextmenu="this.onclick(event);return false;" onmouseover="setCNS(this, 1)" onmouseout="setCNS(this, 0)" onmousedown="itemToChange=' . $id . '; selectedObjectName=\'' . $nodetitle_esc . '\'; selectedObjectDeleted=' . $deleted . '; selectedObjectUrl=\'' . $url . '\';" />&nbsp;';
                    $node .= '<span onclick="treeAction(' . $id . ', \'' . $nodetitle_esc . '\'); setSelected(this);" onmouseover="setHoverClass(this, 1);" onmouseout="setHoverClass(this, 0);" class="treeNode" onmousedown="itemToChange=' . $id . '; selectedObjectName=\'' . $nodetitle_esc . '\'; selectedObjectDeleted=' . $deleted . '; selectedObjectUrl=\'' . $url . '\';" oncontextmenu="document.getElementById(\'f' . $id . '\').onclick(event);return false;" title="' . $alt . '">' . $nodetitleDisplay . $weblinkDisplay . '</span> ' . $pageIdDisplay . '<div style="display:block">';
                    $output .= $node;
                    makeHTML($indent + 1, $id, $expandAll, $theme);
                    $node = '</div></div>';
                } else {
                    $node .= '<div id="node' . $id . '" p="' . $parent . '" style="white-space: nowrap;">' . $spacer . '<img id="s' . $id . '" align="absmiddle" style="margin-left:-3px;cursor: pointer" src="' . $_style["tree_plusnode"] . '" onclick="toggleNode(this,' . ($indent + 1) . ',' . $id . ',' . $expandAll . ',' . ($privateweb == 1 || $privatemgr == 1 ? '1' : '0') . '); return false;" oncontextmenu="this.onclick(event); return false;" />&nbsp;<img id="f' . $id . '" title="' . $_lang['click_to_context'] . '" align="absmiddle" style="cursor: pointer;margin-left:-3px;" src="' . ($privateweb == 1 || $privatemgr == 1 ? $_style["tree_folder_secure"] : $_style["tree_folder"]) . '" onclick="showPopup(' . $id . ',\'' . $nodetitle_esc . '\',event);return false;" oncontextmenu="this.onclick(event);return false;" onmouseover="setCNS(this, 1)" onmouseout="setCNS(this, 0)" onmousedown="itemToChange=' . $id . '; selectedObjectName=\'' . $nodetitle_esc . '\'; selectedObjectDeleted=' . $deleted . '; selectedObjectUrl=\'' . $url . '\';" />&nbsp;';
                    $node .= '<span onclick="treeAction(' . $id . ', \'' . $nodetitle_esc . '\'); setSelected(this);" onmouseover="setHoverClass(this, 1);" onmouseout="setHoverClass(this, 0);" class="treeNode" onmousedown="itemToChange=' . $id . '; selectedObjectName=\'' . $nodetitle_esc . '\'; selectedObjectDeleted=' . $deleted . '; selectedObjectUrl=\'' . $url . '\';" oncontextmenu="document.getElementById(\'f' . $id . '\').onclick(event);return false;" title="' . $alt . '">' . $nodetitleDisplay . $weblinkDisplay . '</span> ' . $pageIdDisplay . '<div style="display:none"></div></div>';
                    array_push($closed2, $id);
                }
            }
        } else {
            $node = $evtOut;
        }
        // invoke OnManagerNodeRender event
        $data['node'] = $node;
        $evtOut = $modx->invokeEvent('OnManagerNodeRender', $data);
        if (is_array($evtOut)) {
            $evtOut = implode("\n", $evtOut);
        }
        if ($evtOut != '') {
            $node = $evtOut;
        }
        $output .= $node;
        // store vars in Javascript
        if ($expandAll == 1) {
            echo '<script type="text/javascript"> ';
            foreach ($opened2 as $item) {
                printf("parent.openedArray[%d] = 1; ", $item);
            }
            echo '</script> ';
        } elseif ($expandAll == 0) {
            echo '<script type="text/javascript"> ';
            foreach ($closed2 as $item) {
                printf("parent.openedArray[%d] = 0; ", $item);
            }
            echo '</script> ';
        }
    }
}
コード例 #6
0
$file['html'] = "levees.html";
$file['ics'] = "levees.ics";
list($fp, $content) = openFiles($file);
// Open the SQLite3 database that stores levee information.
$db = new SQLite3('data/levees.sqlite');
// Initialize a counter that we can use for the GeoJSON marker-symbol property.
$counter = 1;
// Retrieve all the levees
$results = $db->query('SELECT * FROM levees order by startDate, endDate, name');
while ($row = $results->fetchArray(SQLITE3_ASSOC)) {
    // Create JSON+LD for this levee.
    $content['json+ld'][] = makeJSONLD($row);
    // Create GeoJSON for this levee.
    $content['geojson']['features'][] = makeGeoJSON($row, $counter);
    // Create HTML for this levee.
    $content['html'] .= makeHTML($row);
    // Create iCalendar for this levee.
    $vCalendar->addComponent(makeICalendar($row));
    // Increment the counter.
    $counter++;
}
// Add to the GeoJSON object to make it valid.
$content['geojson']['type'] = "FeatureCollection";
// Write the JSON+LD data
fwrite($fp['json+ld'], json_encode($content['json+ld'], JSON_PRETTY_PRINT));
// Write the GeoJSON data
fwrite($fp['geojson'], json_encode($content['geojson'], JSON_PRETTY_PRINT));
// Write the HTML data
fwrite($fp['html'], makeHTMLheader());
fwrite($fp['html'], $content['html']);
fwrite($fp['html'], "\t" . '</tbody>' . "\n" . '</table>' . "\n");
コード例 #7
0
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/**
This script generates an HTML page summarizing the details for all Bio2RDF endpoints
**/
$endpoints = array("affymetrix" => array("endpoint_url" => "http://s4.semanticscience.org:16002/sparql", "graph_uri" => ""), "atlas" => array("endpoint_url" => "http://s4.semanticscience.org:16052/sparql", "graph_uri" => "http://bio2rdf.org/bio2rdf-atlas-statistics"), "biomodels" => array("endpoint_url" => "http://s4.semanticscience.org:16041/sparql", "graph_uri" => "http://bio2rdf.org/bio2rdf-biomodels-statistics"), "bioportal" => array("endpoint_url" => "http://s4.semanticscience.org:16017/sparql", "graph_uri" => "http://bio2rdf.org/bio2rdf-bioportal-statistics"));
/********************/
/** FUNCTION CALLS **/
/********************/
$endpoint_stats = retrieveStatistics($endpoints);
makeHTML($endpoint_stats);
/***************/
/** FUNCTIONS **/
/***************/
function makeHTML($endpoint_stats)
{
    //create one html file per endpoint
    foreach ($endpoint_stats as $endpoint => $d) {
        if (count($d) > 2) {
            //create an output file
            $fo = fopen($endpoint . ".html", "w") or die("Could not create file!");
            if ($fo) {
                $html = "<html>";
                $html .= addHeader($endpoint);
                $html .= "<h1>" . $endpoint . "</h1>";
                $html .= addBasicStatsTable($d['endpoint_url'], $d['triples'], $d['unique_subjects'], $d['unique_predicates'], $d['unique_objects']);
コード例 #8
0
        exit;
    }
    //else
}
//foreach
if ($options['instances_file'] == 'instances/file/path/') {
    echo "** Please specify a valid instances file **" . PHP_EOL;
    exit;
}
$options = print_usage($argv, $argc);
$endpoints = makeEndpoints($options['instances_file']);
$lsr_arr = readLSRIntoArr($options['lsr_file']);
//search the lsr for the descriptions of the endpoints found in endpoints
$endpoints_desc = parseDescriptions($endpoints, $lsr_arr);
$endpoint_stats = retrieveStatistics($endpoints);
makeHTML($endpoint_stats, $endpoints_desc);
/***************/
/** FUNCTIONS **/
/***************/
function print_usage($argv, $argc)
{
    $options = array("instances_file" => "/instances/file/path/", "lsr_file" => "/path/to/lsr");
    // show command line options
    if ($argc == 1) {
        echo "Usage: php {$argv['0']} ";
        foreach ($options as $key => $value) {
            echo "{$key}={$value} " . PHP_EOL;
        }
    }
    // set options from user input
    foreach ($argv as $i => $arg) {
コード例 #9
0
ファイル: nodes.php プロジェクト: Fiberalph/evolution-jp
function makeHTML($indent, $parent = 0, $expandAll)
{
    global $modx;
    global $icons, $iconsPrivate, $_style, $modx_textdir;
    global $output, $_lang, $opened, $opened2, $closed2, $tree_orderby, $docgrp, $in_docgrp, $mgrRole;
    //added global vars
    $pad = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
    if ($parent == '') {
        $parent = 0;
    }
    // setup spacer
    $spacer = get_spacer($indent);
    $tblsc = $modx->getFullTableName('site_content');
    $tbldg = $modx->getFullTableName('document_groups');
    $tbldgn = $modx->getFullTableName('documentgroup_names');
    $access = get_where_mydocs($mgrRole, $in_docgrp);
    $field = 'DISTINCT sc.id,pagetitle,menutitle,parent,isfolder,published,deleted,type,menuindex,hidemenu,alias,contentType';
    $field .= ",privateweb, privatemgr,MAX(IF(1={$mgrRole} OR sc.privatemgr=0 {$in_docgrp}, 1, 0)) AS has_access";
    $from = '[+prefix+]site_content AS sc LEFT JOIN [+prefix+]document_groups dg on dg.document = sc.id';
    $where = "(parent='{$parent}') {$access} GROUP BY sc.id";
    $result = $modx->db->select($field, $from, $where, $tree_orderby);
    $has_child = $modx->db->getRecordCount($result);
    $has_child0 = $has_child;
    if (!isset($modx->config['limit_by_container'])) {
        $modx->config['limit_by_container'] = '';
    }
    if ($modx->config['tree_page_click'] !== '27') {
        if ($modx->config['limit_by_container'] === '') {
            $container_status = 'asis';
        } elseif ($modx->config['limit_by_container'] === '0') {
            $container_status = 'container_only';
        } elseif ($modx->config['limit_by_container'] < $has_child) {
            $container_status = 'too_many';
        } else {
            $container_status = 'asis';
        }
        if ($container_status !== 'asis' && $parent !== '0') {
            $where = "(parent={$parent}) AND isfolder=1 {$access} GROUP BY sc.id";
            $result = $modx->db->select($field, $from, $where, $tree_orderby);
            $has_child = $modx->db->getRecordCount($result);
        }
    }
    if ($has_child == 0 && $container_status !== 'container_only' && $container_status !== 'asis') {
        if ($container_status === 'too_many') {
            $msg = $_lang['too_many_resources'];
        } else {
            $msg = $_lang['empty_folder'];
        }
        if ($msg) {
            $output .= '<div style="white-space: nowrap;">' . $spacer . $pad . '<img align="absmiddle" src="' . $_style["tree_deletedpage"] . '">&nbsp;<span class="emptyNode">' . $msg . '</span></div>';
        }
    } elseif ($has_child == 0 && $container_status !== 'container_only') {
        $msg = $_lang['empty_folder'];
        if ($msg) {
            $output .= '<div style="white-space: nowrap;">' . $spacer . $pad . '<img align="absmiddle" src="' . $_style["tree_deletedpage"] . '">&nbsp;<span class="emptyNode">' . $msg . '</span></div>';
        }
    }
    $loop_count = 0;
    while ($row = $modx->db->getRow($result, 'num')) {
        $loop_count++;
        list($id, $pagetitle, $menutitle, $parent, $isfolder, $published, $deleted, $type, $menuindex, $hidemenu, $alias, $contenttype, $privateweb, $privatemgr, $hasAccess) = $row;
        if ($container_status === 'container_only' && $isfolder == 1) {
            $where = "(parent={$id}) AND isfolder=1 {$access} GROUP BY sc.id";
            $result2 = $modx->db->select($field, $from, $where, $tree_orderby);
            $has_child = $modx->db->getRecordCount($result2);
        }
        $resource_tree_node_name = $modx->config['resource_tree_node_name'];
        switch ($resource_tree_node_name) {
            case 'menutitle':
                $nodetitle = $menutitle ? $menutitle : $pagetitle;
                break;
            case 'alias':
                $nodetitle = $alias ? $alias : $id;
                if (strpos($alias, '.') === false || $modx->config['suffix_mode'] != 1) {
                    $nodetitle .= $modx->config['friendly_url_suffix'];
                }
                $nodetitle = $modx->config['friendly_url_prefix'] . $nodetitle;
                break;
            case 'pagetitle':
                $nodetitle = $pagetitle;
                break;
            case 'createdon':
            case 'editedon':
            case 'publishedon':
            case 'pub_date':
            case 'unpub_date':
                $doc = $modx->getDocumentObject('id', $id);
                $date = $doc[$resource_tree_node_name];
                if (!empty($date)) {
                    $nodetitle = $modx->toDateFormat($date);
                } else {
                    $nodetitle = '- - -';
                }
                break;
            default:
                $nodetitle = $pagetitle;
        }
        $nodetitle = htmlspecialchars(str_replace(array("\r\n", "\n", "\r"), '', $nodetitle));
        $protectedClass = $hasAccess == 0 ? ' protectedNode' : '';
        if ($deleted == 1) {
            $class = 'deletedNode';
        } elseif ($published == 0) {
            $class = 'unpublishedNode';
        } elseif ($hidemenu == 1) {
            $class = "notInMenuNode{$protectedClass}";
        } else {
            $class = "publishedNode{$protectedClass}";
        }
        $nodetitleDisplay = '<span class="' . $class . '">' . "{$nodetitle}</span>";
        $weblinkDisplay = $type == "reference" ? '&nbsp;<img src="' . $_style["tree_linkgo"] . '">' : '';
        $pageIdDisplay = '<small>(' . ($modx_textdir ? '&rlm;' : '') . $id . ')</small>';
        $url = $modx->makeUrl($id, '', '', 'full');
        $alt = "[{$id}] ";
        $alt .= !empty($alias) ? $_lang['alias'] . ": " . $alias : $_lang['alias'] . ": -";
        $alt .= "\n{$_lang['resource_opt_menu_index']}: {$menuindex}";
        $alt .= "\n{$_lang['resource_opt_show_menu']}: " . ($hidemenu == 1 ? $_lang['no'] : $_lang['yes']);
        $alt .= "\n{$_lang['page_data_web_access']}: " . ($privateweb ? $_lang['private'] : $_lang['public']);
        $alt .= "\n{$_lang['page_data_mgr_access']}: " . ($privatemgr ? $_lang['private'] : $_lang['public']);
        $ph['id'] = $id;
        $alt = addslashes($alt);
        $alt = htmlspecialchars($alt, ENT_QUOTES, $modx->config['modx_charset']);
        $ph['alt'] = $alt;
        $ph['parent'] = $parent;
        $ph['spacer'] = $spacer;
        $pagetitle = addslashes($pagetitle);
        $pagetitle = htmlspecialchars($pagetitle, ENT_QUOTES, $modx->config['modx_charset']);
        $nodetitle = addslashes($nodetitle);
        $nodetitle = htmlspecialchars($nodetitle, ENT_QUOTES, $modx->config['modx_charset']);
        $ph['pagetitle'] = "'{$pagetitle}'";
        $ph['nodetitle'] = "'{$nodetitle}'";
        $ph['url'] = "'{$url}'";
        $ph['published'] = $published;
        $ph['deleted'] = $deleted;
        $ph['nodetitleDisplay'] = $nodetitleDisplay;
        $ph['weblinkDisplay'] = $weblinkDisplay;
        $ph['pageIdDisplay'] = $pageIdDisplay;
        $ph['_lang_click_to_context'] = $_lang['click_to_context'];
        if (!$isfolder) {
            $icon = $privateweb || $privatemgr ? $_style["tree_page_secure"] : $_style["tree_page"];
            if ($privateweb || $privatemgr) {
                if (isset($iconsPrivate[$contenttype])) {
                    $icon = $iconsPrivate[$contenttype];
                }
            } else {
                if (isset($icons[$contenttype])) {
                    $icon = $icons[$contenttype];
                }
            }
            if ($id == $modx->config['site_start']) {
                $icon = $_style["tree_page_home"];
            } elseif ($id == $modx->config['error_page']) {
                $icon = $_style["tree_page_404"];
            } elseif ($id == $modx->config['site_unavailable_page']) {
                $icon = $_style["tree_page_hourglass"];
            } elseif ($id == $modx->config['unauthorized_page']) {
                $icon = $_style["tree_page_info"];
            }
            $ph['pid'] = "'p{$id}'";
            $ph['pad'] = $pad;
            $ph['icon'] = $icon;
            switch ($modx->config['tree_page_click']) {
                case '27':
                    $ph['ca'] = 'open';
                    break;
                case '3':
                    $ph['ca'] = 'docinfo';
                    break;
                default:
                    $ph['ca'] = 'open';
            }
            $tpl = get_src_page_node();
            $output .= parse_ph($ph, $tpl);
        } else {
            $ph['fid'] = "'f{$id}'";
            $ph['indent'] = $indent + 1;
            switch ($modx->config['tree_page_click']) {
                case '27':
                    $ph['ca'] = 'open';
                    break;
                case '3':
                    $ph['ca'] = 'docinfo';
                    break;
                default:
                    $ph['ca'] = 'docinfo';
            }
            if ($id == $modx->config['site_start']) {
                $icon = $_style["tree_page_home"];
            } elseif ($id == $modx->config['error_page']) {
                $icon = $_style["tree_page_404"];
            } elseif ($id == $modx->config['site_unavailable_page']) {
                $icon = $_style["tree_page_hourglass"];
            } elseif ($id == $modx->config['unauthorized_page']) {
                $icon = $_style["tree_page_info"];
            }
            // expandAll: two type for partial expansion
            if ($expandAll == 1 || $expandAll == 2 && in_array($id, $opened)) {
                if ($expandAll == 1) {
                    array_push($opened2, $id);
                }
                $ph['_style_tree_minusnode'] = $container_status === 'container_only' && $has_child == 0 ? $_style["tree_blanknode"] : $_style["tree_minusnode"];
                $ph['icon'] = $privateweb == 1 || $privatemgr == 1 ? $_style["tree_folderopen_secure"] : $_style["tree_folderopen"];
                $ph['private_status'] = $privateweb == 1 || $privatemgr == 1 ? '1' : '0';
                $tpl = get_src_fopen_node();
                $output .= parse_ph($ph, $tpl);
                makeHTML($indent + 1, $id, $expandAll);
                $output .= '</div></div>';
            } else {
                if ($container_status === 'container_only' && $has_child == 0) {
                    $ph['_style_tree_plusnode'] = $_style["tree_blanknode"];
                } else {
                    $ph['_style_tree_plusnode'] = $_style["tree_plusnode"];
                }
                $ph['icon'] = $privateweb == 1 || $privatemgr == 1 ? $_style["tree_folder_secure"] : $_style["tree_folder"];
                $ph['private_status'] = $privateweb == 1 || $privatemgr == 1 ? '1' : '0';
                $tpl = get_src_fclose_node();
                $output .= parse_ph($ph, $tpl);
                if ($parent != 0 && $container_status === 'too_many' && $loop_count == $has_child) {
                    $output .= '<div style="white-space: nowrap;">' . $spacer . $pad . '<img align="absmiddle" src="' . $_style["tree_deletedpage"] . '">&nbsp;<span class="emptyNode">' . $_lang['too_many_resources'] . '</span></div>';
                }
                array_push($closed2, $id);
            }
        }
        // store vars in Javascript
        if ($expandAll == 1) {
            echo '<script type="text/javascript"> ';
            foreach ($opened2 as $item) {
                printf("parent.openedArray[%d] = 1; ", $item);
            }
            echo '</script> ';
        } elseif ($expandAll == 0) {
            echo '<script type="text/javascript"> ';
            foreach ($closed2 as $item) {
                printf("parent.openedArray[%d] = 0; ", $item);
            }
            echo '</script> ';
        }
    }
}
コード例 #10
0
    if ($options['graph'] == '') {
        echo "please specify a graph!" . PHP_EOL;
        exit;
    }
    $entry['name'] = "default";
    $entry['sparql'] = $options['sparql'];
    $entry['target.endpoint'] = $options['sparql'];
    $entry['graph'] = $options['graph'];
    $entry['from'] = "FROM <" . $entry['graph'] . ">";
    $entry['describe'] = substr($options['sparql'], 0, strpos($options['sparql'], "/sparql")) . "/describe?url=";
    $outfile = 'statistics.html';
    if ($options['o']) {
        $outfile = $options['o'];
    }
}
makeHTML($entry, $outfile);
function getRegistry($file)
{
    $fh = fopen($file, "r") or die("Could not open File " . $file);
    $h = fgetcsv($fh, 10000, ",");
    while (($a = fgetcsv($fh, 10000, ",")) !== FALSE) {
        $r[$a[0]] = $a;
    }
    fclose($fh);
    return $r;
}
function getRecord($registry, $dataset)
{
    if (!isset($registry[$dataset])) {
        echo "unable to find {$dataset} in registry" . PHP_EOL;
        return null;
コード例 #11
0
ファイル: echo.php プロジェクト: torgrimsonja/mathStats
$fileContent;
$fileLines;
$chartType = array_key_exists('chartType', $_POST) ? escape_html($_POST['chartType']) : 'No Type Chosen';
$uploadPath = "uploads/";
//Logic
if (array_key_exists('newFile', $_FILES) && !empty($_FILES['newFile']['name']) && $_POST['existingFile'] == 'default') {
    $fileName = escape_html($_FILES['newFile']['name']);
    storeFile($uploadPath, $fileName);
    makeFileLines();
    makeHTML($fileLines);
} else {
    if (array_key_exists('existingFile', $_POST) && $_POST['existingFile'] != 'default' && $_FILES['newFile']['name'] == '') {
        $fileName = $_POST['existingFile'];
        existingFileContent();
        makeFileLines();
        makeHTML($fileLines);
    } else {
        if (array_key_exists('existingFile', $_POST) && $_POST['existingFile'] != 'default' && array_key_exists('newFile', $_FILES) && !empty($_FILES['newFile']['name'])) {
            $fileName = escape_html($_FILES['newFile']['name']);
            $previousFileName = $_POST['existingFile'];
            bothMethods();
        } else {
            die('Sorry buddy, you either didn\'t upload a file or it wasn\'t a CSV file.');
        }
    }
}
//Page Level Functions
function storeFile($path, $name)
{
    global $fileContent;
    $fileAlreadyExists = FALSE;