예제 #1
0
 /**
  * returns the folders list for a specific level/parent_id
  *
  * @param int $parentId
  * @param $safinstancesId
  * @return array
  */
 public function getFoldersFiles($parentId = 0, $safinstancesId)
 {
     $filesToReturn = array('files' => array(), 'nbpages' => 0);
     // folders
     $foldersDb = new Filfolders();
     if ($parentId > 0) {
         $upDb = $foldersDb->find($parentId);
         if (isset($upDb[0])) {
             $filesToReturn['files'][] = array('id' => $upDb[0]->parent_id, 'url' => '', 'name' => '..', 'fullname' => '..', 'filename' => '..', 'info' => 'up to "' . $upDb[0]->label . '"', 'date' => '', 'type' => 'FLD', 'istagged' => false, 'filetype' => 'folderback');
         }
     }
     if ($parentId == 0) {
         $parentQ = "(parent_id IS NULL OR parent_id = 0)";
     } else {
         $parentQ = "parent_id = '" . $parentId . "' ";
     }
     foreach ($foldersDb->fetchAll($parentQ . " AND safinstances_id = '" . $safinstancesId . "' ", 'label') as $file) {
         $filesToReturn['files'][] = array('id' => $file->id, 'url' => '', 'name' => $file->label, 'fullname' => $file->label, 'filename' => $file->label, 'info' => '', 'date' => '', 'type' => 'FLD', 'istagged' => false, 'filetype' => 'folder');
     }
     return $filesToReturn;
 }
예제 #2
0
 /**
  * Returns a resultset of tags proposal according to the requets sent.
  * This is used for autocompletion of the file tagging system
  * @return void
  */
 public function gettagsAction()
 {
     $r = $this->getRequest();
     $query = "SELECT id, label, parent_id\n\t\t\t\tFROM filfolders\n\t\t\t\tWHERE safinstances_id = '" . $this->safinstancesId . "'\n\t\t\t\tAND label LIKE '" . addslashes($r->mylabel) . "%'\n\t\t\t\tAND isnode = 0\n\t\t\t\tLIMIT 0 , 20";
     $tags = array();
     $parentsLabels = array();
     foreach ($this->_db->fetchAssoc($query) as $folder) {
         $folder['parentlabel'] = '';
         if ($folder['parent_id'] > 0) {
             if (isset($parentsLabels[$folder['parent_id']])) {
                 $folder['parentlabel'] = $parentsLabels[$folder['parent_id']];
             } else {
                 $folderDb = new Filfolders();
                 $findedFolder = $folderDb->find($folder['parent_id']);
                 $folder['parentlabel'] = $findedFolder[0]->label;
             }
         }
         $tags[] = array($folder['label'], $folder['parentlabel'], $folder['id']);
     }
     $this->view->ResultSet = array('Results' => $tags);
 }
예제 #3
0
 /**
  *
  * @return void
  */
 public function editprocessAction()
 {
     $this->view->jsdisp = false;
     $this->view->msg = 'ERROR: Undefined error';
     $r = $this->getRequest();
     if ($r->layout == 'out') {
         $this->_helper->layout->disableLayout();
     }
     if (isset($r->id)) {
         $eDB = new Filfolders();
         $e = $eDB->find($r->id);
         if (count($e) == 1) {
             if ($r->duplicate == 1) {
                 $e2 = $eDB->createRow();
                 $e2->desc = $r->desc;
                 $e2->isnode = $r->isnode;
                 $e2->isparam = $r->isparam;
                 $e2->label = $r->label;
                 $e2->relevance = $r->relevance;
                 $e2->parent_id = $e[0]->parent_id;
                 $e2->safinstances_id = $e[0]->safinstances_id;
                 $e2->save();
                 $this->view->msg = 'Entity duplicated';
             } else {
                 $e[0]->desc = $r->desc;
                 $e[0]->isnode = $r->isnode;
                 $e[0]->isparam = $r->isparam;
                 $e[0]->label = $r->label;
                 $e[0]->relevance = $r->relevance;
                 $this->view->label = $r->label;
                 $this->view->id = $r->id;
                 if ($e[0]->save()) {
                     $this->view->jsdisp = true;
                     $this->view->msg = 'Data saved, thanks.';
                 } else {
                     $this->view->msg = 'ERROR: error while saving the data';
                 }
             }
         } else {
             $this->view->msg = 'ERROR: we could not find an entry in our DB...';
         }
     } else {
         $this->view->msg = 'ERROR: Could not save the data';
     }
 }