/** * @see \wcf\system\importer\IImporter::import() */ public function import($oldID, array $data, array $additionalData = array()) { // copy smiley $data['smileyPath'] = 'images/smilies/' . basename($additionalData['fileLocation']); if (!@copy($additionalData['fileLocation'], WCF_DIR . $data['smileyPath'])) { return 0; } // check smileycode if (isset($this->knownCodes[mb_strtolower($data['smileyCode'])])) { return $this->knownCodes[mb_strtolower($data['smileyCode'])]; } $data['packageID'] = 1; if (!isset($data['aliases'])) { $data['aliases'] = ''; } // check aliases $aliases = array(); if (!empty($data['aliases'])) { $aliases = explode("\n", StringUtil::unifyNewlines($data['aliases'])); foreach ($aliases as $key => $alias) { if (isset($this->knownCodes[mb_strtolower($alias)])) { unset($aliases[$key]); } } $data['aliases'] = implode("\n", $aliases); } // get category id if (!empty($data['categoryID'])) { $data['categoryID'] = ImportHandler::getInstance()->getNewID('com.woltlab.wcf.smiley.category', $data['categoryID']); } // save smiley $smiley = SmileyEditor::create($data); // add smileyCode + aliases to knownCodes $this->knownCodes[mb_strtolower($data['smileyCode'])] = $smiley->smileyID; foreach ($aliases as $alias) { $this->knownCodes[mb_strtolower($alias)] = $smiley->smileyID; } return $smiley->smileyID; }
/** * @see \wcf\data\ISortableAction::updatePosition() */ public function updatePosition() { $smileyList = new SmileyList(); $smileyList->readObjects(); $i = $this->parameters['data']['offset']; WCF::getDB()->beginTransaction(); foreach ($this->parameters['data']['structure'][0] as $smileyID) { $smiley = $smileyList->search($smileyID); if ($smiley === null) { continue; } $editor = new SmileyEditor($smiley); $editor->update(array('showOrder' => $i++)); } WCF::getDB()->commitTransaction(); }
/** * @see \wcf\page\IForm::save() */ public function save() { parent::save(); $this->objectAction = new SmileyAction(array(), 'create', array('data' => array_merge($this->additionalFields, array('smileyTitle' => $this->smileyTitle, 'smileyCode' => $this->smileyCode, 'aliases' => $this->aliases, 'smileyPath' => $this->smileyPath, 'showOrder' => $this->showOrder, 'categoryID' => $this->categoryID ?: null, 'packageID' => 1)), 'fileLocation' => $this->uploadedFilename ? WCF_DIR . 'images/smilies/' . $this->uploadedFilename : '')); $this->objectAction->executeAction(); $returnValues = $this->objectAction->getReturnValues(); $smileyEditor = new SmileyEditor($returnValues['returnValues']); $smileyID = $returnValues['returnValues']->smileyID; if (!I18nHandler::getInstance()->isPlainValue('smileyTitle')) { I18nHandler::getInstance()->save('smileyTitle', 'wcf.smiley.title' . $smileyID, 'wcf.smiley', 1); // update title $smileyEditor->update(array('smileyTitle' => 'wcf.smiley.title' . $smileyID)); } // reset values $this->smileyCode = ''; $this->categoryID = 0; $this->showOrder = 0; $this->smileyPath = ''; $this->aliases = ''; $this->uploadedFilename = ''; I18nHandler::getInstance()->reset(); $this->saved(); // show success message WCF::getTPL()->assign('success', true); }