[ Index ] |
|
Code source de phpMyVisites 2.3 |
1 <?php 2 /* 3 * phpMyVisites : website statistics and audience measurements 4 * Copyright (C) 2002 - 2006 5 * http://www.phpmyvisites.net/ 6 * phpMyVisites is free software (license GNU/GPL) 7 * Authors : phpMyVisites team 8 */ 9 10 // $Id: FormSiteGeneral.class.php 236 2007-11-04 15:04:08Z matthieu_ $ 11 12 13 14 require_once INCLUDE_PATH . "/core/forms/Form.class.php"; 15 require_once INCLUDE_PATH . "/core/include/SiteConfigDb.class.php"; 16 17 class FormSiteGeneral extends Form 18 { 19 20 var $valueName = ''; 21 var $valueMainUrl = ''; 22 var $valueLogo = '1.png'; 23 var $valueRecordGet = 'all'; 24 var $valueVariableNames = ''; 25 var $site; 26 var $idPdf = -1; 27 var $pathTheme = THEME_DEFAULT; 28 29 function FormSiteGeneral( &$template, $siteAdmin = null, $action = null) 30 { 31 parent::Form( $template, $action ); 32 33 34 // site selected for mod, display site info in form input 35 if( !is_null($siteAdmin)) 36 { 37 $siteSelect = new Site($siteAdmin); 38 39 $this->valueName = $siteSelect->getName(); 40 $urls = $siteSelect->getUrls(); 41 $this->valueMainUrl = $urls[0]; 42 43 $this->valueLogo = $siteSelect->getLogo(); 44 $this->idPdf = $siteSelect->getIdPdf(); 45 $this->pathTheme = $siteSelect->getPathTheme(); 46 47 $params = $siteSelect->getParams(); 48 49 $this->valueRecordGet = $params['params_choice']; 50 $this->valueVariableNames = $params['params_names']; 51 52 $this->siteAdmin = $siteAdmin; 53 } 54 } 55 56 function process() 57 { 58 59 // general input 60 $tmpImg = (isset( $this->valueLogo) && $this->valueLogo!='pixel.gif' ? $this->valueLogo : '1.png'); 61 $formElements = array( 62 array('text', 'form_name', $GLOBALS['lang']['admin_site_name'], 'value="'.str_replace('"',"'",$this->valueName).'"'), 63 array('text', 'form_url', $GLOBALS['lang']['admin_site_url'], 'value="'.$this->valueMainUrl.'"'), 64 array('radio', 'form_logo', sprintf($GLOBALS['lang']['install_afficherlogo'], 65 '<img alt="logo" name="logo_phpmv" src="'.DIR_IMG_LOGOS.'/'. $tmpImg . '"/> ') 66 , $GLOBALS['lang']['install_oui'] . '<br><br><a href="javascript:popup(\'index.php?mod=list_logos\');">-> '.$GLOBALS['lang']['install_logodispo'].'</a>' 67 , 'yes'), 68 array('radio', 'form_logo', null, $GLOBALS['lang']['install_non'], 'no'), 69 array('hidden', 'form_logo_no', $tmpImg), 70 71 ); 72 $this->addElements( $formElements , 'General'); 73 74 // Prepare PDF list 75 $listPdf = array(); 76 $listPdfOption = array(); 77 $listPdf["-1"] = $GLOBALS['lang']['admin_get_default_pdfdefault']; 78 if (isset($this->siteAdmin)) { 79 $pdfDb = new PdfConfigDb($this->siteAdmin); 80 $tmpLstPdf = $pdfDb->getListPdf(); 81 foreach ($tmpLstPdf as $key => $info) { 82 $listPdf[$key] = $info->pdfName. " (".PARAM_URL_NEWSLETTER."=".$key.")"; 83 } 84 } 85 86 // Get List of theme 87 $dir = INCLUDE_PATH."/themes/"; 88 $d = dir($dir); 89 $arDir = array(); 90 91 while (false !== ($entry = $d->read())) 92 { 93 if( is_dir($dir.$entry) 94 && $entry[0] != '.' // we don't want .. or . or .svn 95 ) 96 $arDir[$entry] = ucfirst($entry); 97 } 98 $d->close(); 99 100 101 // optional input (relative to GET variable recording) 102 $formElements = array( 103 array('radio', 'form_params', $GLOBALS['lang']['admin_get_question'] , $GLOBALS['lang']['admin_get_a1'], 'all'), 104 array('radio', 'form_params', null, $GLOBALS['lang']['admin_get_a2'] , 'none'), 105 array('radio', 'form_params', null, $GLOBALS['lang']['admin_get_a3'], 'only'), 106 array('radio', 'form_params', null, $GLOBALS['lang']['admin_get_a4'], 'except'), 107 array('text', 'form_params_names', sprintf( $GLOBALS['lang']['admin_get_list'], GET_LIST_EXAMPLE), 108 'value="'.$this->valueVariableNames.'"'), 109 array('select','form_idpdf'), // Reserve field postion but it is creating after 110 // array('text', 'form_path_theme', $GLOBALS['lang']['admin_get_default_theme'],'value="'.$this->pathTheme.'"'), 111 array('select', 'form_path_theme'), // Reserve field postion but it is creating after 112 113 ); 114 $this->addElements( $formElements , $GLOBALS['lang']['install_utilisateursavances']); 115 116 // Set list PDF with default value 117 $s =& $this->createElement('select','form_idpdf', $GLOBALS['lang']['admin_get_default_pdf']); 118 $s->loadArray($listPdf, $this->idPdf); // Default value 119 $this->addElement($s); 120 121 // Set list theme with default value 122 $s =& $this->createElement('select','form_path_theme', $GLOBALS['lang']['admin_get_default_theme']); 123 $s->loadArray($arDir, $this->pathTheme); // Default value 124 $this->addElement($s); 125 126 // set first radio checked for variables recording 127 //$radio =& $this->getElement('form_params'); 128 //$radio->_attributes['checked'] = 'checked'; 129 $this->setChecked( 'form_params', $this->valueRecordGet ); 130 131 // set first radio checked for logo display 132 $this->setChecked( 'form_logo', $this->valueLogo=='pixel.gif'?'no':'yes' ); 133 134 135 // validation rules 136 $formRules = array( 137 array('form_name', sprintf($GLOBALS['lang']['admin_required'], $GLOBALS['lang']['admin_site_name']), 'required'), 138 array('form_url', sprintf($GLOBALS['lang']['admin_required'], $GLOBALS['lang']['admin_site_url']), 'required'), 139 $this->getRuleCheckUrl( 'form_url'), 140 array('form_logo', sprintf($GLOBALS['lang']['admin_required'], $GLOBALS['lang']['admin_logo_question']), 'required'), 141 array('form_params', sprintf($GLOBALS['lang']['admin_required'], $GLOBALS['lang']['admin_get_question']), 'required'), 142 ); 143 $this->addRules( $formRules ); 144 145 // launche process 146 return parent::process( 'admin_configetperso' ); 147 } 148 149 function postProcess() 150 { 151 $confSite = new SiteConfigDb(); 152 153 $infoSite = array( 154 // db field name => new value 155 'name' => $this->getSubmitValue('form_name'), 156 'logo' => $this->getSubmitValue('form_logo')=='yes' 157 ? $this->getSubmitValue('form_logo_no') 158 : 'pixel.gif', 159 'params_choice' => $this->getSubmitValue('form_params'), 160 'idpdf' => $this->getSubmitValue('form_idpdf'), 161 'path_theme' => $this->getSubmitValue('form_path_theme'), 162 ); 163 164 $urlSite = $this->getSubmitValue('form_url'); 165 166 $params_names = $this->getSubmitValue('form_params_names'); 167 168 if(!empty($params_names)) 169 { 170 $infoSite['params_names'] = $params_names; 171 } 172 173 $req =& Request::getInstance(); 174 switch( $req->getActionName() ) 175 { 176 case 'add': 177 $this->siteAdmin = $confSite->addSite( $infoSite, $urlSite); 178 break; 179 180 case 'mod': 181 $infoSite['idsite'] = $this->siteAdmin; 182 $confSite->modSite( $infoSite, $urlSite); 183 184 break; 185 186 default: 187 trigger_error('Action not specified for Site configuration. Were you trying to add, modify, delete? Only YOU know that!', E_USER_ERROR); 188 break; 189 } 190 191 } 192 } 193 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 14:10:01 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |