本文整理汇总了PHP中js::close方法的典型用法代码示例。如果您正苦于以下问题:PHP js::close方法的具体用法?PHP js::close怎么用?PHP js::close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类js
的用法示例。
在下文中一共展示了js::close方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: download
/**
* Down a file.
*
* @param int $fileID
* @param string $mouse
* @access public
* @return void
*/
public function download($fileID, $mouse = '', $confirm = '')
{
if ($confirm == 'no') {
die(js::close());
}
$file = $this->file->getById($fileID);
/* Change savePath if objectType is source or slide. */
if (strpos(',slide,source,', ",{$file->objectType},") !== false) {
$this->file->setSavePath('source');
$file = $this->file->getById($fileID);
}
/* Judge the mode, down or open. */
$mode = 'down';
$fileTypes = 'txt|jpg|jpeg|gif|png|bmp|xml|html';
if (stripos($fileTypes, $file->extension) !== false and $mouse == 'left') {
$mode = 'open';
}
$account = $this->app->user->account;
if (!$file->public && $account == 'guest') {
$this->locate($this->createLink('user', 'login'));
}
/* If the mode is open, locate directly. */
if ($mode == 'open') {
if (file_exists($file->realPath)) {
$this->locate($file->webPath);
}
$this->app->triggerError("The file you visit {$fileID} not found.", __FILE__, __LINE__, true);
} else {
/* Down the file. */
if (file_exists($file->realPath)) {
$fileName = $file->title . '.' . $file->extension;
$fileData = file_get_contents($file->realPath);
if (commonModel::isAvailable('score')) {
/* Check for update extension.*/
if (!$this->loadModel('score')->hasFileDowned($account, $fileID) and $account != $file->addedBy) {
if (!empty($file->score) and $file->addedBy != $account and $confirm != 'yes') {
die(js::confirm(sprintf($this->lang->file->confirm, $file->score), inlink('download', "id={$fileID}&mouse=&confirm=yes"), inlink('download', "id={$fileID}&mouse=&confirm=no")));
}
if (!$this->score->cost('download', $file->score, 'file', $fileID)) {
$this->view->score = $file->score;
die($this->display());
}
}
}
/* Recording download times, downloads of this file plus one. */
$this->file->log($fileID);
$this->file->sendDownHeader($fileName, $file->extension, $fileData, filesize($file->realPath));
} else {
$this->app->triggerError("The file you visit {$fileID} not found.", __FILE__, __LINE__, true);
}
}
}