Ejemplo n.º 1
0
function DisplayContentBlock($id, $type, $unsaved = false)
{
    global $connection;
    $module_list = json_decode(file_get_contents("../core/modules.json"));
    if ($id == "plugin") {
        foreach ($module_list->plugins as $plugin) {
            if ($plugin->type == $type) {
                $small = $plugin->name;
            }
        }
        if ($small != "") {
            $line = $small;
        }
    } else {
        if ($type == "sec-menu") {
            $request = "SELECT * FROM menu_content WHERE id='{$id}'";
            $result = $connection->query($request);
            $line = $result->fetch_assoc();
            $small = $line["title"] . "[" . $line["container"] . "]";
        } else {
            if ($type == "blog-view") {
                $request = "SELECT * FROM blog_settings WHERE id = '{$id}'";
                $result = $connection->query($request);
                $line = $result->fetch_assoc();
                switch ($line["display_type"]) {
                    case "blog":
                        $blog_type = "<i class='fa fa-th-large'></i> ";
                        break;
                    case "list":
                        $blog_type = "<i class='fa fa-list'></i> ";
                        break;
                    case "circolari":
                        $blog_type = "<i class='fa fa-files-o'></i> ";
                        break;
                }
                $blog_type .= $line["display_type"];
                $small = "Blog: <span class='label label-info'>" . $blog_type . "</span> " . $line["title"];
            } else {
                $request = "SELECT * FROM generic_content WHERE id = '{$id}'";
                $result = $connection->query($request);
                $line = $result->fetch_assoc();
                $small = GenerateDisplayString($type, $line["content"]);
            }
        }
    }
    echo "<li class='ui-state-default' data-id='{$id}' data-type='{$type}'><i class='fa fa-sort sorticon'></i><span class='label label-info'>{$type}</span> {$small} <span class='label label-default'>{$id}</span> ";
    if (!isset($line)) {
        echo "<i class='fa fa-exclamation-triangle tooltipped' data-toggle='tooltip' title='Contenuto inesistente'></i>";
    }
    if ($unsaved) {
        echo " <i class='fa fa-clock-o tooltipped' data-toggle='tooltip' title='Voce non salvata'></i>";
    }
    echo "<span class='flags'></span>";
    echo "<a class='remove-content lmb pull-right tooltipped' data-toggle='tooltip' title='Dissocia contenuto'><i class='fa fa-remove'></i></a>";
    echo "<a class='edit-content lmb pull-right tooltipped' data-toggle='tooltip' title='Modifica contenuto (<i>le modifiche sulla pagina non verranno salvate</i>)'><i class='fa fa-edit'></i></a>";
    echo "</li>";
}
Ejemplo n.º 2
0
function IsViewOrphan($id, $parent)
{
    global $connection, $elements_haschild;
    $request = "SELECT * FROM page_descriptors WHERE descriptor LIKE '%{$id}%'";
    $result = $connection->query($request);
    $line = $result->fetch_assoc();
    if (!isset($line)) {
        $parents = explode(",", $parent);
        $speedup = implode("','", $elements_haschild);
        $request = "SELECT * FROM generic_content WHERE `element-type` IN ('{$speedup}') AND content LIKE '%{$id}%'";
        foreach ($parents as $parnt) {
            if ($parnt != "") {
                $request .= " AND id!='{$parnt}'";
            }
        }
        $result = $connection->query($request);
        $line = $result->fetch_assoc();
        if (!isset($line)) {
            $request = "SELECT * FROM generic_content WHERE id='{$id}'";
            $result = $connection->query($request);
            $line = $result->fetch_assoc();
            $type = $line["element-type"];
            $small = GenerateDisplayString($type, $line["content"]);
            echo "<tr class='orphan-element' data-id='{$id}'><td><input type='checkbox' value='{$id}'> {$id}</td><td>{$type}</td><td>{$small}</td></tr>";
            if ($line["element-type"] == "tabs-block" || $line["element-type"] == "collapse-block") {
                $json_decoded = json_decode($line["content"]);
                $parent = $id;
                foreach ($json_decoded->views as $view) {
                    foreach ($view->elements as $element) {
                        IsViewOrphan($element->dbid, $parent);
                    }
                }
            }
            if ($line["element-type"] == "generic-box") {
                $json_decoded = json_decode($line["content"]);
                $parent = $id;
                foreach ($json_decoded->elements as $element) {
                    IsViewOrphan($element->dbid, $parent);
                }
            }
        }
    }
}