本文整理汇总了PHP中getNumberingPath函数的典型用法代码示例。如果您正苦于以下问题:PHP getNumberingPath函数的具体用法?PHP getNumberingPath怎么用?PHP getNumberingPath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getNumberingPath函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPoint
/**
* @brief Get the points
*/
function getPoint($member_srl, $from_db = false)
{
$member_srl = abs($member_srl);
// Get from instance memory
if (!$from_db && $this->pointList[$member_srl]) {
return $this->pointList[$member_srl];
}
// Get from file cache
$path = sprintf(_XE_PATH_ . 'files/member_extra_info/point/%s', getNumberingPath($member_srl));
$cache_filename = sprintf('%s%d.cache.txt', $path, $member_srl);
if (!$from_db && file_exists($cache_filename)) {
return $this->pointList[$member_srl] = trim(FileHandler::readFile($cache_filename));
}
// Get from the DB
$args = new stdClass();
$args->member_srl = $member_srl;
$output = executeQuery('point.getPoint', $args);
if (isset($output->data->member_srl)) {
$point = (int) $output->data->point;
$this->pointList[$member_srl] = $point;
if (!is_dir($path)) {
FileHandler::makeDir($path);
}
FileHandler::writeFile($cache_filename, $point);
return $point;
}
return 0;
}
示例2: getThumbnailPath
/**
* Returns the path to the thumbnail image
*
* If a thumbnail does not already exist, it is generated,
* written to disk and then the new path is returned
*
* @param int $width
* @param int $height
* @param string $thumbnail_type
* @return mixed|string
*/
public function getThumbnailPath($width = 80, $height = 0, $thumbnail_type = '')
{
// If signiture height setting is omitted, create a square
if (!$height) {
$height = $width;
}
// get thumbail generation info on the doc module configuration.
if (!in_array($thumbnail_type, array('crop', 'ratio'))) {
$thumbnail_type = 'ratio';
}
// Define thumbnail information
$thumbnail_path = sprintf('files/cache/thumbnails/%s', getNumberingPath($this->unique_identifier, 3));
$thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, $width, $height, $thumbnail_type);
// If thumbnail was already created, return path to it
if (is_file($thumbnail_file)) {
return $thumbnail_file;
}
// Retrieve info about original image: path and extension
$source_file = $this->full_image_path;
$ext = pathinfo($source_file, PATHINFO_EXTENSION);
// Create thumbnail
$output = FileHandler::createImageFile($source_file, $thumbnail_file, $width, $height, $ext, $thumbnail_type);
if ($output) {
return $thumbnail_file;
} else {
return '';
}
}
示例3: memberTransImageName
/**
* @brief If member_srl exists in the div or span, replace to image name or nick image for each member_srl
* */
function memberTransImageName($matches)
{
// If member_srl < 0, then return text only in the body
$member_srl = $matches[3];
if ($member_srl < 0) {
return $matches[5];
}
// If member_srl=o(not a member), return the entire body
if (!$member_srl) {
return $matches[0];
}
$oMemberModel = getModel('member');
$nick_name = $matches[5];
// Initialize global variable for cache
if (!isset($GLOBALS['_transImageNameList'][$member_srl])) {
$GLOBALS['_transImageNameList'][$member_srl] = new stdClass();
}
$_tmp =& $GLOBALS['_transImageNameList'][$member_srl];
// If pre-defined data in the global variables, return it
if (!$_tmp->cached) {
$_tmp->cached = true;
$image_name_file = sprintf('files/member_extra_info/image_name/%s%d.gif', getNumberingPath($member_srl), $member_srl);
$image_mark_file = sprintf('files/member_extra_info/image_mark/%s%d.gif', getNumberingPath($member_srl), $member_srl);
if (file_exists(_XE_PATH_ . $image_name_file)) {
$_tmp->image_name_file = $image_name_file . '?' . date('YmdHis', filemtime(_XE_PATH_ . $image_name_file));
$image_name_file = $_tmp->image_name_file;
} else {
$image_name_file = '';
}
if (file_exists(_XE_PATH_ . $image_mark_file)) {
$_tmp->image_mark_file = $image_mark_file . '?' . date('YmdHis', filemtime(_XE_PATH_ . $image_mark_file));
$image_mark_file = $_tmp->image_mark_file;
} else {
$image_mark_file = '';
}
$site_module_info = Context::get('site_module_info');
$group_image = $oMemberModel->getGroupImageMark($member_srl, $site_module_info->site_srl);
$_tmp->group_image = $group_image;
} else {
$group_image = $_tmp->group_image;
$image_name_file = $_tmp->image_name_file;
$image_mark_file = $_tmp->image_mark_file;
}
// If image name and mark doesn't exist, set the original information
if (!$image_name_file && !$image_mark_file && !$group_image) {
return $matches[0];
}
// check member_config
$config = $oMemberModel->getMemberConfig();
if ($config->image_name == 'Y' && $image_name_file) {
$nick_name = sprintf('<img src="%s%s" alt="id: %s" title="id: %s" style="border:0;vertical-align:middle;margin-right:3px" />', Context::getRequestUri(), $image_name_file, strip_tags($nick_name), strip_tags($nick_name));
}
if ($config->image_mark == 'Y' && $image_mark_file) {
$nick_name = sprintf('<img src="%s%s" alt="id: %s" title="id : %s" style="border:0;vertical-align:middle;margin-right:3px"/>%s', Context::getRequestUri(), $image_mark_file, strip_tags($nick_name), strip_tags($nick_name), $nick_name);
}
if ($group_image) {
$nick_name = sprintf('<img src="%s" style="border:0;max-height:16px;vertical-align:middle;margin-right:3px" alt="%s" title="%s" />%s', $group_image->src, $group_image->title, $group_image->description, $nick_name);
}
return preg_replace('/' . preg_quote($matches[5], '/') . '<\\/' . $matches[6] . '>$/', '', $matches[0]) . $nick_name . '</' . $matches[6] . '>';
}
示例4: getFullPath
/**
* Returns path to full size (original) product image
*
* @return string
*/
public function getFullPath()
{
$image_path = "./files/attach/images/shop/{$this->module_srl}/product-images/{$this->product_srl}/{$this->filename}";
if (is_file($image_path)) {
return $image_path;
}
return "./files/attach/shop/" . getNumberingPath($this->module_srl, 3) . "/img/missingProduct.png";
}
示例5: memberTransImageName
/**
* @brief div 또는 span에 member_번호 가 있을때 해당 회원 번호에 맞는 이미지이름이나 닉이미지를 대체
**/
function memberTransImageName($matches)
{
// 회원번호를 추출하여 0보다 찾으면 본문중 text만 return
$member_srl = $matches[3];
if ($member_srl < 0) {
return $matches[5];
}
$site_module_info = Context::get('site_module_info');
$oMemberModel =& getModel('member');
$group_image = $oMemberModel->getGroupImageMark($member_srl, $site_module_info->site_srl);
// 회원이 아닐경우(member_srl = 0) 본문 전체를 return
$nick_name = $matches[5];
if (!$member_srl) {
return $matches[0];
}
// 전역변수에 미리 설정한 데이터가 있다면 그걸 return
if (!$GLOBALS['_transImageNameList'][$member_srl]->cached) {
$GLOBALS['_transImageNameList'][$member_srl]->cached = true;
$image_name_file = sprintf('files/member_extra_info/image_name/%s%d.gif', getNumberingPath($member_srl), $member_srl);
$image_mark_file = sprintf('files/member_extra_info/image_mark/%s%d.gif', getNumberingPath($member_srl), $member_srl);
if (file_exists($image_name_file)) {
$GLOBALS['_transImageNameList'][$member_srl]->image_name_file = $image_name_file;
} else {
$image_name_file = '';
}
if (file_exists($image_mark_file)) {
$GLOBALS['_transImageNameList'][$member_srl]->image_mark_file = $image_mark_file;
} else {
$image_mark_file = '';
}
} else {
$image_name_file = $GLOBALS['_transImageNameList'][$member_srl]->image_name_file;
$image_mark_file = $GLOBALS['_transImageNameList'][$member_srl]->image_mark_file;
}
// 이미지이름이나 마크가 없으면 원본 정보를 세팅
if (!$image_name_file && !$image_mark_file && !$group_image) {
return $matches[0];
}
if ($image_name_file) {
$nick_name = sprintf('<img src="%s%s" border="0" alt="id: %s" title="id: %s" style="vertical-align:middle;margin-right:3px" />', Context::getRequestUri(), $image_name_file, strip_tags($nick_name), strip_tags($nick_name));
}
if ($image_mark_file) {
$nick_name = sprintf('<img src="%s%s" border="0" alt="id: %s" title="id : %s" style="vertical-align:middle;margin-right:3px"/>%s', Context::getRequestUri(), $image_mark_file, strip_tags($nick_name), strip_tags($nick_name), $nick_name);
}
if ($group_image) {
$nick_name = sprintf('<img src="%s" border="0" style="vertical-align:middle;margin-right:3px"/>%s', $group_image->src, $nick_name);
}
$orig_text = preg_replace('/' . preg_quote($matches[5], '/') . '<\\/' . $matches[6] . '>$/', '', $matches[0]);
return $orig_text . $nick_name . '</' . $matches[6] . '>';
}
示例6: getPoint
/**
* @brief 포인트를 구해옴
**/
function getPoint($member_srl, $from_db = false)
{
$member_srl = abs($member_srl);
$path = sprintf('./files/member_extra_info/point/%s', getNumberingPath($member_srl));
if (!is_dir($path)) {
FileHandler::makeDir($path);
}
$cache_filename = sprintf('%s%d.cache.txt', $path, $member_srl);
if (!$from_db && file_exists($cache_filename)) {
return trim(FileHandler::readFile($cache_filename));
}
// DB에서 가져옴
$args->member_srl = $member_srl;
$output = executeQuery('point.getPoint', $args);
$point = (int) $output->data->point;
FileHandler::writeFile($cache_filename, $point);
return $point;
}
示例7: dispCommunicationNewMessage
/**
* @brief 새 쪽지 보여줌
**/
function dispCommunicationNewMessage()
{
$this->setLayoutFile('popup_layout');
// 로그인이 되어 있지 않으면 오류 표시
if (!Context::get('is_logged')) {
return $this->stop('msg_not_logged');
}
$logged_info = Context::get('logged_info');
$oCommunicationModel =& getModel('communication');
// 새 쪽지를 가져옴
$message = $oCommunicationModel->getNewMessage();
if ($message) {
Context::set('message', $message);
}
// 플래그 삭제
$flag_path = './files/communication_extra_info/new_message_flags/' . getNumberingPath($logged_info->member_srl);
$flag_file = sprintf('%s%s', $flag_path, $logged_info->member_srl);
FileHandler::removeFile($flag_file);
$this->setTemplateFile('new_message');
}
示例8: insertProfileImageFromUrl
private function insertProfileImageFromUrl($member_srl, $url)
{
$oModuleModel =& getModel('module');
$config = $oModuleModel->getModuleConfig('member');
$max_width = $config->profile_image_max_width;
if (!$max_width) {
$max_width = "80";
}
//default 90
$max_height = $config->profile_image_max_height;
if (!$max_height) {
$max_height = "80";
}
//default 20
$target_path = sprintf('files/member_extra_info/profile_image/%s', getNumberingPath($member_srl));
$target_tmpfile = $target_path . "sample.jpg";
FileHandler::makeDir($target_path);
//지정된 URL 로부터 프로필 이미지 가져오기
if (file_exists($target_tmpfile)) {
unlink($target_tmpfile);
}
$this->getProfileImageFromUrl($url, $target_tmpfile);
list($width, $height, $type, $attrs) = @getimagesize($target_tmpfile);
if ($type == 3) {
$ext = 'png';
} elseif ($type == 2) {
$ext = 'jpg';
} else {
$ext = 'gif';
}
$target_filename = sprintf('%s%d.%s', $target_path, $member_srl, $ext);
$target_filename_mask = sprintf('%s%d.%s', $target_path, $member_srl, '*');
array_map('unlink', glob($target_filename_mask));
if ($width > $max_width || $height > $max_height || !$type != 1) {
FileHandler::createImageFile($target_tmpfile, $target_filename, $max_width, $max_height, $ext);
} else {
@copy($target_tmpfile, $target_filename);
}
unlink($target_tmpfile);
}
示例9: getThumbnail
function getThumbnail($file_srl = null, $width = 80, $height = 0, $thumbnail_type = 'crop')
{
$oFileModel = getModel('file');
if (!$file_srl) {
return;
}
if (!$height) {
$height = $width;
}
// Define thumbnail information
$thumbnail_path = sprintf('files/cache/thumbnails/%s', getNumberingPath($file_srl, 3));
$thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, $width, $height, $thumbnail_type);
$thumbnail_url = Context::getRequestUri() . $thumbnail_file;
// Return false if thumbnail file exists and its size is 0. Otherwise, return its path
if (file_exists($thumbnail_file)) {
if (filesize($thumbnail_file) < 1) {
return false;
} else {
return $thumbnail_url;
}
}
// Target File
$source_file = NULL;
$file = $oFileModel->getFile($file_srl);
if ($file) {
$source_file = $file->uploaded_filename;
}
if ($source_file) {
$output = FileHandler::createImageFile($source_file, $thumbnail_file, $width, $height, 'jpg', $thumbnail_type);
}
// Return its path if a thumbnail is successfully genetated
if ($output) {
return $thumbnail_url;
} else {
FileHandler::writeFile($thumbnail_file, '', 'w');
}
return;
}
示例10: deleteCategory
/**
* Delete a category
* @param int $category_srl
* @return object
*/
function deleteCategory($category_srl)
{
$args = new stdClass();
$args->category_srl = $category_srl;
$oDocumentModel = getModel('document');
$category_info = $oDocumentModel->getCategory($category_srl);
// Display an error that the category cannot be deleted if it has a child
$output = executeQuery('document.getChildCategoryCount', $args);
if (!$output->toBool()) {
return $output;
}
if ($output->data->count > 0) {
return new Object(-1, 'msg_cannot_delete_for_child');
}
// Delete a category information
$output = executeQuery('document.deleteCategory', $args);
if (!$output->toBool()) {
return $output;
}
$this->makeCategoryFile($category_info->module_srl);
// remove cache
$page = 0;
while (true) {
$args = new stdClass();
$args->category_srl = $category_srl;
$args->list_count = 100;
$args->page = ++$page;
$output = executeQuery('document.getDocumentList', $args, array('document_srl'));
if ($output->data == array()) {
break;
}
foreach ($output->data as $val) {
Rhymix\Framework\Cache::delete('document_item:' . getNumberingPath($val->document_srl) . $val->document_srl);
}
}
// Update category_srl of the documents in the same category to 0
$args = new stdClass();
$args->target_category_srl = 0;
$args->source_category_srl = $category_srl;
$output = executeQuery('document.updateDocumentCategory', $args);
return $output;
}
示例11: mobileFileUpload
/**
* @brief file upload
**/
function mobileFileUpload()
{
$oFileModel =& getModel('file');
$oFileController =& getController('file');
$oMobileexModel =& getModel('mobileex');
$mobileex_config = $oMobileexModel->getMobileexConfig($this->module_srl);
// after upload set template
$this->setTemplatePath($this->module_path . 'tpl');
$this->setTemplateFile("after_upload");
// file lang load
Context::loadLang('./modules/file/lang');
$module_srl = $this->module_srl;
$file_info = Context::get('Filedata');
$upload_type = Context::get('upload_type');
$upload_target_srl = intval(Context::get('uploadTargetSrl'));
if (!$upload_target_srl) {
$upload_target_srl = intval(Context::get('upload_target_srl'));
}
// mobile document check
if ($upload_target_srl && Context::get('document_srl')) {
$mobile_check = $oMobileexModel->getMobileDocument($upload_target_srl);
if (!$mobile_check->data) {
Context::set('msg', Context::getLang('msg_not_mobile_document'));
return;
}
}
if (!$upload_target_srl) {
$upload_target_srl = getNextSequence();
}
// file exist check
if (!$file_info['tmp_name'] || !is_uploaded_file($file_info['tmp_name'])) {
Context::set('msg', Context::getLang('msg_no_file'));
return;
}
// grant check
$allow_fileupload = $oMobileexModel->getUploadGrant($module_srl, $upload_type);
if (!$allow_fileupload) {
Context::set('msg', Context::getLang('msg_not_fileupload_grant'));
return;
}
// file ext check
$allow_filetype = $oMobileexModel->getAllowedFileType($file_info, $module_srl);
if (!$allow_filetype->allowed) {
$msg = strtoupper(str_replace('.', '', $allow_filetype->file_ext)) . " " . Context::getLang('msg_not_allowed_filetype');
Context::set('msg', $msg);
return;
}
// get file type
$imglist = "GIF|PNG|JPG|JPEG";
if (!eregi(strtoupper(str_replace('.', '', $allow_filetype->file_ext)), $imglist)) {
$is_img = 'N';
} else {
$is_img = 'Y';
}
$img_resize_width = (int) $mobileex_config->img_resize_width;
$img_resize_height = (int) $mobileex_config->img_resize_height;
if ($img_resize_width > 0 || $img_resize_height > 0) {
$img_resize_use = true;
} else {
$img_resize_use = false;
}
if ($is_img == 'N' || $is_img == 'Y' && !$img_resize_use) {
// file size check
$allow_filesize = $oMobileexModel->getAllowedFileSize(filesize($file_info['tmp_name']), $module_srl, $upload_target_srl, $upload_type);
if (!$allow_filesize->allowed_filesize || !$allow_filesize->allowed_attach_size) {
if (!$allow_filesize->allowed_filesize) {
Context::set('msg', Context::getLang('msg_not_allowed_filesize'));
} else {
if (!$allow_filesize->allowed_attach_size) {
Context::set('msg', Context::getLang('msg_not_allowed_attach_size'));
}
}
return;
}
}
//insert file
// A workaround for Firefox upload bug
if (preg_match('/^=\\?UTF-8\\?B\\?(.+)\\?=$/i', $file_info['name'], $match)) {
$file_info['name'] = base64_decode(strtr($match[1], ':', '/'));
}
// upload path
if (preg_match("/\\.(jpe?g|gif|png|wm[va]|mpe?g|avi|swf|flv|mp[1-4]|as[fx]|wav|midi?|moo?v|qt|r[am]{1,2}|m4v)\$/i", $file_info['name'])) {
// direct 파일에 해킹을 의심할 수 있는 확장자가 포함되어 있으면 바로 삭제함
$file_info['name'] = preg_replace('/\\.(php|phtm|html?|cgi|pl|exe|jsp|asp|inc)/i', '$0-x', $file_info['name']);
$file_info['name'] = str_replace(array('<', '>'), array('%3C', '%3E'), $file_info['name']);
$path = sprintf("./files/attach/images/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3));
// special character to '_'
// change to md5 file name. because window php bug. window php is not recognize unicode character file name - by cherryfilter
$ext = substr(strrchr($file_info['name'], '.'), 1);
//$_filename = preg_replace('/[#$&*?+%"\']/', '_', $file_info['name']);
$_filename = md5(crypt(rand(1000000, 900000), rand(0, 100))) . '.' . $ext;
$filename = $path . $_filename;
$idx = 1;
while (file_exists($filename)) {
$filename = $path . preg_replace('/\\.([a-z0-9]+)$/i', '_' . $idx . '.$1', $_filename);
$idx++;
}
//.........这里部分代码省略.........
示例12: setPoint
/**
* @brief 포인트 설정
**/
function setPoint($member_srl, $point, $mode = null)
{
$member_srl = abs($member_srl);
$mode_arr = array('add', 'minus', 'update', 'signup');
if (!$mode || !in_array($mode, $mode_arr)) {
$mode = 'update';
}
// 설정 정보 가져오기
$oMemberModel =& getModel('member');
$oModuleModel =& getModel('module');
$oPointModel =& getModel('point');
$config = $oModuleModel->getModuleConfig('point');
// 기존 포인트 정보를 구함
$prev_point = $oPointModel->getPoint($member_srl, true);
$prev_level = $oPointModel->getLevel($prev_point, $config->level_step);
// 포인트 변경
$args->member_srl = $member_srl;
$args->point = $prev_point;
switch ($mode) {
case 'add':
$args->point += $point;
break;
case 'minus':
$args->point -= $point;
break;
case 'update':
$args->point = $point;
break;
case 'signup':
$args->point = $point;
break;
}
if ($args->point < 0) {
$args->point = 0;
}
$point = $args->point;
// 포인트가 있으면 update, 없으면 insert
$oPointModel =& getModel('point');
if ($oPointModel->isExistsPoint($member_srl)) {
executeQuery("point.updatePoint", $args);
} else {
executeQuery("point.insertPoint", $args);
}
// 새로운 레벨을 구함
$level = $oPointModel->getLevel($point, $config->level_step);
// 기존 레벨과 새로운 레벨이 다르면 포인트 그룹 설정 시도
if ($level != $prev_level) {
// 현재 포인트 대비하여 레벨을 계산하고 레벨에 맞는 그룹 설정을 체크
$point_group = $config->point_group;
// 포인트 그룹 정보가 있을때 시행
if ($point_group && is_array($point_group) && count($point_group)) {
// 기본 그룹을 구함
$default_group = $oMemberModel->getDefaultGroup();
// 제거될 그룹과 새로 부여 받을 그룹을 구함
$del_group_list = array();
$new_group_srls = array();
asort($point_group);
// 포인트 그룹 설정을 돌면서 현재 레벨까지 체크
foreach ($point_group as $group_srl => $target_level) {
if ($config->group_reset != 'N') {
$del_group_list[] = $group_srl;
}
if ($target_level <= $level) {
$new_group_srls[] = $group_srl;
}
}
// 만약 새로운 그룹이 없다면 기본 그룹을 부여 받음
if (!$new_group_srls[0]) {
$new_group_srls[0] = $default_group->group_srl;
}
// 연동 그룹 제거
if ($config->group_reset != 'N' && $del_group_list && count($del_group_list)) {
$del_group_args->member_srl = $member_srl;
$del_group_args->group_srl = implode(',', $del_group_list);
$del_group_output = executeQuery('point.deleteMemberGroup', $del_group_args);
}
// 새로운 그룹을 부여
foreach ($new_group_srls as $group_srl) {
$new_group_args->member_srl = $member_srl;
$new_group_args->group_srl = $group_srl;
executeQuery('member.addMemberToGroup', $new_group_args);
}
}
}
// 캐시 설정
$cache_path = sprintf('./files/member_extra_info/point/%s/', getNumberingPath($member_srl));
FileHandler::makedir($cache_path);
$cache_filename = sprintf('%s%d.cache.txt', $cache_path, $member_srl);
FileHandler::writeFile($cache_filename, $point);
return $output;
}
示例13: dispCommunicationNewMessage
/**
* display a new message
* @return void|Object (void : success, Object : fail)
*/
function dispCommunicationNewMessage()
{
$this->setLayoutPath('./common/tpl/');
$this->setLayoutFile('popup_layout');
// Error appears if not logged-in
if (!Context::get('is_logged')) {
return $this->stop('msg_not_logged');
}
$logged_info = Context::get('logged_info');
$oCommunicationModel = getModel('communication');
// get a new message
$columnList = array('message_srl', 'member_srl', 'nick_name', 'title', 'content', 'sender_srl');
$message = $oCommunicationModel->getNewMessage($columnList);
if ($message) {
stripEmbedTagForAdmin($message->content, $message->sender_srl);
Context::set('message', $message);
}
// Delete a flag
$flag_path = './files/communication_extra_info/new_message_flags/' . getNumberingPath($logged_info->member_srl);
$flag_file = sprintf('%s%s', $flag_path, $logged_info->member_srl);
FileHandler::removeFile($flag_file);
$this->setTemplateFile('new_message');
}
示例14: getThumbnail
function getThumbnail($width = 80, $height = 0, $thumbnail_type = '')
{
// Return false if the document doesn't exist
if (!$this->document_srl) {
return;
}
if ($this->isSecret() && !$this->isGranted()) {
return;
}
// If not specify its height, create a square
if (!$height) {
$height = $width;
}
if ($this->get('content')) {
$content = $this->get('content');
} else {
$args = new stdClass();
$args->document_srl = $this->document_srl;
$output = executeQuery('document.getDocument', $args);
$content = $output->data->content;
}
// Return false if neither attachement nor image files in the document
if (!$this->get('uploaded_count') && !preg_match("!<img!is", $content)) {
return;
}
// Get thumbnai_type information from document module's configuration
if (!in_array($thumbnail_type, array('crop', 'ratio'))) {
$config = $GLOBALS['__document_config__'];
if (!$config) {
$oDocumentModel = getModel('document');
$config = $oDocumentModel->getDocumentConfig();
$GLOBALS['__document_config__'] = $config;
}
$thumbnail_type = $config->thumbnail_type ?: 'crop';
}
// Define thumbnail information
$thumbnail_path = sprintf('files/thumbnails/%s', getNumberingPath($this->document_srl, 3));
$thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, $width, $height, $thumbnail_type);
$thumbnail_lockfile = sprintf('%s%dx%d.%s.lock', $thumbnail_path, $width, $height, $thumbnail_type);
$thumbnail_url = Context::getRequestUri() . $thumbnail_file;
// Return false if thumbnail file exists and its size is 0. Otherwise, return its path
if (file_exists($thumbnail_file) || file_exists($thumbnail_lockfile)) {
if (filesize($thumbnail_file) < 1) {
return FALSE;
} else {
return $thumbnail_url . '?' . date('YmdHis', filemtime($thumbnail_file));
}
}
// Create lockfile to prevent race condition
FileHandler::writeFile($thumbnail_lockfile, '', 'w');
// Target File
$source_file = null;
$is_tmp_file = false;
// Find an iamge file among attached files if exists
if ($this->hasUploadedFiles()) {
$file_list = $this->getUploadedFiles();
$first_image = null;
foreach ($file_list as $file) {
if ($file->direct_download !== 'Y') {
continue;
}
if ($file->cover_image === 'Y' && file_exists($file->uploaded_filename)) {
$source_file = $file->uploaded_filename;
break;
}
if ($first_image) {
continue;
}
if (preg_match("/\\.(jpe?g|png|gif|bmp)\$/i", $file->source_filename)) {
if (file_exists($file->uploaded_filename)) {
$first_image = $file->uploaded_filename;
}
}
}
if (!$source_file && $first_image) {
$source_file = $first_image;
}
}
// If not exists, file an image file from the content
if (!$source_file) {
preg_match_all("!<img\\s[^>]*?src=(\"|')([^\"' ]*?)(\"|')!is", $content, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$target_src = htmlspecialchars_decode(trim($match[2]));
if (preg_match('/\\/(common|modules|widgets|addons|layouts)\\//i', $target_src)) {
continue;
} else {
if (!preg_match('/^https?:\\/\\//i', $target_src)) {
$target_src = Context::getRequestUri() . $target_src;
}
$tmp_file = sprintf('./files/cache/tmp/%d', md5(rand(111111, 999999) . $this->document_srl));
if (!is_dir('./files/cache/tmp')) {
FileHandler::makeDir('./files/cache/tmp');
}
FileHandler::getRemoteFile($target_src, $tmp_file);
if (!file_exists($tmp_file)) {
continue;
} else {
if ($is_img = @getimagesize($tmp_file)) {
list($_w, $_h, $_t, $_a) = $is_img;
} else {
//.........这里部分代码省略.........
示例15: deleteModuleDocument
/**
* Delete all documents of the module
* @param int $module_srl
* @return object
*/
function deleteModuleDocument($module_srl)
{
$args = new stdClass();
$args->module_srl = $module_srl;
$oDocumentModel = getModel('document');
$args->module_srl = $module_srl;
$document_list = $oDocumentModel->getDocumentList($args);
$documents = $document_list->data;
$output = executeQuery('document.deleteModuleDocument', $args);
if (is_array($documents)) {
foreach ($documents as $oDocument) {
$document_srl_list[] = $oDocument->document_srl;
}
}
//remove from cache
$oCacheHandler = CacheHandler::getInstance('object');
if ($oCacheHandler->isSupport()) {
if (is_array($document_srl_list)) {
foreach ($document_srl_list as $document_srl) {
$cache_key_item = 'document_item:' . getNumberingPath($document_srl) . $document_srl;
$oCacheHandler->delete($cache_key_item);
}
}
}
return $output;
}