Beispiel #1
0
 public function getItem()
 {
     if (!$this->item) {
         $item = new Dase_DBO_Item($this->db);
         $item->load($this->item_id);
         $this->item = $item;
     }
     return $this->item;
 }
Beispiel #2
0
 public function getItems()
 {
     foreach ($this->getItemIds() as $item_id) {
         $item = new Dase_DBO_Item($this->db);
         $item->load($item_id);
         $this->items[] = $item;
     }
     return $this->items;
 }
Beispiel #3
0
 public function getSearchMd5($r)
 {
     $file = new Dase_DBO_MediaFile($this->db);
     $file->md5 = $r->get('q');
     $res = "files matching {$file->md5}\n";
     foreach ($file->find() as $mf) {
         $item = new Dase_DBO_Item($this->db);
         $item->load($mf->item_id);
         $res .= $item->getUrl($r->app_root) . "\n";
     }
     $r->renderResponse($res);
 }
Beispiel #4
0
 function getItem()
 {
     $item = new Dase_DBO_Item($this->db);
     if ($item->load($this->item_id)) {
         $item->getCollection();
         return $item;
     } else {
         if ($this->p_collection_ascii_id && $this->p_serial_number) {
             $item = Dase_DBO_Item::get($this->db, $this->p_collection_ascii_id, $this->p_serial_number);
             if ($item) {
                 $item->getCollection();
                 return $item;
             }
         }
     }
     return false;
 }
<?php

include 'config.php';
$comms = new Dase_DBO_Comment($db);
foreach ($comms->find() as $c) {
    $item = new Dase_DBO_Item($db);
    $item->load($c->item_id);
    $item->comments_updated = $c->updated;
    $item->comments_count = $item->comment_count + 1;
    $item;
    $item->update();
}
$cs = new Dase_DBO_Collection($db);
$i = 0;
foreach ($cs->find() as $c) {
    print "\nworking on {$c->collection_name}\n\n";
    foreach ($c->getItems() as $item) {
        $i++;
        $item = clone $item;
        if (!$item->collection_name) {
            $item->collection_name = $c->collection_name;
            $type = $item->getItemType();
            $item->item_type_ascii_id = $type->ascii_id;
            $item->item_type_name = $type->name;
            $item->update();
        }
        print "\n{$i}";
    }
}
Beispiel #6
0
 public function getItemsByAttAsAtom($attribute_ascii_id, $app_root)
 {
     $feed = $this->getBaseAtomFeed($app_root);
     $feed->setFeedType('items');
     $att = Dase_DBO_Attribute::get($this->db, $this->ascii_id, $attribute_ascii_id);
     $vals = new Dase_DBO_Value($this->db);
     $vals->attribute_id = $att->id;
     foreach ($vals->find() as $val) {
         $item = new Dase_DBO_Item($this->db);
         $item->load($val->item_id);
         //use cached ???
         $entry = $item->injectAtomEntryData($feed->addEntry(), $app_root);
         $entry->setSummary($item->getValue($attribute_ascii_id));
     }
     return $feed->asXML($app_root);
 }
Beispiel #7
0
 public function postToItemEditForm($r)
 {
     $item = new Dase_DBO_Item($this->db);
     $item->load($r->get('id'));
     $item->text = $r->get('text');
     $item->update();
     $list = $item->getList();
     $r->renderRedirect($list->uniq_id);
 }
Beispiel #8
0
 function getItem()
 {
     $item = new Dase_DBO_Item($this->db);
     $item->load($this->item_id);
     return $item;
 }
Beispiel #9
0
 public function postToSwapFile($r)
 {
     $item = new Dase_DBO_Item($this->db);
     if (!$item->load($r->get('id'))) {
         $r->renderError(404);
     }
     if ($this->user->eid != $item->created_by && !$this->user->is_admin) {
         $r->renderError(401);
     }
     //@unlink($old_path);
     $file = $r->_files['uploaded_file'];
     if ($file && is_file($file['tmp_name'])) {
         $name = $file['name'];
         $path = $file['tmp_name'];
         $type = $file['type'];
         if (!is_uploaded_file($path)) {
             $r->renderError(400, 'no go upload');
         }
         if (!isset(Dase_File::$types_map[$type])) {
             $r->renderError(415, 'unsupported media type: ' . $type);
         }
         $base_dir = $this->config->getMediaDir();
         $old_path = $base_dir . '/' . $item->name;
         @unlink($old_path);
         //we won't worry about deleting old thumbnail
         if (!file_exists($base_dir) || !is_writeable($base_dir)) {
             $r->renderError(403, 'not allowed');
         }
         $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION));
         $basename = Dase_Util::dirify(pathinfo($name, PATHINFO_FILENAME));
         if ('application/pdf' == $type) {
             $ext = 'pdf';
         }
         if ('application/msword' == $type) {
             $ext = 'doc';
         }
         if ('application/vnd.openxmlformats-officedocument.wordprocessingml.document' == $type) {
             $ext = 'docx';
         }
         $newname = $this->_findNextUnique($base_dir, $basename, $ext);
         $new_path = $base_dir . '/' . $newname;
         //move file to new home
         rename($path, $new_path);
         chmod($new_path, 0775);
         $size = @getimagesize($new_path);
         //ONLY update name if item had file already
         //adding file to text item shouldn't change name
         if ($item->file_url) {
             $item->name = $newname;
         }
         if (!$item->title) {
             $item->title = $item->name;
         }
         $item->file_url = 'file/' . $newname;
         $item->filesize = filesize($new_path);
         $item->mime = $type;
         $parts = explode('/', $type);
         if (isset($parts[0]) && 'image' == $parts[0]) {
             $thumb_path = $base_dir . '/thumb/' . $newname;
             $thumb_path = str_replace('.' . $ext, '.jpg', $thumb_path);
             $command = CONVERT . " \"{$new_path}\" -format jpeg -resize '100x100 >' -colorspace RGB {$thumb_path}";
             $exec_output = array();
             $results = exec($command, $exec_output);
             if (!file_exists($thumb_path)) {
                 //Dase_Log::info(LOG_FILE,"failed to write $thumb_path");
             }
             chmod($thumb_path, 0775);
             $newname = str_replace('.' . $ext, '.jpg', $newname);
             $item->thumbnail_url = 'file/thumb/' . $newname;
         } else {
             $item->thumbnail_url = 'www/img/mime_icons/' . Dase_File::$types_map[$type]['size'] . '.png';
         }
         if (isset($size[0]) && $size[0]) {
             $item->width = $size[0];
         }
         if (isset($size[1]) && $size[1]) {
             $item->height = $size[1];
         }
     }
     $item->updated_by = $this->user->eid;
     $item->updated = date(DATE_ATOM);
     $item->update();
     $r->renderRedirect('item/' . $item->id);
 }