public function testSend() { $mailer = Site::getModule('MailModule')->getMailer(); $mailer->Subject = 'Unit Test'; $mailer->Body = 'Unit Test'; $mailer->AddAddress('*****@*****.**'); $this->assertTrue($mailer->Send(), 'sends mail'); }
protected function writeTemplateHeader() { parent::writeTemplateHeader(array('Framework Version' => Loader::$FrameworkVersion)); $this->write('<?php $site = Site::Site(); ?>'); $tsys = Site::getModule('TemplateSystem'); if ($tsys->hasModule('PageSystem')) { $this->write('<?php ' . "if (isset(\$this->page)) {\n" . " \$page = \$this->page;\n" . "} else {\n" . " \$page = \$site->modules->get('PageSystem')->getCurrentPage();\n" . "}\n" . ' ?>'); } $this->write("<?php \$params = " . __CLASS__ . "::getParamsProxy(); ?>"); }
/** * A utility method to truncate the given table(s) * * @param mixed $tables the table(s) to be truncated. accepts a string or array of strings * @return void */ protected function truncate($tables) { $database = Site::getModule('Database'); if (!is_array($tables)) { $tables = array($tables); } foreach ($tables as $table) { $database->query("TRUNCATE TABLE `{$table}`"); } }
/** * A convenience method that returns true if the specified * table(s) contents were last updated before $time. Note * that this is MySQL specific, so if your target db changes, * you'll want to modify this accordingly, if a similar * facility exists at all. * * @static * @access public * @param mixed $tables the name of a table, or an array of * table names * @param int $time the time argument in unix time * @return boolean true if the given table(s) have been * modified since $time */ public static function tablesModifiedSince($tables, $time) { $database = Site::getModule('Database'); if (!is_array($tables)) { $tables = array($tables); } // @WARNING: This is mysql-specific $sth = $database->query('SHOW TABLE STATUS'); while ($row = $sth->fetchObject('stdClass')) { if (in_array($row->name, $tables)) { $updateTime = strtotime($row->update_time); if ($updateTime < $time) { return true; } } } return false; }
public function getDatabase() { $database = Site::getModule('Database'); $database->select($this->_db); return $database; }
/** * A simple method to simply view a template, optionally setting aruments * * @param string|Template name the location of the template * @param array arguments [optional] the arguments to pass to the template, * expressed as name/value pairs * @return void */ public function writeTemplate($template, $arguments = null) { $tsys = Site::getModule('TemplateSystem'); if (is_string($template)) { $template = $tsys->load($name); } elseif (!is_object($template) || !is_a($template, $tsys->getPHPSTL()->getTemplateClass())) { throw new InvalidArgumentException('not a template'); } $this->write($template->render($arguments)); }
private function getMessList(DOMElement $element, $type) { $tsys = Site::getModule('TemplateSystem'); if (!$tsys->hasModule('PageSystem')) { throw new RuntimeException("cannot get {$type}, PageSystem not available"); } $get = 'get' . ucfirst($type); $clear = 'clear' . ucfirst($type); $contClass = $this->getUnquotedAttr($element, 'class', "{$type}-container"); $this->compiler->write("<?php\n" . "if (count(\$page->{$get}())) { \n" . " ?><ul class=\"{$contClass}\"><?php\n" . " foreach (\$page->{$get}() as \$w) {\n" . " ?><li><?php echo \$w ?></li><?php\n" . " } \n?></ul><?php\n" . " \$page->{$clear}();\n" . "}\n" . "?>"); }
public function setUp() { $this->db = Site::getModule('Database'); // hook database events $this->dbObserverHandle =& $this->db->observe(array($this, 'onDatabaseEvent')); }
public function __toString() { $dbo =& $this->dbo; $meta = $dbo->meta(); $table = $meta->getTable(); $key = $meta->getKey(); $sql = "{$this->type} "; $meat = ''; if ($this->type == 'SELECT') { if ($this->fields) { $sql .= "{$this->fields} "; } else { $sql .= "`{$table}`.`{$key}`," . $meta->getColumnsSQL() . ' '; } } elseif ($this->fields) { throw new InvalidArgumentException('field specification is incompatible with non-select queries'); } elseif ($this->pager) { throw new InvalidArgumentException('pager is not compatible with non-select queries'); } if ($this->pager && $this->limit) { throw new InvalidArgumentException('pager is mutually exclusive with limit'); } $meat = "FROM `{$table}` "; foreach ($this->joins as $join) { $meat .= "{$join} "; } for ($i = 0; $i < count($this->wheres); $i++) { $where = $this->wheres[$i]; if (!$i) { $where = "WHERE {$where}"; } else { $where = "AND {$where} "; } $meat .= "{$where} "; } for ($i = 0; $i < count($this->groupBys); $i++) { $group = $this->groupBys[$i]; if (!$i) { $group = "GROUP BY {$group}"; } else { $group = ",{$group}"; } $meat .= "{$group} "; } if ($this->pager && null === $this->pager->results) { $database = Site::getModule('Database'); $lsql = "SELECT COUNT(*) {$meat}"; $sth = $database->query($lsql); $this->pager->setResults($sth->fetchColumn()); } $sql .= $meat; for ($i = 0; $i < count($this->orders); $i++) { $order = $this->orders[$i]; if (!$i) { $order = "ORDER BY {$order}"; } else { $order = ",{$order}"; } $sql .= "{$order} "; } if ($this->pager) { $sql .= $this->pager->getLimit(); } elseif ($this->limit) { $sql .= "LIMIT {$this->limit}"; } return $sql; }