本文整理汇总了PHP中XenForo_Model类的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Model类的具体用法?PHP XenForo_Model怎么用?PHP XenForo_Model使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XenForo_Model类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getAttachment
protected function _getAttachment(XenForo_Model $model)
{
if ($this->_attachment === null) {
$this->_attachment = $model->getModelFromCache('XenForo_Model_Attachment')->getAttachmentById($this->_mediaDw->get('attachment_id'));
}
return $this->_attachment;
}
示例2: _getVideoData
protected function _getVideoData(XenForo_Model $model)
{
if ($this->_videoData === null) {
$this->_videoData = $model->getModelFromCache('sonnb_XenGallery_Model_VideoData')->getDataByDataId($this->_videoDw->get('content_data_id'));
}
return $this->_videoData;
}
示例3: _getPhotoData
protected function _getPhotoData(XenForo_Model $model)
{
if ($this->_photoData === null) {
$dataId = $this->_photoDw->get('photo_data_id');
if (empty($dataId)) {
// sonnb - XenGallery v2.0.0
$dataId = $this->_photoDw->get('content_data_id');
}
$this->_photoData = $model->getModelFromCache('sonnb_XenGallery_Model_PhotoData')->getDataByDataId($dataId);
}
return $this->_photoData;
}
示例4: getDescription
public function getDescription(XenForo_Model $model)
{
$resource = $this->_resourceDw->getMergedData();
$resource = $model->getModelFromCache('XenResource_Model_Resource')->prepareResource($resource, null, $this->getViewingUser());
$resource = $model->getModelFromCache('XenResource_Model_Resource')->prepareResourceCustomFields($resource, array(), $this->getViewingUser());
$params = array('resource' => $resource);
if ($resource['user_id'] == $this->getViewingUserId()) {
return $this->_getSimulationTemplate('bdsocialshare_description_xenresource_resource', $params);
} else {
return $this->_getSimulationTemplate('bdsocialshare_description_xenresource_resource_aut', $params);
}
}
示例5: getVisibleReportsForUser
/**
* Gets the visible reports of this content type for the viewing user.
*
* @see XenForo_ReportHandler_Abstract:getVisibleReportsForUser()
*/
public function getVisibleReportsForUser(array $reports, array $viewingUser)
{
$reportsByUser = array();
foreach ($reports as $reportId => $report) {
$info = unserialize($report['content_info']);
$reportsByUser[$info['profile_user_id']][] = $reportId;
}
$users = XenForo_Model::create('XenForo_Model_User')->getUsersByIds(array_keys($reportsByUser), array('join' => XenForo_Model_User::FETCH_USER_PRIVACY, 'followingUserId' => $viewingUser['user_id']));
$userProfileModel = XenForo_Model::create('XenForo_Model_UserProfile');
foreach ($reportsByUser as $userId => $userReports) {
$remove = false;
if (isset($users[$userId]) && !$userProfileModel->canViewFullUserProfile($users[$userId], $null, $viewingUser)) {
$remove = true;
} else {
if (!XenForo_Permission::hasPermission($viewingUser['permissions'], 'profilePost', 'editAny') && !XenForo_Permission::hasPermission($viewingUser['permissions'], 'profilePost', 'deleteAny')) {
$remove = true;
}
}
if ($remove) {
foreach ($userReports as $reportId) {
unset($reports[$reportId]);
}
}
}
return $reports;
}
示例6: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('position' => 0, 'batch' => 100, 'delete' => false), $data);
$data['batch'] = max(1, $data['batch']);
/* @var $statsModel XenForo_Model_Stats */
$statsModel = XenForo_Model::create('XenForo_Model_Stats');
if ($data['position'] == 0) {
// delete old stats cache if required
if (!empty($data['delete'])) {
$statsModel->deleteStats();
}
// an appropriate date from which to start... first thread, or earliest user reg?
$data['position'] = min(XenForo_Model::create('XenForo_Model_Thread')->getEarliestThreadDate(), XenForo_Model::create('XenForo_Model_User')->getEarliestRegistrationDate());
// start on a 24 hour increment point
$data['position'] = $data['position'] - $data['position'] % 86400;
} else {
if ($data['position'] > XenForo_Application::$time) {
return true;
}
}
$endPosition = $data['position'] + $data['batch'] * 86400;
$statsModel->buildStatsData($data['position'], $endPosition);
$data['position'] = $endPosition;
$actionPhrase = new XenForo_Phrase('rebuilding');
$typePhrase = new XenForo_Phrase('daily_statistics');
$status = sprintf('%s... %s (%s)', $actionPhrase, $typePhrase, XenForo_Locale::date($data['position'], 'absolute'));
return $data;
}
示例7: getModelFromCache
/**
* Gets the specified model object from the cache. If it does not exist,
* it will be instantiated.
*
* @param string $class Name of the class to load
*
* @return XenForo_Model
*/
public function getModelFromCache($class)
{
if (!isset($this->_modelCache[$class])) {
$this->_modelCache[$class] = XenForo_Model::create($class);
}
return $this->_modelCache[$class];
}
示例8: getUser
public function getUser()
{
$visitor = XenForo_Visitor::getInstance();
$userModel = XenForo_Model::create('XenForo_Model_User');
$userInfo = $userModel->getFullUserById($visitor->getUserId());
return $userInfo;
}
示例9: _getThreadModel
/**
*
* @return XenForo_Model_Thread
*/
protected function _getThreadModel()
{
if (!$this->_threadModel) {
$this->_threadModel = XenForo_Model::create('XenForo_Model_Thread');
}
return $this->_threadModel;
}
示例10: runOften
public static function runOften()
{
$feeds = XenForo_Model::create('DigitalPointSocialBar_Model_SocialBar')->getSlugsFromOptions();
shuffle($feeds);
// randomize order in case someone has absurd number of lists attached to forums (would need to be more than 180 unique) to work around Twitter API limits
$cacheObject = XenForo_Application::getCache();
$twitter = DigitalPointSocialBar_Helper_Twitter::getService(XenForo_Application::getOptions()->dpTwitterAccessToken, XenForo_Application::getOptions()->dpTwitterAccessTokenSecret, XenForo_Application::getOptions()->dpTwitterUsername);
// forum specific feeds
if ($feeds) {
foreach ($feeds as $slug) {
$tweets_array = array();
$results = $twitter->listsStatuses(array('slug' => $slug, 'owner_screen_name' => XenForo_Application::getOptions()->dpTwitterUsername, 'count' => 250, 'include_rts' => 1, 'include_entities' => 1));
if (count($results)) {
try {
for ($i = 0; $i < count($results); $i++) {
$tweet = $results[$i];
if (is_object($tweet->user)) {
$screen_name = $tweet->user->screen_name;
if (!@isset($tweets_array[$screen_name])) {
$tweets_array[$screen_name] = DigitalPointSocialBar_Helper_Twitter::parseTweet($tweet);
}
}
}
$cacheObject->save(json_encode(array_values($tweets_array)), 'social_bar_' . str_replace('-', '_', $slug), array(), 604800);
// 7 day cache
} catch (Exception $e) {
}
}
}
}
}
示例11: execute
public function execute(array $deferred, array $data, $targetRunTime, &$status)
{
$data = array_merge(array('startLanguage' => 0, 'startPhrase' => 0, 'position' => 0, 'mapped' => false), $data);
/* @var $phraseModel XenForo_Model_Phrase */
$phraseModel = XenForo_Model::create('XenForo_Model_Phrase');
if ($data['startLanguage'] == 0 && $data['startPhrase'] == 0 && !$data['mapped']) {
$s = microtime(true);
$phraseModel->insertPhraseMapForLanguages($phraseModel->buildPhraseMapForLanguageTree(0), true);
$data['mapped'] = true;
$maxExec = $targetRunTime ? $targetRunTime - (microtime(true) - $s) : 0;
} else {
$maxExec = $targetRunTime;
}
$actionPhrase = new XenForo_Phrase('rebuilding');
$typePhrase = new XenForo_Phrase('phrases');
$status = sprintf('%s... %s %s', $actionPhrase, $typePhrase, str_repeat(' . ', $data['position']));
if (!$targetRunTime || $maxExec > 1) {
$result = $phraseModel->compileAllPhrases($maxExec, $data['startLanguage'], $data['startPhrase']);
} else {
$result = false;
}
if ($result === true) {
return false;
} else {
if ($result) {
$data['startLanguage'] = $result[0];
$data['startPhrase'] = $result[1];
}
$data['position']++;
return $data;
}
}
示例12: run
public function run()
{
/* @var $classModel ThemeHouse_Objects_Model_Class */
$classModel = XenForo_Model::create('ThemeHouse_Objects_Model_Class');
$classes = $classModel->getAllClasses();
if (self::$_dependencies instanceof XenForo_Dependencies_Public) {
$routes = self::$_data['routesPublic'];
} elseif (self::$_dependencies instanceof XenForo_Dependencies_Admin) {
$routes = self::$_data['routesAdmin'];
}
foreach ($classes as $class) {
$routePrefix = '';
if (self::$_dependencies instanceof XenForo_Dependencies_Public) {
$routePrefix = isset($class['route_prefix']) ? $class['route_prefix'] : '';
} elseif (self::$_dependencies instanceof XenForo_Dependencies_Admin) {
$routePrefix = isset($class['route_prefix_admin']) ? $class['route_prefix_admin'] : '';
}
if ($routePrefix && !isset($routes[$routePrefix])) {
$routes[$routePrefix]['build_link'] = 'all';
if (self::$_dependencies instanceof XenForo_Dependencies_Public) {
$routes[$routePrefix]['route_class'] = 'ThemeHouse_Objects_Route_Prefix_Objects';
} elseif (self::$_dependencies instanceof XenForo_Dependencies_Admin) {
$routes[$routePrefix]['route_class'] = 'ThemeHouse_Objects_Route_PrefixAdmin_Objects';
}
}
}
if (self::$_dependencies instanceof XenForo_Dependencies_Public) {
XenForo_Link::setHandlerInfoForGroup('public', $routes);
} elseif (self::$_dependencies instanceof XenForo_Dependencies_Admin) {
XenForo_Link::setHandlerInfoForGroup('admin', $routes);
}
parent::run();
}
示例13: getVisibleModerationQueueEntriesForUser
/**
* Gets visible moderation queue entries for specified user.
*
* @see XenForo_ModerationQueueHandler_Abstract::getVisibleModerationQueueEntriesForUser()
*/
public function getVisibleModerationQueueEntriesForUser(array $contentIds, array $viewingUser)
{
/* @var $profilePostModel XenForo_Model_ProfilePost */
$profilePostModel = XenForo_Model::create('XenForo_Model_ProfilePost');
$profilePosts = $profilePostModel->getProfilePostsByIds($contentIds);
$profileUserIds = array();
foreach ($profilePosts as $profilePost) {
$profileUserIds[] = $profilePost['profile_user_id'];
}
$users = XenForo_Model::create('XenForo_Model_User')->getUsersByIds($profileUserIds, array('join' => XenForo_Model_User::FETCH_USER_PRIVACY, 'followingUserId' => $viewingUser['user_id']));
$output = array();
foreach ($profilePosts as $profilePost) {
if (!isset($users[$profilePost['profile_user_id']])) {
continue;
}
$user = $users[$profilePost['profile_user_id']];
$canManage = true;
if (!$profilePostModel->canViewProfilePostAndContainer($profilePost, $user, $null, $viewingUser)) {
$canManage = false;
} else {
if (!XenForo_Permission::hasPermission($viewingUser['permissions'], 'profilePost', 'editAny') || !XenForo_Permission::hasPermission($viewingUser['permissions'], 'profilePost', 'deleteAny')) {
$canManage = false;
}
}
if ($canManage) {
$output[$profilePost['profile_post_id']] = array('message' => $profilePost['message'], 'user' => array('user_id' => $profilePost['user_id'], 'username' => $profilePost['username']), 'title' => new XenForo_Phrase('profile_post_for_x', array('username' => $user['username'])), 'link' => XenForo_Link::buildPublicLink('profile-posts', $profilePost), 'contentTypeTitle' => new XenForo_Phrase('profile_post'), 'titleEdit' => false);
}
}
return $output;
}
示例14: _getCategoryModel
/**
* @return XenForo_Model_Category
*/
protected function _getCategoryModel()
{
if ($this->_categoryModel === null) {
$this->_categoryModel = XenForo_Model::create('XenForo_Model_Category');
}
return $this->_categoryModel;
}
示例15: actionLanguage
/**
* Displays a form to change the visitor's language, or changes it if a language_id is present.
*
* @return XenForo_ControllerResponse_Abstract
*/
public function actionLanguage()
{
$visitor = XenForo_Visitor::getInstance();
if ($this->_input->inRequest('language_id')) {
$this->_checkCsrfFromToken($this->_input->filterSingle('_xfToken', XenForo_Input::STRING));
$languageId = $this->_input->filterSingle('language_id', XenForo_Input::UINT);
if ($languageId) {
$languages = XenForo_Application::isRegistered('languages') ? XenForo_Application::get('languages') : XenForo_Model::create('XenForo_Model_Language')->getAllLanguagesForCache();
if (!isset($languages[$languageId])) {
$languageId = 0;
}
}
if ($visitor['user_id']) {
$dw = XenForo_DataWriter::create('XenForo_DataWriter_User');
$dw->setExistingData($visitor['user_id']);
$dw->set('language_id', $languageId);
$dw->save();
XenForo_Helper_Cookie::deleteCookie('language_id');
} else {
XenForo_Helper_Cookie::setCookie('language_id', $languageId, 86400 * 365);
}
return $this->responseRedirect(XenForo_ControllerResponse_Redirect::SUCCESS, $this->getDynamicRedirect(false, false));
} else {
$languages = XenForo_Application::isRegistered('languages') ? XenForo_Application::get('languages') : XenForo_Model::create('XenForo_Model_Language')->getAllLanguagesForCache();
$viewParams = array('languages' => $this->getModelFromCache('XenForo_Model_Language')->getAllLanguages(), 'redirect' => $this->getDynamicRedirect(false, false));
return $this->responseView('XenForo_ViewPublic_Misc_Language', 'language_chooser', $viewParams);
}
}