function process_ajax() { $mode = $this->getAttribute('mode'); $q = __Request::get('q'); $result = array(); if ($mode == 'users') { $it = org_glizy_ObjectFactory::createModelIterator('org.glizycms.userManager.models.UserGroup', 'all'); $it->setOrFilters(array("user_firstName" => $q, "user_lastName" => $q, "user_loginId" => $q)); foreach ($it as $ar) { $result[] = array('id' => $ar->user_id, 'text' => $ar->user_loginId); } } else { if ($mode == 'groups') { $it = org_glizy_ObjectFactory::createModelIterator('org.glizycms.userManager.models.UserGroup', 'all', array('filters' => array('usergroup_name' => $q))); foreach ($it as $ar) { $result[] = array('id' => $ar->usergroup_id, 'text' => $ar->usergroup_name); } } else { $it = org_glizy_ObjectFactory::createModelIterator('org.glizycms.roleManager.models.Role', 'all', array('filters' => array('role_name' => $q))); foreach ($it as $ar) { $result[] = array('id' => $ar->role_id, 'text' => $ar->role_name); } } } return $result; }
public function searchDocumentsByTerm($term, $id, $protocol = '', $filterType = '') { $result = array(); if ($protocol && $protocol != $this->protocol) { return $result; } $languageId = $this->editLanguageId; $it = org_glizy_ObjectFactory::createModelIterator('org.glizycms.core.models.Menu'); if ($term) { $it->load('autocompletePagePicker', array('search' => '%' . $term . '%', 'languageId' => $languageId, 'menuId' => '', 'pageType' => $filterType)); } else { if ($id) { if (!is_numeric($id) && strpos($id, $this->protocol) !== 0) { return $result; } elseif (is_string($id)) { $id = $this->getIdFromLink($id); } $it->load('autocompletePagePicker', array('search' => '', 'languageId' => $languageId, 'menuId' => $id)); } else { return $result; } } foreach ($it as $ar) { $result[] = array('id' => $this->protocol . $ar->menu_id, 'text' => $ar->menudetail_title, 'path' => ltrim($ar->p1 . '/' . $ar->p2 . '/' . $ar->p3, '/') . '/' . $ar->menudetail_title); } return $result; }
function render_html() { if (!__Config::get('MULTILANGUAGE_ENABLED')) { return false; } $iterator = org_glizy_ObjectFactory::createModelIterator('org.glizycms.core.models.Language', 'all', array('order' => 'language_order')); if ($iterator->count() > 1) { $output = '<ul class="' . $this->getAttribute('cssClass') . '" id="' . $this->getId() . '">'; if ($this->getAttribute('separator') == 'start') { $output .= '<li class="separator">|</li>'; } foreach ($iterator as $ar) { $url = __Link::addParams(array('language' => $ar->language_code)); if ($ar->language_id == $this->_application->getLanguageId()) { $output .= '<li class="' . $ar->language_code . '">' . org_glizy_helpers_Link::makeSimpleLink(glz_encodeOutput($ar->language_name), $url, '', 'active') . '</li>'; } else { $output .= '<li class="' . $ar->language_code . '">' . org_glizy_helpers_Link::makeSimpleLink(glz_encodeOutput($ar->language_name), $url) . '</li>'; } } if ($this->getAttribute('separator') == 'end') { $output .= '<li>|</li>'; } $output .= '</ul>'; $this->addOutputCode($output); } }
function addModule($moduleId, $permission = array('visible' => 'true')) { $it = org_glizy_ObjectFactory::createModelIterator('org.glizycms.roleManager.models.Role'); foreach ($it as $ar) { $permissions = unserialize($ar->role_permissions); $permissions[$moduleId] = $permission; $ar->role_permissions = serialize($permissions); $ar->save(); } }
public function findTerm($fieldName, $model, $query, $term, $proxyParams = null) { $model = org_glizy_Modules::getModule($proxyParams->moduleId); $it = org_glizy_ObjectFactory::createModelIterator($model->classPath . '.models.Model')->where('title', '%' . $term . '%', 'ILIKE')->orderBy('title'); $result = array(); foreach ($it as $ar) { $result[] = array('id' => $ar->getId(), 'text' => $ar->title); } return $result; }
static function query($path) { $params =& org_glizy_Registry::_getValuesArray(); $iterator = org_glizy_ObjectFactory::createModelIterator('org.glizy.models.Registry', 'all', array('filters' => array('registry_path' => $path))); // TODO controlare se ci sono stati errori $result = array(); foreach ($iterator as $ar) { $params[$ar->registry_path] = $ar->registry_value; $result[$ar->registry_path] = $ar->registry_value; } return $result; }
private function compileRouting() { $routing = ''; $it = org_glizy_ObjectFactory::createModelIterator('org.glizycms.speakingUrl.models.SpeakingUrl')->load('all'); foreach ($it as $ar) { if (isset(self::$modules[$ar->speakingurl_type])) { $routing .= self::$modules[$ar->speakingurl_type]->compileRouting($ar); } } $routing = '<?xml version="1.0" encoding="utf-8"?><glz:Routing>' . $routing . '</glz:Routing>'; $evt = array('type' => GLZ_EVT_LISTENER_COMPILE_ROUTING, 'data' => $routing); $this->dispatchEvent($evt); }
function &loadQuery($queryName = '', $options = array()) { if (is_null($this->_recordIterator)) { $this->_recordIterator =& org_glizy_ObjectFactory::createModelIterator($this->getAttribute('recordClassName')); if ($this->getAttribute('showAll') && method_exists($it, 'showAll')) { $this->_recordIterator->showAll(); } } if (empty($queryName)) { $queryName = $this->getAttribute('query'); } $order = $this->getAttribute('order'); if (!empty($order)) { $options['order'] = array($order => $this->getAttribute('orderModifier')); } if ($this->getAttribute('useQueryParams') && isset($options['filters'])) { $options['params'] = array(); if (count($options['filters'])) { foreach ($options['filters'] as $k => $v) { $options['params'][$k] = is_array($v) ? $v[1] : $v; } } unset($options['filters']); } if ($this->getAttribute('limit')) { $options['limit'] = explode(',', $this->getAttribute('limit')); } if ($this->getAttribute('filters')) { $options['filters'] = $this->getAttribute('filters'); } // TODO // if ($this->getAttribute('categories')) $options['categories'] = $this->getAttribute('categories'); // TODO // if ($this->getAttribute('params')) $options['params'] = $this->getAttribute('params'); $it = $this->_recordIterator->load($queryName); if (!empty($options['filters'])) { if ($this->getAttribute('queryOperator') === 'OR') { $it->setOrFilters($options['filters']); } else { $it->setFilters($options['filters']); } } if (isset($options['order'])) { $it->setOrderBy($options['order']); } if (isset($options['limit'])) { $it->limit($options['limit']); } // glz_dbdebug(true); return $it; }
public function getWithName($fileName, $queryName, $options = array()) { $data = $this->_cacheObj->get($fileName, $this->group); if ($data === false) { $data = array(); $it = org_glizy_ObjectFactory::createModelIterator($this->model, $queryName, $options); foreach ($it as $ar) { $data[] = $ar->getValuesAsArray(); } $this->_cacheObj->save($this->serialize($data), $fileName, $this->group); } else { $data = $this->unserialize($data); } return new org_glizy_dataAccess_cache_Iterator($data); }
/** * Process * * @return boolean false if the process is aborted * @access public */ function process() { $classPath = $this->getAttribute('recordClassName'); if (is_null($classPath)) { // TODO // visualizzare FATAL ERROR $this->RaiseError("DataProvider: record class don't found", __FUNCTION__, __FILE__, __LINE__, 'verbosedie'); } else { $this->iterator =& org_glizy_ObjectFactory::createModelIterator($classPath); if ($this->iterator === false) { // TODO // visualizzare FATAL ERROR $this->RaiseError("DataProvider: record class don't found", __FUNCTION__, __FILE__, __LINE__, 'verbosedie'); } } }
public function execute() { if (method_exists($this->view, 'setData')) { $siteProp = unserialize(org_glizy_Registry::get(__Config::get('REGISTRY_SITE_PROP') . $this->application->getLanguage(), '')); $lastUpdate = org_glizy_Registry::get('movio/modules/publishApp/lastUpdate'); $data = new StdClass(); $data->title = $siteProp['title']; $data->subtitle = $siteProp['subtitle']; if ($lastUpdate) { $data->lastUpdate = '<p>' . __T('Last exportation date') . ': ' . date(__T('GLZ_DATETIME_FORMAT') . '</p>', $lastUpdate); } $data->isExhibitionActive = 1; $it = org_glizy_ObjectFactory::createModelIterator('org.glizycms.core.models.Language')->load('getLanguageDictionary'); $this->setComponentsAttribute('languages', 'rows', $it->count()); $this->view->setData($data); } }
public function login($loginId, $psw, $remember = false) { $this->validateLogin($loginId, $psw); $this->resetSession(); $it = org_glizy_ObjectFactory::createModelIterator('org.glizy.models.User')->load('login', array('loginId' => $loginId, 'password' => $psw)); if ($it->count()) { // login success $this->arUser = $it->current(); if ($this->arUser->user_isActive == 0) { throw org_glizy_authentication_AuthenticationException::userNotActive(); } if (__Config::get('ACL_ROLES') && $this->onlyBackendUser) { $user = array('id' => $this->arUser->user_id, 'firstName' => $this->arUser->user_firstName, 'lastName' => $this->arUser->user_lastName, 'loginId' => $this->arUser->user_loginId, 'email' => $this->arUser->user_email, 'groupId' => $this->arUser->user_FK_usergroup_id, 'backEndAccess' => false); $user =& org_glizy_ObjectFactory::createObject('org.glizy.application.User', $user); if (!$user->acl('Home', 'all')) { org_glizy_Session::destroy(); throw org_glizy_authentication_AuthenticationException::AccessNotAllowed(); } $backEndAccess = true; } else { if ($this->onlyBackendUser && $this->arUser->usergroup_backEndAccess == 0) { throw org_glizy_authentication_AuthenticationException::AccessNotAllowed(); } if (count($this->allowGroups) ? !in_array($this->arUser->user_FK_usergroup_id, $this->allowGroups) : false) { throw org_glizy_authentication_AuthenticationException::AccessNotAllowed(); } $backEndAccess = $this->arUser->usergroup_backEndAccess; } $language = $this->language; if (!$language) { $language = __Config::get('DEFAULT_LANGUAGE'); } $user = array('id' => $this->arUser->user_id, 'firstName' => $this->arUser->user_firstName, 'lastName' => $this->arUser->user_lastName, 'loginId' => $this->arUser->user_loginId, 'email' => $this->arUser->user_email, 'groupId' => $this->arUser->user_FK_usergroup_id, 'backEndAccess' => $backEndAccess, 'language' => $language); $this->setSession($user); if ($remember) { $this->setCookie($loginId, $psw); } $evt = array('type' => GLZ_EVT_USERLOGIN, 'data' => $user); $this->dispatchEvent($evt); return $user; } else { // wrong username or password throw org_glizy_authentication_AuthenticationException::wrongLoginIdOrPassword(); } }
function _initSiteMap($forceReload = false) { $this->log("initSiteMap", GLZ_LOG_SYSTEM); $this->siteMap =& org_glizy_ObjectFactory::createObject('org.glizycms.core.application.SiteMapDB'); $this->siteMap->getSiteArray($forceReload); // controlla se l'utente ha i permessi per modificare la pagina // per velocizzare vengono precaricate tutte le relazioni in memoria $this->_aclPage = array(); if (__Config::get('ACL_ENABLED')) { $this->_aclPage = __Session::get('glizy.aclFront', NULL); if (is_null($this->_aclPage)) { $this->_aclPage = array(); $it = org_glizy_ObjectFactory::createModelIterator('org.glizy.models.Join', 'all', array('filters' => array('join_objectName' => 'menus_tbl#rel_aclFront'))); foreach ($it as $arC) { if (!isset($this->_aclPage[$arC->join_FK_source_id])) { $this->_aclPage[$arC->join_FK_source_id] = array(); } $this->_aclPage[$arC->join_FK_source_id][] = $arC->join_FK_dest_id; } // scorre tutti i menù per attribuire l'acl ai menù che non ce l'hanno // ereditandola dal padre $siteMapIterator =& org_glizy_ObjectFactory::createObject('org.glizy.application.SiteMapIterator', $this->siteMap); while (!$siteMapIterator->EOF) { $n = $siteMapIterator->getNode(); $siteMapIterator->moveNext(); if (!isset($this->_aclPage[$n->id])) { $n2 = $n; while (true) { if ($n2->parentId == 0) { break; } $parentNode = $n2->parentNode(); $n2 = $parentNode; if (isset($this->_aclPage[$parentNode->id])) { $this->_aclPage[$n->id] = $this->_aclPage[$parentNode->id]; break; } } } } __Session::set('glizy.aclFront', $this->_aclPage); } } }
/** * @param $key * @param $queryName * @param array $options * * @return org_glizy_dataAccess_cache_Iterator */ public function getWithName($key, $queryName, $options = array()) { $data = $this->redis->get($key); if ($data == null) { $data = array(); /** @var org_glizy_dataAccess_cache_Iterator $it */ $it = org_glizy_ObjectFactory::createModelIterator($this->model, $queryName, $options); /** @var org_glizy_dataAccess_cache_ActiveRecord $ar */ foreach ($it as $ar) { $data[] = $ar->getValuesAsArray(); } $this->redis->set($key, $this->serialize($data)); } else { $data = $this->unserialize($data); } if ($this->lifeTime != -1) { $this->redis->expire($key, $this->lifeTime); } return new org_glizy_dataAccess_cache_Iterator($data); }
function process() { $this->_content = array(); $this->_content['label'] = $this->getAttribute('label'); $this->_content['cssClass'] = $this->getAttribute('cssClass'); $this->_content['current'] = ''; $this->_content['records'] = array(); $iterator = org_glizy_ObjectFactory::createModelIterator('org.glizycms.core.models.Language'); $iterator->orderBy('language_order'); if ($iterator->count()) { $editLanguageId = $this->_application->getEditingLanguageId(); foreach ($iterator as $ar) { if ($ar->language_id == $editLanguageId) { $this->_content['current'] = $ar->language_name; continue; } $url = org_glizy_helpers_Link::addParams(array('switchLanguage' => $ar->language_id)); $this->_content['records'][] = org_glizy_helpers_Link::makeSimpleLink(glz_encodeOutput($ar->language_name), $url, $ar->language_name); } } }
function process() { $this->repeaterId = $this->getId(); $this->it = org_glizy_ObjectFactory::createModelIterator('org.glizycms.models.Media'); $this->numRecords = 0; $filter = $this->_parent->loadContent($this->repeaterId); if (is_array($filter) && count($filter)) { $filters = array('media_type' => 'IMAGE', 'media_category' => array()); foreach ($filter as $v) { $filters['media_category'][] = array('field' => 'media_category', 'value' => '%"' . $v . '"%', 'condition' => 'LIKE'); } if ($this->getAttribute('queryOr')) { $this->it->setOrFilters($filters); } else { $this->it->setFilters($filters); } $this->it->orderBy('media_title'); $this->numRecords = $this->it->count(); } $this->_content = new StdClass(); }
public function execute($menuId) { if ($menuId) { $menu = org_glizy_ObjectFactory::createModel('org.glizycms.contents.models.Menu'); $menu->load($menuId); //inserire menu_extendsPermissions nella tabella menus_tbl $data = new StdClass(); $data->extendsPermissions = $menu->menu_extendsPermissions; $tableName = $menu->getTableName(); $aclBack = array(); $it = org_glizy_ObjectFactory::createModelIterator('org.glizycms.contents.models.Role')->load('getAclBack', array('menuId' => $menuId, 'tableName' => $tableName)); foreach ($it as $ar) { $aclBack[] = array('id' => $ar->role_id, 'text' => $ar->role_name); } $aclFront = array(); $it = org_glizy_ObjectFactory::createModelIterator('org.glizycms.contents.models.Role')->load('getAclFront', array('menuId' => $menuId, 'tableName' => $tableName)); foreach ($it as $ar) { $aclFront[] = array('id' => $ar->role_id, 'text' => $ar->role_name); } $data->aclBack = $aclBack; $data->aclFront = $aclFront; $this->view->setData($data); } }
function execute_edit($oldState) { $id = __Request::get('dataGridEdit_recordId'); if ($id && strtolower(__Request::get('action', '')) != 'next') { $ar = org_glizy_ObjectFactory::createModel('org.glizycms.roleManager.models.Role'); $ar->load($id); __Request::set('roleId', $ar->role_id); __Request::set('roleName', $ar->role_name); __Request::set('roleActive', $ar->role_active); __Request::set('permissions', $ar->role_permissions); $groups = array(); $it = org_glizy_ObjectFactory::createModelIterator('org.glizycms.roleManager.models.Group', 'getGroups', array('params' => array('roleId' => $id))); foreach ($it as $ar) { $groups[] = array('id' => $ar->join_FK_dest_id, 'text' => $ar->usergroup_name); } $users = array(); $it = org_glizy_ObjectFactory::createModelIterator('org.glizycms.roleManager.models.User', 'getUsers', array('params' => array('roleId' => $id))); foreach ($it as $ar) { $users[] = array('id' => $ar->join_FK_dest_id, 'text' => $ar->user_loginId); } __Request::set('groups', $groups); __Request::set('users', $users); } }
function _init() { parent::_init(); // inizialize the editing language $language = org_glizy_Session::get('glizy.editingLanguageId'); if (is_null($language)) { $ar = org_glizy_ObjectFactory::createModel('org.glizycms.core.models.Language'); $ar->language_isDefault = 1; $ar->language_FK_site_id = org_glizy_Config::get('SITE_ID'); $ar->find(); org_glizy_Session::set('glizy.editingLanguage', $ar->language_code); org_glizy_Session::set('glizy.editingLanguageId', $ar->language_id); org_glizy_Session::set('glizy.editingLanguageIsDefault', $ar->language_isDefault); $language = $ar->language_id; } org_glizy_ObjectValues::set('org.glizy', 'editingLanguageId', $language); $it = org_glizy_ObjectFactory::createModelIterator('org.glizycms.core.models.Language'); //$it = org_glizy_ObjectFactory::createModelIterator('org.glizycms.core.models.Language'); $languagesId = array(); foreach ($it as $ar) { $languagesId[] = $ar->language_id; } org_glizy_ObjectValues::set('org.glizy', 'languagesId', $languagesId); }
function __construct($id, $groupId) { parent::__construct($id, $groupId); $this->roles = array(); $this->aclMatrix = array(); if ($id) { // TODO ora la matrice è memorizzata nella sessione // e non può essere invalidata dal gestore dei ruoli per tutti gli utenti $roles = org_glizy_Session::exists('glizy.roles'); if (!empty($roles)) { $this->roles = org_glizy_Session::get('glizy.roles'); $this->aclMatrix = org_glizy_Session::get('glizy.aclMatrix'); } else { $it = org_glizy_ObjectFactory::createModelIterator('org.glizy.models.Role', 'getPermissions', array('params' => array('id' => $id, 'groupId' => $groupId))); foreach ($it as $ar) { // se il ruolo non è attivo passa al prossimo if (!$ar->role_active) { continue; } // se il ruolo non è stato ancora processato if (!$this->roles[$ar->role_id]) { $this->roles[$ar->role_id] = true; $permissions = unserialize($ar->role_permissions); // unione delle matrici dei permessi foreach ($permissions as $name => $actions) { foreach ((array) $actions as $action => $value) { $this->aclMatrix[strtolower($name)][$action] |= $value; } } } } org_glizy_Session::set('glizy.roles', $this->roles); org_glizy_Session::set('glizy.aclMatrix', $this->aclMatrix); } } }
function process_ajax() { $aColumns = array(); foreach ($this->columns as $column) { if (!in_array($column['columnName'], $aColumns)) { $aColumns[] = $column['columnName']; } } $sSearch = __Request::get('sSearch'); $filters = array(); $it = org_glizy_ObjectFactory::createModelIterator($this->getAttribute('recordClassName')); if ($it->getArType() === 'document') { $it->setOptions(array('type' => 'PUBLISHED_DRAFT')); } if ($this->getAttribute('setFiltersToQuery')) { for ($i = 0; $i < count($aColumns); $i++) { if (__Request::get('sSearch_' . $i)) { $filters[$aColumns[$i]] = __Request::get('sSearch_' . $i); } else { if ($sSearch != '' && __Request::get('bSearchable_' . $i) == "true") { $filters[$aColumns[$i]] = $sSearch; } } } $it->load($this->getAttribute('query'), array('filters' => $filters)); } else { $it->load($this->getAttribute('query')); if (method_exists($it, 'showAll')) { $it->showAll(); } if ($this->getAttribute('fullTextSearch') && $sSearch) { $it->where('fulltext', '%' . $sSearch . '%', 'ILIKE'); } else { for ($i = 0; $i < count($aColumns); $i++) { if (__Request::get('sSearch_' . $i)) { $filters[$aColumns[$i]] = array('value' => __Request::get('sSearch_' . $i), 'condition' => 'LIKE'); } else { if ($sSearch != '' && __Request::get('bSearchable_' . $i) == "true") { $filters[$aColumns[$i]] = array('value' => '%' . $sSearch . '%', 'condition' => 'LIKE'); } } } if (!empty($filters)) { if ($this->getAttribute('queryOperator') === 'OR') { $it->setOrFilters($filters); } else { $it->setFilters($filters); } } } } // Ordering if (__Request::exists('iSortCol_0')) { $iSortingCols = intval(__Request::get('iSortingCols')); for ($i = 0; $i < $iSortingCols; $i++) { if (__Request::get('bSortable_' . intval(__Request::get('iSortCol_' . $i))) == "true") { $order = $aColumns[intval(__Request::get('iSortCol_' . $i))]; $order_dir = __Request::get('sSortDir_' . $i); $it->orderBy($order, $order_dir); break; } } } // Paging if (__Request::get('iDisplayStart', -1) != -1) { $it->limit(array(__Request::get('iDisplayStart'), __Request::get('iDisplayLength', -1))); } $aaData = array(); if ($this->getAttribute('dbDebug')) { org_glizy_dataAccessDoctrine_DataAccess::enableLogging(); } try { foreach ($it as $row) { $rowToInsert = array(); foreach ($this->columns as $column) { if ($column['acl']) { if (!$this->_user->acl($column['acl']['service'], $column['acl']['action'])) { continue; } } $value = $row->{$column}['columnName']; if ($column['renderCell']) { if (!is_object($column['renderCell'])) { $column['renderCell'] = org_glizy_ObjectFactory::createObject($column['renderCell'], $this->_application); } if (is_object($column['renderCell'])) { $value = $column['renderCell']->renderCell($row->getId(), $value, $row, $column['columnName']); } } if (is_object($value)) { $value = json_encode($value); } $rowToInsert[] = $value; } $aaData[] = $rowToInsert; } } catch (Exception $e) { var_dump($e); } if ($this->getAttribute('dbDebug')) { org_glizy_dataAccessDoctrine_DataAccess::disableLogging(); die; } $output = array("sEcho" => intval(__Request::get('sEcho')), "iTotalRecords" => $it->count(), "iTotalDisplayRecords" => $it->count(), "aaData" => $aaData); return $output; }
function getDataFromPageType($pageType, $timestamp) { $it = org_glizy_ObjectFactory::createModelIterator('org.glizycms.core.models.Menu'); $it->where('menu_pageType', $pageType); if ($timestamp) { $it->where('menu_modificationDate', date('d/m/Y H:i:s', $timestamp), '>'); } $result = array(); foreach ($it as $ar) { $menuId = $ar->getId(); $contentProxy = org_glizy_ObjectFactory::createObject('org.glizycms.contents.models.proxy.ContentProxy'); $item = $contentProxy->readContentFromMenu($menuId, org_glizy_ObjectValues::get('org.glizy', 'editingLanguageId')); $item->externalId = $item->__id; $item->title = $item->__title; foreach ($item as $k => $v) { if (strpos($k, '__') === 0) { unset($item->{$k}); } } imageAbsoluteUrl($item, 'banner'); imageAbsoluteUrl($item, 'appImage'); mediaAbsoluteUrl($item, 'video'); foreach ((array) $item->images->image as $i => $image) { $obj = new StdClass(); $obj->image = $image; imageAbsoluteUrl($obj, 'image'); $item->images->title[$i] = $obj->imageTitle; $item->images->url[$i] = $obj->imageUrl; } unset($item->images->image); foreach ((array) $item->attaches->media as $i => $media) { $obj = new StdClass(); $obj->media = $media; mediaAbsoluteUrl($obj, 'media'); $item->attaches->title[$i] = $obj->mediaTitle; $item->attaches->url[$i] = $obj->mediaUrl; } unset($item->attaches->media); $result[] = $item; } return $result; }
private function addComments($value) { $it = org_glizy_ObjectFactory::createModelIterator('movio.modules.storyteller.models.Comment')->load('getCommentFromStory', array('menuId' => $this->pageId, 'hash' => $value->hash)); $value->comments = $it; $value->numComments = $it->count(); // captcha $this->captchaBuilder->build(); $this->sessionEx->set('captcha' . $value->hash, $this->captchaBuilder->getPhrase(), GLZ_SESSION_EX_VOLATILE); $value->captcha = '<img src="' . $this->captchaBuilder->inline() . '" />'; $value->formAuthor = $this->sessionEx->get($value->hash . '_author', ''); $value->formEmail = $this->sessionEx->get($value->hash . '_email', ''); $value->formText = $this->sessionEx->get($value->hash . '_text', ''); $value->formError = $this->sessionEx->get($value->hash . '_error', ''); }
/** * Render * * @return void * @access public */ function render($outputMode = NULL, $skipChilds = false) { $from = ''; $until = ''; $set = ''; $limitStart = 0; if (__Request::exists('resumptionToken')) { if (!__Request::exists('from') && !__Request::exists('until') && !__Request::exists('set') && !__Request::exists('metadataPrefix')) { // TODO controllare la data di scadenza del token $tokenId = __Request::get('resumptionToken'); $fileName = __Paths::get('CACHE') . $tokenId; if (file_exists($fileName)) { $info = unserialize(file_get_contents($fileName)); $limitStart = $info['limitEnd']; $filters = $info['filters']; $metadataPrefix = $info['metadataPrefix']; } else { $this->_application->setError('badResumptionToken', '', $tokenId); return; } } else { $this->_application->setError('exclusiveArgument'); return; } } else { // controlla i parametri ricevuti if (__Request::exists('from')) { $from = __Request::get('from'); if (!org_glizy_oaipmh_OaiPmh::checkDateFormat($from)) { $this->_application->setError('badGranularity', 'from', $from); return; } } if (__Request::exists('until')) { $until = __Request::get('until'); if (!org_glizy_oaipmh_OaiPmh::checkDateFormat($until)) { $this->_application->setError('badGranularity', 'until', $until); return; } } if (__Request::exists('set')) { $set = __Request::get('set'); } if (__Request::exists('metadataPrefix')) { $metadataPrefix = __Request::get('metadataPrefix'); } else { $this->_application->setError('missingArgument', 'metadataPrefix'); return; } $filters = array(); if ($from) { $filters[] = 'picoqueue_date >= ' . org_glizy_dataAccess_DataAccess::qstr($from); } if ($until) { $filters[] = 'picoqueue_date <= ' . org_glizy_dataAccess_DataAccess::qstr($until); } if ($set) { $filters[] = 'picoqueue_recordModule = ' . org_glizy_dataAccess_DataAccess::qstr($set); } } $metadata = $this->_application->getMetadataFormat(); if (isset($metadata[$metadataPrefix])) { // TODO //$inc_record = $metadata[$metadataPrefix]['myhandler']; } else { $this->_application->setError('cannotDisseminateFormat', 'metadataPrefix', $metadataPrefix); return; } $limitLength = __Config::get('oaipmh.maxRecords'); $it = org_glizy_ObjectFactory::createModelIterator('org.glizy.oaipmh.models.PicoQueue', 'all', array('filters' => $filters, 'limit' => array($limitStart, $limitLength), 'numRows' => true)); $num_rows = $it->count(); if ($num_rows > 0) { $oaiPrefix = __Config::get('oaipmh.oaiPrefix'); $countrec = 0; $output = '<ListRecords>'; $output .= org_glizy_oaipmh_OaiPmh::createResumptionToken('ListRecords', array('numRows' => $num_rows, 'limitStart' => $limitStart, 'limitEnd' => $limitStart + $limitLength, 'filters' => $filters, 'metadataPrefix' => $metadataPrefix)); while ($it->hasMore()) { $countrec++; $arC = $it->current(); $it->next(); $setClass = org_glizy_ObjectFactory::createObject($arC->picoqueue_recordModule, $this->_application); if (is_null($setClass)) { continue; } $setClass->loadRecord($arC->picoqueue_recordId); $identifier = $oaiPrefix . $arC->picoqueue_identifier; $datestamp = org_glizy_oaipmh_OaiPmh::formatDatestamp($arC->picoqueue_date); $status_deleted = $arC->picoqueue_action == 'delete' ? true : false; $output .= '<record>'; $output .= '<header'; if ($status_deleted) { $output .= ' status="deleted"'; } $output .= '>'; // use xmlrecord since we use stuff from database $output .= '<identifier>' . org_glizy_oaipmh_OaiPmh::encode($identifier) . '</identifier>'; $output .= '<datestamp>' . org_glizy_oaipmh_OaiPmh::encode($datestamp) . '</datestamp>'; if (!$status_deleted) { $output .= '<setSpec>' . org_glizy_oaipmh_OaiPmh::encode($arC->picoqueue_recordModule) . '</setSpec>'; } $output .= '</header>'; $output .= '<metadata>'; $output .= $setClass->getRecord($identifier); $output .= '</metadata>'; $output .= '</record>'; } $output .= '</ListRecords>'; $this->addOutputCode($output); } else { $this->_application->setError('noRecordsMatch'); } }
public function getDocumentsWithTerm($termId) { $application = org_glizy_ObjectValues::get('org.glizy', 'application'); $entityTypeService = $application->retrieveProxy('movio.modules.ontologybuilder.service.EntityTypeService'); $entityResolver = org_glizy_objectFactory::createObject('movio.modules.ontologybuilder.EntityResolver'); $menuMap = array(); // TODO: non va bene l'implementazione perché scorre tutti i documenti // eseguire un filtro sui documenti del tipo di entità che ha una campo di tipo dizionario $it = org_glizy_ObjectFactory::createModelIterator('movio.modules.ontologybuilder.models.EntityDocument')->load('All'); $result = array(); foreach ($it as $ar) { $entityTypeId = $entityTypeService->getEntityTypeId($ar->getType()); if (!isset($menuMap[$entityTypeId])) { $arMenu = $entityResolver->getMenuVisibleEntity($entityTypeId); $menuMap[$entityTypeId] = $arMenu; } else { $arMenu = $menuMap[$entityTypeId]; } $thesaurusAttribute = $entityTypeService->getAttributeByType($entityTypeId, 'attribute.thesaurus'); $descriptionAttribute = $entityTypeService->getDescriptionAttribute($entityTypeId); // se l'entità di questo documento ha un campo di tipo thesaurus if ($arMenu && $thesaurusAttribute) { $thesaurusAttribute = $this->prepareThesaurusAttribute($thesaurusAttribute); foreach ($thesaurusAttribute as $attribute) { if ($ar->keyInDataExists($attribute)) { if (!is_array($ar->{$attribute})) { continue; } // si cerca nei tag il termine con id uguale a termId foreach ($ar->{$attribute} as $term) { if ($term->id == $termId) { $document_id = $ar->getId(); $result[] = array('id' => $document_id, 'title' => $ar->title, 'description' => glz_strtrim($descriptionAttribute && $ar->keyInDataExists($descriptionAttribute) ? $ar->{$descriptionAttribute} : '', 300), 'url' => __Routing::makeUrl('showEntityDetail', array('pageId' => $arMenu->id, 'entityTypeId' => $entityTypeId, 'document_id' => $document_id))); break; } } } } } } return $result; }
public function deleteAllByType($type) { $it = org_glizy_ObjectFactory::createModelIterator('org.glizycms.speakingUrl.models.SpeakingUrl'); $it->load('deleteAllByType', array(':type' => $type)); $it->exec(); }
public function invalidate() { $application =& org_glizy_ObjectValues::get('org.glizy', 'application'); $siteId = org_glizy_ObjectValues::get('org.glizy', 'siteId'); $iterator = org_glizy_ObjectFactory::createModelIterator('org.glizycms.core.models.Language', 'all'); foreach ($iterator as $ar) { $this->cache->remove('org_glizycms_core_application_SiteMapDB::loadTree' . $siteId . '_' . $ar->language_id, array()); } }
public function delete() { $this->iterator = org_glizy_ObjectFactory::createModelIterator($this->className)->where($this->key, $this->parent->getId())->where($this->objectField, $this->objectName); foreach ($this->iterator as $ar) { $ar->delete(); } }
/** * Add a new menu * * @param string $title the menu title * @param int $parent the menu parent id * @param string $pageType the menu pageType * @return int new menu id */ public function addMenu($title, $parent, $pageType, $type = 'PAGE') { $userId = org_glizy_ObjectValues::get('org.glizy', 'userId'); $menus = org_glizy_ObjectFactory::createModelIterator('org.glizycms.core.models.Menu'); $menus->load('getChildrenMenuInOrder', array('params' => array('menuId' => $parent))); $order = $menus->count() + 1; $application = org_glizy_ObjectValues::get('org.glizy', 'application'); $user = $application->getCurrentUser(); // add the menu $ar = org_glizy_ObjectFactory::createModel('org.glizycms.core.models.Menu'); $ar->menu_parentId = $parent; $ar->menu_pageType = $pageType; $ar->menu_order = $order; $ar->menu_type = $type; $ar->menu_hasPreview = '1'; $ar->menu_url = ''; $ar->menu_creationDate = new org_glizy_types_DateTime(); $ar->menu_modificationDate = new org_glizy_types_DateTime(); $ar->menudetail_title = $title; $ar->menudetail_isVisible = $user->acl(__Config::get('SITEMAP_ID'), 'publish') === true ? 1 : 0; $pageId = $ar->save(); // reorder all brothers menus $this->moveMenu($pageId, $order, $parent); /* // add the details for each languages $languages = org_glizy_ObjectFactory::createModelIterator('org.glizycms.core.models.Language'); $languages->select('*')->orderBy('language_order'); foreach ($languages as $ar) { $ar2 = org_glizy_ObjectFactory::createModel('org.glizycms.core.models.MenuDetail'); $ar2->menudetail_FK_menu_id = $pageId; $ar2->menudetail_FK_language_id = $ar->language_id; $ar2->menudetail_title = $title; // TODO dublin core // if ( !empty( $values['pageParent'] ) ) // { // $arParent = org_glizy_ObjectFactory::createModel('org.glizy.models.MenuDetail'); // $arParent->modifyField('menudetail_FK_language_id', 'defaultSelectValue', NULL); // $result = $arParent->find(array('menudetail_FK_menu_id' => $values['pageParent'], 'menudetail_FK_language_id' => $this->_application->getEditingLanguageId())); // $ar2->menudetail_keywords = $arParent->menudetail_keywords; // $ar2->menudetail_description = $arParent->menudetail_description; // $ar2->menudetail_subject = $arParent->menudetail_subject; // $ar2->menudetail_creator = $arParent->menudetail_creator; // $ar2->menudetail_publisher = $arParent->menudetail_publisher; // $ar2->menudetail_contributor = $arParent->menudetail_contributor; // $ar2->menudetail_type = $arParent->menudetail_type; // $ar2->menudetail_identifier = $arParent->menudetail_identifier; // $ar2->menudetail_source = $arParent->menudetail_source; // $ar2->menudetail_relation = $arParent->menudetail_relation; // $ar2->menudetail_coverage = $arParent->menudetail_coverage; // } // else // { // $ar2->menudetail_keywords = ''; // $ar2->menudetail_description = ''; // $ar2->menudetail_subject = ''; // $ar2->menudetail_creator = ''; // $ar2->menudetail_publisher = ''; // $ar2->menudetail_contributor = ''; // $ar2->menudetail_type = ''; // $ar2->menudetail_identifier = ''; // $ar2->menudetail_source = ''; // $ar2->menudetail_relation = ''; // $ar2->menudetail_coverage = ''; // } // TODO acl associare a publish su sitemap $ar2->menudetail_isVisible = 1; //$user->acl('SiteMap','visible')===true ? '1' : '0'; $ar2->save(); } */ // if ( __Config::get( 'ACL_ENABLED' ) ) // { // __Session::remove( 'glizy.aclBack' ); // __Session::remove( 'glizy.aclFront' ); // } $this->invalidateSitemapCache(); $evt = array('type' => org_glizycms_contents_events_Menu::ADD, 'data' => $pageId); $this->dispatchEvent($evt); return $pageId; }
public function export($languageId = 1, $languageCode = null, $menuIdArray = array(), $title = null, $subtitle = null, $creditPageId = null, $isExhibitionActive = null) { __Paths::set('APPLICATION_TEMPLATE_DEFAULT', __Paths::get('STATIC_DIR') . 'movio/templates/Default/'); $menuIdArray = array_flip($menuIdArray); $menuIdArray = array_fill_keys(array_keys($menuIdArray), 1); $this->medias = array(); $contentProxy = org_glizy_ObjectFactory::createObject('org.glizycms.contents.models.proxy.ContentProxy'); // scorre tutti i menù $menus = org_glizy_ObjectFactory::createModelIterator('org.glizycms.core.models.Menu'); $menus->load('getAllMenu', array('params' => array('languageId' => $languageId))); foreach ($menus as $ar) { $menuId = $ar->menu_id; // salta tutte le pagine che non sono in menuIdArray if (!$menuIdArray[$menuId]) { continue; } $contentVO = $contentProxy->readContentFromMenu($menuId, $languageId); $contentJson = array(); foreach ($contentVO as $k => $v) { if ($k == '__title') { $contentJson['title'] = $v; continue; } if (@strpos($k, '__') === 0) { continue; } if (is_object($v)) { $contentJson[$k] = $this->convertObjectToArray($v); } else { if (@strpos($v, '{"id"') === 0) { $v = $this->addMedia($v); } $contentJson[$k] = $v; } } $arMobile = org_glizy_objectFactory::createModel('movio.models.Mobilecontents'); // informaizoni da salvare per il menu: // menuId, parent, titolo, pageType, type, contenuto // salvare solo i menu visibili // creare una tabella apposta e salvarci i dati dentro // if ($ar->menudetail_isVisible) { $arMobile->content_menuId = $menuId; $arMobile->content_pageType = $ar->menu_pageType; $arMobile->content_parent = $ar->menu_parentId; $arMobile->content_type = $ar->menu_type; $arMobile->content_title = $ar->menudetail_title; if ($arMobile->content_pageType == 'Storyteller') { $contentJson = $this->processStoryTeller($contentJson); } elseif ($arMobile->content_pageType == 'Photogallery') { $contentJson = $this->processPhotoGallery($contentJson); } elseif ($arMobile->content_pageType == 'Photogallery_category') { $arMobile->content_pageType = 'Photogallery'; $contentJson = $this->processPhotoGalleryCategory($contentJson); } elseif ($arMobile->content_pageType == 'ImageHotspot') { $contentJson = $this->processImageHotspot($contentJson); } elseif ($arMobile->content_pageType == 'Timeline') { $contentJson = $this->processTimeline($menuId, $contentJson); } elseif ($arMobile->content_pageType == 'Page') { $contentJson = $this->processPage($contentJson); } elseif ($arMobile->content_pageType == 'Exhibition') { $contentJson = $this->processExhibition($contentJson); $contentJson['isActive'] = $isExhibitionActive ? 1 : 0; } elseif ($arMobile->content_pageType == 'DigitalExhibition') { $contentJson = $this->processDigitalExhibition($contentJson); } elseif ($arMobile->content_pageType == 'Home') { $contentJson['title'] = $title; $contentJson['subtitle'] = $subtitle; } elseif ($arMobile->content_pageType == 'Video') { $contentJson = $this->processVideo($contentJson); } elseif ($arMobile->content_pageType == 'Cover') { $contentJson = $this->processCover($contentJson); } elseif ($arMobile->content_pageType == 'GoogleMap') { $contentJson = $this->processGoogleMap($contentJson); } elseif ($arMobile->content_pageType == 'Graph') { $contentJson = $this->processGraph($contentJson, $menuId, $languageCode); } if ($menuId == $creditPageId) { $arMobile->content_pageType = 'Credits'; $arMobile->content_parent = 0; } $arMobile->content_content = json_encode($contentJson); $contentId = $arMobile->save(); $it = org_glizy_objectFactory::createModelIterator('org.glizycms.core.models.Content'); $fulltextAr = $it->where("id", $menuId)->whereLanguageIs($languageId)->selectIndex('fulltext', 'document_index_fulltext_name', 'document_index_fulltext_value')->first(); if ($fulltextAr->document_index_fulltext_value) { $ar = org_glizy_objectFactory::createModel('movio.modules.publishApp.models.Mobilefulltext'); $ar->mobilefulltext_FK_content_id = $contentId; $ar->mobilefulltext_text = str_replace(' ##', '', $fulltextAr->document_index_fulltext_value); $ar->mobilefulltext_title = $contentJson['title']; $ar->mobilefulltext_subtitle = $contentJson['subtitle']; $ar->save(); } // quando menu_pageType è Entity c'è da scorrere tutti i contenuti dell'entità // e caricare i dati // salvare // documenId, titolo, contenuto if ($arMobile->content_pageType == 'Entity') { $parent = $arMobile->content_id; $application = org_glizy_ObjectValues::get('org.glizy', 'application'); $it = __ObjectFactory::createModelIterator('movio.modules.ontologybuilder.models.EntityDocument'); $it->whereTypeIs('entity' . $contentJson['entitySelect']); foreach ($it as $arEntitySelect) { $documentId = $arEntitySelect->document_id; $c = __ObjectFactory::createComponent('movio.modules.ontologybuilder.views.components.EntityToJSON', $application, $parent, 'glz:EntityToJSON', $documentId); $c->setAttribute('visible', true); $c->process(); $c->render(); $medias = $c->getMedias(); $this->addMediaArray($medias); $graphCode = $c->getGraph(); $this->addGraph($languageCode, $documentId, $graphCode, 'document'); $jsonEntity = $c->getJson(); $jsonEntity['graph'] = 'graph/document/' . $languageCode . '/' . $documentId . '.svg'; $jsonEntity['content'] = $this->processText($jsonEntity['content']); $arContentMobile = org_glizy_objectFactory::createModel('movio.models.Mobilecontents'); $arContentMobile->content_documentId = $documentId; $arContentMobile->content_pageType = 'EntityChild'; $arContentMobile->content_parent = $parent; $arContentMobile->content_title = $arEntitySelect->title; $arContentMobile->content_content = json_encode($jsonEntity); $contentId = $arContentMobile->save(); $fulltextAr = org_glizy_objectFactory::createModel('movio.modules.publishApp.models.DocumentIndexFulltext'); $result = $fulltextAr->find(array('document_index_fulltext_FK_document_detail_id' => $arEntitySelect->document_detail_id)); if ($result) { $ar = org_glizy_objectFactory::createModel('movio.modules.publishApp.models.Mobilefulltext'); $ar->mobilefulltext_FK_content_id = $contentId; $ar->mobilefulltext_text = str_replace(' ##', '', $fulltextAr->document_index_fulltext_value); $ar->mobilefulltext_title = $arEntitySelect->title; $ar->mobilefulltext_subtitle = $arEntitySelect->subtitle; $ar->save(); } } } } } }