本文整理汇总了PHP中Floxim\Floxim\System\Fx::files方法的典型用法代码示例。如果您正苦于以下问题:PHP Fx::files方法的具体用法?PHP Fx::files怎么用?PHP Fx::files使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Floxim\Floxim\System\Fx
的用法示例。
在下文中一共展示了Fx::files方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSavestring
public function getSavestring(System\Entity $content = null)
{
$old_value = $content[$this['keyword']];
if ($old_value != $this->value) {
if (!empty($old_value)) {
$old_value = fx::path()->abs($old_value);
if (file_exists($old_value) && is_file($old_value)) {
fx::files()->rm($old_value);
}
}
if (!empty($this->value)) {
$c_val = fx::path()->abs($this->value);
if (file_exists($c_val) && is_file($c_val)) {
preg_match("~[^" . preg_quote(DIRECTORY_SEPARATOR) . ']+$~', $c_val, $fn);
$path = fx::path()->http('@content_files/' . $content['site_id'] . '/' . $content['type'] . '/' . $this['keyword'] . '/' . $fn[0]);
$try = 0;
while (fx::path()->exists($path)) {
$file_name = preg_replace("~(\\.[^\\.]+)\$~", "_" . $try . "\$1", $fn[0]);
$try++;
$path = fx::path()->http('@content_files/' . $content['type'] . '/' . $this['keyword'] . '/' . $file_name);
}
fx::files()->move($c_val, $path);
}
}
}
$res = isset($path) ? $path : $this->value;
return $res;
}
示例2: getSavestring
public function getSavestring(System\Entity $content = null)
{
$old_value = $content[$this['keyword']];
$old_path = FX_BASE_URL . $old_value;
if ($old_path === $this->value) {
return $this->value;
}
$res = '';
if (!empty($this->value)) {
$c_val = fx::path()->abs($this->value);
if (file_exists($c_val) && is_file($c_val)) {
$file_name = fx::path()->fileName($c_val);
$path = fx::path('@content_files/' . $content['site_id'] . '/' . $content['type'] . '/' . $this['keyword'] . '/' . $file_name);
$path = fx::files()->getPutFilePath($path);
fx::files()->move($c_val, $path);
$res = fx::path()->removeBase(fx::path()->http($path));
}
}
if (!empty($old_value)) {
$old_value = fx::path()->abs($old_value);
if (file_exists($old_value) && is_file($old_value)) {
fx::files()->rm($old_value);
}
}
return $res;
}
示例3: beforeDelete
protected function beforeDelete()
{
parent::beforeDelete();
$files = $this->getFileParams();
foreach ($files as $f) {
fx::files()->rm($f);
}
}
示例4: uploadSave
public function uploadSave($input)
{
$path = 'upload';
$result = fx::files()->saveFile($input['file'], $path);
if (!$result) {
$result = array('error_message' => 'Can not load this file');
fx::http()->status(500);
}
if (isset($input['format']) && !empty($input['format']) && isset($result['path'])) {
$result['formatted_value'] = fx::image($result['path'], $input['format']);
}
return $result;
}
示例5: handleThumbs
protected function handleThumbs()
{
fx::listen('unlink', function ($e) {
$f = $e['file'];
if (fx::files()->isMetaFile($f)) {
return;
}
if (fx::path()->isInside($f, fx::path('@thumbs'))) {
return;
}
if (!fx::path()->isInside($f, fx::path('@content_files'))) {
return;
}
$thumbs = \Floxim\Floxim\System\Thumb::findThumbs($f);
foreach ($thumbs as $thumb) {
fx::files()->rm($thumb);
}
});
}
示例6: dumpDictionary
protected function dumpDictionary($dict, $file)
{
if (!isset($this->lang)) {
$this->setLang();
}
$data = fx::data('lang_string')->where('dict', $dict)->all();
$res = array();
foreach ($data as $s) {
$res[$s['string']] = $s['lang_' . $this->lang];
}
fx::files()->writefile($file, "<?php\nreturn " . var_export($res, 1) . ";");
}
示例7: templateSave
public function templateSave($input)
{
$info = $this->getTemplateInfo($input['template_full_id']);
if (!$info) {
return;
}
if ($info['hash'] !== $input['hash']) {
die("Hash error");
}
$res = mb_substr($info['full'], 0, $info['start']);
$input_source = $input['source'];
$spaces = $input['common_spaces'];
if (!empty($spaces)) {
$lines = explode("\n", $input_source);
foreach ($lines as $num => &$line) {
if ($num === 0) {
continue;
}
$line = $spaces . $line;
}
$input_source = join("\n", $lines);
}
$res .= $input_source;
$res .= mb_substr($info['full'], $info['start'] + $info['length']);
fx::files()->writefile($info['file'], $res);
return array('status' => 'ok');
}
示例8: afterUpdate
protected function afterUpdate()
{
parent::afterUpdate();
// modified image fields
$image_fields = $this->getFields()->find('keyword', $this->modified)->find('type', array(Field\Entity::FIELD_IMAGE, Field\Entity::FIELD_FILE));
foreach ($image_fields as $img_field) {
$old_value = $this->modified_data[$img_field['keyword']];
if (fx::path()->isFile($old_value)) {
fx::files()->rm($old_value);
}
}
}
示例9: removeOldFiles
protected function removeOldFiles()
{
$mask = $this->getTargetMask();
$files = glob($mask);
if (is_array($files)) {
foreach ($files as $file) {
fx::files()->rm($file);
}
}
}
示例10: deleteFiles
protected function deleteFiles()
{
$path = $this->getPath();
fx::files()->rm($path);
}
示例11: afterDelete
protected function afterDelete()
{
parent::afterDelete();
$path = fx::path()->abs($this->getPath());
fx::files()->rm($path);
}
示例12: updateFiles
protected function updateFiles($dir, $base)
{
$items = glob($dir . "/*");
if (!$items) {
return;
}
foreach ($items as $item) {
$item_target = fx::config('ROOT_FOLDER') . str_replace($base, '', $item);
if (is_dir($item)) {
$item_info = pathinfo($item);
// skip specific dirs
if (in_array($item_info['basename'], array('_patch_generator'))) {
continue;
}
fx::files()->mkdir($item_target);
$this->updateFiles($item, $base);
} else {
fx::files()->writefile($item_target, file_get_contents($item));
}
}
}