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


PHP StringUtil::lastIndexOf方法代码示例

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


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

示例1: getTitle

 public static function getTitle($name, $html = false)
 {
     $item = 'wcf.sketchbook.sketchTitles.' . self::nameToLangVar($name);
     $value = WCF::getLanguage()->getDynamicVariable($item);
     $new = false;
     if ($value == $title) {
         $value = StringUtil::substring($title, StringUtil::lastIndexOf($title, '.'));
         $new = true;
     }
     if ($html) {
         return '<span class="sketch' . ($new ? ' sketchNew' : '') . '">' . StringUtil::encodeHTML($title) . '</span>';
     }
     return $title;
 }
开发者ID:nachteule,项目名称:nachteule.wcf.sketchbook,代码行数:14,代码来源:SketchbookUtil.class.php

示例2: getFileTypeIcon

 /**
  * Returns the right file type icon for the given attachment.
  * 
  * @return	string
  */
 public function getFileTypeIcon()
 {
     if ($this->fileTypeIcon === null) {
         $this->fileTypeIcon = '';
         // get file extension
         $extension = StringUtil::firstCharToUpperCase(StringUtil::toLowerCase(StringUtil::substring($this->attachmentName, StringUtil::lastIndexOf($this->attachmentName, '.') + 1)));
         // get file type icon
         if (file_exists(WCF_DIR . 'icon/fileTypeIcon' . $extension . 'M.png')) {
             $this->fileTypeIcon = 'fileTypeIcon' . $extension . 'M.png';
         } else {
             foreach (self::$fileTypeGroups as $key => $group) {
                 if (in_array($extension, $group)) {
                     $this->fileTypeIcon = 'fileTypeIcon' . $key . 'M.png';
                     break;
                 }
             }
             if (empty($this->fileTypeIcon)) {
                 $this->fileTypeIcon = 'fileTypeIconDefaultM.png';
             }
         }
     }
     if (!class_exists('StyleManager')) {
         return RELATIVE_WCF_DIR . 'icon/' . $this->fileTypeIcon;
     } else {
         return StyleManager::getStyle()->getIconPath($this->fileTypeIcon);
     }
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:32,代码来源:Attachment.class.php

示例3: handleRequest

 /**
  * Handles a request on the attachment edit form.
  * Deletes old or uploads new attachments.
  */
 public function handleRequest()
 {
     // delete uploaded attachments
     if (isset($_POST['delete']) && is_array($_POST['delete']) && count($_POST['delete'])) {
         // delete selected attachments
         $keys = array_keys($_POST['delete']);
         $this->delete(intval(array_shift($keys)));
     }
     // move uploaded attachments
     if (isset($_POST['attachmentListPositions']) && is_array($_POST['attachmentListPositions'])) {
         $positionChanged = false;
         $positions = ArrayUtil::toIntegerArray($_POST['attachmentListPositions']);
         foreach ($positions as $attachmentID => $position) {
             $attachmentID = intval($attachmentID);
             if (isset($this->attachments[$this->messageID][$attachmentID]) && $this->attachments[$this->messageID][$attachmentID]['showOrder'] != $position) {
                 $this->attachments[$this->messageID][$attachmentID]['showOrder'] = $position;
                 $sql = "UPDATE\twcf" . WCF_N . "_attachment\n\t\t\t\t\t\tSET\tshowOrder = " . $position . "\n\t\t\t\t\t\tWHERE\tattachmentID = " . $attachmentID;
                 WCF::getDB()->registerShutdownUpdate($sql);
                 $positionChanged = true;
             }
         }
         if ($positionChanged) {
             uasort($this->attachments[$this->messageID], array('self', 'compareAttachments'));
         }
     }
     // upload new attachments
     if (isset($_FILES) && count($_FILES) && isset($_FILES['upload'])) {
         // upload new attachments
         for ($x = 0, $y = count($_FILES['upload']['name']); $x < $y; $x++) {
             $attachment = array();
             $attachment['attachmentName'] = $_FILES['upload']['name'][$x];
             if ($attachment['attachmentName']) {
                 $attachment['attachment'] = $_FILES['upload']['tmp_name'][$x];
                 $attachment['attachmentSize'] = $_FILES['upload']['size'][$x];
                 $attachment['sha1Hash'] = sha1_file($attachment['attachment']);
                 $attachment['attachmentExtension'] = StringUtil::toLowerCase(StringUtil::substring($attachment['attachmentName'], StringUtil::lastIndexOf($attachment['attachmentName'], '.') + 1));
                 $attachment['fileType'] = $_FILES['upload']['type'][$x];
                 $attachment['isImage'] = 0;
                 if (strchr($attachment['fileType'], 'image')) {
                     // check mime
                     $attachment['fileType'] = 'application/octet-stream';
                     if (($imageData = @getImageSize($attachment['attachment'])) !== false) {
                         if (strchr($imageData['mime'], 'image')) {
                             $attachment['fileType'] = $imageData['mime'];
                             if ($attachment['fileType'] == 'image/bmp') {
                                 $attachment['fileType'] = 'image/x-ms-bmp';
                             }
                             $attachment['isImage'] = 1;
                         }
                     }
                 }
                 $attachment['showOrder'] = (isset($this->attachments[$this->messageID]) ? count($this->attachments[$this->messageID]) : 0) + 1;
                 if ($this->checkAttachment($attachment['attachment'], $attachment['attachmentName'] . ':' . $attachment['sha1Hash'], $attachment['attachmentName'], $attachment['attachmentSize'], $attachment['attachmentExtension'], $attachment['isImage'])) {
                     $attachment['messageID'] = $this->messageID;
                     $attachment['idHash'] = $this->idHash;
                     $attachment['userID'] = WCF::getUser()->userID;
                     $attachment['uploadTime'] = TIME_NOW;
                     $attachment['thumbnailType'] = '';
                     if ($this->setAttachment($attachment)) {
                         $this->attachmentHashes[count($this->attachmentHashes)] = $attachment['attachmentName'] . ':' . $attachment['sha1Hash'];
                         $attachment['fileTypeIcon'] = $this->getFileTypeIcon($attachment);
                         $this->attachments[$this->messageID][$attachment['attachmentID']] = $attachment;
                     }
                 }
             }
         }
     }
     $this->assign();
     if (count($this->errors)) {
         // throw user exception
         throw new UserInputException('attachments', $this->errors);
     }
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:77,代码来源:AttachmentsEditor.class.php

示例4: getFileTypeIcon

 /**
  * Returns the right file type icon for the given attachment.
  * 
  * @param	array		$data
  * @return	string
  */
 protected static function getFileTypeIcon($data)
 {
     // get file extension
     $extension = StringUtil::firstCharToUpperCase(StringUtil::toLowerCase(StringUtil::substring($data['attachmentName'], StringUtil::lastIndexOf($data['attachmentName'], '.') + 1)));
     // get file type icon
     if (file_exists(WCF_DIR . 'icon/fileTypeIcon' . $extension . 'M.png')) {
         return StyleManager::getStyle()->getIconPath('fileTypeIcon' . $extension . 'M.png');
     } else {
         foreach (self::$fileTypeGroups as $key => $group) {
             if (in_array($extension, $group)) {
                 return StyleManager::getStyle()->getIconPath('fileTypeIcon' . $key . 'M.png');
             }
         }
         return StyleManager::getStyle()->getIconPath('fileTypeIconDefaultM.png');
     }
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:22,代码来源:Attachments.class.php

示例5: getAttachments


//.........这里部分代码省略.........
                 $row['username'] = $tmp['username'];
             }
         } else {
             if (empty($row['username']) && $row['messageType'] == 'pm') {
                 $tmp = WCF::getDB()->getFirstRow('SELECT username FROM wcf' . WCF_N . '_pm WHERE pmID = ' . $row['messageID']);
                 if (isset($tmp['username'])) {
                     $row['username'] = $tmp['username'];
                 }
             }
         }
         if (!empty($row['username'])) {
             $row['username'] = StringUtil::encodeHTML($row['username']);
         } else {
             $row['username'] = '-';
         }
         if (!empty($row['userID'])) {
             $row['username'] = '<a href="index.php?form=UserEdit&userID=' . $row['userID'] . '&packageID=' . PACKAGE_ID . SID_ARG_2ND_NOT_ENCODED . '" title="' . WCF::getLanguage()->get('wcf.acp.user.edit') . '">' . $row['username'] . '</a>';
         }
         // pm
         $ownPM = false;
         if ($row['messageType'] == 'pm' && !empty($row['userID']) && ($row['userID'] == $userID || $row['userID'] == WCF::getUser()->userID)) {
             if (!empty($userID)) {
                 $tUserID = $userID;
             } else {
                 $tUserID = WCF::getUser()->userID;
             }
             $sql = "SELECT COUNT(*) AS cnt" . "\n  FROM wcf" . WCF_N . "_pm" . "\n WHERE pmID = " . $row['messageID'] . "\n   AND userID = " . $tUserID . "\n   AND saveInOutbox != 0";
             $tmp = WCF::getDB()->getFirstRow($sql);
             if (!empty($tmp['cnt'])) {
                 $ownPM = true;
             }
         }
         if (!empty($row['attachmentSize'])) {
             $row['attachmentSize'] = round($row['attachmentSize'] / 1024, 2) . ' kB';
         }
         // message type urls
         $row['messageTypeUrl'] = $row['messageType'];
         if (self::wbbExists() && preg_match('/^(post|pm)$/', $row['messageType'])) {
             if ($row['messageType'] == 'post') {
                 $row['messageTypeUrl'] = '<a href="' . RELATIVE_WBB_DIR . 'index.php?page=Thread&postID=' . $row['messageID'] . '#post' . $row['messageID'] . '" target="' . ATTACHMENTMANAGER_TARGETWINDOW . '">' . $row['messageType'] . '</a>';
             } else {
                 if ($ownPM) {
                     $row['messageTypeUrl'] = '<a href="' . RELATIVE_WBB_DIR . 'index.php?page=PMView&pmID=' . $row['messageID'] . '#pm' . $row['messageID'] . '" target="' . ATTACHMENTMANAGER_TARGETWINDOW . '">' . $row['messageType'] . '</a>';
                 }
             }
         }
         // thumbnails / files
         $maxLength = 0;
         $shortFileName = $row['attachmentName'];
         if ($isACP && ATTACHMENTMANAGER_MAXLENGTHACP > 0) {
             $maxLength = ATTACHMENTMANAGER_MAXLENGTHACP;
         } else {
             if (ATTACHMENTMANAGER_MAXLENGTHUCP > 0) {
                 $maxLength = ATTACHMENTMANAGER_MAXLENGTHUCP;
             }
         }
         if ($maxLength > 0 && strlen($shortFileName) > $maxLength) {
             preg_match('/^(.*)(\\..*)$/', $shortFileName, $match);
             if (isset($match[2])) {
                 $shortFileName = substr($match[1], 0, $maxLength - (strlen($match[2]) + 2)) . '..' . $match[2];
             } else {
                 $shortFileName = substr($shortFileName, 0, $maxLength);
             }
         }
         $row['attachmentUrl'] = '<span title="' . $row['attachmentName'] . '">' . $shortFileName . '</span>';
         if (self::wbbExists()) {
             if ($row['messageType'] == 'pm' && !$ownPM) {
                 $row['attachmentUrl'] = '<span title="' . $row['attachmentName'] . '">' . $shortFileName . '</span>';
             } else {
                 if (!empty($showThumbnails) && !empty($row['isImage'])) {
                     if (!empty($row['thumbnailSize'])) {
                         $row['attachmentUrl'] = '<a href="' . RELATIVE_WBB_DIR . 'index.php?page=Attachment&attachmentID=' . $row['attachmentID'] . '&h=' . $row['sha1Hash'] . '" target="' . ATTACHMENTMANAGER_TARGETWINDOW . '" style="width:' . ATTACHMENT_THUMBNAIL_WIDTH . 'px; height:' . ATTACHMENT_THUMBNAIL_HEIGHT . 'px;"><img src="' . RELATIVE_WBB_DIR . 'index.php?page=Attachment&attachmentID=' . $row['attachmentID'] . '&h=' . $row['sha1Hash'] . '&thumbnail=1" alt="' . $row['attachmentName'] . '" title="' . $row['attachmentName'] . '" style="max-width:' . ATTACHMENT_THUMBNAIL_WIDTH . 'px; max-height:' . ATTACHMENT_THUMBNAIL_HEIGHT . 'px;" /></a>';
                     } else {
                         $row['attachmentUrl'] = '<a href="' . RELATIVE_WBB_DIR . 'index.php?page=Attachment&attachmentID=' . $row['attachmentID'] . '&h=' . $row['sha1Hash'] . '" target="' . ATTACHMENTMANAGER_TARGETWINDOW . '" style="width:' . ATTACHMENT_THUMBNAIL_WIDTH . 'px; height:' . ATTACHMENT_THUMBNAIL_HEIGHT . 'px;"><img src="' . RELATIVE_WBB_DIR . 'index.php?page=Attachment&attachmentID=' . $row['attachmentID'] . '&h=' . $row['sha1Hash'] . '" alt="' . $row['attachmentName'] . '" title="' . $row['attachmentName'] . '" style="max-width:' . ATTACHMENT_THUMBNAIL_WIDTH . 'px; max-height:' . ATTACHMENT_THUMBNAIL_HEIGHT . 'px;" /></a>';
                     }
                 } else {
                     $row['attachmentUrl'] = '<a href="' . RELATIVE_WBB_DIR . 'index.php?page=Attachment&attachmentID=' . $row['attachmentID'] . '&h=' . $row['sha1Hash'] . '" target="' . ATTACHMENTMANAGER_TARGETWINDOW . '" title="' . $row['attachmentName'] . '">' . $shortFileName . '</a>';
                 }
             }
         }
         $icon = RELATIVE_WCF_DIR . 'icon/fileTypeIconDefaultM.png';
         // get file extension
         $extension = StringUtil::firstCharToUpperCase(StringUtil::toLowerCase(StringUtil::substring($row['attachmentName'], StringUtil::lastIndexOf($row['attachmentName'], '.') + 1)));
         // get file type icon
         if (file_exists(WCF_DIR . 'icon/fileTypeIcon' . $extension . 'M.png')) {
             $icon = RELATIVE_WCF_DIR . 'icon/fileTypeIcon' . $extension . 'M.png';
         } else {
             foreach (self::$fileTypeGroups as $key => $group) {
                 if (in_array($extension, $group)) {
                     $icon = RELATIVE_WCF_DIR . 'icon/fileTypeIcon' . $key . 'M.png';
                     break;
                 }
             }
         }
         $row['mimeIcon'] = '<img src="' . $icon . '"' . ($isACP ? ' height="16" width="16"' : '') . ' alt="' . $row['fileType'] . '" title="' . $row['fileType'] . '" />';
         $ret[$i] = $row;
         $i++;
     }
     return $ret;
 }
开发者ID:Maggan22,项目名称:wbb3addons,代码行数:101,代码来源:AttachmentManager.class.php

示例6: handleRequest

 /**
  * Handles a request on the attachment edit form.
  * Deletes old or uploads new attachments.
  */
 public function handleRequest()
 {
     // delete uploaded attachments
     if (isset($_POST['delete']) && is_array($_POST['delete']) && count($_POST['delete'])) {
         // delete selected attachments
         $keys = array_keys($_POST['delete']);
         $this->delete(intval(array_shift($keys)));
     }
     // move uploaded attachments
     if (isset($_POST['attachmentListPositions']) && is_array($_POST['attachmentListPositions'])) {
         $tmpContainerIDArray = count($this->containerIDArray) ? $this->containerIDArray : array(0);
         $positionChanged = false;
         $positions = ArrayUtil::toIntegerArray($_POST['attachmentListPositions']);
         foreach ($positions as $attachmentID => $position) {
             $attachmentID = intval($attachmentID);
             foreach ($tmpContainerIDArray as $containerID) {
                 if (isset($this->attachments[$containerID][$attachmentID]) && $this->attachments[$containerID][$attachmentID]->showOrder != $position) {
                     $this->attachments[$containerID][$attachmentID]->setShowOrder($position);
                     $positionChanged = true;
                 }
             }
         }
         if ($positionChanged) {
             foreach ($tmpContainerIDArray as $containerID) {
                 uasort($this->attachments[$containerID], array('self', 'compareAttachments'));
             }
         }
     }
     // upload new attachments
     $containerID = count($this->containerIDArray) ? reset($this->containerIDArray) : 0;
     if (isset($_FILES) && count($_FILES) && isset($_FILES['upload'])) {
         // upload new attachments
         for ($x = 0, $y = count($_FILES['upload']['name']); $x < $y; $x++) {
             $attachmentData = array();
             $attachmentData['attachmentName'] = $_FILES['upload']['name'][$x];
             if ($attachmentData['attachmentName']) {
                 $tmpFile = $_FILES['upload']['tmp_name'][$x];
                 $attachmentData['attachmentSize'] = $_FILES['upload']['size'][$x];
                 $attachmentData['sha1Hash'] = @sha1_file($tmpFile);
                 $fileExtension = StringUtil::toLowerCase(StringUtil::substring($attachmentData['attachmentName'], StringUtil::lastIndexOf($attachmentData['attachmentName'], '.') + 1));
                 $attachmentData['fileType'] = $_FILES['upload']['type'][$x];
                 $attachmentData['isImage'] = 0;
                 if (strchr($attachmentData['fileType'], 'image')) {
                     // check mime
                     $attachmentData['fileType'] = 'application/octet-stream';
                     if (($imageData = @getImageSize($tmpFile)) !== false) {
                         if (strchr($imageData['mime'], 'image')) {
                             $attachmentData['fileType'] = $imageData['mime'];
                             if ($attachmentData['fileType'] == 'image/bmp') {
                                 $attachmentData['fileType'] = 'image/x-ms-bmp';
                             }
                             $attachmentData['isImage'] = 1;
                         }
                     }
                 }
                 $attachmentData['showOrder'] = (isset($this->attachments[$containerID]) ? count($this->attachments[$containerID]) : 0) + 1;
                 if ($this->checkAttachment($tmpFile, $attachmentData['attachmentName'] . ':' . $attachmentData['sha1Hash'], $attachmentData['attachmentName'], $attachmentData['attachmentSize'], $fileExtension, $attachmentData['isImage'])) {
                     $attachmentData['packageID'] = $this->packageID;
                     $attachmentData['containerID'] = $containerID;
                     $attachmentData['containerType'] = $this->containerType;
                     $attachmentData['idHash'] = $this->idHash;
                     $attachmentData['userID'] = WCF::getUser()->userID;
                     $attachmentData['uploadTime'] = TIME_NOW;
                     $attachmentData['thumbnailType'] = '';
                     $attachmentData['width'] = $attachmentData['height'] = 0;
                     if ($attachmentData['isImage']) {
                         list($width, $height, ) = @getImagesize($tmpFile);
                         $attachmentData['width'] = $width;
                         $attachmentData['height'] = $height;
                     }
                     // save attachment
                     if ($attachment = AttachmentEditor::create($tmpFile, $attachmentData)) {
                         $this->attachmentHashes[count($this->attachmentHashes)] = $attachmentData['attachmentName'] . ':' . $attachmentData['sha1Hash'];
                         $this->attachments[$containerID][$attachment->attachmentID] = $attachment;
                         // save thumbnails
                         if (ATTACHMENT_ENABLE_THUMBNAILS && $attachment->isImage) {
                             $attachment->createThumbnail($this->thumbnailWidth, $this->thumbnailHeight, $this->addSourceInfo, $this->useEmbedded);
                         }
                     }
                 }
             }
         }
     }
     $this->assign();
     if (count($this->errors)) {
         // throw user exception
         throw new UserInputException('attachments', $this->errors);
     }
 }
开发者ID:joaocustodio,项目名称:EmuDevstore-1,代码行数:93,代码来源:MessageAttachmentListEditor.class.php


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