本文整理汇总了PHP中Site::getModule方法的典型用法代码示例。如果您正苦于以下问题:PHP Site::getModule方法的具体用法?PHP Site::getModule怎么用?PHP Site::getModule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Site
的用法示例。
在下文中一共展示了Site::getModule方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSend
public function testSend()
{
$mailer = Site::getModule('MailModule')->getMailer();
$mailer->Subject = 'Unit Test';
$mailer->Body = 'Unit Test';
$mailer->AddAddress('webmaster@redtreesystems.com');
$this->assertTrue($mailer->Send(), 'sends mail');
}
示例2: writeTemplateHeader
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(); ?>");
}
示例3: truncate
/**
* 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}`");
}
}
示例4: tablesModifiedSince
/**
* 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;
}
示例5: getDatabase
public function getDatabase()
{
$database = Site::getModule('Database');
$database->select($this->_db);
return $database;
}
示例6: writeTemplate
/**
* 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));
}
示例7: getMessList
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" . "?>");
}
示例8: setUp
public function setUp()
{
$this->db = Site::getModule('Database');
// hook database events
$this->dbObserverHandle =& $this->db->observe(array($this, 'onDatabaseEvent'));
}
示例9: __toString
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;
}