diff --git a/config.php b/config.php index 6344ccc6f..f24da0e0d 100644 --- a/config.php +++ b/config.php @@ -1,3 +1,3 @@ - \ No newline at end of file + diff --git a/core/admin/categories.php b/core/admin/categories.php index 159520b76..7d703de58 100644 --- a/core/admin/categories.php +++ b/core/admin/categories.php @@ -73,17 +73,17 @@ echo ''; echo ''; echo ''.$k.''; - plxUtils::printInput($k.'_name', plxUtils::strCheck($v['name']), 'text', '10-50'); + plxUtils::printInput($k.'_name', plxUtils::strCheck($v['name']), 'text', '-50'); echo ''; - plxUtils::printInput($k.'_url', $v['url'], 'text', '10-50'); + plxUtils::printInput($k.'_url', $v['url'], 'text', '-50'); echo ''; plxUtils::printSelect($k.'_active', array('1'=>L_YES,'0'=>L_NO), $v['active']); echo ''; plxUtils::printSelect($k.'_tri', $aTri, $v['tri']); echo ''; - plxUtils::printInput($k.'_bypage', $v['bypage'], 'text', '1-3'); + plxUtils::printInput($k.'_bypage', $v['bypage'], 'text', '-3'); echo ''; - plxUtils::printInput($k.'_ordre', $ordre, 'text', '1-3'); + plxUtils::printInput($k.'_ordre', $ordre, 'text', '-3'); echo ''; plxUtils::printSelect($k.'_menu', array('oui'=>L_DISPLAY,'non'=>L_HIDE), $v['menu']); echo ''; @@ -104,17 +104,17 @@ '; plxUtils::printInput($new_catid.'_template', 'categorie.php', 'hidden'); - plxUtils::printInput($new_catid.'_name', '', 'text', '10-50'); + plxUtils::printInput($new_catid.'_name', '', 'text', '-50'); echo ''; - plxUtils::printInput($new_catid.'_url', '', 'text', '10-50'); + plxUtils::printInput($new_catid.'_url', '', 'text', '-50'); echo ''; plxUtils::printSelect($new_catid.'_active', array('1'=>L_YES,'0'=>L_NO), '1'); echo ''; plxUtils::printSelect($new_catid.'_tri', $aTri, $plxAdmin->aConf['tri']); echo ''; - plxUtils::printInput($new_catid.'_bypage', $plxAdmin->aConf['bypage'], 'text', '1-3'); + plxUtils::printInput($new_catid.'_bypage', $plxAdmin->aConf['bypage'], 'text', '-3'); echo ''; - plxUtils::printInput($new_catid.'_ordre', ++$num, 'text', '1-3'); + plxUtils::printInput($new_catid.'_ordre', ++$num, 'text', '-3'); echo ''; plxUtils::printSelect($new_catid.'_menu', array('oui'=>L_DISPLAY,'non'=>L_HIDE), '1'); echo ' '; diff --git a/core/admin/parametres_users.php b/core/admin/parametres_users.php index bc678708f..076388395 100644 --- a/core/admin/parametres_users.php +++ b/core/admin/parametres_users.php @@ -73,13 +73,13 @@ echo ''; echo ''; echo ''.$_userid.''; - plxUtils::printInput($_userid.'_name', plxUtils::strCheck($_user['name']), 'text', '12-255'); + plxUtils::printInput($_userid.'_name', plxUtils::strCheck($_user['name']), 'text', ''); echo ''; - plxUtils::printInput($_userid.'_login', plxUtils::strCheck($_user['login']), 'text', '12-255'); + plxUtils::printInput($_userid.'_login', plxUtils::strCheck($_user['login']), 'text', ''); echo ''; - plxUtils::printInput($_userid.'_password', '', 'password', '10-255', false, '', '', 'onkeyup="pwdStrength(this.id)"'); + plxUtils::printInput($_userid.'_password', '', 'password', '', false, '', '', 'onkeyup="pwdStrength(this.id)"'); echo ''; - plxUtils::printInput($_userid.'_email', plxUtils::strCheck($_user['email']), 'email', '20-255'); + plxUtils::printInput($_userid.'_email', plxUtils::strCheck($_user['email']), 'email', ''); echo ''; if($_userid=='001') { plxUtils::printInput($_userid.'_profil', $_user['profil'], 'hidden'); @@ -111,14 +111,14 @@ '; plxUtils::printInput($new_userid.'_newuser', 'true', 'hidden'); - plxUtils::printInput($new_userid.'_name', '', 'text', '12-255'); + plxUtils::printInput($new_userid.'_name', '', 'text', ''); plxUtils::printInput($new_userid.'_infos', '', 'hidden'); echo ''; - plxUtils::printInput($new_userid.'_login', '', 'text', '12-255'); + plxUtils::printInput($new_userid.'_login', '', 'text', ''); echo ''; - plxUtils::printInput($new_userid.'_password', '', 'password', '10-255', false, '', '', 'onkeyup="pwdStrength(this.id)"'); + plxUtils::printInput($new_userid.'_password', '', 'password', '', false, '', '', 'onkeyup="pwdStrength(this.id)"'); echo ''; - plxUtils::printInput($new_userid.'_email', '', 'email', '20-255'); + plxUtils::printInput($new_userid.'_email', '', 'email', ''); echo ''; plxUtils::printSelect($new_userid.'_profil', $aProfils, PROFIL_WRITER); echo ''; @@ -138,4 +138,4 @@ eval($plxAdmin->plxPlugins->callHook('AdminUsersFoot')); # On inclut le footer include(dirname(__FILE__).'/foot.php'); -?> \ No newline at end of file +?> diff --git a/core/admin/statiques.php b/core/admin/statiques.php index a57f235ca..40fcddc6a 100644 --- a/core/admin/statiques.php +++ b/core/admin/statiques.php @@ -87,15 +87,15 @@ function checkBox(cb) { $selected = $plxAdmin->aConf['homestatic']==$k ? ' checked="checked"' : ''; echo ''; echo ''; - plxUtils::printInput($k.'_group', plxUtils::strCheck($v['group']), 'text', '10-100'); + plxUtils::printInput($k.'_group', plxUtils::strCheck($v['group']), 'text', '-100'); echo ''; - plxUtils::printInput($k.'_name', plxUtils::strCheck($v['name']), 'text', '10-255'); + plxUtils::printInput($k.'_name', plxUtils::strCheck($v['name']), 'text', '-255'); echo ''; - plxUtils::printInput($k.'_url', $v['url'], 'text', '10-255'); + plxUtils::printInput($k.'_url', $v['url'], 'text', '-255'); echo ''; plxUtils::printSelect($k.'_active', array('1'=>L_YES,'0'=>L_NO), $v['active']); echo ''; - plxUtils::printInput($k.'_ordre', $ordre, 'text', '1-3'); + plxUtils::printInput($k.'_ordre', $ordre, 'text', '2-3'); echo ''; plxUtils::printSelect($k.'_menu', array('oui'=>L_DISPLAY,'non'=>L_HIDE), $v['menu']); $url = $v['url']; @@ -125,16 +125,16 @@ function checkBox(cb) { '; - plxUtils::printInput($new_staticid.'_group', '', 'text', '10-100'); + plxUtils::printInput($new_staticid.'_group', '', 'text', '-100'); echo ''; - plxUtils::printInput($new_staticid.'_name', '', 'text', '10-255'); + plxUtils::printInput($new_staticid.'_name', '', 'text', '-255'); plxUtils::printInput($new_staticid.'_template', 'static.php', 'hidden'); echo ''; - plxUtils::printInput($new_staticid.'_url', '', 'text', '10-255'); + plxUtils::printInput($new_staticid.'_url', '', 'text', '-255'); echo ''; plxUtils::printSelect($new_staticid.'_active', array('1'=>L_YES,'0'=>L_NO), '0'); echo ''; - plxUtils::printInput($new_staticid.'_ordre', ++$num, 'text', '1-3'); + plxUtils::printInput($new_staticid.'_ordre', ++$num, 'text', '2-3'); echo ''; plxUtils::printSelect($new_staticid.'_menu', array('oui'=>L_DISPLAY,'non'=>L_HIDE), '1'); ?> diff --git a/core/admin/theme/images/file.png b/core/admin/theme/images/file.png new file mode 100644 index 000000000..8717e8b07 Binary files /dev/null and b/core/admin/theme/images/file.png differ diff --git a/core/admin/theme/images/progress.png b/core/admin/theme/images/progress.png new file mode 100644 index 000000000..ba302c03d Binary files /dev/null and b/core/admin/theme/images/progress.png differ diff --git a/core/admin/theme/theme.css b/core/admin/theme/theme.css index d9fa04cd8..1e1a0dc6c 100644 --- a/core/admin/theme/theme.css +++ b/core/admin/theme/theme.css @@ -618,4 +618,17 @@ div.ico div { color: #000; text-decoration: none; cursor: pointer; +<<<<<<< f873e59a1417e260bfed80faf1da214f97bc5065 +======= +} + +#statics-table input:not([type="checkbox"]), +#categories-table input:not([type="checkbox"]), +#users-table input:not([type="checkbox"]) { + width: 100%; +} +input[maxlength="3"] { + width: 4rem !important; + text-align: right; +>>>>>>> Gestion de aConf['medias']; + $_SESSION['folder'] = ''; +} +elseif(!empty($_POST['folder'])) { + $_SESSION['currentfolder']= (isset($_SESSION['folder'])?$_SESSION['folder']:''); + $_SESSION['folder'] = ($_POST['folder']=='.'?'':$_POST['folder']); +} +# Nouvel objet de type plxMedias +if($plxAdmin->aConf['userfolders'] AND $_SESSION['profil']==PROFIL_WRITER) + $plxMedias = new plxMedias(PLX_ROOT.$_SESSION['medias'].$_SESSION['user'].'/',$_SESSION['folder']); +else + $plxMedias = new plxMedias(PLX_ROOT.$_SESSION['medias'],$_SESSION['folder']); + +if(!empty($_POST['token'])) { + $res = $plxMedias->uploadFile($_FILES, $_POST); + /* + switch($res) { + case L_PLXMEDIAS_WRONG_FILESIZE: + plxMsg::Error(L_PLXMEDIAS_WRONG_FILESIZE); + break; + case L_PLXMEDIAS_WRONG_FILEFORMAT: + plxMsg::Error(L_PLXMEDIAS_WRONG_FILEFORMAT); + break; + case L_PLXMEDIAS_UPLOAD_ERR: + plxMsg::Error(L_PLXMEDIAS_UPLOAD_ERR); + break; + case L_PLXMEDIAS_UPLOAD_SUCCESSFUL: + plxMsg::Info(L_PLXMEDIAS_UPLOAD_SUCCESSFUL); + break; + } + */ + $plxMedias->outputJSON($res, ($res == L_PLXMEDIAS_UPLOAD_SUCCESSFUL ? '' : 'error')); + +} + +exit; \ No newline at end of file diff --git a/core/lib/class.plx.admin.php b/core/lib/class.plx.admin.php index dbc0ef47d..bd58184cb 100644 --- a/core/lib/class.plx.admin.php +++ b/core/lib/class.plx.admin.php @@ -328,8 +328,14 @@ public function editUsers($content, $action=false) { $this->aUsers[$user_id]['profil'] = ($_SESSION['user']==$user_id?$this->aUsers[$user_id]['profil']:$content[$user_id.'_profil']); $this->aUsers[$user_id]['password'] = $password; $this->aUsers[$user_id]['salt'] = $salt; - $this->aUsers[$user_id]['email'] = $email; - + if(isset($content[$user_id.'_email'])) { + $email = trim($content[$user_id.'_email']); + if(empty($email)) { + $this->aUsers[$user_id]['email'] = ''; + } elseif(plxUtils::checkMail($email)) { + $this->aUsers[$user_id]['email'] = $email; + } + } $this->aUsers[$user_id]['delete'] = (isset($this->aUsers[$user_id]['delete'])?$this->aUsers[$user_id]['delete']:0); $this->aUsers[$user_id]['lang'] = (isset($this->aUsers[$user_id]['lang'])?$this->aUsers[$user_id]['lang']:$this->aConf['default_lang']); $this->aUsers[$user_id]['infos'] = (isset($this->aUsers[$user_id]['infos'])?$this->aUsers[$user_id]['infos']:''); @@ -1079,4 +1085,4 @@ public function checkMaj() { } } -?> \ No newline at end of file +?> diff --git a/core/lib/class.plx.medias.php b/core/lib/class.plx.medias.php index 4fcc7ea18..41b9d829a 100644 --- a/core/lib/class.plx.medias.php +++ b/core/lib/class.plx.medias.php @@ -331,6 +331,60 @@ private function _uploadFile($file, $resize, $thumb) { return L_PLXMEDIAS_UPLOAD_SUCCESSFUL; } + /** + * Méthode qui renvoit une sortie au format JSON + * + * @param msg message + * @param statut status erreur + * @author Stephane F + **/ + public function outputJSON($msg, $status = 'error') { + header('Content-Type: application/json'); + die(json_encode(array( + 'data' => $msg, + 'status' => $status + ))); + } + + /** + * Méthode qui envoie un fichier sur le serveur + * + * @param usrfile fichier utilisateur à uploader + * @param post paramètres + * @return msg résultat de l'envoi des fichiers + * @author Stephane F + **/ + public function uploadFile($usrfile, $post) { + + $file = array( + 'name' => $usrfile['myfiles']['name'], + 'size' => $usrfile['myfiles']['size'], + 'tmp_name' => $usrfile['myfiles']['tmp_name'], + ); + + $resize = false; + $thumb = false; + if(!empty($post['resize'])) { + if($post['resize']=='user') { + $resize = array('width' => intval($post['user_w']), 'height' => intval($post['user_h'])); + } else { + list($width,$height) = explode('x', $post['resize']); + $resize = array('width' => $width, 'height' => $height); + } + } + if(!empty($post['thumb'])) { + if($post['thumb']=='user') { + $thumb = array('width' => intval($post['thumb_w']), 'height' => intval($post['thumb_h'])); + } else { + list($width,$height) = explode('x', $post['thumb']); + $thumb = array('width' => $width, 'height' => $height); + } + } + + return $this->_uploadFile($file, $resize, $thumb); + + } + /** * Méthode qui envoie une liste de fichiers sur le serveur * diff --git a/core/lib/class.plx.show.php b/core/lib/class.plx.show.php index 90e6e722d..4e08b1d3f 100644 --- a/core/lib/class.plx.show.php +++ b/core/lib/class.plx.show.php @@ -1376,10 +1376,12 @@ public function staticId() { * @scope static * @author Florent MONTHEL, Stéphane F **/ - public function staticUrl($type='relatif') { + public function staticUrl($type='relatif', $staticId=false) { # Recupération ID URL - $staticId = $this->staticId(); + if (empty($staticId) or !array_key_exists(str_pad($staticId,3,'0',STR_PAD_LEFT), $this->plxMotor->aStats)) { + $staticId = $this->staticId(); + } $staticIdFill = str_pad($staticId,3,'0',STR_PAD_LEFT); if(!empty($staticId) AND isset($this->plxMotor->aStats[ $staticIdFill ])) echo $this->plxMotor->urlRewrite('?static'.$staticId.'/'.$this->plxMotor->aStats[ $staticIdFill ]['url']); diff --git a/core/lib/class.plx.utils.php b/core/lib/class.plx.utils.php index d82a254f4..0b54705bf 100644 --- a/core/lib/class.plx.utils.php +++ b/core/lib/class.plx.utils.php @@ -190,19 +190,26 @@ public static function printSelect($name, $array, $selected='', $readonly=false, * @param extra extra paramètre pour du javascript par exemple (onclick) * @return stdout **/ - public static function printInput($name, $value='', $type='text', $size='50-255', $readonly=false, $class='', $placeholder='', $extra='') { - - $size = explode('-',$size); - $placeholder = $placeholder!='' ? ' placeholder="'.$placeholder.'"' : ''; - $extra = $extra!='' ? ' '.trim($extra) : ''; - if($type!='hidden') { - if($readonly) - echo ''."\n"; - else - echo ''."\n"; - } else { - echo ''."\n"; - } + public static function printInput($name, $value='', $type='text', $sizes='50-255', $readonly=false, $className='', $placeholder='', $extra='') { + + $params = array( + 'id="id_'.$name.'"', + 'name="'.$name.'"', + 'type="'.$type.'"' + ); + if(! empty($value)) { $params[] = 'value="'.$value.'"'; } + if(! empty($extra)) { $params[] = $extra; } + if($type != 'hidden') { + if($readonly === true) { $params[] = 'readony'; } + if(! empty($className)) { $params[] = $className; } + if(! empty($placeholder)) { $params[] = $placeholder; } + if(! empty($sizes) and (strpos($sizes, '-') !== false)) { + list($size, $maxlength) = explode('-', $sizes); + if(! empty($size)) { $params[] = 'size="'.$size.'"'; } + if(! empty($maxlength)) { $params[] = 'maxlength="'.$maxlength.'"'; } + } + } + echo ''; } /** @@ -1048,4 +1055,4 @@ public static function debug($obj) { echo ""; } } -?> +?> \ No newline at end of file diff --git a/core/lib/filedrag.js b/core/lib/filedrag.js new file mode 100644 index 000000000..17f8159b9 --- /dev/null +++ b/core/lib/filedrag.js @@ -0,0 +1,190 @@ +(function() { + + var usrFiles = []; + var fileSelect = $id("myfiles"); + var fileDrag = $id("filedrag"); + var btnUpload = $id("btn_upload"); + var btnReset = $id("btn_reset"); + + // getElementById + function $id(id) { + return document.getElementById(id); + } + + // form field value + function $_id(id) { + return document.form_uploader.elements[id].value; + } + + // file drag hover + function FileDragHover(e) { + e.stopPropagation(); + e.preventDefault(); + e.target.className = (e.type == "dragover" ? "hover" : ""); + } + + // file selection + function FileSelectHandler(e) { + + // cancel event and hover styling + FileDragHover(e); + + // fetch FileList object + var files = e.target.files || e.dataTransfer.files; + + // unique id + var uid = (new Date().getTime()).toString(10); + + // process all File objects + for (var i = 0; i < files.length; i++) { + var f = { + file : files[i], + fid : 'p_' + uid + '_' + i + }; + div = document.createElement("div"); + div.setAttribute("id", f.fid); + div.setAttribute("class", "progress"); + $id("progress").appendChild(div); + usrFiles.push(f); + ParseFile(f); + } + + btnUpload.style.display = "inline-block"; + btnReset.style.display = "inline-block"; + + } + + // output file information + function ParseFile(f) { + + // display image file + var reader = new FileReader(); + reader.onload = function(e) { + // image + var img = document.createElement("img"); + img.setAttribute("src", f.file.type.indexOf("image") == 0 ? e.target.result : 'theme/images/file.png'); + img.setAttribute("title", f.file.name); + $id(f.fid).appendChild(img); + // delete link + var lnkDelete = document.createElement('a'); + lnkDelete.setAttribute('href', 'javascript:void(0)'); + lnkDelete.innerHTML = '✖'; + lnkDelete.setAttribute("class","btn_delete"); + lnkDelete.setAttribute("className","btn_delete"); /* Hack IE */ + lnkDelete.onclick = function(){ + var div = $id(f.fid); + div.parentNode.removeChild(div); + // remove file from usrFile array + for(var i=0;i 10) { + s = s.substring(0,5) + '...' + getFilePathExtension(s); + } + $id(f.fid).appendChild(document.createTextNode(s)); + } + reader.readAsDataURL(f.file); + } + + function getFilePathExtension(path) { + var filename = path.split('\\').pop().split('/').pop(); + return filename.substr(( Math.max(0, filename.lastIndexOf(".")) || Infinity) + 1); + } + + function UploadFiles(f) { + + var xhr = new XMLHttpRequest(); + if (xhr.upload) { + + var progress = $id(f.fid).appendChild(document.createElement("p")); + progress.setAttribute('class', 'progress'); + + // progress bar + xhr.upload.addEventListener("progress", function(e) { + var pc = parseInt(100 - (e.loaded / e.total * 100)); + progress.style.backgroundPosition = pc + "% 0"; + }, false); + + xhr.onreadystatechange = function(){ + if(xhr.readyState == 4){ + try { + var resp = JSON.parse(xhr.response); + } catch (e){ + var resp = { + status: 'error', + data: 'Unknown error occurred: [' + xhr.responseText + ']' + }; + } + progress.className = (resp.status=='error' ? "failed": "success"); + console.log(resp.status + ': ' + resp.data); + } + }; + + var data = new FormData(); + data.append('myfiles', f.file); + data.append('token', $_id('token')); + data.append('resize', $_id('resize')); + data.append('user_w', $_id('user_w')); + data.append('user_h', $_id('user_h')); + data.append('thumb', $_id('thumb')); + data.append('thumb_w', $_id('thumb_w')); + data.append('thumb_h', $_id('thumb_h')); + // start upload + xhr.open("POST", 'upload.php', true); + xhr.send(data); + + } + + } + + // initialize + function Init() { + + // file select + fileSelect.addEventListener("change", FileSelectHandler, false); + + // is XHR2 available? + var xhr = new XMLHttpRequest(); + if (xhr.upload) { + fileDrag.addEventListener("dragover", FileDragHover, false); + fileDrag.addEventListener("dragleave", FileDragHover, false); + fileDrag.addEventListener("drop", FileSelectHandler, false); + fileDrag.addEventListener("click", function(){ fileSelect.click() }, false); + } + + btnUpload.addEventListener('click', function(e) { + e.stopPropagation(); + e.preventDefault(); + for (var i = 0; i < usrFiles.length; i++) { + UploadFiles(usrFiles[i]); + } + }); + + btnReset.addEventListener('click', function(e) { + e.stopPropagation(); + e.preventDefault(); + usrFiles.splice(0); // reset array + $id('progress').innerHTML = ''; + btnUpload.style.display = "none"; + btnReset.style.display = "none"; + }); + + } + + // call initialization file + if (window.File && window.FileList && window.FileReader) { + Init(); + } + +})(); \ No newline at end of file diff --git a/data/.htaccess b/data/.htaccess deleted file mode 100644 index ce7ca4512..000000000 --- a/data/.htaccess +++ /dev/null @@ -1 +0,0 @@ -options -indexes \ No newline at end of file diff --git a/data/articles/.htaccess b/data/articles/.htaccess deleted file mode 100644 index 51d1a8668..000000000 --- a/data/articles/.htaccess +++ /dev/null @@ -1,4 +0,0 @@ - - Order allow,deny - Deny from all - diff --git a/data/commentaires/.htaccess b/data/commentaires/.htaccess deleted file mode 100644 index 51d1a8668..000000000 --- a/data/commentaires/.htaccess +++ /dev/null @@ -1,4 +0,0 @@ - - Order allow,deny - Deny from all - diff --git a/data/configuration/.htaccess b/data/configuration/.htaccess deleted file mode 100644 index 9a42a760d..000000000 --- a/data/configuration/.htaccess +++ /dev/null @@ -1,4 +0,0 @@ - - Order allow,deny - Deny from all - \ No newline at end of file diff --git a/data/configuration/index.html b/data/configuration/index.html deleted file mode 100644 index e69de29bb..000000000 diff --git a/data/index.html b/data/index.html deleted file mode 100644 index e69de29bb..000000000 diff --git a/data/statiques/.htaccess b/data/statiques/.htaccess deleted file mode 100644 index 51d1a8668..000000000 --- a/data/statiques/.htaccess +++ /dev/null @@ -1,4 +0,0 @@ - - Order allow,deny - Deny from all - diff --git a/themes/defaut/article.php b/themes/defaut/article.php index d7c38853d..12766e87b 100644 --- a/themes/defaut/article.php +++ b/themes/defaut/article.php @@ -29,7 +29,9 @@ artThumbnail(); ?> artContent(); ?> - + + callHook('MyMultiLingue', 'artlinks')) ?> +