public function datatablesTranslationTableAction()
 {
     $this->view->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     header("Content-type: text/javascript");
     $baseUrl = Application_Common_OsPath::getBaseDir();
     $locale = Application_Model_Preference::GetLocale();
     echo "var datatables_dict =" . file_get_contents(Application_Common_OsPath::join($_SERVER["DOCUMENT_ROOT"], $baseUrl, "js/datatables/i18n/", $locale . ".txt"));
 }
示例#2
0
 public static function copyFileToStor($p_targetDir, $fileName, $tempname)
 {
     $audio_file = $p_targetDir . DIRECTORY_SEPARATOR . $tempname;
     Logging::info('copyFileToStor: moving file ' . $audio_file);
     $storDir = Application_Model_MusicDir::getStorDir();
     $stor = $storDir->getDirectory();
     // check if "organize" dir exists and if not create one
     if (!file_exists($stor . "/organize")) {
         if (!mkdir($stor . "/organize", 0777)) {
             return array("code" => 109, "message" => "Failed to create 'organize' directory.");
         }
     }
     if (chmod($audio_file, 0644) === false) {
         Logging::info("Warning: couldn't change permissions of {$audio_file} to 0644");
     }
     // Check if we have enough space before copying
     if (!self::isEnoughDiskSpaceToCopy($stor, $audio_file)) {
         $freeSpace = disk_free_space($stor);
         return array("code" => 107, "message" => "The file was not uploaded, there is\n                " . $freeSpace . "MB of disk space left and the file you are\n                uploading has a size of  " . $fileSize . "MB.");
     }
     // Check if liquidsoap can play this file
     if (!self::liquidsoapFilePlayabilityTest($audio_file)) {
         return array("code" => 110, "message" => "This file appears to be corrupted and will not\n                be added to media library.");
     }
     // Did all the checks for real, now trying to copy
     $audio_stor = Application_Common_OsPath::join($stor, "organize", $fileName);
     $user = Application_Model_User::getCurrentUser();
     if (is_null($user)) {
         $uid = Application_Model_User::getFirstAdminId();
     } else {
         $uid = $user->getId();
     }
     $id_file = "{$audio_stor}.identifier";
     if (file_put_contents($id_file, $uid) === false) {
         Logging::info("Could not write file to identify user: '******'");
         Logging::info("Id file path: '{$id_file}'");
         Logging::info("Defaulting to admin (no identification file was\n                written)");
     } else {
         Logging::info("Successfully written identification file for\n                uploaded '{$audio_stor}'");
     }
     Logging::info("copyFileToStor: moving file {$audio_file} to {$audio_stor}");
     // Martin K.: changed to rename: Much less load + quicker since this is
     // an atomic operation
     if (@rename($audio_file, $audio_stor) === false) {
         //something went wrong likely there wasn't enough space in .
         //the audio_stor to move the file too warn the user that   .
         //the file wasn't uploaded and they should check if there  .
         //is enough disk space                                     .
         unlink($audio_file);
         //remove the file after failed rename
         unlink($id_file);
         // Also remove the identifier file
         return array("code" => 108, "message" => "\n                The file was not uploaded, this error can occur if the computer\n                hard drive does not have enough disk space or the stor\n                directory does not have correct write permissions.");
     }
     // Now that we successfully added this file, we will add another tag
     // file that will identify the user that owns it
     return null;
 }
示例#3
0
 public function getFileMetadataAction()
 {
     $id = $this->_getParam('id');
     $type = $this->_getParam('type');
     try {
         if ($type == "audioclip") {
             $file = Application_Model_StoredFile::Recall($id);
             $this->view->type = $type;
             $md = $file->getMetadata();
             foreach ($md as $key => $value) {
                 if ($key == 'MDATA_KEY_DIRECTORY') {
                     $musicDir = Application_Model_MusicDir::getDirByPK($value);
                     $md['MDATA_KEY_FILEPATH'] = Application_Common_OsPath::join($musicDir->getDirectory(), $md['MDATA_KEY_FILEPATH']);
                 }
             }
             $formatter = new SamplerateFormatter($md["MDATA_KEY_SAMPLERATE"]);
             $md["MDATA_KEY_SAMPLERATE"] = $formatter->format();
             $formatter = new BitrateFormatter($md["MDATA_KEY_BITRATE"]);
             $md["MDATA_KEY_BITRATE"] = $formatter->format();
             $formatter = new LengthFormatter($md["MDATA_KEY_DURATION"]);
             $md["MDATA_KEY_DURATION"] = $formatter->format();
             $this->view->md = $md;
         } elseif ($type == "playlist") {
             $file = new Application_Model_Playlist($id);
             $this->view->type = $type;
             $md = $file->getAllPLMetaData();
             $formatter = new LengthFormatter($md["dcterms:extent"]);
             $md["dcterms:extent"] = $formatter->format();
             $this->view->md = $md;
             $this->view->contents = $file->getContents();
         } elseif ($type == "block") {
             $block = new Application_Model_Block($id);
             $this->view->type = $type;
             $md = $block->getAllPLMetaData();
             $formatter = new LengthFormatter($md["dcterms:extent"]);
             $md["dcterms:extent"] = $formatter->format();
             $this->view->md = $md;
             if ($block->isStatic()) {
                 $this->view->blType = 'Static';
                 $this->view->contents = $block->getContents();
             } else {
                 $this->view->blType = 'Dynamic';
                 $this->view->contents = $block->getCriteria();
             }
             $this->view->block = $block;
         } elseif ($type == "stream") {
             $webstream = CcWebstreamQuery::create()->findPK($id);
             $ws = new Application_Model_Webstream($webstream);
             $md = $ws->getMetadata();
             $this->view->md = $md;
             $this->view->type = $type;
         }
     } catch (Exception $e) {
         Logging::info($e->getMessage());
     }
 }