示例#1
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()));
 }
示例#2
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()));
 }