本文整理汇总了PHP中file::getFilename方法的典型用法代码示例。如果您正苦于以下问题:PHP file::getFilename方法的具体用法?PHP file::getFilename怎么用?PHP file::getFilename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类file
的用法示例。
在下文中一共展示了file::getFilename方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: info
public function info($assignment_id = null)
{
global $db;
if (is_null($assignment_id)) {
$assignment_id = $this->assignment_id;
}
$user_id = user::authService()['user_id'];
if (!isset($assignment_id) && !isset($user_id)) {
return -1;
}
$db->where("assignment_id", $assignment_id);
$result = $db->get("assignment")[0];
$db->where("type_id", $assignment_id);
$db->where("type", "question");
$resultFile = $db->get("file");
$files = array();
foreach ($resultFile as $rowFile) {
$filepath = file::getFilename($rowFile['file_id'], $rowFile['extension']);
$rowFile['filepath'] = $filepath;
$files[] = $rowFile;
}
$result['files'] = $files;
if (user::isStudent()) {
$result['group_id'] = Assignment::groupID($assignment_id);
$result['editor'] = Assignment::getEditor($result['group_id']);
} elseif (user::isTeacher()) {
$db->where("assignment_id", $assignment_id);
$result2 = $db->get("assignment_group", "COUNT(*) as group_count")[0];
$result['group_count'] = $result2['group_count'];
$deadline = explode(" ", $result['deadline']);
$result['due_date'] = $deadline[0];
$result['due_time'] = $deadline[1];
$db->where("assignment_id", $assignment_id);
$sample_codes = $db->get("assignment_sample_code");
$result['sample_code'] = $sample_codes;
}
$result['deadline_time'] = strtotime($result['deadline']);
if (time() > $result['deadline_time']) {
$result['overdue'] = true;
} else {
$result['overdue'] = false;
$diff = $result['deadline_time'] - time();
$result['deadline_day'] = ceil($diff / 60 / 60 / 24);
}
return $result;
}
示例2: assignmentInfo
/**
* assignmentInfo function.
*
* @access public
* @param mixed $assignment_id
* @return void
*/
public function assignmentInfo($assignment_id)
{
$user_id = user::authService()['user_id'];
if (!isset($assignment_id) && !isset($user_id)) {
return -1;
}
$sql = "SELECT * FROM assignment WHERE assignment_id = '{$assignment_id}' ";
$result = $this->query($sql);
$row = $result->fetch_assoc();
$sqlFile = "SELECT * FROM file WHERE type_id = {$assignment_id} AND type = 'question' ";
$resultFile = $this->query($sqlFile);
$files = array();
while ($rowFile = $resultFile->fetch_assoc()) {
$filepath = file::getFilename($rowFile['file_id'], $rowFile['extension']);
$rowFile['filepath'] = $filepath;
$files[] = $rowFile;
}
$row['files'] = $files;
if (user::isStudent()) {
$row['group_id'] = assignment::groupID($assignment_id);
$row['editor'] = assignment::getEditor($row['group_id']);
} elseif (user::isTeacher()) {
$sql2 = "SELECT COUNT(*) as group_count FROM assignment_group WHERE assignment_id = '{$assignment_id}' ";
$result2 = $this->query($sql2);
$row2 = $result2->fetch_assoc();
$row['group_count'] = $row2['group_count'];
$deadline = explode(" ", $row['deadline']);
$row['due_date'] = $deadline[0];
$row['due_time'] = $deadline[1];
$sql3 = "SELECT * FROM assignment_sample_code WHERE assignment_id = '{$assignment_id}' ";
$result3 = $this->query($sql3);
$sample_codes = array();
while ($row3 = $result3->fetch_assoc()) {
$sample_codes[] = $row3;
}
$row['sample_code'] = $sample_codes;
}
return $row;
}