/** * create all table's dto and dao * * @access public */ function autoCreate() { $fileUtility = new FileUtility(); $stringUtility = new StringUtility(); $tableDefinitionDao = new TableDefinitionDao(); $tableNameArray = $tableDefinitionDao->getTableNameList(); $fileNameArray = array(); $generationGapSuffix = GENERATIONGAP_SUFFIX; $baseDaoGenerator = new BaseDaoGenerator(); $baseDao = $baseDaoGenerator->createBaseDaoClass(); $fileUtility->writePhpFile(OUTPUT_DIR . "BaseDao", $baseDao); $fileNameArray[] = "BaseDao"; $dtoGenerator = new DtoGenerator(); $dto = $dtoGenerator->createDto(); $fileUtility->writePhpFile(OUTPUT_DIR . $className . "TableDto", $dto); $fileNameArray[] = $className . "TableDto"; foreach ($tableNameArray as $tableName) { $className = $stringUtility->getClassName($tableName); $columnList = $tableDefinitionDao->getColumnList($tableName); $primaryKeyList = $tableDefinitionDao->getPrimaryKeyList($tableName); $daoGenerator = new DaoGenerator(); if (USE_BASE_CLASS) { $dao = $daoGenerator->createDao($tableName, $columnList, $primaryKeyList[0], "BaseDao"); } else { $dao = $daoGenerator->createDao($tableName, $columnList, $primaryKeyList[0]); } $fileUtility->writePhpFile(OUTPUT_DIR . $className . "Dao", $dao); $fileNameArray[] = $className . "Dao"; } return $fileNameArray; }
public static function getParentPathFromPath($path) { $array = StringUtility::getExplodedStringArray('/', $path); $count = count($array); if ($count == 1) { return "/"; } else { if ($count > 1) { return implode('/', array_slice($array, 0, count($array) - 1)); } } return ""; // empty string }
/** * Creates an absolute URL out of really any input path, removes '../' parts for the targetPath * * @param string $targetPath can be "../../typo3/contrib/myfile.js" or "/myfile.js" * @return string something like "/mysite/typo3/sysext/backend.js" */ public static function getAbsoluteWebPath($targetPath) { if (self::isAbsolutePath($targetPath)) { if (StringUtility::beginsWith($targetPath, PATH_site)) { $targetPath = GeneralUtility::getIndpEnv('TYPO3_SITE_PATH') . self::stripPathSitePrefix($targetPath); } } elseif (strpos($targetPath, '://') !== FALSE) { return $targetPath; } else { // Make an absolute path out of it $targetPath = GeneralUtility::resolveBackPath(dirname(PATH_thisScript) . '/' . $targetPath); $targetPath = self::stripPathSitePrefix($targetPath); $targetPath = GeneralUtility::getIndpEnv('TYPO3_SITE_PATH') . $targetPath; } return $targetPath; }
public function formatProgramName() { //is default program title within allowed length? if (StringUtility::isStringLengthLessThanMaxAllowed($this->CustomProgramName, $this->chars_allowed)) { return; } //no? let's apply marketing (short) program title if (!empty($this->CustomProgramNameShort)) { $this->CustomProgramName = $this->CustomProgramNameShort; } //we applied marketing program title (above) - is the program title now within allowed length? if (StringUtility::isStringLengthLessThanMaxAllowed($this->CustomProgramName, $this->chars_allowed)) { return; } //no? we'll have to forcibly shrink it $this->CustomProgramName = StringUtility::shrinkString($this->CustomProgramName, $this->chars_allowed); }
// get content types related to configuration set $contentTypes = $configSet->getAsset($service)->getSubscribers(); $countCT = count($contentTypes); $totalContentTypes += $countCT; // keep a running total // name of configuration set // Replace '#' with link(/link-fetching code) $ctTxt .= "{\"name\": \"" . $configSet->getPathPath() . "\", \"type\":" . "\"pageconfigurationset\", \"children\":"; $ctTxt .= "["; foreach ($contentTypes as $contentType) { // CONTENT TYPE $pages = $contentType->getAsset($service)->getSubscribers(); $pageCount = count($pages); $totalPages += $pageCount; // Replace '#' with link(/link-fetching code) $ctTxt .= "{\"name\": \"" . StringUtility::getNameFromPath($contentType->getPathPath()) . "\"," . " \"type\": \"contenttype\", \"children\":"; $ctTxt .= "["; if ($pageCount > 0) { foreach ($pages as $page) { // PAGE // Replace '#' with link(/link-fetching code) $ctTxt .= "{\"name\": \"" . $page->getPathPath() . "\", \"url\":" . "\"https://cascade.union.edu:8443/entity/open.act?id=" . $page->getId() . "&type=page\", \"type\": \"page\"},"; } } $ctTxt = rtrim($ctTxt, ","); // Remove last comma, which is invalid. $ctTxt .= "],"; // list of content type pages $ctTxt .= "\"count\": " . $pageCount . "},"; } $ctTxt = rtrim($ctTxt, ",");
function imageNameNoExtension() { $base = Application::basename($this->info->getFilePath()); $arr = StringUtility::split($base, "."); $ret = $arr[0]; return $ret; }
/** * Compresses a string of JavaScript code, removing whitespace, extra * newlines, and extra whitespace. * * @param string Uncompressed JavaScript source code. * @return string Compressed JavaScript code. */ protected function compress($string) { /* Remove leading and trailing whitespace from each line (note, the * ungreedy modifier before the '$' in the below regular expression * should theoretically not be needed, but without it, it seems to * eat newlines. */ $string = preg_replace('/^\\s*(.*?)\\s*?$/m', '\\1', $string); /* Remove C / C++ comments. * * \x27 is a single quote, \x5c is a backslash. * * This is based on code from Jeffrey Friedl's Mastering Regular * Expressions, 3rd Edition (O'Reilly Media, Inc.). * * If you're thinking about rewriting this, you'll probably break it. * It's very fragile ;). */ $string = preg_replace('@([^"\\x27/]+|"[^\\x5c"]*(?:\\x5c.[^\\x5c"]*)*"[^"\\x27/]*|\\x27[^\\x27\\x5c]*(?:\\x5c.[^\\x27\\x5c]*)*\\x27[^"\\x27/]*)|/\\*[^*]*\\*+(?:[^/*][^*]*\\*+)*/|//[^\\n]*@', '\\1', $string); /* Remove any blank lines from the string. */ $string = StringUtility::removeEmptyLines($string); /* "Safe" newline removal. This should work with just about any code * that a browser's JavaScript implementation can understand. * Significant newlines will never be removed. */ $string = preg_replace('/;\\n/', ';', $string); $string = preg_replace('/\\{\\n/', '{', $string); $string = preg_replace('/\\)\\n{/', ') {', $string); $string = preg_replace('/\\}\\nelse/', '} else', $string); $string = preg_replace('/else\\n\\{/', 'else {', $string); return $string; }
private function _encode($string) { return str_replace(';', '\\;', StringUtility::quotedPrintableEncode($string)); }
$activityDate = trim(urldecode($_REQUEST['date'])); $activityHour = trim(urldecode($_REQUEST['hour'])); $activityMinute = trim(urldecode($_REQUEST['minute'])); $activityAMPM = trim(urldecode($_REQUEST['ampm'])); if (!DateUtility::validate('-', $activityDate, DATE_FORMAT_MMDDYY)) { die('Invalid availability date.'); return; } /* Convert formatted time to UNIX timestamp. */ $time = strtotime(sprintf('%s:%s %s', $activityHour, $activityMinute, $activityAMPM)); /* Create MySQL date string w/ 24hr time (YYYY-MM-DD HH:MM:SS). */ $date = sprintf('%s %s', DateUtility::convert('-', $activityDate, DATE_FORMAT_MMDDYY, DATE_FORMAT_YYYYMMDD), date('H:i:00', $time)); /* Highlight what needs highlighting. */ if (strpos($activityNote, 'Status change: ') === 0) { $pipelines = new Pipelines($siteID); $statusRS = $pipelines->getStatusesForPicking(); foreach ($statusRS as $data) { $activityNote = StringUtility::replaceOnce($data['status'], '<span style="color: #ff6c00;">' . $data['status'] . '</span>', $activityNote); } } /* Save the new activity entry. */ $activityEntries = new ActivityEntries($siteID); $activityEntries->update($activityID, $type, $activityNote, $jobOrderID, $date, $_SESSION['CATS']->getTimeZoneOffset()); /* Grab the current activity entry. */ $activityEntry = $activityEntries->get($activityID); /* Send back "(No Notes)" to be displayed if we don't have any. */ if (empty($activityEntry['notes'])) { $activityEntry['notes'] = '(No Notes)'; } /* Send back the XML data. */ $interface->outputXMLPage("<data>\n" . " <errorcode>0</errorcode>\n" . " <errormessage></errormessage>\n" . " <type>" . $activityEntry['type'] . "</type>\n" . " <typedescription>" . $activityEntry['typeDescription'] . "</typedescription>\n" . " <notes>" . htmlspecialchars($activityEntry['notes']) . "</notes>\n" . " <regarding>" . htmlspecialchars($activityEntry['regarding']) . "</regarding>\n" . " <date>" . htmlspecialchars($activityEntry['dateCreated']) . "</date>\n" . "</data>\n");
function copyDirectory($src, $dest) { $ret = ''; if (@opendir($dest)) { if (@opendir($src)) { $list = FileUtlity::directoryList($src, FileUtility::RECURSE); foreach ($list as $dir => $files) { $path_array = StringUtility::split($dir, '/'); /*test for trailing slash*/ if (!preg_match('\\//$', $dest)) { $dest = $dest . '/'; } $cur_path = $dest; foreach ($path_array as $pcmp) { $cur_path = $cur_path . $pcmp; if (!@opendir($cur_path)) { mkdir($cur_path); } } foreach ($files as $file) { FileUtility::copyFile($dir . $file, $cur_path . $file); } } } else { throw new Exception('Source directory: ' . $src . ' does not exist or isn\'t a directory in fileutility.class.inc'); } } else { throw new Exception('Destination directory: ' . $dest . ' does not exist or isn\'t a directory in fileutility.class.inc'); } }
/** * Returns an array of the 'edit' values from a listEditor.js array. * * @param listEditor array * @return listEditor array */ public static function getEditValues($theArray) { $theArrayValues = array(); for ($i = 0; $i < count($theArray); $i++) { if (strpos($theArray[$i], '!!EDIT!!') === 0) { $from = StringUtility::JSSubString($theArray[$i], 8, strpos($theArray[$i], '!!INTO!!')); $into = StringUtility::JSSubString($theArray[$i], strpos($theArray[$i], '!!INTO!!') + 8, strlen($theArray[$i])); $theArrayValues[] = array($from, $into); } } return $theArrayValues; }
/** *This method gets and returns the table name. *@param null *@return string The table name */ public function getTable() { //check if the table name variable contains a value if (empty($this->table)) { //if table is not set yet, get a table name from this class instance $this->table = strtolower(StringUtility::singular(get_class($this))); } //return the formed table name return $this->table; }
private function displayPublicJobOrders() { $site = new Site(-1); $careerPortalSiteID = $site->getFirstSiteID(); if (!eval(Hooks::get('RSS_SITEID'))) { return; } $jobOrders = new JobOrders($careerPortalSiteID); $rs = $jobOrders->getAll(JOBORDERS_STATUS_ACTIVE, -1, -1, -1, false, true); /* XML Headers */ header('Content-type: text/xml'); $indexName = CATSUtility::getIndexName(); $stream = sprintf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" . "<rss version=\"2.0\">\n" . "<channel>\n" . "<title>New Job Orders</title>\n" . "<description>CATS RSS Feed</description>\n" . "<link>%s</link>\n" . "<pubDate>%s</pubDate>\n", CATSUtility::getAbsoluteURI(), DateUtility::getRSSDate()); foreach ($rs as $rowIndex => $row) { $uri = sprintf("%scareers/?p=showJob&ID=%d", CATSUtility::getAbsoluteURI(), $row['jobOrderID']); // Fix URL if viewing from /rss without using globals or dirup '../' if (strpos($_SERVER['PHP_SELF'], '/rss/') !== false) { $uri = str_replace('/rss/', '/', $uri); } $stream .= sprintf("<item>\n" . "<title>%s (%s)</title>\n" . "<description>Located in %s.</description>\n" . "<link>%s</link>\n" . "</item>\n", $row['title'], $jobOrders->typeCodeToString($row['type']), StringUtility::makeCityStateString($row['city'], $row['state']), $uri); } $stream .= "</channel>\n</rss>\n"; echo $stream; }
protected function _getPhoneNumbers() { /* Sanity check. It is possible that the only line of the address * block has been removed during e-mail address extraction. */ if (empty($this->_addressBlock)) { return array(); } $unknownNumbers = array(); $numbers = array(); /* Loop through each line of the address block and attempt to extract * and identify phone numbers. */ foreach ($this->_addressBlock as $lineNumber => $line) { /* Skip lines that don't contain phone numbers. */ if (!StringUtility::containsPhoneNumber($line)) { continue; } /* Regular expressions to help identify phone number types. */ $cell = '/cell|[\\x28\\x5b][CM][\\x29\\x5d]|mob(:?ile|\\b)|\\bc[:\\x5d]|\\bm[:\\x5d]/i'; $home = '/[\\x28\\x5b]H[\\x29\\x5d]|home|evening|night|house/i'; $work = '/work|off(:?ice|\\b)|[\\x28\\x5b][WO][\\x29\\x5d]|direct|day(?:time)?|job/i'; $general = '/[\\x28\\x5b]PH?[\\x29\\x5d]|primary|voice|main|toll|ph(:?one|\\b)/i'; $fax = '/[\\x28\\x5b]FX?[\\x29\\x5d]|fax|facsimile|\\bFX?[:\\x5d]/i'; $tty = '/\\bTT[YD]\\b/i'; $pager = '/pager|beeper/i'; /* Look for keywords that might tell us what type of number it is. * First check to see if the line is ONLY a phone number. If not, * try do identify what kind of phone number it is. * * \x28 is a '(', \x5b is a '[', \x29 is a ')', \x5d is a ']'. */ if (preg_match($cell, $line)) { $numbers[] = array('number' => StringUtility::extractPhoneNumber($line), 'type' => 'cell'); } else { if (preg_match($home, $line)) { $numbers[] = array('number' => StringUtility::extractPhoneNumber($line), 'type' => 'home'); } else { if (preg_match($work, $line)) { $numbers[] = array('number' => StringUtility::extractPhoneNumber($line), 'type' => 'work'); } else { if (preg_match($general, $line)) { if ($this->_mode != ADDRESSPARSER_MODE_COMPANY) { $unknownNumbers[] = StringUtility::extractPhoneNumber($line); } else { $numbers[] = array('number' => StringUtility::extractPhoneNumber($line), 'type' => 'general'); } } else { if (preg_match($fax, $line)) { $numbers[] = array('number' => StringUtility::extractPhoneNumber($line), 'type' => 'fax'); } else { if (preg_match($tty, $line)) { $numbers[] = array('number' => StringUtility::extractPhoneNumber($line), 'type' => 'tty'); } else { if (preg_match($pager, $line)) { $numbers[] = array('number' => StringUtility::extractPhoneNumber($line), 'type' => 'pager'); } else { if (StringUtility::isPhoneNumber($line)) { /* In this case, the line contains only a phone number, and is * truely unknown. */ $unknownNumbers[] = StringUtility::extractPhoneNumber($line); } else { /* In this case, the line contains other data besides just a * phone number. We just can't identify it as anything. */ $unknownNumbers[] = StringUtility::extractPhoneNumber($line); } } } } } } } } } /* Figure out which phone number types we've already found. We'll * use this below. */ $homePhoneRow = ResultSetUtility::findRowByColumnValue($numbers, 'type', 'home'); $workPhoneRow = ResultSetUtility::findRowByColumnValue($numbers, 'type', 'work'); $cellPhoneRow = ResultSetUtility::findRowByColumnValue($numbers, 'type', 'cell'); /* Did we find any unknown phone numbers? If so, we have to try to * guess their types. */ $unknownCount = count($unknownNumbers); if ($unknownCount == 1) { /* If we're only missing one of the three phone number types, and we * found a number on a line by itself, we will assume that the extra * number is one of the missing ones. * * If we don't have a work number, but we have a home number * and a cell number, this is probably a work number. */ if ($workPhoneRow === false && $homePhoneRow !== false && $cellPhoneRow !== false) { $numbers[] = array('number' => $unknownNumbers[0], 'type' => 'work'); } else { if ($homePhoneRow === false && $workPhoneRow !== false && $cellPhoneRow !== false) { $numbers[] = array('number' => $unknownNumbers[0], 'type' => 'home'); } else { if ($cellPhoneRow === false && $workPhoneRow !== false && $homePhoneRow !== false) { $numbers[] = array('number' => $unknownNumbers[0], 'type' => 'cell'); } else { if ($cellPhoneRow !== false && $workPhoneRow !== false && $homePhoneRow !== false) { /* We already know all the phone numbers we need to know, and * it's probably not a fax number, as fax numbers are usually * labeled. Nothing to do except mark it as unknown. */ $numbers[] = array('number' => $unknownNumbers[0], 'type' => 'unknown'); } else { /* We have more than one phone number missing. We will make a * "best guess" according to the mode we are in. */ switch ($this->_mode) { case ADDRESSPARSER_MODE_PERSON: if ($homePhoneRow === false) { $type = 'home'; } else { if ($cellPhoneRow === false) { $type = 'cell'; } else { if ($workPhoneRow === false) { $type = 'work'; } else { $type = 'unknown'; } } } break; case ADDRESSPARSER_MODE_CONTACT: /* 'Contacts' are more likely to list a work or cell * number than a home number. */ if ($workPhoneRow === false) { $type = 'work'; } else { if ($cellPhoneRow === false) { $type = 'cell'; } else { if ($homePhoneRow === false) { $type = 'home'; } else { $type = 'unknown'; } } } break; case ADDRESSPARSER_MODE_COMPANY: // FIXME: Here we should be looking for "general". // We could also have two phone phone numbers. $type = 'general'; break; default: /* Error! Invalid mode. */ $type = 'unknown'; break; } $numbers[] = array('number' => $unknownNumbers[0], 'type' => $type); } } } } } else { if ($unknownCount > 1) { // FIXME } } return $numbers; }
<tr> <td align="left" valign="top" style="text-align: left; width: 50%; height: 240px;"> <div class="noteUnsizedSpan" style="width:410px;">Recent Hires</div> <table class="sortable" width="410" style="margin: 0 0 4px 0;"> <tr> <th align="left" style="font-size:11px;">Name</th> <th align="left" style="font-size:11px;">Company</th> <th align="left" style="font-size:11px;">Recruiter</th> <th align="left" style="font-size:11px;">Date</th> </tr> <?php foreach($this->placedRS as $index => $data): ?> <tr class="<?php TemplateUtility::printAlternatingRowClass($index); ?>"> <td style="font-size:11px;"><a href="<?php echo(CATSUtility::getIndexName()); ?>?m=candidates&a=show&candidateID=<?php echo($data['candidateID']); ?>"style="font-size:11px;" class="<?php echo($data['candidateClassName']); ?>"><?php $this->_($data['firstName']); ?> <?php $this->_($data['lastName']); ?></a></td> <td style="font-size:11px;"><a href="<?php echo(CATSUtility::getIndexName()); ?>?m=companies&a=show&companyID=<?php echo($data['companyID']); ?>" style="font-size:11px;" class="<?php echo($data['companyClassName']); ?>"><?php $this->_($data['companyName']); ?></td> <td style="font-size:11px;"><?php $this->_(StringUtility::makeInitialName($data['userFirstName'], $data['userLastName'], false, LAST_NAME_MAXLEN)); ?></td> <td style="font-size:11px;"><?php $this->_($data['date']); ?></td> </tr> <?php endforeach; ?> </table> <?php if (!count($this->placedRS)): ?> <div style="width: 411px; height: 207px; border: 1px solid #c0c0c0; background: #E7EEFF url(images/nodata/dashboardNoHiresWhite.jpg);"> </div> <?php endif; ?> </td> <td align="center" valign="top" style="text-align: left; width: 50%; height: 240px;"> <div class="noteUnsizedSpan" style="width:495px;">Hiring Overview</div> <map name="dashboardmap" id="dashboardmap">
public function quickSearch() { /* Bail out to prevent an error if the GET string doesn't even contain * a field named 'quickSearchFor' at all. */ if (!isset($_GET['quickSearchFor'])) { CommonErrors::fatal(COMMONERROR_BADFIELDS, $this, 'No query string specified.'); } $query = trim($_GET['quickSearchFor']); $wildCardQuickSearch = $query; $search = new QuickSearch($this->_siteID); $candidatesRS = $search->candidates($query); $companiesRS = $search->companies($query); $contactsRS = $search->contacts($query); $jobOrdersRS = $search->jobOrders($query); //$listsRS = $search->lists($query); if (!empty($candidatesRS)) { foreach ($candidatesRS as $rowIndex => $row) { if (!empty($candidatesRS[$rowIndex]['ownerFirstName'])) { $candidatesRS[$rowIndex]['ownerAbbrName'] = StringUtility::makeInitialName( $candidatesRS[$rowIndex]['ownerFirstName'], $candidatesRS[$rowIndex]['ownerLastName'], false, LAST_NAME_MAXLEN ); } else { $candidatesRS[$rowIndex]['ownerAbbrName'] = 'None'; } if (empty($candidatesRS[$rowIndex]['phoneHome'])) { $candidatesRS[$rowIndex]['phoneHome'] = 'None'; } if (empty($candidatesRS[$rowIndex]['phoneCell'])) { $candidatesRS[$rowIndex]['phoneCell'] = 'None'; } } } if (!empty($companiesRS)) { foreach ($companiesRS as $rowIndex => $row) { if (!empty($companiesRS[$rowIndex]['ownerFirstName'])) { $companiesRS[$rowIndex]['ownerAbbrName'] = StringUtility::makeInitialName( $companiesRS[$rowIndex]['ownerFirstName'], $companiesRS[$rowIndex]['ownerLastName'], false, LAST_NAME_MAXLEN ); } else { $companiesRS[$rowIndex]['ownerAbbrName'] = 'None'; } if (empty($companiesRS[$rowIndex]['phone1'])) { $companiesRS[$rowIndex]['phone1'] = 'None'; } } } if (!empty($contactsRS)) { foreach ($contactsRS as $rowIndex => $row) { if ($contactsRS[$rowIndex]['isHotContact'] == 1) { $contactsRS[$rowIndex]['linkClassContact'] = 'jobLinkHot'; } else { $contactsRS[$rowIndex]['linkClassContact'] = 'jobLinkCold'; } if ($contactsRS[$rowIndex]['leftCompany'] == 1) { $contactsRS[$rowIndex]['linkClassCompany'] = 'jobLinkDead'; } else if ($contactsRS[$rowIndex]['isHotCompany'] == 1) { $contactsRS[$rowIndex]['linkClassCompany'] = 'jobLinkHot'; } else { $contactsRS[$rowIndex]['linkClassCompany'] = 'jobLinkCold'; } if (!empty($contactsRS[$rowIndex]['ownerFirstName'])) { $contactsRS[$rowIndex]['ownerAbbrName'] = StringUtility::makeInitialName( $contactsRS[$rowIndex]['ownerFirstName'], $contactsRS[$rowIndex]['ownerLastName'], false, LAST_NAME_MAXLEN ); } else { $contactsRS[$rowIndex]['ownerAbbrName'] = 'None'; } if (empty($contactsRS[$rowIndex]['phoneWork'])) { $contactsRS[$rowIndex]['phoneWork'] = 'None'; } if (empty($contactsRS[$rowIndex]['phoneCell'])) { $contactsRS[$rowIndex]['phoneCell'] = 'None'; } } } if (!empty($jobOrdersRS)) { foreach ($jobOrdersRS as $rowIndex => $row) { if ($jobOrdersRS[$rowIndex]['startDate'] == '00-00-00') { $jobOrdersRS[$rowIndex]['startDate'] = ''; } if ($jobOrdersRS[$rowIndex]['isHot'] == 1) { $jobOrdersRS[$rowIndex]['linkClass'] = 'jobLinkHot'; } else { $jobOrdersRS[$rowIndex]['linkClass'] = 'jobLinkCold'; } if (!empty($jobOrdersRS[$rowIndex]['recruiterAbbrName'])) { $jobOrdersRS[$rowIndex]['recruiterAbbrName'] = StringUtility::makeInitialName( $jobOrdersRS[$rowIndex]['recruiterFirstName'], $jobOrdersRS[$rowIndex]['recruiterLastName'], false, LAST_NAME_MAXLEN ); } else { $jobOrdersRS[$rowIndex]['recruiterAbbrName'] = 'None'; } if (!empty($jobOrdersRS[$rowIndex]['ownerFirstName'])) { $jobOrdersRS[$rowIndex]['ownerAbbrName'] = StringUtility::makeInitialName( $jobOrdersRS[$rowIndex]['ownerFirstName'], $jobOrdersRS[$rowIndex]['ownerLastName'], false, LAST_NAME_MAXLEN ); } else { $jobOrdersRS[$rowIndex]['ownerAbbrName'] = 'None'; } } } $this->_template->assign('active', $this); $this->_template->assign('jobOrdersRS', $jobOrdersRS); $this->_template->assign('candidatesRS', $candidatesRS); $this->_template->assign('companiesRS', $companiesRS); $this->_template->assign('contactsRS', $contactsRS); //$this->_template->assign('listsRS', $listsRS); $this->_template->assign('wildCardQuickSearch', $wildCardQuickSearch); if (!eval(Hooks::get('HOME_QUICK_SEARCH'))) return; $this->_template->display('./modules/home/SearchEverything.php'); }
/** * Processes an Add Activity / Change Status form and displays * candidates/AddActivityChangeStatusModal.tpl. This is factored out * for code clarity. * * @param boolean from joborders module perspective * @param integer "regarding" job order ID or -1 * @param string module directory * @return void */ private function _addActivityChangeStatus($isJobOrdersMode, $regardingID, $directoryOverride = '') { $notificationHTML = ''; $pipelines = new Pipelines($this->_siteID); $statusRS = $pipelines->getStatusesForPicking(); /* Module directory override for fatal() calls. */ if ($directoryOverride != '') { $moduleDirectory = $directoryOverride; } else { $moduleDirectory = $this->_moduleDirectory; } /* Bail out if we don't have a valid candidate ID. */ if (!$this->isRequiredIDValid('candidateID', $_POST)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid candidate ID.'); } /* Do we have a valid status ID. */ if (!$this->isOptionalIDValid('statusID', $_POST)) { $statusID = -1; } else { $statusID = $_POST['statusID']; } $candidateID = $_POST['candidateID']; if (!eval(Hooks::get('CANDIDATE_ON_ADD_ACTIVITY_CHANGE_STATUS_PRE'))) { return; } if ($this->isChecked('addActivity', $_POST)) { /* Bail out if we don't have a valid job order ID. */ if (!$this->isOptionalIDValid('activityTypeID', $_POST)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid activity type ID.'); } $activityTypeID = $_POST['activityTypeID']; $activityNote = $this->getTrimmedInput('activityNote', $_POST); $activityNote = htmlspecialchars($activityNote); // FIXME: Move this to a highlighter-method? */ if (strpos($activityNote, 'Status change: ') === 0) { foreach ($statusRS as $data) { $activityNote = StringUtility::replaceOnce($data['status'], '<span style="color: #ff6c00;">' . $data['status'] . '</span>', $activityNote); } } /* Add the activity entry. */ $activityEntries = new ActivityEntries($this->_siteID); $activityID = $activityEntries->add($candidateID, DATA_ITEM_CANDIDATE, $activityTypeID, $activityNote, $this->_userID, $regardingID); $activityTypes = $activityEntries->getTypes(); $activityTypeDescription = ResultSetUtility::getColumnValueByIDValue($activityTypes, 'typeID', $activityTypeID, 'type'); $activityAdded = true; } else { $activityAdded = false; $activityNote = ''; $activityTypeDescription = ''; } if ($regardingID <= 0 || $statusID == -1) { $statusChanged = false; $oldStatusDescription = ''; $newStatusDescription = ''; } else { $data = $pipelines->get($candidateID, $regardingID); /* Bail out if we got an empty result set. */ if (empty($data)) { $this->fatalModal('The specified pipeline entry could not be found.'); } $validStatus = ResultSetUtility::findRowByColumnValue($statusRS, 'statusID', $statusID); /* If the status is invalid or unchanged, don't mess with it. */ if ($validStatus === false || $statusID == $data['status']) { $oldStatusDescription = ''; $newStatusDescription = ''; $statusChanged = false; } else { $oldStatusDescription = $data['status']; $newStatusDescription = ResultSetUtility::getColumnValueByIDValue($statusRS, 'statusID', $statusID, 'status'); if ($oldStatusDescription != $newStatusDescription) { $statusChanged = true; } else { $statusChanged = false; } } if ($statusChanged && $this->isChecked('triggerEmail', $_POST)) { $customMessage = $this->getTrimmedInput('customMessage', $_POST); // FIXME: Actually validate the e-mail address? if (empty($data['candidateEmail'])) { $email = ''; $notificationHTML = '<p><span class="bold">Error:</span> An e-mail notification' . ' could not be sent to the candidate because the candidate' . ' does not have a valid e-mail address.</p>'; } else { if (empty($customMessage)) { $email = ''; $notificationHTML = '<p><span class="bold">Error:</span> An e-mail notification' . ' will not be sent because the message text specified was blank.</p>'; } else { if ($this->_accessLevel == ACCESS_LEVEL_DEMO) { $email = ''; $notificationHTML = '<p><span class="bold">Error:</span> Demo users can not send' . ' E-Mails. No E-Mail was sent.</p>'; } else { $email = $data['candidateEmail']; $notificationHTML = '<p>An e-mail notification has been sent to the candidate.</p>'; } } } } else { $email = ''; $customMessage = ''; $notificationHTML = '<p>No e-mail notification has been sent to the candidate.</p>'; } /* Set the pipeline entry's status, but don't send e-mails for now. */ $pipelines->setStatus($candidateID, $regardingID, $statusID, $email, $customMessage); /* If status = placed, and open positions > 0, reduce number of open positions by one. */ if ($statusID == PIPELINE_STATUS_PLACED && is_numeric($data['openingsAvailable']) && $data['openingsAvailable'] > 0) { $jobOrders = new JobOrders($this->_siteID); $jobOrders->updateOpeningsAvailable($regardingID, $data['openingsAvailable'] - 1); } } if ($this->isChecked('scheduleEvent', $_POST)) { /* Bail out if we received an invalid date. */ $trimmedDate = $this->getTrimmedInput('dateAdd', $_POST); if (empty($trimmedDate) || !DateUtility::validate('-', $trimmedDate, DATE_FORMAT_MMDDYY)) { CommonErrors::fatalModal(COMMONERROR_MISSINGFIELDS, $this, 'Invalid date.'); } /* Bail out if we don't have a valid event type. */ if (!$this->isRequiredIDValid('eventTypeID', $_POST)) { CommonErrors::fatalModal(COMMONERROR_BADINDEX, $this, 'Invalid event type ID.'); } /* Bail out if we don't have a valid time format ID. */ if (!isset($_POST['allDay']) || $_POST['allDay'] != '0' && $_POST['allDay'] != '1') { CommonErrors::fatalModal(COMMONERROR_MISSINGFIELDS, $this, 'Invalid time format ID.'); } $eventTypeID = $_POST['eventTypeID']; if ($_POST['allDay'] == 1) { $allDay = true; } else { $allDay = false; } $publicEntry = $this->isChecked('publicEntry', $_POST); $reminderEnabled = $this->isChecked('reminderToggle', $_POST); $reminderEmail = $this->getTrimmedInput('sendEmail', $_POST); $reminderTime = $this->getTrimmedInput('reminderTime', $_POST); $duration = $this->getTrimmedInput('duration', $_POST); /* Is this a scheduled event or an all day event? */ if ($allDay) { $date = DateUtility::convert('-', $trimmedDate, DATE_FORMAT_MMDDYY, DATE_FORMAT_YYYYMMDD); $hour = 12; $minute = 0; $meridiem = 'AM'; } else { /* Bail out if we don't have a valid hour. */ if (!isset($_POST['hour'])) { CommonErrors::fatalModal(COMMONERROR_MISSINGFIELDS, $this, 'Invalid hour.'); } /* Bail out if we don't have a valid minute. */ if (!isset($_POST['minute'])) { CommonErrors::fatalModal(COMMONERROR_MISSINGFIELDS, $this, 'Invalid minute.'); } /* Bail out if we don't have a valid meridiem value. */ if (!isset($_POST['meridiem']) || $_POST['meridiem'] != 'AM' && $_POST['meridiem'] != 'PM') { $this->fatalModal('Invalid meridiem value.', $moduleDirectory); } $hour = $_POST['hour']; $minute = $_POST['minute']; $meridiem = $_POST['meridiem']; /* Convert formatted time to UNIX timestamp. */ $time = strtotime(sprintf('%s:%s %s', $hour, $minute, $meridiem)); /* Create MySQL date string w/ 24hr time (YYYY-MM-DD HH:MM:SS). */ $date = sprintf('%s %s', DateUtility::convert('-', $trimmedDate, DATE_FORMAT_MMDDYY, DATE_FORMAT_YYYYMMDD), date('H:i:00', $time)); } $description = $this->getTrimmedInput('description', $_POST); $title = $this->getTrimmedInput('title', $_POST); /* Bail out if any of the required fields are empty. */ if (empty($title)) { CommonErrors::fatalModal(COMMONERROR_MISSINGFIELDS, $this); return; /*$this->fatalModal( 'Required fields are missing.', $moduleDirectory );*/ } if ($regardingID > 0) { $eventJobOrderID = $regardingID; } else { $eventJobOrderID = -1; } $calendar = new Calendar($this->_siteID); $eventID = $calendar->addEvent($eventTypeID, $date, $description, $allDay, $this->_userID, $candidateID, DATA_ITEM_CANDIDATE, $eventJobOrderID, $title, $duration, $reminderEnabled, $reminderEmail, $reminderTime, $publicEntry, $_SESSION['CATS']->getTimeZoneOffset()); if ($eventID <= 0) { $this->fatalModal('Failed to add calendar event.', $moduleDirectory); } /* Extract the date parts from the specified date. */ $parsedDate = strtotime($date); $formattedDate = date('l, F jS, Y', $parsedDate); $calendar = new Calendar($this->_siteID); $calendarEventTypes = $calendar->getAllEventTypes(); $eventTypeDescription = ResultSetUtility::getColumnValueByIDValue($calendarEventTypes, 'typeID', $eventTypeID, 'description'); $eventHTML = sprintf('<p>An event of type <span class="bold">%s</span> has been scheduled on <span class="bold">%s</span>.</p>', htmlspecialchars($eventTypeDescription), htmlspecialchars($formattedDate)); $eventScheduled = true; } else { $eventHTML = '<p>No event has been scheduled.</p>'; $eventScheduled = false; } if (isset($_GET['onlyScheduleEvent'])) { $onlyScheduleEvent = true; } else { $onlyScheduleEvent = false; } if (!$statusChanged && !$activityAdded && !$eventScheduled) { $changesMade = false; } else { $changesMade = true; } if (!eval(Hooks::get('CANDIDATE_ON_ADD_ACTIVITY_CHANGE_STATUS_POST'))) { return; } $this->_template->assign('candidateID', $candidateID); $this->_template->assign('regardingID', $regardingID); $this->_template->assign('oldStatusDescription', $oldStatusDescription); $this->_template->assign('newStatusDescription', $newStatusDescription); $this->_template->assign('statusChanged', $statusChanged); $this->_template->assign('activityAdded', $activityAdded); $this->_template->assign('activityDescription', $activityNote); $this->_template->assign('activityType', $activityTypeDescription); $this->_template->assign('eventScheduled', $eventScheduled); $this->_template->assign('eventHTML', $eventHTML); $this->_template->assign('notificationHTML', $notificationHTML); $this->_template->assign('onlyScheduleEvent', $onlyScheduleEvent); $this->_template->assign('changesMade', $changesMade); $this->_template->assign('isFinishedMode', true); $this->_template->assign('isJobOrdersMode', $isJobOrdersMode); $this->_template->display('./modules/candidates/AddActivityChangeStatusModal.tpl'); }
/** * Formats SQL result set for display. This is factored out for code * clarity. * * @param array result set from listByView() * @return array formatted result set */ private function _formatListByViewResults($resultSet) { if (empty($resultSet)) { return $resultSet; } foreach ($resultSet as $rowIndex => $row) { if (!empty($resultSet[$rowIndex]['ownerFirstName'])) { $resultSet[$rowIndex]['ownerAbbrName'] = StringUtility::makeInitialName($resultSet[$rowIndex]['ownerFirstName'], $resultSet[$rowIndex]['ownerLastName'], false, LAST_NAME_MAXLEN); } else { $resultSet[$rowIndex]['ownerAbbrName'] = 'None'; } /* Hot contacts [can] have different title styles than normal * companies. */ if ($resultSet[$rowIndex]['isHotContact'] == 1) { $resultSet[$rowIndex]['linkClassContact'] = 'jobLinkHot'; } else { $resultSet[$rowIndex]['linkClassContact'] = 'jobLinkCold'; } /* Strikethrough on no longer associated companies takes priority * over hot companies. */ if ($resultSet[$rowIndex]['leftCompany'] == 1) { $resultSet[$rowIndex]['linkClassCompany'] = 'jobLinkDead'; } else { if ($resultSet[$rowIndex]['isHotCompany'] == 1) { $resultSet[$rowIndex]['linkClassCompany'] = 'jobLinkHot'; } else { $resultSet[$rowIndex]['linkClassCompany'] = 'jobLinkCold'; } } /* Truncate Company Name column */ if (strlen($resultSet[$rowIndex]['companyName']) > self::TRUNCATE_CLIENT_NAME) { $resultSet[$rowIndex]['companyName'] = substr($resultSet[$rowIndex]['companyName'], 0, self::TRUNCATE_CLIENT_NAME) . "..."; } /* Truncate Title column */ if (strlen($resultSet[$rowIndex]['title']) > self::TRUNCATE_TITLE) { $resultSet[$rowIndex]['title'] = substr($resultSet[$rowIndex]['title'], 0, self::TRUNCATE_TITLE) . "..."; } } if (!eval(Hooks::get('CONTACTS_FORMAT_LIST_BY_VIEW'))) { return; } return $resultSet; }
/** *This constructor initializes the $url string variable *@param string $url The url request string *@return void */ public function __construct($url) { //assign this value to the $url internal variable $this->url = StringUtility::removeTags($url); }
$indexFile = $_REQUEST['indexFile']; $isPopup = $_REQUEST['isPopup'] == 1 ? true : false; $_SESSION['CATS']->setPipelineEntriesPerPage($entriesPerPage); $jobOrders = new JobOrders($siteID); $jobOrdersData = $jobOrders->get($jobOrderID); /* Get an array of the pipeline data. */ $pipelines = new Pipelines($siteID); $pipelinesRS = $pipelines->getJobOrderPipeline($jobOrderID); /* Format pipeline data. */ foreach ($pipelinesRS as $rowIndex => $row) { if ($row['submitted'] == '1') { $pipelinesRS[$rowIndex]['highlightStyle'] = 'jobLinkSubmitted'; } else { $pipelinesRS[$rowIndex]['highlightStyle'] = 'jobLinkCold'; } $pipelinesRS[$rowIndex]['addedByAbbrName'] = StringUtility::makeInitialName($pipelinesRS[$rowIndex]['addedByFirstName'], $pipelinesRS[$rowIndex]['addedByLastName'], LAST_NAME_MAXLEN); if ($row['attachmentPresent'] == 1) { $pipelinesRS[$rowIndex]['iconTag'] = '<img src="images/paperclip.gif" alt="" width="16" height="16" />'; } else { $pipelinesRS[$rowIndex]['iconTag'] = ' '; } $pipelinesRS[$rowIndex]['ratingLine'] = TemplateUtility::getRatingObject($pipelinesRS[$rowIndex]['ratingValue'], $pipelinesRS[$rowIndex]['candidateJobOrderID'], $_SESSION['CATS']->getCookie()); } /* Sort the data. */ if ($sortBy !== '' && $sortBy !== 'undefined') { $sorting = array(); foreach ($pipelinesRS as $p) { $sorting[] = $p[$sortBy]; } if ($sortBy == 'ratingValue') { array_multisort($sorting, $sortDirection == 'desc' ? SORT_DESC : SORT_ASC, SORT_NUMERIC, $pipelinesRS);
echo '<td valign="top" align="center">'; $link = 'http://www.catsone.com/professional'; $image = 'images/add_licenses.jpg'; echo '<a href="' . $link . '">'; echo '<img src="' . $image . '" border="0" alt="Click here to add more user licenses"/>'; echo '</a>'; echo '<div style="text-align: left; padding: 10px 25px 0px 25px;">'; echo 'A <i>user license</i>, or <i>seat</i>, is the limit of full-access users you can have. You may '; echo 'have unlimited read only users.'; echo '<p>'; echo 'This version of CATS is licensed to:<br /><center>'; echo '<b>' . LicenseUtility::getName() . '</b><br />'; $seats = LicenseUtility::getNumberOfSeats(); echo ucfirst(StringUtility::cardinal($seats)) . ' ('.$seats.') user license'.($seats!=1?'s':'').'<br />'; echo 'Valid until ' . date('m/d/Y', LicenseUtility::getExpirationDate()) . '<br />'; echo '</center>'; echo '<p>'; echo 'Click <a href="<?php echo $link; ?>">here</a> to purchase additional user seats.'; echo '</div></td>'; } ?> </tr> </table> <input type="submit" class="button" name="submit" id="submit" value="Add User" /> <input type="reset" class="button" name="reset" id="reset" value="Reset" onclick="document.getElementById('userAccessStatus').innerHTML='Delete - All lower access, plus the ability to delete information on the system.'" /> <input type="button" class="button" name="back" id="back" value="Cancel" onclick="javascript:goToURL('<?php echo(CATSUtility::getIndexName()); ?>?m=settings&a=manageUsers');" />
public static function cardinal($x) { if ($x <= 0) { return 'zero'; } $y = $x % 20; if ($x >= 10000000) { return number_format(strval($x), 0); } if (($y = floor($x / 1000000)) > 0 && $y <= 9) { $val = ''; $z = $x - $y * 1000000; if ($z > 0) { $val = ' ' . StringUtility::cardinal($z); } return StringUtility::cardinal($y) . ' million' . $val; } if (($y = floor($x / 1000)) > 0 && $y <= 999) { $val = ''; $z = $x - $y * 1000; if ($z > 0) { $val = ' ' . StringUtility::cardinal($z); } return StringUtility::cardinal($y) . ' thousand' . $val; } if (($y = floor($x / 100)) > 0 && $y <= 9) { $val = ''; $z = $x - $y * 100; if ($z > 0) { $val = ' and ' . StringUtility::cardinal($z); } return StringUtility::cardinal($y) . ' hundred' . $val; } switch ($y = floor($x / 10)) { case 2: $val = 'twenty'; if (($z = $x % ($y * 10)) > 0 && $z <= 9) { $val .= ' ' . StringUtility::cardinal($z); } return $val; case 3: $val = 'thirty'; if (($z = $x % ($y * 10)) > 0 && $z <= 9) { $val .= ' ' . StringUtility::cardinal($z); } return $val; case 4: $val = 'fourty'; if (($z = $x % ($y * 10)) > 0 && $z <= 9) { $val .= ' ' . StringUtility::cardinal($z); } return $val; case 5: $val = 'fifty'; if (($z = $x % ($y * 10)) > 0 && $z <= 9) { $val .= ' ' . StringUtility::cardinal($z); } return $val; case 6: $val = 'sixty'; if (($z = $x % ($y * 10)) > 0 && $z <= 9) { $val .= ' ' . StringUtility::cardinal($z); } return $val; case 7: $val = 'seventy'; if (($z = $x % ($y * 10)) > 0 && $z <= 9) { $val .= ' ' . StringUtility::cardinal($z); } return $val; case 8: $val = 'eighty'; if (($z = $x % ($y * 10)) > 0 && $z <= 9) { $val .= ' ' . StringUtility::cardinal($z); } return $val; case 9: $val = 'ninety'; if (($z = $x % ($y * 10)) > 0 && $z <= 9) { $val .= ' ' . StringUtility::cardinal($z); } return $val; } switch ($x) { case 1: return 'one'; case 2: return 'two'; case 3: return 'three'; case 4: return 'four'; case 5: return 'five'; case 6: return 'six'; case 7: return 'seven'; case 8: return 'eight'; case 9: return 'nine'; case 10: return 'ten'; case 11: return 'eleven'; case 12: return 'twelve'; case 13: return 'thirteen'; case 14: return 'fourteen'; case 15: return 'fifteen'; case 16: return 'sixteen'; case 17: return 'seventeen'; case 18: return 'eighteen'; case 19: return 'nineteen'; } }
/** * Formats SQL result set for display. This is factored out for code * clarity. * * @param array result set from listByView() * @return array formatted result set */ private function _formatListByViewResults($resultSet) { if (empty($resultSet)) { return $resultSet; } foreach ($resultSet as $rowIndex => $row) { /* Get info strings for popup titles */ $resultSet[$rowIndex]['jobOrderInfo'] = InfoString::make(DATA_ITEM_JOBORDER, $resultSet[$rowIndex]['jobOrderID'], $this->_siteID); $resultSet[$rowIndex]['companyInfo'] = InfoString::make(DATA_ITEM_COMPANY, $resultSet[$rowIndex]['companyID'], $this->_siteID); /* Truncate job order title. */ if (strlen($resultSet[$rowIndex]['title']) > self::TRUNCATE_JOBORDER_TITLE) { $resultSet[$rowIndex]['title'] = substr($resultSet[$rowIndex]['title'], 0, self::TRUNCATE_JOBORDER_TITLE) . "..."; } /* Truncate company name. */ if (strlen($resultSet[$rowIndex]['companyName']) > self::TRUNCATE_CLIENT_NAME) { $resultSet[$rowIndex]['companyName'] = substr($resultSet[$rowIndex]['companyName'], 0, self::TRUNCATE_CLIENT_NAME) . "..."; } /* Convert '00-00-00' dates to empty strings. */ $resultSet[$rowIndex]['startDate'] = DateUtility::fixZeroDate($resultSet[$rowIndex]['startDate']); /* Hot jobs [can] have different title styles than normal * jobs. */ if ($resultSet[$rowIndex]['isHot'] == 1) { $resultSet[$rowIndex]['linkClass'] = 'jobLinkHot'; } else { $resultSet[$rowIndex]['linkClass'] = 'jobLinkCold'; } $resultSet[$rowIndex]['recruiterAbbrName'] = StringUtility::makeInitialName($resultSet[$rowIndex]['recruiterFirstName'], $resultSet[$rowIndex]['recruiterLastName'], false, LAST_NAME_MAXLEN); $resultSet[$rowIndex]['ownerAbbrName'] = StringUtility::makeInitialName($resultSet[$rowIndex]['ownerFirstName'], $resultSet[$rowIndex]['ownerLastName'], false, LAST_NAME_MAXLEN); if ($resultSet[$rowIndex]['attachmentPresent'] == 1) { $resultSet[$rowIndex]['iconTag'] = '<img src="images/paperclip.gif" alt="" width="16" height="16" />'; } else { $resultSet[$rowIndex]['iconTag'] = ' '; } } if (!eval(Hooks::get('JO_FORMAT_LIST_BY_VIEW_RESULTS'))) { return; } return $resultSet; }
/** * Formats SQL result set for display. This is factored out for code * clarity. * * @param array result set from listByView() * @return array formatted result set */ private function _formatListByViewResults($resultSet) { if (empty($resultSet)) { return $resultSet; } foreach ($resultSet as $rowIndex => $row) { /* Hot companies [can] have different title styles than normal * companies. */ if ($resultSet[$rowIndex]['isHot'] == 1) { $resultSet[$rowIndex]['linkClass'] = 'jobLinkHot'; } else { $resultSet[$rowIndex]['linkClass'] = 'jobLinkCold'; } if (!empty($resultSet[$rowIndex]['ownerFirstName'])) { $resultSet[$rowIndex]['ownerAbbrName'] = StringUtility::makeInitialName($resultSet[$rowIndex]['ownerFirstName'], $resultSet[$rowIndex]['ownerLastName'], false, LAST_NAME_MAXLEN); } else { $resultSet[$rowIndex]['ownerAbbrName'] = 'None'; } if ($resultSet[$rowIndex]['attachmentPresent'] == 1) { $resultSet[$rowIndex]['iconTag'] = '<img src="images/paperclip.gif" alt="" width="16" height="16" />'; } else { $resultSet[$rowIndex]['iconTag'] = ' '; } /* Display nothing instead of zero's for Job Order Count on Companies * display page. */ if ($resultSet[$rowIndex]['jobOrdersCount'] == 0) { $resultSet[$rowIndex]['jobOrdersCount'] = ' '; } } return $resultSet; }
function createDao($tableName, $columnList, $primaryKey, $baseClassName = null) { $stringUtility = new StringUtility(); $tableClassName = $stringUtility->getClassName($tableName); $tableVariableName = $stringUtility->getVariableName($tableName); if (!empty($baseClassName)) { $extends = "extends " . $baseClassName; $requireBase = "require_once \"./BaseDao.class.php\";"; } $whereUnique = $primaryKey . " = {\$" . $primaryKey . "}"; $whereDtoUnique = "\"" . $primaryKey . " = \" . \$tableDto->" . $primaryKey; $primaryKeyParameter = "\$" . $primaryKey; $selectBase = "select " . join(", ", $columnList) . " from {$tableName}"; $select .= $selectBase . " where "; $select .= $whereUnique; $update = "update from {$table} set " . join(" =?, ", $columnList) . " =? "; $dao = null; $adodb_inc_path = ADODB_INC_PATH; $dao = <<<DAO_END class {$tableClassName}Dao {$extends}{ function getConnection(){ return parent::getConnection(); } function getNextId(){ \$connection = \$this->getConnection(); \$recordSet = \$connection->Execute("select max({$primaryKey}) as maxid from {$tableName}"); if(\$recordSet){ return (\$recordSet->fields{"maxid"} + 1); }else{ return 1; } \t} function findByKey({$primaryKeyParameter}){ \$connection = \$this->getConnection(); \$recordSet = \$connection->Execute("{$select}"); if(!\$recordSet){ return null; }else{ while(!\$recordSet->EOF){ \t\t\t\t\$tableDto = new TableDto(); @recordset_to_dao@ return \$tableDto; } return null; } } function find(){ \$connection = \$this->getConnection(); \$recordSet = \$connection->Execute("{$selectBase}"); if(!\$recordSet){ return null; }else{ \$resultArray = array(); while(!\$recordSet->EOF){ \t\t\t\t\$tableDto = new TableDto(); @recordset_to_dao@ \$recordSet->MoveNext(); \$resultArray[] = \$tableDto; } return \$resultArray; } } function findByRand(\$limit=1){ \$connection = \$this->getConnection(); \$recordSet = \$connection->Execute("{$selectBase} order by rand() limit {\$limit}"); if(!\$recordSet){ return null; }else{ \$resultArray = array(); while(!\$recordSet->EOF){ \t\t\t\t\$tableDto = new TableDto(); @recordset_to_dao@ \$recordSet->MoveNext(); \$resultArray[] = \$tableDto; } return \$resultArray; } } function insert(\$tableDto){ \$connection = \$this->getConnection(); \t\t\$record = array(); @insert_parameter@ \$insertSQL = \$connection->AutoExecute({$tableName}, \$record, "INSERT"); return \$insertSQL; } function update(\$tableDto){ \$connection = \$this->getConnection(); \t\t\$record = array(); @update_parameter@ \$insertSQL = \$connection->AutoExecute({$tableName}, \$record, "UPDATE", {$whereDtoUnique}); return \$insertSQL; } function delete({$primaryKeyParameter}){ \$connection = \$this->getConnection(); \$recordSet = \$connection->Execute("delete from {$tableName} where {$whereUnique}"); return \$connection->Affected_Rows(); } function trancate({$primaryKeyParameter}){ \$connection = \$this->getConnection(); \$recordSet = \$connection->Execute("trancate table {$tableName}"); return \$connection->Affected_Rows(); } function findCount(){ \$connection = \$this->getConnection(); \$recordSet = \$connection->Execute("select count(1) as cnt from {$tableName}"); if(!\$recordSet){ return 0; }else{ if(!\$recordSet->EOF){ return \$recordSet->fields{"cnt"}; }else{ \t\t\t\treturn 0; \t\t\t} } } } DAO_END; $updateParameter = ""; foreach ($columnList as $column) { $updateParameter .= " \$record[\"{$column}\"] = \$tableDto->{$column};\n"; } $insertParameter = ""; foreach ($columnList as $column) { if ($column == $primaryKey) { } else { $insertParameter .= " \$record[\"{$column}\"] = \$tableDto->{$column};\n"; } } $dao = str_replace("@insert_parameter@", $insertParameter, $dao); $dao = str_replace("@update_parameter@", $updateParameter, $dao); $set = null; foreach ($columnList as $column) { $set .= " \$tableDto->{$column} = \$recordSet->fields{\"{$column}\"};\n"; } $dao = str_replace("@recordset_to_dao@", $set, $dao); return $dao; }
function testEscapeSingleQuotes() { $this->assertIdentical(StringUtility::escapeSingleQuotes('Test'), 'Test'); $this->assertIdentical(StringUtility::escapeSingleQuotes("'Test'"), "\\'Test\\'"); $this->assertIdentical(StringUtility::escapeSingleQuotes("'Test ' String'"), "\\'Test \\' String\\'"); }
/** * @Inject logger * * @param callable * @param StringUtility */ public function sayHello($logger, StringUtility $stringUtility) { $name = $this->clientService->userService->getName(); $logger("hello " . $name . " from " . $stringUtility->upper($this->serverName)); }