当前位置: 首页>>代码示例>>PHP>>正文


PHP Document::getImageTag方法代码示例

本文整理汇总了PHP中Document::getImageTag方法的典型用法代码示例。如果您正苦于以下问题:PHP Document::getImageTag方法的具体用法?PHP Document::getImageTag怎么用?PHP Document::getImageTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Document的用法示例。


在下文中一共展示了Document::getImageTag方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cleanTagOrImage

 /**
  * Delete tag or image from ticket content
  *
  * @since version 0.85
  *
  * @param $content   html content of input
  * @param $tags
  *
  * @return htlm content
  **/
 function cleanTagOrImage($content, $tags)
 {
     global $CFG_GLPI;
     // RICH TEXT : delete img tag
     if ($CFG_GLPI["use_rich_text"]) {
         $content = Html::entity_decode_deep($content);
         foreach ($tags as $tag) {
             $content = preg_replace("/<img.*alt=['|\"]" . $tag . "['|\"][^>]*\\>/", "<p></p>", $content);
         }
     } else {
         // SIMPLE TEXT : delete tag
         foreach ($tags as $tag) {
             $content = preg_replace('/' . Document::getImageTag($tag) . '/', '\\r\\n', $content);
         }
     }
     return $content;
 }
开发者ID:glpi-project,项目名称:glpi,代码行数:27,代码来源:ticket.class.php

示例2: addFiles

 /**
  * add files (from $this->input['_filename']) to an ITIL object
  * create document if needed
  * create link from document to ITIL object
  *
  * @param $donotif         Boolean  if we want to raise notification (default 1)
  * @param $disablenotif             (default 0)
  *
  * @return array of doc added name
  **/
 function addFiles($donotif = 1, $disablenotif = 0)
 {
     global $CFG_GLPI;
     if (!isset($this->input['_filename']) || count($this->input['_filename']) == 0) {
         return array();
     }
     $docadded = array();
     foreach ($this->input['_filename'] as $key => $file) {
         $doc = new Document();
         $docitem = new Document_Item();
         $docID = 0;
         $filename = GLPI_TMP_DIR . "/" . $file;
         $input2 = array();
         // Crop/Resize image file if needed
         if (isset($this->input['_coordinates']) && !empty($this->input['_coordinates'][$key])) {
             $image_coordinates = json_decode(urldecode($this->input['_coordinates'][$key]), true);
             Toolbox::resizePicture($filename, $filename, $image_coordinates['img_w'], $image_coordinates['img_h'], $image_coordinates['img_y'], $image_coordinates['img_x'], $image_coordinates['img_w'], $image_coordinates['img_h'], 0);
         } else {
             Toolbox::resizePicture($filename, $filename, 0, 0, 0, 0, 0, 0, 0);
         }
         //If file tag is present
         if (isset($this->input['_tag_filename']) && !empty($this->input['_tag_filename'][$key])) {
             $this->input['_tag'][$key] = $this->input['_tag_filename'][$key];
         }
         // Check for duplicate
         if ($doc->getFromDBbyContent($this->fields["entities_id"], $filename)) {
             if (!$doc->fields['is_blacklisted']) {
                 $docID = $doc->fields["id"];
             }
             // File already exist, we replace the tag by the existing one
             if (isset($this->input['_tag'][$key]) && $docID > 0 && isset($this->input['content'])) {
                 $this->input['content'] = preg_replace('/' . Document::getImageTag($this->input['_tag'][$key]) . '/', Document::getImageTag($doc->fields["tag"]), $this->input['content']);
                 $docadded[$docID]['tag'] = $doc->fields["tag"];
             }
         } else {
             //TRANS: Default document to files attached to tickets : %d is the ticket id
             $input2["name"] = addslashes(sprintf(__('Document Ticket %d'), $this->getID()));
             if ($this->getType() == 'Ticket') {
                 $input2["tickets_id"] = $this->getID();
                 // Insert image tag
                 if (isset($this->input['_tag'][$key])) {
                     $input2["tag"] = $this->input['_tag'][$key];
                 }
             }
             $input2["entities_id"] = $this->fields["entities_id"];
             $input2["documentcategories_id"] = $CFG_GLPI["documentcategories_id_forticket"];
             $input2["_only_if_upload_succeed"] = 1;
             $input2["entities_id"] = $this->fields["entities_id"];
             $input2["_filename"] = array($file);
             $docID = $doc->add($input2);
         }
         if ($docID > 0) {
             if ($docitem->add(array('documents_id' => $docID, '_do_notif' => $donotif, '_disablenotif' => $disablenotif, 'itemtype' => $this->getType(), 'items_id' => $this->getID()))) {
                 $docadded[$docID]['data'] = sprintf(__('%1$s - %2$s'), stripslashes($doc->fields["name"]), stripslashes($doc->fields["filename"]));
                 if (isset($input2["tag"])) {
                     $docadded[$docID]['tag'] = $input2["tag"];
                     unset($this->input['_filename'][$key]);
                     unset($this->input['_tag'][$key]);
                 }
                 if (isset($this->input['_coordinates'][$key])) {
                     unset($this->input['_coordinates'][$key]);
                 }
             }
         }
         // Only notification for the first New doc
         $donotif = 0;
     }
     // Ticket update
     if (isset($this->input['content'])) {
         if ($CFG_GLPI["use_rich_text"]) {
             $this->input['content'] = $this->convertTagToImage($this->input['content'], true, $docadded);
             $this->input['_forcenotif'] = true;
         } else {
             $this->fields['content'] = $this->setSimpleTextContent($this->input['content']);
             $this->updateInDB(array('content'));
         }
     }
     return $docadded;
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:89,代码来源:commonitilobject.class.php

示例3: showListForItem


//.........这里部分代码省略.........
         } else {
             // Anonymous access from FAQ
             $query .= " AND `glpi_documents`.`entities_id`='0' ";
         }
     }
     $query .= " ORDER BY {$sort} {$order}";
     $result = $DB->query($query);
     $number = $DB->numrows($result);
     $i = 0;
     $documents = array();
     $used = array();
     if ($numrows = $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             $documents[$data['assocID']] = $data;
             $used[$data['id']] = $data['id'];
         }
     }
     echo "<div class='spaced'>";
     if ($canedit && $number && $withtemplate < 2) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $params['rand']);
         $massiveactionparams = array('num_displayed' => $number, 'container' => 'mass' . __CLASS__ . $params['rand']);
         Html::showMassiveActions($massiveactionparams);
     }
     $sort_img = "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/" . ($order == "DESC" ? "puce-down.png" : "puce-up.png") . "\" alt='' title=''>";
     echo "<table class='tab_cadre_fixehov'>";
     $header_begin = "<tr>";
     $header_top = '';
     $header_bottom = '';
     $header_end = '';
     if ($canedit && $number && $withtemplate < 2) {
         $header_top .= "<th width='11'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $params['rand']);
         $header_top .= "</th>";
         $header_bottom .= "<th width='11'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $params['rand']);
         $header_bottom .= "</th>";
     }
     foreach ($columns as $key => $val) {
         $header_end .= "<th>" . ($sort == "`{$key}`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort={$key}&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>{$val}</a></th>";
     }
     $header_end .= "</tr>";
     echo $header_begin . $header_top . $header_end;
     $used = array();
     if ($number) {
         // Don't use this for document associated to document
         // To not loose navigation list for current document
         if ($item->getType() != 'Document') {
             Session::initNavigateListItems('Document', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
         }
         $document = new Document();
         foreach ($documents as $data) {
             $docID = $data["id"];
             $link = NOT_AVAILABLE;
             $downloadlink = NOT_AVAILABLE;
             if ($document->getFromDB($docID)) {
                 $link = $document->getLink();
                 $downloadlink = $document->getDownloadLink($linkparam);
             }
             if ($item->getType() != 'Document') {
                 Session::addToNavigateListItems('Document', $docID);
             }
             $used[$docID] = $docID;
             $assocID = $data["assocID"];
             echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>";
             if ($canedit && $withtemplate < 2) {
                 echo "<td width='10'>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]);
                 echo "</td>";
             }
             echo "<td class='center'>{$link}</td>";
             echo "<td class='center'>" . $data['entity'] . "</td>";
             echo "<td class='center'>{$downloadlink}</td>";
             echo "<td class='center'>";
             if (!empty($data["link"])) {
                 echo "<a target=_blank href='" . formatOutputWebLink($data["link"]) . "'>" . $data["link"];
                 echo "</a>";
             } else {
                 echo "&nbsp;";
             }
             echo "</td>";
             echo "<td class='center'>" . Dropdown::getDropdownName("glpi_documentcategories", $data["documentcategories_id"]);
             echo "</td>";
             echo "<td class='center'>" . $data["mime"] . "</td>";
             if ($CFG_GLPI['use_rich_text']) {
                 echo "<td class='center'>";
                 echo !empty($data["tag"]) ? Document::getImageTag($data["tag"]) : '';
                 echo "</td>";
             }
             echo "<td class='center'>" . Html::convDateTime($data["assocdate"]) . "</td>";
             echo "</tr>";
             $i++;
         }
         echo $header_begin . $header_bottom . $header_end;
     }
     echo "</table>";
     if ($canedit && $number && $withtemplate < 2) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
开发者ID:pvasener,项目名称:glpi,代码行数:101,代码来源:document_item.class.php

示例4: header

GLPI is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

GLPI is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
* @since version 0.85
*/
$AJAX_INCLUDE = 1;
include '../inc/includes.php';
header('Content-type: application/json');
Html::header_nocache();
Session::checkLoginUser();
if (isset($_POST['data'])) {
    foreach ($_POST['data'] as $key => $values) {
        $unique_name = Rule::getUuid();
        $response[$key] = array('tag' => Document::getImageTag($unique_name), 'name' => $unique_name);
    }
    echo json_encode($response);
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:30,代码来源:getFileTag.php

示例5: cleanTagOrImage

 /**
  * Delete tag or image from ticket content
  *
  * @since version 0.85
  *
  * @param $content   html content of input
  * @param $tags
  *
  * @return htlm content
  **/
 function cleanTagOrImage($content, $tags)
 {
     global $CFG_GLPI;
     // RICH TEXT : delete img tag
     if ($CFG_GLPI["use_rich_text"]) {
         $html = str_replace(array('&', '&amp;nbsp;'), array('&amp;', ' '), html_entity_decode($content, ENT_QUOTES, "ISO-8859-1"));
         // We parse HTML with dom
         libxml_use_internal_errors(true);
         $dom = new DOMDocument();
         $dom->loadHTML('<html>' . $html . '</html>');
         $dom->preserveWhiteSpace = false;
         // We replace each <img> by a <p>
         $nodes = $dom->getElementsByTagName('img');
         $nodeListLength = $nodes->length;
         $nodesToDelete = array();
         for ($i = 0; $i < $nodeListLength; $i++) {
             $node = $nodes->item($i);
             if ($id = $node->getAttribute('alt')) {
                 foreach ($tags as $tag) {
                     if (preg_match("/" . $tag . "/i", $id)) {
                         $nodesToDelete[] = $node;
                     }
                 }
             }
         }
         foreach ($nodesToDelete as $node) {
             $p = $dom->createElement('p');
             $node->parentNode->replaceChild($p, $node);
         }
         // Get only body content
         $doc = new DOMDocument();
         $body = $dom->getElementsByTagName('body')->item(0);
         foreach ($body->childNodes as $child) {
             $doc->appendChild($doc->importNode($child, true));
         }
         return utf8_decode(Html::entity_decode_deep($doc->saveHTML()));
         // SIMPLE TEXT : delete tag
     } else {
         foreach ($tags as $tag) {
             $content = preg_replace('/' . Document::getImageTag($tag) . '/', '\\r\\n', $content);
         }
         return $content;
     }
 }
开发者ID:remicollet,项目名称:glpi,代码行数:54,代码来源:ticket.class.php

示例6: sendMailById

 /**
  * Send mai lin queue
  *
  * @param $ID        integer ID of the item
  *
  * @return true if send false if not
  **/
 function sendMailById($ID)
 {
     global $CFG_GLPI;
     if ($this->getFromDB($ID)) {
         $mmail = new GLPIMailer();
         $headers = importArrayFromDB($this->fields['headers']);
         if (is_array($headers) && count($headers)) {
             foreach ($headers as $key => $val) {
                 $mmail->AddCustomHeader("{$key}: {$val}");
             }
         }
         // Add custom header for mail grouping in reader
         $mmail->AddCustomHeader("In-Reply-To: GLPI-" . $this->fields["itemtype"] . "-" . $this->fields["items_id"]);
         $mmail->SetFrom($this->fields['sender'], $this->fields['sendername']);
         if ($this->fields['replyto']) {
             $mmail->AddReplyTo($this->fields['replyto'], $this->fields['replytoname']);
         }
         $mmail->Subject = $this->fields['name'];
         if (empty($this->fields['body_html'])) {
             $mmail->isHTML(false);
             $mmail->Body = $this->fields['body_text'];
         } else {
             $mmail->isHTML(true);
             $mmail->Body = '';
             $this->fields['body_html'] = Html::entity_decode_deep($this->fields['body_html']);
             $documents = importArrayFromDB($this->fields['documents']);
             $link_doc = array();
             if (is_array($documents) && count($documents)) {
                 $doc = new Document();
                 foreach ($documents as $docID) {
                     $doc->getFromDB($docID);
                     // Add embeded image if tag present in ticket content
                     if (preg_match_all('/' . Document::getImageTag($doc->fields['tag']) . '/', $this->fields['body_html'], $matches, PREG_PATTERN_ORDER)) {
                         $mmail->AddEmbeddedImage(GLPI_DOC_DIR . "/" . $doc->fields['filepath'], Document::getImageTag($doc->fields['tag']), $doc->fields['filename'], 'base64', $doc->fields['mime']);
                         // Else Add link to the document
                     } else {
                         $link_doc[] = "<a href='" . rtrim($CFG_GLPI["url_base"], '/') . "/front/document.send.php?docid=" . $doc->fields['id'] . "' >" . $doc->fields['name'] . "</a>";
                     }
                 }
             }
             $mmail->Body .= $this->fields['body_html'];
             if (count($link_doc)) {
                 $mmail->Body .= '<p style="border:1px solid #cccccc;padding:5px">' . '<b>' . _n('Associated item', 'Associated items', Session::getPluralNumber()) . ' : </b>' . implode(', ', $link_doc) . '</p>';
             }
             $mmail->AltBody = $this->fields['body_text'];
         }
         $mmail->AddAddress($this->fields['recipient'], $this->fields['recipientname']);
         if (!empty($this->fields['messageid'])) {
             $mmail->MessageID = "<" . $this->fields['messageid'] . ">";
         }
         $messageerror = __('Error in sending the email');
         if (!$mmail->Send()) {
             Session::addMessageAfterRedirect($messageerror . "<br>" . $mmail->ErrorInfo, true);
             $mmail->ClearAddresses();
             $this->update(array('id' => $this->fields['id'], 'sent_try' => $this->fields['sent_try'] + 1));
             return false;
         } else {
             //TRANS to be written in logs %1$s is the to email / %2$s is the subject of the mail
             Toolbox::logInFile("mail", sprintf(__('%1$s: %2$s'), sprintf(__('An email was sent to %s'), $this->fields['recipient']), $this->fields['name'] . "\n"));
             $mmail->ClearAddresses();
             $this->update(array('id' => $this->fields['id'], 'sent_time' => $_SESSION['glpi_currenttime']));
             $this->delete(array('id' => $this->fields['id']));
             return true;
         }
     } else {
         return false;
     }
 }
开发者ID:simaostephanie,项目名称:glpi,代码行数:75,代码来源:queuedmail.class.php

示例7: showForItem


//.........这里部分代码省略.........
             echo "<td colspan='4' class='center'>";
             echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
             echo "<input type='hidden' name='items_id' value='{$ID}'>";
             if ($item->getType() == 'Ticket') {
                 echo "<input type='hidden' name='tickets_id' value='{$ID}'>";
                 echo "<input type='hidden' name='documentcategories_id' value='" . $CFG_GLPI["documentcategories_id_forticket"] . "'>";
             }
             Document::dropdown(array('entity' => $entities, 'used' => $used));
             echo "</td><td class='center' width='20%'>";
             echo "<input type='submit' name='add' value=\"" . _sx('button', 'Associate an existing document') . "\" class='submit'>";
             echo "</td>";
             echo "</tr>";
             echo "</table>";
             Html::closeForm();
         }
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $number && $withtemplate < 2) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $number, 'container' => 'mass' . __CLASS__ . $rand);
         Html::showMassiveActions($massiveactionparams);
     }
     $sort_img = "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/" . ($order == "DESC" ? "puce-down.png" : "puce-up.png") . "\" alt='' title=''>";
     echo "<table class='tab_cadre_fixehov table-striped table-hover'>";
     $header_begin = "<tr>";
     $header_top = '';
     $header_bottom = '';
     $header_end = '';
     if ($canedit && $number && $withtemplate < 2) {
         $header_top .= "<th width='11'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         $header_top .= "</th>";
         $header_bottom .= "<th width='11'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         $header_bottom .= "</th>";
     }
     foreach ($columns as $key => $val) {
         $header_end .= "<th>" . ($sort == "`{$key}`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort={$key}&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>{$val}</a></th>";
     }
     $header_end .= "</tr>";
     echo $header_begin . $header_top . $header_end;
     $used = array();
     if ($number) {
         // Don't use this for document associated to document
         // To not loose navigation list for current document
         if ($item->getType() != 'Document') {
             Session::initNavigateListItems('Document', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
         }
         $document = new Document();
         foreach ($documents as $data) {
             $docID = $data["id"];
             $link = NOT_AVAILABLE;
             $downloadlink = NOT_AVAILABLE;
             if ($document->getFromDB($docID)) {
                 $link = $document->getLink();
                 $downloadlink = $document->getDownloadLink($linkparam);
             }
             if ($item->getType() != 'Document') {
                 Session::addToNavigateListItems('Document', $docID);
             }
             $used[$docID] = $docID;
             $assocID = $data["assocID"];
             echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>";
             if ($canedit && $withtemplate < 2) {
                 echo "<td width='10'>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]);
                 echo "</td>";
             }
             echo "<td class='center'>{$link}</td>";
             echo "<td class='center'>" . $data['entity'] . "</td>";
             echo "<td class='center'>{$downloadlink}</td>";
             echo "<td class='center'>";
             if (!empty($data["link"])) {
                 echo "<a target=_blank href='" . formatOutputWebLink($data["link"]) . "'>" . $data["link"];
                 echo "</a>";
             } else {
                 echo "&nbsp;";
             }
             echo "</td>";
             echo "<td class='center'>" . Dropdown::getDropdownName("glpi_documentcategories", $data["documentcategories_id"]);
             echo "</td>";
             echo "<td class='center'>" . $data["mime"] . "</td>";
             if ($CFG_GLPI['use_rich_text']) {
                 echo "<td class='center'>";
                 echo !empty($data["tag"]) ? Document::getImageTag($data["tag"]) : '';
                 echo "</td>";
             }
             echo "<td class='center'>" . Html::convDateTime($data["assocdate"]) . "</td>";
             echo "</tr>";
             $i++;
         }
         echo $header_begin . $header_bottom . $header_end;
     }
     echo "</table>";
     if ($canedit && $number && $withtemplate < 2) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:101,代码来源:document_item.class.php


注:本文中的Document::getImageTag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。