当前位置: 首页>>代码示例>>PHP>>正文


PHP ProjectConfiguration::getSubredditAudioFileLocalDirectory方法代码示例

本文整理汇总了PHP中ProjectConfiguration::getSubredditAudioFileLocalDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP ProjectConfiguration::getSubredditAudioFileLocalDirectory方法的具体用法?PHP ProjectConfiguration::getSubredditAudioFileLocalDirectory怎么用?PHP ProjectConfiguration::getSubredditAudioFileLocalDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProjectConfiguration的用法示例。


在下文中一共展示了ProjectConfiguration::getSubredditAudioFileLocalDirectory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: executeBackup

 public function executeBackup(sfWebRequest $request)
 {
     $this->redirectUnless($this->getUser()->isAuthenticated() && $this->getUser()->getApiUserId(), '@sf_guard_signin');
     $auth_key = $this->getUser()->getApiAuthKey();
     $subreddit_data = Api::getInstance()->setUser($auth_key)->get('subreddit/' . $request->getParameter('id'), true);
     $subreddit = ApiDoctrine::createObject('Subreddit', $subreddit_data['body']);
     $quick_subreddit = ApiDoctrine::createQuickObject($subreddit_data['body']);
     $this->forward404Unless($subreddit && $subreddit->getId());
     $this->setLayout(false);
     if ($request->getParameter('which') == 'intro') {
         $file_location = rtrim(ProjectConfiguration::getSubredditAudioFileLocalDirectory(), '/') . '/';
         $filename = $subreddit->getEpisodeIntro();
         if (file_exists($file_location . $filename)) {
             ProjectConfiguration::registerAws();
             $response = $subreddit->saveFileToApplicationBucket($file_location, $filename, 'intro');
             if ($response->isOK()) {
                 unlink($file_location . $filename);
             }
         }
     } elseif ($request->getParameter('which') == 'outro') {
         $file_location = rtrim(ProjectConfiguration::getSubredditAudioFileLocalDirectory(), '/') . '/';
         $filename = $subreddit->getEpisodeOutro();
         if (file_exists($file_location . $filename)) {
             ProjectConfiguration::registerAws();
             $response = $subreddit->saveFileToApplicationBucket($file_location, $filename, 'outro');
             if ($response->isOK()) {
                 unlink($file_location . $filename);
             }
         }
     }
 }
开发者ID:nocoolnametom,项目名称:OpenMicNight,代码行数:31,代码来源:actions.class.php

示例2: executeUpload_subreddit_outro

 public function executeUpload_subreddit_outro(sfWebRequest $request)
 {
     $id = $request->getParameter('id');
     $filename = $request->getParameter('name');
     $this->forward404Unless($id && $filename);
     $valid_episode = $this->validateSubredditForOutroUpload($id, $filename);
     $this->forward404Unless($valid_episode);
     // Settings
     $targetDir = rtrim(ProjectConfiguration::getSubredditAudioFileLocalDirectory(), '/');
     //$targetDir = 'uploads/';
     //$cleanupTargetDir = false; // Remove old files
     //$maxFileAge = 60 * 60; // Temp file age in seconds
     // 5 minutes execution time
     @set_time_limit(5 * 60);
     $fileName = $this->getUser()->getAttribute('valid_subreddit_outro_file_hash', '');
     return $this->handlePlupload($request, $targetDir, $fileName);
 }
开发者ID:nocoolnametom,项目名称:OpenMicNight,代码行数:17,代码来源:actions.class.php

示例3: save

 public function save(Doctrine_Connection $conn = null)
 {
     if (sfConfig::get('sf_environment') != 'test' && ($this->isNew() || in_array('domain', $this->_modified) && $this->_get('domain'))) {
         if (!$this->getBucketName() || strlen($this->getBucketName()) == 0) {
             $bucket_name = $this->createAmazonBucketName(ProjectConfiguration::getAmazonBucketPrefix() . $this->_get('domain'));
             $this->setBucketName($bucket_name);
         }
         if ($this->getBucketName() && (!$this->getCfDistId() || strlen($this->getCfDistId() == 0))) {
             if (!isset($bucket_name) || !$bucket_name) {
                 $bucket_name = $this->getBucketName();
             }
             $results = $this->createAmazonDistribution($bucket_name);
             if ($results !== false) {
                 $this->setCfDistId($results['dist_id']);
                 $this->setCfDomainName($results['domain_name']);
             }
         }
     }
     if (!$this->isNew() && !$this->getSkipBackup() && in_array('episode_intro', $this->_modified) && $this->_get('episode_intro')) {
         $file_location = rtrim(ProjectConfiguration::getSubredditAudioFileLocalDirectory(), '/') . '/';
         $filename = $this->_get('episode_intro');
         if (file_exists($file_location . $filename)) {
             ProjectConfiguration::registerAws();
             $response = $this->saveFileToApplicationBucket($file_location, $filename, 'intro');
             if ($response->isOK()) {
                 unlink($file_location . $filename);
             }
         }
     }
     if (!$this->isNew() && !$this->getSkipBackup() && in_array('episode_outro', $this->_modified) && $this->_get('episode_outro')) {
         $file_location = rtrim(ProjectConfiguration::getSubredditAudioFileLocalDirectory(), '/') . '/';
         $filename = $this->_get('episode_outro');
         if (file_exists($file_location . $filename)) {
             ProjectConfiguration::registerAws();
             $response = $this->saveFileToApplicationBucket($file_location, $filename, 'outro');
             if ($response->isOK()) {
                 unlink($file_location . $filename);
             }
         }
     }
     parent::save($conn);
 }
开发者ID:nocoolnametom,项目名称:OpenMicNight,代码行数:42,代码来源:Subreddit.class.php

示例4: executeUpload_outro

 /**
  * Allows for the upload of a Subreddit intro sound file.
  * @param   sfWebRequest   $request a request object
  * @return  string
  */
 public function executeUpload_outro(sfWebRequest $request)
 {
     // PUT makes more sense, but I am limited currently by my API to POST.
     $this->forward404Unless($request->isMethod(sfRequest::POST));
     $content = $request->getContent();
     // Restores backward compatibility. Content can be the HTTP request full body, or a form encoded "content" var.
     if (strpos($content, 'content=') === 0 || $request->hasParameter('content')) {
         $content = $request->getParameter('content');
     }
     $request->setRequestFormat('html');
     try {
         $parameters = $request->getParameterHolder()->getAll();
         $params = $this->getApiAuthFieldValues($parameters, $content);
         $this->validateUpload($content, $request);
     } catch (Exception $e) {
         $this->getResponse()->setStatusCode($e->getCode() ? $e->getCode() : 406);
         $serializer = $this->getSerializer();
         $this->getResponse()->setContentType($serializer->getContentType());
         $error = $e->getMessage();
         // event filter to enable customisation of the error message.
         $result = $this->dispatcher->filter(new sfEvent($this, 'sfDoctrineRestGenerator.filter_error_output'), $error)->getReturnValue();
         if ($error === $result) {
             $error = array(array('message' => $error));
             $this->output = $serializer->serialize($error, 'error');
         } else {
             $this->output = $serializer->serialize($result);
         }
         $this->setTemplate('index');
         return sfView::SUCCESS;
     }
     // We move the file from its temporary location to the Episode in question.
     if ($this->_nice_filename && $this->_temporary_file_location) {
         $targetDir = rtrim(ProjectConfiguration::getSubredditAudioFileLocalDirectory(), '/');
         $pattern = '/\\.([^\\.]+)$/';
         preg_match($pattern, $filename, $matches);
         $extension = array_key_exists(1, $matches) ? $matches[1] : 'mp3';
         // We don't need the upload hash because we're not uploading AJAX-like in real time.
         $hash = sha1(microtime() . $this->object->getIncremented());
         $fileName = $hash . '.' . $extension;
         //Move the file.
         rename($this->_temporary_file_location, $targetDir . '/' . $fileName);
         // update and save it
         $this->object->setEpisodeOutro($fileName);
     }
     return $this->doSave($params);
 }
开发者ID:nocoolnametom,项目名称:OpenMicNight,代码行数:51,代码来源:actions.class.php


注:本文中的ProjectConfiguration::getSubredditAudioFileLocalDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。