Changeset 10
- Timestamp:
- Sep 12, 2005 1:02:01 AM (19 years ago)
- Files:
-
- 6 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/1.1dev/lib/Utilities.inc.php
r3 r10 206 206 207 207 /** 208 * Encodes an email into a user (at) domain (dot) com format. 209 * 210 * @access public 211 * @param string $email An email to encode. 212 * @param string $at Replaces the @. 213 * @param string $dot Replaces the .. 214 * @return string Encoded email. 215 */ 216 function encodeEmail($email, $at='-at-', $dot='-dot-') 217 { 218 $search = array('/@/', '/\./'); 219 $replace = array($at, $dot); 220 return preg_replace($search, $replace, $email); 221 } 222 223 /** 208 224 * Return a human readable filesize. 209 225 * -
trunk/bin/module_maker/_config.inc.php
r9 r10 4 4 5 5 // Determine common site directory. 6 if (false !== ($common_base = realpath($_SERVER['argv'][1]))) { 6 $common_base = realpath($_SERVER['argv'][1]); 7 8 if ('' != $common_base && is_dir($common_base)) { 7 9 // First arg is path to current site. Realpath removes trailing /s 8 10 define('COMMON_BASE', $common_base); 9 11 } else { 10 die( sprintf("Error: First argument must be the directory path to the site (e.g.: /home/sc/www.strangecode.com/).\n", basename($_SERVER['argv'][0])));12 die("Error: First argument must be the directory path to an existing site (ex: /home/sc/www.strangecode.com).\n"); 11 13 } 12 14 … … 25 27 $app->setParam(array( 26 28 'site_name' => 'Module Maker', 27 'site_email' => ' quinn@strangecode.com',29 'site_email' => 'codebase@strangecode.com', 28 30 'enable_session' => false, 29 31 'enable_db' => true, -
trunk/bin/module_maker/module.cli.php
r9 r10 9 9 10 10 $op = null; 11 $valid_ops = array('clean' );11 $valid_ops = array('clean', 'var'); 12 12 13 13 // Test for a single argument. … … 176 176 // -------------FILES------------- 177 177 178 $skel_files[' admin_script'] = file_get_contents($skel_dir . '/admin.php');179 $skel_files[' admin_list_template'] = file_get_contents($skel_dir . '/adm_list.ihtml');180 $skel_files[' admin_form_template'] = file_get_contents($skel_dir . '/adm_form.ihtml');181 $skel_files[' public_script'] = file_get_contents($skel_dir . '/public.php');182 $skel_files[' public_list_template'] = file_get_contents($skel_dir . '/public_list.ihtml');183 $skel_files[' public_detail_template'] = file_get_contents($skel_dir . '/public.ihtml');178 $skel_files['skel_admin_script'] = file_get_contents($skel_dir . '/admin.php'); 179 $skel_files['skel_admin_list_template'] = file_get_contents($skel_dir . '/adm_list.ihtml'); 180 $skel_files['skel_admin_form_template'] = file_get_contents($skel_dir . '/adm_form.ihtml'); 181 $skel_files['skel_public_script'] = file_get_contents($skel_dir . '/public.php'); 182 $skel_files['skel_public_list_template'] = file_get_contents($skel_dir . '/public_list.ihtml'); 183 $skel_files['skel_public_detail_template'] = file_get_contents($skel_dir . '/public.ihtml'); 184 184 185 185 … … 333 333 334 334 /****************************************************************************** 335 * PRINT VAR INSTEAD. 336 *****************************************************************************/ 337 338 if ('var' == $op) { 339 if (isset($replace[$_SERVER['argv'][5]])) { 340 echo "\n\n" . $replace[$_SERVER['argv'][5]] . "\n\n"; 341 } else if (isset($skel_files[$_SERVER['argv'][5]])) { 342 echo "\n\n" . preg_replace($search, $replace, $skel_files[$_SERVER['argv'][5]]) . "\n\n"; 343 } else { 344 die(basename($_SERVER['argv'][0]) . " Error: variable " . $_SERVER['argv'][5] . " not defined. Please choose one of:\n" . join(', ', array_keys(array_merge($replace, $skel_files))) . "\n"); 345 } 346 die; 347 } 348 349 350 /****************************************************************************** 335 351 * WRITE FILES 336 352 *****************************************************************************/ … … 342 358 echo "Writing admin script: $admin_dir/$admin_script\n"; 343 359 $fp = fopen("$admin_dir/$admin_script", "w"); 344 fwrite($fp, preg_replace($search, $replace, $skel_files[' admin_script']));360 fwrite($fp, preg_replace($search, $replace, $skel_files['skel_admin_script'])); 345 361 fclose($fp); 346 362 } … … 352 368 echo "Writing admin list template: $admin_tpl_dir/$admin_list_template\n"; 353 369 $fp = fopen("$admin_tpl_dir/$admin_list_template", "w"); 354 fwrite($fp, preg_replace($search, $replace, $skel_files[' admin_list_template']));370 fwrite($fp, preg_replace($search, $replace, $skel_files['skel_admin_list_template'])); 355 371 fclose($fp); 356 372 } … … 362 378 echo "Writing admin form template: $admin_tpl_dir/$admin_form_template\n"; 363 379 $fp = fopen("$admin_tpl_dir/$admin_form_template", "w"); 364 fwrite($fp, preg_replace($search, $replace, $skel_files[' admin_form_template']));380 fwrite($fp, preg_replace($search, $replace, $skel_files['skel_admin_form_template'])); 365 381 fclose($fp); 366 382 } … … 372 388 echo "Writing public script: $public_dir/$public_script\n"; 373 389 $fp = fopen("$public_dir/$public_script", "w"); 374 fwrite($fp, preg_replace($search, $replace, $skel_files[' public_script']));390 fwrite($fp, preg_replace($search, $replace, $skel_files['skel_public_script'])); 375 391 fclose($fp); 376 392 } … … 382 398 echo "Writing public list template: $public_tpl_dir/$public_list_template\n"; 383 399 $fp = fopen("$public_tpl_dir/$public_list_template", "w"); 384 fwrite($fp, preg_replace($search, $replace, $skel_files[' public_list_template']));400 fwrite($fp, preg_replace($search, $replace, $skel_files['skel_public_list_template'])); 385 401 fclose($fp); 386 402 } … … 392 408 echo "Writing public detail template: $public_tpl_dir/$public_detail_template\n"; 393 409 $fp = fopen("$public_tpl_dir/$public_detail_template", "w"); 394 fwrite($fp, preg_replace($search, $replace, $skel_files[' public_detail_template']));410 fwrite($fp, preg_replace($search, $replace, $skel_files['skel_public_detail_template'])); 395 411 fclose($fp); 396 412 } -
trunk/bin/module_maker/skel/admin.php
r9 r10 186 186 %SET_VALUES_DEFAULT%, 187 187 'new_op' => 'insert', 188 'submit_buttons' = array(189 'submit' 190 'repeat' 191 'cancel' => _("Cancel")188 'submit_buttons' => array( 189 'submit' => _("Add %ITEM_TITLE%"), 190 'repeat' => _("Add & repeat"), 191 'cancel' => _("Cancel"), 192 192 ), 193 193 ); … … 202 202 if ($lock->isLocked() && !$lock->isMine()) { 203 203 $lock->dieErrorPage(); 204 } else { 205 // Get the information for the form. 206 $qid = DB::query(" 207 SELECT * 208 FROM %DB_TBL% 209 WHERE %PRIMARY_KEY% = '" . addslashes($id) . "' 210 "); 211 if (!$frm = mysql_fetch_assoc($qid)) { 212 App::logMsg('Could not find record with %PRIMARY_KEY%: ' . $id, LOG_WARNING, __FILE__, __LINE__); 213 App::raiseMsg(sprintf(_("The requested record %s could not be found"), $id), MSG_ERR, __FILE__, __LINE__); 214 App::dieBoomerangURL(); 215 } 216 217 // Lock this record. 218 $lock->set('%DB_TBL%', '%PRIMARY_KEY%', $id, $frm['address']); 219 220 // Set misc values for the form. 221 $frm['new_op'] = 'update'; 222 $frm['submit_caption'] = _("Save changes"); 223 $frm['repeat_caption'] = _("Save & edit next"); 224 $frm['reset_caption'] = _("Reset"); 225 $frm['cancel_caption'] = _("Cancel"); 226 $frm['%PRIMARY_KEY%'] = $id; 227 228 return $frm; 229 } 204 } 205 206 // Get the information for the form. 207 $qid = DB::query(" 208 SELECT * 209 FROM %DB_TBL% 210 WHERE %PRIMARY_KEY% = '" . addslashes($id) . "' 211 "); 212 if (!$frm = mysql_fetch_assoc($qid)) { 213 App::logMsg('Could not find record with %PRIMARY_KEY%: ' . $id, LOG_WARNING, __FILE__, __LINE__); 214 App::raiseMsg(sprintf(_("The requested record %s could not be found"), $id), MSG_ERR, __FILE__, __LINE__); 215 App::dieBoomerangURL(); 216 } 217 218 // Lock this record. 219 $lock->set('%DB_TBL%', '%PRIMARY_KEY%', $id, $frm['address']); 220 221 // Set misc values for the form. 222 $frm = array_merge(array( 223 %SET_VALUES_DEFAULT%, 224 'new_op' => 'update', 225 'submit_buttons' => array( 226 'submit' => _("Save changes"), 227 'repeat' => _("Save & edit next"), 228 'reset' => _("Reset"), 229 'cancel' => _("Cancel"), 230 ), 231 ), $frm); 232 233 return $frm; 230 234 } 231 235 -
trunk/docs/example_config.inc.php
r9 r10 9 9 */ 10 10 11 if (!preg_match('!^/!', __FILE__)) { 11 // __FILE__ must be an absolute directory path, starting with / on unix and X: on windows. 12 if (!preg_match('!^/|^[A-Z]:!', __FILE__)) { 12 13 trigger_error('_config.inc.php include must be specified with an absolute file path (eg: "require_once dirname(__FILE__) . \'/_config.inc.php\';"', E_USER_ERROR); 13 14 } -
trunk/lib/DB.inc.php
r9 r10 160 160 $this->_connected = true; 161 161 162 // Tell MySQL what character set we're useing. 163 if (preg_match('/^4\.[1-9].*$|^5.*$/', mysql_get_server_info())) { 164 $this->query("SET NAMES '" . $this->mysql_character_sets[strtolower(App::getParam('character_set'))] . "'"); 165 } 166 162 // Tell MySQL what character set we're useing. Available only on MySQL verions > 4.01.01. 163 $this->query("/*!40101 SET NAMES '" . $this->mysql_character_sets[strtolower(App::getParam('character_set'))] . "' */"); 164 167 165 return true; 168 166 }
Note: See TracChangeset
for help on using the changeset viewer.