Exemplo n.º 1
0
 public function defaultImage()
 {
     $this->contentMenu->getElement('socialsharing_default_image')->setActive(true);
     $settings = new Form('default_image');
     $settings->setEnctype("multipart/form-data");
     $file = new FileField('image');
     $validator = new SocialSharingImageValidator(true);
     $file->addValidator($validator);
     $settings->addElement($file);
     $submit = new Submit('upload');
     $submit->setValue(OW::getLanguage()->text('socialsharing', 'upload'));
     $settings->addElement($submit);
     //printVar($config->getValue('socialsharing', 'facebook'));
     if (OW::getRequest()->isPost()) {
         if ($settings->isValid($_POST)) {
             SOCIALSHARING_BOL_Service::getInstance()->uploadImage($_FILES['image']['tmp_name']);
             OW::getFeedback()->info(OW::getLanguage()->text('socialsharing', 'upload_complite'));
             //Setting succsessfully saved
         } else {
             $message = OW::getLanguage()->text('base', 'upload_file_fail');
             switch ($_FILES['image']['error']) {
                 case UPLOAD_ERR_INI_SIZE:
                     $message = $language->text('base', 'upload_file_max_upload_filesize_error');
                     break;
                 case UPLOAD_ERR_PARTIAL:
                     $message = $language->text('base', 'upload_file_file_partially_uploaded_error');
                     break;
                 case UPLOAD_ERR_NO_FILE:
                     $message = $language->text('base', 'upload_file_no_file_error');
                     break;
                 case UPLOAD_ERR_NO_TMP_DIR:
                     $message = $language->text('base', 'upload_file_no_tmp_dir_error');
                     break;
                 case UPLOAD_ERR_CANT_WRITE:
                     $message = $language->text('base', 'upload_file_cant_write_file_error');
                     break;
                 case UPLOAD_ERR_EXTENSION:
                     $message = $language->text('base', 'upload_file_invalid_extention_error');
                     break;
             }
             OW::getFeedback()->error($message);
         }
         $this->redirect();
     }
     $this->addForm($settings);
     $this->assign('imageUrl', SOCIALSHARING_BOL_Service::getInstance()->getDefaultImageUrl());
 }
Exemplo n.º 2
0
 private function addLastStepQuestions($controller)
 {
     $displayPhoto = false;
     $displayPhotoUpload = OW::getConfig()->getValue('base', 'join_display_photo_upload');
     $photoValidator = new photoValidator(false);
     switch ($displayPhotoUpload) {
         case BOL_UserService::CONFIG_JOIN_DISPLAY_AND_SET_REQUIRED_PHOTO_UPLOAD:
             $photoValidator = new photoValidator(true);
         case BOL_UserService::CONFIG_JOIN_DISPLAY_PHOTO_UPLOAD:
             $userPhoto = new FileField('userPhoto');
             $userPhoto->setLabel(OW::getLanguage()->text('base', 'questions_question_user_photo_label'));
             $userPhoto->addValidator($photoValidator);
             $this->addElement($userPhoto);
             $displayPhoto = true;
     }
     $displayTermsOfUse = false;
     if (OW::getConfig()->getValue('base', 'join_display_terms_of_use')) {
         $termOfUse = new CheckboxField('termOfUse');
         $termOfUse->setLabel(OW::getLanguage()->text('base', 'questions_question_user_terms_of_use_label'));
         $termOfUse->setRequired();
         $this->addElement($termOfUse);
         $displayTermsOfUse = true;
     }
     $this->setEnctype('multipart/form-data');
     $event = new OW_Event('join.get_captcha_field');
     OW::getEventManager()->trigger($event);
     $captchaField = $event->getData();
     $displayCaptcha = false;
     if (!empty($captchaField) && $captchaField instanceof FormElement) {
         $captchaField->setName('captchaField');
         $this->addElement($captchaField);
         $displayCaptcha = true;
     }
     //$captchaField = new CaptchaField('captchaField');
     //$this->addElement($captchaField);
     $controller->assign('display_captcha', $displayCaptcha);
     $controller->assign('display_photo', $displayPhoto);
     $controller->assign('display_terms_of_use', $displayTermsOfUse);
     if (OW::getRequest()->isPost()) {
         if (!empty($captchaField) && $captchaField instanceof FormElement) {
             $captchaField->setValue(null);
         }
         if (isset($userPhoto) && isset($_FILES[$userPhoto->getName()]['name'])) {
             $_POST[$userPhoto->getName()] = $_FILES[$userPhoto->getName()]['name'];
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Default action
  */
 public function index()
 {
     //$this->contentMenu->getElement('socialsharing_index')->setActive(true);
     $config = OW::getConfig();
     $order = $config->getValue('socialsharing', 'order');
     $defautOrder = SOCIALSHARING_CLASS_Settings::getEntityList();
     if (!empty($order)) {
         $order = json_decode($order, true);
         if (!is_array($order)) {
             $order = $defautOrder;
         }
         $result = array();
         foreach ($order as $key => $item) {
             if (in_array($key, $defautOrder)) {
                 $result[$key] = $key;
             }
         }
         if (!empty($order)) {
             $order = $result;
         } else {
             $order = $defautOrder;
         }
     } else {
         $order = $defautOrder;
     }
     $this->assign('order', $order);
     $settings = new Form('settings');
     //printVar($order);
     foreach ($order as $item) {
         $element = new CheckboxField($item);
         $element->setValue($config->getValue('socialsharing', $item));
         $settings->addElement($element);
     }
     $settings->setEnctype("multipart/form-data");
     $file = new FileField('image');
     $validator = new SocialSharingImageValidator(true);
     $file->addValidator($validator);
     $settings->addElement($file);
     $submit = new Submit('save_settings');
     $settings->addElement($submit);
     //printVar($config->getValue('socialsharing', 'facebook'));
     $apiKeyForm = new Form('api_key_form');
     $key = new TextField('api_key');
     $key->setLabel(OW::getLanguage()->text('socialsharing', 'api_key_label'));
     $key->setRequired();
     $apiKey = OW::getConfig()->getValue('socialsharing', 'api_key');
     $key->setValue($apiKey);
     $apiKeyForm->addElement($key);
     $apiKeySubmit = new Submit('save_api_key');
     $apiKeyForm->addElement($apiKeySubmit);
     $this->addForm($apiKeyForm);
     if (OW::getRequest()->isPost()) {
         if (isset($_POST['save_settings'])) {
             if ($settings->isValid($_POST)) {
                 $data = $settings->getValues();
                 $config->saveConfig('socialsharing', 'facebook', (bool) $data['facebook']);
                 $config->saveConfig('socialsharing', 'twitter', (bool) $data['twitter']);
                 $config->saveConfig('socialsharing', 'googlePlus', (bool) $data['googlePlus']);
                 $config->saveConfig('socialsharing', 'pinterest', (bool) $data['pinterest']);
                 SOCIALSHARING_BOL_Service::getInstance()->uploadImage($_FILES['image']['tmp_name']);
                 OW::getFeedback()->info(OW::getLanguage()->text('socialsharing', 'settings_saved'));
                 //Setting succsessfully saved
                 $this->redirect();
             } else {
                 OW::getFeedback()->error(OW::getLanguage()->text('socialsharing', 'settings_saved_error'));
                 //
             }
         } else {
             if (isset($_POST['save_api_key'])) {
                 if ($apiKeyForm->isValid($_POST)) {
                     $data = $apiKeyForm->getValues();
                     $config->saveConfig('socialsharing', 'api_key', $data['api_key']);
                     OW::getFeedback()->info(OW::getLanguage()->text('socialsharing', 'api_key_saved'));
                     //Setting succsessfully saved
                     $this->redirect();
                 } else {
                     OW::getFeedback()->error(OW::getLanguage()->text('socialsharing', 'settings_saved_error'));
                 }
             }
         }
     }
     $this->addForm($settings);
     $this->assign('imageUrl', SOCIALSHARING_BOL_Service::getInstance()->getDefaultImageUrl() . '?pid=' . md5(rand(0, 9999999999)));
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . "jquery-ui.min.js");
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('socialsharing')->getStaticJsUrl() . "admin.js");
     OW::getDocument()->addOnloadScript(" window.sharing = new socialSharingAdmin(" . json_encode(array("ajaxResponderUrl" => OW::getRouter()->urlFor('SOCIALSHARING_CTRL_Admin', 'ajaxResponder'))) . ") ");
 }