Example #1
0
 public function edit($params)
 {
     if (!isset($params['id']) || !($id = (int) $params['id'])) {
         throw new Redirect404Exception();
         return;
     }
     $language = OW::getLanguage();
     $config = OW::getConfig();
     $sponsor = SPONSORS_BOL_Service::getInstance()->findSponsorById($id);
     if (!$sponsor->id) {
         throw new Redirect404Exception();
         return;
     }
     $sponsorForm = new Form('sponsorForm');
     $sponsorForm->setEnctype('multipart/form-data');
     $element = new TextField('sponsorName');
     $element->setRequired(true);
     $element->setLabel($language->text('sponsors', 'sponsor_name'));
     $element->setInvitation($language->text('sponsors', 'sponsor_name_desc'));
     $element->setValue($sponsor->name);
     $element->setHasInvitation(true);
     $sponsorForm->addElement($element);
     $element = new TextField('sponsorEmail');
     $element->setRequired(true);
     $validator = new EmailValidator();
     $validator->setErrorMessage($language->text('sponsors', 'invalid_email_format'));
     $element->addValidator($validator);
     $element->setLabel($language->text('sponsors', 'sponsor_email'));
     $element->setInvitation($language->text('sponsors', 'sponsor_email_desc'));
     $element->setValue($sponsor->email);
     $element->setHasInvitation(true);
     $sponsorForm->addElement($element);
     $element = new TextField('sponsorWebsite');
     $element->setRequired(true);
     $validator = new UrlValidator();
     $validator->setErrorMessage($language->text('sponsors', 'invalid_url_format'));
     $element->addValidator($validator);
     $element->setLabel($language->text('sponsors', 'sponsor_website'));
     $element->setInvitation($language->text('sponsors', 'sponsor_website_desc'));
     $element->setHasInvitation(true);
     $element->setValue($sponsor->website);
     $sponsorForm->addElement($element);
     $element = new TextField('sponsorAmount');
     $element->setRequired(true);
     $minAmount = $config->getValue('sponsors', 'minimumPayment');
     $validator = new FloatValidator(0);
     $validator->setErrorMessage($language->text('sponsors', 'invalid_amount_value'));
     $element->addValidator($validator);
     $element->setLabel($language->text('sponsors', 'sponsor_payment_amount'));
     $element->setInvitation($language->text('sponsors', 'admin_payment_amount_desc'));
     $element->setHasInvitation(true);
     $element->setValue($sponsor->price);
     $sponsorForm->addElement($element);
     $element = new TextField('sponsorValidity');
     $element->setRequired(true);
     $element->setValue($sponsor->validity);
     $validator = new IntValidator(0);
     $validator->setErrorMessage($language->text('sponsors', 'invalid_numeric_format'));
     $element->addValidator($validator);
     $element->setLabel($language->text('sponsors', 'sponsorship_validatity'));
     $element->setInvitation($language->text('sponsors', 'sponsorship_validatity_desc'));
     $element->setHasInvitation(true);
     $sponsorForm->addElement($element);
     $element = new FileField('sponsorImage');
     $element->setLabel($language->text('sponsors', 'sponsorsh_image_file'));
     $sponsorForm->addElement($element);
     $element = new Submit('editSponsor');
     $element->setValue(OW::getLanguage()->text('sponsors', 'edit_sponsor_btn'));
     $sponsorForm->addElement($element);
     if (OW::getRequest()->isPost()) {
         if ($sponsorForm->isValid($_POST)) {
             $values = $sponsorForm->getValues();
             $allowedImageExtensions = array('jpg', 'jpeg', 'gif', 'png', 'tiff');
             $sponsorImageFile = "";
             if (isset($_FILES['sponsorImage']) && in_array(UTIL_File::getExtension($_FILES['sponsorImage']['name']), $allowedImageExtensions)) {
                 $backupPath = OW::getPluginManager()->getPlugin('sponsors')->getUserFilesDir() . $_FILES['sponsorImage']['name'];
                 move_uploaded_file($_FILES['sponsorImage']['tmp_name'], $backupPath);
                 $sponsorImageFile = $_FILES['sponsorImage']['name'];
             }
             $sponsor->name = $values['sponsorName'];
             $sponsor->email = $values['sponsorEmail'];
             $sponsor->website = $values['sponsorWebsite'];
             $sponsor->price = $values['sponsorAmount'];
             if (!empty($sponsorImageFile)) {
                 $sponsor->image = $sponsorImageFile;
             }
             $sponsor->userId = $sponsor->userId;
             $sponsor->status = $sponsor->status;
             $sponsor->validity = $values['sponsorValidity'];
             if (SPONSORS_BOL_Service::getInstance()->addSponsor($sponsor)) {
                 OW::getFeedback()->info(OW::getLanguage()->text('sponsors', 'sponsor_edit_ok'));
             } else {
                 OW::getFeedback()->error(OW::getLanguage()->text('sponsors', 'sponsor_edit_error'));
             }
         }
     }
     $this->addForm($sponsorForm);
     $fields = array();
     foreach ($sponsorForm->getElements() as $element) {
         if (!$element instanceof HiddenField) {
             $fields[$element->getName()] = $element->getName();
         }
     }
     $this->assign('formData', $fields);
     $this->assign('currentLogoImage', OW::getPluginManager()->getPlugin('sponsors')->getUserFilesUrl() . $sponsor->image);
     $this->setPageHeading(OW::getLanguage()->text('sponsors', 'edit_sponsor_heading'));
     $this->setPageTitle(OW::getLanguage()->text('sponsors', 'edit_sponsor_heading'));
     $this->setPageHeadingIconClass('ow_ic_edit');
 }
Example #2
0
 /**
  * Upload and add new plugins.
  */
 public function add()
 {
     $this->checkXP();
     OW::getNavigation()->activateMenuItem(OW_Navigation::ADMIN_PLUGINS, 'admin', 'sidebar_menu_plugins_add');
     $language = OW::getLanguage();
     $form = new Form('plugin-add');
     $form->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA);
     $file = new FileField('file');
     $form->addElement($file);
     $submit = new Submit('submit');
     $submit->setValue($language->text('admin', 'plugins_manage_add_submit_label'));
     $form->addElement($submit);
     $this->addForm($form);
     if (OW::getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             // check server file upload limits
             $uploadMaxFilesize = (double) ini_get("upload_max_filesize");
             $postMaxSize = (double) ini_get("post_max_size");
             $serverLimit = $uploadMaxFilesize < $postMaxSize ? $uploadMaxFilesize : $postMaxSize;
             if ($_FILES['file']['error'] != UPLOAD_ERR_OK && $_FILES['file']['error'] == UPLOAD_ERR_INI_SIZE || (empty($_FILES['file']) || $_FILES['file']['size'] > $serverLimit * 1024 * 1024)) {
                 OW::getFeedback()->error($language->text('admin', 'manage_plugins_add_size_error_message', array('limit' => $serverLimit)));
                 $this->redirect();
             }
             if ($_FILES['file']['error'] != UPLOAD_ERR_OK) {
                 switch ($_FILES['file']['error']) {
                     case UPLOAD_ERR_INI_SIZE:
                         $error = $language->text('base', 'upload_file_max_upload_filesize_error');
                         break;
                     case UPLOAD_ERR_PARTIAL:
                         $error = $language->text('base', 'upload_file_file_partially_uploaded_error');
                         break;
                     case UPLOAD_ERR_NO_FILE:
                         $error = $language->text('base', 'upload_file_no_file_error');
                         break;
                     case UPLOAD_ERR_NO_TMP_DIR:
                         $error = $language->text('base', 'upload_file_no_tmp_dir_error');
                         break;
                     case UPLOAD_ERR_CANT_WRITE:
                         $error = $language->text('base', 'upload_file_cant_write_file_error');
                         break;
                     case UPLOAD_ERR_EXTENSION:
                         $error = $language->text('base', 'upload_file_invalid_extention_error');
                         break;
                     default:
                         $error = $language->text('base', 'upload_file_fail');
                 }
                 OW::getFeedback()->error($error);
                 $this->redirect();
             }
             if (!is_uploaded_file($_FILES['file']['tmp_name'])) {
                 OW::getFeedback()->error($language->text('admin', 'manage_plugins_add_empty_field_error_message'));
                 $this->redirect();
             }
             $tempFile = OW_DIR_PLUGINFILES . 'ow' . DS . uniqid('plugin_add') . '.zip';
             $tempDir = OW_DIR_PLUGINFILES . 'ow' . DS . uniqid('plugin_add') . DS;
             copy($_FILES['file']['tmp_name'], $tempFile);
             $zip = new ZipArchive();
             if ($zip->open($tempFile) === true) {
                 $zip->extractTo($tempDir);
                 $zip->close();
             } else {
                 OW::getFeedback()->error(OW::getLanguage()->text('admin', 'manage_plugin_add_extract_error'));
                 $this->redirectToAction('index');
             }
             unlink($tempFile);
             $this->redirect(OW::getRequest()->buildUrlQueryString(OW::getRouter()->urlFor(__CLASS__, 'processAdd'), array('dir' => urlencode($tempDir))));
         }
     }
 }
Example #3
0
 public function page()
 {
     if (!OW::getRequest()->isAjax()) {
         OW::getNavigation()->activateMenuItem(OW_Navigation::ADMIN_SETTINGS, 'admin', 'sidebar_menu_item_main_settings');
     }
     $language = OW::getLanguage();
     $menu = $this->getMenu();
     $this->addComponent('menu', $menu);
     if (!OW::getRequest()->isAjax()) {
         OW::getDocument()->setHeading(OW::getLanguage()->text('admin', 'heading_page_settings'));
         OW::getDocument()->setHeadingIconClass('ow_ic_file');
     }
     $form = new Form('page_settings');
     $form->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA);
     $this->addForm($form);
     $headCode = new Textarea('head_code');
     $headCode->setLabel($language->text('admin', 'page_settings_form_headcode_label'));
     $headCode->setDescription($language->text('admin', 'page_settings_form_headcode_desc'));
     $form->addElement($headCode);
     $bottomCode = new Textarea('bottom_code');
     $bottomCode->setLabel($language->text('admin', 'page_settings_form_bottomcode_label'));
     $bottomCode->setDescription($language->text('admin', 'page_settings_form_bottomcode_desc'));
     $form->addElement($bottomCode);
     $favicon = new FileField('favicon');
     $favicon->setLabel($language->text('admin', 'page_settings_form_favicon_label'));
     $favicon->setDescription($language->text('admin', 'page_settings_form_favicon_desc'));
     $form->addElement($favicon);
     $enableFavicon = new CheckboxField('enable_favicon');
     $form->addElement($enableFavicon);
     $submit = new Submit('save');
     $submit->setValue($language->text('admin', 'save_btn_label'));
     $form->addElement($submit);
     $faviconPath = OW::getPluginManager()->getPlugin('base')->getUserFilesDir() . 'favicon.ico';
     $faviconUrl = OW::getPluginManager()->getPlugin('base')->getUserFilesUrl() . 'favicon.ico';
     $this->assign('faviconSrc', $faviconUrl);
     if (OW::getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             OW::getConfig()->saveConfig('base', 'html_head_code', $data['head_code']);
             OW::getConfig()->saveConfig('base', 'html_prebody_code', $data['bottom_code']);
             if (!empty($_FILES['favicon']['name'])) {
                 if ((int) $_FILES['favicon']['error'] === 0 && is_uploaded_file($_FILES['favicon']['tmp_name']) && UTIL_File::getExtension($_FILES['favicon']['name']) === 'ico') {
                     if (file_exists($faviconPath)) {
                         @unlink($faviconPath);
                     }
                     @move_uploaded_file($_FILES['favicon']['tmp_name'], $faviconPath);
                     if (file_exists($_FILES['favicon']['tmp_name'])) {
                         @unlink($_FILES['favicon']['tmp_name']);
                     }
                 } else {
                     OW::getFeedback()->error($language->text('admin', 'page_settings_favicon_submit_error_message'));
                 }
             }
             OW::getConfig()->saveConfig('base', 'favicon', !empty($data['enable_favicon']));
             OW::getFeedback()->info($language->text('admin', 'settings_submit_success_message'));
         } else {
             OW::getFeedback()->error($language->text('admin', 'settings_submit_error_message'));
         }
         $this->redirect();
     }
     $headCode->setValue(OW::getConfig()->getValue('base', 'html_head_code'));
     $bottomCode->setValue(OW::getConfig()->getValue('base', 'html_prebody_code'));
     $enableFavicon->setValue((int) OW::getConfig()->getValue('base', 'favicon'));
     $this->assign('faviconEnabled', OW::getConfig()->getValue('base', 'favicon'));
     $script = "\$('#{$enableFavicon->getId()}').change(function(){ if(this.checked){ \$('#favicon_enabled').show();\$('#favicon_desabled').hide(); \$('{$favicon->getId()}').attr('disabled', true);}else{ \$('#favicon_enabled').hide();\$('#favicon_desabled').show(); \$('{$favicon->getId()}').attr('disabled', false);} });";
     OW::getDocument()->addOnloadScript($script);
 }
Example #4
0
 public function chooseTheme()
 {
     $language = OW::getLanguage();
     $router = OW::getRouter();
     $this->themeService->updateThemeList();
     $this->themeService->updateThemesInfo();
     $themes = $this->themeService->findAllThemes();
     $themesInfo = array();
     $activeTheme = OW::getThemeManager()->getSelectedTheme()->getDto()->getKey();
     /* @var $theme BOL_Theme */
     foreach ($themes as $theme) {
         $themesInfo[$theme->getKey()] = array("key" => $theme->getKey(), "title" => $theme->getTitle(), "iconUrl" => $this->themeService->getStaticUrl($theme->getKey()) . BOL_ThemeService::ICON_FILE, "previewUrl" => $this->themeService->getStaticUrl($theme->getKey()) . BOL_ThemeService::PREVIEW_FILE, "active" => $theme->getKey() == $activeTheme, "changeUrl" => $router->urlFor(__CLASS__, "changeTheme", array(BOL_StorageService::URI_VAR_KEY => $theme->getKey())), "update_url" => (int) $theme->getUpdate() == 1 ? $router->urlFor("ADMIN_CTRL_Themes", "updateRequest", array(BOL_StorageService::URI_VAR_KEY => $theme->getKey())) : false);
         if (!in_array($theme->getKey(), array(BOL_ThemeService::DEFAULT_THEME, $activeTheme))) {
             $themesInfo[$theme->getKey()]["delete_url"] = $router->urlFor(__CLASS__, "deleteTheme", array("key" => $theme->getKey()));
         }
         if ($theme->getLicenseCheckTimestamp() > 0) {
             $params = array(BOL_StorageService::URI_VAR_BACK_URI => urlencode($router->uriForRoute("admin_themes_choose")), BOL_StorageService::URI_VAR_KEY => $theme->getKey(), BOL_StorageService::URI_VAR_ITEM_TYPE => BOL_StorageService::URI_VAR_ITEM_TYPE_VAL_THEME, BOL_StorageService::URI_VAR_DEV_KEY => $theme->getDeveloperKey(), BOL_StorageService::URI_VAR_RETURN_RESULT => 0);
             $themesInfo[$theme->getKey()]["license_url"] = OW::getRequest()->buildUrlQueryString($router->urlFor("ADMIN_CTRL_Storage", "checkItemLicense"), $params);
         }
         $xmlInfo = $this->themeService->getThemeXmlInfoForKey($theme->getKey());
         $themesInfo[$theme->getKey()] = array_merge($themesInfo[$theme->getKey()], $xmlInfo);
     }
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin("admin")->getStaticJsUrl() . "theme_select.js");
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin("base")->getStaticJsUrl() . "jquery.sticky.js");
     $addData = array("deleteConfirmMsg" => $language->text("admin", "themes_choose_delete_confirm_msg"), "deleteActiveThemeMsg" => $language->text("admin", "themes_cant_delete_active_theme"));
     OW::getDocument()->addOnloadScript("window.owThemes = new ThemesSelect(" . json_encode($themesInfo) . ", " . json_encode($addData) . ");\n        \t\$('.selected_theme_info input.theme_select_submit').click(function(){\n    \t\t\twindow.location.href = '{$themesInfo[$activeTheme]['changeUrl']}';\n    \t\t});\n            \$('.selected_theme_info_stick').sticky({topSpacing:60});\n            \$('.admin_themes_select a.theme_icon').click( function(){ \$('.theme_info .theme_control_button').hide(); });");
     $this->assign("adminThemes", array(BOL_ThemeService::DEFAULT_THEME => $themesInfo[BOL_ThemeService::DEFAULT_THEME]));
     $this->assign("themeInfo", $themesInfo[$activeTheme]);
     $event = new OW_Event("admin.filter_themes_to_choose", array(), $themesInfo);
     OW::getEventManager()->trigger($event);
     $this->assign("themes", $event->getData());
     // add theme
     $form = new Form("theme-add");
     $form->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA);
     $file = new FileField("file");
     $form->addElement($file);
     $submit = new Submit("submit");
     $submit->setValue($language->text("admin", "plugins_manage_add_submit_label"));
     $form->addElement($submit);
     $this->addForm($form);
     if (OW::getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             $result = UTIL_File::checkUploadedFile($_FILES["file"]);
             if (!$result["result"]) {
                 $this->feedback->error($result["message"]);
                 $this->redirect($router->urlForRoute("admin_themes_choose"));
             }
             $pluginfilesDir = OW::getPluginManager()->getPlugin("base")->getPluginFilesDir();
             $tempFile = $this->getTemDirPath() . UTIL_String::getRandomStringWithPrefix("theme_add") . ".zip";
             $tempDirName = UTIL_String::getRandomStringWithPrefix("theme_add");
             if (!move_uploaded_file($_FILES["file"]["tmp_name"], $tempFile)) {
                 $this->feedback->error($language->text("admin", "manage_theme_add_move_file_error"));
                 $this->redirect($router->urlForRoute("admin_themes_choose"));
             }
             $zip = new ZipArchive();
             if ($zip->open($tempFile) === true) {
                 $zip->extractTo($this->getTemDirPath() . $tempDirName);
                 $zip->close();
             } else {
                 $this->feedback->error($language->text("admin", "manage_theme_add_extract_error"));
                 $this->redirect($router->urlForRoute("admin_themes_choose"));
             }
             unlink($tempFile);
             $this->redirect(OW::getRequest()->buildUrlQueryString($router->urlFor(__CLASS__, "processAdd"), array("dir" => $tempDirName)));
         }
     }
 }
Example #5
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());
 }
Example #6
0
 public function addTheme()
 {
     $this->checkXP();
     OW::getNavigation()->activateMenuItem(OW_Navigation::ADMIN_PLUGINS, 'admin', 'sidebar_menu_themes_add');
     $this->setPageHeading(OW::getLanguage()->text('admin', 'themes_add_theme_page_heading'));
     $this->setPageHeadingIconClass('ow_ic_monitor');
     $language = OW::getLanguage();
     $form = new Form('theme-add');
     $form->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA);
     $file = new FileField('file');
     $form->addElement($file);
     $submit = new Submit('submit');
     $submit->setValue($language->text('admin', 'plugins_manage_add_submit_label'));
     $form->addElement($submit);
     $this->addForm($form);
     if (OW::getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             if (empty($_FILES['file']) || $_FILES['file']['error'] > 0 || !is_uploaded_file($_FILES['file']['tmp_name'])) {
                 OW::getFeedback()->error($language->text('admin', 'manage_plugins_add_empty_field_error_message'));
                 $this->redirect();
             }
             if ($_FILES['file']['size'] > 50000000) {
                 OW::getFeedback()->error($language->text('admin', 'manage_plugins_add_size_error_message'));
                 $this->redirect();
             }
             $tempFile = OW_DIR_PLUGINFILES . 'ow' . DS . uniqid('theme_add') . '.zip';
             $tempDir = OW_DIR_PLUGINFILES . 'ow' . DS . uniqid('theme_add') . DS;
             copy($_FILES['file']['tmp_name'], $tempFile);
             $zip = new ZipArchive();
             if ($zip->open($tempFile) === true) {
                 $zip->extractTo($tempDir);
                 $zip->close();
             } else {
                 OW::getFeedback()->error(OW::getLanguage()->text('admin', 'manage_theme_add_extract_error'));
                 $this->redirectToAction();
             }
             unlink($tempFile);
             $this->redirect(OW::getRequest()->buildUrlQueryString(OW::getRouter()->urlFor(__CLASS__, 'processAdd'), array('dir' => urlencode($tempDir))));
         }
     }
 }
Example #7
0
 /**
  * Uploads new plugin and extracts archive contecnts.
  */
 public function add()
 {
     OW::getNavigation()->activateMenuItem(OW_Navigation::ADMIN_PLUGINS, "admin", "sidebar_menu_plugins_add");
     $language = OW::getLanguage();
     $feedback = OW::getFeedback();
     $form = new Form("plugin-add");
     $form->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA);
     $file = new FileField("file");
     $form->addElement($file);
     $submit = new Submit("submit");
     $submit->setValue($language->text("admin", "plugins_manage_add_submit_label"));
     $form->addElement($submit);
     $this->addForm($form);
     if (OW::getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             $result = UTIL_File::checkUploadedFile($_FILES["file"]);
             if (!$result["result"]) {
                 $feedback->error($result["message"]);
                 $this->redirect();
             }
             $pluginfilesDir = OW::getPluginManager()->getPlugin("base")->getPluginFilesDir();
             $tempFile = $pluginfilesDir . UTIL_String::getRandomStringWithPrefix("plugin_add") . ".zip";
             $tempDirName = UTIL_String::getRandomStringWithPrefix("plugin_add");
             if (!move_uploaded_file($_FILES["file"]["tmp_name"], $tempFile)) {
                 $feedback->error($language->text("admin", "manage_plugin_add_move_file_error"));
                 $this->redirectToAction("index");
             }
             $zip = new ZipArchive();
             if ($zip->open($tempFile) === true) {
                 $zip->extractTo($this->getTemDirPath() . $tempDirName);
                 $zip->close();
             } else {
                 $feedback->error($language->text("admin", "manage_plugin_add_extract_error"));
                 $this->redirectToAction("index");
             }
             unlink($tempFile);
             $this->redirect(OW::getRequest()->buildUrlQueryString(OW::getRouter()->urlFor(__CLASS__, "processAdd"), array("dir" => $tempDirName)));
         }
     }
 }
Example #8
0
 public function toplinklist($curr = null)
 {
     OW::getDocument()->addStyleSheet(OW::getPluginManager()->getPlugin('toplink')->getStaticCssUrl() . 'style.css');
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('toplink')->getStaticJsUrl() . 'toplink.js');
     $currId = @$curr['id'];
     $topForm = new Form("topForm");
     $topForm->setEnctype('multipart/form-data');
     $topSubmit = new Submit("topSubmit");
     $topForm->addElement($topSubmit);
     $topName = new TextField("topName");
     $topUrl = new TextField("topUrl");
     $topIcon = new TextField("topIcon");
     $topId = new HiddenField("topId");
     $uploadIcon = new FileField('topIconFile');
     $uploadIcon->setLabel($this->text('toplink', 'new_icon'));
     $topOrder = new TextField('toporder');
     $topTarget = new CheckboxField('toptarget');
     $topPermission = new CheckboxGroup('toppermission');
     $topPermission->setColumnCount(1);
     $topPermission->setLabel($this->text('toplink', 'new_permission'));
     $availableDesc = TOPLINK_BOL_Service::$visibility;
     $topPermission->addOptions($availableDesc);
     $topOrder->setLabel($this->text('toplink', 'new_order'));
     $topOrder->setRequired();
     $topTarget->setLabel($this->text('toplink', 'new_target'));
     $topName->setLabel($this->text('toplink', 'new_name'));
     //$topName->setRequired();
     $topUrl->setLabel($this->text('toplink', 'new_url'));
     $topUrl->setRequired();
     $topIcon->setLabel($this->text('toplink', 'new_icon'));
     if (!empty($currId) && !OW::getRequest()->isPost()) {
         $theTopLink = $this->myService->getTopLinkById($currId);
         $topName->setValue($theTopLink->itemname);
         $topId->setValue($currId);
         $topUrl->setValue($theTopLink->url);
         $topIcon->setValue($theTopLink->icon);
         $topTarget->setValue($theTopLink->target);
         $topOrder->setValue($theTopLink->order);
         $theTopLinkChild = $this->myService->getTopLinkChildObjectByParentId($currId);
         $theTopLinkPermission = $this->myService->getTopLinkPermissionById($currId);
         if (!empty($theTopLinkPermission)) {
             $i = 1;
             foreach ($theTopLinkPermission as $topLinkPermission) {
                 $permissionOption[$i] = $topLinkPermission->availablefor;
                 $i++;
             }
             $topPermission->setValue($permissionOption);
         }
     }
     $topForm->addElement($topName);
     $topForm->addElement($topUrl);
     $topForm->addElement($topIcon);
     $topForm->addElement($topId);
     $topForm->addElement($topTarget);
     $topForm->addElement($topOrder);
     $topForm->addElement($uploadIcon);
     $topForm->addElement($topPermission);
     $this->addForm($topForm);
     /* --- form submit --- */
     $childrenNameList = @$_REQUEST['menuchildname'];
     $childrenUrlList = @$_REQUEST['menuchildurl'];
     $childrenIDList = @$_REQUEST['menuchildid'];
     if (OW::getRequest()->isPost()) {
         if ($topForm->isValid($_POST)) {
             $fdata = $topForm->getValues();
             $newtoplink = new TOPLINK_BOL_Toplink();
             $newtoplink->id = $fdata['topId'];
             $newtoplink->itemname = $fdata['topName'];
             $theurl = $fdata['topUrl'];
             if (!empty($theurl)) {
                 $theurl = preg_match("/^http/", $theurl) ? $theurl : "http://" . $theurl;
             } else {
                 $theurl = "#";
             }
             $newtoplink->url = $theurl;
             /* check file exist */
             if (!empty($fdata['topIcon']) && preg_match("/^\\//", $fdata['topIcon'])) {
                 $newtoplink->icon = $fdata['topIcon'];
                 $iconFileName = preg_replace("/^\\//", "", $newtoplink->icon);
                 if (!file_exists($this->iconDir . $iconFileName)) {
                     $newtoplink->icon = null;
                 }
             }
             /* end */
             $newtoplink->target = $fdata['toptarget'];
             $newtoplink->order = empty($fdata['toporder']) ? 5 : $fdata['toporder'];
             $loadedExts = get_loaded_extensions();
             if (in_array('imagick', $loadedExts)) {
                 $this->iMagicInstalled = true;
             }
             if ($_FILES['topIconFile']['error'] == 0) {
                 $ext = explode('.', $_FILES['topIconFile']['name']);
                 $ext = end($ext);
                 if ($this->iMagicInstalled) {
                     $image = new Imagick($_FILES['topIconFile']['tmp_name']);
                     $image->thumbnailImage(16, 0);
                     file_put_contents($this->iconDir . $_FILES['topIconFile']['name'] . '.png', $image);
                     $uploadresult = $_FILES['topIconFile']['name'] . '.png';
                 } else {
                     try {
                         $image = new UTIL_Image($_FILES['topIconFile']['tmp_name'], 'PNG');
                         $image->resizeImage(16, 16, false)->saveImage($this->iconDir . $_FILES['topIconFile']['name'] . '.png');
                         $uploadresult = $_FILES['topIconFile']['name'] . '.png';
                     } catch (Exception $e) {
                         $uploadresult = null;
                     }
                 }
                 if ($uploadresult) {
                     $newtoplink->icon = "/" . $uploadresult;
                 }
                 /* check file exist AGAIN AFTER UPLOAD */
                 if ($newtoplink->icon && preg_match("/^\\//", $newtoplink->icon)) {
                     $iconFileName = preg_replace("/^\\//", "", $newtoplink->icon);
                     if (!file_exists($this->iconDir . $iconFileName)) {
                         $newtoplink->icon = null;
                     }
                 }
                 /* end */
             }
             $permission = $fdata['toppermission'];
             //save link
             $newid = $this->myService->saveToplink($newtoplink, $permission);
             $toplinkid = !empty($newtoplink->id) ? $newtoplink->id : $newid;
             $childIds = $this->myService->getTopLinkChildIdByParentId($toplinkid);
             if (!empty($childIds)) {
                 if (!empty($childrenIDList)) {
                     foreach ($childIds as $cid) {
                         if (!in_array($cid, $childrenIDList)) {
                             $this->myService->removeToplinkChild($cid);
                         }
                     }
                 } else {
                     foreach ($childIds as $cid) {
                         $this->myService->removeToplinkChild($cid);
                     }
                 }
             }
             //process children if any
             if (!empty($childrenNameList) && !empty($childrenUrlList)) {
                 foreach ($childrenNameList as $childIndex => $childName) {
                     if (!empty($childName) && !empty($childrenUrlList[$childIndex])) {
                         $childDoa = new TOPLINK_BOL_ToplinkChildren();
                         $childDoa->childof = $toplinkid;
                         $childDoa->name = $childName;
                         if (!empty($childrenUrlList[$childIndex])) {
                             $thecurl = preg_match("/^http/", $childrenUrlList[$childIndex]) ? $childrenUrlList[$childIndex] : "http://" . $childrenUrlList[$childIndex];
                         } else {
                             $thecurl = "#";
                         }
                         $childDoa->url = $thecurl;
                         if (!empty($childrenIDList[$childIndex])) {
                             $childDoa->id = $childrenIDList[$childIndex];
                         }
                         $this->myService->saveTopLinkChild($childDoa);
                     }
                 }
             }
             OW::getFeedback()->info($this->text('toplink', 'save_success_message'));
             $this->redirect(OW::getRouter()->urlForRoute('toplink.admin'));
         }
     }
     $alltoplink = $this->myService->getTopLink(true);
     $updatelink = array();
     if (!empty($alltoplink)) {
         foreach ($alltoplink as $toplinkId => $toplink) {
             $toplink->itemname = empty($toplink->itemname) ? $this->text('toplink', 'top_link_no_name') : $toplink->itemname;
             $permissionx = array();
             $theTopLinkPermission = $this->myService->getTopLinkPermissionById($toplink->id);
             foreach ($theTopLinkPermission as $topLinkPermission) {
                 $permissionx[] = ucwords($availableDesc[$topLinkPermission->availablefor]);
             }
             $toplink->permission = !empty($permissionx) ? implode(',', $permissionx) : '';
             $toplink->updateurl = OW::getRouter()->urlForRoute('toplink.admin2', array('id' => $toplink->id));
             $toplink->removeurl = OW::getRouter()->urlForRoute('toplink.remove', array('id' => $toplink->id));
             $alltoplink[$toplinkId] = $toplink;
         }
     }
     if (!empty($theTopLinkChild)) {
         $this->assign('children', $theTopLinkChild);
     }
     $this->assign('alltoplink', $alltoplink);
 }
Example #9
0
 public function index($params)
 {
     $filevernew = array();
     $file = array();
     $flag = false;
     $this->setPageTitle(OW::getLanguage()->text('spdownload', 'index_upload_title'));
     $this->setPageHeading(OW::getLanguage()->text('spdownload', 'index_upload_heading'));
     $arrayCheckCategory = array();
     if (!empty($params) && isset($params['fileId'])) {
         if (!stripos($params['fileId'], "-")) {
             throw new Redirect404Exception();
         }
         $check = $params['fileId'];
         $params['fileId'] = substr($params['fileId'], 0, stripos($params['fileId'], "-"));
         $file = SPDOWNLOAD_BOL_FileService::getInstance()->getFileId($params['fileId']);
         if ($file->id . '-' . $file->slug != $check) {
             throw new Redirect404Exception();
         }
         $CategoryIdList = SPDOWNLOAD_BOL_FileCategoryService::getInstance()->getCategoryId($params['fileId']);
         foreach ($CategoryIdList as $key => $value) {
             array_push($arrayCheckCategory, $value->categoryId);
         }
         $flag = true;
         $file = SPDOWNLOAD_BOL_FileService::getInstance()->getFileId($params['fileId']);
         if ($file === NULL) {
             throw new Redirect404Exception();
         }
         $filevernew = SPDOWNLOAD_BOL_VersionService::getInstance()->getFileVerNew($params['fileId']);
         $url = OW::getPluginManager()->getPlugin('spdownload')->getUserFilesUrl();
         $file->icon = $url . 'icon_small_' . $params['fileId'] . '.png';
         $thumbnails = SPDOWNLOAD_BOL_FileService::getInstance()->getThumbnailList($params['fileId']);
         foreach ($thumbnails as $key => $value) {
             $value->image = $url . $value->fileId . '_thumb_small_' . $value->uri . '.jpg';
         }
         $this->assign('file', $file);
         $this->assign('thumbnails', $thumbnails);
     }
     $form = new Form('upload_form');
     $form->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA);
     $cmpCategories = new SPDOWNLOAD_CMP_Category(false, $arrayCheckCategory);
     $this->addComponent('cmpCategories', $cmpCategories);
     $fieldName = new TextField('upname');
     $fieldName->setLabel($this->text('spdownload', 'form_label_name_up'));
     $fieldName->setRequired();
     if (!empty($params) && isset($params['fileId'])) {
         $fieldName->setValue($file->name);
     }
     $form->addElement($fieldName);
     $fieldSlug = new TextField('upslug');
     $fieldSlug->setLabel($this->text('spdownload', 'form_label_slug_up'));
     $fieldSlug->setRequired();
     if (!empty($params) && isset($params['fileId'])) {
         $fieldSlug->setValue($file->slug);
     }
     $form->addElement($fieldSlug);
     $fieldFile = new FileField('upfile');
     $fieldFile->setLabel($this->text('spdownload', 'form_label_file_up'));
     $form->addElement($fieldFile);
     $fieldIcon = new FileField('upicon');
     $fieldIcon->setLabel($this->text('spdownload', 'form_label_icon_up'));
     $form->addElement($fieldIcon);
     $fieldThumb = new MultiFileField('upthumb', 5);
     $fieldThumb->setLabel($this->text('spdownload', 'form_label_thumb_up'));
     $form->addElement($fieldThumb);
     $fieldDescription = new Textarea('updescription');
     $fieldDescription->setLabel($this->text('spdownload', 'form_label_description_up'));
     if (!empty($params) && isset($params['fileId'])) {
         $fieldDescription->setValue($file->description);
     }
     $form->addElement($fieldDescription);
     $fieldCategory = new CheckboxGroup('ct');
     $form->addElement($fieldCategory);
     $submit = new Submit('upload');
     $submit->setValue($this->text('spdownload', 'form_label_submit_up'));
     $form->addElement($submit);
     $this->addForm($form);
     $this->assign('flag', $flag);
     if (OW::getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             if (!empty($params) && isset($params['fileId'])) {
                 if (!empty($_POST['ct'])) {
                     $arrayAdd = array_diff($_POST['ct'], $arrayCheckCategory);
                     $arrayDelete = array_diff($arrayCheckCategory, $_POST['ct']);
                     foreach ($arrayDelete as $key => $value) {
                         SPDOWNLOAD_BOL_FileCategoryService::getInstance()->deleteId($params['fileId'], $value);
                     }
                     foreach ($arrayAdd as $key => $value) {
                         SPDOWNLOAD_BOL_FileCategoryService::getInstance()->addFileCategory($params['fileId'], $value);
                     }
                 } else {
                     SPDOWNLOAD_BOL_FileCategoryService::getInstance()->deleteId($params['fileId'], null);
                 }
             }
             $arrayFile = array();
             $arrayFile['id'] = null;
             if (!empty($params) && isset($params['fileId'])) {
                 $arrayFile['id'] = $params['fileId'];
             }
             $arrayFile['name'] = $_POST['upname'];
             $arrayFile['description'] = $_POST['updescription'];
             $arrayFile['slug'] = $_POST['upslug'];
             $arrayFile['authorId'] = OW::getUser()->getId();
             $arrayFile['addedTime'] = time();
             SPDOWNLOAD_BOL_FileService::getInstance()->addFile($arrayFile);
             if (isset($arrayFile['id']) && !empty($arrayFile['id'])) {
             } else {
                 $fileNew = SPDOWNLOAD_BOL_FileService::getInstance()->getIdNew($arrayFile);
                 $arrayFile['id'] = $fileNew[0]->id;
             }
             if (empty($params) && !isset($params['fileId'])) {
                 if (isset($_POST['ct']) && !empty($_POST['ct'])) {
                     foreach ($_POST['ct'] as $key => $value) {
                         SPDOWNLOAD_BOL_FileCategoryService::getInstance()->addFileCategory($arrayFile['id'], $value);
                     }
                 }
             }
             $arrayInputFile = array();
             $arrayInputFile['size'] = $_FILES['upfile']['size'];
             $arrayInputFile['name'] = $_FILES['upfile']['name'];
             $arrayInputFile['type'] = $_FILES['upfile']['type'];
             $arrayInputFile['tmp_name'] = $_FILES['upfile']['tmp_name'];
             $arrayInputFile['error'] = $_FILES['upfile']['error'];
             $arrayInputFile['addedTime'] = $arrayFile['addedTime'];
             $arrayInputFile['fileId'] = $arrayFile['id'];
             $path = SPDOWNLOAD_BOL_FileService::getInstance()->getFilePath();
             if ($arrayInputFile['error'] == 0) {
                 SPDOWNLOAD_BOL_VersionService::getInstance()->addVersion($arrayInputFile);
                 $verNew = SPDOWNLOAD_BOL_VersionService::getInstance()->getIdVer($arrayInputFile);
                 $arrayInputFile['id'] = $verNew[0]->id;
                 SPDOWNLOAD_BOL_FileService::getInstance()->move_file($arrayInputFile['tmp_name'], $path, $arrayInputFile['id']);
             }
             if ($_FILES['upicon']['error'] == 0 && !empty($_FILES['upicon']['name'])) {
                 SPDOWNLOAD_BOL_FileService::getInstance()->copy_resize_image($_FILES['upicon']['tmp_name'], 'icon_small', $arrayFile['id'], 'png', 48, 48);
                 SPDOWNLOAD_BOL_FileService::getInstance()->copy_resize_image($_FILES['upicon']['tmp_name'], 'icon_large', $arrayFile['id'], 'png', 128, 128);
             }
             foreach ($_FILES['upthumb']['tmp_name'] as $key => $value) {
                 if ($_FILES['upthumb']['error'][$key] == 0 && !empty($_FILES['upthumb']['name'][$key])) {
                     SPDOWNLOAD_BOL_FileThumbService::getInstance()->addThumb($arrayFile['id'], $key);
                     SPDOWNLOAD_BOL_FileService::getInstance()->copy_resize_image($_FILES['upthumb']['tmp_name'][$key], $arrayFile['id'] . '_thumb_small', $key, 'jpg', 360, 180);
                     SPDOWNLOAD_BOL_FileService::getInstance()->copy_resize_image($_FILES['upthumb']['tmp_name'][$key], $arrayFile['id'] . '_thumb_large', $key, 'jpg', 720, 360);
                 }
             }
         }
         $this->redirect(OW::getRouter()->urlForRoute('spdownload.up_myfile', array('userId' => OW::getUser()->getId())));
     }
 }
Example #10
0
 public function upload()
 {
     if (!OW::getUser()->isAuthorized('ivideo', 'add')) {
         $this->setTemplate(OW::getPluginManager()->getPlugin('base')->getCtrlViewDir() . 'authorization_failed.html');
         return;
     }
     $eventParams = array('pluginKey' => 'ivideo', 'action' => 'upload_video');
     $credits = OW::getEventManager()->call('usercredits.check_balance', $eventParams);
     if ($credits === false) {
         $this->assign('authMsg', OW::getEventManager()->call('usercredits.error_message', $eventParams));
         return;
     } else {
         $this->assign('authMsg', null);
     }
     $language = OW::getLanguage();
     $config = OW::getConfig();
     $uploadForm = new Form('uploadForm');
     $uploadForm->setId('THEFORM');
     $uploadForm->setEnctype('multipart/form-data');
     $element = new TextField('videoName');
     $element->setRequired(true);
     $element->addValidator(new uploadValidator());
     $element->setLabel($language->text('ivideo', 'upload_video_name'));
     $uploadForm->addElement($element);
     $element = new WysiwygTextarea('videoDescription');
     $element->setRequired(true);
     $element->setLabel($language->text('ivideo', 'upload_video_desc'));
     $uploadForm->addElement($element);
     $element = new Selectbox('videoCategory');
     $element->setRequired(true);
     $element->setLabel($language->text('ivideo', 'admin_video_category'));
     foreach (IVIDEO_BOL_CategoryDao::getInstance()->findAll() as $category) {
         $element->addOption($category->id, $category->name);
     }
     $uploadForm->addElement($element);
     $tagService = BOL_TagService::getInstance();
     $tf = new TagsField('tf');
     $tf->setLabel($language->text('ivideo', 'tags_field_label'));
     $uploadForm->addElement($tf);
     $element = new Submit('uploadVideo');
     $element->setValue($language->text('ivideo', 'user_upload_video'));
     $uploadForm->addElement($element);
     if (OW::getRequest()->isPost()) {
         if ($uploadForm->isValid($_POST) && isset($_POST['ax-uploaded-files'])) {
             $values = $uploadForm->getValues();
             $fileName = OW::getSession()->get('ivideo.filename');
             if (is_null($fileName)) {
                 OW::getFeedback()->error($language->text('ivideo', 'admin_video_not_uploaded_error'));
             } else {
                 $video = new IVIDEO_BOL_Video();
                 $video->name = ucwords(UTIL_HtmlTag::stripTags($values['videoName']));
                 $description = UTIL_HtmlTag::stripJs($values['videoDescription']);
                 $description = UTIL_HtmlTag::stripTags($description, array('frame', 'style'), array(), true);
                 $video->description = $description;
                 $video->owner = OW::getuser()->getId();
                 $video->timestamp = time();
                 $video->status = $config->getValue('ivideo', 'videoApproval') == 'auto' ? 'approved' : 'pending';
                 $video->filename = $fileName;
                 $videoId = IVIDEO_BOL_Service::getInstance()->addVideo($video);
                 if ($videoId) {
                     $fullFileName = OW::getPluginManager()->getPlugin('ivideo')->getUserFilesDir() . $fileName;
                     $imageFileName = OW::getPluginManager()->getPlugin('ivideo')->getUserFilesDir() . $fileName . ".png";
                     $ffmpegPath = $config->getValue('ivideo', 'ffmpegPath');
                     if (!empty($ffmpegPath) && file_exists($ffmpegPath)) {
                         exec("{$ffmpegPath} -y -itsoffset -4 -i '{$fullFileName}' -r 1 -f image2 '{$imageFileName}'");
                     }
                     IVIDEO_BOL_VideoCategoryService::getInstance()->setVideoCategories($videoId, $values['videoCategory']);
                     BOL_TagService::getInstance()->updateEntityTags($video->id, 'ivideo-video', TagsField::getTags($values['tf']));
                     $event = new OW_Event('feed.action', array('pluginKey' => 'ivideo', 'entityType' => 'ivideo-comments', 'entityId' => $video->id, 'userId' => $video->owner));
                     OW::getEventManager()->trigger($event);
                     $this->redirect(OW::getRouter()->urlForRoute('ivideo_view_list', array('type' => 'latest')));
                     OW::getFeedback()->info($language->text('ivideo', 'admin_upload_video_ok'));
                 } else {
                     OW::getFeedback()->error($language->text('ivideo', 'admin_upload_video_fail'));
                 }
             }
         }
     }
     $this->addForm($uploadForm);
     if (OW::getSession()->isKeySet('ivideo.filename')) {
         OW::getSession()->delete('ivideo.filename');
     }
     $jsURL = OW::getPluginManager()->getPlugin('ivideo')->getStaticUrl() . 'ajaxupload' . '/';
     $this->assign('filesDir', json_encode(OW::getPluginManager()->getPlugin('ivideo')->getUserFilesDir()));
     $this->assign('uploadAction', json_encode(OW::getRouter()->urlFor('IVIDEO_CTRL_Upload', 'action')));
     $this->assign('maxSize', $config->getValue('ivideo', 'allowedFileSize'));
     $this->assign('allowedExtn', UTIL_String::arrayToDelimitedString(explode(",", $config->getValue('ivideo', 'allowedExtensions')), ",", "'", "'"));
     $this->assign('allowedExtnText', UTIL_String::arrayToDelimitedString(explode(",", $config->getValue('ivideo', 'allowedExtensions')), ","));
     $this->assign('flashURL', $jsURL);
     $this->assign('videoApproval', $config->getValue('ivideo', 'videoApproval'));
     $theme = $config->getValue('ivideo', 'theme');
     OW::getDocument()->addStyleSheet($jsURL . 'css/' . $theme . '/style.css');
     OW::getDocument()->addScript($jsURL . "js/ajaxupload-min.js");
     $this->setPageHeading(OW::getLanguage()->text('ivideo', 'video_user_upload'));
     $this->setPageTitle(OW::getLanguage()->text('ivideo', 'video_user_upload'));
     $this->setPageHeadingIconClass('ow_ic_video');
 }
Example #11
0
 public function chooseTheme()
 {
     $language = OW::getLanguage();
     $this->themeService->updateThemeList();
     $this->themeService->updateThemesInfo();
     $themes = $this->themeService->findAllThemes();
     $themesInfo = array();
     $activeTheme = OW::getThemeManager()->getSelectedTheme()->getDto()->getName();
     /* @var $theme BOL_Theme */
     foreach ($themes as $theme) {
         $themesInfo[$theme->getName()] = (array) json_decode($theme->getDescription());
         $themesInfo[$theme->getName()]['key'] = $theme->getName();
         $themesInfo[$theme->getName()]['title'] = $theme->getTitle();
         $themesInfo[$theme->getName()]['iconUrl'] = $this->themeService->getStaticUrl($theme->getName()) . BOL_ThemeService::ICON_FILE;
         $themesInfo[$theme->getName()]['previewUrl'] = $this->themeService->getStaticUrl($theme->getName()) . BOL_ThemeService::PREVIEW_FILE;
         $themesInfo[$theme->getName()]['active'] = $theme->getName() === $activeTheme;
         $themesInfo[$theme->getName()]['changeUrl'] = OW::getRouter()->urlFor(__CLASS__, 'changeTheme', array('theme' => $theme->getName()));
         $themesInfo[$theme->getName()]['update_url'] = (int) $theme->getUpdate() === 1 && !defined('OW_PLUGIN_XP') ? OW::getRouter()->urlFor('ADMIN_CTRL_Themes', 'updateRequest', array('name' => $theme->getName())) : false;
         if (!in_array($theme->getName(), array(BOL_ThemeService::DEFAULT_THEME, $activeTheme))) {
             $themesInfo[$theme->getName()]['delete_url'] = OW::getRouter()->urlFor(__CLASS__, 'deleteTheme', array('name' => $theme->getName()));
         }
     }
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('admin')->getStaticJsUrl() . 'theme_select.js');
     OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('base')->getStaticJsUrl() . 'jquery.sticky.js');
     $addData = array('deleteConfirmMsg' => $language->text('admin', 'themes_choose_delete_confirm_msg'), 'deleteActiveThemeMsg' => $language->text('admin', 'themes_cant_delete_active_theme'));
     OW::getDocument()->addOnloadScript("window.owThemes = new ThemesSelect(" . json_encode($themesInfo) . ", " . json_encode($addData) . ");\n        \t\$('.selected_theme_info input.theme_select_submit').click(function(){\n    \t\t\twindow.location.href = '" . $themesInfo[$activeTheme]['changeUrl'] . "';\n    \t\t});\n            \$('.selected_theme_info_stick').sticky({topSpacing:60});\n            \$('.admin_themes_select a.theme_icon').click( function(){ \$('.theme_info .theme_control_button').hide(); });");
     $this->assign("adminThemes", array(BOL_ThemeService::DEFAULT_THEME => $themesInfo[BOL_ThemeService::DEFAULT_THEME]));
     $this->assign('themeInfo', $themesInfo[$activeTheme]);
     $event = new OW_Event("admin.filter_themes_to_choose", array(), $themesInfo);
     OW::getEventManager()->trigger($event);
     $this->assign('themes', $event->getData());
     // add theme
     $form = new Form('theme-add');
     $form->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA);
     $file = new FileField('file');
     $form->addElement($file);
     $submit = new Submit('submit');
     $submit->setValue($language->text('admin', 'plugins_manage_add_submit_label'));
     $form->addElement($submit);
     $this->addForm($form);
     if (OW::getRequest()->isPost()) {
         if ($form->isValid($_POST)) {
             $data = $form->getValues();
             $uploadMaxFilesize = (double) ini_get("upload_max_filesize");
             $postMaxSize = (double) ini_get("post_max_size");
             $serverLimit = $uploadMaxFilesize < $postMaxSize ? $uploadMaxFilesize : $postMaxSize;
             if ($_FILES['file']['error'] != UPLOAD_ERR_OK && $_FILES['file']['error'] == UPLOAD_ERR_INI_SIZE || (empty($_FILES['file']) || $_FILES['file']['size'] > $serverLimit * 1024 * 1024)) {
                 OW::getFeedback()->error($language->text('admin', 'manage_plugins_add_size_error_message', array('limit' => $serverLimit)));
                 $this->redirect(OW::getRouter()->urlForRoute('admin_themes_choose'));
             }
             if ($_FILES['file']['error'] != UPLOAD_ERR_OK) {
                 switch ($_FILES['file']['error']) {
                     case UPLOAD_ERR_INI_SIZE:
                         $error = $language->text('base', 'upload_file_max_upload_filesize_error');
                         break;
                     case UPLOAD_ERR_PARTIAL:
                         $error = $language->text('base', 'upload_file_file_partially_uploaded_error');
                         break;
                     case UPLOAD_ERR_NO_FILE:
                         $error = $language->text('base', 'upload_file_no_file_error');
                         break;
                     case UPLOAD_ERR_NO_TMP_DIR:
                         $error = $language->text('base', 'upload_file_no_tmp_dir_error');
                         break;
                     case UPLOAD_ERR_CANT_WRITE:
                         $error = $language->text('base', 'upload_file_cant_write_file_error');
                         break;
                     case UPLOAD_ERR_EXTENSION:
                         $error = $language->text('base', 'upload_file_invalid_extention_error');
                         break;
                     default:
                         $error = $language->text('base', 'upload_file_fail');
                 }
                 OW::getFeedback()->error($error);
                 $this->redirect(OW::getRouter()->urlForRoute('admin_themes_choose'));
             }
             if (!is_uploaded_file($_FILES['file']['tmp_name'])) {
                 OW::getFeedback()->error($language->text('admin', 'manage_themes_add_empty_field_error_message'));
                 $this->redirect(OW::getRouter()->urlForRoute('admin_themes_choose'));
             }
             $tempFile = OW_DIR_PLUGINFILES . 'ow' . DS . uniqid('theme_add') . '.zip';
             $tempDir = OW_DIR_PLUGINFILES . 'ow' . DS . uniqid('theme_add') . DS;
             copy($_FILES['file']['tmp_name'], $tempFile);
             $zip = new ZipArchive();
             if ($zip->open($tempFile) === true) {
                 $zip->extractTo($tempDir);
                 $zip->close();
             } else {
                 OW::getFeedback()->error(OW::getLanguage()->text('admin', 'manage_theme_add_extract_error'));
                 $this->redirect(OW::getRouter()->urlForRoute('admin_themes_choose'));
             }
             unlink($tempFile);
             $this->redirect(OW::getRequest()->buildUrlQueryString(OW::getRouter()->urlFor(__CLASS__, 'processAdd'), array('dir' => urlencode($tempDir))));
         }
     }
 }
Example #12
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'))) . ") ");
 }
 public function upload()
 {
     $form = new Form('form-upload', Router::getInstance()->build('UploadController', 'upload'));
     $form->setAttribute('data-noajax', 'true');
     $form->setEnctype();
     $fieldset = new Fieldset(System::getLanguage()->_('General'));
     $folderInput = new Select('folder', System::getLanguage()->_('ChooseFolder'), Folder::getAll());
     $folderInput->selected_value = Utils::getGET('parent', NULL);
     $fieldset->addElements($folderInput);
     $form->addElements($fieldset);
     $fieldset = new Fieldset(System::getLanguage()->_('FileUpload'));
     $fileInput = new FileUpload('file', System::getLanguage()->_('ChooseFile'), false);
     $fieldset->addElements($fileInput);
     $form->addElements($fieldset);
     if (DOWNLOAD_VIA_SERVER) {
         $fieldset = new Fieldset(System::getLanguage()->_('UploadFromURL'));
         $url = new Text('url', System::getLanguage()->_('EnterURL'), false);
         $name = new Text('name', System::getLanguage()->_('Name'), false);
         $name->setValue(System::getLanguage()->_('DownloadedFile'));
         $fieldset->addElements($url, $name);
         $form->addElements($fieldset);
     }
     $fieldset = new Fieldset(System::getLanguage()->_('PermissionSetting'));
     $permissionInput = new Select('permissions', System::getLanguage()->_('Permission'), FilePermissions::getAll());
     $permissionInput->selected_value = DEFAULT_FILE_PERMISSION;
     $password = new Password('password', System::getLanguage()->_('Password'), false);
     $fieldset->addElements($permissionInput, $password);
     $form->addElements($fieldset);
     if (Utils::getPOST('submit', false) != false) {
         if ($permissionInput->selected_value == 2 && empty($password->value)) {
             $password->error = System::getLanguage()->_('ErrorEmptyTextfield');
         } else {
             if ($form->validate() && (!empty($url->value) || !empty($fileInput->uploaded_file))) {
                 // Specify input control for error display
                 $err = empty($url->value) ? $fileInput : $url;
                 try {
                     $folder = Folder::find('_id', $folderInput->selected_value);
                     $file = new File();
                     $file->folder = $folder;
                     $file->permission = $permissionInput->selected_value;
                     $file->password = $password->value;
                     if (empty($url->value)) {
                         $file->filename = $fileInput->filename;
                         $file->upload($fileInput->uploaded_file);
                     } else {
                         $file->filename = $name->value;
                         $file->remote($url->value);
                     }
                     $file->save();
                     System::forwardToRoute(Router::getInstance()->build('BrowserController', 'show', $folder));
                     exit;
                 } catch (UploadException $e) {
                     $fileInput->filename = '';
                     $fileInput->uploaded_file = '';
                     $err->error = $e->getMessage();
                     if ($e->getCode() != 0) {
                         $err->error .= ' Code: ' . $e->getCode();
                     }
                 } catch (QuotaExceededException $e) {
                     $err->error = System::getLanguage()->_('ErrorQuotaExceeded');
                 } catch (Exception $e) {
                     $fileInput->filename = '';
                     $fileInput->uploaded_file = '';
                     $err->error = System::getLanguage()->_('ErrorWhileUpload') . ' ' . $e->getMessage();
                 }
             }
         }
     }
     $form->setSubmit(new Button(System::getLanguage()->_('Upload'), 'open'));
     if ($folderInput->selected_value == 0) {
         $form->addButton(new Button(System::getLanguage()->_('Cancel'), '', Router::getInstance()->build('BrowserController', 'index')));
     } else {
         $form->addButton(new Button(System::getLanguage()->_('Cancel'), '', Router::getInstance()->build('BrowserController', 'show', new Folder($folderInput->selected_value))));
     }
     $smarty = new Template();
     $smarty->assign('title', System::getLanguage()->_('Upload'));
     $smarty->assign('heading', System::getLanguage()->_('FileUpload'));
     $smarty->assign('form', $form->__toString());
     $smarty->assign('BODY_CLASS', 'preventreload');
     $smarty->requireResource('upload');
     $smarty->display('form.tpl');
 }
Example #14
0
 /**
  * Generates Add Topic Form.
  *
  * @param array $groupSelect
  * @param int $groupId
  * @return Form
  */
 private function generateForm($groupSelect, $groupId, $isHidden)
 {
     $form = new Form('add-topic-form');
     $form->setEnctype("multipart/form-data");
     $lang = OW::getLanguage();
     $title = new TextField('title');
     $title->setRequired(true);
     $sValidator = new StringValidator(1, 255);
     $sValidator->setErrorMessage($lang->text('forum', 'chars_limit_exceeded', array('limit' => 255)));
     $title->addValidator($sValidator);
     $form->addElement($title);
     if ($isHidden) {
         $group = new HiddenField('group');
         $group->setValue($groupId);
     } else {
         $group = new ForumSelectBox('group');
         $group->setOptions($groupSelect);
         if ($groupId) {
             $group->setValue($groupId);
         }
         $group->setRequired(true);
         $group->addValidator(new IntValidator());
     }
     $form->addElement($group);
     $btnSet = array(BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_VIDEO, BOL_TextFormatService::WS_BTN_HTML);
     $text = new WysiwygTextarea('text', $btnSet);
     $text->setRequired(true);
     $sValidator = new StringValidator(1, 50000);
     $sValidator->setErrorMessage($lang->text('forum', 'chars_limit_exceeded', array('limit' => 50000)));
     $text->addValidator($sValidator);
     $form->addElement($text);
     $subscribe = new CheckboxField('subscribe');
     $subscribe->setLabel($lang->text('forum', 'subscribe'));
     $subscribe->setValue(true);
     $form->addElement($subscribe);
     $post = new Submit('post');
     $post->setValue($lang->text('forum', 'add_post_btn'));
     $form->addElement($post);
     $attachmentField = new MultiFileField('attachments', 5);
     $form->addElement($attachmentField);
     $this->addForm($form);
     return $form;
 }
Example #15
0
 /**
  * Generates edit topic form.
  *
  * @param $topicDto
  * @param $postDto
  * @param $uid
  * @return Form
  */
 private function generateEditTopicForm($topicDto, $postDto, $uid)
 {
     $form = new Form('edit-topic-form');
     $form->setEnctype('multipart/form-data');
     $lang = OW::getLanguage();
     $topicIdField = new HiddenField('topic-id');
     $topicIdField->setValue($topicDto->id);
     $form->addElement($topicIdField);
     $postIdField = new HiddenField('post-id');
     $postIdField->setValue($postDto->id);
     $form->addElement($postIdField);
     $attachmentUid = new HiddenField('attachmentUid');
     $attachmentUid->setValue($uid);
     $attachmentUid->setRequired(true);
     $form->addElement($attachmentUid);
     $topicTitleField = new TextField('title');
     $topicTitleField->setValue($topicDto->title);
     $topicTitleField->setRequired(true);
     $sValidator = new StringValidator(1, 255);
     $sValidator->setErrorMessage($lang->text('forum', 'chars_limit_exceeded', array('limit' => 255)));
     $topicTitleField->addValidator($sValidator);
     $form->addElement($topicTitleField);
     $btnSet = array(BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_VIDEO, BOL_TextFormatService::WS_BTN_HTML);
     $postText = new WysiwygTextarea('text', $btnSet);
     $postText->setValue($postDto->text);
     $postText->setRequired(true);
     $sValidator = new StringValidator(1, 50000);
     $sValidator->setErrorMessage($lang->text('forum', 'chars_limit_exceeded', array('limit' => 50000)));
     $postText->addValidator($sValidator);
     $form->addElement($postText);
     $submit = new Submit('save');
     $submit->setValue($lang->text('base', 'edit_button'));
     $form->addElement($submit);
     return $form;
 }
Example #16
0
 /**
  * Generates add post form.
  *
  * @param int $topicId
  * @param string $uid
  * @return Form
  */
 private function generateAddPostForm($topicId, $uid)
 {
     $form = new Form('add-post-form');
     $form->setEnctype('multipart/form-data');
     $lang = OW::getLanguage();
     $addPostUrl = OW::getRouter()->urlForRoute('add-post', array('topicId' => $topicId, 'uid' => $uid));
     $form->setAction($addPostUrl);
     $topicIdField = new HiddenField('topic');
     $topicIdField->setValue($topicId);
     $form->addElement($topicIdField);
     $attachmentUid = new HiddenField('attachmentUid');
     $attachmentUid->setValue($uid);
     $attachmentUid->setRequired(true);
     $form->addElement($attachmentUid);
     $btnSet = array(BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_VIDEO, BOL_TextFormatService::WS_BTN_HTML);
     $postText = new WysiwygTextarea('text', $btnSet);
     $postText->setRequired(true);
     $sValidator = new StringValidator(1, 50000);
     $sValidator->setErrorMessage($lang->text('forum', 'chars_limit_exceeded', array('limit' => 50000)));
     $postText->addValidator($sValidator);
     $form->addElement($postText);
     $submit = new Submit('submit');
     $submit->setValue($lang->text('forum', 'add_post_btn'));
     $form->addElement($submit);
     return $form;
 }
Example #17
0
 public function sponsor()
 {
     $language = OW::getLanguage();
     $config = OW::getConfig();
     $sponsorForm = new Form('sponsorForm');
     $sponsorForm->setEnctype('multipart/form-data');
     $element = new TextField('sponsorName');
     $element->setRequired(true);
     $element->setLabel($language->text('sponsors', 'sponsor_name'));
     $element->setInvitation($language->text('sponsors', 'sponsor_name_desc'));
     $element->setHasInvitation(true);
     $sponsorForm->addElement($element);
     $element = new TextField('sponsorEmail');
     $element->setRequired(true);
     $validator = new EmailValidator();
     $validator->setErrorMessage($language->text('sponsors', 'invalid_email_format'));
     $element->addValidator($validator);
     $element->setLabel($language->text('sponsors', 'sponsor_email'));
     $element->setInvitation($language->text('sponsors', 'sponsor_email_desc'));
     $element->setHasInvitation(true);
     $sponsorForm->addElement($element);
     $element = new TextField('sponsorWebsite');
     $element->setRequired(true);
     $validator = new UrlValidator();
     $validator->setErrorMessage($language->text('sponsors', 'invalid_url_format'));
     $element->addValidator($validator);
     $element->setLabel($language->text('sponsors', 'sponsor_website'));
     $element->setInvitation($language->text('sponsors', 'sponsor_website_desc'));
     $element->setHasInvitation(true);
     $sponsorForm->addElement($element);
     if ($config->getValue('sponsors', 'minimumPayment') > 0) {
         $element = new TextField('sponsorAmount');
         $element->setRequired(true);
         $element->setValue($config->getValue('sponsors', 'minimumPayment'));
         $minAmount = $config->getValue('sponsors', 'minimumPayment');
         $validator = new FloatValidator($minAmount);
         $validator->setErrorMessage($language->text('sponsors', 'invalid_sponsor_amount', array('minAmount' => $minAmount)));
         $element->addValidator($validator);
         $element->setLabel($language->text('sponsors', 'sponsor_payment_amount'));
         $element->setInvitation($language->text('sponsors', 'sponsor_payment_amount_desc', array('minAmount' => $minAmount)));
         $element->setHasInvitation(true);
         $sponsorForm->addElement($element);
     }
     $element = new FileField('sponsorImage');
     $element->setLabel($language->text('sponsors', 'sponsorsh_image_file'));
     $sponsorForm->addElement($element);
     if ($config->getValue('sponsors', 'minimumPayment') > 0) {
         $element = new BillingGatewaySelectionField('gateway');
         $element->setRequired(true);
         $element->setLabel($language->text('sponsors', 'payment_gatway_selection'));
         $sponsorForm->addElement($element);
     }
     $element = new Submit('becomeSponsor');
     $element->setValue(OW::getLanguage()->text('sponsors', 'become_sponsor_btn'));
     $sponsorForm->addElement($element);
     if (OW::getRequest()->isPost()) {
         if ($sponsorForm->isValid($_POST)) {
             $values = $sponsorForm->getValues();
             if (isset($_FILES['sponsorImage']) && in_array(UTIL_File::getExtension($_FILES['sponsorImage']['name']), $this->allowedImageExtensions)) {
                 $backupPath = OW::getPluginManager()->getPlugin('sponsors')->getUserFilesDir() . $_FILES['sponsorImage']['name'];
                 move_uploaded_file($_FILES['sponsorImage']['tmp_name'], $backupPath);
                 $sponsorImageFile = $_FILES['sponsorImage']['name'];
             } else {
                 $sponsorImageFile = "defaultSponsor.jpg";
             }
             if (isset($values['sponsorAmount']) && $values['gateway']) {
                 $billingService = BOL_BillingService::getInstance();
                 if (empty($values['gateway']['url']) || empty($values['gateway']['key']) || !($gateway = $billingService->findGatewayByKey($values['gateway']['key']) || !$gateway->active)) {
                     OW::getFeedback()->error($language->text('base', 'billing_gateway_not_found'));
                     $this->redirect();
                 }
                 $productAdapter = new SPONSORS_CLASS_SponsorProductAdapter();
                 $sale = new BOL_BillingSale();
                 $sale->pluginKey = 'sponsors';
                 $sale->entityDescription = $language->text('sponsors', 'sponsor_payment_gateway_text');
                 $sale->entityKey = $productAdapter->getProductKey();
                 $sale->entityId = time();
                 $sale->price = floatval($values['sponsorAmount']);
                 $sale->period = null;
                 $sale->userId = OW::getUser()->getId() ? OW::getUser()->getId() : 0;
                 $sale->recurring = 0;
                 $extraData = array();
                 $extraData['sponsorName'] = $values['sponsorName'];
                 $extraData['sponsorEmail'] = $values['sponsorEmail'];
                 $extraData['sponsorWebsite'] = $values['sponsorWebsite'];
                 $extraData['sponsorAmount'] = $values['sponsorAmount'];
                 $extraData['sponsorImage'] = $sponsorImageFile;
                 $extraData['status'] = $config->getValue('sponsors', 'autoApprove') == '1' ? 1 : 0;
                 $extraData['validity'] = $config->getValue('sponsors', 'sponsorValidity');
                 $sale->setExtraData($extraData);
                 $saleId = $billingService->initSale($sale, $values['gateway']['key']);
                 if ($saleId) {
                     $billingService->storeSaleInSession($saleId);
                     $billingService->setSessionBackUrl($productAdapter->getProductOrderUrl());
                     OW::getApplication()->redirect($values['gateway']['url']);
                 }
             } else {
                 $sponsor = new SPONSORS_BOL_Sponsor();
                 $sponsor->name = $values['sponsorName'];
                 $sponsor->email = $values['sponsorEmail'];
                 $sponsor->website = $values['sponsorWebsite'];
                 $sponsor->price = 0;
                 $sponsor->image = $sponsorImageFile;
                 $sponsor->userId = OW::getUser()->getId() ? OW::getUser()->getId() : 0;
                 $sponsor->status = $config->getValue('sponsors', 'autoApprove') == '1' ? 1 : 0;
                 $sponsor->validity = $config->getValue('sponsors', 'sponsorValidity');
                 $sponsor->timestamp = time();
                 if (SPONSORS_BOL_Service::getInstance()->addSponsor($sponsor)) {
                     if ($sponsor->status == 1) {
                         OW::getFeedback()->info(OW::getLanguage()->text('sponsors', 'sponsor_live_notification'));
                     } else {
                         OW::getFeedback()->info(OW::getLanguage()->text('sponsors', 'sponsor_live_notification_after_approval'));
                     }
                 } else {
                     OW::getFeedback()->error(OW::getLanguage()->text('sponsors', 'sponsor_add_error'));
                 }
             }
         }
     }
     $this->addForm($sponsorForm);
     $fields = array();
     foreach ($sponsorForm->getElements() as $element) {
         if (!$element instanceof HiddenField) {
             $fields[$element->getName()] = $element->getName();
         }
     }
     $this->assign('formData', $fields);
     $this->setPageHeading(OW::getLanguage()->text('sponsors', 'become_sponsor_heading'));
     $this->setPageTitle(OW::getLanguage()->text('sponsors', 'become_sponsor_title'));
     $this->setPageHeadingIconClass('ow_ic_gear_wheel');
 }