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


PHP UTIL_File类代码示例

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


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

示例1: addTemplate

 public function addTemplate($fileName, $roleIds = null, $default = false)
 {
     $canvasWidth = self::CANVAS_WIDTH;
     $canvasHeight = $this->config['cover_height'];
     $coverImage = new UTIL_Image($fileName);
     $imageHeight = $coverImage->getHeight();
     $imageWidth = $coverImage->getWidth();
     $css = array('width' => 'auto', 'height' => 'auto');
     $tmp = $canvasWidth * $imageHeight / $imageWidth;
     if ($tmp >= $canvasHeight) {
         $css['width'] = '100%';
     } else {
         $css['height'] = '100%';
     }
     $template = new UHEADER_BOL_Template();
     $extension = UTIL_File::getExtension($fileName);
     $template->file = uniqid('template-') . '.' . $extension;
     $template->default = $default;
     $template->timeStamp = time();
     $dimensions = array('height' => $imageHeight, 'width' => $imageWidth);
     $template->setSettings(array('dimensions' => $dimensions, 'css' => $css, 'canvas' => array('width' => $canvasWidth, 'height' => $canvasHeight), 'position' => array('top' => 0, 'left' => 0)));
     $this->service->saveTemplate($template);
     if ($roleIds !== null) {
         $this->service->saveRoleIdsForTemplateId($template->id, $roleIds);
     }
     $templatePath = $this->service->getTemplatePath($template);
     OW::getStorage()->copyFile($fileName, $templatePath);
 }
开发者ID:vazahat,项目名称:dudex,代码行数:28,代码来源:templates_bridge.php

示例2: uploadTmpAvatar

 public function uploadTmpAvatar($file)
 {
     if (isset($file)) {
         $lang = OW::getLanguage();
         if (!UTIL_File::validateImage($file['name'])) {
             return array('result' => false, 'error' => $lang->text('base', 'not_valid_image'));
         }
         if (!empty($file['error'])) {
             $message = BOL_FileService::getInstance()->getUploadErrorMessage($file['error']);
         }
         if (!empty($message)) {
             return array('result' => false, 'error' => $message);
         }
         $filesize = OW::getConfig()->getValue('base', 'avatar_max_upload_size');
         if (empty($file['size']) || $filesize * 1024 * 1024 < $file['size']) {
             $message = OW::getLanguage()->text('base', 'upload_file_max_upload_filesize_error');
             return array('result' => false, 'error' => $message);
         }
         $avatarService = BOL_AvatarService::getInstance();
         $key = $avatarService->getAvatarChangeSessionKey();
         $uploaded = $avatarService->uploadUserTempAvatar($key, $file['tmp_name']);
         if (!$uploaded) {
             return array('result' => false, 'error' => $lang->text('base', 'upload_avatar_faild'));
         }
         $url = $avatarService->getTempAvatarUrl($key, 3);
         return array('result' => true, 'url' => $url);
     }
     return array('result' => false);
 }
开发者ID:ZyXelP,项目名称:oxwall,代码行数:29,代码来源:upload_tmp_avatar_trait.php

示例3: import

 public function import($params)
 {
     $importDir = $params['importDir'];
     $txtFile = $importDir . 'configs.txt';
     // import configs
     if (file_exists($txtFile)) {
         $string = file_get_contents($txtFile);
         $configs = json_decode($string, true);
     }
     if (!$configs) {
         return;
     }
     $attachmentService = FORUM_BOL_PostAttachmentService::getInstance();
     $attDir = OW::getPluginManager()->getPlugin('forum')->getUserFilesDir();
     $attachments = $attachmentService->findAllAttachments();
     if (!$attachments) {
         return;
     }
     foreach ($attachments as $file) {
         OW::getDbo()->query("SELECT 1 ");
         $ext = UTIL_File::getExtension($file->fileName);
         $path = $attachmentService->getAttachmentFilePath($file->id, $file->hash, $ext);
         $fileName = str_replace($attDir, '', $path);
         $content = file_get_contents($configs['url'] . '/' . $fileName);
         if (mb_strlen($content)) {
             OW::getStorage()->fileSetContent($path, $content);
         }
     }
 }
开发者ID:vazahat,项目名称:dudex,代码行数:29,代码来源:import.php

示例4: processCleanUp

 public function processCleanUp()
 {
     $configs = OW::getConfig()->getValues('cacheextreme');
     //clean template cache
     if ($configs['template_cache']) {
         OW_ViewRenderer::getInstance()->clearCompiledTpl();
     }
     //clean db backend cache
     if ($configs['backend_cache']) {
         OW::getCacheManager()->clean(array(), OW_CacheManager::CLEAN_ALL);
     }
     //clean themes static contents cache
     if ($configs['theme_static']) {
         OW::getThemeManager()->getThemeService()->processAllThemes();
     }
     //clean plugins static contents cache
     if ($configs['plugin_static']) {
         $pluginService = BOL_PluginService::getInstance();
         $activePlugins = $pluginService->findActivePlugins();
         /* @var $pluginDto BOL_Plugin */
         foreach ($activePlugins as $pluginDto) {
             $pluginStaticDir = OW_DIR_PLUGIN . $pluginDto->getModule() . DS . 'static' . DS;
             if (file_exists($pluginStaticDir)) {
                 $staticDir = OW_DIR_STATIC_PLUGIN . $pluginDto->getModule() . DS;
                 if (file_exists($staticDir)) {
                     UTIL_File::removeDir($staticDir);
                 }
                 mkdir($staticDir);
                 chmod($staticDir, 0777);
                 UTIL_File::copyDir($pluginStaticDir, $staticDir);
             }
         }
     }
 }
开发者ID:vazahat,项目名称:dudex,代码行数:34,代码来源:service.php

示例5: includeStaticFile

 public function includeStaticFile($file)
 {
     $document = OW::getDocument();
     $staticUrl = $this->plugin->getStaticUrl();
     $ext = UTIL_File::getExtension($file);
     $file .= "?" . $this->plugin->getDto()->build;
     switch ($ext) {
         case "css":
             $document->addStyleSheet($staticUrl . $file);
             break;
         case "js":
             $document->addScript($staticUrl . $file);
             break;
     }
 }
开发者ID:vazahat,项目名称:dudex,代码行数:15,代码来源:plugin.php

示例6: addFile

 public function addFile(MAILBOX_BOL_FileUpload $dto, $filePath)
 {
     $ext = UTIL_File::getExtension($dto->fileName);
     if (!$this->fileExtensionIsAllowed($ext) && !file_exists($filePath)) {
         return false;
     }
     $uploadPath = $this->getUploadFilePath($dto->hash, $ext);
     $dto->filePath = $uploadPath;
     $this->saveOrUpdate($dto);
     $attId = $dto->id;
     if (move_uploaded_file($filePath, $uploadPath)) {
         @chmod($uploadPath, 0666);
         return true;
     } else {
         $this->uploadFileDao->deleteById($attId);
         return false;
     }
 }
开发者ID:vazahat,项目名称:dudex,代码行数:18,代码来源:file_upload_service.php

示例7: renderInput

 /**
  * @see FormElement::renderInput()
  *
  * @param array $params
  * @return string
  */
 public function renderInput($params = null)
 {
     parent::renderInput($params);
     $fileElementId = $this->getId() . '_file';
     $entityId = $this->getValue();
     if (empty($entityId)) {
         $entityId = uniqid('upload');
     }
     $iframeUrl = OW::getRouter()->urlFor('MAILBOX_CTRL_Mailbox', 'fileUpload', array('entityId' => $entityId, 'formElementId' => $fileElementId));
     $attachFileHtml = '<div id="file_attachment" class="ow_mailbox_attachment">
                            <span class="ow_mailbox_attachment_icon ow_ic_attach ">&nbsp;</span>
                            <a class="file" href="javascript://"></a> (<span class="filesize"></span>)
                            <a rel="40" class="ow_delete_attachment ow_lbutton ow_hidden" href="javascript://" style="display: none;">' . OW::getLanguage()->text('mailbox', 'attache_file_delete_button') . '</a>
                        </div>';
     $fileList = array();
     if (!empty($entityId)) {
         $fileService = MAILBOX_BOL_FileUploadService::getInstance();
         $uploadFileDtoList = $fileService->findUploadFileList($entityId);
         foreach ($uploadFileDtoList as $uploadFileDto) {
             $file = array();
             $file['hash'] = $uploadFileDto->hash;
             $file['filesize'] = round($uploadFileDto->fileSize / 1024, 2) . 'Kb';
             $file['filename'] = $uploadFileDto->fileName;
             $file['fileUrl'] = $fileService->getUploadFileUrl($uploadFileDto->hash, UTIL_File::getExtension($uploadFileDto->fileName));
             $fileList[] = $file;
         }
     }
     $params = array('elementId' => $fileElementId, 'ajaxResponderUrl' => OW::getRouter()->urlFor("MAILBOX_CTRL_Mailbox", "responder"), 'fileResponderUrl' => $iframeUrl, 'attachFileHtml' => $attachFileHtml, 'fileList' => $fileList);
     $script = "  window.fileUpload_" . $this->getId() . " = new fileUpload(" . json_encode($params) . ");\n                        window.fileUpload_" . $this->getId() . ".init();";
     OW::getDocument()->addOnloadScript($script);
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin("mailbox")->getStaticJsUrl() . 'ajax_file_upload.js');
     $hiddenAttr = array('id' => $this->getId(), 'type' => 'hidden', 'name' => $this->getName(), 'value' => $entityId);
     $fileAttr = $this->attributes;
     unset($fileAttr['name']);
     $fileAttr['id'] = $fileElementId;
     return UTIL_HtmlTag::generateTag('input', $hiddenAttr) . '<span class="' . $fileElementId . '_class">' . UTIL_HtmlTag::generateTag('input', $fileAttr) . '</span>
             <div id="' . $fileElementId . '_list" class="ow_small ow_smallmargin">
                 <div class="ow_attachments_label mailbox_attachments_label ow_hidden">' . OW::getLanguage()->text('mailbox', 'attachments') . ' :</div>
             </div>';
 }
开发者ID:vazahat,项目名称:dudex,代码行数:46,代码来源:ajax_file_upload.php

示例8: createAvatar

 protected function createAvatar($userId)
 {
     $avatarService = BOL_AvatarService::getInstance();
     $path = $_FILES['userPhoto']['tmp_name'];
     if (!file_exists($path)) {
         return false;
     }
     if (!UTIL_File::validateImage($_FILES['userPhoto']['name'])) {
         return false;
     }
     $event = new OW_Event('base.before_avatar_change', array('userId' => $userId, 'avatarId' => null, 'upload' => true, 'crop' => false, 'isModerable' => false));
     OW::getEventManager()->trigger($event);
     $avatarSet = $avatarService->setUserAvatar($userId, $path, array('isModerable' => false, 'trackAction' => false));
     if ($avatarSet) {
         $avatar = $avatarService->findByUserId($userId);
         if ($avatar) {
             $event = new OW_Event('base.after_avatar_change', array('userId' => $userId, 'avatarId' => $avatar->id, 'upload' => true, 'crop' => false));
             OW::getEventManager()->trigger($event);
         }
     }
     return $avatarSet;
 }
开发者ID:hardikamutech,项目名称:loov,代码行数:22,代码来源:join.php

示例9: getFileNameList

 public function getFileNameList($dirPath, $prefix = null, array $fileTypes = null)
 {
     $dirPath = UTIL_File::removeLastDS($dirPath);
     $resultList = array();
     $handle = opendir($dirPath);
     while (($item = readdir($handle)) !== false) {
         if ($item === '.' || $item === '..') {
             continue;
         }
         if ($prefix != null) {
             $prefixLength = strlen($prefix);
             if (!($prefixLength <= strlen($item) && substr($item, 0, $prefixLength) === $prefix)) {
                 continue;
             }
         }
         $path = $dirPath . DS . $item;
         if ($fileTypes === null || is_file($path) && in_array(UTIL_File::getExtension($item), $fileTypes)) {
             $resultList[] = $path;
         }
     }
     closedir($handle);
     return $resultList;
 }
开发者ID:vazahat,项目名称:dudex,代码行数:23,代码来源:file_storage.php

示例10: exportThemes

 private function exportThemes(ZipArchive $za, $archiveDir)
 {
     $currentTheme = OW::getThemeManager()->getSelectedTheme()->getDto();
     $currentThemeDir = OW::getThemeManager()->getSelectedTheme()->getRootDir();
     $currentThemeUserfilesDir = OW_DIR_THEME_USERFILES;
     $this->configs['currentTheme'] = array('name' => $currentTheme->name, 'customCss' => $currentTheme->customCss, 'customCssFileName' => $currentTheme->customCssFileName, 'description' => $currentTheme->description, 'isActive' => $currentTheme->isActive, 'sidebarPosition' => $currentTheme->sidebarPosition, 'title' => $currentTheme->title);
     $controlValueList = OW::getDbo()->queryForList(" SELECT * FROM " . BOL_ThemeControlValueDao::getInstance()->getTableName() . " WHERE themeId = :themeId ", array('themeId' => $currentTheme->id));
     foreach ($controlValueList as $controlValue) {
         $this->configs['controlValue'][$controlValue['themeControlKey']] = $controlValue['value'];
     }
     $za->addEmptyDir($archiveDir . '/' . $currentTheme->getName());
     $this->zipFolder($za, $currentThemeDir, $archiveDir . '/' . $currentTheme->getName() . '/');
     $themesDir = Ow::getPluginManager()->getPlugin('dataexporter')->getPluginFilesDir() . 'themes' . DS;
     UTIL_File::copyDir(OW_DIR_THEME_USERFILES, $themesDir);
     $fileList = Ow::getStorage()->getFileNameList(OW_DIR_THEME_USERFILES);
     mkdir($themesDir, 0777);
     foreach ($fileList as $file) {
         if (Ow::getStorage()->isFile($file)) {
             Ow::getStorage()->copyFileToLocalFS($file, $themesDir . mb_substr($file, mb_strlen(OW_DIR_THEME_USERFILES)));
         }
     }
     $za->addEmptyDir($archiveDir . '/themes');
     $this->zipFolder($za, $themesDir, $archiveDir . '/themes/');
 }
开发者ID:vazahat,项目名称:dudex,代码行数:24,代码来源:export.php

示例11: updateThemeInfo

 /**
  * Update theme info in the [OW_DB_PREFIX]_base_theme table according to the theme.xml file and force theme rebuilding if necessary
  * @param $name
  * @param bool $processTheme
  */
 public function updateThemeInfo($name, $processTheme = false)
 {
     $path = OW_DIR_THEME . $name;
     $xmlFiles = UTIL_File::findFiles($path, array('xml'), 1);
     $themeXml = $xmlFiles[0];
     if (basename($themeXml) === self::MANIFEST_FILE) {
         $xml = simplexml_load_file($themeXml);
         $title = (string) $xml->name;
         $build = (int) $xml->build;
         $developerKey = (string) $xml->developerKey;
         $sidebarPosition = (string) $xml->sidebarPosition;
         if (!in_array(trim($sidebarPosition), array('left', 'right', 'none'))) {
             $sidebarPosition = 'none';
         }
         $xmlArray = (array) $xml;
         unset($xmlArray['masterPages']);
         $description = json_encode($xmlArray);
         if (!trim($title)) {
             $title = $name;
         }
         $theme = $this->findThemeByName($name);
         if (empty($theme)) {
             return;
         }
         $theme->setName($name);
         $theme->setTitle($title);
         $theme->setDescription($description);
         $theme->setSidebarPosition($sidebarPosition);
         $theme->setDeveloperKey($developerKey);
         $this->themeDao->save($theme);
         if ($processTheme) {
             $this->processTheme($theme->getId());
         }
     }
 }
开发者ID:hardikamutech,项目名称:loov,代码行数:40,代码来源:theme_service.php

示例12: deleteAttachmentsByConversationList

 /**
  *
  * @param array $conversationIdList
  * @return array<MAILBOX_BOL_Attachment>
  */
 public function deleteAttachmentsByConversationList(array $conversationIdList)
 {
     $attachmentList = $this->attachmentDao->findAttachmentstByConversationList($conversationIdList);
     foreach ($attachmentList as $attachment) {
         $ext = UTIL_File::getExtension($attachment['fileName']);
         $path = $this->getAttachmentFilePath($attachment['id'], $attachment['hash'], $ext);
         if (OW::getStorage()->removeFile($path)) {
             $this->attachmentDao->deleteById($attachment['id']);
         }
     }
 }
开发者ID:vazahat,项目名称:dudex,代码行数:16,代码来源:conversation_service.php

示例13: process

 /**
  * Uploads avatar
  *
  * @return boolean
  */
 public function process()
 {
     $values = $this->getValues();
     $avatarService = BOL_AvatarService::getInstance();
     $userId = OW::getUser()->getId();
     if (strlen($_FILES['avatar']['tmp_name'])) {
         if (!UTIL_File::validateImage($_FILES['avatar']['name'])) {
             return array('result' => false, 'error' => -1);
         }
         $event = new OW_Event('base.before_avatar_change', array('userId' => $userId, 'upload' => true, 'crop' => false));
         OW::getEventManager()->trigger($event);
         $avatarSet = $avatarService->setUserAvatar($userId, $_FILES['avatar']['tmp_name']);
         $event = new OW_Event('base.after_avatar_change', array('userId' => $userId, 'upload' => true, 'crop' => false));
         OW::getEventManager()->trigger($event);
         $avatar = $avatarService->findByUserId($userId);
         if ($avatar) {
             $avatarService->trackAvatarChangeActivity($userId, $avatar->id);
         }
         return array('result' => $avatarSet);
     } else {
         return array('result' => false);
     }
 }
开发者ID:vazahat,项目名称:dudex,代码行数:28,代码来源:avatar.php

示例14: deleteAttachmentFiles

 public function deleteAttachmentFiles()
 {
     $attachDtoList = $this->attachmentDao->getAttachmentForDelete();
     foreach ($attachDtoList as $attachDto) {
         /* @var $attachDto MAILBOX_BOL_Attachment */
         $ext = UTIL_File::getExtension($attachDto->fileName);
         $attachmentPath = $this->getAttachmentFilePath($attachDto->id, $attachDto->hash, $ext, $attachDto->fileName);
         try {
             OW::getStorage()->removeFile($attachmentPath);
             $this->attachmentDao->deleteById($attachDto->id);
         } catch (Exception $ex) {
         }
     }
 }
开发者ID:tammyrocks,项目名称:mailbox,代码行数:14,代码来源:conversation_service.php

示例15: uninstall

 /**
  * Uninstalls plugin.
  *
  * @param string $key
  */
 public function uninstall($key)
 {
     if (empty($key)) {
         throw new LogicException('');
     }
     $pluginDto = $this->findPluginByKey(trim($key));
     if ($pluginDto === null) {
         throw new LogicException('');
     }
     // trigger event
     $event = new OW_Event(OW_EventManager::ON_BEFORE_PLUGIN_UNINSTALL, array('pluginKey' => $pluginDto->getKey()));
     OW::getEventManager()->trigger($event);
     include OW_DIR_PLUGIN . $pluginDto->getModule() . DS . 'deactivate.php';
     // include plugin custom uninstall script
     include OW_DIR_PLUGIN . $pluginDto->getModule() . DS . 'uninstall.php';
     // delete plugin work dirs
     $dirsToRemove = array(OW_DIR_PLUGINFILES . $pluginDto->getModule(), OW_DIR_PLUGIN_USERFILES . $pluginDto->getModule());
     if (!defined('OW_PLUGIN_XP')) {
         $dirsToRemove[] = OW_DIR_STATIC_PLUGIN . $pluginDto->getModule();
     }
     foreach ($dirsToRemove as $dir) {
         if (file_exists($dir)) {
             UTIL_File::removeDir($dir);
         }
     }
     // remove plugin configs
     OW::getConfig()->deletePluginConfigs($pluginDto->getKey());
     // delete language prefix
     $prefixId = BOL_LanguageService::getInstance()->findPrefixId($pluginDto->getKey());
     if (!empty($prefixId)) {
         BOL_LanguageService::getInstance()->deletePrefix($prefixId, true);
     }
     //delete authorization stuff
     BOL_AuthorizationService::getInstance()->deleteGroup($pluginDto->getKey());
     // drop plugin tables
     $tables = OW::getDbo()->queryForColumnList("SHOW TABLES LIKE '" . str_replace('_', '\\_', OW_DB_PREFIX) . $pluginDto->getKey() . "\\_%'");
     if (!empty($tables)) {
         $query = "DROP TABLE ";
         foreach ($tables as $table) {
             $query .= "`" . $table . "`,";
         }
         $query = substr($query, 0, -1);
         OW::getDbo()->query($query);
     }
     //remove entry in DB
     $this->deletePluginById($pluginDto->getId());
 }
开发者ID:hardikamutech,项目名称:loov,代码行数:52,代码来源:plugin_service.php


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