Ejemplo n.º 1
0
<?php

/**
    @file
    @breif View a File Attachment, AJAX aware
*/
$mime = Base_File::mimeInfo($this->File['kind']);
// $opts = array(
//     'action'=>$this->link('/file/save'),
//     'enctype'=>'multipart/form-data',
//     'method'=>'post'
// );
// echo $this->form('FileUpload',$opts);
echo '<form action="' . radix::link('/file/save') . '" enctype="multipart/form-data" id="note-edit-form" method="post">';
echo '<table>';
echo '<tr><td class="l">File:</td><td>' . html($this->File['name']) . '</td></tr>';
echo '<tr><td class="l">Type:</td><td>' . img($mime['icon'], 'File') . '&nbsp;' . $mime['name'] . '</td></tr>';
echo '<tr><td class="l">Size:</td><td>' . ImperiumView::niceSize($this->File['size']) . '</td></tr>';
if (!empty($this->File->link)) {
    echo '<tr>';
    echo '<td class="l">Link To:</td>';
    echo '<td>';
    // @todo this is not elegant /djb 20111013
    if (preg_match('/(contact|invoice|workorder):(\\d+)/', $this->File['link'], $m)) {
        $page = '/' . $m[1] . '/view?' . substr($m[1], 0, 1) . '=' . $m[2];
        echo '<a href="' . radix::link($page) . '">' . ucfirst($m[1]) . ' #' . $m[2] . '</a>';
    } else {
        echo $this->File['link'];
    }
    echo '</td>';
    echo '</tr>';
Ejemplo n.º 2
0
// }
//
// if (!empty($_GET['c'])) {
// 	$f->link = sprintf('contact:%d',$_GET['c']);
// }
// if (!empty($_GET['i'])) {
// 	$f->link = sprintf('invoice:%d',$_GET['i']);
// }
// if (!empty($_GET['w'])) {
// 	$f->link = sprintf('workorder:%d',$_GET['w']);
// }
//
// if (!empty($f->link)) {
// 	$this->view->title = array('File','Create',' #' . $f->link);
// }
$f = new Base_File($_POST['id']);
switch (strtolower($_POST['a'])) {
    case 'delete':
        $f->delete();
        Session::flash('info', 'File Deleted');
        Radix::redirect('/file');
        break;
    case 'upload':
        $f->copyPost($_FILES['file']);
        //if ($f) {
        //	$f['id'] = intval($_POST['id']);
        //	$f['link'] = $_POST['link'];
        //	$f->import($_FILES['file']);
        $f->save();
        Session::flash('info', 'File #' . $f['id'] . ' Saved');
        // } else {
Ejemplo n.º 3
0
<?php

/**
    @file
    @brief File Controller
*/
$id = intval($_GET['id']);
// if (empty($id)) {
// 	throw new Exception('Bad Request', 400);
// }
$f = new Base_File($id);
if (empty($f['id'])) {
    throw new Exception('File Not Found', 404);
}
$_ENV['title'] = array('File', $f['name']);
$this->File = $f;
$this->FileHistoryList = $f->getHistory();