本文整理汇总了PHP中UTIL_String::getRandomStringWithPrefix方法的典型用法代码示例。如果您正苦于以下问题:PHP UTIL_String::getRandomStringWithPrefix方法的具体用法?PHP UTIL_String::getRandomStringWithPrefix怎么用?PHP UTIL_String::getRandomStringWithPrefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UTIL_String
的用法示例。
在下文中一共展示了UTIL_String::getRandomStringWithPrefix方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: chooseTheme
public function chooseTheme()
{
$language = OW::getLanguage();
$router = OW::getRouter();
$this->themeService->updateThemeList();
$this->themeService->updateThemesInfo();
$themes = $this->themeService->findAllThemes();
$themesInfo = array();
$activeTheme = OW::getThemeManager()->getSelectedTheme()->getDto()->getKey();
/* @var $theme BOL_Theme */
foreach ($themes as $theme) {
$themesInfo[$theme->getKey()] = array("key" => $theme->getKey(), "title" => $theme->getTitle(), "iconUrl" => $this->themeService->getStaticUrl($theme->getKey()) . BOL_ThemeService::ICON_FILE, "previewUrl" => $this->themeService->getStaticUrl($theme->getKey()) . BOL_ThemeService::PREVIEW_FILE, "active" => $theme->getKey() == $activeTheme, "changeUrl" => $router->urlFor(__CLASS__, "changeTheme", array(BOL_StorageService::URI_VAR_KEY => $theme->getKey())), "update_url" => (int) $theme->getUpdate() == 1 ? $router->urlFor("ADMIN_CTRL_Themes", "updateRequest", array(BOL_StorageService::URI_VAR_KEY => $theme->getKey())) : false);
if (!in_array($theme->getKey(), array(BOL_ThemeService::DEFAULT_THEME, $activeTheme))) {
$themesInfo[$theme->getKey()]["delete_url"] = $router->urlFor(__CLASS__, "deleteTheme", array("key" => $theme->getKey()));
}
if ($theme->getLicenseCheckTimestamp() > 0) {
$params = array(BOL_StorageService::URI_VAR_BACK_URI => urlencode($router->uriForRoute("admin_themes_choose")), BOL_StorageService::URI_VAR_KEY => $theme->getKey(), BOL_StorageService::URI_VAR_ITEM_TYPE => BOL_StorageService::URI_VAR_ITEM_TYPE_VAL_THEME, BOL_StorageService::URI_VAR_DEV_KEY => $theme->getDeveloperKey(), BOL_StorageService::URI_VAR_RETURN_RESULT => 0);
$themesInfo[$theme->getKey()]["license_url"] = OW::getRequest()->buildUrlQueryString($router->urlFor("ADMIN_CTRL_Storage", "checkItemLicense"), $params);
}
$xmlInfo = $this->themeService->getThemeXmlInfoForKey($theme->getKey());
$themesInfo[$theme->getKey()] = array_merge($themesInfo[$theme->getKey()], $xmlInfo);
}
OW::getDocument()->addScript(OW::getPluginManager()->getPlugin("admin")->getStaticJsUrl() . "theme_select.js");
OW::getDocument()->addScript(OW::getPluginManager()->getPlugin("base")->getStaticJsUrl() . "jquery.sticky.js");
$addData = array("deleteConfirmMsg" => $language->text("admin", "themes_choose_delete_confirm_msg"), "deleteActiveThemeMsg" => $language->text("admin", "themes_cant_delete_active_theme"));
OW::getDocument()->addOnloadScript("window.owThemes = new ThemesSelect(" . json_encode($themesInfo) . ", " . json_encode($addData) . ");\n \t\$('.selected_theme_info input.theme_select_submit').click(function(){\n \t\t\twindow.location.href = '{$themesInfo[$activeTheme]['changeUrl']}';\n \t\t});\n \$('.selected_theme_info_stick').sticky({topSpacing:60});\n \$('.admin_themes_select a.theme_icon').click( function(){ \$('.theme_info .theme_control_button').hide(); });");
$this->assign("adminThemes", array(BOL_ThemeService::DEFAULT_THEME => $themesInfo[BOL_ThemeService::DEFAULT_THEME]));
$this->assign("themeInfo", $themesInfo[$activeTheme]);
$event = new OW_Event("admin.filter_themes_to_choose", array(), $themesInfo);
OW::getEventManager()->trigger($event);
$this->assign("themes", $event->getData());
// add theme
$form = new Form("theme-add");
$form->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA);
$file = new FileField("file");
$form->addElement($file);
$submit = new Submit("submit");
$submit->setValue($language->text("admin", "plugins_manage_add_submit_label"));
$form->addElement($submit);
$this->addForm($form);
if (OW::getRequest()->isPost()) {
if ($form->isValid($_POST)) {
$data = $form->getValues();
$result = UTIL_File::checkUploadedFile($_FILES["file"]);
if (!$result["result"]) {
$this->feedback->error($result["message"]);
$this->redirect($router->urlForRoute("admin_themes_choose"));
}
$pluginfilesDir = OW::getPluginManager()->getPlugin("base")->getPluginFilesDir();
$tempFile = $this->getTemDirPath() . UTIL_String::getRandomStringWithPrefix("theme_add") . ".zip";
$tempDirName = UTIL_String::getRandomStringWithPrefix("theme_add");
if (!move_uploaded_file($_FILES["file"]["tmp_name"], $tempFile)) {
$this->feedback->error($language->text("admin", "manage_theme_add_move_file_error"));
$this->redirect($router->urlForRoute("admin_themes_choose"));
}
$zip = new ZipArchive();
if ($zip->open($tempFile) === true) {
$zip->extractTo($this->getTemDirPath() . $tempDirName);
$zip->close();
} else {
$this->feedback->error($language->text("admin", "manage_theme_add_extract_error"));
$this->redirect($router->urlForRoute("admin_themes_choose"));
}
unlink($tempFile);
$this->redirect(OW::getRequest()->buildUrlQueryString($router->urlFor(__CLASS__, "processAdd"), array("dir" => $tempDirName)));
}
}
}
示例2: downloadItem
/**
* Downloads item archive and returns it's local path.
*
* @param string $key
* @param string $devKey
* @param string $licenseKey
* @return string
* @throws LogicException
*/
public function downloadItem($key, $devKey, $licenseKey = null)
{
$params = array(self::URI_VAR_KEY => trim($key), self::URI_VAR_DEV_KEY => trim($devKey), self::URI_VAR_LICENSE_KEY => $licenseKey != null ? trim($licenseKey) : null);
$data = array_merge($params, $this->triggerEventBeforeRequest($params));
$paramsObj = new UTIL_HttpClientParams();
$paramsObj->addParams($data);
$response = UTIL_HttpClient::get($this->getStorageUrl(self::URI_DOWNLOAD_ITEM), $paramsObj);
if (!$response || $response->getStatusCode() != UTIL_HttpClient::HTTP_STATUS_OK || !$response->getBody()) {
throw new LogicException("Can't download file. Server returned empty file.");
}
$fileName = UTIL_String::getRandomStringWithPrefix("plugin_archive_", 8, UTIL_String::RND_STR_NUMERIC) . ".zip";
$archivePath = OW_DIR_PLUGINFILES . DS . $fileName;
file_put_contents($archivePath, $response->getBody());
return $archivePath;
}
示例3: add
/**
* Uploads new plugin and extracts archive contecnts.
*/
public function add()
{
OW::getNavigation()->activateMenuItem(OW_Navigation::ADMIN_PLUGINS, "admin", "sidebar_menu_plugins_add");
$language = OW::getLanguage();
$feedback = OW::getFeedback();
$form = new Form("plugin-add");
$form->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA);
$file = new FileField("file");
$form->addElement($file);
$submit = new Submit("submit");
$submit->setValue($language->text("admin", "plugins_manage_add_submit_label"));
$form->addElement($submit);
$this->addForm($form);
if (OW::getRequest()->isPost()) {
if ($form->isValid($_POST)) {
$data = $form->getValues();
$result = UTIL_File::checkUploadedFile($_FILES["file"]);
if (!$result["result"]) {
$feedback->error($result["message"]);
$this->redirect();
}
$pluginfilesDir = OW::getPluginManager()->getPlugin("base")->getPluginFilesDir();
$tempFile = $pluginfilesDir . UTIL_String::getRandomStringWithPrefix("plugin_add") . ".zip";
$tempDirName = UTIL_String::getRandomStringWithPrefix("plugin_add");
if (!move_uploaded_file($_FILES["file"]["tmp_name"], $tempFile)) {
$feedback->error($language->text("admin", "manage_plugin_add_move_file_error"));
$this->redirectToAction("index");
}
$zip = new ZipArchive();
if ($zip->open($tempFile) === true) {
$zip->extractTo($this->getTemDirPath() . $tempDirName);
$zip->close();
} else {
$feedback->error($language->text("admin", "manage_plugin_add_extract_error"));
$this->redirectToAction("index");
}
unlink($tempFile);
$this->redirect(OW::getRequest()->buildUrlQueryString(OW::getRouter()->urlFor(__CLASS__, "processAdd"), array("dir" => $tempDirName)));
}
}
}