KnowbaseItem::showFull PHP Method

showFull() public method

Print out (html) show item : question and answer
public showFull ( $options = [] ) : nothing
$options array of options
return nothing (display item : question and answer)
    function showFull($options = array())
    {
        global $DB, $CFG_GLPI;
        if (!$this->can($this->fields['id'], READ)) {
            return false;
        }
        $linkusers_id = true;
        // show item : question and answer
        if (Session::getLoginUserID() === false && $CFG_GLPI["use_public_faq"] || $_SESSION["glpiactiveprofile"]["interface"] == "helpdesk" || !User::canView()) {
            $linkusers_id = false;
        }
        $this->updateCounter();
        $knowbaseitemcategories_id = $this->fields["knowbaseitemcategories_id"];
        $fullcategoryname = getTreeValueCompleteName("glpi_knowbaseitemcategories", $knowbaseitemcategories_id);
        $tmp = "<a href='" . $this->getSearchURL() . "?knowbaseitemcategories_id={$knowbaseitemcategories_id}'>" . $fullcategoryname . "</a>";
        echo "<table class='tab_cadre_fixe'>";
        echo "<tr><th colspan='4'>" . sprintf(__('%1$s: %2$s'), __('Category'), $tmp);
        echo "</th></tr>";
        echo "<tr><td class='left' colspan='4'><h2>" . __('Subject') . "</h2>";
        if (KnowbaseItemTranslation::canBeTranslated($this)) {
            echo KnowbaseItemTranslation::getTranslatedValue($this, 'name');
        } else {
            echo $this->fields["name"];
        }
        echo "</td></tr>";
        echo "<tr><td class='left' colspan='4'><h2>" . __('Content') . "</h2>\n";
        echo "<div id='kbanswer'>";
        echo $this->getAnswer();
        echo "</div>";
        echo "</td></tr>";
        echo "<tr><th class='tdkb'  colspan='2'>";
        if ($this->fields["users_id"]) {
            // Integer because true may be 2 and getUserName return array
            if ($linkusers_id) {
                $linkusers_id = 1;
            } else {
                $linkusers_id = 0;
            }
            printf(__('%1$s: %2$s'), __('Writer'), getUserName($this->fields["users_id"], $linkusers_id));
            echo "<br>";
        }
        if ($this->fields["date"]) {
            //TRANS: %s is the datetime of update
            printf(__('Created on %s'), Html::convDateTime($this->fields["date"]));
            echo "<br>";
        }
        if ($this->fields["date_mod"]) {
            //TRANS: %s is the datetime of update
            printf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"]));
        }
        echo "</th>";
        echo "<th class='tdkb' colspan='2'>";
        if ($this->countVisibilities() == 0) {
            echo "<span class='red'>" . __('Unpublished') . "</span><br>";
        }
        printf(_n('%d view', '%d views', $this->fields["view"]), $this->fields["view"]);
        echo "<br>";
        if ($this->fields["is_faq"]) {
            _e('This item is part of the FAQ');
        } else {
            _e('This item is not part of the FAQ');
        }
        echo "</th></tr>";
        echo "</table>";
        return true;
    }

Usage Example

Ejemplo n.º 1
0
                 break;
         }
         if (!is_null($item)) {
             $item->add($_POST);
             Event::log($_POST["knowbaseitems_id"], "knowbaseitem", 4, "tools", sprintf(__('%s adds a target'), $_SESSION["glpiname"]));
         }
     }
     Html::back();
 } else {
     if (isset($_GET["id"])) {
         if (isset($_GET["_in_modal"])) {
             Html::popHeader(__('Knowledge base'), $_SERVER['PHP_SELF']);
             $kb = new KnowbaseItem();
             if ($_GET['id']) {
                 $kb->check($_GET["id"], READ);
                 $kb->showFull();
             } else {
                 // New item
                 $kb->showForm($_GET["id"], $_GET);
             }
             Html::popFooter();
         } else {
             // modifier un item dans la base de connaissance
             $kb->check($_GET["id"], READ);
             if (Session::getLoginUserID()) {
                 if ($_SESSION["glpiactiveprofile"]["interface"] == "central") {
                     Html::header(KnowbaseItem::getTypeName(1), $_SERVER['PHP_SELF'], "tools", "knowbaseitem");
                 } else {
                     Html::helpHeader(__('FAQ'), $_SERVER['PHP_SELF']);
                 }
                 Html::helpHeader(__('FAQ'), $_SERVER['PHP_SELF'], $_SESSION["glpiname"]);
All Usage Examples Of KnowbaseItem::showFull