Пример #1
0
 private function setFileMaxSize()
 {
     $fileMaxSize = array();
     $fileMaxSize['format'] = opTimelinePluginUtil::getFileSizeMaxOfFormat();
     $fileMaxSize['size'] = opTimelinePluginUtil::getFileSizeMax();
     $this->fileMaxSize = $fileMaxSize;
 }
Пример #2
0
 public function executePost(sfWebRequest $request)
 {
     $errorResponse = $this->getErrorResponseIfBadRequestOfTweetPost($request);
     if (!is_null($errorResponse)) {
         return $this->renderJSONDirect($errorResponse);
     }
     $validator = new opValidatorImageFile(array('required' => false));
     $validator->setOption('max_size', opTimelinePluginUtil::getFileSizeMax());
     try {
         $file = $request->getFiles('timeline-submit-upload');
         if (0 !== count($file)) {
             $validatedFile = $validator->clean($file);
         } else {
             $validatedFile = null;
         }
     } catch (sfValidatorError $e) {
         if ('max_size' === $e->getCode()) {
             $errorResponse = array('status' => 'error', 'message' => 'file size over', 'type' => 'file_size');
         } elseif ('mime_types' === $e->getCode()) {
             $errorResponse = array('status' => 'error', 'message' => 'not image', 'type' => 'not_image');
         } else {
             $errorResponse = array('status' => 'error', 'message' => 'file upload error', 'type' => 'upload');
         }
         return $this->renderJSONDirect($errorResponse);
     }
     $this->createActivityDataByRequest($request);
     if (!is_null($validatedFile)) {
         $this->timeline->createActivityImageByFileInfoAndActivity($validatedFile, $this->createdActivity);
     }
     $responseData = $this->createResponActivityDataOfPost();
     $responseData['body'] = htmlspecialchars($responseData['body'], ENT_QUOTES, 'UTF-8');
     $responseData['body_html'] = $request->getParameter('in_reply_to_activity_id');
     if (is_null($request->getParameter('in_reply_to_activity_id'))) {
         $responseData['body_html'] = op_activity_linkification(nl2br(op_api_force_escape($responseData['body'])));
     } else {
         $responseData['body_html'] = op_activity_linkification(nl2br($responseData['body']));
     }
     if (!is_null($validatedFile)) {
         return $this->renderJSONDirect(array('status' => 'success', 'message' => 'file up success', 'data' => $responseData));
     }
     return $this->renderJSONDirect(array('status' => 'success', 'message' => 'tweet success', 'data' => $responseData));
 }
Пример #3
0
 private function getErrorResponseIfBadRequestOfPost(sfWebRequest $request)
 {
     $errorInfo = $this->getErrorResponseIfBadRequestOfTweetPost($request);
     if (!empty($errorInfo)) {
         return $errorInfo;
     }
     if ($this->isUploadImagePost()) {
         $fileInfo = $this->createFileInfo($request);
         if ($fileInfo['size'] >= opTimelinePluginUtil::getFileSizeMax()) {
             return array('status' => 'error', 'message' => 'file size over', 'type' => 'file_size');
         }
         $stream = fopen($fileInfo['tmp_name'], 'r');
         if (false === $stream) {
             return array('status' => 'error', 'message' => 'file upload error', 'type' => 'upload');
         }
         if (!$this->isImageUploadByFileInfo($fileInfo)) {
             return array('status' => 'error', 'message' => 'not image', 'type' => 'not_image');
         }
     }
     return null;
 }
Пример #4
0
<?php 
if ($isCommunity && $community->isPrivilegeBelong($memberId)) {
    ?>
      ,'target': 'community',
      'target_id': <?php 
    echo $community->getId();
}
?>
    };
var viewPhoto = '<?php 
echo $viewPhoto;
?>
';
var MAXLENGTH = 140;
var fileMaxSize = '<?php 
echo opTimelinePluginUtil::getFileSizeMax();
?>
';
//]]>
</script>
<?php 
use_javascript('/opTimelinePlugin/js/jquery.timeline.js', 'last');
use_javascript('/opTimelinePlugin/js/jquery.timeago.js', 'last');
use_javascript('/opTimelinePlugin/js/timeline-loader.api.js', 'last');
use_javascript('/opTimelinePlugin/js/lightbox.js', 'last');
use_stylesheet('/opTimelinePlugin/css/lightbox.css', 'last');
use_stylesheet('/opTimelinePlugin/css/bootstrap.css', 'last');
use_stylesheet('/opTimelinePlugin/css/timeline.css', 'last');
?>

<?php