本文整理汇总了PHP中XenForo_Template_Helper_Core::helperSnippet方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Template_Helper_Core::helperSnippet方法的具体用法?PHP XenForo_Template_Helper_Core::helperSnippet怎么用?PHP XenForo_Template_Helper_Core::helperSnippet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_Template_Helper_Core
的用法示例。
在下文中一共展示了XenForo_Template_Helper_Core::helperSnippet方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _importMedia
protected function _importMedia(array $item, array $options)
{
$sDb = $this->_sourceDb;
$xfDb = $this->_xfDb;
if (!$this->_fileRoot) {
$this->_fileRoot = $sDb->fetchOne('SELECT setting FROM ' . $this->_prefix . 'settings WHERE varname = \'datafull\'');
}
$originalFilePath = sprintf('%s/%d/%s', $this->_fileRoot, $item['cat'], $item['bigimage']);
if (!file_exists($originalFilePath)) {
return false;
}
$xenOptions = XenForo_Application::getOptions();
$imageExtensions = preg_split('/\\s+/', trim($xenOptions->xengalleryImageExtensions));
$videoExtensions = preg_split('/\\s+/', trim($xenOptions->xengalleryVideoExtensions));
$extension = XenForo_Helper_File::getFileExtension($originalFilePath);
if (in_array($extension, $imageExtensions)) {
$mediaType = 'image_upload';
} else {
if (in_array($extension, $videoExtensions)) {
$mediaType = 'video_upload';
} else {
return false;
}
}
$tempFile = tempnam(XenForo_Helper_File::getTempDir(), 'xfmg');
copy($originalFilePath, $tempFile);
$model = $this->_getMediaGalleryImportersModel();
$albumId = 0;
$categoryId = 0;
$privacy = 'public';
if ($item['cattype'] == 'a') {
$albumId = $model->mapAlbumId($item['cat']);
$privacy = $item['private'] == 'yes' ? 'private' : 'public';
} elseif ($item['cattype'] == 'c') {
$categoryId = $model->mapCategoryId($item['cat']);
$privacy = 'category';
}
$user = $xfDb->fetchRow('
SELECT user_id, username
FROM xf_user
WHERE user_id = ?
', $item['userid']);
if (!$user) {
return false;
}
$xengalleryMedia = array('media_title' => $this->_convertToUtf8($item['title'], true), 'media_description' => XenForo_Template_Helper_Core::helperSnippet($this->_convertToUtf8($item['description'], true), 0, array('stripHtml' => true)), 'media_date' => $item['date'], 'last_edit_date' => $item['lastpost'], 'last_comment_date' => $item['lastpost'], 'media_type' => $mediaType, 'media_state' => 'visible', 'album_id' => $albumId, 'category_id' => $categoryId, 'media_privacy' => $privacy, 'attachment_id' => 0, 'user_id' => $user['user_id'], 'username' => $user['username'], 'ip_id' => $model->getLatestIpIdFromUserId($user['user_id']), 'likes' => 0, 'like_users' => array(), 'comment_count' => $item['numcom'], 'rating_count' => 0, 'media_view_count' => $item['views']);
$xfAttachment = array('data_id' => 0, 'content_type' => 'xengallery_media', 'content_id' => 0, 'attach_date' => $item['date'], 'temp_hash' => '', 'unassociated' => 0, 'view_count' => $item['views']);
$xfAttachmentData = array('user_id' => $user['user_id'], 'upload_date' => $item['date'], 'filename' => $item['bigimage'], 'attach_count' => 1);
$importedMediaId = $model->importMedia($item['id'], $tempFile, '', $xengalleryMedia, $xfAttachment, $xfAttachmentData);
@unlink($tempFile);
return $importedMediaId;
}
示例2: _importCategory
protected function _importCategory(array $category, array $options)
{
$model = $this->_getMediaGalleryImportersModel();
$xengalleryCategory = array('category_title' => $this->_convertToUtf8($category['title'], true), 'category_description' => XenForo_Template_Helper_Core::helperSnippet($this->_convertToUtf8($category['description'], true), 0, array('stripHtml' => true)), 'upload_user_groups' => $category['hasimages'] ? unserialize('a:1:{i:0;i:-1;}') : unserialize('a:0:{}'), 'view_user_groups' => unserialize('a:1:{i:0;i:-1;}'), 'allowed_types' => unserialize('a:1:{i:0;s:3:"all";}'), 'parent_category_id' => $category['parent'], 'display_order' => $category['displayorder'], 'category_breadcrumb' => unserialize('a:0:{}'), 'depth' => 0, 'category_media_count' => $category['imagecount'], 'field_cache' => unserialize('a:0:{}'));
$importedCategoryId = $model->importCategory($category['catid'], $xengalleryCategory);
return $importedCategoryId;
}
示例3: _importMedia
protected function _importMedia(array $item, array $options)
{
$originalFilePath = $this->_config['ipboard_path'] . '/uploads/' . $item['image_directory'] . '/' . $item['image_masked_file_name'];
if (!file_exists($originalFilePath)) {
return false;
}
$tempFile = tempnam(XenForo_Helper_File::getTempDir(), 'xfmg');
copy($originalFilePath, $tempFile);
/** @var XenGallery_Model_Album $albumModel */
$albumModel = XenForo_Model::create('XenGallery_Model_Album');
$model = $this->_getMediaGalleryImportersModel();
$mediaPrivacy = 'private';
$albumId = 0;
$categoryId = 0;
if ($item['image_album_id'] > 0) {
$albumId = $model->mapAlbumId($item['image_album_id']);
$permission = $albumModel->getUserAlbumPermission($albumId, 'view');
if ($permission) {
$mediaPrivacy = $permission['access_type'];
}
} else {
if ($item['image_album_id'] == 0 && $item['image_category_id'] > 0) {
$categoryId = $model->mapCategoryId($item['image_category_id']);
$mediaPrivacy = 'category';
}
}
$userId = $this->_userIdMap[$item['image_member_id']];
$xengalleryMedia = array('media_title' => $this->_convertToUtf8($item['image_caption'], true), 'media_description' => XenForo_Template_Helper_Core::helperSnippet($this->_convertToUtf8($item['image_description'], true), 0, array('stripHtml' => true)), 'media_date' => $item['image_date'], 'last_edit_date' => $item['image_date'], 'last_comment_date' => $item['image_last_comment'], 'media_type' => 'image_upload', 'media_state' => 'visible', 'album_id' => $albumId, 'category_id' => $categoryId, 'media_privacy' => $mediaPrivacy, 'attachment_id' => 0, 'user_id' => $userId, 'username' => $item['name'], 'ip_id' => $model->getLatestIpIdFromUserId($userId), 'likes' => 0, 'like_users' => array(), 'comment_count' => $item['image_comments'], 'rating_count' => 0, 'media_view_count' => $item['image_views']);
$xfAttachment = array('data_id' => 0, 'content_type' => 'xengallery_media', 'content_id' => 0, 'attach_date' => $item['image_date'], 'temp_hash' => '', 'unassociated' => 0, 'view_count' => $item['image_views']);
$xfAttachmentData = array('user_id' => $userId, 'upload_date' => $item['image_date'], 'filename' => utf8_substr($this->_convertToUtf8($item['image_file_name']), 0, 100), 'attach_count' => 1);
$importedMediaId = $model->importMedia($item['image_id'], $tempFile, '', $xengalleryMedia, $xfAttachment, $xfAttachmentData);
@unlink($tempFile);
return $importedMediaId;
}
示例4: getContentTitle
public function getContentTitle(array $content)
{
return XenForo_Template_Helper_Core::helperSnippet($content['message'], 150, array('stripQuote' => true));
}