作者:jacbo
项目:Fireball_New
public function __construct()
{
parent::__construct();
// accessible news categories
$accessibleCategoryIDs = NewsCategory::getAccessibleCategoryIDs();
if (!empty($accessibleCategoryIDs)) {
$this->getConditionBuilder()->add('news.newsID IN (SELECT newsID FROM cms' . WCF_N . '_news_to_category WHERE categoryID IN (?))', array($accessibleCategoryIDs));
} else {
$this->getConditionBuilder()->add('1=0');
}
//get default settings
if (!WCF::getSession()->getPermission('mod.cms.news.canModerateNews')) {
$this->getConditionBuilder()->add('news.isDisabled = 0');
}
if (!WCF::getSession()->getPermission('mod.cms.news.canModerateNews')) {
$this->getConditionBuilder()->add('news.isDeleted = 0');
}
//can view delayed news
if (!WCF::getSession()->getPermission('user.cms.news.canViewDelayedNews')) {
$this->getConditionBuilder()->add('news.isDisabled = ?', array(0));
}
// 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()));
}
}
作者:joshuarueswe
项目:de.voolia.new
/**
* 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()));
}
}
作者:ZerGabrie
项目:WC
/**
* Loads the compiled language file.
* Compiles the language file before if necessary.
*/
public function loadLanguage()
{
$filename = TMP_DIR . 'setup/lang/cache/' . $this->languageCode . '_wcf.setup.php';
if (!file_exists($filename)) {
$xml = new XML();
$xml->load(TMP_DIR . 'setup/lang/setup_' . $this->languageCode . '.xml');
// get language items
$categoriesToCache = array();
$items = $xml->xpath()->query('/ns:language/ns:category/ns:item');
foreach ($items as $item) {
$categoriesToCache[] = array('name' => $item->getAttribute('name'), 'cdata' => $item->nodeValue);
}
// update language files here
if (count($categoriesToCache) > 0) {
$file = new File($filename);
$file->write("<?php\n/**\n* WoltLab Community Framework\n* language: " . $this->languageCode . "\n* encoding: UTF-8\n* category: WCF Setup\n* generated at " . gmdate("r") . "\n* \n* DO NOT EDIT THIS FILE\n*/\n");
foreach ($categoriesToCache as $name) {
$file->write("\$this->items['" . $name['name'] . "'] = '" . str_replace("'", "\\'", $name['cdata']) . "';\n");
// compile dynamic language variables
if (strpos($name['cdata'], '{') !== false) {
$compiledString = LanguageFactory::getInstance()->getScriptingCompiler()->compileString($name['name'], $name['cdata']);
$file->write("\$this->dynamicItems['" . $name['name'] . "'] = '" . str_replace("'", "\\'", $compiledString['template']) . "';\n");
}
}
$file->write("?>");
$file->close();
}
}
include_once $filename;
$this->setLocale();
}
作者:CaribeSo
项目:article-cor
/**
* {@inheritdoc}
*/
public function update()
{
//get classes
$baseClass = $this->className;
$articleClass = $baseClass::getBaseClass();
//count attachments
if (isset($this->parameters['attachmentHandler']) && $this->parameters['attachementHandler'] !== null) {
$data['attachments'] = count($this->parameters['attachmentHandler']);
}
parent::update();
foreach ($this->objects as $article) {
$this->objectIDs[] = $article->{$baseClass::getDatabaseTableIndexName()};
}
foreach ($this->objects as $news) {
if (isset($this->parameters['categoryIDs'])) {
$news->updateCategoryIDs($this->parameters['categoryIDs']);
}
// update tags
$tags = array();
if (isset($this->parameters['tags'])) {
$tags = $this->parameters['tags'];
unset($this->parameters['tags']);
}
if (!empty($tags)) {
$languageID = !isset($this->parameters['data']['languageID']) || $this->parameters['data']['languageID'] === null ? LanguageFactory::getInstance()->getDefaultLanguageID() : $this->parameters['data']['languageID'];
TagEngine::getInstance()->addObjectTags($articleClass::$objectType, $article->{$baseClass::getDatabaseTableIndexName()}, $tags, $languageID);
}
}
}
作者:nick-stroh
项目:WC
/**
* Creates a new ViewableUserActivityEventList object.
*/
public function __construct()
{
parent::__construct();
if (LanguageFactory::getInstance()->multilingualismEnabled() && count(WCF::getUser()->getLanguageIDs())) {
$this->getConditionBuilder()->add('(user_activity_event.languageID IN (?) OR user_activity_event.languageID IS NULL)', array(WCF::getUser()->getLanguageIDs()));
}
}
作者:Gribori
项目:de.incendium.cms.new
/**
* Creates a new NewsCategoryList object.
*
* @param array<integer> $categoryIDs
*/
public function __construct(array $categoryIDs)
{
ViewableEntryList::__construct();
// accessible news categories
if (!empty($categoryIDs)) {
$this->getConditionBuilder()->add('news_entry_to_category.categoryID IN (?)', array($categoryIDs));
$this->getConditionBuilder()->add('news_entry.entryID = news_entry_to_category.entryID');
} else {
$this->getConditionBuilder()->add('1=0');
}
// default conditions
if (!WCF::getSession()->getPermission('mod.news.canModerateEntry')) {
$this->getConditionBuilder()->add('news_entry.isDisabled = 0');
}
if (!WCF::getSession()->getPermission('mod.news.canViewDeletedEntry')) {
$this->getConditionBuilder()->add('news_entry.isDeleted = 0');
}
if (WCF::getUser()->userID) {
$this->getConditionBuilder()->add('(news_entry.isPublished = 1 OR news_entry.userID = ?)', array(WCF::getUser()->userID));
} else {
$this->getConditionBuilder()->add('news_entry.isPublished = 1');
}
// apply language filter
if (LanguageFactory::getInstance()->multilingualismEnabled() && count(WCF::getUser()->getLanguageIDs())) {
$this->getConditionBuilder()->add('(news_entry.languageID IN (?) OR news_entry.languageID IS NULL)', array(WCF::getUser()->getLanguageIDs()));
}
}
作者:nick-stroh
项目:WC
/**
* @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;
}
作者:nick-stroh
项目:WC
/**
* @see \wcf\data\IEditableObject::create()
*/
public static function create(array $parameters = array())
{
$descriptions = array();
if (isset($parameters['description']) && is_array($parameters['description'])) {
if (count($parameters['description']) > 1) {
$descriptions = $parameters['description'];
$parameters['description'] = '';
} else {
$parameters['description'] = reset($parameters['description']);
}
}
$cronjob = parent::create($parameters);
// save cronjob description
if (!empty($descriptions)) {
// set default value
if (isset($descriptions[''])) {
$defaultValue = $descriptions[''];
} else {
if (isset($descriptions['en'])) {
// fallback to English
$defaultValue = $descriptions['en'];
} else {
if (isset($descriptions[WCF::getLanguage()->getFixedLanguageCode()])) {
// fallback to the language of the current user
$defaultValue = $descriptions[WCF::getLanguage()->getFixedLanguageCode()];
} else {
// fallback to first description
$defaultValue = reset($descriptions);
}
}
}
// fetch data directly from database during framework installation
if (!PACKAGE_ID) {
$sql = "SELECT\t*\n\t\t\t\t\tFROM\twcf" . WCF_N . "_language_category\n\t\t\t\t\tWHERE\tlanguageCategory = ?";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute(array('wcf.acp.cronjob'));
$languageCategory = $statement->fetchObject('wcf\\data\\language\\category\\LanguageCategory');
$languages = new LanguageList();
$languages->readObjects();
} else {
$languages = LanguageFactory::getInstance()->getLanguages();
$languageCategory = LanguageFactory::getInstance()->getCategory('wcf.acp.cronjob');
}
$sql = "INSERT INTO\twcf" . WCF_N . "_language_item\n\t\t\t\t\t\t(languageID, languageItem, languageItemValue, languageCategoryID, packageID)\n\t\t\t\tVALUES\t\t(?, ?, ?, ?, ?)\n\t\t\t\tON DUPLICATE KEY UPDATE languageItemValue = VALUES(languageItemValue)";
$statement = WCF::getDB()->prepareStatement($sql);
foreach ($languages as $language) {
$value = $defaultValue;
if (isset($descriptions[$language->languageCode])) {
$value = $descriptions[$language->languageCode];
}
$statement->execute(array($language->languageID, 'wcf.acp.cronjob.description.cronjob' . $cronjob->cronjobID, $value, $languageCategory->languageCategoryID, $cronjob->packageID));
}
// update cronjob
$cronjobEditor = new CronjobEditor($cronjob);
$cronjobEditor->update(array('description' => 'wcf.acp.cronjob.description.cronjob' . $cronjob->cronjobID));
}
return $cronjob;
}
作者:nick-stroh
项目:WC
/**
* Contructs a new TagCloud object.
*
* @param array<integer> $languageIDs
*/
public function __construct(array $languageIDs = array())
{
$this->languageIDs = $languageIDs;
if (empty($this->languageIDs)) {
$this->languageIDs = array_keys(LanguageFactory::getInstance()->getLanguages());
}
// init cache
$this->loadCache();
}
作者:CaribeSo
项目:be.bastelstu.wcf.fake
/**
* @see \wcf\page\IPage::assignVariables()
*/
public function readData()
{
parent::readData();
foreach (static::$providerLocales as $locale) {
$languageCode = substr($locale, 0, 2);
if (\wcf\system\language\LanguageFactory::getInstance()->getLanguageByCode($languageCode)) {
$this->availableLocales[$locale] = \wcf\system\WCF::getLanguage()->get('wcf.acp.faker.locale.' . $locale);
}
}
}
作者:nick-stroh
项目:WC
/**
* @see \wcf\form\IForm::save()
*/
public function save()
{
AbstractForm::save();
$editor = new LanguageEditor($this->language);
$editor->update(array('countryCode' => mb_strtolower($this->countryCode), 'languageName' => $this->languageName, 'languageCode' => mb_strtolower($this->languageCode)));
LanguageFactory::getInstance()->clearCache();
$this->saved();
// show success message
WCF::getTPL()->assign('success', true);
}
作者:knz
项目:Firebal
/**
* @see \cms\system\content\type\ISearchableContentType::getSearchableData()
*/
public function getSearchableData(Content $content)
{
foreach (LanguageFactory::getInstance()->getLanguages() as $language) {
$this->searchIndexData[$language->languageID] = array();
foreach ($this->searchableFields as $field) {
$this->searchIndexData[$language->languageID][] = $language->get($content->{$field});
}
$this->searchIndexData[$language->languageID] = implode("\n", $this->searchIndexData[$language->languageID]);
}
return $this->searchIndexData;
}
作者:Gribori
项目:de.incendium.cms.new
/**
* @see \wcf\system\dashboard\box\IDashboardBox::init()
*/
public function init(DashboardBox $box, IPage $page)
{
parent::init($box, $page);
if (MODULE_TAGGING && WCF::getSession()->getPermission('user.tag.canViewTag') && WCF::getSession()->getPermission('user.news.canReadEntry')) {
$languageIDs = array();
if (LanguageFactory::getInstance()->multilingualismEnabled()) {
$languageIDs = WCF::getUser()->getLanguageIDs();
}
$this->tagCloud = new TypedTagCloud('de.incendium.cms.news.entry', $languageIDs);
}
$this->fetched();
}
作者:joshuarueswe
项目:de.voolia.new
/**
* @see \wcf\system\dashboard\box\IDashboardBox::init()
*/
public function init(DashboardBox $box, IPage $page)
{
parent::init($box, $page);
if (MODULE_TAGGING) {
$languageIDs = array();
if (LanguageFactory::getInstance()->multilingualismEnabled()) {
$languageIDs = WCF::getUser()->getLanguageIDs();
}
// get tag cloud for news entries
$this->tagCloud = new TypedTagCloud('de.voolia.news.entry', $languageIDs);
}
$this->fetched();
}
作者:Gribori
项目:de.incendium.cms.filebas
/**
* @inheritDoc
*/
protected function loadContent()
{
if (MODULE_TAGGING && WCF::getSession()->getPermission('user.tag.canViewTag') && WCF::getSession()->getPermission('user.filebase.canViewEntry')) {
$languageIDs = [];
if (LanguageFactory::getInstance()->multilingualismEnabled()) {
$languageIDs = WCF::getUser()->getLanguageIDs();
}
$tagCloud = new TypedTagCloud('de.incendium.filebase.entry', $languageIDs);
$tags = $tagCloud->getTags();
if (!empty($tags)) {
$this->content = WCF::getTPL()->fetch('tagCloudBox', 'wcf', ['tags' => $tags, 'taggableObjectType' => 'de.incendium.filebase.entry']);
}
}
}
作者:nick-stroh
项目:WC
/**
* @see \wcf\action\IAction::execute()
*/
public function execute()
{
parent::execute();
// reset stylesheets
StyleHandler::resetStylesheets();
// delete language cache and compiled templates as well
LanguageFactory::getInstance()->deleteLanguageCache();
// get package dirs
CacheHandler::getInstance()->flushAll();
$this->executed();
if (!isset($_POST['noRedirect'])) {
HeaderUtil::redirect(LinkHandler::getInstance()->getLink('CacheList'));
}
exit;
}
作者:0xLeo
项目:WC
/**
* Uninstalls node components and returns next node.
*
* @param string $node
* @return string
*/
public function uninstall($node) {
$nodes = $this->nodeBuilder->getNodeData($node);
// invoke node-specific actions
foreach ($nodes as $data) {
$nodeData = unserialize($data['nodeData']);
switch ($data['nodeType']) {
case 'package':
$this->uninstallPackage($nodeData);
break;
case 'pip':
$this->executePIP($nodeData);
break;
}
}
// mark node as completed
$this->nodeBuilder->completeNode($node);
$node = $this->nodeBuilder->getNextNode($node);
// perform post-uninstall actions
if ($node == '') {
// update options.inc.php if uninstallation is completed
OptionEditor::resetCache();
// clear cache
CacheHandler::getInstance()->flushAll();
// reset language cache
LanguageFactory::getInstance()->clearCache();
LanguageFactory::getInstance()->deleteLanguageCache();
// reset stylesheets
StyleHandler::resetStylesheets();
// rebuild application paths
ApplicationHandler::rebuild();
}
if ($this->requireRestructureVersionTables) {
$this->restructureVersionTables();
}
// return next node
return $node;
}
作者:Gribori
项目:de.incendium.cms.linklis
/**
* Calculates the number of entries.
*/
protected function initEntries()
{
$this->entries = array();
$conditionBuilder = new PreparedStatementConditionBuilder();
$conditionBuilder->add('entry.isDisabled = ?', array(0));
$conditionBuilder->add('entry.isDeleted = ?', array(0));
// apply language filter
if (LanguageFactory::getInstance()->multilingualismEnabled() && count(WCF::getUser()->getLanguageIDs())) {
$conditionBuilder->add('(entry.languageID IN (?) OR entry.languageID IS NULL)', array(WCF::getUser()->getLanguageIDs()));
}
$sql = "SELECT\t\tCOUNT(*) AS count, entry_to_category.categoryID\n\t\t\tFROM\t\tlinklist" . WCF_N . "_entry entry\n\t\t\tLEFT JOIN\tlinklist" . WCF_N . "_entry_to_category entry_to_category\n\t\t\tON\t\t(entry_to_category.entryID = entry.entryID)\n\t\t\t" . $conditionBuilder . "\n\t\t\tGROUP BY\tentry_to_category.categoryID";
$statement = WCF::getDB()->prepareStatement($sql);
$statement->execute($conditionBuilder->getParameters());
while ($row = $statement->fetchArray()) {
$this->entries[$row['categoryID']] = $row['count'];
}
}
作者:jacbo
项目:Fireball_New
public function getConditions(IForm $form = null)
{
$conditionBuilder = new PreparedStatementConditionBuilder();
// accessible category ids
$categoryIDs = NewsCategory::getAccessibleCategoryIDs();
if (empty($categoryIDs)) {
throw new PermissionDeniedException();
}
$conditionBuilder->add($this->getTableName() . '.newsID IN (SELECT newsID FROM cms' . WCF_N . '_news_to_category WHERE categoryID IN (?))', array($categoryIDs));
// default conditions
$conditionBuilder->add($this->getTableName() . '.isDisabled = 0');
$conditionBuilder->add($this->getTableName() . '.isDeleted = 0');
// language
if (LanguageFactory::getInstance()->multilingualismEnabled() && count(WCF::getUser()->getLanguageIDs())) {
$conditionBuilder->add('(' . $this->getTableName() . '.languageID IN (?) OR ' . $this->getTableName() . '.languageID IS NULL)', array(WCF::getUser()->getLanguageIDs()));
}
return $conditionBuilder;
}
作者:joshuarueswe
项目:de.voolia.new
/**
* @see \wcf\system\importer\IImporter::import()
*/
public function import($oldID, array $data, array $additionalData = array())
{
// get user id
$data['userID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.user', $data['userID']);
// get news id
if (is_numeric($oldID)) {
$news = new News($oldID);
if (!$news->newsID) {
$data['newsID'] = $oldID;
}
}
// get news categories
$categoryIDs = array();
if (!empty($additionalData['categories'])) {
foreach ($additionalData['categories'] as $oldCategoryID) {
$newCategoryID = ImportHandler::getInstance()->getNewID('de.voolia.news.category', $oldCategoryID);
if ($newCategoryID) {
$categoryIDs[] = $newCategoryID;
}
}
}
// work-around for unknown username
if (empty($data['username'])) {
$user = new User($data['userID']);
$data['username'] = $user->username;
}
// get language by languageCode
if (!empty($additionalData['languageCode'])) {
if (($language = LanguageFactory::getInstance()->getLanguageByCode($additionalData['languageCode'])) !== null) {
$data['languageID'] = $language->languageID;
}
}
// create news
$news = NewsEditor::create($data);
$newsEditor = new NewsEditor($news);
// save the tags from news entry
if (!empty($additionalData['tags'])) {
TagEngine::getInstance()->addObjectTags('de.voolia.news.entry', $news->newsID, $additionalData['tags'], $news->languageID ?: LanguageFactory::getInstance()->getDefaultLanguageID());
}
// update news categories
$newsEditor->updateCategoryIDs($categoryIDs);
ImportHandler::getInstance()->saveNewID('de.voolia.news.entry', $oldID, $news->newsID);
return $news->newsID;
}