예제 #1
0
파일: images.php 프로젝트: netixx/frankiz
 function handler_upload($page)
 {
     $page->assign('exception', false);
     $page->assign('image', false);
     if (FrankizUpload::has('file')) {
         $g = Group::from('temp')->select(GroupSelect::castes());
         $temp = $g->caste(Rights::everybody());
         try {
             $upload = FrankizUpload::v('file');
             $secret = uniqid();
             $i = new FrankizImage();
             $i->insert();
             $i->caste($temp);
             $i->label($secret);
             $i->image($upload);
             $page->assign('image', $i);
             $page->assign('secret', $secret);
         } catch (Exception $e) {
             try {
                 if ($i) {
                     $i->delete();
                 }
             } catch (Exception $eb) {
                 $page->assign('exception', $eb);
             }
             $page->assign('exception', $e);
             if ($e instanceof ImageSizeException) {
                 $page->assign('pixels', true);
             } else {
                 if ($e instanceof UploadSizeException) {
                     $page->assign('bytes', true);
                 } else {
                     if ($e instanceof ImageFormatException) {
                         $page->assign('format', true);
                     }
                 }
             }
         }
     }
     if (Env::has('delete')) {
         $image = new FrankizImage(Env::i('iid'));
         $image->select(FrankizImageSelect::base());
         if ($image->label() == Env::s('secret')) {
             $image->delete();
         }
     }
     $page->addCssLink('upload.css');
     $page->changeTpl('images/upload.tpl', SIMPLE);
 }
예제 #2
0
/**
 * Create an image for a promotion, for a group, if needed
 */
function create_promo_image(Group $g, $promo)
{
    $g->select(GroupSelect::base());
    if ($g->image()) {
        return;
    }
    if ($promo % 2 == 0) {
        $upload = FrankizUpload::fromFile(dirname(__FILE__) . '/../images/rouje.png');
        $label = 'Chic à la rouje';
    } else {
        $upload = FrankizUpload::fromFile(dirname(__FILE__) . '/../images/jone.png');
        $label = 'Chic à la jone';
    }
    $i = new FrankizImage();
    $i->insert();
    $i->caste($g->caste(Rights::everybody()));
    $i->label($label);
    $i->image($upload, false);
    $g->image($i);
}
예제 #3
0
파일: import.php 프로젝트: netixx/frankiz
     }
 */
 //Photo
 $works = false;
 $suffix = '_original';
 $folder = '/home/2009/matthieu/photos';
 $original = true;
 $path = $folder . '/' . $u->hruid() . $suffix . '.jpg';
 if (file_exists($path)) {
     $upload = FrankizUpload::fromFile($path);
     if ($upload->size() > 0) {
         try {
             $i = new FrankizImage();
             $i->insert();
             $i->caste($tol_caste);
             $i->label($u->firstname() . ' ' . $u->lastname());
             $i->image($upload, false);
             if ($original) {
                 $u->original($i);
             } else {
                 $u->photo($i);
             }
             $works = true;
         } catch (Exception $e) {
             echo 'Error:' . $e->getMessage() . "\n";
         }
     }
 }
 if (!$works) {
     echo 'Not done: ' . $u->id() . ' - ' . $u->displayname() . ' - ' . $path . "\n";
 }
예제 #4
0
파일: links.php 프로젝트: netixx/frankiz
 function handler_links_admin($page)
 {
     if (!S::user()->perms()->hasFlag('admin')) {
         return PL_FORBIDDEN;
     }
     $collec = Link::all();
     $collec->select(LinkSelect::all());
     $results = $collec->split('ns');
     if (Env::has('modify')) {
         $id = Env::i('id');
         $link = $collec->get($id);
         if ($link !== false) {
             if (Env::has('image')) {
                 try {
                     $group = Group::from('partnership');
                     $group->select();
                     $image = new FrankizImage();
                     $image->insert();
                     $image->label($link->label());
                     $image->caste($group->caste('everybody'));
                     $image->image(FrankizUpload::v('image'));
                     $link->image($image);
                 } catch (Exception $e) {
                     $page->assign('err', $e->getMessage());
                 }
             }
             $link->label(Env::t('label'));
             $link->link(Env::t('link'));
             $link->description(Env::t('description'));
             $link->comment(Env::t('comment'));
         } else {
             $err = 'Le lien modifié n\'existe plus.';
             $page->assign('err', $err);
         }
     }
     $page->addCssLink('links.css');
     $page->assign('links', $results);
     $page->assign('title', 'Administrer les liens');
     $page->changeTpl('links/admin_links.tpl');
 }