private function createStaticSpotFile($site, $spot, $tplSpotId) { $staticspotPath = 'cache/templates/' . $site->getId() . '/staticspots/'; $filename = $spot->systemName() . '_' . $tplSpotId . '.php'; if (!is_dir($staticspotPath)) { $fm = new FileMaker(); $fm->makeDirectory($staticspotPath); } $filepath = $staticspotPath . $filename; $fm = new FileMaker(); $fm->makeFile($filepath, $spot->getContent()); $serverpath = 'dynamic/includes'; $uploader = new FTPUploader($site); $uploader->upload($serverpath, $filepath, $filename); return $this->serverSideInclude($serverpath . $filename); }
private function createFolder($path) { $fm = new FileMaker(); $fm->makeDirectory($path); }
public function savetemplate() { global $varChecker; $template = $this->dRep->getTemplate($varChecker->getValue('id'), false); if ($varChecker->getValue('name') != '') { $name = $varChecker->getValue('name'); } else { throw new DataException('nonatemplateme', array('templatename')); } if ($varChecker->getValue('folderId') == 0) { throw new DataException('noResourceFolder', array('resourcefilefields')); } $resourceFolder = $this->dRep->getFolder($varChecker->getValue('folderId')); if ($resourceFolder->getId() == 'new') { throw new DataException('folderNotExist'); } //we have the temporary template created, now we need to make it propper $spots = $template->getSpots(); $postedSpots = $varChecker->getValue('spots'); $count = 0; $newSpots = array(); foreach ($postedSpots as $index => $postedSpot) { $postedSpotArray = explode('-', $postedSpot); if (count($postedSpotArray) != 3) { throw new DataException('errorSaveSpot'); } $tplSpotId = $postedSpotArray[0]; $spotId = $postedSpotArray[1]; $spotName = $postedSpotArray[2]; if ($spotId == 'new' || $spotId == 0) { throw new DataException('allspotsneedtype'); } if (isset($spots[$tplSpotId])) { //this spot exists from before - check if it has changed $spot = $spots[$tplSpotId]; if ($spot->getId() != $spotId) { $configs = $spot->getConfigValues(); $order = $spot->order(); $tplSpotId = $spot->getTplSpotId(); $spot = $this->dRep->getSpot($spotId); $spot->setProperties(array('order' => $order, 'tplSpotId' => $tplSpotId, 'configs' => $configs)); } } else { $spot = $this->dRep->getSpot(array('spotId' => $spotId)); } $spotName = $spot->getConfigvalue('name'); if ($spotName !== false) { $spot->setConfigvalue($spotName, $spotName); } $order = array('order' => $index); $spot->setProperties($order); $newSpots[$tplSpotId] = $spot; $count++; } $vars = array('name' => $name, 'spots' => $newSpots, 'folder' => $resourceFolder); if (!is_object($template->getSite())) { $vars['site'] = $varChecker->getValue('siteId'); } else { if ($template->getSite()->getId() != $varChecker->getValue('siteId')) { $fm = new FileMaker(); if (!is_dir('cache/templates/' . $varChecker->getValue('siteId'))) { $fm->makeDirectory('cache/templates/' . $varChecker->getValue('siteId')); } $oldPath = 'cache/templates/' . $template->getSite()->getId() . '/' . $template->getFilename(); $newPath = 'cache/templates/' . $varChecker->getValue('siteId') . '/' . $template->getFilename(); $fm->moveFile($oldPath, $newPath); $vars['site'] = $varChecker->getValue('siteId'); } } $template->setProperties($vars); $template = $this->dRep->saveTemplate($template); echo json_encode(array('success' => 'tpl_saved', 'id' => $template->getId())); }
public function Unpack() { global $varChecker; $path = $varChecker->getValue('path'); $zipper = new Zipper(); if ($zipper->IsZipFile($path)) { $fmaker = new FileMaker(); $filename = substr($path, strrpos($path, '/') + 1); $folderpath = str_replace($filename, '', $path); $folderpath = $folderpath . 'resources/'; $fmaker->makeDirectory($folderpath, true); $files = $zipper->Decompress($path, $folderpath); $processedFiles = $this->saveFiles($files, $folderpath); $savedFiles = $processedFiles['saved']; $errorfiles = $processedFiles['error']; } else { //create files array with just one file } if (count($savedFiles) > 0) { $result = array('success' => 'resourcesuploaded', 'files' => $savedFiles, 'errorfiles' => $errorfiles, 'folder' => $folderpath, 'rawcount' => count($files)); } else { $result = array('error' => 'resourcesfailed', 'files' => $savedFiles, 'errorfiles' => $errorfiles, 'folder' => $folderpath, 'rawcount' => count($files)); } return $result; }