[ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 # CMS - CMS Made Simple 3 # (c)2004 by Ted Kulp (tedkulp@users.sf.net) 4 # This project's homepage is: http://cmsmadesimple.org 5 # 6 # This program is free software; you can redistribute it and/or modify 7 # it under the terms of the GNU General Public License as published by 8 # the Free Software Foundation; either version 2 of the License, or 9 # (at your option) any later version. 10 # 11 # This program is distributed in the hope that it will be useful, 12 # BUT withOUT ANY WARRANTY; without even the implied warranty of 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 # GNU General Public License for more details. 15 # You should have received a copy of the GNU General Public License 16 # along with this program; if not, write to the Free Software 17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 # 19 #$Id: Link.inc.php 3599 2006-12-19 02:56:32Z elijahlofgren $ 20 21 class Link extends ContentBase 22 { 23 24 function Link() { 25 $this->ContentBase(); 26 $this->mProperties->SetAllowedPropertyNames(array('url', 'target')); 27 } 28 29 function FriendlyName() 30 { 31 return 'Link'; 32 } 33 34 function SetProperties() 35 { 36 $this->mProperties->Add('string', 'url'); 37 $this->mProperties->Add('string', 'target'); 38 39 #Turn off caching 40 $this->mCachable = false; 41 } 42 43 function FillParams($params) 44 { 45 if (isset($params)) 46 { 47 $parameters = array('url', 'target'); 48 foreach ($parameters as $oneparam) 49 { 50 if (isset($params[$oneparam])) 51 { 52 $this->SetPropertyValue($oneparam, $params[$oneparam]); 53 } 54 } 55 if (FALSE == empty($_POST['file_url'])) 56 { 57 $this->SetPropertyValue('url', $params['file_url']); 58 } 59 if (isset($params['title'])) 60 { 61 $this->mName = $params['title']; 62 } 63 if (isset($params['menutext'])) 64 { 65 $this->mMenuText = $params['menutext']; 66 } 67 if (isset($params['accesskey'])) 68 { 69 $this->mAccessKey = $params['accesskey']; 70 } 71 if (isset($params['titleattribute'])) 72 { 73 $this->mTitleAttribute = $params['titleattribute']; 74 } 75 if (isset($params['tabindex'])) 76 { 77 $this->mTabIndex = $params['tabindex']; 78 } 79 if (isset($params['alias'])) 80 { 81 $this->mAlias = $params['alias']; 82 } 83 if (isset($params['parent_id'])) 84 { 85 if ($this->mParentId != $params['parent_id']) 86 { 87 $this->mHierarchy = ''; 88 $this->mItemOrder = -1; 89 } 90 $this->mParentId = $params['parent_id']; 91 } 92 if (isset($params['active'])) 93 { 94 $this->mActive = true; 95 } 96 else 97 { 98 $this->mActive = false; 99 } 100 if (isset($params['showinmenu'])) 101 { 102 $this->mShowInMenu = true; 103 } 104 else 105 { 106 $this->mShowInMenu = false; 107 } 108 } 109 } 110 111 function ValidateData() 112 { 113 $errors = array(); 114 115 if ($this->mName == '') 116 { 117 $errors[]= lang('nofieldgiven',array(lang('title'))); 118 $result = false; 119 } 120 121 if ($this->mMenuText == '') 122 { 123 $errors[]= lang('nofieldgiven',array(lang('menutext'))); 124 $result = false; 125 } 126 127 if ($this->GetPropertyValue('url') == '' && TRUE == empty($_POST['file_url'])) 128 { 129 $errors[]= lang('nofieldgiven',array(lang('url'))); 130 $result = false; 131 } 132 133 return (count($errors) > 0?$errors:FALSE); 134 } 135 136 function Show() 137 { 138 } 139 140 function EditAsArray($adding = false, $tab = 0, $showadmin = false) 141 { 142 global $gCms; 143 144 $ret = array(); 145 146 $ret[]= array(lang('title').':','<input type="text" name="title" value="'.cms_htmlentities($this->mName).'" />'); 147 $ret[]= array(lang('menutext').':','<input type="text" name="menutext" value="'.cms_htmlentities($this->mMenuText).'" />'); 148 if (check_permission(get_userid(), 'Modify Page Structure') || ($adding == true && check_permission(get_userid(), 'Add Pages'))) 149 { 150 $contentops =& $gCms->GetContentOperations(); 151 $ret[]= array(lang('parent').':', $contentops->CreateHierarchyDropdown($this->mId, $this->mParentId)); 152 } 153 154 $ret[]= array(lang('url').':','<input type="text" name="url" size="80" value="'.cms_htmlentities($this->GetPropertyValue('url')).'" />'); 155 156 $text = '<option value="">'.lang('no_file_url').'</option>'; 157 $text .= $this->directoryToSelect($gCms->config['uploads_path'], true, $gCms->config['uploads_path'], $this->GetPropertyValue('url')); 158 $ret[]= array(lang('file_url').':','<select name="file_url">'.$text.'</select>'); 159 160 $text = '<option value="">'.lang('none').'</option>'; 161 $text .= '<option value="_blank"'.($this->GetPropertyValue('target')=='_blank'?' selected="selected"':'').'>_blank</option>'; 162 $text .= '<option value="_parent"'.($this->GetPropertyValue('target')=='_parent'?' selected="selected"':'').'>_parent</option>'; 163 $text .= '<option value="_self"'.($this->GetPropertyValue('target')=='_self'?' selected="selected"':'').'>_self</option>'; 164 $text .= '<option value="_top"'.($this->GetPropertyValue('target')=='_top'?' selected="selected"':'').'>_top</option>'; 165 $ret[]= array(lang('target').':','<select name="target">'.$text.'</select>'); 166 $ret[]= array(lang('active').':','<input type="checkbox" name="active"'.($this->mActive?' checked="checked"':'').' />'); 167 $ret[]= array(lang('showinmenu').':','<input type="checkbox" name="showinmenu"'.($this->mShowInMenu?' checked="checked"':'').' />'); 168 $ret[]= array(lang('titleattribute').':','<input type="text" name="titleattribute" maxlength="255" size="80" value="'.cms_htmlentities($this->mTitleAttribute).'" />'); 169 $ret[]= array(lang('tabindex').':','<input type="text" name="tabindex" maxlength="10" value="'.cms_htmlentities($this->mTabIndex).'" />'); 170 $ret[]= array(lang('accesskey').':','<input type="text" name="accesskey" maxlength="5" value="'.cms_htmlentities($this->mAccessKey).'" />'); 171 172 if (!$adding && $showadmin) 173 { 174 $userops =& $gCms->GetUserOperations(); 175 $ret[]= array(lang('owner').':', $userops->GenerateDropdown($this->Owner())); 176 } 177 178 if ($adding || $showadmin) 179 { 180 $ret[]= $this->ShowAdditionalEditors(); 181 } 182 183 return $ret; 184 } 185 186 /* Modfied from the Diagnostics module's directoryToArray. Thanks to SjG */ 187 function directoryToSelect($directory, $recursive, &$orig_dir, $url) 188 { 189 $select = ''; 190 if ($handle = opendir($directory)) { 191 while (false !== ($file = readdir($handle))) { 192 if ($file != "." && $file != ".." && $file[0] != '.') { // Mod Skip hidden file/dir 193 if (is_dir($directory. "/" . $file)) { 194 if($recursive) { 195 $select .= $this->directoryToSelect($directory. "/" . $file, $recursive, $orig_dir, $url); 196 } 197 $file = $directory . "/" . $file; 198 $file = preg_replace("/\/\//si", "/", $file); 199 // $array_items[$file] = "(dir)"; 200 } else { 201 $file = $directory . "/" . $file; 202 // $stats = stat ( $file ); 203 $file = preg_replace("/\/\//si", "/", $file); 204 // $array_items[$file] = "(".$stats[7].") " . date("Y-m-d H:i:s",$stats[9]); 205 $uploads_dir = basename($orig_dir); 206 $file = str_replace($orig_dir, '', $file); 207 $file = $uploads_dir.$file; 208 // $array_items[$file] = $file; 209 $select .= '<option value="'.$file.'"'.($url==$file?' selected="selected"':'').'>'.$file.'</option>'; 210 } 211 } 212 } 213 closedir($handle); 214 } 215 return $select; 216 } 217 218 219 function GetURL($rewrite = true) 220 { 221 return cms_htmlentities($this->GetPropertyValue('url')); 222 } 223 } 224 225 # vim:ts=4 sw=4 noet 226 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Tue Apr 3 18:50:37 2007 | par Balluche grâce à PHPXref 0.7 |