本文整理汇总了PHP中Pimcore\File::mkdir方法的典型用法代码示例。如果您正苦于以下问题:PHP File::mkdir方法的具体用法?PHP File::mkdir怎么用?PHP File::mkdir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore\File
的用法示例。
在下文中一共展示了File::mkdir方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* @param null $options
* @return bool|void
* @throws \Exception
* @throws \Zend_Http_Client_Exception
*/
public function send($options = null)
{
$sourceFile = $this->getSourceFile();
$destinationFile = $this->getDestinationFile();
if (!$sourceFile) {
throw new \Exception("No sourceFile provided.");
}
if (!$destinationFile) {
throw new \Exception("No destinationFile provided.");
}
if (is_array($options)) {
if ($options['overwrite'] == false && file_exists($destinationFile)) {
throw new \Exception("Destination file : '" . $destinationFile . "' already exists.");
}
}
if (!$this->getHttpClient()) {
$httpClient = \Pimcore\Tool::getHttpClient(null, ['timeout' => 3600 * 60]);
} else {
$httpClient = $this->getHttpClient();
}
$httpClient->setUri($this->getSourceFile());
$response = $httpClient->request();
if ($response->isSuccessful()) {
$data = $response->getBody();
File::mkdir(dirname($destinationFile));
$result = File::put($destinationFile, $data);
if ($result === false) {
throw new \Exception("Couldn't write destination file:" . $destinationFile);
}
} else {
throw new \Exception("Couldn't download file:" . $sourceFile);
}
return true;
}
示例2: config
/**
* @param array $config
*/
public function config($config = [])
{
$settings = null;
// check for an initial configuration template
// used eg. by the demo installer
$configTemplatePath = PIMCORE_CONFIGURATION_DIRECTORY . "/system.template.php";
if (file_exists($configTemplatePath)) {
try {
$configTemplate = new \Zend_Config(include $configTemplatePath);
if ($configTemplate->general) {
// check if the template contains a valid configuration
$settings = $configTemplate->toArray();
// unset database configuration
unset($settings["database"]["params"]["host"]);
unset($settings["database"]["params"]["port"]);
}
} catch (\Exception $e) {
}
}
// set default configuration if no template is present
if (!$settings) {
// write configuration file
$settings = ["general" => ["timezone" => "Europe/Berlin", "language" => "en", "validLanguages" => "en", "debug" => "1", "debugloglevel" => "debug", "custom_php_logfile" => "1", "extjs6" => "1"], "database" => ["adapter" => "Mysqli", "params" => ["username" => "root", "password" => "", "dbname" => ""]], "documents" => ["versions" => ["steps" => "10"], "default_controller" => "default", "default_action" => "default", "error_pages" => ["default" => "/"], "createredirectwhenmoved" => "", "allowtrailingslash" => "no", "generatepreview" => "1"], "objects" => ["versions" => ["steps" => "10"]], "assets" => ["versions" => ["steps" => "10"]], "services" => [], "cache" => ["excludeCookie" => ""], "httpclient" => ["adapter" => "Zend_Http_Client_Adapter_Socket"]];
}
$settings = array_replace_recursive($settings, $config);
// create initial /website/var folder structure
// @TODO: should use values out of startup.php (Constants)
$varFolders = ["areas", "assets", "backup", "cache", "classes", "config", "email", "log", "plugins", "recyclebin", "search", "system", "tmp", "versions", "webdav"];
foreach ($varFolders as $folder) {
\Pimcore\File::mkdir(PIMCORE_WEBSITE_VAR . "/" . $folder);
}
$configFile = \Pimcore\Config::locateConfigFile("system.php");
File::putPhpFile($configFile, to_php_data_file_format($settings));
}
示例3: getWorkingDir
/**
* @static
* @return string
*/
public static function getWorkingDir()
{
$dir = PIMCORE_CONFIGURATION_DIRECTORY . "/videopipelines";
if (!is_dir($dir)) {
\Pimcore\File::mkdir($dir);
}
return $dir;
}
示例4: __construct
/**
* @param string $data
* @param string $filename
*/
public function __construct($data, $filename = null)
{
if (!is_dir(PIMCORE_LOG_FILEOBJECT_DIRECTORY)) {
File::mkdir(PIMCORE_LOG_FILEOBJECT_DIRECTORY);
}
$this->data = $data;
$this->filename = $filename;
if (empty($this->filename)) {
$folderpath = PIMCORE_LOG_FILEOBJECT_DIRECTORY . strftime('/%Y/%m/%d');
if (!is_dir($folderpath)) {
mkdir($folderpath, 0775, true);
}
$this->filename = $folderpath . "/" . uniqid("fileobject_", true);
}
File::put($this->filename, $this->data);
}
示例5: loadFile
/**
* @return array|mixed
*/
protected function loadFile()
{
if (!is_dir($this->getConfigDir())) {
File::mkdir($this->getConfigDir());
}
if (empty($this->dashboards)) {
if (is_file($this->getConfigFile())) {
$dashboards = Serialize::unserialize(file_get_contents($this->getConfigFile()));
if (!empty($dashboards)) {
$this->dashboards = $dashboards;
}
}
if (empty($this->dashboards)) {
// if no configuration exists, return the base config
$this->dashboards = array("welcome" => array("positions" => array(array(array("id" => 1, "type" => "pimcore.layout.portlets.modificationStatistic", "config" => null), array("id" => 2, "type" => "pimcore.layout.portlets.modifiedAssets", "config" => null)), array(array("id" => 3, "type" => "pimcore.layout.portlets.modifiedObjects", "config" => null), array("id" => 4, "type" => "pimcore.layout.portlets.modifiedDocuments", "config" => null)))));
}
}
return $this->dashboards;
}
示例6: loadFile
/**
* @return array|mixed
*/
protected function loadFile()
{
if (!is_dir($this->getConfigDir())) {
File::mkdir($this->getConfigDir());
}
if (empty($this->dashboards)) {
if (is_file($this->getConfigFile())) {
$dashboards = Serialize::unserialize(file_get_contents($this->getConfigFile()));
if (!empty($dashboards)) {
$this->dashboards = $dashboards;
}
}
if (empty($this->dashboards)) {
$perspectiveCfg = Config::getRuntimePerspective();
$dasboardCfg = $perspectiveCfg["dashboards"] ? $perspectiveCfg["dashboards"] : [];
$this->dashboards = $dasboardCfg["predefined"] ? $dasboardCfg["predefined"] : [];
}
}
return $this->dashboards;
}
示例7: config
/**
* @param array $config
*/
public function config($config = array())
{
$settings = null;
// check for an initial configuration template
// used eg. by the demo installer
$configTemplatePath = PIMCORE_CONFIGURATION_DIRECTORY . "/system.xml.template";
if (file_exists($configTemplatePath)) {
try {
$configTemplate = new \Zend_Config_Xml($configTemplatePath);
if ($configTemplate->general) {
// check if the template contains a valid configuration
$settings = $configTemplate->toArray();
// unset database configuration
unset($settings["database"]["params"]["host"]);
unset($settings["database"]["params"]["port"]);
}
} catch (\Exception $e) {
}
}
// set default configuration if no template is present
if (!$settings) {
// write configuration file
$settings = array("general" => array("timezone" => "Europe/Berlin", "language" => "en", "validLanguages" => "en", "debug" => "1", "debugloglevel" => "debug", "custom_php_logfile" => "1", "extjs6" => "1"), "database" => array("adapter" => "Mysqli", "params" => array("username" => "root", "password" => "", "dbname" => "")), "documents" => array("versions" => array("steps" => "10"), "default_controller" => "default", "default_action" => "default", "error_pages" => array("default" => "/"), "createredirectwhenmoved" => "", "allowtrailingslash" => "no", "allowcapitals" => "no", "generatepreview" => "1"), "objects" => array("versions" => array("steps" => "10")), "assets" => array("versions" => array("steps" => "10")), "services" => array(), "cache" => array("excludeCookie" => ""), "httpclient" => array("adapter" => "Zend_Http_Client_Adapter_Socket"));
}
$settings = array_replace_recursive($settings, $config);
// convert all special characters to their entities so the xml writer can put it into the file
$settings = array_htmlspecialchars($settings);
// create initial /website/var folder structure
// @TODO: should use values out of startup.php (Constants)
$varFolders = array("areas", "assets", "backup", "cache", "classes", "config", "email", "log", "plugins", "recyclebin", "search", "system", "tmp", "versions", "webdav");
foreach ($varFolders as $folder) {
\Pimcore\File::mkdir(PIMCORE_WEBSITE_VAR . "/" . $folder);
}
$config = new \Zend_Config($settings, true);
$writer = new \Zend_Config_Writer_Xml(array("config" => $config, "filename" => PIMCORE_CONFIGURATION_SYSTEM));
$writer->write();
}
示例8: getTemporaryFile
/**
* returns the path to a temp file
*
* @return string
*/
public function getTemporaryFile($fullPath = false)
{
$destinationPath = PIMCORE_TEMPORARY_DIRECTORY . "/asset-temporary/asset_" . $this->getId() . "_" . md5(microtime()) . "__" . $this->getFilename();
if (!is_dir(dirname($destinationPath))) {
File::mkdir(dirname($destinationPath));
}
$src = $this->getStream();
$dest = fopen($destinationPath, "w+");
stream_copy_to_stream($src, $dest);
fclose($dest);
@chmod($destinationPath, File::getDefaultMode());
if ($fullPath) {
return $destinationPath;
}
return str_replace(PIMCORE_DOCUMENT_ROOT, "", $destinationPath);
}
示例9: save
/**
* @param User $user
* @return void
*/
public function save($user = null)
{
if ($this->getElement() instanceof Element\ElementInterface) {
$this->setType(Element\Service::getElementType($this->getElement()));
}
$this->setSubtype($this->getElement()->getType());
$this->setPath($this->getElement()->getFullPath());
$this->setDate(time());
$this->loadChilds($this->getElement());
if ($user instanceof Model\User) {
$this->setDeletedby($user->getName());
}
// serialize data
Element\Service::loadAllFields($this->element);
$this->element->_fulldump = true;
$data = Serialize::serialize($this->getElement());
$this->getResource()->save();
if (!is_dir(PIMCORE_RECYCLEBIN_DIRECTORY)) {
File::mkdir(PIMCORE_RECYCLEBIN_DIRECTORY);
}
File::put($this->getStoreageFile(), $data);
$saveBinaryData = function ($element, $rec, $scope) {
// assets are kina special because they can contain massive amount of binary data which isn't serialized, we create separate files for them
if ($element instanceof Asset) {
if ($element->getType() != "folder") {
$handle = fopen($scope->getStorageFileBinary($element), "w+");
$src = $element->getStream();
stream_copy_to_stream($src, $handle);
fclose($handle);
}
$children = $element->getChilds();
foreach ($children as $child) {
$rec($child, $rec, $scope);
}
}
};
$saveBinaryData($this->getElement(), $saveBinaryData, $this);
@chmod($this->getStoreageFile(), File::getDefaultMode());
}
示例10: getImageThumbnail
/**
* @param $thumbnailName
* @param int $page
* @param bool $deferred $deferred deferred means that the image will be generated on-the-fly (details see below)
* @return mixed|string
*/
public function getImageThumbnail($thumbnailName, $page = 1, $deferred = false)
{
// just 4 testing
//$this->clearThumbnails(true);
if (!\Pimcore\Document::isAvailable()) {
\Logger::error("Couldn't create image-thumbnail of document " . $this->getFullPath() . " no document adapter is available");
return "/pimcore/static/img/filetype-not-supported.png";
}
$thumbnail = Image\Thumbnail\Config::getByAutoDetect($thumbnailName);
$thumbnail->setName("document_" . $thumbnail->getName() . "-" . $page);
try {
if (!$deferred) {
$converter = \Pimcore\Document::getInstance();
$converter->load($this->getFileSystemPath());
$path = PIMCORE_TEMPORARY_DIRECTORY . "/document-image-cache/document_" . $this->getId() . "__thumbnail_" . $page . ".png";
if (!is_dir(dirname($path))) {
\Pimcore\File::mkdir(dirname($path));
}
$lockKey = "document-thumbnail-" . $this->getId() . "-" . $page;
if (!is_file($path) && !Model\Tool\Lock::isLocked($lockKey)) {
Model\Tool\Lock::lock($lockKey);
$converter->saveImage($path, $page);
Model\Tool\Lock::release($lockKey);
} else {
if (Model\Tool\Lock::isLocked($lockKey)) {
return "/pimcore/static/img/please-wait.png";
}
}
}
if ($thumbnail) {
$path = Image\Thumbnail\Processor::process($this, $thumbnail, $path, $deferred);
}
return preg_replace("@^" . preg_quote(PIMCORE_DOCUMENT_ROOT) . "@", "", $path);
} catch (\Exception $e) {
\Logger::error("Couldn't create image-thumbnail of document " . $this->getFullPath());
\Logger::error($e);
}
return "/pimcore/static/img/filetype-not-supported.png";
}
示例11: saveFolderAction
public function saveFolderAction()
{
$object = Object::getById($this->getParam("id"));
$classId = $this->getParam("class_id");
// general settings
$general = \Zend_Json::decode($this->getParam("general"));
$object->setValues($general);
$object->setUserModification($this->getUser()->getId());
$object = $this->assignPropertiesFromEditmode($object);
if ($object->isAllowed("publish")) {
try {
// grid config
$gridConfig = \Zend_Json::decode($this->getParam("gridconfig"));
if ($classId) {
$configFile = PIMCORE_CONFIGURATION_DIRECTORY . "/object/grid/" . $object->getId() . "_" . $classId . "-user_" . $this->getUser()->getId() . ".psf";
} else {
$configFile = PIMCORE_CONFIGURATION_DIRECTORY . "/object/grid/" . $object->getId() . "-user_" . $this->getUser()->getId() . ".psf";
}
$configDir = dirname($configFile);
if (!is_dir($configDir)) {
File::mkdir($configDir);
}
File::put($configFile, Tool\Serialize::serialize($gridConfig));
$object->save();
$this->_helper->json(array("success" => true));
} catch (\Exception $e) {
$this->_helper->json(array("success" => false, "message" => $e->getMessage()));
}
}
$this->_helper->json(array("success" => false, "message" => "missing_permission"));
}
示例12: generate
/**
*
*/
public function generate()
{
$errorImage = PIMCORE_PATH . '/static6/img/filetype-not-supported.png';
$deferred = false;
$generated = false;
if (!$this->asset) {
$this->filesystemPath = $errorImage;
} elseif (!$this->filesystemPath) {
$cs = $this->asset->getCustomSetting("image_thumbnail_time");
$im = $this->asset->getCustomSetting("image_thumbnail_asset");
if ($im || $this->imageAsset) {
if ($this->imageAsset) {
$im = $this->imageAsset;
} else {
$im = Model\Asset::getById($im);
}
if ($im instanceof Image) {
$imageThumbnail = $im->getThumbnail($this->getConfig());
$this->filesystemPath = $imageThumbnail->getFileSystemPath();
}
}
if (!$this->filesystemPath) {
$timeOffset = $this->timeOffset;
if (!$this->timeOffset && $cs) {
$timeOffset = $cs;
}
// fallback
if (!$timeOffset) {
$timeOffset = ceil($this->asset->getDuration() / 3);
}
$converter = \Pimcore\Video::getInstance();
$converter->load($this->asset->getFileSystemPath());
$path = PIMCORE_TEMPORARY_DIRECTORY . "/video-image-cache/video_" . $this->asset->getId() . "__thumbnail_" . $timeOffset . ".png";
if (!is_dir(dirname($path))) {
File::mkdir(dirname($path));
}
if (!is_file($path)) {
$lockKey = "video_image_thumbnail_" . $this->asset->getId() . "_" . $timeOffset;
Model\Tool\Lock::acquire($lockKey);
// after we got the lock, check again if the image exists in the meantime - if not - generate it
if (!is_file($path)) {
$converter->saveImage($path, $timeOffset);
$generated = true;
}
Model\Tool\Lock::release($lockKey);
}
if ($this->getConfig()) {
$this->getConfig()->setFilenameSuffix("time-" . $timeOffset);
try {
$path = Image\Thumbnail\Processor::process($this->asset, $this->getConfig(), $path, $deferred, true, $generated);
} catch (\Exception $e) {
Logger::error("Couldn't create image-thumbnail of video " . $this->asset->getRealFullPath());
Logger::error($e);
$path = $errorImage;
}
}
$this->filesystemPath = $path;
}
\Pimcore::getEventManager()->trigger("asset.video.image-thumbnail", $this, ["deferred" => $deferred, "generated" => $generated]);
}
}
示例13: update
/**
* Updates and save the email log entry to the db and the file-system
*/
protected function update()
{
$this->getDao()->update();
if (!is_dir(PIMCORE_LOG_MAIL_PERMANENT)) {
File::mkdir(PIMCORE_LOG_MAIL_PERMANENT);
}
if ($html = $this->getBodyHtml()) {
if (File::put(PIMCORE_LOG_MAIL_PERMANENT . '/email-' . $this->getId() . '-html.log', $html) === false) {
Logger::warn('Could not write html email log file. LogId: ' . $this->getId());
}
}
if ($text = $this->getBodyText()) {
if (File::put(PIMCORE_LOG_MAIL_PERMANENT . '/email-' . $this->getId() . '-text.log', $text) === false) {
Logger::warn('Could not write text email log file. LogId: ' . $this->getId());
}
}
}
示例14: fileexplorerAddFolderAction
public function fileexplorerAddFolderAction()
{
$this->checkPermission("fileexplorer");
$success = false;
if ($this->getParam("filename") && $this->getParam("path")) {
$path = $this->getFileexplorerPath("path");
$file = $path . "/" . $this->getParam("filename");
if (is_writeable(dirname($file))) {
File::mkdir($file);
$success = true;
}
}
$this->_helper->json(array("success" => $success));
}
示例15: generateScreenshotAction
public function generateScreenshotAction()
{
$success = false;
if ($this->getParam("id")) {
$doc = Document::getById($this->getParam("id"));
$url = Tool::getHostUrl() . $doc->getRealFullPath() . "?pimcore_preview=true";
$config = \Pimcore\Config::getSystemConfig();
if ($config->general->http_auth) {
$username = $config->general->http_auth->username;
$password = $config->general->http_auth->password;
if ($username && $password) {
$url = str_replace("://", "://" . $username . ":" . $password . "@", $url);
}
}
$tmpFile = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/screenshot_tmp_" . $doc->getId() . ".png";
$file = PIMCORE_TEMPORARY_DIRECTORY . "/document-page-previews/document-page-screenshot-" . $doc->getId() . ".jpg";
$dir = dirname($file);
if (!is_dir($dir)) {
File::mkdir($dir);
}
try {
if (\Pimcore\Image\HtmlToImage::convert($url, $tmpFile)) {
$im = \Pimcore\Image::getInstance();
$im->load($tmpFile);
$im->scaleByWidth(400);
$im->save($file, "jpeg", 85);
unlink($tmpFile);
$success = true;
}
} catch (\Exception $e) {
\Logger::error($e);
}
}
$this->_helper->json(array("success" => $success));
}