Permalink
Browse files

* minor tweaks

  • Loading branch information...
1 parent aa08d00 commit 884f9a4a89065e3aa004c1c55921e84a6174cbec @xwisdom xwisdom committed Jul 18, 2005
@@ -1,122 +1,114 @@
-<?php
-
-global $ContextMenuCnt;
-$ContextMenuCnt = 0;
-
-class ContextMenu {
-
- function ContextMenu($id='',$width=120,$visible=false) {
- $ContextMenuCnt++;
- $this->html = "";
- $this->visible = $visible ? $visible:false;
- $this->width = is_numeric($width) ? intval($width):120;
- $this->id = id ? $id:"cntxMnu".$ContextMenuCnt; // set id
- }
-
- function addItem($text,$action="",$img="",$disabled=0){
- global $base_url;
- if(!$img) $img = $base_url."manager/media/images/_tx_.gif";
- if(substr($action,0,3)=="js:") $action = substr($action,3);
- else if(substr($action,0,3)=="hl:") $action = "window.location.href='".substr($action,3)."'";
- else $action = "window.location.href='".$action."'";
- $action=" onmouseover=\"this.className='cntxMnuItemOver';\" onmouseout=\"this.className='cntxMnuItem';\" onclick=\"$action; hideCntxMenu('".$this->id."');\"";
- if ($disabled) $action="";
- $this->html .= "
- <div class='".($disabled ? "cntxMnuItemDisabled":"cntxMnuItem")."' $action>
- <img src='$img' width='16' height='16' align='absmiddle' />&nbsp;$text
- </div>
- ";
- }
-
- function addSeparator(){
- $this->html .= "
- <div class='cntxMnuSeparator'></div>
- ";
- }
-
- function render() {
- global $modx;
- global $ContextMenuScript;
-
- $html = $ContextMenuScript.
- "<div id='".$this->id."' class='contextMenu' style='width:".$this->width."px; visibility:".($this->visible ?'visible':'hidden')."'>".$this->html."</div>";
- $ContextMenuScript = ""; // reset css
- return $html;
- }
-
- function getClientScriptObject(){
- return "getCntxMenu('".$this->id."')";
- }
-}
-
-$ContextMenuScript = <<<BLOCK
-<script>
- function getCntxMenu(id) {
- if(self.DynElement) return new DynElement(id);
- else return document.getElementById(id);
- }
- function hideCntxMenu(id){
- var cm = getCntxMenu(id);
- cm.style.visibility = 'hidden';
- }
-</script>
-<style>
-.contextMenu {
- background-image: url("media/images/bg/context.gif");
- background-color: #fff;
- background-position: top left;
- background-repeat: repeat-y;
- margin: 0px;
- padding: 0px;
- border: 1px solid #003399;
- border-left-color: #eaeaea;
- border-top-color: #eaeaea;
- border-right-color: #909090;
- border-bottom-color: #707070;
- position: absolute;
- z-index: 10000; }
-
-.cntxMnuItem {
- background-image: url('media/images/_tx_.gif');
- cursor: pointer;
- font: menu;
- color: MenuText;
- padding: 3px 16px 3px 2px; }
-
-.cntxMnuItemOver {
- cursor: pointer;
- color: #000000;
- background-color: #FFCC00;
- background-position: bottom left;
- background-repeat: repeat-x;
- background-image: url("media/images/misc/buttonbar_gs.gif");
- font: menu;
- padding: 2px 15px 2px 1px;
- border: 1px solid #FFAA00; /*#003399;*/
-}
-
-.cntxMnuItemDisabled {
- cursor: default;
- font: menu;
- padding: 3px 16px 3px 2px;
- color: graytext;
-}
-.cntxMnuItem IMG, .cntxMnuItemOver IMG, .cntxMnuItemDisabled IMG {
- margin-right: 8px;
-}
-
-.cntxMnuItem IMG, .cntxMnuItemDisabled IMG {
- filter: gray();
-}
-
-.cntxMnuSeparator {
- font-size: 0pt;
- height: 1px;
- background-color: #6A8CCB;
- overflow: hidden;
- margin: 3px 1px 3px 28px; }
-
-</style>
-BLOCK;
-
-?>
+<?php
+
+global $ContextMenuCnt;
+$ContextMenuCnt = 0;
+
+class ContextMenu {
+
+ function ContextMenu($id='',$width=120,$visible=false) {
+ $ContextMenuCnt++;
+ $this->html = "";
+ $this->visible = $visible ? $visible:false;
+ $this->width = is_numeric($width) ? intval($width):120;
+ $this->id = id ? $id:"cntxMnu".$ContextMenuCnt; // set id
+ }
+
+ function addItem($text,$action="",$img="",$disabled=0){
+ global $base_url;
+ if(!$img) $img = $base_url."manager/media/images/_tx_.gif";
+ if(substr($action,0,3)=="js:") $action = substr($action,3);
+ else if(substr($action,0,3)=="hl:") $action = "window.location.href='".substr($action,3)."'";
+ else $action = "window.location.href='".$action."'";
+ $action=" onmouseover=\"this.className='cntxMnuItemOver';\" onmouseout=\"this.className='cntxMnuItem';\" onclick=\"$action; hideCntxMenu('".$this->id."');\"";
+ if ($disabled) $action="";
+ $this->html .= "
+ <div class='".($disabled ? "cntxMnuItemDisabled":"cntxMnuItem")."' $action>
+ <img src='$img' width='16' height='16' align='absmiddle' />&nbsp;$text
+ </div>
+ ";
+ }
+
+ function addSeparator(){
+ $this->html .= "
+ <div class='cntxMnuSeparator'></div>
+ ";
+ }
+
+ function render() {
+ global $modx;
+ global $ContextMenuScript;
+
+ $html = $ContextMenuScript.
+ "<div id='".$this->id."' class='contextMenu' style='width:".$this->width."px; visibility:".($this->visible ?'visible':'hidden')."'>".$this->html."</div>";
+ $ContextMenuScript = ""; // reset css
+ return $html;
+ }
+
+ function getClientScriptObject(){
+ return "getCntxMenu('".$this->id."')";
+ }
+}
+
+$ContextMenuScript = <<<BLOCK
+<script>
+ function getCntxMenu(id) {
+ if(self.DynElement) return new DynElement(id);
+ else return document.getElementById(id);
+ }
+ function hideCntxMenu(id){
+ var cm = getCntxMenu(id);
+ cm.style.visibility = 'hidden';
+ }
+</script>
+<style>
+.contextMenu {
+ background: #fff url(media/images/bg/context.gif) repeat-y top left;
+ margin: 0;
+ padding: 0;
+ border: 1px solid #003399;
+ border-left-color: #eaeaea;
+ border-top-color: #eaeaea;
+ border-right-color: #909090;
+ border-bottom-color: #707070;
+ position: absolute;
+ z-index: 10000; }
+
+.cntxMnuItem {
+ background-image: url(media/images/_tx_.gif);
+ cursor: pointer;
+ color: #000;
+ padding: 3px 16px 3px 2px; }
+
+.cntxMnuItemOver {
+ cursor: pointer;
+ color: #000;
+ background: #fc0 url(media/images/misc/buttonbar_gs.gif) repeat-x bottom left;
+ padding: 2px 15px 2px 1px;
+ border: 1px solid #fa0; /*#003399;*/
+}
+
+.cntxMnuItemDisabled {
+ cursor: default;
+ font: menu;
+ padding: 3px 16px 3px 2px;
+ color: #111;
+}
+.cntxMnuItem IMG, .cntxMnuItemOver IMG, .cntxMnuItemDisabled IMG {
+ margin-right: 8px;
+}
+
+.cntxMnuItem IMG, .cntxMnuItemDisabled IMG {
+ filter: gray();
+}
+
+.cntxMnuSeparator {
+ font-size: 0;
+ height: 1px;
+ background-color: #6A8CCB;
+ overflow: hidden;
+ margin: 3px 1px 3px 28px; }
+
+</style>
+BLOCK;
+
+?>
@@ -397,7 +397,18 @@ function outputContent($noEvent=false) {
$header = 'Content-Type: '.$type.'; charset='.$this->config['etomite_charset'];
header($header);
if(!$this->checkPreview() && $this->documentObject['content_dispo']==1) {
- $name = $this->documentObject['alias'] ? $this->documentObject['alias']:preg_replace("\W","",$this->documentObject['pagetitle']);
+ if($this->documentObject['alias']) $name = $this->documentObject['alias'];
+ else {
+ // strip title of special characters
+ $name = $this->documentObject['pagetitle'];
+ $name = strip_tags($name);
+ $name = strtolower($name);
+ $name = preg_replace('/&.+?;/', '', $name); // kill entities
+ $name = preg_replace('/[^\.%a-z0-9 _-]/', '', $name);
+ $name = preg_replace('/\s+/', '-', $name);
+ $name = preg_replace('|-+|', '-', $name);
+ $name = trim($name, '-');
+ }
$header = 'Content-Disposition: attachment; filename='.$name;
header($header);
}
@@ -16,7 +16,8 @@
*///FOR MODx
session_start();if(!isset($_SESSION['mgrValidated'])) {
die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the MODx Content Manager instead of accessing this file directly.");
-}include("../../../../../includes/config.inc.php");
+}
+include("../../../../../includes/config.inc.php");
// connect to the database
if(@!$modxDBConn = mysql_connect($database_server, $database_user, $database_password)) {
die("Failed to create the database connection!");

0 comments on commit 884f9a4

Please sign in to comment.