本文整理汇总了PHP中app::getModule方法的典型用法代码示例。如果您正苦于以下问题:PHP app::getModule方法的具体用法?PHP app::getModule怎么用?PHP app::getModule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app
的用法示例。
在下文中一共展示了app::getModule方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCategories
protected function getCategories($admin = FALSE)
{
$display = $this->getConfig('display');
$exclude = $this->getConfig('exclude');
$obj = \app::getModule('blog')->getEntity('category');
$finalTree = array();
$list = array();
$subtree = '';
foreach ($obj as $key => $row) {
$thisref =& $finalTree[$row->id_category];
$thisref['parent_id'] = $row->id_parent;
$thisref['name'] = $row->name;
$thisref['url'] = $row->url;
if (!is_array($exclude) || is_array($exclude) && !in_array($row->id_category, $exclude) || $admin) {
if ($row->id_category == 0) {
$list[$row->id_category] =& $thisref;
} else {
$finalTree[$row->id_parent]['children'][$row->id_category] =& $thisref;
}
}
if ($display != 'no' && $row->id_category == $display && !$admin) {
$subtree = array($row->id_category => &$thisref);
}
}
if (!empty($subtree)) {
return $subtree;
} elseif (isset($finalTree[0]['children'])) {
return $finalTree[0]['children'];
}
return '';
}
示例2: catchError
/**
* Catch errors
* @param string $code
* @param string $file
* @param integer $line
* @param string $message
*/
public function catchError($code, $file, $line, $message)
{
$mess = $message . ' ' . t('in line') . ' ' . $line;
if ($code == 0 || $code == 2 || $code == 8 || $code == 256 || $code == 512 || $code == 1024 || $code == 2048 || $code == 4096 || $code == 8192 || $code == 16384) {
/* If it's a low level error, we save but we notice the dev */
\tools::file_put_contents(PROFILE_PATH . $this->getConfig('viewPath'), $_POST['editor']);
$return = array('eval' => '$("#' . $this->getId() . '",ParsimonyAdmin.currentBody).html("' . $mess . '");', 'notification' => t('Saved but') . ' : ' . $mess, 'notificationType' => 'normal');
} else {
$return = array('eval' => '$("#' . $this->getId() . '",ParsimonyAdmin.currentBody).html("' . $mess . '");', 'notification' => t('Error') . ' : ' . $mess, 'notificationType' => 'negative');
}
if (ob_get_level()) {
ob_clean();
}
echo json_encode($return);
unset($GLOBALS['lastError']);
/* to avoid to display error at the end of page load*/
\app::getModule('admin')->saveAll();
/* finish to save config */
}
示例3: process
public function process($vars)
{
\app::removeListener('afterInsert');
\app::removeListener('afterUpdate');
$idEntity = $this->entity->getId()->name;
$cutForeign = explode('_', $this->entity_foreign, 2);
$foreignEntity = \app::getModule($cutForeign[0])->getEntity($cutForeign[1]);
$idNameForeignEntity = $foreignEntity->getId()->name;
$cutAsso = explode('_', $this->entity_asso, 2);
$assoEntity = \app::getModule($cutAsso[0])->getEntity($cutAsso[1]);
$idAsso = $assoEntity->getId()->name;
/* Get old links */
$old = array();
foreach (\PDOconnection::getDB()->query('SELECT ' . PREFIX . $assoEntity->getTableName() . '.* FROM ' . PREFIX . $assoEntity->getTableName() . ' WHERE ' . $idEntity . ' = ' . $vars[':' . $idEntity], \PDO::FETCH_ASSOC) as $oldRows) {
$old[$oldRows[$idNameForeignEntity]] = $oldRows[$idAsso];
}
/* Add new links */
if (!empty($this->value) && is_array($this->value)) {
/* is_array in case all items are removed and $this->value == "empty" */
foreach ($this->value as $idForeign => $value) {
if (isset($old[$idForeign])) {
unset($old[$idForeign]);
} else {
if (substr($idForeign, 0, 3) === 'new') {
$idForeign = $foreignEntity->insertInto(array($idNameForeignEntity => '', $foreignEntity->getBehaviorTitle() => trim($value)), FALSE);
}
$assoEntity->insertInto(array($idAsso => '', $idEntity => $vars[':' . $idEntity], $idNameForeignEntity => $idForeign), FALSE);
}
}
}
/* Remove killed links */
if (!empty($old)) {
foreach ($old as $linkID) {
$assoEntity->delete($linkID, FALSE);
}
}
}
示例4:
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
echo $this->displayLabel($fieldName);
?>
<select name="<?php
echo $tableName;
?>
[<?php
echo $this->name;
?>
]" id="<?php
echo $fieldName;
?>
">
<?php
$users = \app::getModule('core')->getEntity('user')->select();
foreach ($users as $row) {
?>
<option value="<?php
echo $row->id_user;
?>
"<?php
if ($value == $row->id_user) {
echo ' selected="selected"';
}
?>
><?php
echo $row->pseudo;
?>
</option>
<?php
示例5: build
/**
* Generates the code to build a module
* @static function
* @param string $name module name
* @param string $title module title
*/
public static function build($name, $title)
{
$reservedKeywords = array('__halt_compiler', 'abstract', 'and', 'array', 'as', 'break', 'callable', 'case', 'catch', 'class', 'clone', 'const', 'continue', 'declare', 'default', 'die', 'do', 'echo', 'else', 'elseif', 'empty', 'enddeclare', 'endfor', 'endforeach', 'endif', 'endswitch', 'endwhile', 'eval', 'exit', 'extends', 'final', 'for', 'foreach', 'function', 'global', 'goto', 'if', 'implements', 'include', 'include_once', 'instanceof', 'insteadof', 'interface', 'isset', 'list', 'namespace', 'new', 'or', 'print', 'private', 'protected', 'public', 'require', 'require_once', 'return', 'static', 'switch', 'throw', 'trait', 'try', 'unset', 'use', 'var', 'while', 'xor');
if (!is_dir('modules/' . $name) && !is_numeric($name) && !in_array($name, $reservedKeywords)) {
$name = preg_replace('@[^a-zA-Z0-9]@', '', $name);
$licence = str_replace('{{module}}', $name, file_get_contents("modules/admin/licence.txt"));
tools::createDirectory('modules/' . $name);
$template = '<?php
' . $licence . '
namespace ' . $name . ';
/**
* @title ' . str_replace('\'', '\\\'', $title) . '
* @description ' . str_replace('\'', '\\\'', $title) . '
* @copyright 1
* @browsers all
* @php_version_min 5.3
*/
class module extends \\module {
protected $name = \'' . str_replace('\'', '\\\'', $name) . '\';
}
?>';
file_put_contents('modules/' . $name . '/module.php', $template);
include 'modules/' . $name . '/module.php';
$name2 = $name . '\\module';
$mod = new $name2($name);
$page = new \page(1, $name);
$page->setModule($name);
$page->setTitle('Index ' . $name);
$page->setRegex('@^index$@');
/* Set rights forbidden for non admins, admins are allowed by default */
foreach (\app::getModule('core')->getEntity('role') as $role) {
if ($role->permissions == 0) {
$mod->setRights($role->id_role, 0);
$page->setRights($role->id_role, 0);
}
}
$mod->addPage($page);
$mod->save();
$config = new \config('profiles/' . PROFILE . '/config.php', TRUE);
$config->add('$config[\'modules\'][\'' . $name . '\']', '7');
return $config->save();
} else {
return FALSE;
}
}
示例6: drawmenu
public function drawmenu($items)
{
$cpt = 1;
$count = count($items);
foreach ($items as $item) {
$classes = array();
$class = '';
if (isset($item['url'])) {
if (empty($item['url'])) {
$url = '#';
} elseif (substr($item['url'], 0, 4) === 'http') {
$url = $item['url'];
} else {
$url = BASE_PATH . $item['url'];
}
$title = $item['title'];
} else {
$page = \app::getModule($item['module'])->getPage($item['page']);
if ($page->getRights($_SESSION['id_role']) & DISPLAY) {
if ($item['module'] === \app::$config['defaultModule']) {
$url = BASE_PATH . substr($page->getRegex(), 2, -2);
} else {
$url = BASE_PATH . $item['module'] . '/' . substr($page->getRegex(), 2, -2);
}
if (count($page->getURLcomponents()) == 0) {
$title = $page->getTitle();
} else {
$dynamicURL = '';
foreach ($page->getURLcomponents() as $urlRegex) {
if (isset($urlRegex['modelProperty'])) {
$prop = explode('.', $urlRegex['modelProperty']);
$table = explode('_', $prop[0], 2);
$entity = \app::getModule($table[0])->getEntity($table[1]);
$entityTitle = $entity->getBehaviorTitle();
foreach ($entity as $row) {
$dynamicURL .= '<li><a href="' . str_replace('(?<' . $urlRegex['name'] . '>' . $urlRegex['regex'] . ')', $row->{$prop}[1], $url) . '">' . $row->{$entityTitle} . '</a></li>';
}
}
}
}
} else {
$dynamicURL = '';
}
}
if (BASE_PATH . \app::$request->getParam('parsiurl') == $url) {
$classes[] = 'current';
}
if ($count == $cpt) {
$classes[] = 'last';
}
if ($cpt == 1) {
$classes[] = 'first';
}
$hasChild = FALSE;
if (isset($item['children'])) {
$hasChild = TRUE;
$classes[] = 'parent';
}
if (count($classes) > 0) {
$class = 'class="' . implode(' ', $classes) . '"';
}
if (isset($dynamicURL)) {
echo $dynamicURL;
unset($dynamicURL);
} else {
?>
<li id="itemlist_<?php
echo $item['id'];
?>
" <?php
echo $class;
?>
>
<a href="<?php
echo $url;
?>
"><?php
echo $title;
?>
</a>
<?php
if ($hasChild === TRUE) {
echo '<ul>';
$this->drawmenu($item['children']);
echo '</ul>';
}
?>
</li>
<?php
}
$cpt++;
}
}
示例7: foreach
}
}
}
/* Add tables on canvas */
$tables = $this->getConfig('tables');
if (!empty($tables)) {
foreach ($tables as $tableName => $table) {
echo 'addTable( "' . $tableName . '", ' . $table['top'] . ', ' . $table['left'] . '); ';
}
}
?>
window.propParams = new Array();
<?php
/* Save params of the page for future proposals */
if ($_POST['typeProgress'] == 'page') {
$page = \app::getModule($_POST['MODULE'])->getPage($_POST['IDPage']);
foreach ($page->getURLcomponents() as $urlRegex) {
if (isset($urlRegex['modelProperty'])) {
?>
propParams["<?php
echo $urlRegex['modelProperty'];
?>
"] = ":<?php
echo $urlRegex['name'];
?>
";
<?php
}
}
}
/* Display saved properties */
示例8: unset
<select name="module" onchange="$(this).closest('.admintabs').find('.rightbox').hide();$('#rights-<?php
echo $row->id_role;
?>
-' + this.value).show()">
<?php
$modules = \app::$activeModules;
unset($modules['admin']);
foreach ($modules as $moduleName => $type) {
echo '<option value="' . $moduleName . '">' . $moduleName . '</option>';
}
?>
</select>
</legend>
<?php
foreach (\app::$activeModules as $moduleName => $type) {
$module = app::getModule($moduleName);
echo '<div id="rights-' . $row->id_role . '-' . $moduleName . '" class="rightbox' . ($moduleName !== 'core' ? ' none' : '') . '">';
?>
<div class="enablemodule<?php
echo $moduleName === 'core' ? ' none' : '';
?>
">
<input type="hidden" name="modulerights[<?php
echo $row->id_role;
?>
][<?php
echo $moduleName;
?>
]" value="0">
<input type="checkbox" class="onOff" name="modulerights[<?php
echo $row->id_role;
示例9: unset
*
* @category Parsimony
* @package admin
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
app::$response->addJSFile('admin/blocks/modules/block.js', 'footer');
$activeModule = \app::$activeModules;
/* Put active module at the top of the list, and remove admin && core modules */
unset($activeModule[MODULE]);
$activeModule = array_merge(array(MODULE => '5555'), $activeModule);
unset($activeModule['admin']);
unset($activeModule['core']);
$activeModule['core'] = 0;
/* add core(administration tab) module at the end */
foreach ($activeModule as $module => $type) {
$moduleobj = \app::getModule($module);
$moduleInfos = \tools::getClassInfos($moduleobj);
if (!isset($moduleInfos['displayAdmin'])) {
$moduleInfos['displayAdmin'] = 3;
}
$adminHTML = $moduleobj->displayAdmin();
if ($adminHTML === FALSE) {
$htmlConfig = '';
} else {
$htmlConfig = '<a href="#left_sidebar/settings/' . $module . '" class="configmodule" title="' . t('Administration Module') . ' ' . ucfirst(s($moduleInfos['title'])) . '"></a>';
}
if ($moduleInfos['displayAdmin'] > 0) {
?>
<div class="moduleTab <?php
echo $module === MODULE ? 'active' : '';
?>
示例10: t
?>
" <span class="entity2"></span> " ?</div>
</div>
<div id="popup2" class="popup" style="text-align: center;width:300px;">
<div class="title_popup"><?php
echo t('Link to another module');
?>
<span class="conf_box_close ui-icon ui-icon-closethick right"></span>
</div>
<div style="line-height: 30px;margin-top: 10px;color: #333;">Choose a table</div>
<div style="margin:10px 0 20px">
<select id="linkToExternal">
<?php
foreach (\app::$activeModules as $moduleName => $moduleConf) {
if ($moduleName != 'admin' && $moduleName != $module) {
foreach (\app::getModule($moduleName)->getModel() as $entityName => $entity) {
echo '<option>' . $moduleName . ' - ' . $entityName . '</option>';
}
}
}
?>
</select>
</div>
<input type="button" id="btnLinkToExternal" value="<?php
echo t('Do the Link');
?>
">
</div>
</div>
<div id="leftsidebar" class="areaWrite">
<h2 class="hdb"><?php
示例11: t
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
app::$response->addJSFile('admin/blocks/tree/block.js', 'footer');
?>
<div id="config_tree_selector" class="none">
<span class="spanDND sprite sprite-csspickerlittle cssblock floatleft" data-action="onDesign"></span>
<?php
if ($_SESSION['permissions'] & 128) {
?>
<span class="floatleft ui-icon ui-icon-wrench configure_block" rel="getViewConfigBlock" data-action="onConfigure" title="<?php
echo t('Configuration');
?>
"></span>
<?php
if ($_SESSION['permissions'] & 256) {
?>
<span draggable="true" class="floatleft move_block ui-icon ui-icon-arrow-4"></span>
<span class="ui-icon ui-icon-trash config_destroy floatleft" data-action="onDelete"></span>
<?php
}
}
?>
</div>
<div id="tree">
<?php
$IDPage = \app::$request->getParam('IDPage');
if ($IDPage && is_numeric($IDPage)) {
echo \app::getModule('admin')->structureTree(\theme::get(\app::$request->getParam('THEMEMODULE'), \app::$request->getParam('THEME')));
}
?>
</div>
示例12: foreach
*
* @category Parsimony
* @package core/fields
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
echo $this->displayLabel($fieldName);
$foreignID = $this->value;
$sth = PDOconnection::getDB()->query('SELECT * FROM ' . PREFIX . $this->moduleLink . '_' . $this->link);
// used ->getEntity() but there was interference because of cache
if (is_object($sth)) {
$sth->setFetchMode(PDO::FETCH_OBJ);
echo '<select name="' . $tableName . '[' . $this->name . ']">';
if (!$this->required) {
echo '<option></option>';
}
$properties = app::getModule($this->moduleLink)->getEntity($this->link)->getFields();
foreach ($sth as $key => $row) {
$text = $this->templatelink;
foreach ($properties as $key => $field) {
if (get_class($field) == \app::$aliasClasses['field_ident']) {
$id = $key;
}
if (isset($row->{$key})) {
$text = str_replace('%' . $key . '%', $row->{$key}, $text);
}
}
if ($row->{$id} == $foreignID) {
$selected = ' selected="selected"';
} else {
$selected = '';
}
示例13: foreach
$allowedModules = (array) $block->getConfig('allowedModules');
foreach (\app::$activeModules as $moduleName => $state) {
echo '<option' . (in_array($moduleName, $allowedModules) ? ' selected="selected"' : '') . '>' . $moduleName . '</option>';
}
?>
</select>
</div>
<div class="placeholder blockhead">
<label><?php
echo t('Permissions: only for the selected groups');
?>
</label>
<select name="allowedRoles[]" multiple="multiple">
<?php
$allowedRoles = (array) $block->getConfig('allowedRoles');
$obj = \app::getModule('core')->getEntity('role');
foreach ($obj as $row) {
echo '<option value="' . $row->id_role . '"' . (in_array($row->id_role, $allowedRoles) ? ' selected="selected"' : '') . '>' . $row->name . '</option>';
}
?>
</select>
</div>
</div>
<div class="clear padd">
<h3>Ajax load</h3>
<div class="placeholder blockhead">
<label><?php
echo t('Reload the block every X seconds');
?>
</label> <input type="text" name="ajaxReload" value="<?php
echo $block->getConfig('ajaxReload');
示例14: foreach
if (!strstr($page->getMeta('robots'), 'noindex')) {
if (count($page->getURLcomponents()) == 0) {
$urls[] = 'http://' . DOMAIN . '/' . $module . '/' . $page->getURL();
} else {
$nb = 0;
foreach ($page->getURLcomponents() as $urlRegex) {
if (isset($urlRegex['modelProperty'])) {
$nb++;
}
}
if ($nb == 1) {
foreach ($page->getURLcomponents() as $urlRegex) {
if (isset($urlRegex['modelProperty'])) {
$prop = explode('.', $urlRegex['modelProperty']);
$table = explode('_', $prop[0], 2);
$entity = \app::getModule($table[0])->getEntity($table[1]);
foreach ($entity as $row) {
$url = $page->getRegex();
$url = str_replace('(?<' . $urlRegex['name'] . '>' . $urlRegex['regex'] . ')', $row->{$prop}[1], substr($page->getRegex(), 2, -2));
$urls[] = 'http://' . DOMAIN . '/' . $module . '/' . $url;
}
}
}
}
}
}
}
}
echo '<?xml version="1.0" encoding="UTF-8" ?> ';
// in PHP to avoid confusion with short_opentag
?>
示例15: afterInsert
public function afterInsert($vars)
{
$configs = \app::getModule('blog')->getConfigs();
$reqhold = 'SELECT count(' . PREFIX . 'blog_comment.id_comment) from ' . PREFIX . 'blog_comment where ' . PREFIX . '.blog_comment.status = 0';
$hold = \PDOconnection::getDB()->query($reqhold)->fetch();
$holdcomments = $hold[0];
if ($holdcomments == '') {
$holdcomments = 0;
}
if (isset($vars[':author'])) {
$author = $vars[':author'];
}
if (isset($vars[':author_email'])) {
$author_email = $vars[':author_email'];
}
$id_comment = $vars[':id_comment'];
$id_post = $vars[':id_post'];
$author_ip = $vars[':author_ip'];
$author_url = $vars[':author_url'];
$content = $vars[':content'];
$remote = isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : $author_ip;
$postquery = "SELECT blog_post.title, blog_post.url from blog_post where id_post =" . $id_post;
$posttitle = '';
$posturl = '';
$params = \PDOconnection::getDB()->query($postquery);
foreach ($params as $param) {
$posttitle = $param['title'];
$posturl = $param['url'];
}
// Email me when anyone posts a comment mailForAnyPost or a comment is held for moderation
if ($configs['mailForAnyPost'] == '1' || $configs['heldModeration'] == '1' && $vars[':status'] == '0') {
// if block config provides mailing before moderation
$titre = utf8_decode('Comment Moderation for ' . $posttitle . ' (' . $vars[':date'] . ')');
$message = t('A new comment on', FALSE) . ' ' . $posttitle . ' ' . t('is held for moderation', FALSE);
$message .= '<br><A href="' . $posturl . '">' . $posturl . '</A><br>';
$message .= '<br>' . isset($vars[':author']) ? t('Author :') . $author : '' . t('(IP :') . $author_ip . ',' . $remote . ' )';
if (isset($vars[':author_email'])) {
$message .= '<br>' . t('E-mail :') . '<A href="mailto:' . $author_email . '">' . $author_email . '</A>';
}
$message .= '<br>' . t('Website :') . $author_url;
$message .= '<br>' . t('Whois :') . '<A href="' . 'http://whois.arin.net/rest/ip/' . $author_ip . '">' . 'http://whois.arin.net/rest/ip/' . $author_ip . '</a>';
$message .= '<br>' . t('Comment :') . $content . '<br>' . t('ID Comment') . $id_comment;
$message .= '<br>' . '<A href="' . BASE_PATH . 'index#modules/model/blog/comment">' . BASE_PATH . 'index#modules/model/blog/comment</a>';
$message .= '<br>' . t('Right now, ' . $holdcomments . ' comments await your approval', false) . '.';
$message = utf8_decode($message);
$adminmail = \app::$config['mail']['adminMail'];
ob_start();
include 'blog/views/mail/moderationmail.php';
$body = ob_get_clean();
if (\tools::sendMail($adminmail, '' . $adminmail . '', '' . $adminmail . '', $titre, $body)) {
return true;
} else {
return false;
}
}
// else config provides mailing after previous approved comment
if ($configs['previousComment'] == '1' && $vars[':status'] == '1') {
$titre = utf8_decode('Approved comment for ' . $posttitle . ' (' . $vars[':date'] . ')');
$message = t('New approved comment on', FALSE) . ' ' . $posttitle;
$message .= '<br><A href="' . $posturl . '">' . $posturl . '</A><br>';
$message .= '<br>' . isset($vars[':author']) ? t('Author :') . $author : '' . t('(IP :') . $author_ip . ',' . $remote . ' )';
if (isset($vars[':author_email'])) {
$message .= '<br>' . t('E-mail :') . '<A href="mailto:' . $author_email . '">' . $author_email . '</A>';
}
$message .= '<br>' . t('Website :') . $author_url;
$message .= '<br>' . t('Whois :') . '<A href="' . 'http://whois.arin.net/rest/ip/' . $author_ip . '">' . 'http://whois.arin.net/rest/ip/' . $author_ip . '</a>';
$message .= '<br>' . t('Comment :') . $content . '<br>' . t('ID Comment') . $id_comment;
$message .= '<br>' . '<A href="' . BASE_PATH . 'index#modules/model/blog/comment">' . BASE_PATH . 'index#modules/model/blog/comment</a>';
$message .= '<br>' . t('Right now, ' . $holdcomments . ' comments await your approval', false) . '.';
$message = utf8_decode($message);
$adminmail = \app::$config['mail']['adminMail'];
ob_start();
include 'blog/views/mail/moderationmail.php';
$body = ob_get_clean();
if (\tools::sendMail($adminmail, '' . $adminmail . '', '' . $adminmail . '', $titre, $body)) {
return true;
} else {
return false;
}
}
}