Example #1
0
 /**
  * Returns the PAGDIVS elements contained in a page with the ID passed as param.
  *
  * @param integer $pageStructureId ID of the page you want retreive the divs from
  * @param boolean $onlyOnline If you only want the divs that have a status "online". Default = true.
  * @param array $dontRetreiveIds Array of div ids we don't want to retreive (or we want to hide)
  * @param bool $showTitles
  * @param array $titleTags
  *
  * @return Array result in an array form containing assotiative array rows
  */
 public function getDivs($pageStructureId = 44, $onlyOnline = true, $dontRetreiveIds = array(), $showTitles = false, $titleTags = array('<h1>', '</h1>'), $structure = false)
 {
     $pageStructureId = (int) $pageStructureId;
     $usersId = Sydney_Tools_User::getUserdata('users_id');
     if (!$usersId) {
         $usersId = 0;
     }
     $sql = "SELECT *, pagstructure_pagdivs.order as order_pagstructure_pagdiv\n\t\t\t\tFROM\n\t\t\t\t\tpagdivs, pagstructure_pagdivs\n\t\t\t\tWHERE\n\t\t\t\t\tpagdivs.id = pagstructure_pagdivs.pagdivs_id AND\n\t\t\t\t\tpagstructure_pagdivs.pagstructure_id = '" . $pageStructureId . "'\n\t\t\t\tAND pagdivs.isDeleted = 0";
     if ($onlyOnline) {
         $sql .= ' AND pagdivs.online = 1';
     }
     if (count($dontRetreiveIds) > 0) {
         $sql .= ' AND pagdivs.id NOT IN (' . implode(',', $dontRetreiveIds) . ') ';
     }
     // $sql .= ' ORDER BY pagdivs.order';
     // 12 Jun 2013 - AS - use the order from the link table so we can have different orders in pages for 1 node
     $sql .= ' ORDER BY pagstructure_pagdivs.order';
     return $this->_postContentTreatment($this->checkIsEditable($this->_db->fetchAll($sql)), $showTitles, $titleTags, $structure);
 }
Example #2
0
 /**
  * Move a file from a directory to the final appdata of the webinstance
  * and register it to the DB
  *
  * @param string $filepath Path to the temp files
  * @param string $comment Comment to place in the meta description (for search purpose, for ex the name of the user)
  * @param string $folder The name of the folder to push the files in
  * @return bool|int
  */
 public function fileToFileManager($filepath = '', $comment = '', $folder = 'temp')
 {
     if (!file_exists($filepath)) {
         return false;
     }
     try {
         $fileObj = Sydney_Medias_Filetypesfactory::createfiletype($filepath);
         $newName = uniqid() . '_' . Sydney_Medias_Utils::sanitizeFilename($fileObj->basename . '.' . $fileObj->extension);
         $newPath = Sydney_Tools_Paths::getAppdataPath() . '/adminfiles/' . $fileObj->extension . '/';
         if (!is_dir($newPath)) {
             mkdir($newPath, 0777, true);
         }
         rename($filepath, $newPath . $newName);
         $fileName = $newName;
         $newFileObj = Sydney_Medias_Filetypesfactory::createfiletype($newPath . $newName);
         $fileInfo = $newFileObj->getFileinfo();
         $fileWeight = $fileInfo['general.filesize'];
         // On récupère la taille du fichier pour pouvoir l'ajouter en DB
         $type = $newFileObj->extension;
         $usersId = Sydney_Tools_User::getUserdata('users_id');
         // @todo TODO we ll have to change that, for now it uploads the file as Arnaud (user id 1) if nothing is defined.
         if ($usersId === false) {
             $usersId = 1;
         }
         $safinstancesId = Sydney_Tools_Sydneyglobals::getSafinstancesId();
         // save the file to DB
         $fileFilesId = $this->registerFileToDb($newPath, $fileName, $fileWeight, $type, $usersId, $safinstancesId, array(), $comment);
         // put them in the right folder
         $filefoldersDb = new Filfolders();
         $filefoldersId = $filefoldersDb->addSystemFolder($folder);
         if ($fileFilesId) {
             $fileCorDb = new FilfoldersFilfiles();
             $fileCor = $fileCorDb->createRow();
             $fileCor->filfolders_id = $filefoldersId;
             $fileCor->filfiles_id = $fileFilesId;
             $fileCor->save();
         }
         // returns the files ids
         return $fileFilesId;
     } catch (Exception $e) {
         Zend_Debug::dump($e->getMessage());
         return false;
     }
 }