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


PHP StringUtil::getRandomID方法代码示例

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


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

示例1: uploadAttachment

 /**
  * upload an attachment
  *
  * @param  Integer  $forumId
  * @param  String  $groupId
  * @return  Object  $oMbqEtAtt
  */
 public function uploadAttachment($oMbqEtForum, $groupId = null)
 {
     //ref wcf\action\AJAXUploadAction,wcf\action\AJAXProxyAction,wcf\data\attachment\AttachmentAction
     $parameters['objectType'] = 'com.woltlab.wbb.post';
     $parameters['objectID'] = 0;
     $parameters['tmpHash'] = $groupId ? $groupId : StringUtil::getRandomID();
     $parameters['parentObjectID'] = $oMbqEtForum->forumId->oriValue;
     $parameters['__files'] = UploadHandler::getUploadHandler('attachment');
     //ref AJAXUploadAction::readParameters()
     $oAttachmentAction = new AttachmentAction(array(), 'upload', $parameters);
     //ref AJAXProxyAction::invoke()
     $oAttachmentAction->validateAction();
     //todo:catch exception
     $ret = $oAttachmentAction->executeAction();
     //todo:catch exception
     if ($ret['returnValues']['attachments']) {
         $r = array_shift($ret['returnValues']['attachments']);
         $oMbqEtAtt = MbqMain::$oClk->newObj('MbqEtAtt');
         $oMbqEtAtt->attId->setOriValue($r['attachmentID']);
         $oMbqEtAtt->groupId->setOriValue($parameters['tmpHash']);
         $oMbqEtAtt->filtersSize->setOriValue($r['filesize']);
         $oMbqEtAtt->uploadFileName->setOriValue($r['filename']);
         return $oMbqEtAtt;
     } else {
         MbqError::alert('', "Upload attachment failed!", '', MBQ_ERR_APP);
     }
 }
开发者ID:keweiliu6,项目名称:test-kunena3,代码行数:34,代码来源:MbqWrEtAtt.php

示例2: 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;
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:29,代码来源:UserOptionImporter.class.php

示例3: actionImplement

 /**
  * action implement
  */
 public function actionImplement()
 {
     if (!MbqMain::$oMbqConfig->moduleIsEnable('forum')) {
         MbqError::alert('', "Not support module forum!", '', MBQ_ERR_NOT_SUPPORT);
     }
     $forumId = MbqMain::$input['forum_id'];
     $groupId = MbqMain::$input['group_id'] ? MbqMain::$input['group_id'] : StringUtil::getRandomID();
     $oMbqRdEtForum = MbqMain::$oClk->newObj('MbqRdEtForum');
     $objsMbqEtForum = $oMbqRdEtForum->getObjsMbqEtForum(array($forumId), array('case' => 'byForumIds'));
     if ($objsMbqEtForum && ($oMbqEtForum = $objsMbqEtForum[0])) {
         $oMbqAclEtAtt = MbqMain::$oClk->newObj('MbqAclEtAtt');
         if ($oMbqAclEtAtt->canAclUploadAttach($oMbqEtForum)) {
             //acl judge
             $oMbqWrEtAtt = MbqMain::$oClk->newObj('MbqWrEtAtt');
             $oMbqEtAtt = $oMbqWrEtAtt->uploadAttachment($forumId, $groupId);
             $oMbqRdEtAtt = MbqMain::$oClk->newObj('MbqRdEtAtt');
             $this->data['result'] = true;
             $data1 = $oMbqRdEtAtt->returnApiDataAttachment($oMbqEtAtt);
             MbqMain::$oMbqCm->mergeApiData($this->data, $data1);
         } else {
             MbqError::alert('', '', '', MBQ_ERR_APP);
         }
     } else {
         MbqError::alert('', "Need valid forum id!", '', MBQ_ERR_APP);
     }
 }
开发者ID:ZerGabriel,项目名称:wbb,代码行数:29,代码来源:MbqActUploadAttach.php

示例4: update

 /**
  * @see	\wcf\data\DatabaseObjectEditor::update()
  */
 public function update(array $parameters = array())
 {
     // update salt and create new password hash
     if (isset($parameters['password']) && $parameters['password'] !== '') {
         $parameters['password'] = PasswordUtil::getDoubleSaltedHash($parameters['password']);
         $parameters['accessToken'] = StringUtil::getRandomID();
         // update accessToken
         $this->accessToken = $parameters['accessToken'];
     } else {
         unset($parameters['password'], $parameters['accessToken']);
     }
     parent::update($parameters);
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:16,代码来源:UserEditor.class.php

示例5: replaceContentCallback

 /**
  * Reorders content to provide a logical order. In fact the content of
  * '{content}' is moved outside the if-condition in order to capture
  * the content during runtime, safely determining wether content is empty
  * or not.
  * 
  * @param	array		$matches
  * @return	string
  */
 protected static function replaceContentCallback(array $matches)
 {
     $beforeContent = $matches[1];
     $content = $matches[2];
     $afterContent = $matches[3];
     $elseContent = isset($matches[5]) ? $matches[5] : '';
     $variable = 'hascontent_' . StringUtil::getRandomID();
     $newContent = '{capture assign=' . $variable . '}' . $content . '{/capture}' . "\n";
     $newContent .= '{assign var=' . $variable . ' value=$' . $variable . '|trim}' . "\n";
     $newContent .= '{if $' . $variable . '}' . $beforeContent . '{@$' . $variable . '}' . "\n" . $afterContent;
     if (!empty($elseContent)) {
         $newContent .= '{else}' . $elseContent . "\n";
     }
     $newContent .= '{/if}' . "\n";
     return $newContent;
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:25,代码来源:HascontentPrefilterTemplatePlugin.class.php

示例6: executeStart

 /**
  * @see	\wcf\system\template\ICompilerTemplatePlugin::executeStart()
  */
 public function executeStart($tagArgs, TemplateScriptingCompiler $compiler)
 {
     $compiler->pushTag('implode');
     if (!isset($tagArgs['from'])) {
         throw new SystemException($compiler->formatSyntaxError("missing 'from' argument in implode tag", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
     }
     if (!isset($tagArgs['item'])) {
         throw new SystemException($compiler->formatSyntaxError("missing 'item' argument in implode tag", $compiler->getCurrentIdentifier(), $compiler->getCurrentLineNo()));
     }
     $hash = StringUtil::getRandomID();
     $glue = isset($tagArgs['glue']) ? $tagArgs['glue'] : "', '";
     $this->tagStack[] = array('hash' => $hash, 'glue' => $glue);
     $phpCode = "<?php\n";
     $phpCode .= "\$_length" . $hash . " = count(" . $tagArgs['from'] . ");\n";
     $phpCode .= "\$_i" . $hash . " = 0;\n";
     $phpCode .= "foreach (" . $tagArgs['from'] . " as " . (isset($tagArgs['key']) ? (mb_substr($tagArgs['key'], 0, 1) != '$' ? "\$this->v[" . $tagArgs['key'] . "]" : $tagArgs['key']) . " => " : '') . (mb_substr($tagArgs['item'], 0, 1) != '$' ? "\$this->v[" . $tagArgs['item'] . "]" : $tagArgs['item']) . ") { ?>";
     return $phpCode;
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:21,代码来源:ImplodeCompilerTemplatePlugin.class.php

示例7: replaceContentCallback

	/**
	 * Reorders content to provide a logical order. In fact the content of
	 * '{content}' is moved outside the if-condition in order to capture
	 * the content during runtime, safely determining wether content is empty
	 * or not.
	 * 
	 * @param	array		$matches
	 * @return	string
	 */
	protected static function replaceContentCallback(array $matches) {
		$beforeContent = $matches['before'];
		$content = $matches['content'];
		$afterContent = $matches['after'];
		$elseContent = (isset($matches['else'])) ? $matches['else'] : '';
		$assignContent = (isset($matches['assign']) && !empty($matches['assign'])) ? $matches['assign'] : '';
		$variable = 'hascontent_' . StringUtil::getRandomID();
		
		$newContent = '{capture assign='.$variable.'}'.$content.'{/capture}'."\n";
		$newContent .= '{assign var='.$variable.' value=$'.$variable.'|trim}'."\n";
		
		if ($assignContent) $newContent .= '{capture assign='.$assignContent.'}'."\n";
		$newContent .= '{if $'.$variable.'}'.$beforeContent.'{@$'.$variable.'}'."\n".$afterContent;
		
		if (!empty($elseContent)) {
			$newContent .= '{else}'.$elseContent."\n";
		}
		
		$newContent .= '{/if}'."\n";
		
		if ($assignContent) $newContent .= "{/capture}\n{@$".$assignContent."}\n";
		
		return $newContent;
	}
开发者ID:0xLeon,项目名称:WCF,代码行数:33,代码来源:HascontentPrefilterTemplatePlugin.class.php

示例8: readParameters

 /**
  * @see	\wcf\page\IPage::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     I18nHandler::getInstance()->register('styleDescription');
     $this->setVariables();
     if (empty($_POST)) {
         $this->readStyleVariables();
     }
     $templateGroupList = new TemplateGroupList();
     $templateGroupList->sqlOrderBy = "templateGroupName";
     $templateGroupList->readObjects();
     $this->availableTemplateGroups = $templateGroupList->getObjects();
     if (isset($_REQUEST['tmpHash'])) {
         $this->tmpHash = StringUtil::trim($_REQUEST['tmpHash']);
     }
     if (empty($this->tmpHash)) {
         $this->tmpHash = StringUtil::getRandomID();
     }
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:22,代码来源:StyleAddForm.class.php

示例9: initOMbqEtForum

 /**
  * init one forum by condition
  *
  * @param  Mixed  $var
  * @param  Array  $mbqOpt
  * $mbqOpt['case'] = 'byForumId' means init forum by forum id
  * $mbqOpt['case'] = 'oDetailedBoardNode' means init forum by oDetailedBoardNode
  * @return  Mixed
  */
 public function initOMbqEtForum($var = null, $mbqOpt = array())
 {
     if ($mbqOpt['case'] == 'byForumId') {
         if (isset(MbqMain::$oMbqAppEnv->exttAllForums[$var])) {
             return MbqMain::$oMbqAppEnv->exttAllForums[$var];
         }
         return false;
     } elseif ($mbqOpt['case'] == 'oDetailedBoardNode') {
         $oBoard = $var->getBoard();
         $oMbqEtForum = MbqMain::$oClk->newObj('MbqEtForum');
         $oMbqEtForum->forumId->setOriValue($oBoard->boardID);
         $oMbqEtForum->forumName->setOriValue($oBoard->getTitle());
         $oMbqEtForum->description->setOriValue($oBoard->description);
         $oMbqEtForum->totalTopicNum->setOriValue($var->getThreads());
         $oMbqEtForum->totalPostNum->setOriValue($var->getPosts());
         $oMbqEtForum->parentId->setOriValue($oBoard->parentID);
         if ($var->getUnreadThreads()) {
             $oMbqEtForum->newPost->setOriValue(MbqBaseFdt::getFdt('MbqFdtForum.MbqEtForum.newPost.range.yes'));
         }
         if ($oBoard->isExternalLink()) {
             $oMbqEtForum->url->setOriValue($oBoard->getLink());
         }
         if ($oBoard->isCategory()) {
             $oMbqEtForum->subOnly->setOriValue(MbqBaseFdt::getFdt('MbqFdtForum.MbqEtForum.subOnly.range.yes'));
         } elseif ($oBoard->isBoard()) {
             $oMbqEtForum->subOnly->setOriValue(MbqBaseFdt::getFdt('MbqFdtForum.MbqEtForum.subOnly.range.no'));
         }
         $oMbqAclEtForumTopic = MbqMain::$oClk->newObj('MbqAclEtForumTopic');
         $oMbqEtForum->mbqBind['oDetailedBoardNode'] = $var;
         if ($oMbqAclEtForumTopic->canAclNewTopic($oMbqEtForum)) {
             $oMbqEtForum->canPost->setOriValue(MbqBaseFdt::getFdt('MbqFdtForum.MbqEtForum.canPost.range.yes'));
         } else {
             $oMbqEtForum->canPost->setOriValue(MbqBaseFdt::getFdt('MbqFdtForum.MbqEtForum.canPost.range.no'));
         }
         $attachmentObjectType = 'com.woltlab.wbb.post';
         $attachmentObjectID = 0;
         $attachmentParentObjectID = $oBoard->boardID;
         $oAttachmentHandler = new AttachmentHandler($attachmentObjectType, $attachmentObjectID, \wcf\util\StringUtil::getRandomID(), $attachmentParentObjectID);
         if ($oAttachmentHandler->canUpload()) {
             $oMbqEtForum->canUpload->setOriValue(MbqBaseFdt::getFdt('MbqFdtForum.MbqEtForum.canUpload.range.yes'));
         } else {
             $oMbqEtForum->canUpload->setOriValue(MbqBaseFdt::getFdt('MbqFdtForum.MbqEtForum.canUpload.range.no'));
         }
         return $oMbqEtForum;
     }
     MbqError::alert('', __METHOD__ . ',line:' . __LINE__ . '.' . MBQ_ERR_INFO_UNKNOWN_CASE);
 }
开发者ID:keweiliu6,项目名称:test-kunena3,代码行数:56,代码来源:MbqRdEtForum.php

示例10: save

 /**
  * @see wcf\form\IForm::save()
  */
 public function save()
 {
     // generate salt
     $salt = StringUtil::getRandomID();
     // write master password file
     $file = new File(WCF_DIR . 'acp/masterPassword.inc.php');
     $file->write("<?php\n/** MASTER PASSWORD STORAGE\nDO NOT EDIT THIS FILE */\ndefine('MASTER_PASSWORD', '" . StringUtil::getSaltedHash($this->masterPassword, $salt) . "');\ndefine('MASTER_PASSWORD_SALT', '" . $salt . "');\n?>");
     $file->close();
     @chmod(WCF_DIR . 'acp/masterPassword.inc.php', 0777);
     parent::save();
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:14,代码来源:MasterPasswordInitForm.class.php

示例11: setBoundary

 /**
  * Creates a boundary for mutlipart/mixed Mail 
  */
 protected function setBoundary()
 {
     $this->boundary = "==Multipart_Boundary_x" . StringUtil::getRandomID() . "x";
 }
开发者ID:ZerGabriel,项目名称:WCF,代码行数:7,代码来源:Mail.class.php

示例12: getToken

 /**
  * Returns a short SHA1-hash.
  * 
  * @return	string
  */
 protected function getToken()
 {
     return mb_substr(StringUtil::getRandomID(), 0, 8);
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:9,代码来源:PackageInstallationNodeBuilder.class.php

示例13: save

 /**
  * @see	\wcf\form\IForm::save()
  */
 public function save()
 {
     parent::save();
     $this->objectAction = new UserOptionAction(array(), 'create', array('data' => array_merge($this->additionalFields, array('optionName' => StringUtil::getRandomID(), 'categoryName' => $this->categoryName, 'optionType' => $this->optionType, 'defaultValue' => $this->defaultValue, 'showOrder' => $this->showOrder, 'outputClass' => $this->outputClass, 'validationPattern' => $this->validationPattern, 'selectOptions' => $this->selectOptions, 'required' => $this->required, 'askDuringRegistration' => $this->askDuringRegistration, 'searchable' => $this->searchable, 'editable' => $this->editable, 'visible' => $this->visible, 'packageID' => 1, 'additionalData' => $this->optionType == 'select' ? serialize(array('allowEmptyValue' => true)) : ''))));
     $this->objectAction->executeAction();
     $returnValues = $this->objectAction->getReturnValues();
     $userOption = $returnValues['returnValues'];
     // save language vars
     I18nHandler::getInstance()->save('optionName', 'wcf.user.option.option' . $userOption->optionID, 'wcf.user.option');
     I18nHandler::getInstance()->save('optionDescription', 'wcf.user.option.option' . $userOption->optionID . '.description', 'wcf.user.option');
     $editor = new UserOptionEditor($userOption);
     $editor->update(array('optionName' => 'option' . $userOption->optionID));
     $this->saved();
     // reset values
     $this->optionName = $this->optionDescription = $this->categoryName = $this->optionType = $this->defaultValue = $this->validationPattern = $this->selectOptions = $this->outputClass = '';
     $this->optionType = 'text';
     $this->required = $this->searchable = $this->showOrder = $this->askDuringRegistration = 0;
     $this->editable = 3;
     $this->visible = 15;
     I18nHandler::getInstance()->reset();
     // show success
     WCF::getTPL()->assign('success', true);
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:26,代码来源:UserOptionAddForm.class.php

示例14: __construct

 /**
  * Constructs a new instance of HTTPRequest.
  * 
  * @param	string		$url		URL to connect to
  * @param	array<string>	$options
  * @param	mixed		$postParameters	Parameters to send via POST
  * @param	array		$files		Files to attach to the request
  */
 public function __construct($url, array $options = array(), $postParameters = array(), array $files = array())
 {
     $this->setURL($url);
     $this->postParameters = $postParameters;
     $this->files = $files;
     $this->setOptions($options);
     // set default headers
     $this->addHeader('user-agent', "HTTP.PHP (HTTPRequest.class.php; WoltLab Community Framework/" . WCF_VERSION . "; " . WCF::getLanguage()->languageCode . ")");
     $this->addHeader('accept', '*/*');
     $this->addHeader('accept-language', WCF::getLanguage()->getFixedLanguageCode());
     if (isset($this->options['maxLength'])) {
         $this->addHeader('Range', 'bytes=0-' . ($this->options['maxLength'] - 1));
     }
     if ($this->options['method'] !== 'GET') {
         if (empty($this->files)) {
             if (is_array($postParameters)) {
                 $this->body = http_build_query($this->postParameters, '', '&');
             } else {
                 if (is_string($postParameters) && !empty($postParameters)) {
                     $this->body = $postParameters;
                 }
             }
             $this->addHeader('content-type', 'application/x-www-form-urlencoded');
         } else {
             $boundary = StringUtil::getRandomID();
             $this->addHeader('content-type', 'multipart/form-data; boundary=' . $boundary);
             // source of the iterators: http://stackoverflow.com/a/7623716/782822
             if (!empty($this->postParameters)) {
                 $iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($this->postParameters), \RecursiveIteratorIterator::SELF_FIRST);
                 foreach ($iterator as $k => $v) {
                     if (!$iterator->hasChildren()) {
                         $key = '';
                         for ($i = 0, $max = $iterator->getDepth(); $i <= $max; $i++) {
                             if ($i === 0) {
                                 $key .= $iterator->getSubIterator($i)->key();
                             } else {
                                 $key .= '[' . $iterator->getSubIterator($i)->key() . ']';
                             }
                         }
                         $this->body .= "--" . $boundary . "\r\n";
                         $this->body .= 'Content-Disposition: form-data; name="' . $key . '"' . "\r\n\r\n";
                         $this->body .= $v . "\r\n";
                     }
                 }
             }
             $iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($this->files), \RecursiveIteratorIterator::SELF_FIRST);
             foreach ($iterator as $k => $v) {
                 if (!$iterator->hasChildren()) {
                     $key = '';
                     for ($i = 0, $max = $iterator->getDepth(); $i <= $max; $i++) {
                         if ($i === 0) {
                             $key .= $iterator->getSubIterator($i)->key();
                         } else {
                             $key .= '[' . $iterator->getSubIterator($i)->key() . ']';
                         }
                     }
                     $this->body .= "--" . $boundary . "\r\n";
                     $this->body .= 'Content-Disposition: form-data; name="' . $k . '"; filename="' . basename($v) . '"' . "\r\n";
                     $this->body .= 'Content-Type: ' . (FileUtil::getMimeType($v) ?: 'application/octet-stream.') . "\r\n\r\n";
                     $this->body .= file_get_contents($v) . "\r\n";
                 }
             }
             $this->body .= "--" . $boundary . "--";
         }
         $this->addHeader('content-length', strlen($this->body));
     }
     if (isset($this->options['auth'])) {
         $this->addHeader('authorization', "Basic " . base64_encode($options['auth']['username'] . ":" . $options['auth']['password']));
     }
     $this->addHeader('connection', 'Close');
 }
开发者ID:nick-strohm,项目名称:WCF,代码行数:79,代码来源:HTTPRequest.class.php

示例15: import

 /**
  * Imports a style.
  * 
  * @param	string		$filename
  * @param	integer		$packageID
  * @param	StyleEditor	$style
  * @return	StyleEditor
  */
 public static function import($filename, $packageID = 1, StyleEditor $style = null)
 {
     // open file
     $tar = new Tar($filename);
     // get style data
     $data = self::readStyleData($tar);
     $styleData = array('styleName' => $data['name'], 'variables' => $data['variables'], 'styleVersion' => $data['version'], 'styleDate' => $data['date'], 'copyright' => $data['copyright'], 'license' => $data['license'], 'authorName' => $data['authorName'], 'authorURL' => $data['authorURL']);
     // create template group
     if (!empty($data['templates'])) {
         $templateGroupName = $originalTemplateGroupName = $data['name'];
         $templateGroupFolderName = preg_replace('/[^a-z0-9_-]/i', '', $templateGroupName);
         if (empty($templateGroupFolderName)) {
             $templateGroupFolderName = 'generic' . mb_substr(StringUtil::getRandomID(), 0, 8);
         }
         $originalTemplateGroupFolderName = $templateGroupFolderName;
         // get unique template group name
         $i = 1;
         while (true) {
             $sql = "SELECT\tCOUNT(*) AS count\n\t\t\t\t\tFROM\twcf" . WCF_N . "_template_group\n\t\t\t\t\tWHERE\ttemplateGroupName = ?";
             $statement = WCF::getDB()->prepareStatement($sql);
             $statement->execute(array($templateGroupName));
             $row = $statement->fetchArray();
             if (!$row['count']) {
                 break;
             }
             $templateGroupName = $originalTemplateGroupName . '_' . $i;
             $i++;
         }
         // get unique folder name
         $i = 1;
         while (true) {
             $sql = "SELECT\tCOUNT(*) AS count\n\t\t\t\t\tFROM\twcf" . WCF_N . "_template_group\n\t\t\t\t\tWHERE\ttemplateGroupFolderName = ?";
             $statement = WCF::getDB()->prepareStatement($sql);
             $statement->execute(array(FileUtil::addTrailingSlash($templateGroupFolderName)));
             $row = $statement->fetchArray();
             if (!$row['count']) {
                 break;
             }
             $templateGroupFolderName = $originalTemplateGroupFolderName . '_' . $i;
             $i++;
         }
         $templateGroupAction = new TemplateGroupAction(array(), 'create', array('data' => array('templateGroupName' => $templateGroupName, 'templateGroupFolderName' => FileUtil::addTrailingSlash($templateGroupFolderName))));
         $returnValues = $templateGroupAction->executeAction();
         $styleData['templateGroupID'] = $returnValues['returnValues']->templateGroupID;
     }
     // import images
     if (!empty($data['images']) && $data['imagesPath'] != 'images/') {
         // create images folder if necessary
         $imagesLocation = self::getFileLocation($data['imagesPath']);
         $styleData['imagePath'] = FileUtil::getRelativePath(WCF_DIR, $imagesLocation);
         $index = $tar->getIndexByFilename($data['images']);
         if ($index !== false) {
             // extract images tar
             $destination = FileUtil::getTemporaryFilename('images_');
             $tar->extract($index, $destination);
             // open images tar
             $imagesTar = new Tar($destination);
             $contentList = $imagesTar->getContentList();
             foreach ($contentList as $key => $val) {
                 if ($val['type'] == 'file') {
                     $imagesTar->extract($key, $imagesLocation . basename($val['filename']));
                     FileUtil::makeWritable($imagesLocation . basename($val['filename']));
                 }
             }
             // delete tmp file
             $imagesTar->close();
             @unlink($destination);
         }
     }
     // import templates
     if (!empty($data['templates'])) {
         $index = $tar->getIndexByFilename($data['templates']);
         if ($index !== false) {
             // extract templates tar
             $destination = FileUtil::getTemporaryFilename('templates_');
             $tar->extract($index, $destination);
             // open templates tar and group templates by package
             $templatesTar = new Tar($destination);
             $contentList = $templatesTar->getContentList();
             $packageToTemplates = array();
             foreach ($contentList as $val) {
                 if ($val['type'] == 'file') {
                     $folders = explode('/', $val['filename']);
                     $packageName = array_shift($folders);
                     if (!isset($packageToTemplates[$packageName])) {
                         $packageToTemplates[$packageName] = array();
                     }
                     $packageToTemplates[$packageName][] = array('index' => $val['index'], 'filename' => implode('/', $folders));
                 }
             }
             // copy templates
             foreach ($packageToTemplates as $package => $templates) {
//.........这里部分代码省略.........
开发者ID:nick-strohm,项目名称:WCF,代码行数:101,代码来源:StyleEditor.class.php


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