public function getTags($usersId)
 {
     $user = new Users();
     $tag = new Filfolders();
     $selector = $this->select(Zend_Db_Table::SELECT_WITHOUT_FROM_PART)->setIntegrityCheck(false)->from(array('u' => $user->getTableName(true)), '')->join(array('fu' => $this->getTableName(true)), 'u.id = fu.users_id', '')->join(array('ff' => $tag->getTableName(true)), 'fu.filfolders_id = ff.id', array('label', 'parent_id', 'id'))->where('u.id = ?', $usersId)->where('ff.safinstances_id = ?', Sydney_Tools_Sydneyglobals::getSafinstancesId())->order('ff.pagorder');
     return $this->fetchAll($selector);
 }
Exemple #2
0
 /**
  *
  * @param $divs
  * @param bool $showTitles
  * @param array $titleTags
  * @return mixed
  */
 private function _postContentTreatment($divs, $showTitles = false, $structure = false)
 {
     $titleTags = array('<div class="breadcrumbs margin-bottom-40"><div class="container"><h1 class="color-green pull-left">', '</h1></div></div>');
     if (!$showTitles) {
         return $divs;
     } else {
         $oldPageStructureId = '';
         for ($i = 0; $i < count($divs); $i++) {
             $pageStructureId = $divs[$i]['pagstructure_id'];
             $breadCrum = $structure->getBreadCrumData(Sydney_Tools_Sydneyglobals::getSafinstancesId(), $divs[$i]['pagstructure_id']);
             $label = '';
             foreach ($breadCrum as $elm) {
                 $label = $elm['label'];
             }
             if ($oldPageStructureId == $pageStructureId) {
                 $label = '';
             }
             if ($label != '') {
                 $label = $titleTags[0] . $label . $titleTags[1];
             }
             $divs[$i]['content'] = $label . $divs[$i]['content'];
             $oldPageStructureId = $pageStructureId;
         }
         return $divs;
     }
 }
Exemple #3
0
 /**
  * Start caching
  *
  * Determine if we have a cache hit. If so, return the response; else,
  * start caching.
  *
  * @param  Zend_Controller_Request_Abstract $request
  * @return void
  */
 public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
 {
     $request = $this->getRequest();
     // $request = new Zend_Controller_Request_Http();
     $moduleName = $request->getModuleName();
     $params = $request->getParams();
     /**
      * On récupère la homeId uniquement si on arrive à la racine du site
      * @author GDE
      * @project Belgium Telecom
      * @since 10/01/2013
      */
     $pagstrDB = new Pagstructure();
     if (count($params) == 3 && $params['module'] == 'publicms' && $params['controller'] == 'index' && $params['action'] == 'view') {
         $params['page'] = $pagstrDB->getHomeId(Sydney_Tools_Sydneyglobals::getSafinstancesId());
     }
     if ($moduleName == 'publicms' && isset($params['page'])) {
         $pagstr = $pagstrDB->find($params['page']);
         if (count($pagstr) == 1) {
             /**
              * Enregistre en session le rootid courant
              * Utilisé pour savoir quel index de recherche utiliser
              * FAR: Utile aussi pour la séparation par langue
              * @author GDE
              * @project Belgium Telecom
              * @since 10/01/2013
              */
             $breadCrumData = $pagstrDB->getBreadCrumData(Sydney_Tools_Sydneyglobals::getSafinstancesId(), $this->_treatPageData($params['page']));
             $rootid = $breadCrumData[0]['id'];
             $lucenesearch = new Zend_Session_Namespace('current-page-rootid');
             if (!empty($rootid)) {
                 $lucenesearch->rootid = $rootid;
             }
             $struct = $pagstr[0];
             $struct->hits++;
             $struct->save();
             if (!Sydney_Auth::getInstance()->hasIdentity() && $struct->iscachable != 0 && $struct->cachetime > 0) {
                 $this->cache->setLifetime($struct->cachetime);
                 if (!$request->isGet()) {
                     self::$doNotCache = true;
                     return;
                 }
                 $path = $request->getPathInfo();
                 $this->key = $moduleName . '_' . md5($path);
                 if (false !== ($response = $this->getCache())) {
                     $response->sendResponse();
                     exit;
                 }
             }
         }
     }
 }
 /**
  * Helper main function
  * @param $actionsHtml String HTML code showing the action buttons
  * @param $content String The content of this element
  * @param $dbId Int DB id of the object
  * @param $order Int order of this item in the DB
  * @param $params Array parameters (if any)
  * @return String HTML to be inserted in the view
  */
 public function contentViewembeder($actionsHtml = '', $content = '', $dbId = 0, $order = 0, $params = array(), $pagstructureId = 0)
 {
     if (!empty($content)) {
         switch (Sydney_Tools_Sydneyglobals::getConf('helpers')->content->viewembedder->method) {
             case 'ajax':
                 return Sydney_View_Embedder_Content::ajaxContents($content);
                 break;
             case 'filegetcontents':
                 return file_get_contents(Sydney_Tools::getRootUrl() . '/' . $content . '/sydneylayout/no/');
                 break;
             case 'curlgetcontents':
                 return Sydney_View_Embedder_Content::curlGetContents(Sydney_Tools::getRootUrl() . $content . '/sydneylayout/no/');
                 break;
             case 'action':
             default:
                 $i = 0;
                 $module = null;
                 $controller = null;
                 $action = null;
                 $oldv = null;
                 $params2 = array();
                 foreach (preg_split("/\\//", $content) as $v) {
                     if ($i == 1) {
                         $module = $v;
                     } elseif ($i == 2) {
                         $controller = $v;
                     } elseif ($i == 3) {
                         $action = $v;
                     } elseif ($i > 3) {
                         if ($i % 2 == 0) {
                             $params2[$v] = null;
                             $oldv = $v;
                         }
                         if ($i % 2 == 1) {
                             $params2[$oldv] = $v;
                             $oldv = null;
                         }
                     }
                     $i++;
                 }
                 return $this->view->action($action, $controller, $module, array_merge($params2, $params));
                 break;
         }
     }
     // END - if content
     return '';
 }
 public function save($label, Sydney_Content_Translator $translate, $lang, $tableId, $tableField = '')
 {
     $rowTranlationData = $this->getRowByTableName(array($translate->getTableName()), $lang, $tableId, $tableField);
     // If exist then update row
     if ($rowTranlationData) {
         $rowTranlationData->label = $label;
         $result = $this->update(array('label' => $label), 'tbl_name = "' . $translate->getTableName() . '" AND tbl_id = ' . intval($tableId) . ' AND code_language = "' . $lang . '"
                 AND tbl_field = "' . $tableField . '" AND safinstances_id = ' . Sydney_Tools_Sydneyglobals::getSafinstancesId());
     } else {
         // Else create row
         $result = $this->insert(array('label' => $label, 'tbl_name' => $translate->getTableName(), 'tbl_id' => intval($tableId), 'tbl_field' => $tableField, 'code_language' => $lang, 'safinstances_id' => Sydney_Tools_Sydneyglobals::getSafinstancesId()));
     }
     // Clear cache
     $cache = Zend_Registry::get('cache');
     $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
     return $result;
 }
Exemple #6
0
 public function __construct($id = 0)
 {
     $this->_schema = Sydney_Tools_Sydneyglobals::getConf()->db->params->dbname;
     parent::__construct($id);
 }
 /**
  * @since 19/02/2014
  */
 public function getcleanurlpagebyidnodeAction()
 {
     $id = (int) $this->_getParam('id', null);
     $page = new Pagstructure();
     $data = $page->get($id);
     $label = Sydney_Tools_Sydneyglobals::getConf('general')->url->newFormat && !empty($data['url']) ? $data['url'] : Sydney_Tools_Friendlyurls::getUrlLabel($data['label']);
     $this->view->resultSet = array('url' => Sydney_Tools_Friendlyurls::getFriendlyUrl($id, $label, 'page', new Zend_View_Helper_Url()));
 }
 /**
  * Send the email
  *
  * @param string $emails List of recepients separated by a space
  * @param $dbRow
  * @return Zend_Mail | false
  */
 protected function _sendEmailForms($emails = '', $dbRow)
 {
     $mail = new Zend_Mail();
     // define the recipients
     $eValidator = new Zend_Validate_EmailAddress();
     $sendTheMail = false;
     if (trim($emails) == '') {
         $email = Sydney_Tools_Sydneyglobals::getConf('general')->siteEmail;
         if ($eValidator->isValid($email)) {
             $mail->addTo($email, Sydney_Tools_Sydneyglobals::getConf('general')->siteTitle . ' website');
             $sendTheMail = true;
         }
     } else {
         foreach (preg_split('/,/', $emails) as $email) {
             if ($eValidator->isValid(trim($email))) {
                 $mail->addTo($email, Sydney_Tools_Sydneyglobals::getConf('general')->siteTitle . ' website');
                 $sendTheMail = true;
             }
         }
     }
     if ($sendTheMail) {
         $mail->setBodyText('This email is in HTML format');
         $msg = '<br/><br/>You have received an email from the "email form" available on ' . Sydney_Tools_Sydneyglobals::getConf('general')->siteTitle . ' :<br/><br/><br/>';
         if ($dbRow->fname != '') {
             $msg .= '<b>First Name</b> : ' . $dbRow->fname . '<br/>';
         }
         if ($dbRow->lname != '') {
             $msg .= '<b>Last Name</b> : ' . $dbRow->lname . '<br/>';
         }
         if ($dbRow->fullname != '') {
             $msg .= '<b>Full name</b> : ' . $dbRow->fullname . '<br/>';
         }
         if ($dbRow->email != '') {
             $msg .= '<b>Email</b> : ' . $dbRow->email . '<br/>';
         }
         if ($dbRow->phonenr != '') {
             $msg .= '<b>Phone Number</b> : ' . $dbRow->phonenr . '<br/>';
         }
         if ($dbRow->subject != '') {
             $msg .= '<b>Subject</b> : ' . $dbRow->subject . '<br/>';
         }
         if ($dbRow->message != '') {
             $msg .= '<b>Message</b> :<br/> ' . nl2br($dbRow->message) . '<br/>';
         }
         $msg .= '<br/><br/>';
         $mail->setBodyHtml($msg);
         $mail->setFrom($dbRow->email, $dbRow->fname . ' ' . $dbRow->lname . ' ' . $dbRow->fullname);
         $mail->setSubject('Email form - ' . $dbRow->subject);
         return $mail->send();
     } else {
         return false;
     }
 }
Exemple #9
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;
     }
 }