function __construct($oModule, $aParam = array())
 {
     $this->_oModule = $oModule;
     $this->_aParam = $aParam;
     if (count($aParam) && isset($aParam['photo']) && $aParam['photo'] != 0) {
         $aFile = BxDolService::call('photos', 'get_photo_array', array($aParam['photo'], 'browse'), 'Search');
         if (!$aFile['no_image']) {
             $aParam = array_merge($aParam, array('thumbnail' => $GLOBALS['oBxSitesModule']->_oTemplate->parseHtmlByName('thumb110.html', array('image' => $aFile['file'], 'spacer' => getTemplateIcon('spacer.gif')))));
         }
     }
     $this->_aCustomForm = $this->getFullForm();
     $this->_aCustomForm['form_attrs']['action'] = BX_DOL_URL_ROOT . $this->_oModule->_oConfig->getBaseUri() . 'edit/' . $aParam['id'];
     $oCategories = new BxDolCategories();
     $oCategories->getTagObjectConfig();
     $this->_aCustomForm['inputs']['categories'] = $oCategories->getGroupChooser('bx_sites', (int) $this->_oModule->iOwnerId, true, $this->_aParam['categories']);
     $aFormInputsSubmit = array('Submit' => array('type' => 'submit', 'name' => 'submit_form', 'value' => _t('_Submit'), 'colspan' => false));
     $this->_aCustomForm['inputs'] = array_merge($this->_aCustomForm['inputs'], $aFormInputsSubmit);
     parent::__construct($this->_aCustomForm);
 }
示例#2
0
 function _addSiteForm()
 {
     bx_sites_import('FormAdd');
     $oForm = new BxSitesFormAdd($this);
     $sMsgBox = '';
     if (isset($_POST['url'])) {
         if (isset($_POST['title'])) {
             $aParam = array('url' => process_pass_data($_POST['url']));
             if (isset($_POST['thumbnail_html'])) {
                 $this->_addThumbToForm($_POST['thumbnail_html'], $aParam);
             }
             $oForm = new BxSitesFormAdd($this, $aParam);
             $oForm->initChecker();
             if ($oForm->isSubmittedAndValid()) {
                 $sCategories = implode(';', array_unique(explode(';', $oForm->getCleanValue('categories'))));
                 $sEntryUri = getEntryUri($_POST['title']);
                 unset($oForm->aInputs['categories']);
                 $aValsAdd = array('date' => time(), 'entryUri' => $oForm->generateUri(), 'status' => $this->_oConfig->_bAutoapprove || $this->isAdmin() ? 'approved' : 'pending', 'categories' => $sCategories);
                 if (isset($_FILES['photo']['tmp_name']) && $_FILES['photo']['tmp_name']) {
                     $aValsAdd['photo'] = $oForm->uploadPhoto($_FILES['photo']['tmp_name']);
                 }
                 $aValsAdd['ownerid'] = $this->iOwnerId;
                 if ($iSiteId = $oForm->insert($aValsAdd)) {
                     $this->isAllowedAdd(true);
                     $this->onSiteCreate($iSiteId, $aValsAdd['status']);
                     header('Location:' . BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'browse/my');
                 } else {
                     $sMsgBox = MsgBox(_t('_bx_sites_error_occured'));
                 }
             }
         } else {
             $oForm->initChecker();
             if ($oForm->isSubmittedAndValid()) {
                 $sUrl = process_pass_data($_POST['url']);
                 $sUrlFull = strncasecmp($sUrl, 'http://', 7) != 0 && strncasecmp($sUrl, 'https://', 8) != 0 ? 'http://' . $sUrl : $sUrl;
                 $aSite = $this->_oDb->getSiteByUrl($sUrl);
                 if (count($aSite) == 0) {
                     $aInfo = getSiteInfo($sUrlFull);
                     if (!empty($aInfo)) {
                         $aParam = array('url' => $sUrl, 'title' => $aInfo['title'], 'description' => $aInfo['description']);
                         // BEGIN STW INTEGRATION
                         if (getParam('bx_sites_account_type') != 'No Automated Screenshots') {
                             $aSTWOptions = array();
                             bx_sites_import('STW');
                             $sThumbHTML = getThumbnailHTML($sUrlFull, $aSTWOptions, false, false);
                             if ($sThumbHTML) {
                                 $this->_addThumbToForm($sThumbHTML, $aParam);
                             }
                         }
                         // END STW INTEGRATION
                         $oForm = new BxSitesFormAdd($this, $aParam);
                     } else {
                         $sMsgBox = MsgBox(_t('_bx_sites_site_link_error'));
                         $oForm->aInputs['url']['value'] = $sUrl;
                     }
                 } else {
                     header('Location:' . BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/' . $aSite['entryUri']);
                 }
             }
         }
     }
     return $sMsgBox . $this->_oTemplate->parseHtmlByName('form.html', array('form' => $oForm->getCode()));
 }
示例#3
0
 function _addSiteForm()
 {
     bx_sites_import('FormAdd');
     $oForm = new BxSitesFormAdd($this);
     $sMsgBox = '';
     if (isset($_POST['url'])) {
         if (isset($_POST['title'])) {
             $aParam = array('url' => $_POST['url']);
             if (isset($_POST['thumbnail_url'])) {
                 $this->_addThumbToForm($_POST['thumbnail_url'], $aParam);
             }
             $oForm = new BxSitesFormAdd($this, $aParam);
             $oForm->initChecker();
             if ($oForm->isSubmittedAndValid()) {
                 $sCategories = implode(';', array_unique(explode(';', $oForm->getCleanValue('categories'))));
                 $sEntryUri = getEntryUri($_POST['title']);
                 unset($oForm->aInputs['categories']);
                 $aValsAdd = array('date' => time(), 'entryUri' => $oForm->generateUri(), 'status' => $this->_oConfig->_bAutoapprove || $this->isAdmin() ? 'approved' : 'pending', 'categories' => $sCategories);
                 if (isset($_FILES['photo']['tmp_name']) && $_FILES['photo']['tmp_name']) {
                     $aValsAdd['photo'] = $oForm->uploadPhoto($_FILES['photo']['tmp_name']);
                 } else {
                     if (isset($_POST['thumbnail_url'])) {
                         $aValsAdd['photo'] = $oForm->uploadPhoto($_POST['thumbnail_url'], true);
                     }
                 }
                 $aValsAdd['ownerid'] = $this->iOwnerId;
                 if ($iSiteId = $oForm->insert($aValsAdd)) {
                     $this->isAllowedAdd(true);
                     $this->onSiteCreate($iSiteId, $aValsAdd['status']);
                     header('Location:' . BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'browse/my');
                 } else {
                     $sMsgBox = MsgBox(_t('_bx_sites_error_occured'));
                 }
             }
         } else {
             // check enter URL if available
             // preg_match("/^(http:\/\/{1})((\w+\.){1,})\w{2,}$/i", $url)
             $oForm->initChecker();
             if ($oForm->isSubmittedAndValid()) {
                 $sUrl = $_POST['url'];
                 $sUrlFull = strncasecmp($sUrl, 'http://', 7) != 0 ? 'http://' . $sUrl : $sUrl;
                 $aSite = $this->_oDb->getSiteByUrl($sUrl);
                 if (count($aSite) == 0) {
                     $aInfo = getSiteInfo($sUrlFull);
                     if (!empty($aInfo)) {
                         $aParam = array('url' => $sUrl, 'title' => $aInfo['title'], 'description' => $aInfo['description']);
                         $sThumbUrl = $this->_queryRemoteThumbnail($sUrlFull, array('Size' => 'lg'));
                         if ($sThumbUrl) {
                             $this->_addThumbToForm($sThumbUrl, $aParam);
                         }
                         $oForm = new BxSitesFormAdd($this, $aParam);
                     } else {
                         $sMsgBox = MsgBox(_t('_bx_sites_site_link_error'));
                         $oForm->aInputs['url']['value'] = $sUrl;
                     }
                 } else {
                     header('Location:' . BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/' . $aSite['entryUri']);
                 }
             }
         }
     }
     return $sMsgBox . $this->_oTemplate->parseHtmlByName('form.html', array('form' => $oForm->getCode()));
 }