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


PHP XenForo_Locale::date方法代码示例

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


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

示例1: _getPaidContentItemAddEditResponse

 /**
  * Helper to get the paid content add/edit form controller response.
  *
  * @param array $paidContentItem
  *
  * @return XenForo_ControllerResponse_View
  */
 protected function _getPaidContentItemAddEditResponse(array $paidContentItem)
 {
     $paidContentItem = $this->_getPaidContentModel()->preparePaidContent($paidContentItem);
     $userGroups = $this->_getUserGroupModel()->getAllUserGroups();
     if (!empty($paidContentItem['paid_content_id'])) {
         $selUserGroupIds = explode(',', $paidContentItem['user_group_ids']);
         if (in_array(-1, $selUserGroupIds)) {
             $allUserGroups = true;
             $selUserGroupIds = array_keys($userGroups);
         } else {
             $allUserGroups = false;
         }
     } else {
         $allUserGroups = true;
         $selUserGroupIds = array_keys($userGroups);
     }
     if (empty($paidContentItem['start_date'])) {
         $paidContentItem['startDate'] = XenForo_Locale::date(XenForo_Application::$time, 'picker');
     }
     if (empty($paidContentItem['end_date'])) {
         $startTime = !empty($paidContentItem['start_date']) ? $paidContentItem['start_date'] : XenForo_Application::$time;
         $paidContentItem['endDate'] = XenForo_Locale::date($startTime + 7 * 24 * 60 * 60, 'picker');
     }
     $viewParams = array('paidContentItem' => $paidContentItem, 'allUserGroups' => $allUserGroups, 'selUserGroupIds' => $selUserGroupIds, 'userGroups' => $userGroups);
     return $this->responseView('ThemeHouse_PayForContent_ViewAdmin_PaidContentItem_Edit', 'th_paid_content_item_edit_payforcontent', $viewParams);
 }
开发者ID:ThemeHouse-XF,项目名称:PayForContent,代码行数:33,代码来源:PaidContent.php

示例2: createContent

 public function createContent($tabId, $tabName, array $createCriteria, array $params)
 {
     if (!$createCriteria['resource_category_id']) {
         return $tabId;
     }
     /* @var $dw XenResource_DataWriter_Resource */
     $dw = XenForo_DataWriter::create('XenResource_DataWriter_Resource', XenForo_DataWriter::ERROR_SILENT);
     $dw->bulkSet(array('resource_category_id' => $createCriteria['resource_category_id'], 'title' => $params['title'], 'tag_line' => isset($params['tag_line']) ? $params['tag_line'] : new XenForo_Phrase('waindigo_resource_tag_line_create_tabs', $params, false), 'user_id' => $params['user_id'], 'username' => $params['username'], 'tab_id' => $tabId));
     $dw->setOption(Waindigo_Tabs_Extend_XenResource_DataWriter_Resource::OPTION_CHECK_TAB_RULES, false);
     $descriptionDw = $dw->getDescriptionDw();
     $descriptionDw->set('message', $params['message']);
     $versionDw = $dw->getVersionDw();
     $dw->set('is_fileless', 1);
     $versionDw->setOption(XenResource_DataWriter_Version::OPTION_IS_FILELESS, true);
     $versionDw->set('version_string', XenForo_Locale::date(XenForo_Application::$time, 'Y-m-d'));
     if ($dw->hasErrors()) {
         return $tabId;
     }
     if (!$tabId) {
         $tabId = $this->getTabId();
         $dw->set('tab_id', $tabId);
     }
     if (!$dw->save()) {
         return $tabId;
     }
     $this->insertTab($tabId, 'resource', $dw->get('resource_id'), $tabName);
     return $tabId;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:28,代码来源:Resource.php

示例3: 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;
 }
开发者ID:namgiangle90,项目名称:tokyobaito,代码行数:28,代码来源:DailyStats.php

示例4: rebuild

 /**
  * @see XenForo_CacheRebuilder_DailyStats::rebuild()
  */
 public function rebuild($position = 0, array &$options = array(), &$detailedMessage = '')
 {
     $options['batch'] = isset($options['batch']) ? $options['batch'] : 28;
     $options['batch'] = max(1, $options['batch']);
     /* @var $userModel XenForo_Model_Stats */
     $statsModel = XenForo_Model::create('XenForo_Model_Stats');
     if ($position == 0) {
         // delete old stats cache if required
         if (!empty($options['delete'])) {
             $statsModel->deleteStats();
         }
         $xenOptions = XenForo_Application::get('options');
         // an appropriate date from which to start... first thread, or earliest user reg?
         if ($xenOptions->th_noForo_noForum) {
             $position = XenForo_Model::create('XenForo_Model_User')->getEarliestRegistrationDate();
         } else {
             $position = min(XenForo_Model::create('XenForo_Model_Thread')->getEarliestThreadDate(), XenForo_Model::create('XenForo_Model_User')->getEarliestRegistrationDate());
         }
         // start on a 24 hour increment point
         $position = $position - $position % 86400;
     } else {
         if ($position > XenForo_Application::$time) {
             return true;
         }
     }
     XenForo_Db::beginTransaction();
     $endPosition = $position + $options['batch'] * 86400;
     $data = $statsModel->buildStatsData($position, $endPosition);
     XenForo_Db::commit();
     $detailedMessage = XenForo_Locale::date($position, 'absolute');
     return $endPosition;
 }
开发者ID:ThemeHouse-XF,项目名称:NoForo,代码行数:35,代码来源:DailyStats.php

示例5: dateSplit

 /**
  * Splits an array into individual chunks of days, keyed by the midnight timestamp of the day specified by each item
  *
  * @param array $items
  * @param string $dateField
  *
  * @return array [$midnight] => $item
  */
 public static function dateSplit(array $items, $dateField)
 {
     $newItems = array();
     foreach ($items as $key => $value) {
         $newItems[XenForo_Locale::date($value[$dateField])][$key] = $value;
     }
     return $newItems;
 }
开发者ID:namgiangle90,项目名称:tokyobaito,代码行数:16,代码来源:Alert.php

示例6: actionIndex

 /**
  * Displays a form to do an advanced search.
  *
  * @return XenForo_ControllerResponse_Abstract
  */
 public function actionIndex()
 {
     $search = array('child_nodes' => true, 'order' => 'date');
     $searchId = $this->_input->filterSingle('search_id', XenForo_Input::UINT);
     if ($searchId) {
         if ($this->_input->filterSingle('searchform', XenForo_Input::UINT)) {
             $params = $this->_input->filter(array('q' => XenForo_Input::STRING, 't' => XenForo_Input::STRING, 'o' => XenForo_Input::STRING, 'g' => XenForo_Input::UINT, 'c' => XenForo_Input::ARRAY_SIMPLE));
             // allow this to pass through for the search type check later
             $this->_request->setParam('type', $params['t']);
             $users = '';
             if (!empty($params['c']['user'])) {
                 foreach ($this->_getUserModel()->getUsersByIds($params['c']['user']) as $user) {
                     $users .= $user['username'] . ', ';
                 }
                 $users = substr($users, 0, -2);
             }
             if (!empty($params['c']['node'])) {
                 $nodes = array_fill_keys(explode(' ', $params['c']['node']), true);
             } else {
                 $nodes = array();
             }
             if (!empty($params['c']['date'])) {
                 $date = XenForo_Locale::date(intval($params['c']['date']), 'picker');
             } else {
                 $date = '';
             }
             if (!empty($params['c']['user_content'])) {
                 $userContent = $params['c']['user_content'];
             } else {
                 $userContent = '';
             }
             $search = array_merge($search, array('keywords' => $params['q'], 'title_only' => !empty($params['c']['title_only']), 'users' => $users, 'user_content' => $userContent, 'date' => $date, 'nodes' => $nodes, 'child_nodes' => empty($nodes), 'order' => $params['o'], 'group_discussion' => $params['g'], 'existing' => true));
         } else {
             return $this->responseReroute(__CLASS__, 'results');
         }
     }
     if (!XenForo_Visitor::getInstance()->canSearch()) {
         throw $this->getNoPermissionResponseException();
     }
     $nodeId = $this->_input->filterSingle('node_id', XenForo_Input::UINT);
     if ($nodeId) {
         $search['nodes'][$nodeId] = true;
     }
     $viewParams = array('supportsRelevance' => XenForo_Search_SourceHandler_Abstract::getDefaultSourceHandler()->supportsRelevance(), 'nodes' => $this->_getNodeModel()->getViewableNodeList(null, true), 'search' => empty($search) ? array() : $search);
     $searchType = $this->_input->filterSingle('type', XenForo_Input::STRING);
     if ($searchType) {
         $typeHandler = $this->_getSearchModel()->getSearchDataHandler($searchType);
         if ($typeHandler) {
             $viewParams['searchType'] = $searchType;
             $response = $typeHandler->getSearchFormControllerResponse($this, $this->_input, $viewParams);
             if ($response) {
                 return $response;
             }
         }
     }
     $viewParams['searchType'] = '';
     return $this->responseView('XenForo_ViewPublic_Search_Form', 'search_form', $viewParams);
 }
开发者ID:Sywooch,项目名称:forums,代码行数:63,代码来源:Search.php

示例7: verifyAndProcessingTimeinput

 public function verifyAndProcessingTimeinput(XenForo_Controller $controller, $sorttime = '', $datepicker)
 {
     $sorttime = array_map('intval', explode(":", $sorttime));
     if (count($sorttime) != 2) {
         throw new XenForo_Exception("Missing agrument for create/edit event.");
         return false;
     }
     $datepicker = XenForo_Locale::date($datepicker, 'd-m-Y');
     $datepicker = array_map('intval', explode('-', $datepicker));
     $gmmktime = gmmktime($sorttime[0], $sorttime[1], 0, $datepicker[1], $datepicker[0], $datepicker[2]);
     return $gmmktime - XenForo_Locale::getTimeZoneOffset();
 }
开发者ID:Sywooch,项目名称:forums,代码行数:12,代码来源:Setup.php

示例8: promoteUser

 /**
  *
  * @see XenForo_Model_UserGroupPromotion::promoteUser()
  */
 public function promoteUser(array $promotion, $userId, $state = 'automatic')
 {
     $db = $this->_getDb();
     XenForo_Db::beginTransaction($db);
     $this->_getUserModel()->addUserGroupChange($userId, "ugPromotion{$promotion['promotion_id']}", $promotion['extra_user_group_ids']);
     $customFields = @unserialize($promotion['custom_fields_th']);
     if ($customFields) {
         foreach ($customFields as $customFieldId => $customFieldValue) {
             if (is_string($customFieldValue)) {
                 $replace = array('{now}' => XenForo_Application::$time, '{date}' => XenForo_Locale::date(XenForo_Application::$time, 'picker'));
                 $customFieldValue = strtr($customFieldValue, $replace);
             }
             $this->_getUserChangeTempModel()->applyTempUserChange($userId, 'custom_field', $customFieldId, $customFieldValue, null, "ugPromotion{$promotion['promotion_id']}{$customFieldId}");
         }
     }
     $this->insertPromotionLogEntry($promotion['promotion_id'], $userId, $state);
     XenForo_Db::commit($db);
 }
开发者ID:ThemeHouse-XF,项目名称:UserPromotions,代码行数:22,代码来源:UserGroupPromotion.php

示例9: _prepareDateField

 protected function _prepareDateField($value)
 {
     if ($value) {
         return XenForo_Locale::date($value);
     } else {
         return '';
     }
 }
开发者ID:darkearl,项目名称:projectT122015,代码行数:8,代码来源:UserChangeLog.php

示例10: getEventCalendarEntries

 public function getEventCalendarEntries(array $events)
 {
     $entries = array();
     $i = 0;
     foreach ($events as $eventId => $event) {
         $i++;
         $currentDate = XenForo_Locale::date($event['begin_date'], 'Y-m-d H:i:s');
         if ($event['end_date']) {
             $nextDate = XenForo_Locale::date($event['end_date'], 'Y-m-d H:i:s');
         } else {
             $nextDate = Date('Y-m-d', strtotime('+1 day', strtotime($currentDate)));
             $nextDate .= ' 00:00:00';
         }
         $entries[] = array('id' => $eventId, 'title' => XenForo_Helper_String::wholeWordTrim($event['event_title'], 25), 'start' => "{$currentDate}", 'url' => XenForo_Link::convertUriToAbsoluteUri(XenForo_Link::buildPublicLink(TEAM_ROUTE_ACTION . '/events', $event), true), 'allDay' => false, 'end' => "{$nextDate}", 'className' => 'eventEntry');
     }
     return $entries;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:17,代码来源:Event.php

示例11: userMatchesCriteria

 /**
  * Determines if the given user matches the criteria. The provided
  * user should be a full user record; if fields are missing, an error
  * will not be thrown, and the criteria check will fail.
  *
  * @param array|string $criteria List of criteria, format: [] with keys rule and data; may be serialized
  * @param boolean $matchOnEmpty If true and there's no criteria, true is returned; otherwise, false
  * @param array|null $user Full user record to check against; if null, user visitor
  *
  * @return boolean
  */
 public static function userMatchesCriteria($criteria, $matchOnEmpty = false, array $user = null)
 {
     if (!($criteria = self::unserializeCriteria($criteria))) {
         return (bool) $matchOnEmpty;
     }
     if (!$user) {
         $user = XenForo_Visitor::getInstance()->toArray();
     }
     if (!isset($user['customFields'])) {
         $user['customFields'] = !empty($user['custom_fields']) ? @unserialize($user['custom_fields']) : array();
     }
     if (!isset($user['externalAuth'])) {
         $user['externalAuth'] = !empty($user['external_auth']) ? @unserialize($user['external_auth']) : array();
     }
     foreach ($criteria as $criterion) {
         $data = $criterion['data'];
         // custom user fields
         if (strpos($criterion['rule'], self::$_userFieldPrefix) === 0) {
             $userFieldId = substr($criterion['rule'], self::$_userFieldPrefixLength);
             if (!isset($user['customFields'][$userFieldId])) {
                 return false;
             }
             $userField = $user['customFields'][$userFieldId];
             // text fields - check that data exists within the text value
             if (isset($data['text'])) {
                 if (stripos($userField, $data['text']) === false) {
                     return false;
                 }
             } else {
                 if (isset($data['choices'])) {
                     // multi-choice
                     if (is_array($userField)) {
                         if (!array_intersect($userField, $data['choices'])) {
                             return false;
                         }
                     } else {
                         if (!in_array($userField, $data['choices'])) {
                             return false;
                         }
                     }
                 }
             }
         } else {
             switch ($criterion['rule']) {
                 // username
                 case 'username':
                     $names = preg_split('/\\s*,\\s*/', utf8_strtolower($data['names']), -1, PREG_SPLIT_NO_EMPTY);
                     if (!in_array(utf8_strtolower($user['username']), $names)) {
                         return false;
                     }
                     break;
                     // username-search
                 // username-search
                 case 'username_search':
                     if (self::_arrayStringSearch($data['needles'], $user['username']) === false) {
                         return false;
                     }
                     break;
                     // email-search
                 // email-search
                 case 'email_search':
                     if (self::_arrayStringSearch($data['needles'], $user['email']) === false) {
                         return false;
                     }
                     break;
                     // days since registration
                 // days since registration
                 case 'registered_days':
                     if (!isset($user['register_date'])) {
                         return false;
                     }
                     $daysRegistered = floor((XenForo_Application::$time - $user['register_date']) / 86400);
                     if ($daysRegistered < $data['days']) {
                         return false;
                     }
                     break;
                     // total messages posted
                 // total messages posted
                 case 'messages_posted':
                     if (!isset($user['message_count']) || $user['message_count'] < $data['messages']) {
                         return false;
                     }
                     break;
                     // maximum messages posted
                 // maximum messages posted
                 case 'messages_maximum':
                     if (!isset($user['message_count']) || $user['message_count'] > $data['messages']) {
                         return false;
                     }
//.........这里部分代码省略.........
开发者ID:Sywooch,项目名称:forums,代码行数:101,代码来源:Criteria.php

示例12: actionGetProfile

 public function actionGetProfile()
 {
     $visitor = XenForo_Visitor::getInstance();
     $permissions = $visitor->getPermissions();
     $session_model = $this->getModelFromCache('XenForo_Model_Session');
     $userid = $this->_input->filterSingle('userid', XenForo_Input::UINT);
     if (!$userid) {
         $userid = XenForo_Visitor::getUserId();
     }
     try {
         $user = $this->getHelper('UserProfile')->assertUserProfileValidAndViewable($userid, array('join' => XenForo_Model_User::FETCH_LAST_ACTIVITY));
     } catch (Exception $e) {
         json_error($e->getControllerResponse()->errorText->render());
     }
     $online_info = $session_model->getSessionActivityRecords(array('user_id' => $user['user_id'], 'cutOff' => array('>', $session_model->getOnlineStatusTimeout())));
     $is_online = false;
     if (count($online_info) == 1) {
         $is_online = true;
     }
     $posts = $user['message_count'];
     $joindate = prepare_utf8_string(XenForo_Locale::date($user['register_date'], 'absolute'));
     $out = array('username' => prepare_utf8_string(strip_tags($user['username'])), 'posts' => $posts, 'joindate' => $joindate, 'online' => $is_online, 'avatar_upload' => $visitor->canUploadAvatar());
     $maxFileSize = XenForo_Permission::hasPermission($permissions, 'avatar', 'maxFileSize');
     if ($maxFileSize > 0) {
         $out['avatar_resize'] = true;
     }
     $avatarurl = process_avatarurl(XenForo_Template_Helper_Core::getAvatarUrl($user, 'm'));
     if (strpos($avatarurl, '/xenforo/avatars/avatar_') !== false) {
         $avatarurl = '';
     }
     if ($avatarurl != '') {
         $out['avatarurl'] = $avatarurl;
     }
     if ($visitor->hasAdminPermission('ban')) {
         $out['ban'] = true;
     }
     // New Profile Fields
     $groups = array();
     // About
     $out_group = array('name' => 'about', 'values' => array(array('name' => prepare_utf8_string(fr_get_phrase('messages')), 'value' => strval($posts)), array('name' => prepare_utf8_string(fr_get_phrase('joined')), 'value' => $joindate), array('name' => prepare_utf8_string(fr_get_phrase('likes_received')), 'value' => strval($user['like_count']))));
     $groups[] = $out_group;
     // Additional information
     $out_group = array('name' => 'additional');
     // Status
     if (!empty($user['status'])) {
         $out_group['values'][] = array('name' => prepare_utf8_string(fr_get_phrase('status')), 'value' => prepare_utf8_string($user['status']));
     }
     // Location
     if (!empty($user['location'])) {
         $out_group['values'][] = array('name' => prepare_utf8_string(fr_get_phrase('location')), 'value' => prepare_utf8_string($user['location']));
     }
     // Occupation
     if (!empty($user['occupation'])) {
         $out_group['values'][] = array('name' => prepare_utf8_string(fr_get_phrase('occupation')), 'value' => prepare_utf8_string($user['occupation']));
     }
     // About
     if (!empty($user['about'])) {
         $out_group['values'][] = array('name' => prepare_utf8_string(fr_get_phrase('about')), 'value' => prepare_utf8_string(remove_bbcode($user['about'], true, true)));
     }
     if (count($out_group['values'])) {
         $groups[] = $out_group;
     }
     $out['groups'] = $groups;
     return $out;
 }
开发者ID:Sywooch,项目名称:forums,代码行数:65,代码来源:Profile.php

示例13: date

 /**
  * Date formatting. Format represents a string name of a format.
  *
  * @param integer Unix timestamp to format
  * @param string  Named format (name options TBD)
  *
  * @return string
  */
 public static function date($timestamp, $format = null)
 {
     return XenForo_Locale::date($timestamp, $format, self::$_language);
 }
开发者ID:hahuunguyen,项目名称:DTUI_201105,代码行数:12,代码来源:Core.php

示例14: preparePaidContent

 public function preparePaidContent(array $paidContent)
 {
     if (!empty($paidContent['cost_amount']) && !isset($paidContent['currency_old'])) {
         if (isset($paidContent['currency'])) {
             $paidContent['currency_old'] = $paidContent['currency'];
         } else {
             $paidContent['currency_old'] = '';
         }
         $paidContent['currency'] = strtoupper($paidContent['cost_currency']);
     }
     if (!empty($paidContent['cost_amount'])) {
         if ($paidContent['cost_amount'] == '0.00') {
             $paidContent['costPhrase'] = new XenForo_Phrase('free');
         } else {
             $paidContent['costPhrase'] = XenForo_Locale::numberFormat($paidContent['cost_amount'], 2) . ' ' . $paidContent['currency'];
         }
     }
     if (!empty($paidContent['paid_content_id'])) {
         $paidContent['paid_content_title'] = new XenForo_Phrase($this->getPaidContentPhraseName($paidContent['paid_content_id']));
     }
     if (isset($paidContent['user_group_ids']) && $paidContent['user_group_ids'] != -1) {
         $paidContent['userGroupIds'] = explode(',', $paidContent['user_group_ids']);
     }
     if (!empty($paidContent['start_date'])) {
         $paidContent['startDate'] = XenForo_Locale::date($paidContent['start_date'], 'picker');
     }
     if (!empty($paidContent['end_date'])) {
         $paidContent['endDate'] = XenForo_Locale::date($paidContent['end_date'], 'picker');
     }
     return $paidContent;
 }
开发者ID:ThemeHouse-XF,项目名称:PayForContent,代码行数:31,代码来源:PaidContent.php

示例15: actionSave

 public function actionSave()
 {
     $this->_assertPostOnly();
     $categoryModel = $this->_getCategoryModel();
     if ($resourceId = $this->_input->filterSingle('resource_id', XenForo_Input::UINT)) {
         list($resource, $category) = $this->_getResourceHelper()->assertResourceValidAndViewable($resourceId);
         if (!$this->_getResourceModel()->canEditResource($resource, $category, $errorPhraseKey)) {
             throw $this->getErrorOrNoPermissionResponseException($errorPhraseKey);
         }
         $categoryPermissions = $categoryModel->getCategoryPermCache(null, $category['resource_category_id']);
         $canEditCategory = XenForo_Permission::hasContentPermission($categoryPermissions, 'editAny');
     } else {
         $category = false;
         $resource = false;
         $canEditCategory = true;
     }
     $resourceData = $this->_input->filter(array('resource_category_id' => XenForo_Input::UINT, 'title' => XenForo_Input::STRING, 'tag_line' => XenForo_Input::STRING, 'external_url' => XenForo_Input::STRING, 'alt_support_url' => XenForo_Input::STRING, 'prefix_id' => XenForo_Input::UINT));
     if (!$resourceData['resource_category_id']) {
         return $this->responseError(new XenForo_Phrase('you_must_select_category'));
     }
     $newCategory = $category;
     if ($canEditCategory) {
         if (!$resource || $resource['resource_category_id'] != $resourceData['resource_category_id']) {
             // new resource or changing category - let's make sure we can do that
             $newCategory = $this->_getResourceHelper()->assertCategoryValidAndViewable($resourceData['resource_category_id']);
             if (!$categoryModel->canAddResource($newCategory, $key)) {
                 throw $this->getErrorOrNoPermissionResponseException($key);
             }
         }
         $categoryId = $resourceData['resource_category_id'];
     } else {
         $categoryId = $resource['resource_category_id'];
         unset($resourceData['resource_category_id']);
     }
     if (!$resource || $resource['prefix_id'] != $resourceData['prefix_id'] || $resource['resource_category_id'] != $categoryId) {
         if (!$this->_getPrefixModel()->verifyPrefixIsUsable($resourceData['prefix_id'], $categoryId)) {
             $resourceData['prefix_id'] = 0;
             // not usable, just blank it out
         }
     }
     /* @var $dw XenResource_DataWriter_Resource */
     $dw = XenForo_DataWriter::create('XenResource_DataWriter_Resource');
     if ($resourceId) {
         $dw->setExistingData($resource['resource_id']);
     } else {
         $visitor = XenForo_Visitor::getInstance();
         $dw->set('user_id', $visitor['user_id']);
         $dw->set('username', $visitor['username']);
     }
     $dw->bulkSet($resourceData);
     if (!$resourceId || $newCategory['resource_category_id'] != $category['resource_category_id']) {
         if ($newCategory['always_moderate_create'] && ($dw->get('resource_state') == 'visible' || !$resourceId) && !XenForo_Visitor::getInstance()->hasPermission('resource', 'approveUnapprove')) {
             $dw->set('resource_state', 'moderated');
         }
     }
     if (!$resourceId) {
         $watch = XenForo_Visitor::getInstance()->default_watch_state;
         if (!$watch) {
             $watch = 'watch_no_email';
         }
         $dw->setExtraData(XenResource_DataWriter_Resource::DATA_THREAD_WATCH_DEFAULT, $watch);
     }
     $customFields = $this->_getResourceHelper()->getCustomFieldValues($null, $shownCustomFields);
     $dw->setCustomFields($customFields, $shownCustomFields);
     $extraData = $this->_input->filter(array('attachment_hash' => XenForo_Input::STRING, 'file_hash' => XenForo_Input::STRING, 'version_string' => XenForo_Input::STRING, 'resource_file_type' => XenForo_Input::STRING, 'download_url' => XenForo_Input::STRING, 'price' => XenForo_Input::UNUM, 'currency' => XenForo_Input::STRING, 'external_purchase_url' => XenForo_Input::STRING));
     $message = $this->getHelper('Editor')->getMessageText('message', $this->_input);
     $message = XenForo_Helper_String::autoLinkBbCode($message);
     $descriptionDw = $dw->getDescriptionDw();
     $descriptionDw->set('message', $message);
     $descriptionDw->setExtraData(XenResource_DataWriter_Update::DATA_ATTACHMENT_HASH, $extraData['attachment_hash']);
     $versionDw = $dw->getVersionDw();
     if (!$resourceId) {
         switch ($extraData['resource_file_type']) {
             case 'file':
                 if ($newCategory['allow_local']) {
                     $versionDw->setExtraData(XenResource_DataWriter_Version::DATA_ATTACHMENT_HASH, $extraData['file_hash']);
                 }
                 break;
             case 'url':
                 if ($newCategory['allow_external']) {
                     if (!$extraData['download_url']) {
                         $versionDw->error(new XenForo_Phrase('please_enter_external_download_url'), 'download_url');
                     } else {
                         $versionDw->set('download_url', $extraData['download_url']);
                     }
                 }
                 break;
             case 'commercial_external':
                 if ($newCategory['allow_commercial_external']) {
                     if (!$extraData['price'] || !$extraData['currency'] || !$extraData['external_purchase_url']) {
                         $dw->error(new XenForo_Phrase('please_complete_required_fields'));
                     } else {
                         $dw->bulkSet(array('is_fileless' => 1, 'price' => $extraData['price'], 'currency' => $extraData['currency'], 'external_purchase_url' => $extraData['external_purchase_url']));
                         $versionDw->setOption(XenResource_DataWriter_Version::OPTION_IS_FILELESS, true);
                     }
                 }
                 break;
             case 'fileless':
                 if ($newCategory['allow_fileless']) {
                     $dw->set('is_fileless', 1);
//.........这里部分代码省略.........
开发者ID:Sywooch,项目名称:forums,代码行数:101,代码来源:Resource.php


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