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


PHP UTIL_File::validateImage方法代码示例

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


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

示例1: uploadTmpAvatar

 public function uploadTmpAvatar($file)
 {
     if (isset($file)) {
         $lang = OW::getLanguage();
         if (!UTIL_File::validateImage($file['name'])) {
             return array('result' => false, 'error' => $lang->text('base', 'not_valid_image'));
         }
         if (!empty($file['error'])) {
             $message = BOL_FileService::getInstance()->getUploadErrorMessage($file['error']);
         }
         if (!empty($message)) {
             return array('result' => false, 'error' => $message);
         }
         $filesize = OW::getConfig()->getValue('base', 'avatar_max_upload_size');
         if (empty($file['size']) || $filesize * 1024 * 1024 < $file['size']) {
             $message = OW::getLanguage()->text('base', 'upload_file_max_upload_filesize_error');
             return array('result' => false, 'error' => $message);
         }
         $avatarService = BOL_AvatarService::getInstance();
         $key = $avatarService->getAvatarChangeSessionKey();
         $uploaded = $avatarService->uploadUserTempAvatar($key, $file['tmp_name']);
         if (!$uploaded) {
             return array('result' => false, 'error' => $lang->text('base', 'upload_avatar_faild'));
         }
         $url = $avatarService->getTempAvatarUrl($key, 3);
         return array('result' => true, 'url' => $url);
     }
     return array('result' => false);
 }
开发者ID:ZyXelP,项目名称:oxwall,代码行数:29,代码来源:upload_tmp_avatar_trait.php

示例2: validateFile

 private function validateFile($file)
 {
     $language = OW::getLanguage();
     if (!UTIL_File::validateImage($file['name'])) {
         $error = $language->text('gheader', 'upload_file_extension_is_not_allowed');
         throw new InvalidArgumentException($error);
     }
     if ((int) $file['size'] > (double) OW::getConfig()->getValue('base', 'tf_max_pic_size') * 1024 * 1024) {
         $error = $language->text('base', 'upload_file_max_upload_filesize_error');
         throw new InvalidArgumentException($error);
     }
 }
开发者ID:vazahat,项目名称:dudex,代码行数:12,代码来源:header.php

示例3: createAvatar

 protected function createAvatar($userId)
 {
     $avatarService = BOL_AvatarService::getInstance();
     $path = $_FILES['userPhoto']['tmp_name'];
     if (!file_exists($path)) {
         return false;
     }
     if (!UTIL_File::validateImage($_FILES['userPhoto']['name'])) {
         return false;
     }
     $event = new OW_Event('base.before_avatar_change', array('userId' => $userId, 'avatarId' => null, 'upload' => true, 'crop' => false, 'isModerable' => false));
     OW::getEventManager()->trigger($event);
     $avatarSet = $avatarService->setUserAvatar($userId, $path, array('isModerable' => false, 'trackAction' => false));
     if ($avatarSet) {
         $avatar = $avatarService->findByUserId($userId);
         if ($avatar) {
             $event = new OW_Event('base.after_avatar_change', array('userId' => $userId, 'avatarId' => $avatar->id, 'upload' => true, 'crop' => false));
             OW::getEventManager()->trigger($event);
         }
     }
     return $avatarSet;
 }
开发者ID:hardikamutech,项目名称:loov,代码行数:22,代码来源:join.php

示例4: imageUploader

 public function imageUploader($file, $query)
 {
     $error = false;
     $language = OW::getLanguage();
     if (!UTIL_File::validateImage($file['name'])) {
         $error = $language->text('base', 'upload_file_extension_is_not_allowed');
     }
     if ((int) $file['size'] > (double) OW::getConfig()->getValue('base', 'tf_max_pic_size') * 1024 * 1024) {
         $error = $language->text('base', 'upload_file_max_upload_filesize_error');
     }
     if ($error) {
         return array('type' => 'uploadError', 'error' => $error, 'result' => $file);
     }
     $service = BOL_AttachmentService::getInstance();
     $attachDto = new BOL_Attachment();
     $attachDto->setUserId(OW::getUser()->getId());
     $attachDto->setAddStamp(time());
     $attachDto->setStatus(0);
     $service->saveAttachment($attachDto);
     $fileName = 'attach_' . $attachDto->getId() . '.' . UTIL_File::getExtension($file['name']);
     $attachDto->setFileName($fileName);
     $service->saveAttachment($attachDto);
     $uploadPath = $service->getAttachmentsTempDir() . $fileName;
     $uploadUrl = $service->getAttachmentsTempUrl() . $fileName;
     if (!move_uploaded_file($file['tmp_name'], $uploadPath)) {
         return array('type' => 'uploadError', 'error' => $language->text('base', 'upload_file_fail'), 'result' => $file);
     }
     @chmod($uploadPath, 0666);
     $markup = array('html' => '<img src="' . $uploadUrl . '" />', 'js' => '', 'css' => '');
     $content = new EQUESTIONS_CMP_AttPhotoPreview($uploadUrl);
     $result = array();
     $result['content'] = array('html' => $content->render(), 'js' => '', 'css' => '');
     $result['oembed'] = array("type" => "file", 'filePath' => $uploadPath, "fileId" => $attachDto->getId());
     $response = array('content' => $markup, 'type' => 'imageUploader', 'result' => $result);
     return $response;
 }
开发者ID:vazahat,项目名称:dudex,代码行数:36,代码来源:attachments.php

示例5: user

 public function user()
 {
     if (!OW::getRequest()->isAjax()) {
         OW::getNavigation()->activateMenuItem(OW_Navigation::ADMIN_SETTINGS, 'admin', 'sidebar_menu_item_user_settings');
     }
     $language = OW::getLanguage();
     $avatarService = BOL_AvatarService::getInstance();
     if (isset($_GET['del-avatar']) && in_array($_GET['del-avatar'], array(1, 2))) {
         $del = $avatarService->deleteCustomDefaultAvatar((int) $_GET['del-avatar']);
         if ($del) {
             OW::getFeedback()->info($language->text('admin', 'default_avatar_deleted'));
         }
         $this->redirect(OW::getRouter()->urlForRoute('admin_settings_user'));
     }
     $uploadMaxFilesize = (double) ini_get("upload_max_filesize");
     $postMaxSize = (double) ini_get("post_max_size");
     $maxUploadMaxFilesize = BOL_FileService::getInstance()->getUploadMaxFilesize();
     $this->assign('maxUploadMaxFilesize', $maxUploadMaxFilesize);
     $userSettingsForm = new UserSettingsForm($maxUploadMaxFilesize);
     $this->addForm($userSettingsForm);
     $conf = OW::getConfig();
     $avatarSize = $conf->getValue('base', 'avatar_size');
     $bigAvatarSize = $conf->getValue('base', 'avatar_big_size');
     $avatarUploadSize = $conf->getValue('base', 'avatar_max_upload_size');
     $userSettingsForm->getElement('avatar_max_upload_size')->setValue((double) $avatarUploadSize);
     $userSettingsForm->getElement('avatarSize')->setValue($avatarSize);
     $userSettingsForm->getElement('bigAvatarSize')->setValue($bigAvatarSize);
     $userSettingsForm->getElement('displayName')->setValue($conf->getValue('base', 'display_name_question'));
     // privacy
     $userSettingsForm->getElement('who_can_join')->setValue($conf->getValue('base', 'who_can_join'));
     $userSettingsForm->getElement('who_can_invite')->setValue($conf->getValue('base', 'who_can_invite'));
     $userSettingsForm->getElement('guests_can_view')->setValue($conf->getValue('base', 'guests_can_view'));
     $userSettingsForm->getElement('user_approve')->setValue($conf->getValue('base', 'mandatory_user_approve'));
     // profile questions
     $userSettingsForm->getElement('user_view_presentation')->setValue(OW::getConfig()->getValue('base', 'user_view_presentation') == 'tabs');
     $this->assign('displayConfirmEmail', !defined('OW_PLUGIN_XP'));
     if (OW::getRequest()->isPost() && $userSettingsForm->isValid($_POST)) {
         if (!empty($_FILES['avatar']['tmp_name']) && !UTIL_File::validateImage($_FILES['avatar']['name']) || !empty($_FILES['bigAvatar']['tmp_name']) && !UTIL_File::validateImage($_FILES['bigAvatar']['name'])) {
             OW::getFeedback()->error($language->text('base', 'not_valid_image'));
             $this->redirect();
         }
         $values = $userSettingsForm->getValues();
         $guestPassword = OW_Config::getInstance()->getValue('base', 'guests_can_view_password');
         if ((int) $values['guests_can_view'] === 3 && empty($values['password']) && is_null($guestPassword)) {
             OW::getFeedback()->error($language->text('admin', 'permission_global_privacy_empty_pass_error_message'));
             $this->redirect();
         } else {
             if ((int) $values['guests_can_view'] === 3 && strlen(trim($values['password'])) < 4 && strlen(trim($values['password'])) > 0) {
                 OW::getFeedback()->error($language->text('admin', 'permission_global_privacy_pass_length_error_message'));
                 $this->redirect();
             }
         }
         $res = $userSettingsForm->process();
         OW::getFeedback()->info($language->text('admin', 'user_settings_updated'));
         $this->redirect();
     }
     $avatar = $avatarService->getDefaultAvatarUrl(1);
     $avatarBig = $avatarService->getDefaultAvatarUrl(2);
     $this->assign('avatar', $avatar);
     $this->assign('avatarBig', $avatarBig);
     $custom = json_decode($conf->getValue('base', 'default_avatar'), true);
     $this->assign('customAvatar', $custom);
     $language->addKeyForJs('admin', 'confirm_avatar_delete');
     if (!OW::getRequest()->isAjax()) {
         OW::getDocument()->setHeading(OW::getLanguage()->text('admin', 'heading_user_settings'));
         OW::getDocument()->setHeadingIconClass('ow_ic_gear_wheel');
     }
     OW::getNavigation()->deactivateMenuItems(OW_Navigation::ADMIN_SETTINGS);
 }
开发者ID:ZyXelP,项目名称:oxwall,代码行数:69,代码来源:settings.php

示例6: uploadPhoto

function uploadPhoto()
{
    global $language;
    global $PHOTO_BOL_PhotoService_inst;
    global $PHOTO_BOL_PhotoAlbumService;
    global $PHOTO_BOL_PhotoTemporaryService;
    global $BOL_AuthorizationService;
    global $getConfig;
    $app = \Slim\Slim::getInstance();
    $app->response->headers->set('Content-Type', 'application/json');
    $app->response->setStatus(200);
    $user_id = $app->request()->params('user_id');
    //$data = $_POST;
    //$requdired_data = array("userId");
    //    foreach ($required_data as $rdata) {
    //        if (!array_key_exists($rdata, $data) || empty($data[$rdata])) {
    //            $return = array("message" => "Please enter " . $rdata, "status" => "false");
    //            echo json_encode($return);
    //            exit();
    //        }
    //    }
    $language = $language;
    $userId = $user_id;
    $albumName = "randoms";
    // Delete old temporary photos
    $tmpPhotoService = $PHOTO_BOL_PhotoTemporaryService;
    $photoService = $PHOTO_BOL_PhotoService_inst;
    $photoAlbumService = $PHOTO_BOL_PhotoAlbumService;
    $file = $_FILES['photo'];
    print_r($file);
    die;
    $tmpPhotoService->deleteUserTemporaryPhotos($userId);
    $accepted = floatval($getConfig->getValue('photo', 'accepted_filesize') * 1024 * 1024);
    if (strlen($file['tmp_name'])) {
        if (!UTIL_File::validateImage($file['name']) || $file['size'] > $accepted) {
            $json = array("response_message" => $language->text('photo', 'no_photo_uploaded'), "response_status" => "0");
            $app->response->setBody(json_encode($json));
            //$this->redirect();
        }
        $tmpPhotoService->addTemporaryPhoto($file['tmp_name'], $userId, 1);
        $tmpList = $tmpPhotoService->findUserTemporaryPhotos($userId, 'order');
        $tmpList = array_reverse($tmpList);
        // check album exists
        if (!($album = $photoAlbumService->findAlbumByName($albumName, $userId))) {
            $album = new PHOTO_BOL_PhotoAlbum();
            $album->name = $albumName;
            $album->userId = $userId;
            $album->createDatetime = time();
            $photoAlbumService->addAlbum($album);
        }
        foreach ($tmpList as $tmpPhoto) {
            $photo = $tmpPhotoService->moveTemporaryPhoto($tmpPhoto['dto']->id, $album->id, null);
            if ($photo) {
                $BOL_AuthorizationService->trackAction('photo', 'upload');
                $photoService->createAlbumCover($album->id, array($photo));
                $photoService->triggerNewsfeedEventOnSinglePhotoAdd($album, $photo);
                $photoParams = array('addTimestamp' => $photo->addDatetime, 'photoId' => $photo->id, 'hash' => $photo->hash, 'description' => $photo->description);
                $event = new OW_Event(PHOTO_CLASS_EventHandler::EVENT_ON_PHOTO_ADD, array($photoParams));
                OW::getEventManager()->trigger($event);
                $photo = $photoService->findPhotoById($photo->id);
                if ($photo) {
                    $return_data = array("response_status" => "1", "response_message" => "photo has been uploaded with success!");
                    $app->response->setBody(json_encode($return_data));
                } else {
                    //                    $json = array("message" => "photo not uploaded, something went wrong!", "status" => "false");
                    //                    echo json_encode($json);
                    //                    exit();
                    $return_data = array("response_status" => "0", "response_message" => "photo not uploaded, something went wrong!");
                    $app->response->setBody(json_encode($return_data));
                }
            }
        }
    } else {
        //        $json = array("message" => $language->text('photo', 'no_photo_uploaded'), "status" => "false");
        //        echo json_encode($json);
        //        exit();
        $return_data = array("response_message" => $language->text('photo', 'no_photo_uploaded'), "response_status" => "0");
        $app->response->setBody(json_encode($return_data));
    }
    //  }
}
开发者ID:bhushansonar,项目名称:hammu,代码行数:81,代码来源:index____.php

示例7: createAvatar

 public function createAvatar($userId, $isModerable = true, $trackAction = true)
 {
     $key = $this->getAvatarChangeSessionKey();
     $path = $this->getTempAvatarPath($key, 2);
     if (!file_exists($path)) {
         return false;
     }
     if (!UTIL_File::validateImage($path)) {
         return false;
     }
     $event = new OW_Event('base.before_avatar_change', array('userId' => $userId, 'avatarId' => null, 'upload' => true, 'crop' => false, 'isModerable' => $isModerable));
     OW::getEventManager()->trigger($event);
     $avatarSet = $this->setUserAvatar($userId, $path, array('isModerable' => $isModerable, 'trackAction' => $trackAction));
     if ($avatarSet) {
         $avatar = $this->findByUserId($userId);
         if ($avatar) {
             $event = new OW_Event('base.after_avatar_change', array('userId' => $userId, 'avatarId' => $avatar->id, 'upload' => true, 'crop' => false));
             OW::getEventManager()->trigger($event);
         }
         $this->deleteUserTempAvatar($key);
     }
     return $avatarSet;
 }
开发者ID:hardikamutech,项目名称:loov,代码行数:23,代码来源:avatar_service.php

示例8: isValid

 /**
  * @see OW_Validator::isValid()
  *
  * @param mixed $value
  */
 public function isValid($value)
 {
     if (empty($value)) {
         return true;
     }
     $realName = $value['name'];
     $tmpName = $value['tmp_name'];
     switch (false) {
         case is_uploaded_file($tmpName):
             $this->setErrorMessage(OW::getLanguage()->text('groups', 'errors_image_upload'));
             return false;
         case UTIL_File::validateImage($realName):
             $this->setErrorMessage(OW::getLanguage()->text('groups', 'errors_image_invalid'));
             return false;
     }
     return true;
 }
开发者ID:vazahat,项目名称:dudex,代码行数:22,代码来源:groups.php

示例9: addFile

 /**
  * Add file
  * 
  * @param string $plugin
  * @return integer|string
  */
 public static function addFile($plugin)
 {
     $uploaddir = OW::getPluginManager()->getPlugin('base')->getUserFilesDir();
     $name = $_FILES['file']['name'];
     if (!UTIL_File::validateImage($name)) {
         return OW::getLanguage()->text('base', 'invalid_file_type_acceptable_file_types_jpg_png_gif');
     }
     $tmpname = $_FILES['file']['tmp_name'];
     if ((int) $_FILES['file']['size'] > (double) OW::getConfig()->getValue('base', 'tf_max_pic_size') * 1024 * 1024) {
         return OW::getLanguage()->text('base', 'upload_file_max_upload_filesize_error');
     }
     $image = new UTIL_Image($tmpname);
     $height = $image->getHeight();
     $width = $image->getWidth();
     $id = BOL_MediaPanelService::getInstance()->add($plugin, 'image', OW::getUser()->getId(), array('name' => $name, 'height' => $height, 'width' => $width));
     OW::getStorage()->copyFile($tmpname, $uploaddir . $id . '-' . $name);
     @unlink($tmpname);
     return $id;
 }
开发者ID:hardikamutech,项目名称:loov,代码行数:25,代码来源:media_panel.php

示例10: uploadPhoto

function uploadPhoto()
{
    global $language;
    global $PHOTO_BOL_PhotoTemporaryService;
    global $PHOTO_BOL_PhotoService_inst;
    global $PHOTO_BOL_PhotoAlbumService;
    global $getConfig;
    global $BOL_AuthorizationService;
    $app = \Slim\Slim::getInstance();
    $app->response->headers->set('Content-Type', 'application/json');
    $app->response->setStatus(200);
    //Lang Call Start
    $hammu_lang_id = $app->request()->params("lang_id");
    if (!empty($hammu_lang_id)) {
        getCurrentLanguages($hammu_lang_id);
    }
    //Lang Call end
    $user_id = $app->request()->params('user_id');
    $language = $language;
    $userId = $user_id;
    $albumName = "randoms";
    // Delete old temporary photos
    $tmpPhotoService = $PHOTO_BOL_PhotoTemporaryService;
    $photoService = $PHOTO_BOL_PhotoService_inst;
    $photoAlbumService = $PHOTO_BOL_PhotoAlbumService;
    $file = $_FILES['photo'];
    $tmpPhotoService->deleteUserTemporaryPhotos($userId);
    $accepted = floatval($getConfig->getValue('photo', 'accepted_filesize') * 1024 * 1024);
    if (strlen($file['tmp_name'])) {
        if (!UTIL_File::validateImage($file['name']) || $file['size'] > $accepted) {
            $json = array("response_message" => $language->text('photo', 'no_photo_uploaded'), "response_status" => "0");
            $app->response->setBody(json_encode($json));
            //$this->redirect();
        }
        $tmpPhotoService->addTemporaryPhoto($file['tmp_name'], $userId, 1);
        $tmpList = $tmpPhotoService->findUserTemporaryPhotos($userId, 'order');
        $tmpList = array_reverse($tmpList);
        // check album exists
        if (!($album = $photoAlbumService->findAlbumByName($albumName, $userId))) {
            $album = new PHOTO_BOL_PhotoAlbum();
            $album->name = $albumName;
            $album->userId = $userId;
            $album->createDatetime = time();
            $photoAlbumService->addAlbum($album);
        }
        foreach ($tmpList as $tmpPhoto) {
            $photo = $tmpPhotoService->moveTemporaryPhoto($tmpPhoto['dto']->id, $album->id, null);
            if ($photo) {
                $BOL_AuthorizationService->trackAction('photo', 'upload');
                $photoService->createAlbumCover($album->id, array($photo));
                $photoService->triggerNewsfeedEventOnSinglePhotoAdd($album, $photo);
                $photoParams = array('addTimestamp' => $photo->addDatetime, 'photoId' => $photo->id, 'hash' => $photo->hash, 'description' => $photo->description);
                $event = new OW_Event(PHOTO_CLASS_EventHandler::EVENT_ON_PHOTO_ADD, array($photoParams));
                OW::getEventManager()->trigger($event);
                $photo = $photoService->findPhotoById($photo->id);
                $photoDataArr = array('albumId' => $photo->albumId, 'status' => $photo->status, 'hash' => $photo->hash, 'id' => $photo->id, 'uploadKey' => $photo->uploadKey);
                if ($photo) {
                    $message = $language->text("hammu", "photo_upload_success");
                    //"photo has been uploaded successfully!"
                    $return_data = array("response_status" => "1", "response_message" => $message, "data" => $photoDataArr);
                    $app->response->setBody(json_encode($return_data));
                } else {
                    $message = $language->text("hammu", "photo_upload_fail");
                    //"photo not uploaded, something went wrong!"
                    $return_data = array("response_status" => "0", "response_message" => $message);
                    $app->response->setBody(json_encode($return_data));
                }
            }
        }
    } else {
        $return_data = array("response_message" => $language->text('photo', 'no_photo_uploaded'), "response_status" => "0");
        $app->response->setBody(json_encode($return_data));
    }
    //  }
}
开发者ID:bhushansonar,项目名称:hammu,代码行数:75,代码来源:index_4_7_2015.php

示例11: process

 /**
  * Uploads avatar
  *
  * @return boolean
  */
 public function process()
 {
     $values = $this->getValues();
     $avatarService = BOL_AvatarService::getInstance();
     $userId = OW::getUser()->getId();
     if (strlen($_FILES['avatar']['tmp_name'])) {
         if (!UTIL_File::validateImage($_FILES['avatar']['name'])) {
             return array('result' => false, 'error' => -1);
         }
         $event = new OW_Event('base.before_avatar_change', array('userId' => $userId, 'upload' => true, 'crop' => false));
         OW::getEventManager()->trigger($event);
         $avatarSet = $avatarService->setUserAvatar($userId, $_FILES['avatar']['tmp_name']);
         $event = new OW_Event('base.after_avatar_change', array('userId' => $userId, 'upload' => true, 'crop' => false));
         OW::getEventManager()->trigger($event);
         $avatar = $avatarService->findByUserId($userId);
         if ($avatar) {
             $avatarService->trackAvatarChangeActivity($userId, $avatar->id);
         }
         return array('result' => $avatarSet);
     } else {
         return array('result' => false);
     }
 }
开发者ID:vazahat,项目名称:dudex,代码行数:28,代码来源:avatar.php

示例12: getAttachmentType

 public function getAttachmentType(MAILBOX_BOL_Attachment $attachment)
 {
     $type = 'doc';
     if (UTIL_File::validateImage($attachment->fileName)) {
         $type = 'image';
     }
     return $type;
 }
开发者ID:tammyrocks,项目名称:mailbox,代码行数:8,代码来源:conversation_service.php

示例13: edit


//.........这里部分代码省略.........
     $checkboxId = UTIL_HtmlTag::generateAutoId('chk');
     $tdId = UTIL_HtmlTag::generateAutoId('td');
     $this->assign('tdId', $tdId);
     $this->assign('chId', $checkboxId);
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin("eventx")->getStaticJsUrl() . 'eventx.js');
     $enableMapSuggestion = OW::getConfig()->getValue('eventx', 'enableMapSuggestion');
     if ($enableMapSuggestion == '1') {
         OW::getDocument()->addScript("http://maps.googleapis.com/maps/api/js?sensor=false&amp;libraries=places");
         OW::getDocument()->addScript(OW::getPluginManager()->getPlugin("eventx")->getStaticJsUrl() . 'jquery.geocomplete.min.js');
     }
     $this->assign('enableMapSuggestion', $enableMapSuggestion);
     OW::getDocument()->addOnloadScript("new eventAddForm(" . json_encode(array('checkbox_id' => $checkboxId, 'end_date_id' => $form->getElement('end_date')->getId(), 'tdId' => $tdId)) . ")");
     if ($event->getImage()) {
         $this->assign('imgsrc', $this->eventService->generateImageUrl($event->getImage(), true));
     }
     $endDateFlag = $event->getEndDateFlag();
     if (OW::getRequest()->isPost()) {
         $endDateFlag = !empty($_POST['endDateFlag']);
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             $serviceEvent = new OW_Event(EVENTX_BOL_EventService::EVENTX_BEFORE_EVENTX_EDIT, array('eventId' => $event->id), $data);
             OW::getEventManager()->trigger($serviceEvent);
             $data = $serviceEvent->getData();
             $dateArray = explode('/', $data['start_date']);
             $startStamp = mktime(0, 0, 0, $dateArray[1], $dateArray[2], $dateArray[0]);
             if ($data['start_time'] != 'all_day') {
                 $startStamp = mktime($data['start_time']['hour'], $data['start_time']['minute'], 0, $dateArray[1], $dateArray[2], $dateArray[0]);
             }
             if (!empty($_POST['endDateFlag']) && !empty($data['end_date'])) {
                 $dateArray = explode('/', $data['end_date']);
                 $endStamp = mktime(0, 0, 0, $dateArray[1], $dateArray[2], $dateArray[0]);
                 $endStamp = strtotime("+1 day", $endStamp);
                 if ($data['end_time'] != 'all_day') {
                     $hour = 0;
                     $min = 0;
                     if ($data['end_time'] != 'all_day') {
                         $hour = $data['end_time']['hour'];
                         $min = $data['end_time']['minute'];
                     }
                     $dateArray = explode('/', $data['end_date']);
                     $endStamp = mktime($hour, $min, 0, $dateArray[1], $dateArray[2], $dateArray[0]);
                 }
             }
             $event->setStartTimeStamp($startStamp);
             if (empty($endStamp)) {
                 $endStamp = strtotime("+1 day", $startStamp);
                 $endStamp = mktime(0, 0, 0, date('n', $endStamp), date('j', $endStamp), date('Y', $endStamp));
             }
             if ($startStamp > $endStamp) {
                 OW::getFeedback()->error($language->text('eventx', 'add_form_invalid_end_date_error_message'));
                 $this->redirect();
             } else {
                 $event->setEndTimeStamp($endStamp);
                 if (!empty($_FILES['image']['name'])) {
                     if ((int) $_FILES['image']['error'] !== 0 || !is_uploaded_file($_FILES['image']['tmp_name']) || !UTIL_File::validateImage($_FILES['image']['name'])) {
                         OW::getFeedback()->error($language->text('base', 'not_valid_image'));
                         $this->redirect();
                     } else {
                         $event->setImage(uniqid());
                         $this->eventService->saveEventImage($_FILES['image']['tmp_name'], $event->getImage());
                     }
                 }
                 $event->setTitle(htmlspecialchars($data['title']));
                 $event->setLocation(UTIL_HtmlTag::autoLink(strip_tags($data['location'])));
                 $event->setWhoCanView((int) $data['who_can_view']);
                 $event->setWhoCanInvite((int) $data['who_can_invite']);
                 $event->setDescription($data['desc']);
                 $event->setEndDateFlag(!empty($_POST['endDateFlag']));
                 $event->setStartTimeDisable($data['start_time'] == 'all_day');
                 $event->setEndTimeDisable($data['end_time'] == 'all_day');
                 $event->setMaxInvites($data['max_invites']);
                 $this->eventService->saveEvent($event);
                 $eventCategory = isset($data['event_category']) ? $data['event_category'] : 1;
                 $this->eventService->setItemCategories($event->getId(), $eventCategory);
                 if (isset($data['tags'])) {
                     $tags = array();
                     $tags = $data['tags'];
                     foreach ($tags as $id => $tag) {
                         $tags[$id] = UTIL_HtmlTag::stripTags($tag);
                     }
                     BOL_TagService::getInstance()->updateEntityTags($event->id, 'eventx', $tags);
                 }
                 $e = new OW_Event(EVENTX_BOL_EventService::EVENTX_AFTER_EVENTX_EDIT, array('eventId' => $event->id));
                 OW::getEventManager()->trigger($e);
                 OW::getFeedback()->info($language->text('eventx', 'edit_form_success_message'));
                 $this->redirect(OW::getRouter()->urlForRoute('eventx.view', array('eventId' => $event->getId())));
             }
         }
     }
     if (!$endDateFlag) {
         $form->getElement('end_date')->addAttribute('disabled', 'disabled');
         $form->getElement('end_date')->addAttribute('style', 'display:none;');
         $form->getElement('end_time')->addAttribute('disabled', 'disabled');
         $form->getElement('end_time')->addAttribute('style', 'display:none;');
     }
     $this->assign('endDateFlag', $endDateFlag);
     $this->setPageHeading($language->text('eventx', 'edit_page_heading'));
     $this->setPageTitle($language->text('eventx', 'edit_page_title'));
     $this->addForm($form);
 }
开发者ID:vazahat,项目名称:dudex,代码行数:101,代码来源:base.php

示例14: edit

 /**
  * Update event controller
  * 
  * @param array $params 
  */
 public function edit($params)
 {
     $event = $this->getEventForParams($params);
     $language = OW::getLanguage();
     $form = new EventAddForm('event_edit');
     $form->getElement('title')->setValue($event->getTitle());
     $form->getElement('desc')->setValue($event->getDescription());
     $form->getElement('location')->setValue($event->getLocation());
     $form->getElement('who_can_view')->setValue($event->getWhoCanView());
     $form->getElement('who_can_invite')->setValue($event->getWhoCanInvite());
     $form->getElement('who_can_invite')->setValue($event->getWhoCanInvite());
     $startTimeArray = array('hour' => date('G', $event->getStartTimeStamp()), 'minute' => date('i', $event->getStartTimeStamp()));
     $form->getElement('start_time')->setValue($startTimeArray);
     $startDate = date('Y', $event->getStartTimeStamp()) . '/' . date('n', $event->getStartTimeStamp()) . '/' . date('j', $event->getStartTimeStamp());
     $form->getElement('start_date')->setValue($startDate);
     if ($event->getEndTimeStamp() !== null) {
         $endTimeArray = array('hour' => date('G', $event->getEndTimeStamp()), 'minute' => date('i', $event->getEndTimeStamp()));
         $form->getElement('end_time')->setValue($endTimeArray);
         $endTimeStamp = $event->getEndTimeStamp();
         if ($event->getEndTimeDisable()) {
             $endTimeStamp = strtotime("-1 day", $endTimeStamp);
         }
         $endDate = date('Y', $endTimeStamp) . '/' . date('n', $endTimeStamp) . '/' . date('j', $endTimeStamp);
         $form->getElement('end_date')->setValue($endDate);
     }
     if ($event->getStartTimeDisable()) {
         $form->getElement('start_time')->setValue('all_day');
     }
     if ($event->getEndTimeDisable()) {
         $form->getElement('end_time')->setValue('all_day');
     }
     $form->getSubmitElement('submit')->setValue(OW::getLanguage()->text('event', 'edit_form_submit_label'));
     $checkboxId = UTIL_HtmlTag::generateAutoId('chk');
     $tdId = UTIL_HtmlTag::generateAutoId('td');
     $this->assign('tdId', $tdId);
     $this->assign('chId', $checkboxId);
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin("event")->getStaticJsUrl() . 'event.js');
     OW::getDocument()->addOnloadScript("new eventAddForm(" . json_encode(array('checkbox_id' => $checkboxId, 'end_date_id' => $form->getElement('end_date')->getId(), 'tdId' => $tdId)) . ")");
     if ($event->getImage()) {
         $this->assign('imgsrc', $this->eventService->generateImageUrl($event->getImage(), true));
     }
     $endDateFlag = $event->getEndDateFlag();
     if (OW::getRequest()->isPost()) {
         $endDateFlag = !empty($_POST['endDateFlag']);
         //$this->assign('endDateFlag', !empty($_POST['endDateFlag']));
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             $serviceEvent = new OW_Event(EVENT_BOL_EventService::EVENT_BEFORE_EVENT_EDIT, array('eventId' => $event->id), $data);
             OW::getEventManager()->trigger($serviceEvent);
             $data = $serviceEvent->getData();
             $dateArray = explode('/', $data['start_date']);
             $startStamp = mktime(0, 0, 0, $dateArray[1], $dateArray[2], $dateArray[0]);
             if ($data['start_time'] != 'all_day') {
                 $startStamp = mktime($data['start_time']['hour'], $data['start_time']['minute'], 0, $dateArray[1], $dateArray[2], $dateArray[0]);
             }
             if (!empty($_POST['endDateFlag']) && !empty($data['end_date'])) {
                 $dateArray = explode('/', $data['end_date']);
                 $endStamp = mktime(0, 0, 0, $dateArray[1], $dateArray[2], $dateArray[0]);
                 $endStamp = strtotime("+1 day", $endStamp);
                 if ($data['end_time'] != 'all_day') {
                     $hour = 0;
                     $min = 0;
                     if ($data['end_time'] != 'all_day') {
                         $hour = $data['end_time']['hour'];
                         $min = $data['end_time']['minute'];
                     }
                     $dateArray = explode('/', $data['end_date']);
                     $endStamp = mktime($hour, $min, 0, $dateArray[1], $dateArray[2], $dateArray[0]);
                 }
             }
             $event->setStartTimeStamp($startStamp);
             if (empty($endStamp)) {
                 $endStamp = strtotime("+1 day", $startStamp);
                 $endStamp = mktime(0, 0, 0, date('n', $endStamp), date('j', $endStamp), date('Y', $endStamp));
             }
             if ($startStamp > $endStamp) {
                 OW::getFeedback()->error($language->text('event', 'add_form_invalid_end_date_error_message'));
                 $this->redirect();
             } else {
                 $event->setEndTimeStamp($endStamp);
                 if (!empty($_FILES['image']['name'])) {
                     if ((int) $_FILES['image']['error'] !== 0 || !is_uploaded_file($_FILES['image']['tmp_name']) || !UTIL_File::validateImage($_FILES['image']['name'])) {
                         OW::getFeedback()->error($language->text('base', 'not_valid_image'));
                         $this->redirect();
                     } else {
                         $event->setImage(uniqid());
                         $this->eventService->saveEventImage($_FILES['image']['tmp_name'], $event->getImage());
                     }
                 }
                 $event->setTitle(htmlspecialchars($data['title']));
                 $event->setLocation(UTIL_HtmlTag::autoLink(strip_tags($data['location'])));
                 $event->setWhoCanView((int) $data['who_can_view']);
                 $event->setWhoCanInvite((int) $data['who_can_invite']);
                 $event->setDescription($data['desc']);
                 $event->setEndDateFlag(!empty($_POST['endDateFlag']));
//.........这里部分代码省略.........
开发者ID:jorgemunoz8807,项目名称:havanabook,代码行数:101,代码来源:base.php

示例15: process

 public static function process($plugin, $params)
 {
     $language = OW::getLanguage();
     $uploaddir = OW::getPluginManager()->getPlugin('base')->getUserFilesDir();
     $name = $_FILES['file']['name'];
     if (!UTIL_File::validateImage($name)) {
         OW::getFeedback()->error("Invalid file type. Acceptable file types: JPG/PNG/GIF");
         OW::getApplication()->redirect();
     }
     $tmpname = $_FILES['file']['tmp_name'];
     if ((int) $_FILES['file']['size'] > (double) OW::getConfig()->getValue('base', 'tf_max_pic_size') * 1024 * 1024) {
         OW::getFeedback()->error($language->text('base', 'upload_file_max_upload_filesize_error'));
         OW::getApplication()->redirect();
     }
     $image = new UTIL_Image($tmpname);
     $height = $image->getHeight();
     $width = $image->getWidth();
     $id = BOL_MediaPanelService::getInstance()->add($plugin, 'image', OW::getUser()->getId(), array('name' => $name, 'height' => $height, 'width' => $width));
     $uploadFilePath = $uploaddir . $id . '-' . $name;
     $tmpUploadFilePath = $uploaddir . 'tmp_' . $id . '-' . $name;
     $image->saveImage($tmpUploadFilePath);
     $storage = OW::getStorage();
     $storage->copyFile($tmpUploadFilePath, $uploadFilePath);
     @unlink($tmpUploadFilePath);
     $params['pid'] = $id;
     OW::getApplication()->redirect(OW::getRouter()->urlFor('BASE_CTRL_MediaPanel', 'gallery', $params) . '#bottom');
 }
开发者ID:vazahat,项目名称:dudex,代码行数:27,代码来源:media_panel.php


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