public function submitFilesAPI()
 {
     $data = file_get_contents("php://input");
     $dataArr = (array) json_decode($data);
     if (empty($dataArr)) {
         ZDebug::my_echo('Error: Json format error!');
         //header('HTTP/1.1 500 Json format error');
         $this->submitFileHelper();
         exit;
     }
     // $dataArr['folderFullName'] cannot be null
     if (!isset($dataArr['folderFullName']) || empty($dataArr['folderFullName'])) {
         ZDebug::my_echo('Error: folderFullName cannot be null!');
         $this->submitFileHelper();
         exit;
     }
     if (!isset($dataArr['files']) || count($dataArr['files']) == 0) {
         ZDebug::my_echo('Error: no file in the submit!');
         $this->submitFileHelper();
         exit;
     }
     // Build folder and sub folders in file root if not exist
     mkdirInFileRoot($dataArr['folderFullName']);
     // Adding files
     foreach ($dataArr['files'] as $fileItem) {
         $myFile['url'] = $fileItem->url;
         $myFile = array_merge($myFile, (array) json_decode($fileItem->fields));
         // Get folder real full name - absolute path
         $folderABSName = FILE_ROOT . DIRECTORY_SEPARATOR . $dataArr['folderFullName'];
         // Download file to folder
         $fileFullName = $this->downloadFile($myFile['url'], $folderABSName);
         if (!$fileFullName) {
             ZDebug::my_echo('Download failed! URL: ' . $myFile['url']);
             continue;
         }
         // Import this file to DB
         import('SyncFiles');
         SyncFiles::importFiles($dataArr['folderFullName']);
         // Update the file info with data in json
         import('dao.File');
         $file = new File();
         $fileToSave = $file->getFile($fileFullName);
         if ($fileToSave) {
             $fileToSave['page_title'] = $myFile['Text'];
             $fileToSave['page_meta'] = $fileItem->fields;
             $file->saveFile($fileToSave);
         } else {
             ZDebug::my_echo('Import to DB failed! ' . $fileFullName);
         }
         // Build thumbnails here?
         //$myThumb = imageCache::cacheImage($fileFullName, 160, 120);
         //if(!$myThumb) ZDebug::my_echo ('error build thumbnail for ' . $fileFullName);
         ZDebug::my_print($myFile, 'Adding file');
     }
     ZDebug::my_echo('Success to add ' . count($dataArr['files']) . ' files to folder: ' . $dataArr['folderFullName']);
     exit;
 }
Example #2
0
 function Template($filename, $error, $f = __FILE__, $l = __LINE__)
 {
     $this->_error = $error;
     $this->_config = array();
     $this->_config['reg'] = false;
     $this->_template = array();
     $this->_template['filename'] = $filename;
     $this->_template['content'] = File::getFile($filename, &$this->_error);
 }
Example #3
0
            if (isset($napt->view) && !empty($napt->view)) {
                $napt->setGlobal('content', $napt->getTemplate($napt->view));
            } else {
                $napt->setGlobal('content', $napt->getTemplate('noModuleDefined'));
            }
        }
    } else {
        if ($napt->isModule($napt->module)) {
            include 'modules/' . $napt->module . '/index.inc.php';
        } else {
            $napt->setGlobal('content', $napt->getTemplate('noModuleDefined', 'napt'));
        }
    }
}
/* Homepage Rahmen einlesen */
$homepage = File::getFile('templates/main.html');
/* Global-Array auslesen und einsetzen,
 * Napt-Spezifische Ausschnitte wegschneiden
 */
$loc_glob = $napt->getGlobal();
foreach ($loc_glob as $key => $global) {
    $homepage = ereg_replace("<!-- global.{$key} -->", $global, $homepage);
}
$homepageTpl = $napt->getSysTemplate('dummy');
$homepageTpl->_template['content'] = $homepage;
$homepageTpl->_template['filename'] = 'templates/main.html';
if ($napt->isLogged) {
    $homepageTpl->cut('LOGIN');
} else {
    $homepageTpl->cut('LOGOUT');
}
Example #4
0
 /**
  * Test simple notify call
  */
 public function testNotify()
 {
     $sText = md5(time());
     $this->assertInstanceOf('\\notifyy\\AbstractAdapter', $this->_object->notify(\notifyy\Notifyable::SUCCESS, $sText));
     $this->assertStringEndsWith($sText . PHP_EOL, file_get_contents($this->_object->getFile()));
 }