/** * Gets called when custom data is to be added for a file custom data can for example be * plugin specific name value items that should get added into a file listning. * * @param MCManager $man MCManager reference that the plugin is assigned to. * @param BaseFile $file File reference to add custom info/data to. * @param string $type Where is the info needed for example list or info. * @param Array $custom Name/Value array to add custom items to. * @return bool true/false if the execution of the event chain should continue. */ function onCustomInfo(&$man, &$file, $type, &$input) { switch ($type) { case "list": $input['previewable'] = $file->isFile() && $man->verifyFile($file, "preview") >= 0; break; } return true; // Pass to next }
public static function show() { parent::show(); $taskP = TASK_PATH . $_GET['task'] . '/data/'; $tableF = $taskP . $_GET['table']; $infoF = $taskP . $_GET['info']; $detail = array(ucfirst($_GET['task']), ucfirst($_GET['table'])); //echo $tableF; $table = Task::ReadTable($tableF); //var_dump($table); $header = array(); $footer = array(); $i = 0; foreach ($table[0] as $k => $v) { $header[] = $k; $footer[] = '$' . chr(65 + $i++); } //echo $infoF; $info = BaseFile::getFileContent($infoF); $info = $info ? explode("\r\n", $info) : array(); self::setTitle($detail[1] . ' - ' . $detail[0]); self::$smarty->assign('historyUrl', Url::getBasePhp('History')); self::$smarty->assign('favoriteUrl', Url::getBasePhp('Favorite')); self::$smarty->assign('detail', $detail); self::$smarty->assign('info', $info); self::$smarty->assign('header', $header); self::$smarty->assign('footer', $footer); self::$smarty->assign('table', $table); self::$smarty->display('Sheet.tpl'); }
public static function testRGB() { $contents = BaseFile::getFileContent(TMP_PATH . 'datatables.txt.css'); $pattern = "/#[0-9a-fA-F]{3,}/"; preg_match_all($pattern, $contents, $k); $tongji = array_count_values($k[0]); ksort($tongji); $pa = array(); $re = array(); echo '<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title></title></head><body>'; foreach ($tongji as $k => $v) { $s = '0123456789abcdef'; $t = array(); for ($i = 0; $i < strlen($s); $i++) { $t[$s[$i]] = $s[strlen($s) - $i - 1]; } $s = strtolower($k); $n = '#'; for ($i = 1; $i < strlen($s); $i++) { $n .= $t[$s[$i]]; } echo '<p><div style="background-color: ' . $k . '; width: 500px; float:left;">' . $k . '</div>' . $v; echo '<div style="background-color: ' . $n . '; width: 500px; float:left;">' . $n . '</div></p>'; //$pa[] = '/'.$k.'/'; //$re[] = $n; } //echo preg_replace($pa, $re, $contents); }
public function getTmpContent($label) { $file = $this->getTmpFile($label); if ($file) { return parent::getFileContent($file); } else { return false; } }
public function delete(Doctrine_Connection $conn = null) { if ($this->isImage()) { $class = sfImageHandler::getStorageClassName(); $storage = call_user_func(array($class, 'create'), $this, $class); $storage->deleteBinary(); } return parent::delete($conn); }
/** * Gets called when custom data is to be added for a file custom data can for example be * plugin specific name value items that should get added into a file listning. * * @param MCManager $man MCManager reference that the plugin is assigned to. * @param BaseFile $file File reference to add custom info/data to. * @param string $type Where is the info needed for example list or info. * @param Array $custom Name/Value array to add custom items to. * @return bool true/false if the execution of the event chain should continue. */ function onCustomInfo(&$man, &$file, $type, &$input) { switch ($type) { // When the file is selected/inserted case "insert": // Can be used by the insert_templates like this {$custom.mycustomfield} $input['mycustomfield'] = strtoupper($file->getName()); // Will be used as title/alt in TinyMCE link/image dialogs $input['description'] = $file->getName() . " (" . $this->_getSizeStr($file->getLength()) . ")"; break; // When the file is displayed in a more info dialog // When the file is displayed in a more info dialog case "info": //$input['mycustomfield'] = strtoupper($file->getName()); break; // When the file is listed // When the file is listed case "list": //$input['mycustomfield'] = strtoupper($file->getName()); break; } // Chain to next return true; }
public static function Vague2List($importFile, $exportFile) { if ($content = BaseFile::getFileContent($importFile)) { $codeArr = array(); $r = "/[0-9.]{6}/"; preg_match_all($r, $content, $k); foreach ($k[0] as $t) { $tt = CommonInfo::Num2Code($t); if ($tt) { $codeArr[] = array('code' => $tt); } } } else { return false; } $codeNameArray = CommonInfo::CodeArray2CodeNameArray($codeArr); self::putList($exportFile, $codeNameArray); }
public static function getPurposeList() { $purpose = array(); if (($d1 = opendir(TASK_PATH)) == false) { return $purpose; } while (($d2 = readdir($d1)) !== false) { if (!is_dir(TASK_PATH . $d2) || $d2 == "." || $d2 == "..") { continue; } $p = TASK_PATH . $d2 . "/"; $f = $p . "SUMMARY.txt"; if (!file_exists($f)) { continue; } $sd = TableFile::getAllData($f); if (!$sd) { continue; } $l = array(); foreach ($sd as $d) { if ($d['aim'] != self::$aim) { continue; } $f = $p . 'data/' . $d['table']; if (file_exists($f)) { $l[] = array('table' => $d['table'], 'info' => $d['info'], 'url' => Url::getBasePhp('Sheet') . '?task=' . $d2 . '&table=' . $d['table'] . '&info=' . $d['info']); } } if ($l) { $f = $p . "README.txt"; $re = array(); if (file_exists($f)) { $re = BaseFile::getFileContent($f); $re = explode("\r\n", $re); } $purpose[ucfirst($d2)] = array('readme' => $re, 'list' => $l); } } return $purpose; }
/** * Gets called when custom data is to be added for a file custom data can for example be * plugin specific name value items that should get added into a file listning. * * @param MCManager $man MCManager reference that the plugin is assigned to. * @param BaseFile $file File reference to add custom info/data to. * @param string $type Where is the info needed for example list or info. * @param Array $custom Name/Value array to add custom items to. * @return bool true/false if the execution of the event chain should continue. */ function onCustomInfo(&$man, &$file, $type, &$input) { // Is file and image $config = $file->getConfig(); $input["editable"] = false; if ($file->isFile() && ($type == "list" || $type == "insert" || $type == "info")) { // Should we get config on each file here? //$config = $file->getConfig(); $ext = getFileExt($file->getName()); if (!in_array($ext, array('gif', 'jpeg', 'jpg', 'png', 'bmp'))) { return true; } $imageutils = new $config['thumbnail'](); $canEdit = $imageutils->canEdit($ext); $imageInfo = @getimagesize($file->getAbsolutePath()); $fileWidth = $imageInfo[0]; $fileHeight = $imageInfo[1]; $targetWidth = $config['thumbnail.width']; $targetHeight = $config['thumbnail.height']; // Check thumnail size if ($config['thumbnail.scale_mode'] == "percentage") { if ($config['thumbnail.height'] > $config['thumbnail.width']) { $target = $config['thumbnail.width']; } else { $target = $config['thumbnail.height']; } $percentage = 0; if ($fileWidth > $fileHeight) { $percentage = $target / $fileWidth; } else { $percentage = $target / $fileHeight; } if ($percentage <= 1) { $targetWidth = round($fileWidth * $percentage); $targetHeight = round($fileHeight * $percentage); } else { $targetWidth = $fileWidth; $targetHeight = $fileHeight; } } $input["thumbnail"] = true; // Check against config. if ($config["thumbnail.max_width"] != "" && $fileWidth > $config["thumbnail.max_width"] || $config["thumbnail.max_height"] != "" && $fileHeight > $config["thumbnail.max_height"]) { $input["thumbnail"] = false; } else { $input["twidth"] = $targetWidth; $input["theight"] = $targetHeight; } // Get thumbnail URL if ($type == "insert") { $thumbFile = $man->getFile($file->getParent() . "/" . $config['thumbnail.folder'] . "/" . $config['thumbnail.prefix'] . $file->getName()); if ($thumbFile->exists()) { $input["thumbnail_url"] = $man->convertPathToURI($thumbFile->getAbsolutePath()); } } $input["width"] = $fileWidth; $input["height"] = $fileHeight; $input["editable"] = $canEdit; } return true; }
public function save(Doctrine_Connection $conn = null) { $this->setFilesize(strlen($this->FileBin->bin)); return parent::save($conn); }
/** * Returns a peer instance associated with this om. * * Since Peer classes are not to have any instance attributes, this method returns the * same instance for all member of this class. The method could therefore * be static, but this would prevent one from overriding the behavior. * * @return FilePeer */ public function getPeer() { if (self::$peer === null) { self::$peer = new FilePeer(); } return self::$peer; }
/** * Initializes internal state of File object. * @see parent::__construct() */ public function __construct() { // Make sure that parent constructor is always invoked, since that // is where any default values for this object are set. parent::__construct(); }
public static function putSomeData($file, $data) { if (empty($data)) { return true; } if (!file_exists($file)) { return self::putAllData($file, $data); } if ($content = parent::getFileContent($file)) { //得到表头数据 $rows = explode("\r\n", $content); $title = explode("|", $rows[0]); $rows = array(); $special = array("|", "\r\n"); //按照表头数据 来整合新数据 foreach ($data as $adata) { if (!$adata) { continue; } $row = array(); foreach ($title as $item) { $row[] = str_replace($special, " ", $adata[$item]); } $rows[] = join("|", $row); } $content = "\r\n" . join("\r\n", $rows); return parent::putFileContent($file, $content, FILE_APPEND); } else { return false; } }