コード例 #1
0
ファイル: resourcesControl.inc.php プロジェクト: ratbird/hope
Treeview, die Strukturdarstellung, views: resources, make_hierarchie
/*****************************************************************************/

$edit_structure_object = Request::option('edit_structure_object');
if ($view == "resources"){
    require_once $RELATIVE_PATH_RESOURCES . '/views/ShowThread.class.php';


    if ($edit_structure_object) {
        echo"<form method=\"POST\" action=\"".URLHelper::getLink()."\">";
        echo CSRFProtection::tokenTag();
    }

    $range_id = $user->id;

    $resUser=new ResourcesUserRoots($range_id);
    $thread=new ShowThread();

    $roots=$resUser->getRoots();
    if (is_array($roots)) {
        foreach ($roots as $a) {
            $thread->showThreadLevel($a);
        }
        echo "<br>&nbsp;";
    } else {
        echo "</td></tr>";
        $msg->displayMsg(12);
    }

    if ($edit_structure_object) {
        echo "</form>";
コード例 #2
0
    function browseLevels()
    {
        $parameters = array();
        if ($this->open_object) {
            $query = "SELECT parent_id FROM resources_objects WHERE resource_id = ?";
            $statement = DBManager::get()->prepare($query);
            $statement->execute(array($this->open_object));
            $temp = $statement->fetchColumn();
            if ($temp != '0') {
                $way_back = $temp;
            }

            $query = "SELECT a.resource_id, a.name, a.description
                      FROM resources_objects AS a
                      LEFT JOIN resources_objects AS b ON (b.parent_id = a.resource_id)
                      WHERE a.parent_id = :parent_id AND (a.category_id IS NULL OR b.resource_id IS NOT NULL)
                      GROUP BY resource_id
                      ORDER BY name";
            $parameters[':parent_id'] = $this->open_object;
        } else {
            $way_back=-1;

            $resRoots = new ResourcesUserRoots($range_id);
            $roots = $resRoots->getRoots();

            if (is_array($roots)) {
                $query = "SELECT resource_id, name, description
                          FROM resources_objects
                          WHERE resource_id IN (:resource_ids)
                          ORDER BY name";
                $parameters[':resource_ids'] = $roots;
            } else {
                $query = '';
                $clause = "AND 1=2";
            }
        }

        if ($query) {
            $statement = DBManager::get()->prepare($query);
            $statement->execute($parameters);
            $elements = $statement->fetchAll(PDO::FETCH_ASSOC);

            //check for sublevels in current level
            $sublevels = false;
            if (count($elements)) {
                $ids = array_map(function ($a) { return $a['resource_id']; }, $elements);
                
                $query = "SELECT 1 FROM resources_objects WHERE parent_id IN (?)";
                $statement = DBManager::get()->prepare($query);
                $statement->execute(array($ids));
                $sublevels = $statement->fetchColumn() > 0;
            }
        }
        ?>
        <tr>
            <td <? $this->cssSw->switchClass(); echo $this->cssSw->getFullClass() ?>>
                <?
                echo $this->getHistory($this->open_object);
                ?>
            </td>
            <td <? echo $this->cssSw->getFullClass() ?>width="15%" align="right" nowrap valign="top">
                <?
                if ($way_back>=0) : ?>
                <a href="<?= URLHelper::getLink('?view=search&quick_view_mode='. Request::option('view_mode')
                            . '&' . (!$way_back ? "reset=TRUE" : "open_level=$way_back")) ?>">
                    <?= Icon::create('arr_2left', 'clickable', ['title' => _('eine Ebene zurück')])->asImg(16, ["class" => 'text-top']) ?>
                    </a>
                <? endif ?>
            </td>
        </tr>
        <tr>
            <td <? $this->cssSw->switchClass(); echo $this->cssSw->getFullClass() ?> align="left" colspan="2">
                <?
                if (count($elements) == 0 || !$sublevels) { ?>
                    <?= MessageBox::info(_("Auf dieser Ebene existieren keine weiteren Unterebenen")) ?>
                <? } else {
                ?>
                <table width="90%" cellpadding=5 cellspacing=0 border=0 align="center">
                    <?
                    if (count($elements) % 2 == 1)
                        $i=0;
                    else
                        $i=1;
                    print "<td width=\"55%\" valign=\"top\">";
                    foreach ($elements as $element) {
                        if (!$switched && $i > count($elements) / 2) {
                            print "</td><td width=\"40%\" valign=\"top\">";
                            $switched = TRUE;
                        } ?>
                        <a href="<?= URLHelper::getLink('?view=search&quick_view_mode='. Request::option('view_mode') .'&open_level=' . $element['resource_id']) ?>">
                            <b><?= htmlReady($element['name']) ?></b>
                        </a><br>
                        <? $i++;
                    }
                    print "</table>";
                }
                ?>
            </td>
        </tr>
        <tr>
            <td <? $this->cssSw->switchClass(); echo $this->cssSw->getFullClass() ?> align="left" colspan="2">
                <?=_("Ressourcen auf dieser Ebene:")?>
            </td>
        </tr>
        <?
    }