예제 #1
0
 public static function handleEmailPreviewRequest(AbstractAlert $Alert)
 {
     $GLOBALS['Session']->requireAccountLevel('Staff');
     $email = \Emergence\Mailer\AbstractMailer::renderTemplate('alerts/notifications/' . $Alert::$notificationTemplate, ['Alert' => $Alert]);
     \Debug::dumpVar($Alert->getData(), false, 'Alert');
     print '<h2>Email</h2>';
     print '<pre>';
     print 'From: ' . htmlspecialchars($email['from'] ?: \Emergence\Mailer\AbstractMailer::getDefaultFrom()) . PHP_EOL;
     print 'Subject: ' . htmlspecialchars($email['subject']) . PHP_EOL . PHP_EOL;
     print htmlspecialchars($email['body']);
     print '</pre>';
     print '<h2>Preview</h2>';
     print '<div style="border: 1px dashed #ccc; width: 600px; font-family: arial,sans-serif; font-size: 80%; padding: 15px">' . $email['body'] . '</div>';
 }
 public static function searchRequest()
 {
     $GLOBALS['Session']->requireAccountLevel('Developer');
     set_time_limit(180);
     if (empty($_REQUEST['q'])) {
         return static::throwInvalidRequestError('q required');
     }
     $fileResults = DB::query('SELECT f.ID FROM (SELECT MAX(ID) AS ID FROM _e_files GROUP BY Handle, CollectionID) matches JOIN _e_files f USING(ID) WHERE f.Status = "Normal"');
     // open grep process
     $cmd = sprintf('xargs grep -nIP "%s" ', addslashes($_REQUEST['q']));
     $cwd = Site::$rootPath . '/data/';
     $grepProc = proc_open($cmd, array(0 => array('pipe', 'r'), 1 => array('pipe', 'w')), $pipes, $cwd);
     // pipe file list into xargs
     $filesCount = 0;
     while ($file = $fileResults->fetch_assoc()) {
         fwrite($pipes[0], $file['ID'] . PHP_EOL);
     }
     fclose($pipes[0]);
     // pipe results out
     $output = array();
     while (!feof($pipes[1])) {
         $line = trim($origLine = stream_get_line($pipes[1], 100000000, PHP_EOL));
         #            print "$origLine<hr>";
         $line = explode(':', $line, 3);
         if (count($line) === 3) {
             $file = SiteFile::getByID($line[0]);
             if (strlen($line[2]) > 255) {
                 $result = preg_match("/{$_REQUEST['q']}/", $line[2], $matches, PREG_OFFSET_CAPTURE);
                 $line[2] = substr(substr($line[2], max(0, $matches[0][1] - 50)), 0, 255);
             }
             if (!$file) {
                 Debug::dumpVar($line, true, 'no file');
             }
             $output[] = array('File' => $file ? $file->getData() : null, 'line' => $line[1], 'result' => trim($line[2]));
         }
     }
     fclose($pipes[1]);
     proc_close($grepProc);
     JSON::respond(array('success' => true, 'data' => $output));
 }
예제 #3
0
 /**
  * Default output function
  */
 public function __tostring()
 {
     return '<pre>' . Debug::dumpVar($this, __CLASS__, PHP_DEBUG_DUMP_ARR_STR) . '<pre>';
 }
예제 #4
0
<?php

$GLOBALS['Session']->requireAccountLevel('Developer');
if (Slate\CBL\ContentArea::getCount() > 0) {
    die("Content area database is already populated, aborting");
}
$mapsCsvUrl = 'https://docs.google.com/a/slate.is/spreadsheets/d/1LnjTF5i2CeQrR9EQLB0llomtkpJ_xx38oyjat8wr2_g/export?format=csv&id=1LnjTF5i2CeQrR9EQLB0llomtkpJ_xx38oyjat8wr2_g&gid=1995361518';
$mapsCsv = SpreadsheetReader::createFromStream(fopen($mapsCsvUrl, 'r'));
while ($mapsRow = $mapsCsv->getNextRow()) {
    Debug::dumpVar($mapsRow, false, '$mapRow');
    $mapCsv = SpreadsheetReader::createFromStream(fopen($mapsRow['CSV'], 'r'));
    $ContentArea = Slate\CBL\ContentArea::create(['Code' => $mapsRow['Code'], 'Title' => $mapsRow['Title']], true);
    \Debug::dumpVar($ContentArea, false, 'creating content area');
    while ($row = $mapCsv->getNextRow()) {
        if ($row['Type'] == 'Competency Statement') {
            $lastCompetency = Slate\CBL\Competency::create(['ContentArea' => $ContentArea, 'Code' => $row['Code'], 'Descriptor' => $row['Descriptor'], 'Statement' => $row['Statement']], true);
            \Debug::dumpVar($lastCompetency, false, 'creating competency');
        } elseif ($row['Type'] == 'Standard') {
            \Debug::dumpVar(Slate\CBL\Skill::create(['Competency' => $lastCompetency, 'Code' => $row['Code'], 'Descriptor' => $row['Descriptor'], 'Statement' => $row['Statement'], 'DemonstrationsRequired' => $row['ER']], true), false, 'creating skill');
        }
    }
}
예제 #5
0
 /**
  * HTML_Table_Config
  * 
  * @since V2.0.0 - 26 Apr 2006
  */
 function __tostring()
 {
     return '<pre>' . Debug::dumpVar($this->singleton()->getConfig(), __CLASS__, PHP_DEBUG_DUMP_ARR_STR) . '</pre>';
 }
예제 #6
0
 /**
  * Show a super array
  * 
  * @param string $SuperArrayType Type of super en array to add
  * @since V2.0.0 - 07 Apr 2006
  */
 private function showSuperArray($SuperArrayType)
 {
     // Lang
     $txtVariable = "Var";
     $txtNoVariable = "NO VARIABLE";
     $NoVariable = " -- {$txtNoVariable} -- ";
     $SuperArray = null;
     $buffer = '';
     $ArrayTitle = Debug::$globalEnvConstantsCorresp[$SuperArrayType];
     $SuperArray = $GLOBALS["{$ArrayTitle}"];
     $Title = "{$ArrayTitle} {$txtVariable}";
     $SectionBasetitle = "<b>{$Title} (" . count($SuperArray) . ') :';
     if (count($SuperArray)) {
         $buffer .= $SectionBasetitle . '</b>';
         $buffer .= '<pre>' . Debug::dumpVar($SuperArray, $ArrayTitle, PHP_DEBUG_DUMP_STR) . '</pre>';
     } else {
         $buffer .= $SectionBasetitle . "{$NoVariable}</b>";
     }
     return $buffer;
 }