本文整理汇总了PHP中wcf\system\WCF类的典型用法代码示例。如果您正苦于以下问题:PHP WCF类的具体用法?PHP WCF怎么用?PHP WCF使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WCF类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: enable
/**
* Enables this option.
*
* @param boolean $enable
*/
public function enable($enable = true)
{
$value = intval(!$enable);
$sql = "UPDATE\twcf" . WCF_N . "_user_option\n\t\t\tSET\tdisabled = ?\n\t\t\tWHERE\toptionID = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array($value, $this->optionID));
}
示例2: getData
/**
* @see \wcf\system\option\IOptionType::getData()
*/
public function getData(Option $option, $newValue)
{
$number = str_replace(WCF::getLanguage()->get('wcf.global.thousandsSeparator'), '', $newValue);
$number = str_replace(WCF::getLanguage()->get('wcf.global.decimalPoint'), '.', $number);
if (!preg_match('~^(?:\\d*)\\.?\\d+~', $number, $matches)) {
return 0;
}
$number = $matches[0];
if (preg_match('/[kmgt]i?b$/i', $newValue, $multiplier)) {
switch (mb_strtolower($multiplier[0])) {
case 'tb':
$number *= 1000;
case 'gb':
$number *= 1000;
case 'mb':
$number *= 1000;
case 'kb':
$number *= 1000;
break;
case 'tib':
$number *= 1024;
case 'gib':
$number *= 1024;
case 'mib':
$number *= 1024;
case 'kib':
$number *= 1024;
break;
}
}
return $number;
}
示例3: calCfg
/**
* calculate the final config of $this->cfg through $this->cfg default value and MbqMain::$customConfig and MbqMain::$oMbqAppEnv and the plugin support degree
*/
public function calCfg()
{
$url = WCF::getPath();
MbqMain::$oMbqAppEnv->siteRootUrl = substr($url, 0, strlen($url) - 4);
//init user
$oUser = DefaultUserAuthentication::getInstance()->loginAutomatically(true);
if ($oUser && $oUser->userID) {
MbqMain::$oMbqAppEnv->oCurrentUser = $oUser;
$oMbqRdEtUser = MbqMain::$oClk->newObj('MbqRdEtUser');
$oMbqRdEtUser->initOCurMbqEtUser();
}
if (MbqMain::hasLogin()) {
//!!!
header('Mobiquo_is_login: true');
} else {
header('Mobiquo_is_login: false');
}
$oMbqRdEtForum = MbqMain::$oClk->newObj('MbqRdEtForum');
MbqMain::$oMbqAppEnv->exttForumTree = $oMbqRdEtForum->getForumTree();
//!!!
parent::calCfg();
/* calculate the final config */
$this->cfg['base']['sys_version']->setOriValue(PACKAGE_VERSION);
if (OFFLINE) {
$this->cfg['base']['is_open']->setOriValue(MbqBaseFdt::getFdt('MbqFdtConfig.base.is_open.range.no'));
} else {
$this->cfg['base']['is_open']->setOriValue(MbqBaseFdt::getFdt('MbqFdtConfig.base.is_open.range.yes'));
}
if (!MODULE_CONVERSATION || !WCF::getSession()->getPermission('user.conversation.canUseConversation')) {
$this->cfg['pc']['module_enable']->setOriValue(MbqBaseFdt::getFdt('MbqFdtConfig.pc.module_enable.range.disable'));
$this->cfg['pc']['conversation']->setOriValue(MbqBaseFdt::getFdt('MbqFdtConfig.pc.conversation.range.notSupport'));
}
}
示例4: getData
/**
* @see \wcf\system\option\IOptionType::getData()
*/
public function getData(Option $option, $newValue)
{
$newValue = str_replace(' ', '', $newValue);
$newValue = str_replace(WCF::getLanguage()->get('wcf.global.thousandsSeparator'), '', $newValue);
$newValue = str_replace(WCF::getLanguage()->get('wcf.global.decimalPoint'), '.', $newValue);
return floatval($newValue);
}
示例5: prepare
/**
* @see \wcf\system\user\activity\event\IUserActivityEvent::prepare()
*/
public function prepare(array $events)
{
$newsIDs = array();
foreach ($events as $event) {
$newsIDs[] = $event->objectID;
}
$newsList = new ViewableNewsList();
$newsList->getConditionBuilder()->add("news.newsID IN (?)", array($newsIDs));
$newsList->readObjects();
$newsEntries = $newsList->getObjects();
foreach ($events as $event) {
if (isset($newsEntries[$event->objectID])) {
$news = $newsEntries[$event->objectID];
if (!$news->canRead()) {
continue;
}
$event->setIsAccessible();
$text = WCF::getLanguage()->getDynamicVariable('news.recentActivity.likedNews', array('news' => $news));
$event->setTitle($text);
$event->setDescription($news->getExcerpt());
} else {
$event->setIsOrphaned();
}
}
}
示例6: getParsedTag
/**
* @see \wcf\system\bbcode\IBBCode::getParsedTag()
*/
public function getParsedTag(array $openingTag, $content, array $closingTag, BBCodeParser $parser)
{
if ($parser->getOutputType() == 'text/html') {
$quoteLink = !empty($openingTag['attributes'][1]) ? $openingTag['attributes'][1] : '';
$externalQuoteLink = !empty($openingTag['attributes'][1]) ? !ApplicationHandler::getInstance()->isInternalURL($openingTag['attributes'][1]) : false;
if (!$externalQuoteLink) {
$quoteLink = preg_replace('~^https?://~', RouteHandler::getProtocol(), $quoteLink);
}
$quoteAuthor = !empty($openingTag['attributes'][0]) ? $openingTag['attributes'][0] : '';
$quoteAuthorObject = null;
if ($quoteAuthor && !$externalQuoteLink) {
$quoteAuthorLC = mb_strtolower(StringUtil::decodeHTML($quoteAuthor));
foreach (MessageEmbeddedObjectManager::getInstance()->getObjects('com.woltlab.wcf.quote') as $user) {
if (mb_strtolower($user->username) == $quoteAuthorLC) {
$quoteAuthorObject = $user;
break;
}
}
}
WCF::getTPL()->assign(array('content' => $content, 'quoteLink' => $quoteLink, 'quoteAuthor' => $quoteAuthor, 'quoteAuthorObject' => $quoteAuthorObject, 'isExternalQuoteLink' => $externalQuoteLink));
return WCF::getTPL()->fetch('quoteBBCodeTag');
} else {
if ($parser->getOutputType() == 'text/simplified-html') {
return WCF::getLanguage()->getDynamicVariable('wcf.bbcode.quote.text', array('content' => $content, 'cite' => !empty($openingTag['attributes'][0]) ? $openingTag['attributes'][0] : '')) . "\n";
}
}
}
示例7: execute
/**
* @see \wcf\system\event\IEventListener::execute()
*/
public function execute($eventObj, $className, $eventName)
{
// try {
// $request = new HTTPRequest(self::FEED_URL);
// $request->execute();
// $feedData = $request->getReply();
// $feedData = $feedData['body'];
// }
// catch (SystemException $e) {
// // log error
// $e->getExceptionID();
// return;
// }
// if (!$xml = simplexml_load_string($feedData)) {
// return;
// }
$feed = array();
// $i = 10;
// foreach ($xml->channel[0]->item as $item) {
// if ($i -- == 0) {
// break;
// }
// $feed[] = array(
// 'title' => (string) $item->title,
// 'description' => (string) $item->description,
// 'link' => (string) $item->guid,
// 'time' => strtotime((string) $item->pubDate)
// );
// }
WCF::getTPL()->assign(array('codequakeNewsFeed' => $feed));
}
示例8: countUserFailures
/**
* Returns the number of authentication failures for given user account.
*
* @param integer $userID
* @return boolean
*/
public static function countUserFailures($userID)
{
$sql = "SELECT\tCOUNT(*) AS count\n\t\t\tFROM\twcf" . WCF_N . "_user_authentication_failure\n\t\t\tWHERE\tuserID = ?\n\t\t\t\tAND time > ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array($userID, TIME_NOW - USER_AUTHENTICATION_FAILURE_TIMEOUT));
return $statement->fetchColumn();
}
示例9: import
/**
* @see \wcf\system\importer\IImporter::import()
*/
public function import($oldID, array $data, array $additionalData = array())
{
$data['packageID'] = 1;
// set temporary option name
$data['optionName'] = StringUtil::getRandomID();
if ($data['optionType'] == 'boolean' || $data['optionType'] == 'integer') {
if (isset($data['defaultValue'])) {
$data['defaultValue'] = intval($data['defaultValue']);
}
}
// create category
$this->createCategory($data['categoryName']);
// save option
$action = new UserOptionAction(array(), 'create', array('data' => $data));
$returnValues = $action->executeAction();
$userOption = $returnValues['returnValues'];
// update generic option name
$editor = new UserOptionEditor($userOption);
$editor->update(array('optionName' => 'option' . $userOption->optionID));
// save name
$sql = "INSERT IGNORE INTO\twcf" . WCF_N . "_language_item\n\t\t\t\t\t\t(languageID, languageItem, languageItemValue, languageItemOriginIsSystem, languageCategoryID, packageID)\n\t\t\tVALUES\t\t\t(?, ?, ?, ?, ?, ?)";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array(LanguageFactory::getInstance()->getDefaultLanguageID(), 'wcf.user.option.option' . $userOption->optionID, $additionalData['name'], 0, $this->languageCategoryID, 1));
ImportHandler::getInstance()->saveNewID('com.woltlab.wcf.user.option', $oldID, $userOption->optionID);
return $userOption->optionID;
}
示例10: getLabel
/**
* Returns the label of the input element.
*
* @param string $identifier
* @return string
*/
protected function getLabel($identifier)
{
if (isset($this->labels[$identifier])) {
return '<label for="' . $identifier . '">' . WCF::getLanguage()->get($this->labels[$identifier]) . '</label>';
}
return '';
}
示例11: validate
/**
* Validates object options and permissions.
*
* @param \wcf\data\DatabaseObject $object
* @param string $optionsColumnName
* @param string $permissionsColumnName
* @return boolean
*/
protected function validate(DatabaseObject $object, $optionsColumnName = 'options', $permissionsColumnName = 'permissions')
{
// check the options of this item
$hasEnabledOption = true;
if ($object->{$optionsColumnName}) {
$hasEnabledOption = false;
$options = explode(',', strtoupper($object->{$optionsColumnName}));
foreach ($options as $option) {
if (defined($option) && constant($option)) {
$hasEnabledOption = true;
break;
}
}
}
if (!$hasEnabledOption) {
return false;
}
// check the permission of this item for the active user
$hasPermission = true;
if ($object->{$permissionsColumnName}) {
$hasPermission = false;
$permissions = explode(',', $object->{$permissionsColumnName});
foreach ($permissions as $permission) {
if (WCF::getSession()->getPermission($permission)) {
$hasPermission = true;
break;
}
}
}
if (!$hasPermission) {
return false;
}
return true;
}
示例12: __construct
/**
* Creates the AccessibleNewsList object.
*/
public function __construct()
{
parent::__construct();
// accessible news categories
$accessibleCategoryIDs = NewsCategory::getAccessibleCategoryIDs();
if (!empty($accessibleCategoryIDs)) {
$this->getConditionBuilder()->add('news.newsID IN (SELECT newsID FROM news' . WCF_N . '_news_to_category WHERE categoryID IN (?))', array($accessibleCategoryIDs));
} else {
$this->getConditionBuilder()->add('1=0');
}
// default conditions
if (!WCF::getSession()->getPermission('mod.news.canReadDeactivatedNews')) {
$this->getConditionBuilder()->add('news.isActive = 1');
}
if (!WCF::getSession()->getPermission('mod.news.canReadDeletedNews')) {
$this->getConditionBuilder()->add('news.isDeleted = 0');
}
if (!WCF::getSession()->getPermission('mod.news.canReadFutureNews')) {
if (WCF::getUser()->userID) {
$this->getConditionBuilder()->add('(news.isPublished = 1 OR news.userID = ?)', array(WCF::getUser()->userID));
} else {
$this->getConditionBuilder()->add('news.isPublished = 1');
}
}
// apply language filter
if (LanguageFactory::getInstance()->multilingualismEnabled() && count(WCF::getUser()->getLanguageIDs())) {
$this->getConditionBuilder()->add('(news.languageID IN (?) OR news.languageID IS NULL)', array(WCF::getUser()->getLanguageIDs()));
}
}
示例13: prepare
/**
* @see \wcf\system\like\IViewableLikeProvider::prepare()
*/
public function prepare(array $likes)
{
$responseIDs = array();
foreach ($likes as $like) {
$responseIDs[] = $like->objectID;
}
// get objects type ids
$responses = array();
$conditionBuilder = new PreparedStatementConditionBuilder();
$conditionBuilder->add('comment_response.responseID IN (?)', array($responseIDs));
$sql = "SELECT\t\tcomment.objectTypeID, comment_response.responseID\n\t\t\tFROM\t\twcf" . WCF_N . "_comment_response comment_response\n\t\t\tLEFT JOIN\twcf" . WCF_N . "_comment comment\n\t\t\tON\t\t(comment.commentID = comment_response.commentID)\n\t\t\t" . $conditionBuilder;
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditionBuilder->getParameters());
while ($row = $statement->fetchArray()) {
$responses[$row['responseID']] = $row['objectTypeID'];
}
// group likes by object type id
$likeData = array();
foreach ($likes as $like) {
if (isset($responses[$like->objectID])) {
if (!isset($likeData[$responses[$like->objectID]])) {
$likeData[$responses[$like->objectID]] = array();
}
$likeData[$responses[$like->objectID]][] = $like;
}
}
foreach ($likeData as $objectTypeID => $likes) {
$objectType = CommentHandler::getInstance()->getObjectType($objectTypeID);
if (CommentHandler::getInstance()->getCommentManager($objectType->objectType) instanceof IViewableLikeProvider) {
CommentHandler::getInstance()->getCommentManager($objectType->objectType)->prepare($likes);
}
}
}
示例14: rebuild
/**
* @see \wcf\system\cache\builder\AbstractCacheBuilder::rebuild()
*/
protected function rebuild(array $parameters)
{
$data = array();
// number of entry
$sql = "SELECT\tCOUNT(*) AS count,\n\t\t\t\tSUM(downloads) AS downloads\n\t\t\tFROM\tfilebase" . WCF_N . "_entry";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute();
$row = $statement->fetchArray();
$data['entries'] = $row['count'];
$data['downloads'] = $row['downloads'];
// number of comments
$sql = "SELECT\tSUM(comments) AS count\n\t\t\tFROM\tfilebase" . WCF_N . "_entry\n\t\t\tWHERE\tcomments > 0";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute();
$data['comments'] = $statement->fetchColumn();
// number of authors
$sql = "SELECT\tCOUNT(DISTINCT userID) AS count\n\t\t\tFROM\tfilebase" . WCF_N . "_entry";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute();
$data['authors'] = $statement->fetchColumn();
// files + total size
$sql = "SELECT\tCOUNT(*) AS files,\n\t\t\t\tSUM(filesize) AS size\n\t\t\tFROM\tfilebase" . WCF_N . "_file";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute();
$row = $statement->fetchArray();
$data['files'] = $row['files'];
$data['size'] = $row['size'];
// downloads per day
$days = ceil((TIME_NOW - FILEBASE_INSTALL_DATE) / 86400);
if ($days <= 0) {
$days = 1;
}
$data['downloadsPerDay'] = $data['downloads'] / $days;
return $data;
}
示例15: getPermissions
/**
* Returns the acl options for the given category and for the given user.
* If no user is given, the active user is used.
*
* @param wcf\data\category\Category $category
* @param wcf\data\user\User $user
*/
public function getPermissions(Category $category, User $user = null) {
if ($user === null) {
$user = WCF::getUser();
}
$permissions = array();
if (isset($this->categoryPermissions[$category->categoryID])) {
if (isset($this->categoryPermissions[$category->categoryID]['group'])) {
foreach ($user->getGroupIDs() as $groupID) {
if (isset($this->categoryPermissions[$category->categoryID]['group'][$groupID])) {
foreach ($this->categoryPermissions[$category->categoryID]['group'][$groupID] as $optionName => $optionValue) {
if (isset($permissions[$optionName])) {
$permissions[$optionName] = $permissions[$optionName] || $optionValue;
}
else {
$permissions[$optionName] = $optionValue;
}
}
}
}
}
if (isset($this->categoryPermissions[$category->categoryID]['user']) && isset($this->categoryPermissions[$category->categoryID]['user'][$user->userID])) {
foreach ($this->categoryPermissions[$category->categoryID]['user'][$user->userID] as $optionName => $optionValue) {
$permissions[$optionName] = $optionValue;
}
}
}
return $permissions;
}