Пример #1
0
 /**
  * Returns an array containing the list of modules as key and controllers in a sub array
  * Example:
  * <code>
  * Array
  * (
  *     [admin] => Array
  *         (
  *             [0] => Index
  *             [1] => Jscripts
  *             [2] => Servicesfolder
  *         )
  *
  * </code>
  * @param string $modulesPath
  * @return array
  */
 public function getModulesAndControllersList($introspect = false, $modulesPath = '/core/application/modules/')
 {
     $rdir = Sydney_Tools_Paths::getCorePath() . '/../' . $modulesPath;
     $dirs = array();
     // get the module directory
     if ($handle = opendir($rdir)) {
         while (false !== ($file = readdir($handle))) {
             if (!preg_match('/^\\./', $file)) {
                 $dirs[$file] = array();
                 if ($handle2 = opendir($rdir . $file . '/controllers/')) {
                     while (false !== ($cntrl = readdir($handle2))) {
                         if (!preg_match('/^\\./', $cntrl)) {
                             $cnl = preg_split('/Controller.php/', $cntrl);
                             if (count($cnl) == 2) {
                                 if ($introspect) {
                                     $dirs[$file][$cnl[0]] = $this->introspect($file, $cnl[0], $rdir . $file . '/controllers/' . $cntrl);
                                 } else {
                                     $dirs[$file][] = $cnl[0];
                                 }
                             }
                         }
                     }
                 }
             }
         }
         closedir($handle);
     }
     return $dirs;
 }
Пример #2
0
 private function setLayoutLoginAdmin()
 {
     $this->view->headLink()->appendStylesheet($this->view->cdn . '/sydneyassets/styles/reset.css');
     $this->view->headLink()->appendStylesheet($this->view->cdn . '/sydneyassets/styles/main.css');
     $this->view->headLink()->appendStylesheet($this->view->cdn . '/sydneyassets/styles/antidot.css');
     $this->view->headLink()->appendStylesheet($this->view->cdn . '/sydneyassets/styles/antidotprint.css', 'print');
     $this->view->headLink()->appendStylesheet('/sydneyassets/jslibs/jquery/css/smoothness/jquery-ui-1.10.4.min.css');
     $this->view->headScript()->appendFile(Sydney_Tools::getRootUrlCdn() . '/sydneyassets/scripts/sydneyscripts.js', 'text/javascript');
     $this->_helper->layout->setLayoutPath(Sydney_Tools_Paths::getCorePath() . '/webinstances/sydney/layouts');
     $this->_helper->layout->setLayout('login');
 }
Пример #3
0
 /**
  * Add modules
  */
 public function initCustomModules()
 {
     if (count($this->customModules) > 0) {
         $this->frontController->addModuleDirectory(Sydney_Tools_Paths::getCustomapPath() . '/modules');
         foreach ($this->customModules as $module => $role) {
             $this->frontController->addControllerDirectory(Sydney_Tools_Paths::getCustomapPath() . '/modules/' . $module . '/controllers', $module);
         }
     }
 }
Пример #4
0
 /**
  * Displays the content of a zip file (id passed as arg)
  */
 public function showzipcontentAction()
 {
     $request = $this->getRequest();
     if (isset($request->id) && preg_match('/^[0-9]{1,30}$/', $request->id)) {
         $id = $request->id;
         $fileModel = new Filfiles();
         $where = "id = " . $id . " AND safinstances_id = '" . $this->safinstancesId . "' AND type = 'ZIP' ";
         $files = $fileModel->fetchAll($where);
         $this->view->ziplist = array();
         if (count($files) == 1) {
             $file = $files[0];
             //Définition dynamique du fullpath
             $fileType = $file->type;
             $fullpath = Sydney_Tools_Paths::getAppdataPath() . '/adminfiles/' . $fileType . '/' . $file->filename;
             $fileTypeInstance = Sydney_Medias_Filetypesfactory::createfiletype($fullpath);
             $this->view->ziplist = $fileTypeInstance->getZipContent();
         }
     }
 }
Пример #5
0
 /**
  * Check the access rights agains the DB if we are in the publicms module
  *
  * @param $role
  * @return void
  */
 private function checkRightsPublicms($role)
 {
     // check if instance is offline
     $safinstanceDB = new Safinstances();
     $safinstances = $safinstanceDB->find($this->safinstancesId);
     if (count($safinstances) != 1) {
         print "FATAL ERROR 452 in Sydney_Controller_Plugin_Auth::checkRightsPublicms(" . $this->safinstancesId . ")";
         header('Location: ' . Sydney_Tools_Paths::getRootUrlCdn() . '/install/instance/index.php/referrer/PluginAuth/checkRightsPublicms/noinstancefound');
         exit;
     } elseif ($safinstances[0]->active == 0) {
         print $safinstances[0]->offlinemessage;
         if (empty($safinstances[0]->offlinemessage)) {
             print "This site is offline.";
             header('Location: ' . Sydney_Tools_Paths::getRootUrlCdn() . '/install/instance/index.php/referrer/PluginAuth/checkRightsPublicms');
         }
         exit;
     }
     // get page data
     $d = $this->request->getParams();
     if ($d['module'] == 'publicms' && $d['controller'] == 'index' && $d['action'] == 'view') {
         $nodes = new Pagstructure();
         if (!isset($d['page']) || !preg_match("/^[0-9]{1,100}\$/", $d['page'])) {
             $nodeId = $nodes->getHomeId($this->safinstancesId);
         } else {
             $nodeId = $d['page'];
         }
         $node = $nodes->fetchAll(" id = '" . $nodeId . "' AND safinstances_id = '" . $this->safinstancesId . "' ");
         if (count($node) == 1) {
             $authorizedGroupId = $node[0]->usersgroups_id;
             if (!self::isContentAccessible($authorizedGroupId, $this->userNamespace->user['member_of_groups'])) {
                 $this->redirecting('default', 'login', 'index', 'code04');
             }
         } else {
             print "Node {$nodeId} not found! (FATAL ERROR 542 in Sydney_Controller_Plugin_Auth::checkRightsPublicms)";
             header('Location: ' . Sydney_Tools_Paths::getRootUrlCdn() . '/install/instance/index.php/referrer/PluginAuth/checkRightsPublicms/nodenotfound');
             exit;
         }
     }
 }
Пример #6
0
 public function __construct()
 {
     Zend_Translate::setCache(Zend_Cache::factory('Core', 'File', array('lifetime' => 7200, 'automatic_serialization' => true), array('cache_dir' => Sydney_Tools_Paths::getCachePath(), 'file_locking' => false)));
     $this->setTranslate(new Zend_Translate(array('adapter' => 'Sydney_Translate_Adapter_Db', 'content' => $this::TABLE_NAME, 'locale' => Sydney_Tools_Localization::getCurrentContentLanguage(), 'disableNotices' => $this::DISABLE_NOTICE)));
     $this->getTranslate()->addTranslation(array('adapter' => 'Sydney_Translate_Adapter_Db', 'content' => $this::TABLE_NAME, 'locale' => Sydney_Tools_Localization::getCurrentContentLanguage(), 'disableNotices' => $this::DISABLE_NOTICE));
 }
Пример #7
0
 /**
  * Add the the logging in a CSV file
  */
 public function addFilterCSV()
 {
     $writer = new Zend_Log_Writer_Null();
     if ($this->debugLevel > 0) {
         $registry = Zend_Registry::getInstance();
         $config = $registry->get('config');
         $writer = new Zend_Log_Writer_Stream(Sydney_Tools_Paths::getWebInstancePath() . DIRECTORY_SEPARATOR . $config->general->logdirpath . '/general.log.csv');
         $format = '"%timestamp%","%priorityName%","%priority%","%className%","%message%","%identity%","%HTTP_REFERER%","%REMOTE_ADDR%","%REQUEST_METHOD%","%REQUEST_TIME%"' . PHP_EOL;
         $formatter = new Zend_Log_Formatter_Simple($format);
         $writer->setFormatter($formatter);
     }
     $this->addWriter($writer);
 }
Пример #8
0
 /**
  * Show small images from uploaded pictures based on it's id and type size
  *
  * Type size :
  * 2 = 64x64 pixel
  * 3 = 32x32 pixel
  * 4 = 16x16 pixel
  *
  * Example : /publicms/file/thumb/id/1/ts/2
  * where ts is the thumb size mode
  * amd id is the ID of the file to get
  */
 public function thumbAction()
 {
     $this->initFileHeaders();
     $request = $this->getRequest();
     if (isset($request->id) && preg_match('/^[0-9]{1,30}$/', $request->id)) {
         if (isset($request->ts) && preg_match('/^[0-9]{1,30}$/', $request->ts)) {
             $typeSize = $request->ts;
         } else {
             $typeSize = 1;
         }
         $elementId = $request->id;
         $fileModel = new Filfiles();
         $where = 'id = ' . $elementId . ' AND safinstances_id = ' . $this->safinstancesId;
         $result = $fileModel->fetchAll($where);
         if (count($result) == 1) {
             $file = $result[0];
             $fileType = $file->type;
             $fullpath = Sydney_Tools_Paths::getAppdataPath() . '/adminfiles/' . $fileType . '/' . $file->filename;
             $fileTypeInstance = Sydney_Medias_Filetypesfactory::createfiletype($fullpath);
             // defines the thumb size
             if ($typeSize == 2) {
                 $fileTypeInstance->thumbSize = array(64, 64);
             }
             if ($typeSize == 3) {
                 $fileTypeInstance->thumbSize = array(32, 32);
             }
             if ($typeSize == 4) {
                 $fileTypeInstance->thumbSize = array(16, 16);
             }
             if (!$fileTypeInstance->showThumb()) {
                 print 'Image can not be processed';
             }
         } else {
             print 'You do not have access to this information';
         }
     } else {
         print 'Something is missing...';
     }
     $this->render('index');
 }
Пример #9
0
 public function uploadscreenAction()
 {
     $this->_helper->layout->setLayoutPath(Sydney_Tools_Paths::getCorePath() . '/webinstances/sydney/layouts');
     $this->_helper->layout->setLayout('layoutBlank');
 }
Пример #10
0
 public function __construct()
 {
     $this->path = Sydney_Tools_Paths::getLocalPath() . '/layouts/';
 }
Пример #11
0
 /**
  *
  * @param $path string
  */
 public static function setWebInstancePath($path)
 {
     self::$webInstancePath = $path;
 }
Пример #12
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;
     }
 }
Пример #13
0
 /**
  *
  * @param unknown_type $type
  * @param Zend_View $zview
  * @param unknown_type $useCompression
  * @param unknown_type $useConcatenation
  * @param unknown_type $ctrl
  */
 public static function concatScripts($type, Zend_View $zview, $useConcatenation = true)
 {
     $r = '';
     $path = Sydney_Tools_Paths::getCorePath() . '/webinstances/sydney/html';
     $path2 = Sydney_Tools_Paths::getJslibsPath();
     $arrayOrig['jsOrig'] = Zend_Registry::getInstance()->get('config')->admin->js->orig;
     $arrayOrig['cssOrig'] = Zend_Registry::getInstance()->get('config')->admin->css->orig;
     $arrayLibs['jsLibs'] = Zend_Registry::getInstance()->get('config')->admin->js->libs;
     $arrayLibs['cssLibs'] = Zend_Registry::getInstance()->get('config')->admin->css->libs;
     /**
      * CSS + JS
      */
     // adding the main files from the jslibs
     foreach ($arrayLibs[$type . 'Libs'] as $file) {
         if ($useConcatenation) {
             if (file_exists($path2 . $file)) {
                 $tcnt = file_get_contents($path2 . $file);
                 if ($type == 'css' && preg_match('#sydneyassets\\/jslibs\\/jquery#', $file)) {
                     $needleStr = "#url\\(\"images\\/([a-zA-Z0-9_-]+)\\.(png|gif|jpg)\"#";
                     $replaceStr = "url(" . Sydney_Tools_Paths::getRootUrlCdn() . "\\/sydneyassets\\/jslibs\\/jquery\\/css\\/smoothness\\/images\\/\$1.\$2";
                     $tcnt = preg_replace($needleStr, $replaceStr, $tcnt);
                 }
                 if ($type == 'css' && preg_match('/skins\\/sam/', $file)) {
                     $pht = preg_replace("/^\\/assets\\/yui\\/build\\/([A-z]{1,50})\\/assets\\/skins\\/sam\\/([A-z-_]{1,50}(\\.css))/", "/sydneyassets/yui/build/\\1/assets/skins/sam/", $file);
                     $tcnt = str_replace('../../../../assets/skins/sam/', Sydney_Tools::getRootUrlCdn() . '/sydneyassets/yui/build/assets/skins/sam/', $tcnt);
                     $tcnt = preg_replace("/url\\(([A-z0-9_-]{1,50})\\.(png)\\)/", "url(" . $pht . "\\1.\\2)", $tcnt);
                 }
                 $r .= "/* =========== File: " . $path2 . $file . " ================ */ \n\n\n" . $tcnt . "\n\n\n\n";
             }
         } else {
             if ($type == 'css') {
                 $zview->headLink()->appendStylesheet($file);
             } else {
                 // GDE - 19/08/2013 - On va chercher "jslibs" sur le cdn (com.antidot.sydney)
                 $zview->headScript()->appendFile(Zend_Registry::getInstance()->get('config')->general->cdn . $file, 'text/javascript');
             }
         }
     }
     // adding the main files
     foreach ($arrayOrig[$type . 'Orig'] as $file) {
         if ($useConcatenation) {
             $tcnt = file_get_contents($path . $file);
             $r .= "/* =========== File: " . $path . $file . " ================ */ \n\n\n" . $tcnt . "\n\n\n\n";
         } else {
             if ($type == 'css') {
                 $zview->headLink()->appendStylesheet($file);
             } else {
                 $zview->headScript()->appendFile(Sydney_Tools::getRootUrlCdn() . $file, 'text/javascript');
             }
         }
     }
     // END Foreach
     /**
      * JS
      */
     if ($type == 'js') {
         // adding the UI files
         $t = self::getDirList($path . '/sydneyassets/scripts/ui/');
         foreach ($t as $file) {
             if ($useConcatenation) {
                 $r .= "/* =========== File: " . $path . '/sydneyassets/scripts/ui/' . $file . " ================ */ \n\n\n" . file_get_contents($path . '/sydneyassets/scripts/ui/' . $file) . "\n\n\n\n";
             } else {
                 $zview->headScript()->appendFile(Sydney_Tools::getRootUrlCdn() . '/sydneyassets/scripts/ui/' . $file, 'text/javascript');
             }
         }
         // add the launcher
         $launchFile = '/sydneyassets/scripts/zLauncher.js';
         if ($useConcatenation) {
             $r .= "/* =========== File: " . $path . $launchFile . " ================ */ \n\n\n" . file_get_contents($path . $launchFile) . "\n\n\n\n";
         } else {
             $zview->headScript()->appendFile(Sydney_Tools::getRootUrlCdn() . $launchFile, 'text/javascript');
         }
     }
     return $r;
 }
Пример #14
0
 /**
  *
  */
 protected function loadInstanceViewHelpers()
 {
     $localInstanceHelpersPath = Sydney_Tools_Paths::getLocalPath() . '/library/View/Helper';
     if (file_exists($localInstanceHelpersPath)) {
         $this->view->addHelperPath($localInstanceHelpersPath, 'Publicms_View_Helper');
     }
 }
Пример #15
0
 /**
  *
  * @return void
  */
 public function setUpLayoutProps()
 {
     $this->layout = $this->_helper->layout();
     // setup the layout
     if (isset($this->_config->general->sydneylayout) && $this->_config->general->sydneylayout == 'no' || isset($this->sydneyLayout) && $this->sydneyLayout == 'no') {
         // do not use the sydney layout if it is defined as it in the ini file
     } else {
         $this->layout->setLayoutPath(Sydney_Tools_Paths::getCorePath() . '/webinstances/sydney/layouts');
         $this->layout->setLayout('layoutSydney');
     }
     $this->view->cdnurl = $this->_config->general->cdn;
     $this->layout->cdnurl = $this->_config->general->cdn;
     $this->setupCSS();
     // setup some layout vars
     $this->layout->registry = $this->_registry;
     $this->layout->_config = $this->_config;
     $this->layout->auth = $this->_auth;
     $this->layout->users_id = $this->usersId;
     $this->layout->translate = $this->_registry->get('Zend_Translate');
     $this->view->translate = $this->_registry->get('Zend_Translate');
     $this->layout->avmodules = $this->availableModules;
     // define the current module
     $this->layout->currentModule = $this->_request->getModuleName();
     $this->setupScripts();
     // set up the title
     $this->view->headTitle()->setSeparator(' / ');
 }
Пример #16
0
 /**
  * Logs data to file for debug purpose
  * @param string $message
  * @param string $file
  * @return bool
  */
 protected function _logToFile($message = '', $file = 'Sydney_Medias_Filestypes.log')
 {
     if (!$this->_debug) {
         return false;
     }
     $c = date('Ymd H:i:s') . ';' . $this->filename . ';' . $this->extension . ';"' . $message . '"' . "\n";
     file_put_contents(Sydney_Tools_Paths::getLogPath() . '/' . $file, $c, FILE_APPEND);
     return true;
 }