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 ''; }
/** * 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 */ }
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); } } }
* @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
/** * 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; } }
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++; } }
} } } /* 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 */
<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;
* * @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' : ''; ?>
?> " <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
* @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>
* * @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 = ''; }
$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');
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 ?>
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; } } }
/** * Reset a user's password and send the new one by email * @param $userMail mail */ public function resetPassword($userMail) { $newPass = substr(hash('sha1', uniqid(mt_rand())), 0, 8); \app::getModule('core')->getEntity('user')->where('mail = :mail')->update(array('pass' => $newPass, 'mail' => $userMail)); $password = $newPass; ob_start(); include 'admin/views/mail/remdp.php'; $body = ob_get_clean(); if (\tools::sendMail($userMail, \app::$config['mail']['adminMail'], \app::$config['mail']['adminMail'], 'Password reset', $body)) { return '1'; } else { return '0'; } }
echo t('Title'); ?> " /> <input type="text" id="input_url" placeholder="http://" /> <input type="button" value="<?php echo t('Add'); ?> " id="add-menu-item"> <h3><?php echo t('Choose An Existing Link'); ?> </h3> <ul id="addPageItem"> <?php foreach (\app::$activeModules as $module => $mode) { $moduleObj = \app::getModule($module); $pagesMod = $moduleObj->getPages(); if (!empty($pagesMod)) { ?> <li><?php echo $module; ?> <ul> <?php foreach ($moduleObj->getPages() as $key => $page) { $nb = 0; foreach ($page->getURLcomponents() as $tab) { if (isset($tab['regex'])) { $nb++; } }
public function saveEditInlineAction($id, $data = FALSE) { if ($data === FALSE) { /* if it's not an ajax request ( forms ) */ $data = \app::$request->getParam($this->name); } if ($data !== FALSE) { $data = $this->validate($data); if ($data !== FALSE) { $entityObj = \app::getModule($this->entity->getModule())->getEntity($this->entity->getName()); $res = \PDOconnection::getDB()->prepare('UPDATE ' . PREFIX . $this->entity->getModule() . '_' . $this->entity->getName() . ' SET ' . $this->name . ' = :data WHERE ' . $entityObj->getId()->name . '=:id'); $res->execute(array(':data' => $data, ':id' => $id)); if ($res !== FALSE) { $this->value = $data; return $this->display(); } } } return FALSE; }
public function __wakeup() { /* * Load fields objects and inject a reference to its entity parent * Create a public property for each field that links to the field value */ foreach ($this->fields as $key => &$field) { if (!is_array($field)) { $field = new \core\fields\alias($key, array('label' => $key, 'calculation' => $field)); } else { extract($field); $name = $module . '_' . $entity; if (!isset($this->entities[$name])) { $this->entities[$name] = app::getModule($module)->getEntity($entity); } $field = $this->entities[$name]->getField($fieldName); } $this->{$key} =& $field->getValue(); } }
$filterhtml = ''; $grouphtml = ''; $sorthtml = ''; $properties = $this->getConfig('properties'); $selected = $block->getConfig('selected'); $count = 0; foreach ($selected as $key => $value) { if (isset($value['alias'])) { $name = $value['alias']; $field = new \core\fields\alias($name, array('label' => $name, 'calculation' => ' ( ' . $value['calculated'] . ' ) ')); } else { $name = $value['table'] . '.' . $value['property']; $table = $value['table']; $property = $value['property']; list($module, $entity) = explode('_', $table, 2); $field = \app::getModule($module)->getEntity($entity)->getField($property); } ob_start(); /* FILTER */ if (isset($value['filter'])) { if (get_class($field) === 'core\\fields\\date' || get_class($field) === 'core\\fields\\publication') { $cssname = str_replace('.', '', $name); ?> <style> #<?php echo $cssname; ?> _checkvalues {display:none;} #<?php echo $cssname; ?>
?> <div class="placeholder"> <label><?php echo t('Select a table'); ?> </label> <select name="entity" id="entity"> <?php foreach (\app::$activeModules as $module => $type) { ?> <optgroup label="<?php echo $module; ?> "> <?php foreach (\app::getModule($module)->getModel() as $model => $entity) { if ($this->getConfig('entity') != '' && $module . ' - ' . $model == $this->getConfig('module') . ' - ' . $this->getConfig('entity')) { $selected = ' selected="selected"'; } else { $selected = ''; } ?> <option value="<?php echo $module . ' - ' . $model; ?> "<?php echo $selected; ?> ><?php echo $model; ?>
/** * Build the query and his PDO statement with SQL infos already set to this object * @return bool */ public function buildQuery($forceRebuild = FALSE) { if (!isset($this->_SQL['stmt']) || $forceRebuild) { /* exec query once a page load */ \app::dispatchEvent('beforeBuildQuery', array()); /* SELECT */ $query = 'SELECT '; if ($this instanceof \entity) { /* only for entity, to define defaults selects && from */ $this->beforeSelect(); if (empty($this->_SQL['selects'])) { $this->_SQL['selects'][$this->_tableName . '.*'] = $this->_tableName . '.*'; } $this->_SQL['froms'][$this->_tableName] = $this->_tableName; /* FROM for entity */ /* extends */ if (!empty($this->_extends)) { foreach ($this->_extends as $entity) { $foreignFields = $entity->getFields(); foreach ($foreignFields as $name => &$field) { if ($name !== $field->name) { /* detect alias */ $tableName = $field->getTableName(); $aliasName = $name . '_' . $tableName; $this->_SQL['selects'][$aliasName] = $tableName . '.' . $name . ' AS ' . $aliasName; } else { $this->_SQL['selects'][$name] = $field->getTableName() . '.' . $name; /* best than "table.*" which bug when using alias ( duplicate) */ } } $foreignTableName = str_replace('\\model\\', '_', get_class($entity)); $this->join($this->_tableName . '.' . $this->getId()->name, $foreignTableName . '.' . $entity->getId()->name, 'left outer join'); } } } foreach ($this->getFields() as $field) { /* TODO IMPROVE */ if (!$field instanceof \core\fields\alias) { $module = $field->entity->getModule(); $entity = $field->entity->getName(); $id = $field->entity->getId()->name; if ($field instanceof \field_formasso) { $cutForeign = explode('_', $field->entity_foreign, 2); $foreignEntity = \app::getModule($cutForeign[0])->getEntity($cutForeign[1]); $idNameForeignEntity = $foreignEntity->getId()->name; $this->_SQL['selects'][$field->name] = ' CONCAT( \'{\', GROUP_CONCAT(CONCAT(\'"\', ' . $field->entity_foreign . '.' . $idNameForeignEntity . ' , \'"\',\':"\',' . $field->entity_foreign . '.' . $foreignEntity->getBehaviorTitle() . ', \'"\')), \'}\') AS ' . $field->name; $this->groupBy($module . '_' . $entity . '.' . $id); $this->join($module . '_' . $entity . '.' . $id, $field->entity_asso . '.' . $field->entity->getId()->name, 'left outer join'); $this->join($field->entity_asso . '.' . $idNameForeignEntity, $field->entity_foreign . '.' . $idNameForeignEntity, 'left outer join'); } elseif ($this->getField($id) === FALSE) { $this->select($module . '_' . $entity . '.' . $id, TRUE); } } } $query .= implode(',', $this->_SQL['selects']); /* FROM */ if (empty($this->_SQL['joins'])) { $query .= ' FROM ' . reset($this->_SQL['froms']); } else { $firstTable = reset($this->_SQL['joins']); $tableLeft = strstr($firstTable['propertyLeft'], '.', true); $query .= ' FROM ' . $tableLeft; $this->_SQL['froms'][$tableLeft] = $tableLeft; //to prefix $tableLeft foreach ($this->_SQL['joins'] as $join) { $tableRight = strstr($join['propertyRight'], '.', true); $this->_SQL['froms'][$tableRight] = $tableRight; //to prefix $tableRight $query .= ' ' . $join['type'] . ' ' . $tableRight . ' ON ' . $join['propertyLeft'] . ' = ' . $join['propertyRight']; } } /* WHERE */ $this->_SQL['vars'] = array(); // init here for pagination if (isset($this->_SQL['wheres'])) { $wheres = array(); foreach ($this->_SQL['wheres'] as $where) { // Frame the "where" if several sql conditions /* For the record if(strstr($where,'&&') || strstr($where,'||') || stristr($where,' or ') || stristr($where,' and ')) $wheres[] = */ $wheres[] = '(' . $this->evaluateConditions($where) . ')'; } if (!empty($wheres)) { $query .= ' WHERE ' . implode(' AND ', $wheres); } } /* GROUP BY */ if (isset($this->_SQL['groupBys'])) { $query .= ' GROUP BY ' . implode(' ,', $this->_SQL['groupBys']); } /* HAVING */ if (isset($this->_SQL['havings'])) { $havings = array(); foreach ($this->_SQL['havings'] as $having) { // Frame the "having" if several sql conditions $havings[] = '(' . $this->evaluateConditions($having) . ')'; } if (!empty($havings)) { $query .= ' HAVING ' . implode(' AND ', $havings); } } /* ORDER */ if (isset($this->_SQL['orders'])) { $orders = array(); foreach ($this->_SQL['orders'] as $property => $order) { $orders[] = $property . ' ' . $order; } $query .= ' ORDER BY ' . implode(',', $orders); } /* DB PREFIX */ if (PREFIX !== '') { /* must be before pagination */ $query .= ' '; /* tip to replace table name */ foreach ($this->_SQL['froms'] as $table) { $query = preg_replace('/([,\\s\\(])' . $table . '([\\.\\s])/', '$1' . PREFIX . $table . '$2', $query); } } /* LIMIT */ if (isset($this->_SQL['limit'])) { $limit = ' LIMIT 0,' . $this->_SQL['limit']; if (isset($this->_SQL['pagination']) && $this->_SQL['pagination'] !== FALSE) { $this->_SQL['pagination'] = new \pagination($query, $this->_SQL['limit'], $this->_SQL['vars']); $start = $this->_SQL['pagination']->getCurrentPage() * $this->_SQL['limit'] - $this->_SQL['limit']; $limit = ' LIMIT ' . $start . ',' . $this->_SQL['limit']; } $query .= $limit; } $this->_SQL['query'] = $query; } /* EXEC query */ if (!empty($this->_SQL['vars'])) { $this->_SQL['stmt'] = \PDOconnection::getDB()->prepare($this->_SQL['query']); $this->_SQL['stmt']->setFetchMode(\PDO::FETCH_INTO, $this); $this->_SQL['stmt']->execute($this->_SQL['vars']); } else { $this->_SQL['stmt'] = \PDOconnection::getDB()->query($this->_SQL['query'], \PDO::FETCH_INTO, $this); } return $this->_SQL['stmt']; }
$result = $qpage->fetch(); $has_comment = $result['has_comment']; $rowdate = $result['publicationGMT']; $entity = \app::getModule('blog')->getEntity('comment'); $desc = ''; // Number of items $desc = ' order by ' . PREFIX . 'blog_comment.id_comment ' . $configs['commentOrder']; $qcomment = 'select ' . PREFIX . 'blog_comment.id_comment, ' . PREFIX . 'blog_comment.author, ' . PREFIX . 'blog_comment.author_ip, ' . PREFIX . 'blog_comment.date, ' . PREFIX . 'blog_comment.content, ' . PREFIX . 'blog_comment.status, ' . PREFIX . 'blog_comment.id_user, ' . PREFIX . 'blog_comment.id_parent, ' . PREFIX . 'blog_comment.author_email from ' . PREFIX . 'blog_comment where ' . PREFIX . 'blog_comment.id_post = ' . $idpage . ' AND ' . PREFIX . 'blog_comment.status = 1 ' . $desc; if (is_numeric($configs['items'])) { $qcomment .= ' limit 0, ' . $configs['items'] . ''; } // Query approved comments $comments = \PDOconnection::getDB()->query($qcomment); // if config provides that comments must be automatically closed on articles after X days $days = $configs['closeAfterDays']; if (\app::getModule('blog')->getEntity('comment')->olderComments($rowdate, $days) == TRUE) { if ($has_comment == '1') { $heldFormoderation = $configs['alwaysApprove']; if ($heldFormoderation == '1') { $notify = t('Your comment is held for moderation'); } else { $notify = t('Your comment is approved'); } if (isset($_POST['add'])) { $_POST['blog_comment']['id_post'] = $idpage; $res = $entity->insertInto($_POST); if ($res === TRUE || is_numeric($res)) { echo '<div class="notify positive">' . $notify . '</div>'; } else { echo '<div class="notify negative">' . t('Your comment cannot be send') . ': ' . $res . '</div>'; }
* Do not edit or add to this file if you wish to upgrade Parsimony to newer * versions in the future. If you wish to customize Parsimony for your * needs please refer to http://www.parsimony.mobi for more information. * * @authors Julien Gras et Benoît Lorillot * @copyright Julien Gras et Benoît Lorillot * * @category Parsimony * @package core/fields * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ \app::$response->addJSFile('lib/jquery-ui/jquery-ui-1.10.3.min.js'); \app::$response->addCSSFile('core/fields/formasso/css.css'); echo $this->displayLabel($fieldName); $cutForeign = explode('_', $this->entity_foreign, 2); $foreignEntity = \app::getModule($cutForeign[0])->getEntity($cutForeign[1]); $titleForeignEntity = $foreignEntity->getBehaviorTitle(); $words = array(); foreach ($foreignEntity as $foreignRow) { $obj = new stdClass(); $obj->label = $foreignRow->{$titleForeignEntity}; $obj->value = $foreignEntity->getId()->value; $words[] = $obj; } $values = json_decode($value, TRUE); if ($this->mode === 'tag') { ?> <script> function addATag<?php echo $fieldName;
public function getView() { $html = ''; $blockquery = $this->getConfig('blockquery'); $block = \app::$response->page->searchBlock($blockquery); if ($block !== null) { $filterhtml = ''; $grouphtml = ''; $sorthtml = ''; $properties = $this->getConfig('properties'); $selected = $block->getConfig('selected'); $countFil = -1; $endfil = ''; $filhtml = ''; foreach ($selected as $tabprop => $val) { // Define property & field if (isset($val['alias'])) { $property = $name = $val['alias']; $field = new \core\fields\alias($name, array('label' => $name, 'calculation' => ' ( ' . $val['calculated'] . ' ) ')); } else { $table = $val['table']; $property = $val['property']; list($module, $entity) = explode('_', $table, 2); $field = \app::getModule($module)->getEntity($entity)->getField($property); } /* Default SORT value */ if (isset($val['sort'])) { $sortconfigs = $properties[$tabprop]['sort']; if (!isset($_POST['submitfilter']) && !empty($sortconfigs)) { $_POST['sort'][$property] = $sortconfigs; } } /* Default GROUP value */ if (isset($val['group'])) { $groupconfigs = $properties[$tabprop]['group']; if (!isset($_POST['submitfilter']) && !empty($groupconfigs)) { $_POST['group'][$property] = $groupconfigs; } } /* FILTER */ ob_start(); if (isset($val['filter'])) { $template = isset($properties[$tabprop]['tpl']) ? $properties[$tabprop]['tpl'] : 'string'; $configs = $properties[$tabprop]; /* Default FILTER value */ $defaultconfigs = $properties[$tabprop]['default']; if (!isset($_POST['submitfilter'])) { /* Default FILTER TPL */ if ($configs['tpl'] == 'string' || $configs['tpl'] == 'select') { $_POST['filter'][$property] = isset($defaultconfigs['rangeStart']) ? $defaultconfigs['rangeStart'] : ''; } elseif ($configs['tpl'] == 'choice' && isset($defaultconfigs['rangeStart']) && $defaultconfigs['rangeStart'] !== '') { $_POST['filter'][$property][] = $defaultconfigs['rangeStart']; } elseif ($configs['tpl'] == 'range') { $_POST['filter'][$property]['start'] = isset($defaultconfigs['rangeStart']) ? $defaultconfigs['rangeStart'] : ''; $_POST['filter'][$property]['end'] = isset($defaultconfigs['rangeEnd']) ? $defaultconfigs['rangeEnd'] : ''; } elseif ($configs['tpl'] == 'datetimerange' || $configs['tpl'] == 'daterange') { $now = new \DateTime('now'); $nowEnd = new \DateTime('now'); $nowformat = $now->format('Y-m-d H:i'); $nowformat = str_replace(' ', 'T', $nowformat); if (!isset($defaultconfigs['state'])) { // static values for fields\date or fields\publication if (isset($defaultconfigs['start'])) { $_POST['filter'][$property]['start'] = $defaultconfigs['start']; } if (isset($defaultconfigs['end'])) { $_POST['filter'][$property]['end'] = $defaultconfigs['end']; } } else { // dynamic values if (!isset($defaultconfigs['now-start'])) { $selstart = $defaultconfigs['select-start']; $ys = $defaultconfigs['year-start']; $ms = $defaultconfigs['month-start']; $ds = $defaultconfigs['day-start']; if ($ys == '' && $ms == '' && $ds == '') { $_POST['filter'][$property]['start'] = ''; } else { $dateStart = ($ys != '' ? $selstart . ' ' . $ys . ' year ' : '') . ($ms != '' ? $selstart . ' ' . $ms . ' month ' : '') . ($ds != '' ? $selstart . ' ' . $ds . ' day ' : ''); // date modify with after or before values $dynstart = $now->modify($dateStart); $dynstart = $dynstart->format('Y-m-d H:i'); $dynstart = str_replace(' ', 'T', $dynstart); // Start -> set dynamic property $_POST['filter'][$property]['start'] = $dynstart; } } else { // now // Start -> set dynamic property to NOW $_POST['filter'][$property]['start'] = $nowformat; } if (!isset($defaultconfigs['now-end'])) { $selend = $defaultconfigs['select-end']; $ys = $defaultconfigs['year-end']; $ms = $defaultconfigs['month-end']; $ds = $defaultconfigs['day-end']; if ($ys == '' && $ms == '' && $ds == '') { $_POST['filter'][$property]['end'] = ''; } else { $dateEnd = ($ys != '' ? $selend . ' ' . $ys . ' year ' : '') . ($ms != '' ? $selend . ' ' . $ms . ' month ' : '') . ($ds != '' ? $selend . ' ' . $ds . ' day ' : ''); // date modify with after or before values $dynend = $nowEnd->modify($dateEnd); $dynend = $dynend->format('Y-m-d H:i'); $dynend = str_replace(' ', 'T', $dynend); $_POST['filter'][$property]['end'] = $dynend; } } else { // End -> set dynamic property to NOW $_POST['filter'][$property]['end'] = $nowformat; } } } } include 'modules/core/blocks/filter/views/' . $template . '.php'; } $filterhtml .= ob_get_clean(); /* GROUP */ ob_start(); if (isset($val['group'])) { if (get_class($field) === 'core\\fields\\date' || get_class($field) === 'core\\fields\\publication') { ?> <div><label><?php echo $field->label; ?> </label> <select name="group[<?php echo $property; ?> ]"> <option></option> <option value="day" <?php echo isset($_POST['group']) && isset($_POST['group'][$property]) && $_POST['group'][$property] === 'day' ? ' selected="selected"' : ''; ?> >day</option> <option value="month" <?php echo isset($_POST['group']) && isset($_POST['group'][$property]) && $_POST['group'][$property] === 'month' ? ' selected="selected"' : ''; ?> >month</option> <option value="year" <?php echo isset($_POST['group']) && isset($_POST['group'][$property]) && $_POST['group'][$property] === 'year' ? ' selected="selected"' : ''; ?> >year</option> </select> </div> <?php } else { ?> <div> <label><?php echo $field->label; ?> </label> <input type="checkbox" name="group[<?php echo $property; ?> ]" <?php echo isset($_POST['group']) && isset($_POST['group'][$property]) && $_POST['group'][$property] == 1 ? ' checked="checked"' : ''; ?> > </div> <?php } } $grouphtml .= ob_get_clean(); /* SORT */ ob_start(); if (isset($val['sort'])) { ?> <div><label><?php echo $field->label; ?> </label> <select name="sort[<?php echo $property; ?> ]"> <option></option> <option value="asc" <?php echo isset($_POST['sort']) && isset($_POST['sort'][$property]) && $_POST['sort'][$property] === 'asc' ? ' selected="selected"' : ''; ?> >ASC</option> <option value="desc" <?php echo isset($_POST['sort']) && isset($_POST['sort'][$property]) && $_POST['sort'][$property] === 'desc' ? ' selected="selected"' : ''; ?> >DESC</option> </select> </div> <?php } $sorthtml .= ob_get_clean(); } } $filtertitle = '<h2>' . t('Filter by') . '</h2>'; $grouptitle = '<h2>' . t('Group by') . '</h2>'; $sorttitle = '<h2>' . t('Sort by') . '</h2>'; $html = '<form method="post" action=""><input type="hidden" name="TOKEN" value="' . TOKEN . '"/>' . (!empty($filterhtml) ? '<div class="filter">' . $filtertitle . $filterhtml . '</div>' : '') . (!empty($grouphtml) ? '<div class="groupfilter">' . $grouptitle . $grouphtml . '</div>' : '') . (!empty($sorthtml) ? '<div class="sortfilter">' . $sorttitle . $sorthtml . '</div>' : '') . '<input type="submit" name="submitfilter"></form>'; return $html; }
* obtain it through the world-wide-web, please send an email * to contact@parsimony-cms.com so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade Parsimony to newer * versions in the future. If you wish to customize Parsimony for your * needs please refer to http://www.parsimony.mobi for more information. * * @authors Julien Gras et Benoît Lorillot * @copyright Julien Gras et Benoît Lorillot * * @category Parsimony * @package admin * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ ?> <div class="adminzone" id="admin_profile" style="padding-left: 0px;"> <div id="conf_box_title"><?php echo t('My profile'); ?> </div> <div class="adminzonemenu"></div> <div class="adminzonecontent"> <?php echo str_replace('action=""', 'target="formResult" action=""', \app::getModule('core')->getEntity('user')->getById($_SESSION['id_user'])->fetch()->getViewUpdateForm()); ?> </div> </div>
/** * Init objects theme module & page */ private function initObjects() { $this->theme = \theme::get(\app::$request->getParam('THEMEMODULE'), \app::$request->getParam('THEME')); $this->module = \app::getModule(\app::$request->getParam('MODULE')); $IDPage = \app::$request->getParam('IDPage'); if ($IDPage && is_numeric($IDPage)) { \app::$response->page = $this->page = $this->module->getPage($IDPage); } }
/** * Dispatch Request * @return response|string */ public function dispatch() { /* Admin UI ? */ if ($_SESSION['permissions'] > 0 && !isset($_GET['preview']) && $this->method === 'GET' && ($this->isAjax() !== TRUE || isset($_GET['getBlockAdmin']))) { define('PARSI_ADMIN', 1); $adminPage = new \page(1, 'admin'); $adminPage->setTheme(FALSE); /* Display admin */ return app::$response->setContent($adminPage->addBlock(new \admin\blocks\toolbar("admintoolbar")), 200); } $module = app::getModule($this->module); if ($module->getRights($_SESSION['id_role']) === 1) { /* 1 = allowed */ $result = $module->controller($this->secondPartURL, $this->method); if ($result !== FALSE) { /* Ok */ return app::$response->setContent($result, 200); } else { /* Not found */ return app::$response->setContent(app::getModule('core')->getView('404'), 404); } } else { /* Forbidden */ return app::$response->setContent(app::getModule('core')->getView('403'), 403); } }